mirror of
https://github.com/veden/Rampant.git
synced 2025-03-17 20:58:35 +02:00
AI Points: Print spending to chat, print gains to chat, award idle biters bonus points
Configurable settings for: 1) Printing AI point spending to chat 2) Printing AI point gains to chat 3) Granting "Idle Biters" bonus points
This commit is contained in:
parent
8e46e96667
commit
292d407e13
@ -336,6 +336,11 @@ function upgrade.attempt(universe)
|
||||
universe.safeEntities = {}
|
||||
|
||||
universe.aiPointsScaler = settings.global["rampant--aiPointsScaler"].value
|
||||
|
||||
universe.aiPointsPrintGainsToChat = settings.global["rampant--aiPointsPrintGainsToChat"].value
|
||||
universe.aiPointsPrintSpendingToChat = settings.global["rampant--aiPointsPrintSpendingToChat"].value
|
||||
universe.aiPointsIdleAwardValue = settings.global["rampant--aiPointsIdleAwardValue"].value
|
||||
|
||||
universe.aiNocturnalMode = settings.global["rampant--permanentNocturnal"].value
|
||||
|
||||
universe.mapIterator = nil
|
||||
|
55
control.lua
55
control.lua
@ -132,7 +132,10 @@ local function onIonCannonFired(event)
|
||||
local map = universe.maps[event.surface.index]
|
||||
map.ionCannonBlasts = map.ionCannonBlasts + 1
|
||||
map.points = map.points + 4000
|
||||
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. 4000 .. ". [Ion Cannon] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
|
||||
local chunk = getChunkByPosition(map, event.position)
|
||||
if (chunk ~= -1) then
|
||||
rallyUnits(chunk, map, event.tick)
|
||||
@ -165,6 +168,8 @@ local function onModSettingsChange(event)
|
||||
return
|
||||
end
|
||||
|
||||
--game.print("onModSettingsChange() processing for Rampant")
|
||||
|
||||
upgrade.compareTable(universe,
|
||||
"safeBuildings",
|
||||
settings.global["rampant--safeBuildings"].value)
|
||||
@ -232,6 +237,11 @@ local function onModSettingsChange(event)
|
||||
"aiPointsScaler",
|
||||
settings.global["rampant--aiPointsScaler"].value)
|
||||
|
||||
|
||||
universe.aiPointsIdleAwardValue = settings.global["rampant--aiPointsIdleAwardValue"].value
|
||||
universe.aiPointsPrintGainsToChat = settings.global["rampant--aiPointsPrintGainsToChat"].value
|
||||
universe.aiPointsPrintSpendingToChat = settings.global["rampant--aiPointsPrintSpendingToChat"].value
|
||||
|
||||
universe.enabledMigration = universe.expansion and settings.global["rampant--enableMigration"].value
|
||||
universe.peacefulAIToggle = settings.global["rampant--peacefulAIToggle"].value
|
||||
universe.printAIStateChanges = settings.global["rampant--printAIStateChanges"].value
|
||||
@ -485,9 +495,18 @@ local function onDeath(event)
|
||||
elseif event.force and (event.force.name ~= "enemy") and
|
||||
((entityType == "unit-spawner") or (entityType == "turret"))
|
||||
then
|
||||
map.points = map.points +
|
||||
(((entityType == "unit-spawner") and RECOVER_NEST_COST) or RECOVER_WORM_COST)
|
||||
|
||||
if (entityType == "unit-spawner") then
|
||||
map.points = map.points + RECOVER_NEST_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. RECOVER_NEST_COST .. ". [Nest Lost] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
else
|
||||
map.points = map.points + RECOVER_WORM_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. RECOVER_WORM_COST .. ". [Worm Lost] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
end
|
||||
|
||||
unregisterEnemyBaseStructure(map, entity)
|
||||
|
||||
if (chunk ~= -1) then
|
||||
@ -728,6 +747,9 @@ local function onRocketLaunch(event)
|
||||
local map = universe.maps[entity.surface.index]
|
||||
map.rocketLaunched = map.rocketLaunched + 1
|
||||
map.points = map.points + 5000
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. 5000 .. ". [Rocket Launch] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -798,6 +820,9 @@ local function onUnitGroupCreated(event)
|
||||
if not settler and universe.squadCount > universe.AI_MAX_SQUAD_COUNT then
|
||||
group.destroy()
|
||||
map.points = map.points + AI_SQUAD_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. AI_SQUAD_COST .. ". [Squad Refund] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@ -812,6 +837,9 @@ local function onUnitGroupCreated(event)
|
||||
else
|
||||
if not (surface.darkness > 0.65) then
|
||||
map.points = map.points + AI_SQUAD_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. AI_SQUAD_COST .. ". [Squad Refund] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
group.destroy()
|
||||
return
|
||||
end
|
||||
@ -823,6 +851,9 @@ local function onUnitGroupCreated(event)
|
||||
if not settler and universe.squadCount > universe.AI_MAX_SQUAD_COUNT then
|
||||
group.destroy()
|
||||
map.points = map.points + AI_SQUAD_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. AI_SQUAD_COST .. ". [Squad Refund] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@ -850,6 +881,9 @@ local function onGroupFinishedGathering(event)
|
||||
else
|
||||
group.destroy()
|
||||
map.points = map.points + AI_SETTLER_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. AI_SETTLER_COST .. ". [Settler Refund] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
end
|
||||
else
|
||||
if (universe.squadCount < universe.AI_MAX_SQUAD_COUNT) then
|
||||
@ -857,6 +891,9 @@ local function onGroupFinishedGathering(event)
|
||||
else
|
||||
group.destroy()
|
||||
map.points = map.points + AI_SQUAD_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. AI_SQUAD_COST .. ". [Squad Refund] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -867,6 +904,9 @@ local function onGroupFinishedGathering(event)
|
||||
if not settler and universe.squadCount > universe.AI_MAX_SQUAD_COUNT then
|
||||
group.destroy()
|
||||
map.points = map.points + AI_SQUAD_COST
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. AI_SQUAD_COST .. ". [Squad Refund] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@ -920,7 +960,12 @@ local function onBuilderArrived(event)
|
||||
local targetPosition = universe.position
|
||||
targetPosition.x = builder.position.x
|
||||
targetPosition.y = builder.position.y
|
||||
|
||||
|
||||
--local map = universe.maps[event.surface.index] -- crashes
|
||||
if universe.aiPointsPrintSpendingToChat then
|
||||
--game.print(map.surface.name .. ": Settled: [gps=" .. targetPosition.x .. "," .. targetPosition.y .."]") -- crashes
|
||||
game.print("Settled: [gps=" .. targetPosition.x .. "," .. targetPosition.y .."]")
|
||||
end
|
||||
builder.surface.create_entity(universe.createBuildCloudQuery)
|
||||
end
|
||||
|
||||
|
@ -227,6 +227,9 @@ function aiAttackWave.formSettlers(map, chunk)
|
||||
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe)
|
||||
universe.builderCount = universe.builderCount + 1
|
||||
map.points = map.points - AI_SETTLER_COST
|
||||
if universe.aiPointsPrintSpendingToChat then
|
||||
game.print(map.surface.name .. ": Points: -" .. AI_SETTLER_COST .. ". [Settler] Total: " .. string.format("%.2f", map.points) .. " [gps=" .. squadPosition.x .. "," .. squadPosition.y .. "]")
|
||||
end
|
||||
map.groupNumberToSquad[squad.groupNumber] = squad
|
||||
else
|
||||
if (squad.group.valid) then
|
||||
@ -272,6 +275,9 @@ function aiAttackWave.formVengenceSquad(map, chunk)
|
||||
map.groupNumberToSquad[squad.groupNumber] = squad
|
||||
universe.squadCount = universe.squadCount + 1
|
||||
map.points = map.points - AI_VENGENCE_SQUAD_COST
|
||||
if universe.aiPointsPrintSpendingToChat then
|
||||
game.print(map.surface.name .. ": Points: -" .. AI_VENGENCE_SQUAD_COST .. ". [Vengence] Total: " .. string.format("%.2f", map.points) .. " [gps=" .. squadPosition.x .. "," .. squadPosition.y .. "]")
|
||||
end
|
||||
else
|
||||
if (squad.group.valid) then
|
||||
squad.group.destroy()
|
||||
@ -322,6 +328,9 @@ function aiAttackWave.formSquads(map, chunk, tick)
|
||||
AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION,
|
||||
AGGRESSIVE_CAN_ATTACK_WAIT_MAX_DURATION)
|
||||
end
|
||||
if universe.aiPointsPrintSpendingToChat then
|
||||
game.print(map.surface.name .. ": Points: -" .. AI_SQUAD_COST .. ". [Squad] Total: " .. string.format("%.2f", map.points) .. " [gps=" .. squadPosition.x .. "," .. squadPosition.y .. "]")
|
||||
end
|
||||
else
|
||||
if (squad.group.valid) then
|
||||
squad.group.destroy()
|
||||
|
@ -94,6 +94,30 @@ function aiPlanning.planning(map, evolution_factor, tick)
|
||||
|
||||
universe.unitRefundAmount = AI_UNIT_REFUND * evolution_factor
|
||||
universe.kamikazeThreshold = NO_RETREAT_BASE_PERCENT + (evolution_factor * NO_RETREAT_EVOLUTION_BONUS_MAX)
|
||||
|
||||
if (map.lastPoints ~= nil) then
|
||||
-- game.print(map.points .. " " .. map.lastPoints)
|
||||
if (map.points ~= map.lastPoints) then
|
||||
if (false) then
|
||||
game.print(map.surface.name .. ": map.points = " .. string.format("%.2f", map.points) .. " ( " .. string.format("%.2f", map.points - map.lastPoints) .. " change)")
|
||||
end
|
||||
map.lastPointsUpdateTick = tick
|
||||
else
|
||||
if (universe.aiPointsIdleAwardValue > 0 and tick - map.lastPointsUpdateTick > 3600) then -- if our setting is enabled and we haven't generated non-passive points in the last minute
|
||||
local targetPoints = map.points + universe.aiPointsIdleAwardValue
|
||||
if (targetPoints < maxOverflowPoints) then
|
||||
map.points = targetPoints
|
||||
map.lastPointsUpdateTick = tick
|
||||
|
||||
if (universe.aiPointsPrintGainsToChat) then
|
||||
game.print(map.surface.name .. ": Points: +" .. universe.aiPointsIdleAwardValue .. ". [Idle Biters] Total: " .. string.format("%.2f", map.points) .. " (" .. string.format("%.2f", maxOverflowPoints) .. " is max)")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
map.lastPointsUpdateTick = tick
|
||||
end
|
||||
|
||||
local points = ((AI_POINT_GENERATOR_AMOUNT * mRandom()) + (map.activeNests * 0.001) +
|
||||
(AI_POINT_GENERATOR_AMOUNT * mMax(evolution_factor ^ 2.5, 0.1))) * universe.aiPointsScaler
|
||||
@ -114,6 +138,8 @@ function aiPlanning.planning(map, evolution_factor, tick)
|
||||
map.points = maxOverflowPoints
|
||||
end
|
||||
|
||||
map.lastPoints = map.points
|
||||
|
||||
if (map.stateTick <= tick) then
|
||||
local roll = mRandom()
|
||||
if (map.temperament < 0.05) then -- 0 - 0.05
|
||||
@ -267,12 +293,24 @@ function aiPlanning.planning(map, evolution_factor, tick)
|
||||
map.stateTick = randomTickEvent(tick, AI_MIN_STATE_DURATION, AI_MAX_STATE_DURATION)
|
||||
|
||||
if universe.printAIStateChanges then
|
||||
game.print(map.surface.name .. ": AI state is now: " .. constants.stateEnglish[map.state] .. ", Next state change is in " .. (map.stateTick - tick) / 60 .. " seconds")
|
||||
game.print(map.surface.name .. ": AI is now: " .. constants.stateEnglish[map.state] .. ", Next state change is in " .. string.format("%.2f", (map.stateTick - tick) / (60*60)) .. " minutes @ " .. getTimeStringFromTick(map.stateTick) .. " playtime")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function getTimeStringFromTick(tick)
|
||||
|
||||
local tickToSeconds = tick / 60
|
||||
|
||||
local days = math.floor(tickToSeconds / 86400)
|
||||
local hours = math.floor((tickToSeconds % 86400) / 3600)
|
||||
local minutes = math.floor((tickToSeconds % 3600) / 60)
|
||||
local seconds = math.floor(tickToSeconds % 60)
|
||||
return days .. "d " .. hours .. "h " .. minutes .. "m " .. seconds .. "s"
|
||||
end
|
||||
|
||||
|
||||
|
||||
function aiPlanning.temperamentPlanner(map)
|
||||
local destroyPlayerBuildings = map.destroyPlayerBuildings
|
||||
|
@ -535,16 +535,22 @@ end
|
||||
|
||||
function chunkUtils.accountPlayerEntity(entity, map, addObject, creditNatives)
|
||||
if (BUILDING_PHEROMONES[entity.type] ~= nil) and (entity.force.name ~= "enemy") then
|
||||
local universe = map.universe
|
||||
local entityValue = BUILDING_PHEROMONES[entity.type]
|
||||
|
||||
local overlapArray = getEntityOverlapChunks(map, entity)
|
||||
if not addObject then
|
||||
if creditNatives then
|
||||
map.destroyPlayerBuildings = map.destroyPlayerBuildings + 1
|
||||
if (map.state == AI_STATE_ONSLAUGHT) then
|
||||
map.points = map.points + entityValue
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. math.floor(entityValue) .. ". [Structure Kill] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
else
|
||||
map.points = map.points + (entityValue * 0.12)
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
game.print(map.surface.name .. ": Points: +" .. math.floor(entityValue * 0.12) .. ". [Structure Kill] Total: " .. string.format("%.2f", map.points))
|
||||
end
|
||||
end
|
||||
end
|
||||
entityValue = -entityValue
|
||||
|
@ -18807,6 +18807,9 @@ rampant--safeBuildings-railSignals=Safety: Make rail signals safe from biters
|
||||
rampant--safeBuildings-trainStops=Safety: Make train stops safe from biters
|
||||
rampant--permanentNocturnal=AI: Nocturnal Mode
|
||||
rampant--aiPointsScaler=AI: Difficulty Scaling
|
||||
rampant--aiPointsIdleAwardValue=AI: Award Idle Biters Points
|
||||
rampant--aiPointsPrintSpendingToChat=AI: Print Point Spending to Chat
|
||||
rampant--aiPointsPrintGainsToChat=AI: Print Point Gains to Chat
|
||||
rampant--addWallResistanceAcid=Safety; Increase wall resistance to spitters
|
||||
rampant--safeBuildings-lamps=Safety: Make lamps safe from biters
|
||||
rampant--removeBloodParticles=Optimization: Remove blood particles (Reduces lag spikes)
|
||||
@ -18906,6 +18909,9 @@ rampant--safeBuildings-lamps=Make lamps safe from biters
|
||||
rampant--safeBuildings-trainStops=Make train stops safe from biters
|
||||
rampant--permanentNocturnal=Toggling this will cause Rampant attack waves to spawn at night. Works better with the clockwork mod or a mod that extends night.
|
||||
rampant--aiPointsScaler=Between 0.0 and 100.0. This scales how many action points the ai gets per logic cycle to perform actions like making attack waves. 0.3 - very easy, 0.75 - easy, 1.0 - medium, 1.25+ - hard
|
||||
rampant--aiPointsIdleAwardValue=Between 0.0 and 400.0. If the biters have not gained or spent any action points in the last rolling 60 seconds then award them with this many points. This does not consider passive point generation. For reference, 400 is the cost of an expansion squad and 175 is the cost of an attack squad.
|
||||
rampant--aiPointsPrintSpendingToChat=Print a message to chat whenever Rampant spends points. Includes GPS coordinates. Keep disabled for the hardest Rampant experience. Heads up: can fill up chat quickly during busy battles!
|
||||
rampant--aiPointsPrintGainsToChat=Print a message to chat whenever Rampant gains points. Does not show passive point generation. Keep disabled for the hardest Rampant experience. Heads up: can fill up chat quickly during busy battles!
|
||||
rampant--addWallResistanceAcid=Toggling this will cause a %60 acid resistance to be added to all wall entities to reduce the damage done by spitters to walls.
|
||||
rampant--removeBloodParticles=The blood particles that are created when biters are being killed can cause UPS spikes, this removes them.
|
||||
rampant--enableSwarm=This reduces the size of the unit collision_mask causing them to reduce pathing collisions and smooth out the attacks
|
||||
|
36
settings.lua
36
settings.lua
@ -496,10 +496,42 @@ data:extend({
|
||||
default_value = 1.0,
|
||||
minimum_value = 0.0,
|
||||
maximum_value = 100.0,
|
||||
order = "m[total]-b[ai]",
|
||||
order = "m[total]-b[ai]1",
|
||||
per_user = false
|
||||
},
|
||||
|
||||
{
|
||||
type = "double-setting",
|
||||
name = "rampant--aiPointsIdleAwardValue",
|
||||
description = "rampant--aiPointsIdleAwardValue",
|
||||
setting_type = "runtime-global",
|
||||
default_value = 0.0,
|
||||
minimum_value = 0.0,
|
||||
maximum_value = 400.0,
|
||||
order = "m[total]-b[ai]2",
|
||||
per_user = false
|
||||
},
|
||||
|
||||
{
|
||||
type = "bool-setting",
|
||||
name = "rampant--aiPointsPrintSpendingToChat",
|
||||
description = "rampant--aiPointsPrintSpendingToChat",
|
||||
setting_type = "runtime-global",
|
||||
default_value = false,
|
||||
order = "m[total]-b[ai]3",
|
||||
per_user = false
|
||||
},
|
||||
|
||||
{
|
||||
type = "bool-setting",
|
||||
name = "rampant--aiPointsPrintGainsToChat",
|
||||
description = "rampant--aiPointsPrintGainsToChat",
|
||||
setting_type = "runtime-global",
|
||||
default_value = false,
|
||||
order = "m[total]-b[ai]4",
|
||||
per_user = false
|
||||
},
|
||||
|
||||
{
|
||||
type = "double-setting",
|
||||
name = "rampant--temperamentRateModifier",
|
||||
@ -510,7 +542,7 @@ data:extend({
|
||||
order = "m[total]-b[ai]",
|
||||
per_user = false
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
type = "bool-setting",
|
||||
name = "rampant--removeBloodParticles",
|
||||
|
Loading…
x
Reference in New Issue
Block a user