1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-17 20:58:35 +02:00

Merge remote-tracking branch 'dagothur/dev' into dev

This commit is contained in:
Aaron Veden 2023-01-02 18:10:13 -08:00
commit 0a2cc758da
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
7 changed files with 110 additions and 72 deletions

View File

@ -3,7 +3,8 @@ Version: 3.2.0
Contributions:
- Garrotte13: Missing turret sounds due too many sounds triggering at once
- ldinc: Added mod setting to configure maximum evolution by distance
- PlexPt: marked zhcnremake translations as incompatible due to them being out of date
- PlexPt: Marked zhcnremake translations as incompatible due to them being out of date
- Dagothur: Centralized base point management
Improvements:
- Added console command /rampantRemoveNewEnemies which changes all new enemies to vanilla enemies for allowing the disabling of new enemies on an existing save
- Added console command /rampantRemoveFaction to remove individual factions on existing saves
@ -13,6 +14,7 @@ Version: 3.2.0
Tweaks:
- Increased the death thresholds to 17000 <50%, 34000 <70%, 60000 <90%, 100000 for adaptation
- Changed spawner pollution check to use 75% of the chunk pollution diffuse value
- Bases no longer gain points in AI_STATE_PEACEFUL (Dagothur)
Bugfixes:
- Removed layer-13 from projectiles
- script_raised_built now looks for enemy faction and registers as needed
@ -22,10 +24,13 @@ Version: 3.2.0
- Fixed faction mutation mutating to an existing faction is no longer counted towards max number of mutations per base
- Corrected typo of `randominess` to `randomness` in tooltips
- Fixed alignmentTable being nil due to an invalid reference to the neutral faction
- Bases can no longer spend points that exceed the overflow limit (Dagothur)
Optimizations:
- Moved most constants out of global
- Removed new enemy variations setting
- Moved neturalObject scan chunk to after a chunk is determined to be passable
- Centralized base points manipulation and chat messaging (Dagothur)
- Base point deductions for unit losses are now batched in 20 to reduce chat spam when using the print AI points to chat options (Dagothur)
---------------------------------------------------------------------------------------------------
Version: 3.1.2

View File

@ -40,8 +40,6 @@ local queryUtils = require("libs/QueryUtils")
local FACTION_SET = constants.FACTION_SET
local BUILDING_EVOLVE_LOOKUP = constants.BUILDING_EVOLVE_LOOKUP
local ENEMY_ALIGNMENT_LOOKUP = constants.ENEMY_ALIGNMENT_LOOKUP
local VANILLA_ENTITY_TYPE_LOOKUP = constants.VANILLA_ENTITY_TYPE_LOOKUP
local ENTITY_SKIP_COUNT_LOOKUP = constants.ENTITY_SKIP_COUNT_LOOKUP
@ -161,7 +159,8 @@ local unregisterResource = chunkUtils.unregisterResource
local cleanSquads = squadAttack.cleanSquads
local queueUpgrade = baseUtils.queueUpgrade
local rebuildNativeTables = baseUtils.rebuildNativeTables
local modifyBaseUnitPoints = baseUtils.modifyBaseUnitPoints
local tRemove = table.remove
@ -190,11 +189,7 @@ local function onIonCannonFired(event)
if base then
base.ionCannonBlasts = base.ionCannonBlasts + 1
rallyUnits(chunk, map, event.tick, base)
base.unitPoints = base.unitPoints + 4000
if universe.aiPointsPrintGainsToChat then
game.print(map.surface.name .. ": Points: +" .. 4000 .. ". [Ion Cannon] Total: " ..
string.format("%.2f", base.unitPoints))
end
modifyBaseUnitPoints(base, 4000, "Ion Cannon")
end
end
end
@ -477,9 +472,8 @@ local function onDeath(event)
base.damagedBy[damageTypeName] = (base.damagedBy[damageTypeName] or 0) + 0.01
base.deathEvents = base.deathEvents + 1
end
base.unitPoints = base.unitPoints - UNIT_DEATH_POINT_COST
if universe.aiPointsPrintSpendingToChat then
game.print(map.surface.name .. ": Points: -" .. UNIT_DEATH_POINT_COST .. ". [Unit Lost] Total: " .. string.format("%.2f", base.unitPoints))
if base.lostEnemyUnits % 20 == 0 then
modifyBaseUnitPoints(base, -(20*UNIT_DEATH_POINT_COST), "20 Units Lost")
end
if (universe.random() < universe.rallyThreshold) and not surface.peaceful_mode then
rallyUnits(chunk, map, tick, base)
@ -502,17 +496,9 @@ local function onDeath(event)
then
if base then
if (entityType == "unit-spawner") then
base.unitPoints = base.unitPoints + RECOVER_NEST_COST
if universe.aiPointsPrintGainsToChat then
game.print(map.surface.name .. ": Points: +" .. RECOVER_NEST_COST ..
". [Nest Lost] Total: " .. string.format("%.2f", base.unitPoints))
end
modifyBaseUnitPoints(base, RECOVER_NEST_COST, "Nest Lost")
elseif (entityType == "turret") then
base.unitPoints = base.unitPoints + RECOVER_WORM_COST
if universe.aiPointsPrintGainsToChat then
game.print(map.surface.name .. ": Points: +" .. RECOVER_WORM_COST ..
". [Worm Lost] Total: " .. string.format("%.2f", base.unitPoints))
end
modifyBaseUnitPoints(base, RECOVER_WORM_COST, "Worm Lost")
end
rallyUnits(chunk, map, tick, base)
if artilleryBlast then
@ -669,10 +655,7 @@ local function onRocketLaunch(event)
local base = findNearbyBase(map, chunk)
if base then
base.rocketLaunched = base.rocketLaunched + 1
base.unitPoints = base.unitPoints + 5000
if universe.aiPointsPrintGainsToChat then
game.print(map.surface.name .. ": Points: +" .. 5000 .. ". [Rocket Launch] Total: " .. string.format("%.2f", base.unitPoints))
end
modifyBaseUnitPoints(base, 5000, "Rocket Launch")
end
end
end

