Skip to content

Commit

Permalink
Add global modifier limit support
Browse files Browse the repository at this point in the history
.. and begin using said global limits for Replica Nebulis, Warning Call, Purposeful Harbinger, Vast Power, and Dark Ideation.
  • Loading branch information
Lothrik committed Jan 26, 2022
1 parent bf06e44 commit 8fe92a5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
21 changes: 19 additions & 2 deletions src/Classes/ModDB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,23 @@ end

function ModDBClass:SumInternal(context, modType, cfg, flags, keywordFlags, source, ...)
local result = 0
local globalLimits = { }
for i = 1, select('#', ...) do
local modList = self.mods[select(i, ...)]
if modList then
for i = 1, #modList do
local mod = modList[i]
if mod.type == modType and band(flags, mod.flags) == mod.flags and MatchKeywordFlags(keywordFlags, mod.keywordFlags) and (not source or mod.source:match("[^:]+") == source) then
if mod[1] then
result = result + (context:EvalMod(mod, cfg) or 0)
local value = context:EvalMod(mod, cfg) or 0
if mod[1].globalLimit and mod[1].globalLimitKey then
globalLimits[mod[1].globalLimitKey] = globalLimits[mod[1].globalLimitKey] or 0
if globalLimits[mod[1].globalLimitKey] + value > mod[1].globalLimit then
value = mod[1].globalLimit - globalLimits[mod[1].globalLimitKey]
end
globalLimits[mod[1].globalLimitKey] = m_min(mod[1].globalLimit, globalLimits[mod[1].globalLimitKey] + value)
end
result = result + value
else
result = result + mod.value
end
Expand Down Expand Up @@ -207,6 +216,7 @@ function ModDBClass:ListInternal(context, result, cfg, flags, keywordFlags, sour
end

function ModDBClass:TabulateInternal(context, result, modType, cfg, flags, keywordFlags, source, ...)
local globalLimits = { }
for i = 1, select('#', ...) do
local modName = select(i, ...)
local modList = self.mods[modName]
Expand All @@ -216,7 +226,14 @@ function ModDBClass:TabulateInternal(context, result, modType, cfg, flags, keywo
if (mod.type == modType or not modType) and band(flags, mod.flags) == mod.flags and MatchKeywordFlags(keywordFlags, mod.keywordFlags) and (not source or mod.source:match("[^:]+") == source) then
local value
if mod[1] then
value = context:EvalMod(mod, cfg)
value = context:EvalMod(mod, cfg) or 0
if mod[1].globalLimit and mod[1].globalLimitKey then
globalLimits[mod[1].globalLimitKey] = globalLimits[mod[1].globalLimitKey] or 0
if globalLimits[mod[1].globalLimitKey] + value > mod[1].globalLimit then
value = mod[1].globalLimit - globalLimits[mod[1].globalLimitKey]
end
globalLimits[mod[1].globalLimitKey] = m_min(mod[1].globalLimit, globalLimits[mod[1].globalLimitKey] + value)
end
else
value = mod.value
end
Expand Down
13 changes: 0 additions & 13 deletions src/Modules/CalcPerform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,6 @@ local function doActorMisc(env, actor)
modDB:NewMod("DamageTaken", "INC", 10, "Malediction")
modDB:NewMod("Damage", "INC", -10, "Malediction")
end
if modDB:Sum("INC", nil, "VastPowerAoE") > 0 then
local incFromVastPower = modDB:Sum("INC", nil, "VastPowerAoE")
local maxVastPower = data.misc.VastPowerMaxAoEPercent
modDB:NewMod("AreaOfEffect", "INC", incFromVastPower, "Vast Power", { type = "Multiplier", var = "PowerCharge", limit = maxVastPower, limitTotal = true })
end
end
end

Expand Down Expand Up @@ -1689,14 +1684,6 @@ function calcs.perform(env, avoidCache)
modDB.conditions["AffectedBy"..buff.name:gsub(" ","")] = true
local srcList = new("ModList")
local inc = skillModList:Sum("INC", skillCfg, "AuraEffect", "BuffEffect", "BuffEffectOnSelf", "AuraEffectOnSelf", "AuraBuffEffect", "SkillAuraEffectOnSelf")

-- Take the Purposeful Harbinger buffs into account.
-- These are capped to 40% increased buff effect, no matter the amount allocated
local incFromPurposefulHarbinger = math.min(
skillModList:Sum("INC", skillCfg, "PurpHarbAuraBuffEffect"),
data.misc.PurposefulHarbingerMaxBuffPercent)
inc = inc + incFromPurposefulHarbinger

local more = skillModList:More(skillCfg, "AuraEffect", "BuffEffect", "BuffEffectOnSelf", "AuraEffectOnSelf", "AuraBuffEffect", "SkillAuraEffectOnSelf")
srcList:ScaleAddList(buff.modList, (1 + inc / 100) * more)
srcList:ScaleAddList(extraAuraModList, (1 + inc / 100) * more)
Expand Down
2 changes: 0 additions & 2 deletions src/Modules/Data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@ data.misc = { -- magic numbers
TrapTriggerRadiusBase = 10,
MineDetonationRadiusBase = 60,
MineAuraRadiusBase = 35,
PurposefulHarbingerMaxBuffPercent = 40,
VastPowerMaxAoEPercent = 50,
MaxEnemyLevel = 84,
LowPoolThreshold = 0.5,
AccuracyPerDexBase = 2,
Expand Down
19 changes: 10 additions & 9 deletions src/Modules/ModParser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,8 @@ local modTagList = {
["per (%d+)%% cold resistance above 75%%"] = function(num) return { tag = { type = "PerStat", stat = "ColdResistOver75", div = num } } end,
["per (%d+)%% lightning resistance above 75%%"] = function(num) return { tag = { type = "PerStat", stat = "LightningResistOver75", div = num } } end,
["per (%d+) devotion"] = function(num) return { tag = { type = "PerStat", stat = "Devotion", div = num } } end,
["per (%d+)%% missing fire resistance, up to a maximum of (%d+)%%"] = function(num, _, limit) return { tag = { type = "PerStat", stat = "MissingFireResist", div = num, limit = tonumber(limit), limitTotal = true } } end,
["per (%d+)%% missing cold resistance, up to a maximum of (%d+)%%"] = function(num, _, limit) return { tag = { type = "PerStat", stat = "MissingColdResist", div = num, limit = tonumber(limit), limitTotal = true } } end,
["per (%d+)%% missing fire resistance, up to a maximum of (%d+)%%"] = function(num, _, limit) return { tag = { type = "PerStat", stat = "MissingFireResist", div = num, globalLimit = tonumber(limit), globalLimitKey = "ReplicaNebulisFire" } } end,
["per (%d+)%% missing cold resistance, up to a maximum of (%d+)%%"] = function(num, _, limit) return { tag = { type = "PerStat", stat = "MissingColdResist", div = num, globalLimit = tonumber(limit), globalLimitKey = "ReplicaNebulisCold" } } end,
["per endurance, frenzy or power charge"] = { tag = { type = "PerStat", stat = "TotalCharges" } },
["per totem"] = { tag = { type = "PerStat", stat = "TotemsSummoned" } },
["per summoned totem"] = { tag = { type = "PerStat", stat = "TotemsSummoned" } },
Expand Down Expand Up @@ -1650,8 +1650,8 @@ local specialModList = {
["cannot be stunned while you have at least (%d+) rage"] = function(num) return { mod("AvoidStun", "BASE", 100, { type = "MultiplierThreshold", var = "Rage", threshold = num }) } end,
["lose ([%d%.]+)%% of life per second per rage while you are not losing rage"] = function(num) return { mod("LifeDegen", "BASE", 1, { type = "PercentStat", stat = "Life", percent = num }, { type = "Multiplier", var = "Rage"}) } end,
["if you've warcried recently, you and nearby allies have (%d+)%% increased attack speed"] = function(num) return { mod("ExtraAura", "LIST", { mod = mod("Speed", "INC", num, nil, ModFlag.Attack) }, { type = "Condition", var = "UsedWarcryRecently" }) } end,
["gain (%d+)%% increased armour per (%d+) power for 8 seconds when you warcry, up to a maximum of (%d+)%%"] = function(num, _, mp, max_inc) return {
mod("Armour", "INC", num, { type = "Multiplier", var = "WarcryPower", div = tonumber(mp), limit = tonumber(max_inc), limitTotal = true }, { type = "Condition", var = "UsedWarcryInPast8Seconds" })
["gain (%d+)%% increased armour per (%d+) power for 8 seconds when you warcry, up to a maximum of (%d+)%%"] = function(num, _, div, limit) return {
mod("Armour", "INC", num, { type = "Multiplier", var = "WarcryPower", div = tonumber(div), globalLimit = tonumber(limit), globalLimitKey = "WarningCall" }, { type = "Condition", var = "UsedWarcryInPast8Seconds" })
} end,
["warcries grant (%d+) rage per (%d+) power if you have less than (%d+) rage"] = {
flag("Condition:CanGainRage"),
Expand Down Expand Up @@ -2363,14 +2363,15 @@ local specialModList = {
["onslaught"] = { flag("Condition:Onslaught") },
["unholy might"] = { flag("Condition:UnholyMight") },
["your aura buffs do not affect allies"] = { flag("SelfAurasCannotAffectAllies") },
["aura buffs from skills have (%d+)%% increased effect on you for each herald affecting you"] = function(num) return { mod("AuraBuffEffect", "INC", num, { type = "Multiplier", var = "Herald"}) } end,
["aura buffs from skills have (%d+)%% increased effect on you for each herald affecting you"] = function(num) return { mod("SkillAuraEffectOnSelf", "INC", num, { type = "Multiplier", var = "Herald"}) } end,
["aura buffs from skills have (%d+)%% increased effect on you for each herald affecting you, up to (%d+)%%"] = function(num, _, limit) return {
mod("PurpHarbAuraBuffEffect", "INC", num, { type = "Multiplier", var = "Herald" })
-- Maximum buff effect is handled in CalcPerform, PurpHarbAuraBuffEffect is capped with a constant there.
mod("SkillAuraEffectOnSelf", "INC", num, { type = "Multiplier", var = "Herald", globalLimit = tonumber(limit), globalLimitKey = "PurposefulHarbinger" })
} end,
["(%d+)%% increased area of effect per power charge, up to a maximum of (%d+)%%"] = function(num, _, limit) return {
mod("VastPowerAoE", "INC", num),
-- Maximum effect is handled in CalcPerform, VastPowerAoE is capped with a constant there.
mod("AreaOfEffect", "INC", num, { type = "Multiplier", var = "PowerCharge", globalLimit = tonumber(limit), globalLimitKey = "VastPower" })
} end,
["(%d+)%% increased chaos damage per (%d+) maximum mana, up to a maximum of (%d+)%%"] = function(num, _, div, limit) return {
mod("ChaosDamage", "INC", num, { type = "PerStat", stat = "Mana", div = tonumber(div), globalLimit = tonumber(limit), globalLimitKey = "DarkIdeation" })
} end,
["nearby allies' damage with hits is lucky"] = { mod("ExtraAura", "LIST", { onlyAllies = true, mod = flag("LuckyHits") }) },
["your damage with hits is lucky"] = { flag("LuckyHits") },
Expand Down

0 comments on commit 8fe92a5

Please sign in to comment.