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

need to fill in damage type base mutations

This commit is contained in:
Aaron Veden 2021-07-19 21:22:38 -07:00
parent 63fe2b58bd
commit e88c4ef1ec
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
9 changed files with 126 additions and 75 deletions

View File

@ -407,16 +407,16 @@ function upgrade.attempt(universe)
universe.maxPoints = 0
-- if (universe.maps) then
-- for _,map in pairs(universe.maps) do
-- for _,base in pairs(map.bases) do
-- base.damagedBy = {}
-- base.deathEvents = 0
-- end
-- end
-- end
if (universe.maps) then
for _,map in pairs(universe.maps) do
for _,base in pairs(map.bases) do
base.damagedBy = {}
base.deathEvents = 0
end
end
end
game.print("Rampant - Version 1.1.0")
game.print("Rampant - Version 1.1.2")
end
return (starting ~= global.version) and global.version

View File

@ -476,18 +476,18 @@ local function onDeath(event)
if (entityType == "unit") then
if (chunk ~= -1) and event.force and (event.force.name ~= "enemy") then
-- local group = entity.unit_group
-- if group then
-- local damageType = event.damage_type
-- local squad = map.groupNumberToSquad[group.group_number]
-- if squad then
-- local base = squad.base
-- if base then
-- base.damagedBy[damageType] = (base.damagedBy[damageType] or 0) + 0.01
-- base.deathEvents = base.deathEvents + 1
-- end
-- end
-- end
local group = entity.unit_group
if group then
local damageType = event.damage_type
local squad = map.groupNumberToSquad[group.group_number]
if squad then
local base = squad.base
if base then
base.damagedBy[damageType] = (base.damagedBy[damageType] or 0) + 0.01
base.deathEvents = base.deathEvents + 1
end
end
end
-- drop death pheromone where unit died
deathScent(map, chunk)
@ -865,12 +865,12 @@ local function onUnitGroupCreated(event)
squad = createSquad(nil, nil, group, settler)
map.groupNumberToSquad[group.group_number] = squad
-- if universe.NEW_ENEMIES then
-- local chunk = getChunkByPosition(map, group.position)
-- if (chunk ~= -1) then
-- squad.base = findNearbyBase(map, chunk)
-- end
-- end
if universe.NEW_ENEMIES then
local chunk = getChunkByPosition(map, group.position)
if (chunk ~= -1) then
squad.base = findNearbyBase(map, chunk)
end
end
if settler then
universe.builderCount = universe.builderCount + 1
@ -903,12 +903,12 @@ local function onUnitGroupCreated(event)
squad = createSquad(nil, nil, group, settler)
map.groupNumberToSquad[group.group_number] = squad
-- if universe.NEW_ENEMIES then
-- local chunk = getChunkByPosition(group.position)
-- if (chunk ~= -1) then
-- squad.base = findNearbyBase(map, chunk)
-- end
-- end
if universe.NEW_ENEMIES then
local chunk = getChunkByPosition(group.position)
if (chunk ~= -1) then
squad.base = findNearbyBase(map, chunk)
end
end
if settler then
universe.builderCount = universe.builderCount + 1

View File

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

View File

@ -225,9 +225,9 @@ function aiAttackWave.formSettlers(map, chunk)
universe.formCommand.unit_count = scaledWaveSize
local foundUnits = surface.set_multi_command(universe.formCommand)
if (foundUnits > 0) then
-- if universe.NEW_ENEMIES then
-- squad.base = findNearbyBase(map, chunk)
-- end
if universe.NEW_ENEMIES then
squad.base = findNearbyBase(map, chunk)
end
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe)
universe.builderCount = universe.builderCount + 1
map.points = map.points - AI_SETTLER_COST
@ -275,9 +275,9 @@ function aiAttackWave.formVengenceSquad(map, chunk)
universe.formCommand.unit_count = scaledWaveSize
local foundUnits = surface.set_multi_command(universe.formCommand)
if (foundUnits > 0) then
-- if universe.NEW_ENEMIES then
-- squad.base = findNearbyBase(map, chunk)
-- end
if universe.NEW_ENEMIES then
squad.base = findNearbyBase(map, chunk)
end
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe)
map.groupNumberToSquad[squad.groupNumber] = squad
universe.squadCount = universe.squadCount + 1
@ -326,9 +326,9 @@ function aiAttackWave.formSquads(map, chunk, tick)
universe.formCommand.unit_count = scaledWaveSize
local foundUnits = surface.set_multi_command(universe.formCommand)
if (foundUnits > 0) then
-- if universe.NEW_ENEMIES then
-- squad.base = findNearbyBase(map, chunk)
-- end
if universe.NEW_ENEMIES then
squad.base = findNearbyBase(map, chunk)
end
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe)
map.points = map.points - AI_SQUAD_COST
universe.squadCount = universe.squadCount + 1

View File

@ -125,7 +125,7 @@ function aiPlanning.planning(map, evolution_factor, tick)
points = points * universe.aiPointsScaler
map.baseIncrement = points * 3.5
map.baseIncrement = points
local currentPoints = map.points

View File

