1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-28 03:29:34 +02:00

see changelog

This commit is contained in:
Aaron Veden 2020-02-02 11:30:50 -08:00
parent 85d5724fc4
commit b7c8d69f32
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
7 changed files with 68 additions and 27 deletions

View File

@ -358,8 +358,12 @@ function upgrade.attempt(natives, setNewSurface)
end
global.version = 101
end
end
if (global.version < 103) then
natives.pendingStealGroups = {}
natives.pendingStealGroups.len = 1
if not setNewSurface then
game.surfaces[natives.activeSurface].print("Rampant - Version 0.18.3")
end

View File

@ -1,8 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 0.18.4
Date: 1. 2. 2020
Date: 2. 2. 2020
Improvements:
- Unit groups created by factorio when shelling spawners are now converted to Rampant squads
Bugfixes:
- Re-added removed settings that were actual used with Rampant
- Potential squad getting stuck on impassable terrain
---------------------------------------------------------------------------------------------------
Version: 0.18.3

View File

@ -607,7 +607,8 @@ script.on_nth_tick(INTERVAL_LOGIC,
game.forces.enemy.evolution_factor,
tick)
squadsBeginAttack(natives)
squadsBeginAttack(natives,
game.surfaces[natives.activeSurface])
if natives.newEnemies then
recycleBases(natives, tick)
@ -975,8 +976,11 @@ end
local function onUnitGroupCreated(event)
local group = event.group
if (group.force.name ~= "enemy") then
if (group.force.name == "enemy") then
if not group.is_script_driven then
natives.pendingStealGroups.len = natives.pendingStealGroups.len + 1
natives.pendingStealGroups[natives.pendingStealGroups.len] = group
end
end
end
@ -1044,7 +1048,7 @@ script.on_event(defines.events.on_entity_spawned, onEntitySpawned)
script.on_event(defines.events.on_rocket_launched, onRocketLaunch)
script.on_event(defines.events.on_entity_died, onDeath)
script.on_event(defines.events.on_chunk_generated, onChunkGenerated)
-- script.on_event(defines.events.on_unit_group_created, onUnitGroupCreated)
script.on_event(defines.events.on_unit_group_created, onUnitGroupCreated)
script.on_event(defines.events.on_force_created, onForceCreated)
script.on_event(defines.events.on_forces_merged, onForceMerged)

View File

@ -101,7 +101,8 @@ function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChun
for x=1,8 do
local neighborChunk = neighborDirectionChunks[x]
if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk) then
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk)) or
(chunk == SENTINEL_IMPASSABLE_CHUNK) then
local score = scoreFunction(natives, squad, neighborChunk)
if (score > highestScore) then
highestScore = score
@ -146,7 +147,8 @@ function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionCh
for x=1,8 do
local neighborChunk = neighborDirectionChunks[x]
if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk) then
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk)) or
(chunk == SENTINEL_IMPASSABLE_CHUNK) then
local score = scoreFunction(squad, neighborChunk)
if (score > highestScore) then
highestScore = score
@ -224,7 +226,8 @@ function movementUtils.scoreNeighborsForRetreat(chunk, neighborDirectionChunks,
for x=1,8 do
local neighborChunk = neighborDirectionChunks[x]
if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk) then
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk)) or
(chunk == SENTINEL_IMPASSABLE_CHUNK) then
local score = scoreFunction(map, neighborChunk)
if (score > highestScore) then
highestScore = score

View File

