Skip to content

Commit

Permalink
see readme
Browse files Browse the repository at this point in the history
  • Loading branch information
veden committed May 27, 2017
1 parent 49a82fc commit 9e361b3
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 169 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ https://forums.factorio.com/viewtopic.php?f=94&t=31445
There will be a slight pause the first time this is started up due to indexing all the chunks that have been generated.

MP should be working
If experiencing desyncs, after an update, please due the following:
1) let me know
2) Load save with Rampant enabled
3) Save the map after Rampant has been updated
4) Load save in step 3

Configure Options not in game menu:
- Ramp up to max biter wave size
Expand Down Expand Up @@ -50,6 +55,20 @@ Configure Options not in game menu:

# Version History

0.15.10 -
- Fix: nil chunk in pheromone utils(https://mods.factorio.com/mods/Veden/Rampant/discussion/13806)
- Tweak: Increased failed behaviors before dispanding from 3 to 6
- Improvement: Switched to untargetable indestructible safe buildings
- Improvement: Changed the "ground shake" message to be displayed at a more appropriate time
- Improvement: Recycling biter groups now has a lower threshold and checks for active nearby squads before purging the clusters
- Optimization: Adjusted factorio pathfinder parameters to favor short paths for performance
- Optimization: Moved invariants out of inner loop in pheromone dispersion
- Optimization: Reduced garbage generated when doing passive map scan
- Optimization: Switched rally cries to a once per logic cycle per chunk
- Optimization: Locallized global defines in files that use them
- Optimization: Preallocating tables of falses for chunk neighbors
- Framework: Split squad regrouping and squad cleanup

0.15.9 -
- Improvement: Added bobs higher tier big electric poles to be included with make safe toggle for big electric poles
- Improvement: Added logic to reconnect wires when big electric poles are made safe and get destroyed (Thanks Jeroen D Stout, https://forums.factorio.com/viewtopic.php?f=94&t=31445&start=140#p275663)
Expand Down
100 changes: 46 additions & 54 deletions Upgrade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,101 +42,93 @@ function upgrade.attempt(natives, regionMap)
regionMap.pP = nil
regionMap.pR = nil

global.version = constants.VERSION_9
global.version = constants.VERSION_9
end
if (global.version < constants.VERSION_10) then
for _,squad in pairs(natives.squads) do
squad.frenzy = false
squad.frenzyPosition = {x=0,y=0}
squad.rabid = false
end
for _,squad in pairs(natives.squads) do
squad.frenzy = false
squad.frenzyPosition = {x=0,y=0}
squad.rabid = false
end

global.version = constants.VERSION_10
global.version = constants.VERSION_10
end
if (global.version < constants.VERSION_11) then
natives.state = constants.AI_STATE_AGGRESSIVE
natives.temperament = 0
natives.state = constants.AI_STATE_AGGRESSIVE
natives.temperament = 0

global.version = constants.VERSION_11
global.version = constants.VERSION_11
end
if (global.version < constants.VERSION_12) then
for _,squad in pairs(natives.squads) do
squad.status = constants.SQUAD_GUARDING
squad.kamikaze = false
end
for _,squad in pairs(natives.squads) do
squad.status = constants.SQUAD_GUARDING
squad.kamikaze = false
end

-- reset ai build points due to error in earning points
natives.points = 0
-- reset ai build points due to error in earning points
natives.points = 0

global.version = constants.VERSION_12
end
if (global.version < constants.VERSION_13) then

-- used to rate limit the number of rally cries during a period of time
natives.rallyCries = MAX_RALLY_CRIES

global.version = constants.VERSION_13
end
if (global.version < constants.VERSION_14) then
game.map_settings.unit_group.member_disown_distance = 5
game.map_settings.unit_group.max_member_speedup_when_behind = 1.1
game.map_settings.unit_group.max_member_slowdown_when_ahead = 1.0
game.map_settings.unit_group.max_group_slowdown_factor = 0.9

game.surfaces[1].print("Rampant - Version 0.14.11")
global.version = constants.VERSION_14
global.version = constants.VERSION_12
end
if (global.version < constants.VERSION_16) then

natives.lastShakeMessage = 0
--remove version 14 retreat limit, it has been made redundant
natives.retreats = nil

game.map_settings.unit_group.max_group_radius = 20
natives.lastShakeMessage = 0
--remove version 14 retreat limit, it has been made redundant
natives.retreats = nil

game.surfaces[1].print("Rampant - Version 0.14.13")
global.version = constants.VERSION_16
game.surfaces[1].print("Rampant - Version 0.14.13")
global.version = constants.VERSION_16
end
if (global.version < constants.VERSION_18) then

print(global.version)

natives.safeEntities = {}
natives.safeEntityName = {}

game.surfaces[1].print("Rampant - Version 0.15.5")
global.version = constants.VERSION_18
end
if (global.version < constants.VERSION_20) then

natives.aiPointsScaler = settings.global["rampant-aiPointsScaler"].value
natives.aiNocturnalMode = settings.global["rampant-permanentNocturnal"].value

game.surfaces[1].print("Rampant - Version 0.15.8")
global.version = constants.VERSION_20
end
if (global.version < constants.VERSION_21) then

game.surfaces[1].print("Rampant - Version 0.15.9")
global.version = constants.VERSION_21
end
if (global.version < constants.VERSION_22) then

-- been made redundant
natives.rallyCries = nil

-- switched over to tick event
regionMap.logicTick = roundToNearest(game.tick + INTERVAL_LOGIC, INTERVAL_LOGIC)
regionMap.processTick = roundToNearest(game.tick + INTERVAL_PROCESS, INTERVAL_PROCESS)
-- needs to be on inner logic tick loop interval
natives.stateTick = roundToNearest(game.tick + INTERVAL_LOGIC, INTERVAL_LOGIC)
natives.temperamentTick = roundToNearest(game.tick + INTERVAL_LOGIC, INTERVAL_LOGIC)

game.map_settings.path_finder.short_request_ratio = 0.8
game.map_settings.path_finder.short_cache_size = 25
game.map_settings.path_finder.long_cache_size = 5
game.map_settings.path_finder.min_steps_to_check_path_find_termination = 300

game.map_settings.max_failed_behavior_count = 6
--[[
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
--]]
local mapSettings = game.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.max_failed_behavior_count = constants.MAX_FAILED_BEHAVIORS

mapSettings.unit_group.member_disown_distance = constants.UNIT_GROUP_DISOWN_DISTANCE
mapSettings.unit_group.tick_tolerance_when_member_arrives = constants.UNIT_GROUP_TICK_TOLERANCE

mapSettings.unit_group.max_group_radius = constants.UNIT_GROUP_MAX_RADIUS
mapSettings.unit_group.max_member_speedup_when_behind = constants.UNIT_GROUP_MAX_SPEED_UP
mapSettings.unit_group.max_member_slowdown_when_ahead = constants.UNIT_GROUP_MAX_SLOWDOWN
mapSettings.unit_group.max_group_slowdown_factor = constants.UNIT_GROUP_SLOWDOWN_FACTOR

game.surfaces[1].print("Rampant - Version 0.15.10")
global.version = constants.VERSION_22
end
Expand Down
24 changes: 12 additions & 12 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ local squadBeginAttack = aiAttack.squadBeginAttack

local retreatUnits = aiDefense.retreatUnits

-- local regenerateEntity = entityUtils.regenerateEntity
local addRemoveEntity = entityUtils.addRemoveEntity
local makeImmortalEntity = entityUtils.makeImmortalEntity

Expand All @@ -80,7 +79,7 @@ local function onChunkGenerated(event)
end

local function onModSettingsChange(event)

if event and (string.sub(event.setting, 1, 7) ~= "rampant") then
return
end
Expand Down Expand Up @@ -112,6 +111,7 @@ local function onModSettingsChange(event)
end

local function onConfigChanged()

if upgrade.attempt(natives, regionMap) then
onModSettingsChange(nil)

Expand All @@ -132,7 +132,7 @@ local function onConfigChanged()
area = { left_top = { x = chunk.x * 32,
y = chunk.y * 32 }}})
end
end
end
end

