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

fixed settler max distance and added greater variance to distance

This commit is contained in:
Aaron Veden 2021-12-28 13:17:39 -08:00
parent 0152b40854
commit 50bfae2547
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
7 changed files with 55 additions and 16 deletions

View File

@ -9,6 +9,7 @@ local chunkUtils = require("libs/ChunkUtils")
-- constants
local MINIMUM_EXPANSION_DISTANCE = constants.MINIMUM_EXPANSION_DISTANCE
local DEFINES_COMMAND_GROUP = defines.command.group
local DEFINES_COMMAND_WANDER = defines.command.wander
local DEFINES_COMMAND_BUILD_BASE = defines.command.build_base
@ -452,7 +453,6 @@ function upgrade.attempt(universe)
universe.expansion = game.map_settings.enemy_expansion.enabled
universe.expansionMaxDistance = game.map_settings.enemy_expansion.max_expansion_distance * CHUNK_SIZE
universe.expansionMaxDistanceDerivation = universe.expansionMaxDistance * 0.33
universe.expansionMinTime = game.map_settings.enemy_expansion.min_expansion_cooldown
universe.expansionMaxTime = game.map_settings.enemy_expansion.max_expansion_cooldown
universe.expansionMinSize = game.map_settings.enemy_expansion.settler_group_min_size
@ -559,8 +559,17 @@ function upgrade.attempt(universe)
if universe.NEW_ENEMIES then
addBasesToAllEnemyStructures(universe, game.tick)
end
end
if global.version < 208 then
global.version = 208
game.print("Rampant - Version 2.1.0")
universe.expansionMaxDistanceDerivation = nil
universe.expansionLowTargetDistance = (universe.expansionMaxDistance + MINIMUM_EXPANSION_DISTANCE) * 0.33
universe.expansionMediumTargetDistance = (universe.expansionMaxDistance + MINIMUM_EXPANSION_DISTANCE) * 0.50
universe.expansionHighTargetDistance = (universe.expansionMaxDistance + MINIMUM_EXPANSION_DISTANCE) * 0.75
universe.expansionDistanceDeviation = universe.expansionMediumTargetDistance * 0.33
game.print("Rampant - Version 2.1.1")
end
return (starting ~= global.version) and global.version

View File

@ -1,3 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 2.1.1
Date: 28. 12. 2021
Improvements:
- Settlers now have a 40% chance to move roughly 50% of max expansion distance, 25% chance to move roughly 33% of max expansion distance, and 25% chance to move roughly 75% of max expansion distance, 5% chance to settler where the group formed, 5% chance to go 100% of max expansion distance
Bugfixes:
- Settlers in some cases not setting a maxDistance which caused settlers to build where they were formed
---------------------------------------------------------------------------------------------------
Version: 2.1.0
Date: 27. 12. 2021

View File

@ -38,8 +38,6 @@ local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS
-- imported functions
local addBasesToAllEnemyStructures = chunkUtils.addBasesToAllEnemyStructures
local getChunkById = mapUtils.getChunkById
local setChunkBase = chunkPropertyUtils.setChunkBase
local setPointAreaInQuery = queryUtils.setPointAreaInQuery
local setPositionInQuery = queryUtils.setPositionInQuery

View File

@ -15,6 +15,8 @@ local baseUtils = require("BaseUtils")
-- constants
local MINIMUM_EXPANSION_DISTANCE = constants.MINIMUM_EXPANSION_DISTANCE
local BASE_PHEROMONE = constants.BASE_PHEROMONE
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
@ -226,12 +228,6 @@ function aiAttackWave.formSettlers(map, chunk)
if squadPosition then
local squad = createSquad(squadPosition, map, nil, true)
squad.maxDistance = gaussianRandomRangeRG(universe.expansionMaxDistance * 0.5,
universe.expansionMaxDistanceDerivation,
10,
universe.expansionMaxDistance,
universe.random)
local scaledWaveSize = settlerWaveScaling(universe)
universe.formGroupCommand.group = squad.group
universe.formCommand.unit_count = scaledWaveSize

View File

@ -216,6 +216,8 @@ constants.SQUAD_BUILDING = 6
-- Squad Related
constants.MINIMUM_EXPANSION_DISTANCE = 10
constants.RETREAT_GRAB_RADIUS = 24
constants.RETREAT_SPAWNER_GRAB_RADIUS = 75

View File

@ -8,6 +8,7 @@ local movementUtils = {}
local constants = require("Constants")
local mapUtils = require("MapUtils")
local mathUtils = require("MathUtils")
local unitGroupUtils = require("UnitGroupUtils")
-- constants
@ -17,7 +18,7 @@ local SQUAD_SETTLING = constants.SQUAD_SETTLING
-- imported functions
local gaussianRandomRangeRG = mathUtils.gaussianRandomRangeRG
local calculateSettlerMaxDistance = unitGroupUtils.calculateSettlerMaxDistance
local canMoveChunkDirection = mapUtils.canMoveChunkDirection
local getNeighborChunks = mapUtils.getNeighborChunks
@ -66,11 +67,7 @@ function movementUtils.addMovementPenalty(squad, chunk)
squad.settler = true
squad.originPosition.x = squad.group.position.x
squad.originPosition.y = squad.group.position.y
squad.maxDistance = gaussianRandomRangeRG(universe.expansionMaxDistance * 0.5,
universe.expansionMaxDistanceDerivation,
10,
universe.expansionMaxDistance,
universe.random)
squad.maxDistance = calculateSettlerMaxDistance(universe)
squad.status = SQUAD_SETTLING
else

View File

@ -8,14 +8,18 @@ local unitGroupUtils = {}
local mapUtils = require("MapUtils")
local constants = require("Constants")
local chunkPropertyUtils = require("ChunkPropertyUtils")
local mathUtils = require("MathUtils")
-- constants
local MINIMUM_EXPANSION_DISTANCE = constants.MINIMUM_EXPANSION_DISTANCE
local SQUAD_RETREATING = constants.SQUAD_RETREATING
local SQUAD_GUARDING = constants.SQUAD_GUARDING
-- imported functions
local gaussianRandomRangeRG = mathUtils.gaussianRandomRangeRG
local getSquadsOnChunk = chunkPropertyUtils.getSquadsOnChunk
local getNeighborChunks = mapUtils.getNeighborChunks
@ -73,6 +77,27 @@ function unitGroupUtils.findNearbySquad(map, chunk)
return nil
end
function unitGroupUtils.calculateSettlerMaxDistance(universe)
local targetDistance
local distanceRoll = universe.random()
if distanceRoll < 0.05 then
return 0
elseif distanceRoll < 0.30 then
targetDistance = universe.expansionLowTargetDistance
elseif distanceRoll < 0.70 then
targetDistance = universe.expansionMediumTargetDistance
elseif distanceRoll < 0.95 then
targetDistance = universe.expansionHighTargetDistance
else
return universe.expansionMaxDistance
end
return gaussianRandomRangeRG(targetDistance,
universe.expansionDistanceDeviation,
MINIMUM_EXPANSION_DISTANCE,
universe.expansionMaxDistance,
universe.random)
end
function unitGroupUtils.createSquad(position, map, group, settlers)
local unitGroup = group or map.surface.create_unit_group({position=position})
@ -97,6 +122,10 @@ function unitGroupUtils.createSquad(position, map, group, settlers)
chunk = -1
}
if settlers then
squad.maxDistance = unitGroupUtils.calculateSettlerMaxDistance(map.universe)
end
if position then
squad.originPosition.x = position.x
squad.originPosition.y = position.y