View File

@ -27,6 +27,7 @@ local chunkPropertyUtils = require("ChunkPropertyUtils")
local unitGroupUtils = require("UnitGroupUtils")
local movementUtils = require("MovementUtils")
local mathUtils = require("MathUtils")
local baseUtils = require("libs/BaseUtils")
-- constants
@ -74,6 +75,8 @@ local scoreNeighborsForResource = movementUtils.scoreNeighborsForResource
local createSquad = unitGroupUtils.createSquad
local getDeathGeneratorRating = chunkPropertyUtils.getDeathGeneratorRating
local modifyBaseUnitPoints = baseUtils.modifyBaseUnitPoints
local mCeil = math.ceil
-- module code
@ -256,12 +259,7 @@ function aiAttackWave.formSettlers(map, chunk, base)
squad.kamikaze = map.random() < kamikazeThreshold
universe.builderCount = universe.builderCount + 1
base.unitPoints = base.unitPoints - AI_SETTLER_COST
if universe.aiPointsPrintSpendingToChat then
game.print(map.surface.name .. ": Points: -" .. AI_SETTLER_COST .. ". [Settler] Total: " ..
string.format("%.2f", base.unitPoints) .. " [gps=" .. squadPosition.x .. "," ..
squadPosition.y .. "]")
end
modifyBaseUnitPoints(base, -AI_SETTLER_COST, "Settler", squadPosition.x, squadPosition.y)
universe.groupNumberToSquad[squad.groupNumber] = squad
else
if (squad.group.valid) then
@ -306,11 +304,7 @@ function aiAttackWave.formVengenceSquad(map, chunk, base)
squad.kamikaze = map.random() < calculateKamikazeSquadThreshold(foundUnits, universe)
universe.groupNumberToSquad[squad.groupNumber] = squad
universe.squadCount = universe.squadCount + 1
base.unitPoints = base.unitPoints - AI_VENGENCE_SQUAD_COST
if universe.aiPointsPrintSpendingToChat then
game.print(map.surface.name .. ": Points: -" .. AI_VENGENCE_SQUAD_COST .. ". [Vengence] Total: " ..
string.format("%.2f", base.unitPoints) .. " [gps=" .. squadPosition.x .. "," .. squadPosition.y .. "]")
end
modifyBaseUnitPoints(base, -AI_VENGENCE_SQUAD_COST, "Vengence", squadPosition.x, squadPosition.y)
else
if (squad.group.valid) then
squad.group.destroy()
@ -357,11 +351,7 @@ function aiAttackWave.formVengenceSettler(map, chunk, base)
squad.kamikaze = map.random() < calculateKamikazeSettlerThreshold(foundUnits, universe)
universe.groupNumberToSquad[squad.groupNumber] = squad
universe.builderCount = universe.builderCount + 1
base.unitPoints = base.unitPoints - AI_VENGENCE_SQUAD_COST
if universe.aiPointsPrintSpendingToChat then
game.print(map.surface.name .. ": Points: -" .. AI_VENGENCE_SQUAD_COST .. ". [Vengence Settlers] Total: " ..
string.format("%.2f", base.unitPoints) .. " [gps=" .. squadPosition.x .. "," .. squadPosition.y .. "]")
end
modifyBaseUnitPoints(base, -AI_VENGENCE_SQUAD_COST, "Vengence Settlers", squadPosition.x, squadPosition.y)
else
if (squad.group.valid) then
squad.group.destroy()
@ -404,17 +394,12 @@ function aiAttackWave.formSquads(map, chunk, base)
if (foundUnits > 0) then
squad.base = base
squad.kamikaze = map.random() < calculateKamikazeSquadThreshold(foundUnits, universe)
base.unitPoints = base.unitPoints - AI_SQUAD_COST
universe.squadCount = universe.squadCount + 1
universe.groupNumberToSquad[squad.groupNumber] = squad
if (base.stateAI == BASE_AI_STATE_AGGRESSIVE) then
base.sentAggressiveGroups = base.sentAggressiveGroups + 1
end
if universe.aiPointsPrintSpendingToChat then
game.print(map.surface.name .. ": Points: -" .. AI_SQUAD_COST .. ". [Squad] Total: " ..
string.format("%.2f", base.unitPoints) .. " [gps=" .. squadPosition.x .. "," ..
squadPosition.y .. "]")
end
modifyBaseUnitPoints(base, -AI_SQUAD_COST, "Squad", squadPosition.x, squadPosition.y)
else
if (squad.group.valid) then
squad.group.destroy()

