From c1b83097537f2e1d7c5e00d2f70e3305d248259d Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 29 Nov 2025 11:46:16 +0200 Subject: [PATCH] Expand UB_SetNumberJa25EnemiesInSurfaceSector * Allow adding jeeps and robots to sectors now * From Lua side, it is now possible to add differing amount of arguments to the function. Minimum required is 3 (sector x & y and amount of admins) So all of the following examples will work correctly: - UB_SetNumberJa25EnemiesInSurfaceSector( x, y, ubNumAdmins ) - UB_SetNumberJa25EnemiesInSurfaceSector( x, y, ubNumAdmins, ubNumTroops ) - - UB_SetNumberJa25EnemiesInSurfaceSector( x, y, ubNumAdmins, ubNumTroops,ubNumElites ) - UB_SetNumberJa25EnemiesInSurfaceSector( x, y, ubNumAdmins, ubNumTroops,ubNumElites, ubNumTanks ) - UB_SetNumberJa25EnemiesInSurfaceSector( x, y, ubNumAdmins, ubNumTroops,ubNumElites, ubNumTanks , ubNumJeeps ) - UB_SetNumberJa25EnemiesInSurfaceSector( x, y, ubNumAdmins, ubNumTroops,ubNumElites, ubNumTanks , ubNumJeeps, ubNumRobots ) --- Strategic/LuaInitNPCs.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index edc706452..d6fd165bc 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -2243,18 +2243,38 @@ static int l_SetNumberOfJa25BloodCatsInSector(lua_State* L) static int l_SetNumberJa25EnemiesInSurfaceSector(lua_State* L) { - if (lua_gettop(L) >= 6) + if ( lua_gettop(L) >= 3 ) { INT16 sSectorX = lua_tointeger(L, 1); INT16 sSectorY = lua_tointeger(L, 2); UINT8 ubNumAdmins = lua_tointeger(L, 3); - UINT8 ubNumTroops = lua_tointeger(L, 4); - UINT8 ubNumElites = lua_tointeger(L, 5); - UINT8 ubNumTanks = lua_tointeger(L, 6); - //TODO: expand lua call to include these two + UINT8 ubNumTroops = 0; + UINT8 ubNumElites = 0; + UINT8 ubNumTanks = 0; UINT8 ubNumJeeps = 0; UINT8 ubNumRobots = 0; + if ( lua_gettop(L) >= 4 ) + { + ubNumTroops = lua_tointeger(L, 4); + } + if ( lua_gettop(L) >= 5 ) + { + ubNumElites = lua_tointeger(L, 5); + } + if ( lua_gettop(L) >= 6 ) + { + ubNumTanks = lua_tointeger(L, 6); + } + if ( lua_gettop(L) >= 7 ) + { + ubNumJeeps = lua_tointeger(L, 7); + } + if ( lua_gettop(L) >= 8 ) + { + ubNumRobots = lua_tointeger(L, 8); + } + SetNumberJa25EnemiesInSurfaceSector(SECTOR(sSectorX, sSectorY), ubNumAdmins, ubNumTroops, ubNumElites, ubNumTanks, ubNumJeeps, ubNumRobots); }