1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-26 03:20:07 +02:00

cherry picked defunct branch

This commit is contained in:
Aaron Veden 2019-03-05 22:18:03 -08:00
parent cec40f2dfb
commit 7263400966
21 changed files with 271 additions and 141 deletions

View File

@ -94,9 +94,9 @@ function upgrade.attempt(natives)
For making changes to maps that haven't had Rampant loaded and aren't starting from a brand new map
Was causing desyncs when client connected before having the below settings saved into the map 0.15.15 factorio
--]]
game.map_settings.path_finder.short_request_ratio = constants.PATH_FINDER_SHORT_REQUEST_RATIO
game.map_settings.path_finder.short_cache_size = constants.PATH_FINDER_SHORT_CACHE_SIZE
game.map_settings.path_finder.long_cache_size = constants.PATH_FINDER_LONG_REQUEST_RATIO
-- game.map_settings.path_finder.short_request_ratio = constants.PATH_FINDER_SHORT_REQUEST_RATIO
-- game.map_settings.path_finder.short_cache_size = constants.PATH_FINDER_SHORT_CACHE_SIZE
-- game.map_settings.path_finder.long_cache_size = constants.PATH_FINDER_LONG_REQUEST_RATIO
game.map_settings.unit_group.max_group_radius = constants.UNIT_GROUP_MAX_RADIUS
game.map_settings.unit_group.max_member_speedup_when_behind = constants.UNIT_GROUP_MAX_SPEED_UP

View File

@ -1,3 +1,17 @@
---------------------------------------------------------------------------------------------------
Version: 0.17.4
Date: 3. 5. 2019
Improvements:
- Increased the size of nest and worm template when looking for place to build, increases nest and worm spacing
- Increased chunk processing from 825 to 1020 chunks
Tweaks:
- Removed old map path finder settings
- Added new find position centered flag to positions searches
- Adjusted new enemy worm ranges to vanilla levels
Bugfixes:
- Fixed player pheromone not having highest value on chunk player was on
- Fixed settlers not being able to see chunks with resources on them
---------------------------------------------------------------------------------------------------
Version: 0.17.3
Date: 2. 28. 2019

View File

