mirror of
https://github.com/veden/Rampant.git
synced 2024-12-30 21:19:46 +02:00
re-enabled regrouping
This commit is contained in:
parent
43fb867c15
commit
d9a9045ada
@ -68,7 +68,8 @@ Configure Options not in game menu:
|
|||||||
- Optimization: Precompute retreatThreshold, maxSquads, rallyThreshold, formSquadThreshold, attackWaveSize, attackWaveSizeLowerBound, attackWaveSizeUpperBound, attackWaveSizeDeviation, kamikazeThreshold, attackWaveThreshold once per logic cycle
|
- Optimization: Precompute retreatThreshold, maxSquads, rallyThreshold, formSquadThreshold, attackWaveSize, attackWaveSizeLowerBound, attackWaveSizeUpperBound, attackWaveSizeDeviation, kamikazeThreshold, attackWaveThreshold once per logic cycle
|
||||||
- Optimization: Reduced garbage generated by pheromone map processing
|
- Optimization: Reduced garbage generated by pheromone map processing
|
||||||
- Optimization: Reduced garbage generated by attack formation scanning
|
- Optimization: Reduced garbage generated by attack formation scanning
|
||||||
- Framework: renamed chunk pX to x, so chunks could be used in calls to things like get_pollution
|
- Optimization: Capped squad regrouping attempts to 15 per logic cycle
|
||||||
|
- Framework: renamed chunk pX,pY to x,y, so chunks could be used in calls to things like get_pollution
|
||||||
|
|
||||||
0.15.10 -
|
0.15.10 -
|
||||||
- Fix: nil chunk in pheromone utils(https://mods.factorio.com/mods/Veden/Rampant/discussion/13806)
|
- Fix: nil chunk in pheromone utils(https://mods.factorio.com/mods/Veden/Rampant/discussion/13806)
|
||||||
|
@ -123,6 +123,8 @@ function upgrade.attempt(natives, regionMap)
|
|||||||
natives.attackWaveUpperBound = 0
|
natives.attackWaveUpperBound = 0
|
||||||
natives.unitRefundAmount = 0
|
natives.unitRefundAmount = 0
|
||||||
natives.attackWaveThreshold = 0
|
natives.attackWaveThreshold = 0
|
||||||
|
|
||||||
|
natives.regroupIndex = 1
|
||||||
|
|
||||||
natives.useCustomAI = settings.startup["rampant-useCustomAI"].value
|
natives.useCustomAI = settings.startup["rampant-useCustomAI"].value
|
||||||
if natives.useCustomAI then
|
if natives.useCustomAI then
|
||||||
|
@ -188,7 +188,7 @@ local function onTick(event)
|
|||||||
surface)
|
surface)
|
||||||
|
|
||||||
cleanSquads(natives)
|
cleanSquads(natives)
|
||||||
-- regroupSquads(natives)
|
regroupSquads(natives)
|
||||||
|
|
||||||
processPlayers(players, regionMap, surface, natives, tick)
|
processPlayers(players, regionMap, surface, natives, tick)
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL = 10000
|
|||||||
constants.PROCESS_QUEUE_SIZE = 450
|
constants.PROCESS_QUEUE_SIZE = 450
|
||||||
constants.SCAN_QUEUE_SIZE = 6
|
constants.SCAN_QUEUE_SIZE = 6
|
||||||
constants.BASE_QUEUE_SIZE = 1
|
constants.BASE_QUEUE_SIZE = 1
|
||||||
|
constants.SQUAD_QUEUE_SIZE = 5
|
||||||
constants.PROCESS_PLAYER_BOUND = 4
|
constants.PROCESS_PLAYER_BOUND = 4
|
||||||
|
|
||||||
constants.TICKS_A_SECOND = 60
|
constants.TICKS_A_SECOND = 60
|
||||||
|
@ -9,6 +9,8 @@ local constants = require("Constants")
|
|||||||
|
|
||||||
local MOVEMENT_PHEROMONE_GENERATOR_AMOUNT = constants.MOVEMENT_PHEROMONE_GENERATOR_AMOUNT
|
local MOVEMENT_PHEROMONE_GENERATOR_AMOUNT = constants.MOVEMENT_PHEROMONE_GENERATOR_AMOUNT
|
||||||
|
|
||||||
|
local SQUAD_QUEUE_SIZE = constants.SQUAD_QUEUE_SIZE
|
||||||
|
|
||||||
local DEFINES_GROUP_STATE_FINISHED = defines.group_state.finished
|
local DEFINES_GROUP_STATE_FINISHED = defines.group_state.finished
|
||||||
local DEFINES_GROUP_STATE_ATTACKING_TARGET = defines.group_state.attacking_target
|
local DEFINES_GROUP_STATE_ATTACKING_TARGET = defines.group_state.attacking_target
|
||||||
local DEFINES_GROUP_STATE_ATTACKING_DISTRACTION = defines.group_state.attacking_distraction
|
local DEFINES_GROUP_STATE_ATTACKING_DISTRACTION = defines.group_state.attacking_distraction
|
||||||
@ -29,6 +31,8 @@ local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE
|
|||||||
|
|
||||||
local mLog = math.log10
|
local mLog = math.log10
|
||||||
|
|
||||||
|
local mMin = math.min
|
||||||
|
|
||||||
local tableRemove = table.remove
|
local tableRemove = table.remove
|
||||||
local tableInsert = table.insert
|
local tableInsert = table.insert
|
||||||
local euclideanDistanceNamed = mapUtils.euclideanDistanceNamed
|
local euclideanDistanceNamed = mapUtils.euclideanDistanceNamed
|
||||||
@ -169,11 +173,11 @@ function unitGroupUtils.cleanSquads(natives)
|
|||||||
group.destroy()
|
group.destroy()
|
||||||
else
|
else
|
||||||
local status = squad.status
|
local status = squad.status
|
||||||
local squadPosition = group.position
|
|
||||||
local cycles = squad.cycles
|
local cycles = squad.cycles
|
||||||
if (status == SQUAD_RETREATING) and (cycles == 0) then
|
if (status == SQUAD_RETREATING) and (cycles == 0) then
|
||||||
squad.status = SQUAD_GUARDING
|
squad.status = SQUAD_GUARDING
|
||||||
squad.frenzy = true
|
squad.frenzy = true
|
||||||
|
local squadPosition = group.position
|
||||||
squad.frenzyPosition.x = squadPosition.x
|
squad.frenzyPosition.x = squadPosition.x
|
||||||
squad.frenzyPosition.y = squadPosition.y
|
squad.frenzyPosition.y = squadPosition.y
|
||||||
elseif (group.state == DEFINES_GROUP_STATE_FINISHED) then
|
elseif (group.state == DEFINES_GROUP_STATE_FINISHED) then
|
||||||
@ -196,20 +200,23 @@ function unitGroupUtils.regroupSquads(natives)
|
|||||||
|
|
||||||
local squads = natives.squads
|
local squads = natives.squads
|
||||||
local squadCount = #squads
|
local squadCount = #squads
|
||||||
|
|
||||||
|
local startIndex = natives.regroupIndex
|
||||||
|
|
||||||
for i=1,squadCount do
|
local maxSquadIndex = mMin(startIndex + SQUAD_QUEUE_SIZE, squadCount)
|
||||||
|
for i=startIndex,maxSquadIndex do
|
||||||
local squad = squads[i]
|
local squad = squads[i]
|
||||||
local group = squad.group
|
local group = squad.group
|
||||||
if group.valid and not isAttacking(group) then
|
if group.valid and not isAttacking(group) then
|
||||||
local status = squad.status
|
local status = squad.status
|
||||||
local memberCount = #group.members
|
local memberCount = #group.members
|
||||||
if (memberCount < groupThreshold) then
|
if (memberCount < groupThreshold) then
|
||||||
local squadPosition = group.position
|
local squadPosition = group.position
|
||||||
local mergedSquads = false
|
local mergedSquads = false
|
||||||
for x=i+1,squadCount do
|
for x=i+1,squadCount do
|
||||||
local mergeSquad = squads[x]
|
local mergeSquad = squads[x]
|
||||||
local mergeGroup = mergeSquad.group
|
local mergeGroup = mergeSquad.group
|
||||||
if mergeGroup.valid and (mergeSquad.status == status) and not isAttacking(mergeGroup) and (euclideanDistanceNamed(squadPosition, mergeGroup.position) < GROUP_MERGE_DISTANCE) then
|
if mergeGroup.valid and (euclideanDistanceNamed(squadPosition, mergeGroup.position) < GROUP_MERGE_DISTANCE) and (mergeSquad.status == status) and not isAttacking(mergeGroup) then
|
||||||
local mergeMembers = mergeGroup.members
|
local mergeMembers = mergeGroup.members
|
||||||
local mergeCount = #mergeMembers
|
local mergeCount = #mergeMembers
|
||||||
if ((mergeCount + memberCount) < AI_MAX_BITER_GROUP_SIZE) then
|
if ((mergeCount + memberCount) < AI_MAX_BITER_GROUP_SIZE) then
|
||||||
@ -236,7 +243,13 @@ function unitGroupUtils.regroupSquads(natives)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (maxSquadIndex == squadCount) then
|
||||||
|
natives.regroupIndex = 1
|
||||||
|
else
|
||||||
|
natives.regroupIndex = maxSquadIndex
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return unitGroupUtils
|
return unitGroupUtils
|
||||||
|
Loading…
Reference in New Issue
Block a user