1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-14 02:23:01 +02:00

cleaned up config.lua and distributed methods into code files

This commit is contained in:
Aaron Veden 2021-12-04 11:42:41 -08:00
parent 9dfb61e735
commit 31c50a15c8
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
5 changed files with 18 additions and 48 deletions

View File

@ -43,6 +43,7 @@ Date: 23. 11. 2021
Framework:
- Fixed Rampant in-memory map visualization tool for debugging
- Added debug mod settings for showing enemy structures being upgraded in place
- Moved config methods into relevant code files
Removals:
- Removed map deadzones as they were breaking regional bases

View File

@ -1,40 +0,0 @@
local config = {}
-- imported
local mathUtils = require("libs/MathUtils")
-- imported functions
local gaussianRandomRange = mathUtils.gaussianRandomRange
local mCeil = math.ceil
-- automatic mod detection
config.ionCannonPresent = settings.startup["ion-cannon-radius"] ~= nil
-- configurations
--[[
attackWaveScaling is used to calculate the attack wave size from the evolutionFactor
default is universe.attackWaveMaxSize * (evolutionFactor ^ 1.666667)
DOES NOT affect vanilla biters waves
--]]
config.attackWaveScaling = function (universe)
return mCeil(gaussianRandomRange(universe.attackWaveSize,
universe.attackWaveDeviation,
1,
universe.attackWaveUpperBound))
end
config.settlerWaveScaling = function (universe)
return mCeil(gaussianRandomRange(universe.settlerWaveSize,
universe.settlerWaveDeviation,
universe.expansionMinSize,
universe.expansionMaxSize))
end
return config

View File

@ -17,7 +17,6 @@ local aiPlanning = require("libs/AIPlanning")
local tests = require("tests")
local chunkUtils = require("libs/ChunkUtils")
local upgrade = require("Upgrade")
local config = require("config")
local aiPredicates = require("libs/AIPredicates")
local stringUtils = require("libs/StringUtils")
@ -101,7 +100,6 @@ local findNearbyBase = baseUtils.findNearbyBase
local processActiveNests = mapProcessor.processActiveNests
local getDeathGenerator = chunkPropertyUtils.getDeathGenerator
local setChunkBase = chunkPropertyUtils.setChunkBase
local retreatUnits = squadDefense.retreatUnits
@ -147,7 +145,7 @@ local function onIonCannonFired(event)
end
local function hookEvents()
if config.ionCannonPresent then
if settings.startup["ion-cannon-radius"] ~= nil then
script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_fired"),
onIonCannonFired)
end

View File

@ -11,7 +11,6 @@ local chunkPropertyUtils = require("ChunkPropertyUtils")
local unitGroupUtils = require("UnitGroupUtils")
local movementUtils = require("MovementUtils")
local mathUtils = require("MathUtils")
local config = require("__Rampant__/config")
local baseUtils = require("BaseUtils")
-- constants
@ -61,12 +60,26 @@ local getChunkByXY = mapUtils.getChunkByXY
local scoreNeighborsForFormation = movementUtils.scoreNeighborsForFormation
local scoreNeighborsForResource = movementUtils.scoreNeighborsForResource
local createSquad = unitGroupUtils.createSquad
local attackWaveScaling = config.attackWaveScaling
local settlerWaveScaling = config.settlerWaveScaling
local getDeathGenerator = chunkPropertyUtils.getDeathGenerator
local mCeil = math.ceil
-- module code
local function settlerWaveScaling(universe)
return mCeil(gaussianRandomRange(universe.settlerWaveSize,
universe.settlerWaveDeviation,
universe.expansionMinSize,
universe.expansionMaxSize))
end
local function attackWaveScaling(universe)
return mCeil(gaussianRandomRange(universe.attackWaveSize,
universe.attackWaveDeviation,
1,
universe.attackWaveUpperBound))
end
local function attackWaveValidCandidate(chunk, map)
local isValid = getNestActiveness(map, chunk)
if map.state == AI_STATE_RAIDING then

View File

@ -28,7 +28,6 @@
#:path-prefix packageName
(string->path "info.json")
(string->path "control.lua")
(string->path "config.lua")
(string->path "data.lua")
(string->path "data-updates.lua")
(string->path "data-final-fixes.lua")
@ -69,7 +68,6 @@
(sleep 0.1)
(make-directory packagePath)
(copyFile "control.lua" modFolder)
(copyFile "config.lua" modFolder)
(copyFile "info.json" modFolder)
(copyFile "data.lua" modFolder)
(copyFile "data-updates.lua" modFolder)