@ -76,6 +76,9 @@ local calculateKamikazeThreshold = unitGroupUtils.calculateKamikazeThreshold
local positionFromDirectionAndChunk = mapUtils.positionFromDirectionAndChunk
local positionFromDirectionAndFlat = mapUtils.positionFromDirectionAndFlat
local createSquad = unitGroupUtils.createSquad
local membersToSquad = unitGroupUtils.membersToSquad
local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
@ -499,21 +502,45 @@ end
function squadAttack.squadsBeginAttack(natives)
local pending = natives.pendingAttack
function squadAttack.squadsBeginAttack(natives, surface)
local squads = natives.squads
local pendingLen = pending.len
local x = 0
local pendingAttack = natives.pendingAttack
local pendingStealGroups = natives.pendingStealGroups
for i=1,pendingLen do
local squad = pending[i]
local cmd = natives.map.retreatCommand
local x = 0
for i=1, pendingStealGroups.len do
local group = pendingStealGroups[i]
if group and group.valid then
if (group.state ~= DEFINES_GROUP_GATHERING) then
local squad = createSquad(group.position, surface, nil, false)
pendingAttack.len = pendingAttack.len + 1
pendingAttack[pendingAttack.len] = squad
cmd.group = squad.group
membersToSquad(cmd, #group.members, group.members, true)
group.destroy()
else
x = x + 1
pendingStealGroups[x] = group
end
end
end
pendingStealGroups.len = x
x = 0
for i=1,pendingAttack.len do
local squad = pendingAttack[i]
local group = squad.group
if group and group.valid then
local groupState = group.state
local groupState = group.state
if (groupState ~= DEFINES_GROUP_FINISHED) and (squad.cycles ~= 0) then
squad.cycles = squad.cycles - 1
x = x + 1
pending[x] = squad
pendingAttack[x] = squad
else
local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
if not squad.kamikaze then
@ -535,7 +562,8 @@ function squadAttack.squadsBeginAttack(natives)
end
end
pending.len = x
pendingAttack.len = x
end
squadAttackG = squadAttack

View File

@ -94,7 +94,7 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
map)
if (exitPath ~= SENTINEL_IMPASSABLE_CHUNK) then
local targetPosition = map.position
local targetPosition2 = map.position2
local targetPosition2 = map.position2
positionFromDirectionAndFlat(exitDirection, position, targetPosition)
@ -106,7 +106,7 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
if (nextExitPath ~= SENTINEL_IMPASSABLE_CHUNK) then
positionFromDirectionAndFlat(nextExitDirection, retreatPosition, targetPosition2)
local retreatPosition2 = findMovementPosition(surface, targetPosition2)
if retreatPosition2 then
@ -119,19 +119,19 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
-- to each unit, this is the only way I have found to have snappy mid battle retreats even after 0.14.4
local newSquad = findNearbyRetreatingSquad(map, exitPath)
if not newSquad then
newSquad = createSquad(retreatPosition, surface)
local squads = map.natives.squads
squads.len = squads.len+1
squads[squads.len] = newSquad
end
if newSquad then
newSquad.status = SQUAD_RETREATING
newSquad.cycles = 13
local cmd = map.retreatCommand
local cmd = map.retreatCommand
cmd.group = newSquad.group
if enemiesToSquad then
membersToSquad(cmd, enemiesToSquad.len, enemiesToSquad, artilleryBlast)
@ -141,7 +141,7 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
newSquad.rabid = true
end
end
if not newSquad.rapid then
newSquad.frenzy = true
local squadPosition = newSquad.group.position

View File

@ -8,6 +8,7 @@ local unitGroupUtils = {}
local mapUtils = require("MapUtils")
local constants = require("Constants")
local chunkPropertyUtils = require("ChunkPropertyUtils")
local chunkUtils = require("ChunkUtils")
local movementUtils = require("MovementUtils")
-- constants
@ -139,14 +140,12 @@ function unitGroupUtils.createSquad(position, surface, group, settlers)
end
function unitGroupUtils.membersToSquad(cmd, size, members, overwriteGroup)
-- if (members ~= nil) then
for i=1,size do
local member = members[i]
if member.valid and (overwriteGroup or (not overwriteGroup and not member.unit_group)) then
member.set_command(cmd)
end
end
-- end
end
function unitGroupUtils.convertUnitGroupToSquad(natives, unitGroup)