1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-14 02:23:01 +02:00

a498fd7: Fixed /rampantSetAIState command around invalid or missing parameters

This commit is contained in:
Aaron Veden 2023-01-19 20:43:41 -08:00
parent fab7f0cc6c
commit 14b2270bdd
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
4 changed files with 21 additions and 18 deletions

View File

@ -51,6 +51,7 @@ Version: 3.2.0
- Fixed projectiles not being able to collide with spawner eggs and wasps
- Fixed bases being able to mutate to the same factions
- Fixed players disconnecting on multiplayer could leave residual player pheromone that never dissipated
- Fixed /rampantSetAIState command could error if not provide correct parameters or didn't display a message if parameters were missing
Optimizations:
- Moved most constants out of global
- Removed new enemy variations setting

View File

@ -1344,29 +1344,31 @@ local function rampantSetAIState(event)
end
end
if target ~= constants.BASE_AI_STATE_PEACEFUL and
target ~= constants.BASE_AI_STATE_AGGRESSIVE and
target ~= constants.BASE_AI_STATE_RAIDING and
target ~= constants.BASE_AI_STATE_MIGRATING and
target ~= constants.BASE_AI_STATE_SIEGE and
target ~= constants.BASE_AI_STATE_ONSLAUGHT
then
if not target or not constants.STATE_ENGLISH[target] then
game.print(target .. " is not a valid state. /rampantSetAIState <stateId> <baseId>")
return
else
if not baseId then
game.print("Invalid baseId. /rampantSetAIState <stateId> <baseId>")
return
end
local base = universe.bases[baseId]
if not base then
game.print(baseId .. " is not a valid base. /rampantSetAIState <stateId> <baseId>")
return
end
local previousState = base.stateAI
base.stateAI = target
local surface = base.map.surface
if not surface.valid then
game.print("Base is invalid because surface is invalid")
return
end
game.print("id:" .. baseId .. " on surface:" .. surface.name .. " is now in " .. constants.stateEnglish[base.stateAI])
game.print("id:" .. baseId .. " on surface:" .. surface.name
.. " was in " .. constants.STATE_ENGLISH[previousState]
.. " is now in " .. constants.STATE_ENGLISH[base.stateAI])
end
else
game.print("Missing parameters: /rampantSetAIState <stateId> <baseId>")
end
end

View File

@ -359,7 +359,7 @@ local function temperamentPlanner(base, evolutionLevel)
base.builtEnemyBuilding .. ", iCB:" .. base.ionCannonBlasts .. ", aB:" ..
base.artilleryBlasts .. ", temp:" .. base.temperament .. ", tempScore:" .. base.temperamentScore ..
", points:" .. base.points .. ", unitPoints:" .. base.unitPoints .. ", state:" ..
constants.stateEnglish[base.stateAI] .. ", surface:" .. base.map.surface.index .. " [" ..
constants.STATE_ENGLISH[base.stateAI] .. ", surface:" .. base.map.surface.index .. " [" ..
base.map.surface.name .. "]" .. ", aS:" .. universe.squadCount .. ", aB:" .. universe.builderCount ..
", atkSize:" .. universe.attackWaveSize .. ", stlSize:" .. universe.settlerWaveSize ..
", formGroup:" .. universe.formSquadThreshold .. ", sAgg:".. base.sentAggressiveGroups ..
@ -555,7 +555,7 @@ local function processState(universe, base, tick)
base.stateAITick = randomTickEvent(universe.random, tick, BASE_AI_MIN_STATE_DURATION, BASE_AI_MAX_STATE_DURATION)
if universe.printAIStateChanges then
game.print(base.id .. ": AI is now: " .. constants.stateEnglish[base.stateAI] .. ", Next state change is in "
game.print(base.id .. ": AI is now: " .. constants.STATE_ENGLISH[base.stateAI] .. ", Next state change is in "
.. string.format("%.2f", (base.stateAITick - tick) / (60*60)) .. " minutes @ " ..
getTimeStringFromTick(base.stateAITick) .. " playtime")
end

View File

@ -117,13 +117,13 @@ constants.BASE_AI_STATE_MIGRATING = 5
constants.BASE_AI_STATE_SIEGE = 6
constants.BASE_AI_STATE_ONSLAUGHT = 7
constants.stateEnglish = {}
constants.stateEnglish[constants.BASE_AI_STATE_PEACEFUL] = "AI_STATE_PEACEFUL"
constants.stateEnglish[constants.BASE_AI_STATE_AGGRESSIVE] = "AI_STATE_AGGRESSIVE"
constants.stateEnglish[constants.BASE_AI_STATE_RAIDING] = "AI_STATE_RAIDING"
constants.stateEnglish[constants.BASE_AI_STATE_MIGRATING] = "AI_STATE_MIGRATING"
constants.stateEnglish[constants.BASE_AI_STATE_SIEGE] = "AI_STATE_SIEGE"
constants.stateEnglish[constants.BASE_AI_STATE_ONSLAUGHT] = "AI_STATE_ONSLAUGHT"
constants.STATE_ENGLISH = {}
constants.STATE_ENGLISH[constants.BASE_AI_STATE_PEACEFUL] = "AI_STATE_PEACEFUL"
constants.STATE_ENGLISH[constants.BASE_AI_STATE_AGGRESSIVE] = "AI_STATE_AGGRESSIVE"
constants.STATE_ENGLISH[constants.BASE_AI_STATE_RAIDING] = "AI_STATE_RAIDING"
constants.STATE_ENGLISH[constants.BASE_AI_STATE_MIGRATING] = "AI_STATE_MIGRATING"
constants.STATE_ENGLISH[constants.BASE_AI_STATE_SIEGE] = "AI_STATE_SIEGE"
constants.STATE_ENGLISH[constants.BASE_AI_STATE_ONSLAUGHT] = "AI_STATE_ONSLAUGHT"
constants.BASE_GENERATION_STATE_DORMANT = 0
constants.BASE_GENERATION_STATE_ACTIVE = 1