From 5450359cfe567d08d232020d7d44fa80c13520c3 Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Wed, 21 Jul 2021 17:48:52 -0700 Subject: [PATCH] need to finish faction selection on damage --- README.md | 1 + libs/BaseUtils.lua | 35 ++++++++++++++++++++--------------- libs/Constants.lua | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c40f694..d9023f4 100755 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Factorio Mod - Improves the enemies tactics by using potential fields/pheromones # Forum Post +https://mod.factorio.com/veden/Rampant https://forums.factorio.com/viewtopic.php?f=94&t=31445 # Notes diff --git a/libs/BaseUtils.lua b/libs/BaseUtils.lua index 2e2c32d..afb14db 100755 --- a/libs/BaseUtils.lua +++ b/libs/BaseUtils.lua @@ -16,6 +16,8 @@ local FACTION_MUTATION_MAPPING = constants.FACTION_MUTATION_MAPPING local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER +local FACTIONS_BY_DAMAGE_TYPE = constants.FACTIONS_BY_DAMAGE_TYPE + local BASE_AI_STATE_ACTIVE = constants.BASE_AI_STATE_ACTIVE local BASE_AI_STATE_MUTATE = constants.BASE_AI_STATE_MUTATE @@ -333,22 +335,25 @@ 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 + local damageFactions = FACTIONS_BY_DAMAGE_TYPE[damageType] + if (damageFactions) then + if baseAlignment[2] then + if (roll < 0.05) then + baseAlignment[2] = nil + baseAlignment[1] = damageFactions[math.random(#damageFactions)] + elseif (roll < 0.25) then + baseAlignment[1] = damageFactions[math.random(#damageFactions)] + else + baseAlignment[2] = damageFactions[math.random(#damageFactions)] + end + else + if (roll < 0.85) then + base.alignment[1] = damageFactions[math.random(#damageFactions)] + else + base.alignment[2] = damageFactions[math.random(#damageFactions)] + end + end else if baseAlignment[2] then if (roll < 0.05) then diff --git a/libs/Constants.lua b/libs/Constants.lua index d1ebadb..f8aa4b9 100755 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -472,6 +472,33 @@ for tier=1, 10 do end end +constants.FACTIONS_BY_DAMAGE_TYPE = { + ["physical"] = { + + }, + ["impact"] = { + + }, + ["poison"] = { + + }, + ["explosion"] = { + + }, + ["fire"] = { + + }, + ["laser"] = { + + }, + ["acid"] = { + + }, + ["electric"] = { + + } +} + constants.FACTION_SET = {} constants.FACTION_SET[#constants.FACTION_SET+1] = {