1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-17 20:58:35 +02:00

FACTO-96: Fixed rampantSetAIState command for multiple AIs per surface

This commit is contained in:
Aaron Veden 2022-04-09 17:54:17 -07:00
parent 2d9b87e127
commit d671709e1f
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
2 changed files with 20 additions and 15 deletions

View File

@ -25,6 +25,7 @@ Version: 3.0.0
- Fixed Krastorio2 on_force_created playerforces being nil
- Fixed enemy map scan creating bases unnecessarily
- Fixed base.index reference error in displaying ai state
- Fixed rampantSetAIState command to work with multiple ais per surface
---------------------------------------------------------------------------------------------------
Version: 2.2.0

View File

@ -1072,20 +1072,18 @@ remote.add_interface("rampantTests",
)
local function rampantSetAIState(event)
local surfaceIndex = game.players[event.player_index].surface.index
local map = universe.maps[surfaceIndex]
if not map then
return
end
game.print(map.surface.name .. " is in " .. constants.stateEnglish[map.state])
if event.parameter then
local target = tonumber(event.parameter)
local target
local baseId
local i = 0
if (target == nil) then
game.print("invalid param")
return
for m in string.gmatch(event.parameter, "%d+") do
if i == 0 then
i = i + 1
target = tonumber(m)
else
baseId = tonumber(m)
end
end
if target ~= constants.BASE_AI_STATE_PEACEFUL and
@ -1095,11 +1093,17 @@ local function rampantSetAIState(event)
target ~= constants.BASE_AI_STATE_SIEGE and
target ~= constants.BASE_AI_STATE_ONSLAUGHT
then
game.print(target .. " is not a valid state")
game.print(target .. " is not a valid state. /rampantSetAIState <stateId> <baseId>")
return
else
map.state = target
game.print(map.surface.name .. " is now in " .. constants.stateEnglish[map.state])
local base = universe.bases[baseId]
if not base then
game.print(baseId .. " is not a valid base. /rampantSetAIState <stateId> <baseId>")
return
end
base.stateAI = target
local surface = base.surface
game.print("id:" .. baseId .. " on surface:" .. surface.name .. " is now in " .. constants.stateEnglish[base.stateAI])
end
end
end