local function onTick(event)
Expand All @@ -142,25 +142,24 @@ local function onTick(event)
local surface = game.surfaces[1]
local evolutionFactor = game.forces.enemy.evolution_factor
local players = game.players

processPendingChunks(natives, regionMap, surface, pendingChunks)
scanMap(regionMap, surface, natives, evolutionFactor)

if (tick == regionMap.logicTick) then
regionMap.logicTick = regionMap.logicTick + INTERVAL_LOGIC

planning(natives, evolutionFactor, tick, surface)

cleanSquads(natives, evolutionFactor)
-- regroupSquads(natives, evolutionFactor)
regroupSquads(natives, evolutionFactor)

processPlayers(players, regionMap, surface, natives, evolutionFactor, tick)

squadBeginAttack(natives, players, evolutionFactor)
squadAttack(regionMap, surface, natives)
end

processMap(regionMap, surface, natives, evolutionFactor)
processMap(regionMap, surface, natives, evolutionFactor)
end
end

Expand All @@ -187,12 +186,12 @@ local function onDeath(event)
local entityPosition = entity.position
local deathChunk = getChunkByPosition(regionMap, entityPosition.x, entityPosition.y)

if (deathChunk ~= nil) then
if deathChunk then
-- drop death pheromone where unit died
deathScent(deathChunk)

