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

766913c: Ensure non settler squads don't form unless base or player

pheromone is greater than 0.001
This commit is contained in:
Aaron Veden 2023-01-07 21:47:37 -08:00
parent 8006a047f0
commit 97d19407ac
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 32 additions and 0 deletions

View File

@ -34,6 +34,7 @@ Version: 3.2.0
- Bases can no longer spend points that exceed the overflow limit (Dagothur)
- Fixed death pheromone spread being initialized to 0 instead of max negative number causing victory scent to spread incorrectly
- Fixed chunk scanning have a false negative for impassable chunks
- Fixed non-settler unit groups being created when player or base pheromone is effectively zero
Optimizations:
- Moved most constants out of global
- Removed new enemy variations setting

View File

@ -54,6 +54,8 @@ local RECOVER_WORM_COST = constants.RECOVER_WORM_COST
local RETREAT_GRAB_RADIUS = constants.RETREAT_GRAB_RADIUS
local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS
local BASE_PHEROMONE = constants.BASE_PHEROMONE
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
local UNIT_DEATH_POINT_COST = constants.UNIT_DEATH_POINT_COST
@ -783,6 +785,11 @@ local function onUnitGroupCreated(event)
return
end
if not settler and (chunk[BASE_PHEROMONE] < 0.0001) and (chunk[PLAYER_PHEROMONE] < 0.0001) then
group.destroy()
return
end
squad = createSquad(nil, map, group, settler, base)
universe.groupNumberToSquad[group.group_number] = squad
@ -808,6 +815,11 @@ local function onUnitGroupCreated(event)
return
end
if not settler and chunk[BASE_PHEROMONE] < 0.0001 and chunk[PLAYER_PHEROMONE] < 0.0001 then
group.destroy()
return
end
squad = createSquad(nil, map, group, settler, base)
universe.groupNumberToSquad[group.group_number] = squad
@ -840,6 +852,12 @@ local function onGroupFinishedGathering(event)
group.destroy()
end
else
local chunk = getChunkByPosition(map, squad.group.position)
if (chunk ~= -1) and (chunk[BASE_PHEROMONE] < 0.0001) and (chunk[PLAYER_PHEROMONE] < 0.0001) then
group.destroy()
return
end
if (universe.squadCount <= universe.AI_MAX_SQUAD_COUNT) then
squadDispatch(map, squad, event.tick)
else
@ -868,6 +886,11 @@ local function onGroupFinishedGathering(event)
return
end
if not settler and (chunk[BASE_PHEROMONE] < 0.0001) and (chunk[PLAYER_PHEROMONE] < 0.0001) then
group.destroy()
return
end
squad = createSquad(nil, map, group, settler, base)
universe.groupNumberToSquad[group.group_number] = squad
if settler then

View File

@ -272,6 +272,10 @@ function aiAttackWave.formVengenceSquad(map, chunk, base)
and ((base.unitPoints - AI_VENGENCE_SQUAD_COST) > 0)
and (map.random() < universe.formSquadThreshold)
then
if (chunk[BASE_PHEROMONE] < 0.0001) or (chunk[PLAYER_PHEROMONE] < 0.0001) then
return
end
local surface = map.surface
local squadPath, squadDirection = scoreNeighborsForFormation(getNeighborChunks(map, chunk.x, chunk.y),
validUnitGroupLocation,
@ -364,6 +368,10 @@ function aiAttackWave.formSquads(map, chunk, base)
and ((base.unitPoints - AI_SQUAD_COST) > 0)
and (map.random() < universe.formSquadThreshold)
then
if (chunk[BASE_PHEROMONE] < 0.0001) or (chunk[PLAYER_PHEROMONE] < 0.0001) then
return
end
local surface = map.surface
local squadPath, squadDirection = scoreNeighborsForFormation(getNeighborChunks(map, chunk.x, chunk.y),
validUnitGroupLocation,