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

FACTO-254: Fixed rally chunk not using correct chunk base for cost check

This commit is contained in:
Aaron Veden 2023-03-12 14:28:49 -07:00
parent 852df6d140
commit 8aa2939ff9
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 23 additions and 18 deletions

View File

@ -54,6 +54,7 @@ Version: 3.2.0
- 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
- Fixed the pheromone processing could skip the inner most chunks or the outer most chunks of a map
- Fixed rallying units didn't use the base associated with the chunk for determining cost
Optimizations:
- Moved most constants out of global
- Removed new enemy variations setting

View File

@ -183,7 +183,7 @@ local function onIonCannonFired(event)
local base = findNearbyBase(chunk)
if base then
base.ionCannonBlasts = base.ionCannonBlasts + 1
rallyUnits(chunk, event.tick, base)
rallyUnits(chunk, event.tick)
modifyBaseUnitPoints(base, 4000, "Ion Cannon")
end
end
@ -477,7 +477,7 @@ local function onDeath(event)
modifyBaseUnitPoints(base, -(20*UNIT_DEATH_POINT_COST), "20 Units Lost")
end
if (Universe.random() < Universe.rallyThreshold) and not surface.peaceful_mode then
rallyUnits(chunk, tick, base)
rallyUnits(chunk, tick)
end
if artilleryBlast then
base.artilleryBlasts = base.artilleryBlasts + 1
@ -502,7 +502,7 @@ local function onDeath(event)
elseif (entityType == "turret") then
modifyBaseUnitPoints(base, RECOVER_WORM_COST, "Worm Lost")
end
rallyUnits(chunk, tick, base)
rallyUnits(chunk, tick)
if artilleryBlast then
base.artilleryBlasts = base.artilleryBlasts + 1
end

View File

@ -1033,26 +1033,30 @@ local function scoreNeighborsForFormation(neighborChunks, validFunction, scoreFu
return highestChunk, highestDirection
end
function Squad.rallyUnits(chunk, tick, base)
if ((tick - getRallyTick(chunk) > COOLDOWN_RALLY) and (base.unitPoints >= AI_VENGENCE_SQUAD_COST)) then
setRallyTick(chunk, tick)
local cX = chunk.x
local cY = chunk.y
local startX, endX, stepX, startY, endY, stepY = visitPattern(tick % 4, cX, cY, RALLY_CRY_DISTANCE)
local vengenceQueue = Universe.vengenceQueue
local map = chunk.map
for x=startX, endX, stepX do
for y=startY, endY, stepY do
if (x ~= cX) and (y ~= cY) then
local rallyChunk = getChunkByXY(map, x, y)
if (rallyChunk ~= -1) and rallyChunk.nestCount then
function Squad.rallyUnits(chunk, tick)
if (tick - getRallyTick(chunk)) < COOLDOWN_RALLY then
return
end
setRallyTick(chunk, tick)
local cX = chunk.x
local cY = chunk.y
local startX, endX, stepX, startY, endY, stepY = visitPattern(tick % 4, cX, cY, RALLY_CRY_DISTANCE)
local vengenceQueue = Universe.vengenceQueue
local map = chunk.map
for x=startX, endX, stepX do
for y=startY, endY, stepY do
if (x ~= cX) and (y ~= cY) then
local rallyChunk = getChunkByXY(map, x, y)
if rallyChunk ~= -1 then
local base = rallyChunk.base
if rallyChunk.nestCount
and (base.unitPoints >= AI_VENGENCE_SQUAD_COST)
then
vengenceQueue[rallyChunk.id] = rallyChunk
end
end
end
end
return true
end
end