@ -24,8 +24,9 @@ local stringUtils = require("StringUtils")
-- constants
local INTERVAL_LOGIC = constants.INTERVAL_LOGIC
local INTERVAL_PROCESS = constants.INTERVAL_PROCESS
local INTERVAL_CHUNK = constants.INTERVAL_CHUNK
local INTERVAL_PLAYER_PROCESS = constants.INTERVAL_PLAYER_PROCESS
local INTERVAL_MAP_PROCESS = constants.INTERVAL_MAP_PROCESS
-- local INTERVAL_CHUNK = constants.INTERVAL_CHUNK
local INTERVAL_SCAN = constants.INTERVAL_SCAN
local INTERVAL_SQUAD = constants.INTERVAL_SQUAD
-- local INTERVAL_SPAWNER = constants.INTERVAL_SPAWNER
@ -69,7 +70,7 @@ local squadsDispatch = squadAttack.squadsDispatch
local positionToChunkXY = mapUtils.positionToChunkXY
local roundToNearest = mathUtils.roundToNearest
-- local roundToNearest = mathUtils.roundToNearest
local getChunkByPosition = mapUtils.getChunkByPosition
@ -104,20 +105,19 @@ local retreatUnits = squadDefense.retreatUnits
local getChunkBase = chunkPropertyUtils.getChunkBase
local isSpawnerEgg = stringUtils.isSpawnerEgg
-- local isSpawnerEgg = stringUtils.isSpawnerEgg
local addRemovePlayerEntity = chunkUtils.addRemovePlayerEntity
local unregisterEnemyBaseStructure = chunkUtils.unregisterEnemyBaseStructure
local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure
local makeImmortalEntity = chunkUtils.makeImmortalEntity
local getChunkSpawnerEggTick = chunkPropertyUtils.getChunkSpawnerEggTick
local setChunkSpawnerEggTick = chunkPropertyUtils.setChunkSpawnerEggTick
-- local getChunkSpawnerEggTick = chunkPropertyUtils.getChunkSpawnerEggTick
-- local setChunkSpawnerEggTick = chunkPropertyUtils.setChunkSpawnerEggTick
local upgradeEntity = baseUtils.upgradeEntity
local rebuildNativeTables = baseUtils.rebuildNativeTables
local sFind = string.find
local mRandom = math.random
-- local references to global
@ -274,11 +274,11 @@ local function rebuildMap()
distraction = DEFINES_DISTRACTION_NONE }
-- switched over to tick event
map.logicTick = roundToNearest(game.tick + INTERVAL_LOGIC, INTERVAL_LOGIC)
map.scanTick = roundToNearest(game.tick + INTERVAL_SCAN, INTERVAL_SCAN)
map.processTick = roundToNearest(game.tick + INTERVAL_PROCESS, INTERVAL_PROCESS)
map.chunkTick = roundToNearest(game.tick + INTERVAL_CHUNK, INTERVAL_CHUNK)
map.squadTick = roundToNearest(game.tick + INTERVAL_SQUAD, INTERVAL_SQUAD)
-- map.logicTick = roundToNearest(game.tick + INTERVAL_LOGIC, INTERVAL_LOGIC)
-- map.scanTick = roundToNearest(game.tick + INTERVAL_SCAN, INTERVAL_SCAN)
-- map.processTick = roundToNearest(game.tick + INTERVAL_PROCESS, INTERVAL_PROCESS)
-- map.chunkTick = roundToNearest(game.tick + INTERVAL_CHUNK, INTERVAL_CHUNK)
-- map.squadTick = roundToNearest(game.tick + INTERVAL_SQUAD, INTERVAL_SQUAD)
end
@ -379,17 +379,34 @@ local function onConfigChanged()
prepWorld(true)
end
script.on_nth_tick(INTERVAL_PROCESS,
script.on_nth_tick(INTERVAL_PLAYER_PROCESS,
function (event)
local tick = event.tick
local gameRef = game
local surface = gameRef.surfaces[natives.activeSurface]
processPlayers(gameRef.players, map, surface, natives, tick)
processMap(map, surface, natives, tick, gameRef.forces.enemy.evolution_factor)
processPlayers(gameRef.players,
map,
surface,
natives,
event.tick)
end)
script.on_nth_tick(INTERVAL_MAP_PROCESS,
function (event)
-- local tick = event.tick
local gameRef = game
local surface = gameRef.surfaces[natives.activeSurface]
processMap(map,
surface,
natives,
event.tick,
gameRef.forces.enemy.evolution_factor)
end)
script.on_nth_tick(INTERVAL_SCAN,
function (event)
local tick = event.tick

View File

@ -60,10 +60,10 @@ end
--]]
local mapSettings = data.raw["map-settings"]["map-settings"]
mapSettings.path_finder.short_request_ratio = constants.PATH_FINDER_SHORT_REQUEST_RATIO
mapSettings.path_finder.short_cache_size = constants.PATH_FINDER_SHORT_CACHE_SIZE
mapSettings.path_finder.long_cache_size = constants.PATH_FINDER_LONG_REQUEST_RATIO
mapSettings.path_finder.min_steps_to_check_path_find_termination = constants.PATH_FINDER_MIN_STEPS_TO_CHECK_PATH
-- mapSettings.path_finder.short_request_ratio = constants.PATH_FINDER_SHORT_REQUEST_RATIO
-- mapSettings.path_finder.short_cache_size = constants.PATH_FINDER_SHORT_CACHE_SIZE
-- mapSettings.path_finder.long_cache_size = constants.PATH_FINDER_LONG_REQUEST_RATIO
-- mapSettings.path_finder.min_steps_to_check_path_find_termination = constants.PATH_FINDER_MIN_STEPS_TO_CHECK_PATH
mapSettings.max_failed_behavior_count = constants.MAX_FAILED_BEHAVIORS

View File

@ -1,7 +1,7 @@
{
"name" : "Rampant",
"factorio_version" : "0.17",
"version" : "0.17.3",
"version" : "0.17.4",
"title" : "Rampant",
"author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",

View File

@ -169,7 +169,8 @@ function aiAttackWave.formSettlers(map, surface, natives, chunk, tick)
map.position,
0.98),
CHUNK_SIZE,
4)
4,
true)
if squadPosition then
local squad = createSquad(squadPosition, surface, natives, nil, true)
@ -212,7 +213,8 @@ function aiAttackWave.formVengenceSquad(map, surface, natives, chunk)
map.position,
0.98),
CHUNK_SIZE,
4)
4,
true)
if squadPosition then
local squad = createSquad(squadPosition, surface, natives)
@ -250,7 +252,8 @@ function aiAttackWave.formSquads(map, surface, natives, chunk)
map.position,
0.98),
CHUNK_SIZE,
4)
4,
true)
if squadPosition then
local squad = createSquad(squadPosition, surface, natives)

View File