if ((event.force ~= nil) and (event.force.name == "player")) then
local evolutionFactor = game.forces.enemy.evolution_factor
local evolutionFactor = entity.force.evolution_factor
local tick = event.tick

if (deathChunk[MOVEMENT_PHEROMONE] < -(evolutionFactor * RETREAT_MOVEMENT_PHEROMONE_LEVEL)) then
Expand All @@ -216,7 +215,6 @@ local function onDeath(event)
end
end

-- removeScout(entity, natives)
elseif (entity.type == "unit-spawner") or (entity.type == "turret") then
addRemoveEntity(regionMap, entity, natives, false, false)
end
Expand All @@ -226,7 +224,9 @@ local function onDeath(event)
if (event.force ~= nil) and (event.force.name == "enemy") then
creditNatives = true
local victoryChunk = getChunkByPosition(regionMap, entityPosition.x, entityPosition.y)
victoryScent(victoryChunk, entity.type)
if victoryChunk then
victoryScent(victoryChunk, entity.type)
end
end
if creditNatives and natives.safeBuildings and (natives.safeEntities[entity.type] or natives.safeEntityName[entity.name]) then
makeImmortalEntity(surface, entity)
Expand Down
21 changes: 21 additions & 0 deletions data-updates.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local vanillaUpdates = require("prototypes/enemies/UpdatesVanilla")
local bobsUpdates = require("prototypes/enemies/UpdatesBobs")
local NEUpdates = require("prototypes/enemies/UpdatesNE")
local constants = require("libs/Constants")

local function bobsDetected()
return data.raw["turret"]["bob-big-explosive-worm-turret"] ~= nil
Expand All @@ -25,6 +26,26 @@ if settings.startup["rampant-useDumbProjectiles"].value then
end
end

--[[
try to make sure new maps use the correct map settings without having to completely load the mod.
done because seeing desync issues with dynamic map-settings changes before re-saving the map.
--]]
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.max_failed_behavior_count = constants.MAX_FAILED_BEHAVIORS

mapSettings.unit_group.member_disown_distance = constants.UNIT_GROUP_DISOWN_DISTANCE
mapSettings.unit_group.tick_tolerance_when_member_arrives = constants.UNIT_GROUP_TICK_TOLERANCE

mapSettings.unit_group.max_group_radius = constants.UNIT_GROUP_MAX_RADIUS
mapSettings.unit_group.max_member_speedup_when_behind = constants.UNIT_GROUP_MAX_SPEED_UP
mapSettings.unit_group.max_member_slowdown_when_ahead = constants.UNIT_GROUP_MAX_SLOWDOWN
mapSettings.unit_group.max_group_slowdown_factor = constants.UNIT_GROUP_SLOWDOWN_FACTOR



Loading

0 comments on commit 9e361b3

Please sign in to comment.