View File

@ -27,6 +27,8 @@ local baseUtils = require("BaseUtils")
-- constants
local UNIT_DEATH_POINT_COST = constants.UNIT_DEATH_POINT_COST
local BASE_PROCESS_INTERVAL = constants.BASE_PROCESS_INTERVAL
local BASE_GENERATION_STATE_ACTIVE = constants.BASE_GENERATION_STATE_ACTIVE
@ -73,6 +75,8 @@ local randomTickEvent = mathUtils.randomTickEvent
local randomTickDuration = mathUtils.randomTickDuration
local upgradeBaseBasedOnDamage = baseUtils.upgradeBaseBasedOnDamage
local modifyBaseUnitPoints = baseUtils.modifyBaseUnitPoints
local modifyBaseSpecialPoints = baseUtils.modifyBaseSpecialPoints
local linearInterpolation = mathUtils.linearInterpolation
@ -175,15 +179,11 @@ local function processBase(universe, base, tick)
end
if (currentPoints < universe.maxPoints) then
base.unitPoints = currentPoints + points
elseif currentPoints > universe.maxOverflowPoints then
base.unitPoints = universe.maxOverflowPoints
modifyBaseUnitPoints(base, points, "Logic Cycle", base.x, base.y)
end
if (base.points < universe.maxPoints) then
base.points = base.points + (points * 0.75)
else
base.points = universe.maxPoints
modifyBaseSpecialPoints(base, (points * 0.75), "Logic Cycle", base.x, base.y)
end
if universe.NEW_ENEMIES then
@ -538,6 +538,11 @@ local function processState(universe, base, tick)
end
end
local remainingUnits = base.lostEnemyUnits % 20
if remainingUnits ~= 0 then
modifyBaseUnitPoints(base, -(remainingUnits*UNIT_DEATH_POINT_COST), remainingUnits.." Units Lost")
end
base.destroyPlayerBuildings = 0
base.lostEnemyUnits = 0
base.lostEnemyBuilding = 0

View File

