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 universe.maxPoints = 0
-- if (universe.maps) then if (universe.maps) then
-- for _,map in pairs(universe.maps) do for _,map in pairs(universe.maps) do
-- for _,base in pairs(map.bases) do for _,base in pairs(map.bases) do
-- base.damagedBy = {} base.damagedBy = {}
-- base.deathEvents = 0 base.deathEvents = 0
-- end end
-- end end
-- end end
game.print("Rampant - Version 1.1.0") game.print("Rampant - Version 1.1.2")
end end
return (starting ~= global.version) and global.version return (starting ~= global.version) and global.version

View File

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

View File

@ -1,7 +1,7 @@
{ {
"name" : "Rampant", "name" : "Rampant",
"factorio_version" : "1.1", "factorio_version" : "1.1",
"version" : "1.1.1", "version" : "1.1.2",
"title" : "Rampant", "title" : "Rampant",
"author" : "Veden", "author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445", "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 universe.formCommand.unit_count = scaledWaveSize
local foundUnits = surface.set_multi_command(universe.formCommand) local foundUnits = surface.set_multi_command(universe.formCommand)
if (foundUnits > 0) then if (foundUnits > 0) then
-- if universe.NEW_ENEMIES then if universe.NEW_ENEMIES then
-- squad.base = findNearbyBase(map, chunk) squad.base = findNearbyBase(map, chunk)
-- end end
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe) squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe)
universe.builderCount = universe.builderCount + 1 universe.builderCount = universe.builderCount + 1
map.points = map.points - AI_SETTLER_COST map.points = map.points - AI_SETTLER_COST
@ -275,9 +275,9 @@ function aiAttackWave.formVengenceSquad(map, chunk)
universe.formCommand.unit_count = scaledWaveSize universe.formCommand.unit_count = scaledWaveSize
local foundUnits = surface.set_multi_command(universe.formCommand) local foundUnits = surface.set_multi_command(universe.formCommand)
if (foundUnits > 0) then if (foundUnits > 0) then
-- if universe.NEW_ENEMIES then if universe.NEW_ENEMIES then
-- squad.base = findNearbyBase(map, chunk) squad.base = findNearbyBase(map, chunk)
-- end end
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe) squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe)
map.groupNumberToSquad[squad.groupNumber] = squad map.groupNumberToSquad[squad.groupNumber] = squad
universe.squadCount = universe.squadCount + 1 universe.squadCount = universe.squadCount + 1
@ -326,9 +326,9 @@ function aiAttackWave.formSquads(map, chunk, tick)
universe.formCommand.unit_count = scaledWaveSize universe.formCommand.unit_count = scaledWaveSize
local foundUnits = surface.set_multi_command(universe.formCommand) local foundUnits = surface.set_multi_command(universe.formCommand)
if (foundUnits > 0) then if (foundUnits > 0) then
-- if universe.NEW_ENEMIES then if universe.NEW_ENEMIES then
-- squad.base = findNearbyBase(map, chunk) squad.base = findNearbyBase(map, chunk)
-- end end
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe) squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, universe)
map.points = map.points - AI_SQUAD_COST map.points = map.points - AI_SQUAD_COST
universe.squadCount = universe.squadCount + 1 universe.squadCount = universe.squadCount + 1

View File

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

View File

@ -321,17 +321,76 @@ local function upgradeBase(map, base)
else else
baseAlignment[2] = findBaseMutation(map) baseAlignment[2] = findBaseMutation(map)
end end
return true
else else
if (roll < 0.85) then if (roll < 0.85) then
base.alignment[1] = findBaseMutation(map) base.alignment[1] = findBaseMutation(map)
else else
base.alignment[2] = findBaseMutation(map) base.alignment[2] = findBaseMutation(map)
end end
return true
end end
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) function baseUtils.processBase(chunk, map, tick, base)
if not base.alignment[1] then if not base.alignment[1] then
return return
@ -345,9 +404,7 @@ function baseUtils.processBase(chunk, map, tick, base)
point.y = chunk.y + (CHUNK_SIZE * mRandom()) point.y = chunk.y + (CHUNK_SIZE * mRandom())
local upgradeRoll = mRandom() local upgradeRoll = mRandom()
if ((base.state == BASE_AI_STATE_MUTATE) and (upgradeRoll < 0.02)) or if (upgradeRoll < 0.05) then
((base.state == BASE_AI_STATE_ACTIVE) and (upgradeRoll < 0.1))
then
local entities = surface.find_entities_filtered(universe.filteredEntitiesPointQueryLimited) local entities = surface.find_entities_filtered(universe.filteredEntitiesPointQueryLimited)
if #entities ~= 0 then if #entities ~= 0 then
local entity = entities[1] local entity = entities[1]
@ -363,17 +420,11 @@ function baseUtils.processBase(chunk, map, tick, base)
end end
end end
-- if (base.deathEvents > 1000) then if ((upgradeRoll > 0.95) and (base.deathEvents > 3000)) then
-- if (upgradeRoll > 0.95) then upgradeBaseBasedOnDamage(map, base)
if (base.points >= BASE_UPGRADE) then base.damagedBy = {}
if upgradeBase(map, base) then base.deathEvents = 0
base.points = base.points - BASE_UPGRADE
end
end end
-- end
-- base.damagedBy = {}
-- base.deathEvents = 0
-- end
base.points = base.points + map.baseIncrement base.points = base.points + map.baseIncrement
@ -385,12 +436,12 @@ function baseUtils.processBase(chunk, map, tick, base)
-- ) -- )
if (base.stateTick <= tick) then if (base.stateTick <= tick) then
local roll = mRandom() -- local roll = mRandom()
if (roll < 0.85) then -- if (roll < 0.85) then
base.state = BASE_AI_STATE_ACTIVE base.state = BASE_AI_STATE_ACTIVE
else -- else
base.state = BASE_AI_STATE_MUTATE -- base.state = BASE_AI_STATE_MUTATE
end -- end
base.stateTick = randomTickEvent(tick, base.stateTick = randomTickEvent(tick,
BASE_AI_MIN_STATE_DURATION, BASE_AI_MIN_STATE_DURATION,
BASE_AI_MAX_STATE_DURATION) BASE_AI_MAX_STATE_DURATION)

View File

@ -515,17 +515,17 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity, damageType)
if (chunk ~= -1) then if (chunk ~= -1) then
local count = getFunc(map, chunk) local count = getFunc(map, chunk)
if count then 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 (count <= 1) then
if (hiveType == "spitter-spawner") or (hiveType == "biter-spawner") then if (hiveType == "spitter-spawner") or (hiveType == "biter-spawner") then
setRaidNestActiveness(map, chunk, 0) setRaidNestActiveness(map, chunk, 0)
setNestActiveness(map, chunk, 0) setNestActiveness(map, chunk, 0)
end end
setFunc(map, chunk, 0) 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 if (getEnemyStructureCount(map, chunk) == 0) then
setChunkBase(map, chunk, nil) setChunkBase(map, chunk, nil)
end 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_DISTANCE_TO_EVO_INDEX = 1 / 9600
constants.BASE_SPAWNER_UPGRADE = 250 constants.BASE_SPAWNER_UPGRADE = 500
constants.BASE_WORM_UPGRADE = 200 constants.BASE_WORM_UPGRADE = 400
constants.BASE_UPGRADE = 1500 constants.BASE_UPGRADE = 1500
constants.BASE_DISTANCE_THRESHOLD = 30 * constants.CHUNK_SIZE constants.BASE_DISTANCE_THRESHOLD = 30 * constants.CHUNK_SIZE

View File

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