Fixed console on Win11 and monkey pathfinding

This commit is contained in:
Lwmte 2025-03-24 22:03:52 +01:00
parent ac77c5f9ad
commit 78e8d34c00
3 changed files with 10 additions and 4 deletions

View file

@ -9,10 +9,12 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Added live console input to perform Lua commands in realtime.
### Bug fixes
* Fixed pathfinding for friendly NPCs, such as monkeys.
* Fixed particles remaining in the level after reloading from the savegame.
* Fixed particles being canceled by fog bulbs.
* Fixed crash in case hair object is the last object in a level.
* Fixed crash with incorrectly applied animated textures on static meshes.
* Fixed console window not hiding in non-debug mode on Windows 11.
### Lua API changes
* Added missing constructor for `Collision.Probe` without room number.

View file

@ -1150,6 +1150,7 @@ bool StalkBox(ItemInfo* item, ItemInfo* enemy, int boxNumber)
{
if (enemy == nullptr || boxNumber == NO_VALUE)
return false;
auto* box = &g_Level.PathfindingBoxes[boxNumber];
int xRange = STALK_DIST + ((box->bottom - box->top) * BLOCK(1));
@ -1635,8 +1636,11 @@ void CreatureMood(ItemInfo* item, AI_INFO* AI, bool isViolent)
auto* LOT = &creature->LOT;
auto* enemy = creature->Enemy;
if (enemy == nullptr)
return;
// HACK: Fallback to bored mood from attack mood if enemy was cleared.
// Replaces previous "fix" with early exit, because it was breaking friendly NPC pathfinding. -- Lwmte, 24.03.25
if (enemy == nullptr && creature->Mood == MoodType::Attack)
creature->Mood = MoodType::Bored;
int boxNumber;
switch (creature->Mood)
@ -1645,7 +1649,7 @@ void CreatureMood(ItemInfo* item, AI_INFO* AI, bool isViolent)
boxNumber = LOT->Node[GetRandomControl() * LOT->ZoneCount >> 15].boxNumber;
if (ValidBox(item, AI->zoneNumber, boxNumber))
{
if (StalkBox(item, enemy, boxNumber) && enemy->HitPoints > 0 && creature->Enemy)
if (StalkBox(item, enemy, boxNumber) && creature->Enemy && enemy->HitPoints > 0)
{
TargetBox(LOT, boxNumber);
creature->Mood = MoodType::Bored;

View file

@ -427,7 +427,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Hide console window if mode isn't debug.
#ifndef _DEBUG
if (!DebugMode)
ShowWindow(GetConsoleWindow(), 0);
FreeConsole();
else
#endif
ConsoleThreadHandle = BeginThread(ConsoleInput, ConsoleThreadID);