@ -42,8 +42,6 @@ local ENEMY_ALIGNMENT_LOOKUP = constants.ENEMY_ALIGNMENT_LOOKUP
local EVOLUTION_TABLE_ALIGNMENT = constants.EVOLUTION_TABLE_ALIGNMENT
local BUILDING_EVOLVE_LOOKUP = constants.BUILDING_EVOLVE_LOOKUP
local BASE_ALIGNMENT_NEUTRAL = constants.BASE_ALIGNMENT_NEUTRAL
local MINIMUM_BUILDING_COST = constants.MINIMUM_BUILDING_COST
local FACTION_MUTATION_MAPPING = constants.FACTION_MUTATION_MAPPING
@ -439,8 +437,9 @@ function baseUtils.processBaseMutation(chunk, map, base)
local entity = entities[1]
local cost = (COST_LOOKUP[entity.name] or MAGIC_MAXIMUM_NUMBER)
if (base.points >= cost) then
local position = entity.position
baseUtils.modifyBaseSpecialPoints(base, -cost, "Scheduling Entity upgrade", position.x, position.y)
baseUtils.queueUpgrade(entity, base, nil, false, true)
base.points = base.points - cost
end
end
end
@ -518,5 +517,75 @@ function baseUtils.createBase(map, chunk, tick)
return base
end
function baseUtils.modifyBaseUnitPoints(base, points, tag, x, y)
if points > 0 and base.stateAI == BASE_AI_STATE_PEACEFUL then
return
end
tag = tag or ""
x = x or nil
y = y or nil
base.unitPoints = base.unitPoints + points
local universe = base.universe
local overflowMessage = ""
if base.unitPoints > universe.maxOverflowPoints then
base.unitPoints = universe.maxOverflowPoints
overflowMessage = " [Point cap reached]"
end
local printPointChange = ""
if points > 0 and universe.aiPointsPrintGainsToChat then
printPointChange = "+" .. string.format("%.2f", points)
elseif points < 0 and universe.aiPointsPrintSpendingToChat then
printPointChange = string.format("%.2f", points)
end
if printPointChange ~= "" then
local gps = ""
if x ~= nil then
gps = " [gps=" .. x .. "," .. y .. "]"
end
game.print("[" .. base.id .. "]:" .. base.map.surface.name .. " " .. printPointChange .. " [" .. tag .. "] Unit Total:" .. string.format("%.2f", base.unitPoints) .. overflowMessage .. gps)
end
end
function baseUtils.modifyBaseSpecialPoints(base, points, tag, x, y)
if points > 0 and base.stateAI == BASE_AI_STATE_PEACEFUL then
return
end
tag = tag or ""
x = x or nil
y = y or nil
base.points = base.points + points
local universe = base.universe
local overflowMessage = ""
if base.points > universe.maxOverflowPoints then
base.points = universe.maxOverflowPoints
overflowMessage = " [Point cap reached]"
end
local printPointChange = ""
if points > 0 and universe.aiPointsPrintGainsToChat then
printPointChange = "+" .. string.format("%.2f", points)
elseif points < 0 and universe.aiPointsPrintSpendingToChat then
printPointChange = string.format("%.2f", points)
end
if printPointChange ~= "" then
local gps = ""
if x ~= nil then
gps = " [gps=" .. x .. "," .. y .. "]"
end
game.print("[" .. base.id .. "]:" .. base.map.surface.name .. " " .. printPointChange .. " [" .. tag .. "] Special Total:" .. string.format("%.2f", base.points) .. overflowMessage .. gps)
end
end
baseUtilsG = baseUtils
return baseUtils

View File

@ -30,8 +30,6 @@ local baseUtils = require("BaseUtils")
-- constants
local COST_LOOKUP = constants.COST_LOOKUP
local PROXY_ENTITY_LOOKUP = constants.PROXY_ENTITY_LOOKUP
local BASE_DISTANCE_TO_EVO_INDEX = constants.BASE_DISTANCE_TO_EVO_INDEX
@ -214,7 +212,7 @@ function chunkProcessor.processPendingUpgrades(universe, tick)
registerEnemyBaseStructure(map, createdEntity, base, true)
end
if not entityData.evolve and universe.printBaseUpgrades then
surface.print("[gps=".. position.x ..",".. position.y .."] " .. "Scheduled upgrade for ".. entityName .. " to " .. name)
surface.print("["..base.id.."]:"..surface.name.." Upgrading ".. entityName .. " to " .. name .. " [gps=".. position.x ..",".. position.y .."]")
end
if remote.interfaces["kr-creep"] then
remote.call("kr-creep", "spawn_creep_at_position", surface, foundPosition or position)

View File

@ -98,9 +98,10 @@ local removeChunkBase = chunkPropertyUtils.removeChunkBase
local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount
local findNearbyBase = chunkPropertyUtils.findNearbyBase
local createBase = baseUtils.createBase
local queueUpgrade = baseUtils.queueUpgrade
local createBase = baseUtils.createBase
local modifyBaseUnitPoints = baseUtils.modifyBaseUnitPoints
local euclideanDistancePoints = mathUtils.euclideanDistancePoints
@ -584,7 +585,6 @@ end
function chunkUtils.accountPlayerEntity(entity, map, addObject, base)
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
@ -594,17 +594,10 @@ function chunkUtils.accountPlayerEntity(entity, map, addObject, base)
pointValue = 0
end
base.destroyPlayerBuildings = base.destroyPlayerBuildings + 1
if (base.stateAI == BASE_AI_STATE_ONSLAUGHT) then
base.unitPoints = base.unitPoints + pointValue
if universe.aiPointsPrintGainsToChat then
game.print(map.surface.name .. ": Points: +" .. math.floor(pointValue) .. ". [Structure Kill] Total: " .. string.format("%.2f", base.unitPoints))
end
else
base.unitPoints = base.unitPoints + (pointValue * 0.12)
if universe.aiPointsPrintGainsToChat then
game.print(map.surface.name .. ": Points: +" .. math.floor(pointValue) .. ". [Structure Kill] Total: " .. string.format("%.2f", base.unitPoints))
end
if (base.stateAI ~= BASE_AI_STATE_ONSLAUGHT) then
pointValue = pointValue * 0.12
end
modifyBaseUnitPoints(base, pointValue, "Structure Kill")
end
entityValue = -entityValue
end