mirror of
https://github.com/veden/Rampant.git
synced 2024-12-26 20:54:12 +02:00
FACTO-89: Fixed on_unit_group_finished_gathering invalid chunk/base checks
This commit is contained in:
parent
fe271b5c56
commit
537a8a03e9
@ -1,7 +1,7 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 3.0.0
|
||||
Notes:
|
||||
- Will reset maps of in progress games
|
||||
- Will reset maps of in progress games. This means that all enemy units will be removed and new enemy faction mutations will be reset.
|
||||
Improvement:
|
||||
- Modified death pheromone squad path scoring
|
||||
- AI is now per regional base
|
||||
|
24
control.lua
24
control.lua
@ -112,6 +112,7 @@ local victoryScent = pheromoneUtils.victoryScent
|
||||
local createSquad = unitGroupUtils.createSquad
|
||||
|
||||
local createBase = baseUtils.createBase
|
||||
local findNearbyBaseByPosition = chunkPropertyUtils.findNearbyBaseByPosition
|
||||
local findNearbyBase = chunkPropertyUtils.findNearbyBase
|
||||
|
||||
local processActiveNests = mapProcessor.processActiveNests
|
||||
@ -747,11 +748,14 @@ local function onUnitGroupCreated(event)
|
||||
return
|
||||
end
|
||||
map.activeSurface = true
|
||||
local chunk = getChunkByPosition(map, group.position)
|
||||
local position = group.position
|
||||
local chunk = getChunkByPosition(map, position)
|
||||
local base
|
||||
if (chunk == -1) then
|
||||
return
|
||||
base = findNearbyBaseByPosition(map, position.x, position.y)
|
||||
else
|
||||
base = findNearbyBase(map, chunk)
|
||||
end
|
||||
local base = findNearbyBase(map, chunk)
|
||||
if not base then
|
||||
group.destroy()
|
||||
return
|
||||
@ -830,8 +834,18 @@ local function onGroupFinishedGathering(event)
|
||||
end
|
||||
end
|
||||
else
|
||||
local chunk = getChunkByPosition(map, group.position)
|
||||
local base = findNearbyBase(map, chunk)
|
||||
local position = group.position
|
||||
local chunk = getChunkByPosition(map, position)
|
||||
local base
|
||||
if chunk == -1 then
|
||||
base = findNearbyBaseByPosition(map, position.x, position.y)
|
||||
else
|
||||
base = findNearbyBase(map, chunk)
|
||||
end
|
||||
if not base then
|
||||
group.destroy()
|
||||
return
|
||||
end
|
||||
local settler = canMigrate(map, base) and
|
||||
(universe.builderCount < universe.AI_MAX_BUILDER_COUNT) and
|
||||
(universe.random() < 0.25)
|
||||
|
@ -594,6 +594,21 @@ function chunkPropertyUtils.findNearbyBase(map, chunk)
|
||||
return foundBase
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.findNearbyBaseByPosition(map, x, y)
|
||||
local foundBase
|
||||
|
||||
local closest = MAGIC_MAXIMUM_NUMBER
|
||||
for _, base in pairs(map.bases) do
|
||||
local distance = manhattenDistancePoints(base.x, base.y, x, y)
|
||||
if (distance <= base.distanceThreshold) and (distance < closest) then
|
||||
closest = distance
|
||||
foundBase = base
|
||||
end
|
||||
end
|
||||
|
||||
return foundBase
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.processNestActiveness(map, chunk)
|
||||
local nests = chunkPropertyUtils.getNestCount(map, chunk)
|
||||
local base = chunkPropertyUtils.findNearbyBase(map, chunk)
|
||||
|
Loading…
Reference in New Issue
Block a user