@ -352,7 +352,13 @@ function baseUtils.upgradeEntity(entity, surface, baseAlignment, natives, evolut
local spawnerName = findEntityUpgrade(baseAlignment, currentEvo, evoIndex, natives, ((entityType == "unit-spawner") and natives.evolutionTableUnitSpawner) or natives.evolutionTableWorm)
if spawnerName then
local newPosition = surface.find_non_colliding_position(spawnerName, position, CHUNK_SIZE, 4)
local newPosition = surface.find_non_colliding_position(
((entityType == "unit-spawner") and "chunk-scanner-nest-rampant") or "chunk-scanner-worm-rampant",
position,
CHUNK_SIZE,
4,
true
)
if newPosition then
return surface.create_entity({name = spawnerName, position = newPosition})
end
@ -384,18 +390,18 @@ local function upgradeBase(natives, evolutionFactor, base)
local roll = mRandom()
if alignmentCount == 2 then
if (roll < 0.05) then
base.alignment = {findMutation(natives, evolutionFactor, base.alignment[1])}
base.alignment = {findMutation(natives, evolutionFactor)}
elseif (roll < 0.4) then
base.alignment = {findMutation(natives, evolutionFactor, base.alignment[2]), base.alignment[2]}
base.alignment = {findMutation(natives, evolutionFactor), base.alignment[2]}
else
base.alignment = {base.alignment[1], findMutation(natives, evolutionFactor, base.alignment[1])}
base.alignment = {base.alignment[1], findMutation(natives, evolutionFactor)}
end
return true
elseif alignmentCount == 1 then
if (roll < 0.85) then
base.alignment = {findMutation(natives, evolutionFactor, base.alignment[1])}
base.alignment = {findMutation(natives, evolutionFactor)}
else
base.alignment = {base.alignment[1], findMutation(natives, evolutionFactor, base.alignment[1])}
base.alignment = {base.alignment[1], findMutation(natives, evolutionFactor)}
end
return true
end

View File

@ -243,7 +243,7 @@ function chunkUtils.scanChunkPaths(chunk, surface, map)
return pass
end
function chunkUtils.scorePlayerBuildings(surface, map, natives)
local function scorePlayerBuildings(surface, map, natives)
local entities = surface.find_entities_filtered(map.filteredEntitiesPlayerQuery)
local playerObjects = 0
@ -269,12 +269,12 @@ function chunkUtils.scorePlayerBuildings(surface, map, natives)
return playerObjects
end
function chunkUtils.scoreEnemyBuildings(surface, map)
local nests = surface.find_entities_filtered(map.filteredEntitiesUnitSpawnereQuery)
local worms = surface.find_entities_filtered(map.filteredEntitiesWormQuery)
-- function chunkUtils.scoreEnemyBuildings(surface, map)
-- local nests = surface.find_entities_filtered(map.filteredEntitiesUnitSpawnereQuery)
-- local worms = surface.find_entities_filtered(map.filteredEntitiesWormQuery)
return nests, worms
end
-- return nests, worms
-- end
function chunkUtils.initialScan(chunk, natives, surface, map, tick, evolutionFactor, rebuilding)
local passScore = chunkUtils.calculatePassScore(surface, map)
@ -282,9 +282,10 @@ function chunkUtils.initialScan(chunk, natives, surface, map, tick, evolutionFac
if (passScore >= 0.40) then
local pass = chunkUtils.scanChunkPaths(chunk, surface, map)
local playerObjects = chunkUtils.scorePlayerBuildings(surface, map, natives)
local playerObjects = scorePlayerBuildings(surface, map, natives)
local nests, worms = chunkUtils.scoreEnemyBuildings(surface, map)
local nests = surface.find_entities_filtered(map.filteredEntitiesUnitSpawnereQuery)
local worms = surface.find_entities_filtered(map.filteredEntitiesWormQuery)
if ((playerObjects > 0) or (#nests > 0)) and (pass == CHUNK_IMPASSABLE) then
pass = CHUNK_ALL_DIRECTIONS
@ -383,7 +384,7 @@ function chunkUtils.chunkPassScan(chunk, surface, map)
end
function chunkUtils.analyzeChunk(chunk, natives, surface, map)
local playerObjects = chunkUtils.scorePlayerBuildings(surface, map, natives)
local playerObjects = scorePlayerBuildings(surface, map, natives)
setPlayerBaseGenerator(map, chunk, playerObjects)
local resources = surface.count_entities_filtered(map.countResourcesQuery) * RESOURCE_NORMALIZER
setResourceGenerator(map, chunk, resources)

View File

@ -40,7 +40,7 @@ constants.MAGIC_MAXIMUM_BASE_NUMBER = 100000000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN = 10000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = 170000
constants.PROCESS_QUEUE_SIZE = 275
constants.PROCESS_QUEUE_SIZE = 85
constants.SCAN_QUEUE_SIZE = 10
constants.BASE_QUEUE_SIZE = 1
constants.SQUAD_QUEUE_SIZE = 2
@ -49,7 +49,8 @@ constants.PROCESS_PLAYER_BOUND = 128
constants.TICKS_A_SECOND = 60
constants.TICKS_A_MINUTE = constants.TICKS_A_SECOND * 60
constants.INTERVAL_PROCESS = 19
constants.INTERVAL_PLAYER_PROCESS = 19
constants.INTERVAL_MAP_PROCESS = 5
constants.INTERVAL_SCAN = 21
constants.INTERVAL_CHUNK = 17
constants.INTERVAL_LOGIC = 61
@ -90,8 +91,6 @@ constants.RESOURCE_MINIMUM_FORMATION_DELTA = 15
constants.AI_POINT_GENERATOR_AMOUNT = 6
constants.AI_SQUAD_COST = 175
constants.AI_NEST_COST = 10
constants.AI_WORM_COST = 2
constants.AI_VENGENCE_SQUAD_COST = 45
constants.AI_SETTLER_COST = 200
constants.AI_BASE_BUILDING_COST = 500
@ -369,7 +368,7 @@ constants.MOVEMENT_PENALTY_AMOUNT = 10000
constants.DEATH_PHEROMONE_GENERATOR_AMOUNT = 750
constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT = 300
constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT = -0.1
constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT = 0
-- pheromone diffusion amounts
@ -451,8 +450,8 @@ constants.BUILDING_PHEROMONES["fluid-turret"] = 2800
constants.BUILDING_PHEROMONES["turret"] = 1000
constants.BUILDING_PHEROMONES["artillery-turret"] = 10000
constants.RETREAT_FILTER = {}
constants.RETREAT_FILTER[constants.SQUAD_RETREATING] = true
-- constants.RETREAT_FILTER = {}
-- constants.RETREAT_FILTER[constants.SQUAD_RETREATING] = true
-- map settings tweaks

View File

@ -156,10 +156,10 @@ function mapProcessor.processMap(map, surface, natives, tick, evolutionFactor)
for x=index,endIndex do
local chunk = processQueue[x]
if (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
-- chunk[CHUNK_TICK] = tick
commitPheromone(map, chunk, scentStaging[i])
scents(map, chunk)
commitPheromone(map, chunk, scentStaging[i], tick)
-- scents(map, chunk)
end
i = i + 1
end
@ -190,17 +190,6 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
local squads = allowingAttacks and (0.11 <= roll) and (roll <= 0.20) and (natives.points >= AI_SQUAD_COST)
for i=1,#playerOrdering do
local player = players[playerOrdering[i]]
if validPlayer(player, natives) then
local playerChunk = getChunkByPosition(map, player.character.position)
if (playerChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
playerScent(playerChunk)
end
end
end
-- not looping everyone because the cost is high enough already in multiplayer
if (#playerOrdering > 0) then
local player = players[playerOrdering[1]]
@ -262,9 +251,9 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
local chunk = getChunkByXY(map, x, y)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
-- chunk[CHUNK_TICK] = tick
commitPheromone(map, chunk, scentStaging[i])
scents(map, chunk)
-- scents(map, chunk)
end
i = i + 1
end
@ -272,6 +261,17 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
end
end
end
for i=1,#playerOrdering do
local player = players[playerOrdering[i]]
if validPlayer(player, natives) then
local playerChunk = getChunkByPosition(map, player.character.position)
if (playerChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
playerScent(playerChunk)
end
end
end
end
--[[

View File

@ -11,6 +11,8 @@ local chunkPropertyUtils = require("ChunkPropertyUtils")
-- constants
local CHUNK_TICK = constants.CHUNK_TICK
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
local BASE_PHEROMONE = constants.BASE_PHEROMONE
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
@ -30,7 +32,6 @@ local DEATH_PHEROMONE_GENERATOR_AMOUNT = constants.DEATH_PHEROMONE_GENERATOR_AMO
-- imported functions
local getCardinalChunks = mapUtils.getCardinalChunks
local getNeighborChunks = mapUtils.getNeighborChunks
local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount
@ -46,17 +47,6 @@ local linearInterpolation = mathUtils.linearInterpolation
-- module code
function pheromoneUtils.scents(map, chunk)
chunk[BASE_PHEROMONE] = chunk[BASE_PHEROMONE] + (getPlayerBaseGenerator(map, chunk))
local resourceGenerator = getResourceGenerator(map, chunk)
local enemyCount = getEnemyStructureCount(map, chunk)
chunk[MOVEMENT_PHEROMONE] = chunk[MOVEMENT_PHEROMONE] - (getDeathGenerator(map, chunk))
if (resourceGenerator > 0) and (enemyCount == 0) then
chunk[RESOURCE_PHEROMONE] = chunk[RESOURCE_PHEROMONE] + (linearInterpolation(resourceGenerator, 15000, 20000))
end
end
function pheromoneUtils.victoryScent(map, chunk, entityType)
local value = BUILDING_PHEROMONES[entityType]
if value then
@ -75,13 +65,24 @@ function pheromoneUtils.playerScent(playerChunk)
playerChunk[PLAYER_PHEROMONE] = playerChunk[PLAYER_PHEROMONE] + PLAYER_PHEROMONE_GENERATOR_AMOUNT
end
function pheromoneUtils.commitPheromone(map, chunk, staging)
function pheromoneUtils.commitPheromone(map, chunk, staging, tick)
chunk[CHUNK_TICK] = tick
chunk[MOVEMENT_PHEROMONE] = staging[MOVEMENT_PHEROMONE]
chunk[BASE_PHEROMONE] = staging[BASE_PHEROMONE]
chunk[PLAYER_PHEROMONE] = staging[PLAYER_PHEROMONE]
chunk[RESOURCE_PHEROMONE] = staging[RESOURCE_PHEROMONE]
decayDeathGenerator(map, chunk)
chunk[BASE_PHEROMONE] = chunk[BASE_PHEROMONE] + (getPlayerBaseGenerator(map, chunk))
local resourceGenerator = getResourceGenerator(map, chunk)
local enemyCount = getEnemyStructureCount(map, chunk)
chunk[MOVEMENT_PHEROMONE] = chunk[MOVEMENT_PHEROMONE] - (getDeathGenerator(map, chunk))
if (resourceGenerator > 0) and (enemyCount == 0) then
chunk[RESOURCE_PHEROMONE] = chunk[RESOURCE_PHEROMONE] + (linearInterpolation(resourceGenerator, 15000, 20000))
end
end
function pheromoneUtils.processPheromone(map, chunk, staging)

View File

@ -20,7 +20,7 @@ local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
local BASE_PHEROMONE = constants.BASE_PHEROMONE
local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
local ATTACK_SCORE = constants.ATTACK_SCORE
-- local ATTACK_SCORE = constants.ATTACK_SCORE
local ATTACK_SCORE_KAMIKAZE = constants.ATTACK_SCORE_KAMIKAZE
local SQUAD_BUILDING = constants.SQUAD_BUILDING
@ -108,21 +108,24 @@ local function settleMove(map, attackPosition, attackCmd, settleCmd, squad, grou
local groupPosition = group.position
local x, y = positionToChunkXY(groupPosition)
local chunk = getChunkByXY(map, x, y)
local scoreFunction = scoreResourceLocation
if (natives.state == AI_STATE_SIEGE) then
scoreFunction = scoreSiegeLocation
end
local attackChunk, attackDirection = scoreNeighborsForSettling(map,
chunk,
getNeighborChunks(map, x, y),
((natives.state == AI_STATE_SIEGE) and scoreSiegeLocation) or
scoreResourceLocation,
scoreFunction,
squad)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, chunk, squad)
addMovementPenalty(natives, squad, chunk)
elseif (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, attackChunk, squad)
addMovementPenalty(natives, squad, attackChunk)
-- elseif (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
-- addSquadToChunk(map, attackChunk, squad)
-- addMovementPenalty(natives, squad, attackChunk)
end
if group.valid and (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
local resourceGenerator = getResourceGenerator(map, groupPosition)
local resourceGenerator = getResourceGenerator(map, attackChunk)
local distance = euclideanDistancePoints(groupPosition.x, groupPosition.y, squad.originPosition.x, squad.originPosition.y)
if (distance >= squad.maxDistance) or ((resourceGenerator ~= 0) and (getNestCount(map, chunk) == 0)) then
@ -179,9 +182,9 @@ local function attackMove(map, attackPosition, attackCmd, squad, group, natives,
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, chunk, squad)
addMovementPenalty(natives, squad, chunk)
elseif (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, attackChunk, squad)
addMovementPenalty(natives, squad, attackChunk)
-- elseif (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
-- addSquadToChunk(map, attackChunk, squad)
-- addMovementPenalty(natives, squad, attackChunk)
end
if group.valid and (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
local playerBaseGenerator = getPlayerBaseGenerator(map, attackChunk)
@ -244,10 +247,14 @@ function squadAttack.squadsBeginAttack(natives, players)
for i=1,#squads do
local squad = squads[i]
local group = squad.group
local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
if not squad.kamikaze then
squad.kamikaze = (mRandom() < kamikazeThreshold)
end
if squad.settlers then
if (squad.status == SQUAD_GUARDING) and group and group.valid then
local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
squad.kamikaze = mRandom() < kamikazeThreshold
-- local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
-- squad.kamikaze = mRandom() < kamikazeThreshold
squad.status = SQUAD_SETTLING
end
else
@ -259,10 +266,10 @@ function squadAttack.squadsBeginAttack(natives, players)
squad.frenzyPosition.y = groupPosition.y
end
local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
if not squad.kamikaze then
squad.kamikaze = (mRandom() < kamikazeThreshold)
end
-- local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
-- if not squad.kamikaze then
-- squad.kamikaze = (mRandom() < kamikazeThreshold)
-- end
if squad.kamikaze and (mRandom() < (kamikazeThreshold * 0.75)) then
squad.attackScoreFunction = ATTACK_SCORE_KAMIKAZE

View File

@ -54,7 +54,7 @@ local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
function unitGroupUtils.findNearbySquadFiltered(map, chunk, position)
for _,squad in pairs(getSquadsOnChunk(map, chunk)) do
local unitGroup = squad.group
if unitGroup and unitGroup.valid and RETREAT_FILTER[squad.status] then
if unitGroup and unitGroup.valid and (squad.status == SQUAD_RETREATING) then
if (euclideanDistanceNamed(unitGroup.position, position) <= HALF_CHUNK_SIZE) then
return squad
end
@ -66,7 +66,7 @@ function unitGroupUtils.findNearbySquadFiltered(map, chunk, position)
for i=1,#neighbors do
for _,squad in pairs(getSquadsOnChunk(map, neighbors[i])) do
local unitGroup = squad.group
if unitGroup and unitGroup.valid and RETREAT_FILTER[squad.status] then
if unitGroup and unitGroup.valid and (squad.status == SQUAD_RETREATING) then
if (euclideanDistanceNamed(unitGroup.position, position) <= HALF_CHUNK_SIZE) then
return squad
end

View File

@ -12522,7 +12522,7 @@ rampant-removeBloodParticles=The blood particles that are created when biters ar
# rampant-enableBuildings=Enable buildings and technologies rampant offers
rampant-enableSwarm=This reduces the size of the unit collision_mask causing them to reduce pathing collisions and smooth out the attacks
rampant-attack-warning=Shows a message warning players that an attack wave is incoming
rampant-newEnemies=Adds news enemies that will be dispersed over the world. This increases the RAM requirements minimum 2GB to 9GB.
rampant-newEnemies=Adds news enemies that will be dispersed over the world. This increases the RAM requirements. With 1 variation for each biter, worm, and nest and 5 tiers expect upto a 2GB RAM increase. With 20 variations and 10 tiers set expect up to 9GB RAM increase. Variations add randominess to each tier of biter, worms, or nests. Tiers are the power level of the biters.
rampant-enemySeed=The seed that powers all of the unit generation, so change this if you want the enemy stats to change
rampant-deadZoneFrequency=The percentage of zones that start without worms or nests
rampant-newEnemyNestVariations=This number corresponds to the number of variations per tier. The higher the number the smoother the enemy power curve. Min 1, Max 20

View File

@ -1,5 +1,5 @@
(module BuildScript racket
(provide run)
(provide all-defined-out)
(require file/zip)
(require json)
@ -87,8 +87,8 @@
(define (zipIt)
(makeZip modFolder))
(define (run)
;; (copyFiles modFolder)
(define (runStart)
(copyFiles modFolder)
;;(copyFiles zipModFolder)
(makeZip modFolder)
;; (makeZip modFolder)
(system*/exit-code "/data/games/factorio/bin/x64/factorio")))

View File

@ -34,7 +34,8 @@
kamikazeScore
pollution
aNe
aRNe)
aRNe
squads)
#:transparent)
(struct Chunk (kamikazeScore
@ -60,7 +61,8 @@
deathGen
pollution
aNe
aRNe)
aRNe
squads)
#:transparent)
(require threading)
@ -72,7 +74,7 @@
(define (stringToChunk str)
(match-let (((list movement base player resource passable tick rating x y nest
worms rally retreat resourceGen playerGen deathGen pollution aNe aRNe) (string-split str ",")))
worms rally retreat resourceGen playerGen deathGen pollution aNe aRNe squads) (string-split str ",")))
(apply Chunk
(cons (+ (string->number base)
(* (string->number player) 2500))
@ -95,8 +97,9 @@
(* (string->number player) 2500))
(map string->number
(list x y movement base player resource passable tick rating nest
worms rally retreat resourceGen playerGen deathGen pollution aNe aRNe))))))))))
worms rally retreat resourceGen playerGen deathGen pollution aNe
aRNe squads))))))))))
(define (chunk->string chunk)
(string-append "x: " (~v (Chunk-x chunk)) "\n"
"y: " (~v (Chunk-y chunk)) "\n"
@ -122,7 +125,8 @@
"sRet: " (~v (Chunk-retreatScore chunk)) "\n"
"pol: " (~v (Chunk-pollution chunk)) "\n"
"aNe: " (~v (Chunk-aNe chunk)) "\n"
"aRNe: " (~v (Chunk-aRNe chunk)) "\n"))
"aRNe: " (~v (Chunk-aRNe chunk)) "\n"
"sqs: " (~v (Chunk-squads chunk)) "\n"))
(define (normalizeRange xs)
(let* ((sDev (stddev xs))
@ -158,7 +162,8 @@
(sKam (map Chunk-kamikazeScore chunks))
(pol (map Chunk-pollution chunks))
(aNe (map Chunk-aNe chunks))
(aRNe (map Chunk-aRNe chunks)))
(aRNe (map Chunk-aRNe chunks))
(sqs (map Chunk-squads chunks)))
;; (ChunkRange (MinMax (apply min xs) (apply max xs))
;; (MinMax (apply min ys) (apply max ys))
@ -205,8 +210,8 @@
(normalizeRange sKam)
(normalizeRange pol)
(MinMax (apply min aNe) (apply max aNe))
(MinMax (apply min aRNe) (apply max aRNe)))
(MinMax (apply min aRNe) (apply max aRNe))
(MinMax (apply min sqs) (apply max sqs)))
))
(define (readState filePath)

View File

@ -822,32 +822,32 @@ local function addWormDefaults(template, upgrades)
name = "prepareRange",
[1] = 30,
[2] = 30,
[3] = 31,
[4] = 31,
[5] = 32,
[6] = 32,
[7] = 33,
[8] = 33,
[9] = 34,
[10] = 34
[3] = 35,
[4] = 35,
[5] = 40,
[6] = 40,
[7] = 40,
[8] = 40,
[9] = 45,
[10] = 45
})
pushUpgrade(upgrades,
{
type = "attack",
name = "range",
[1] = 21,
[2] = 22,
[3] = 23,
[4] = 23,
[5] = 24,
[6] = 26,
[7] = 26,
[8] = 28,
[9] = 30,
[10] = 32
[1] = 25,
[2] = 27,
[3] = 31,
[4] = 33,
[5] = 35,
[6] = 36,
[7] = 37,
[8] = 38,
[9] = 39,
[10] = 40
})
pushUpgrade(upgrades,
{
type = "resistance",

View File

@ -37,5 +37,81 @@ data:extend({
circuit_wire_connection_point = circuit_connector_definitions["chest"].points,
circuit_connector_sprites = circuit_connector_definitions["chest"].sprites,
circuit_wire_max_distance = default_circuit_wire_max_distance
},
{
type = "container",
name = "chunk-scanner-nest-rampant",
icon = "__base__/graphics/icons/wooden-chest.png",
icon_size = 32,
flags = {},
collision_mask = {"player-layer", "object-layer", "water-tile"},
collision_box = {{-6, -6}, {6, 6}},
selection_box = {{-6, -6}, {6, 6}},
minable = {mining_time = 1, result = "wooden-chest"},
max_health = 100,
corpse = "small-remnants",
fast_replaceable_group = "container",
inventory_size = 16,
open_sound = { filename = "__base__/sound/wooden-chest-open.ogg" },
close_sound = { filename = "__base__/sound/wooden-chest-close.ogg" },
vehicle_impact_sound = { filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0 },
picture =
{
filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
priority = "extra-high",
width = 32,
height = 36,
shift = util.by_pixel(0.5, -2),
hr_version =
{
filename = "__base__/graphics/entity/wooden-chest/hr-wooden-chest.png",
priority = "extra-high",
width = 62,
height = 72,
shift = util.by_pixel(0.5, -2),
scale = 0.5
}
},
circuit_wire_connection_point = circuit_connector_definitions["chest"].points,
circuit_connector_sprites = circuit_connector_definitions["chest"].sprites,
circuit_wire_max_distance = default_circuit_wire_max_distance
},
{
type = "container",
name = "chunk-scanner-worm-rampant",
icon = "__base__/graphics/icons/wooden-chest.png",
icon_size = 32,
flags = {},
collision_mask = {"player-layer", "object-layer", "water-tile"},
collision_box = {{-3, -3}, {3, 3}},
selection_box = {{-3, -3}, {3, 3}},
minable = {mining_time = 1, result = "wooden-chest"},
max_health = 100,
corpse = "small-remnants",
fast_replaceable_group = "container",
inventory_size = 16,
open_sound = { filename = "__base__/sound/wooden-chest-open.ogg" },
close_sound = { filename = "__base__/sound/wooden-chest-close.ogg" },
vehicle_impact_sound = { filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0 },
picture =
{
filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
priority = "extra-high",
width = 32,
height = 36,
shift = util.by_pixel(0.5, -2),
hr_version =
{
filename = "__base__/graphics/entity/wooden-chest/hr-wooden-chest.png",
priority = "extra-high",
width = 62,
height = 72,
shift = util.by_pixel(0.5, -2),
scale = 0.5
}
},
circuit_wire_connection_point = circuit_connector_definitions["chest"].points,
circuit_connector_sprites = circuit_connector_definitions["chest"].sprites,
circuit_wire_max_distance = default_circuit_wire_max_distance
}
})

View File

@ -9,11 +9,11 @@ function vanillaUpdates.useDumbProjectiles()
local attackType = (FORCE_OLD_PROJECTILES and "stream") or "projectile"
local unitPrefix = (FORCE_OLD_PROJECTILES and "") or "direction-"
turrets["small-worm-turret"]["attack_parameters"] = biterUtils.createRangedAttack(
{
cooldown = 60,
range = 21,
range = 25,
min_range = 5,
turn_range = 1,
type = "projectile",
@ -26,7 +26,7 @@ function vanillaUpdates.useDumbProjectiles()
turrets["medium-worm-turret"]["attack_parameters"] = biterUtils.createRangedAttack(
{
cooldown = 60,
range = 25,
range = 30,
min_range = 3,
turn_range = 1,
type = "projectile",
@ -40,7 +40,7 @@ function vanillaUpdates.useDumbProjectiles()
turrets["big-worm-turret"]["attack_parameters"] = biterUtils.createRangedAttack(
{
cooldown = 60,
range = 26,
range = 38,
min_range = 3,
type = "projectile",
turn_range = 1,
@ -52,15 +52,14 @@ function vanillaUpdates.useDumbProjectiles()
turrets["behemoth-worm-turret"]["attack_parameters"] = biterUtils.createRangedAttack(
{
cooldown = 60,
range = 26,
range = 48,
min_range = 3,
type = "projectile",
turn_range = 1,
fire_penalty = 0,
scale = 1.2
scale = 1.5
},
"acid-ball-5-" .. attackType .. "-rampant")
"acid-ball-5-" .. attackType .. "-rampant")
local units = data.raw["unit"];

View File

@ -391,7 +391,8 @@ function tests.exportAiState()
chunkPropertyUtils.getDeathGenerator(global.map, chunk),
game.surfaces[global.natives.activeSurface].get_pollution(chunk),
chunkPropertyUtils.getNestActiveness(global.map, chunk),
chunkPropertyUtils.getRaidNestActiveness(global.map, chunk)}, ",") .. "\n"
chunkPropertyUtils.getRaidNestActiveness(global.map, chunk),
#chunkPropertyUtils.getSquadsOnChunk(global.map, chunk)}, ",") .. "\n"
end
game.write_file("rampantState.txt", s, false)
end

View File

@ -4,7 +4,7 @@
(define CHUNK_SIZE 32)
(define INVALID_CHUNK (Chunk -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))
(define INVALID_CHUNK (Chunk -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))
(define windowX 500)
(define windowY 0)
@ -142,7 +142,8 @@
kamikazeScore
pollution
aNe
aRNe) chunkMinMaxes))
aRNe
squads) chunkMinMaxes))
(set! activeChunkSet chunks)
(set! activeChunkMinMaxSet chunkMinMaxes)
@ -267,7 +268,7 @@
(new radio-box%
[label "Show Layer"]
[choices (list "movement" "base" "player" "resource" "passable" "tick" "rating" "nests" "worms" "rally" "retreat" "resourceGen" "playerGen" "deathGen" "attackScore" "settleScore" "siegeScore" "retreatScore" "kamikazeScore" "pollution" "aNe" "aRNe")]
[choices (list "movement" "base" "player" "resource" "passable" "tick" "rating" "nests" "worms" "rally" "retreat" "resourceGen" "playerGen" "deathGen" "attackScore" "settleScore" "siegeScore" "retreatScore" "kamikazeScore" "pollution" "aNe" "aRNe" "squads")]
[selection 0]
[parent mainFrame]
(callback (lambda (radioButton event)