Skip to content

Commit

Permalink
Implement parsing for some currently unsupported reflected mods. (Pat…
Browse files Browse the repository at this point in the history
…hOfBuildingCommunity#5014)

* FEAT: Implement parsing for some reflected mods.

* FEAT: generalize base cost parser mod formula.
  • Loading branch information
Paliak authored Sep 10, 2022
1 parent 3bbdc80 commit 6921ce1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Modules/CalcDefence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ function calcs.defence(env, actor)
local enemyCritChance = env.configInput["enemyCritChance"] or env.configPlaceholder["enemyCritChance"] or 0
local enemyCritDamage = env.configInput["enemyCritDamage"] or env.configPlaceholder["enemyCritDamage"] or 0
output["EnemyCritEffect"] = 1 + enemyCritChance / 100 * (enemyCritDamage / 100) * (1 - output.CritExtraDamageReduction / 100)
local enemyCfg = {keywordFlags = bit.bnot(KeywordFlag.MatchAll)} -- Match all keywordFlags parameter for enemy min-max damage mods
for _, damageType in ipairs(dmgTypeList) do
local enemyDamageMult = calcLib.mod(enemyDB, nil, "Damage", damageType.."Damage", isElemental[damageType] and "ElementalDamage" or nil) -- missing taunt from allies
local enemyDamage = tonumber(env.configInput["enemy"..damageType.."Damage"])
Expand All @@ -935,7 +936,10 @@ function calcs.defence(env, actor)
if enemyOverwhelm == nil then
enemyOverwhelm = tonumber(env.configPlaceholder["enemy"..damageType.."enemyOverwhelm"]) or 0
end


-- Add min-max enemy damage from mods
enemyDamage = enemyDamage + (enemyDB:Sum("BASE", enemyCfg, (damageType.."Min")) + enemyDB:Sum("BASE", enemyCfg, (damageType.."Max"))) / 2

output[damageType.."EnemyPen"] = enemyPen
output[damageType.."EnemyOverwhelm"] = enemyOverwhelm
output["totalEnemyDamageIn"] = output["totalEnemyDamageIn"] + enemyDamage
Expand Down
28 changes: 26 additions & 2 deletions src/Modules/ModParser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ local formList = {
["^([%+%-]?[%d%.]+)%%? of"] = "BASE",
["^([%+%-][%d%.]+)%%? base"] = "BASE",
["^([%+%-]?[%d%.]+)%%? additional"] = "BASE",
["cost ([%+%-]%d+)"] = "BASECOST",
["(%d+) additional hits?"] = "BASE",
["^you gain ([%d%.]+)"] = "BASE",
["^gains? ([%d%.]+)%% of"] = "BASE",
Expand Down Expand Up @@ -798,6 +799,7 @@ local modFlagList = {
["with physical skills"] = { keywordFlags = KeywordFlag.Physical },
["with channelling skills"] = { tag = { type = "SkillType", skillType = SkillType.Channel } },
["channelling skills"] = { tag = { type = "SkillType", skillType = SkillType.Channel } },
["non-channelling skills"] = { tag = { type = "SkillType", skillType = SkillType.Channel, neg = true } },
["with brand skills"] = { tag = { type = "SkillType", skillType = SkillType.Brand } },
["for stance skills"] = { tag = { type = "SkillType", skillType = SkillType.Stance } },
["of stance skills"] = { tag = { type = "SkillType", skillType = SkillType.Stance } },
Expand Down Expand Up @@ -975,6 +977,8 @@ local preFlagList = {
["^nearby enemies have "] = { applyToEnemy = true },
["^nearby enemies deal "] = { applyToEnemy = true },
["^nearby enemies "] = { applyToEnemy = true },
["against you"] = { applyToEnemy = true, actorEnemy = true},
["^hits against you "] = { applyToEnemy = true, flags = ModFlag.Hit },
["^enemies near your totems deal "] = { applyToEnemy = true },
-- Other
["^your flasks grant "] = { },
Expand Down Expand Up @@ -2285,6 +2289,10 @@ local specialModList = {
mod("ExtraSkill", "LIST", { skillId = gemIdLookup[skill], level = 1, noSupports = true, triggered = true }),
mod("CurseEffect", "INC", tonumber(num), { type = "SkillName", skillName = string.gsub(" "..skill, "%W%l", string.upper):sub(2) }),
} end,
["curse enemies with (%D+) on %a+, with (%d+)%% reduced effect"] = function(_, skill, num) return {
mod("ExtraSkill", "LIST", { skillId = gemIdLookup[skill], level = 1, noSupports = true, triggered = true }),
mod("CurseEffect", "INC", -tonumber(num), { type = "SkillName", skillName = string.gsub(" "..skill, "%W%l", string.upper):sub(2) }),
} end,
["%d+%% chance to curse n?o?n?%-?c?u?r?s?e?d? ?enemies with (%D+) on %a+, with (%d+)%% increased effect"] = function(_, skill, num) return {
mod("ExtraSkill", "LIST", { skillId = gemIdLookup[skill], level = 1, noSupports = true, triggered = true }),
mod("CurseEffect", "INC", tonumber(num), { type = "SkillName", skillName = string.gsub(" "..skill, "%W%l", string.upper):sub(2) }),
Expand Down Expand Up @@ -2495,6 +2503,10 @@ local specialModList = {
mod("ShockBase", "BASE", data.nonDamagingAilment["Shock"].default, { type = "Condition", var = "Focused" }),
mod("EnemyModifier", "LIST", { mod = flag("Condition:Shocked") }, { type = "Condition", var = "Focused" } ),
},
["shock yourself for (%d+) seconds when you focus"] = {
mod("ShockBase", "BASE", data.nonDamagingAilment["Shock"].default, { type = "Condition", var = "Focused" }),
flag("Condition:Shocked", { type = "Condition", var = "Focused" }),
},
["drops shocked ground while moving, lasting (%d+) seconds"] = { mod("ShockBase", "BASE", data.nonDamagingAilment["Shock"].default, { type = "ActorCondition", actor = "enemy", var = "OnShockedGround"} ) },
["drops scorched ground while moving, lasting (%d+) seconds"] = { mod("ScorchBase", "BASE", data.nonDamagingAilment["Scorch"].default, { type = "ActorCondition", actor = "enemy", var = "OnScorchedGround"} ) },
["drops brittle ground while moving, lasting (%d+) seconds"] = { mod("BrittleBase", "BASE", data.nonDamagingAilment["Brittle"].default, { type = "ActorCondition", actor = "enemy", var = "OnBrittleGround"} ) },
Expand Down Expand Up @@ -3521,7 +3533,7 @@ local specialModList = {
["you do not inherently take less damage for having fortification"] = { flag("Condition:NoFortificationMitigation") },
["skills supported by intensify have %+(%d) to maximum intensity"] = function(num) return { mod("Multiplier:IntensityLimit", "BASE", num) } end,
["spells which can gain intensity have %+(%d) to maximum intensity"] = function(num) return { mod("Multiplier:IntensityLimit", "BASE", num) } end,
["hexes you inflict have %+(%d+) to maximum doom"] = function(num) return { mod("MaxDoom", "BASE", num) } end,
["hexes you inflict have ([%+%-]%d+) to maximum doom"] = function(num) return { mod("MaxDoom", "BASE", num) } end,
["while stationary, gain (%d+)%% increased area of effect every second, up to a maximum of (%d+)%%"] = function(num, _, limit) return {
mod("AreaOfEffect", "INC", num, { type = "Multiplier", var = "StationarySeconds", globalLimit = tonumber(limit), globalLimitKey = "ExpansiveMight" }, { type = "Condition", var = "Stationary" }),
} end,
Expand Down Expand Up @@ -3554,6 +3566,7 @@ local specialModList = {
mod("MinionModifier", "LIST", { mod = mod("EnemyPhysicalDamageReduction", "BASE", -num) })
} end,
["focus has (%d+)%% increased cooldown recovery rate"] = function(num) return { mod("FocusCooldownRecovery", "INC", num, { type = "Condition", var = "Focused"}) } end,
["focus has (%d+)%% reduced cooldown recovery rate"] = function(num) return { mod("FocusCooldownRecovery", "INC", -num, { type = "Condition", var = "Focused"}) } end,
["(%d+)%% chance to deal double damage with attacks if attack time is longer than 1 second"] = function(num) return {
mod("DoubleDamageChance", "BASE", num, 0, 0, { type = "Condition", var = "OneSecondAttackTime" })
} end,
Expand Down Expand Up @@ -4302,6 +4315,12 @@ local function parseMod(line, order)
modType = "MORE"
elseif modForm == "BASE" then
modSuffix, line = scan(line, suffixTypes, true)
elseif modForm == "BASECOST" then
if not modName then
return { }, line
end
modName = modName.."Cost"
modValue = tonumber(formCap[1])
elseif modForm == "CHANCE" then
elseif modForm == "REGENPERCENT" then
modName = regenTypes[formCap[2]]
Expand Down Expand Up @@ -4424,7 +4443,12 @@ local function parseMod(line, order)
end
elseif misc.applyToEnemy then
for i, effectMod in ipairs(modList) do
modList[i] = mod("EnemyModifier", "LIST", { mod = effectMod })
local newMod = effectMod
if effectMod[1] and type(effectMod) == "table" and misc.actorEnemy then
newMod = copyTable(effectMod)
newMod[1]["actor"] = "enemy"
end
modList[i] = mod("EnemyModifier", "LIST", { mod = newMod })
end
end
end
Expand Down

0 comments on commit 6921ce1

Please sign in to comment.