@ -321,17 +321,76 @@ local function upgradeBase(map, base)
else
baseAlignment[2] = findBaseMutation(map)
end
return true
else
if (roll < 0.85) then
base.alignment[1] = findBaseMutation(map)
else
base.alignment[2] = findBaseMutation(map)
end
return true
end
end
local function pickMutationFromDamageType(map, damageType, roll, base)
local baseAlignment = base.alignment
if (damageType == "physical") then
elseif (damageType == "impact") then
elseif (damageType == "poison") then
elseif (damageType == "explosion") then
elseif (damageType == "fire") then
elseif (damageType == "laser") then
elseif (damageType == "acid") then
elseif (damageType == "electric") then
else
if baseAlignment[2] then
if (roll < 0.05) then
baseAlignment[2] = nil
baseAlignment[1] = findBaseMutation(map)
elseif (roll < 0.25) then
baseAlignment[1] = findBaseMutation(map)
else
baseAlignment[2] = findBaseMutation(map)
end
else
if (roll < 0.85) then
base.alignment[1] = findBaseMutation(map)
else
base.alignment[2] = findBaseMutation(map)
end
end
end
end
local function upgradeBaseBasedOnDamage(map, base)
local total = 0
for _,amount in pairs(base.damagedBy) do
total = total + amount
end
local mutationAmount = total * 0.15
base.damagedBy["mutation"] = mutationAmount
total = total + mutationAmount
local pickedDamage
local roll = mRandom()
for damageType,amount in pairs(base.damagedBy) do
if (roll - (amount / total) < 0) then
pickedDamage = damageType
break
end
end
pickMutationFromDamageType(map, pickedDamage, roll, base)
end
function baseUtils.processBase(chunk, map, tick, base)
if not base.alignment[1] then
return
@ -345,9 +404,7 @@ function baseUtils.processBase(chunk, map, tick, base)
point.y = chunk.y + (CHUNK_SIZE * mRandom())
local upgradeRoll = mRandom()
if ((base.state == BASE_AI_STATE_MUTATE) and (upgradeRoll < 0.02)) or
((base.state == BASE_AI_STATE_ACTIVE) and (upgradeRoll < 0.1))
then
if (upgradeRoll < 0.05) then
local entities = surface.find_entities_filtered(universe.filteredEntitiesPointQueryLimited)
if #entities ~= 0 then
local entity = entities[1]
@ -363,17 +420,11 @@ function baseUtils.processBase(chunk, map, tick, base)
end
end
-- if (base.deathEvents > 1000) then
-- if (upgradeRoll > 0.95) then
if (base.points >= BASE_UPGRADE) then
if upgradeBase(map, base) then
base.points = base.points - BASE_UPGRADE
end
if ((upgradeRoll > 0.95) and (base.deathEvents > 3000)) then
upgradeBaseBasedOnDamage(map, base)
base.damagedBy = {}
base.deathEvents = 0
end
-- end
-- base.damagedBy = {}
-- base.deathEvents = 0
-- end
base.points = base.points + map.baseIncrement
@ -385,12 +436,12 @@ function baseUtils.processBase(chunk, map, tick, base)
-- )
if (base.stateTick <= tick) then
local roll = mRandom()
if (roll < 0.85) then
base.state = BASE_AI_STATE_ACTIVE
else
base.state = BASE_AI_STATE_MUTATE
end
-- local roll = mRandom()
-- if (roll < 0.85) then
base.state = BASE_AI_STATE_ACTIVE
-- else
-- base.state = BASE_AI_STATE_MUTATE
-- end
base.stateTick = randomTickEvent(tick,
BASE_AI_MIN_STATE_DURATION,
BASE_AI_MAX_STATE_DURATION)

View File

@ -515,17 +515,17 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity, damageType)
if (chunk ~= -1) then
local count = getFunc(map, chunk)
if count then
local base = getChunkBase(map, chunk)
if base then
base.damagedBy[damageType] = (base.damagedBy[damageType] or 0) + 1
base.deathEvents = base.deathEvents + 3
end
if (count <= 1) then
if (hiveType == "spitter-spawner") or (hiveType == "biter-spawner") then
setRaidNestActiveness(map, chunk, 0)
setNestActiveness(map, chunk, 0)
end
setFunc(map, chunk, 0)
-- local base = getChunkBase(map, chunk)
-- if base then
-- base.damagedBy[damageType] = (base.damagedBy[damageType] or 0) + 1
-- base.deathEvents = base.deathEvents + 1
-- end
if (getEnemyStructureCount(map, chunk) == 0) then
setChunkBase(map, chunk, nil)
end

View File

@ -179,8 +179,8 @@ constants.BASE_COLLECTION_THRESHOLD = constants.TICKS_A_MINUTE * 2
constants.BASE_DISTANCE_TO_EVO_INDEX = 1 / 9600
constants.BASE_SPAWNER_UPGRADE = 250
constants.BASE_WORM_UPGRADE = 200
constants.BASE_SPAWNER_UPGRADE = 500
constants.BASE_WORM_UPGRADE = 400
constants.BASE_UPGRADE = 1500
constants.BASE_DISTANCE_THRESHOLD = 30 * constants.CHUNK_SIZE

View File

@ -115,9 +115,9 @@ function aiDefense.retreatUnits(chunk, cause, map, tick, radius)
end
if created then
-- if universe.NEW_ENEMIES then
-- newSquad.base = findNearbyBase(map, chunk)
-- end
if universe.NEW_ENEMIES then
newSquad.base = findNearbyBase(map, chunk)
end
map.groupNumberToSquad[newSquad.groupNumber] = newSquad
universe.squadCount = universe.squadCount + 1
end