From 0c7813a46baed4a826b62fe793b2b340b664cab7 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 11 Oct 2025 11:39:42 +0300 Subject: [PATCH] Supply ProfileID to LUA scripts instead of SoldierID Lua scripts expect to receive the same profileID value back from l_FindSolderByProfileID() that is supplied to it on the script side. This is a bit suboptimal as we constantly keep searching for the correct soldier on different calls to C++ side with the way it works now. --- Strategic/LuaInitNPCs.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index 4992a7536..edc706452 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -8657,7 +8657,7 @@ static int l_TileIsOutOfBoundsClosestPC(lua_State* L) static int l_FindSoldierByProfileID(lua_State* L) { SOLDIERTYPE* pSoldier; - UINT16 id = NOBODY; + UINT8 foundProfileID = -1; UINT16 ubLoop = 0, ubLoopLimit = MAX_NUM_SOLDIERS; if (lua_gettop(L)) @@ -8668,11 +8668,12 @@ static int l_FindSoldierByProfileID(lua_State* L) { if (pSoldier->bActive && pSoldier->ubProfile == ubTargetNPC) { - id = pSoldier->ubID; + foundProfileID = pSoldier->ubProfile; + break; } } - lua_pushinteger(L, id); + lua_pushinteger(L, foundProfileID); } return 1; @@ -8695,6 +8696,7 @@ static int l_FindSoldierByProfileIDBool(lua_State* L) if (pSoldier->bActive && pSoldier->ubProfile == ubTargetNPC) { ProfBool = TRUE; + break; } }