Skip to content

Commit 651cad3

Browse files
authored
Add support for generic "DOUBLED" modForm (#1095)
* Add "OVERRIDE" check to GetMultiplier method * Add "globalLimit" functionality for "MORE" multipliers to ModDB * Add support for universal "is doubled" mod parsing * Add additional phrasing options for "doubled" mods * Remove mods from specialModList that are now generically supported * Add instructions for "globalLimit" to modSyntax documentation --------- Co-authored-by: majochem <majochem@users.noreply.github.com>
1 parent 5b06daa commit 651cad3

5 files changed

Lines changed: 72 additions & 31 deletions

File tree

docs/modSyntax.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Often a mod will only apply under certain conditions, apply multiple times based
3636
* var: mod to multiply by
3737
* limit: The maximum number the mod can go up to
3838
* limitTotal: boolean that changes the behavior of limit to apply after multiplication. Defaults to false.
39+
* globalLimit: The maximum global number the mod can go up to, even with multiple sources. Useful for mods that say "up to a maximum of ..."
40+
* globalLimitKey: string identifier for the global limit. Mods with identical keys cannot go over the globalLimit.
3941
* MultiplierThreshold: Similar to a condition that only applies when the variable is above a specified threshold
4042
* var: name of the mod
4143
* threshold: number to reach before the mod applies

src/Classes/ModDB.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,28 @@ end
123123
function ModDBClass:MoreInternal(context, cfg, flags, keywordFlags, source, ...)
124124
local result = 1
125125
local modPrecision = nil
126+
local globalLimits = { }
126127
for i = 1, select('#', ...) do
127128
local modList = self.mods[select(i, ...)]
128129
local modResult = 1 --The more multipliers for each mod are computed to the nearest percent then applied.
129130
if modList then
130131
for i = 1, #modList do
131132
local mod = modList[i]
132133
if mod.type == "MORE" and band(flags, mod.flags) == mod.flags and MatchKeywordFlags(keywordFlags, mod.keywordFlags) and (not source or mod.source:match("[^:]+") == source) then
134+
local value
133135
if mod[1] then
134-
modResult = modResult * (1 + (context:EvalMod(mod, cfg) or 0) / 100)
136+
value = context:EvalMod(mod, cfg) or 0
137+
if mod[1].globalLimit and mod[1].globalLimitKey then
138+
globalLimits[mod[1].globalLimitKey] = globalLimits[mod[1].globalLimitKey] or 0
139+
if globalLimits[mod[1].globalLimitKey] + value > mod[1].globalLimit then
140+
value = mod[1].globalLimit - globalLimits[mod[1].globalLimitKey]
141+
end
142+
globalLimits[mod[1].globalLimitKey] = globalLimits[mod[1].globalLimitKey] + value
143+
end
135144
else
136-
modResult = modResult * (1 + mod.value / 100)
145+
value = mod.value or 0
137146
end
147+
modResult = modResult * (1 + value / 100)
138148
if modPrecision then
139149
modPrecision = m_max(modPrecision, (data.highPrecisionMods[mod.name] and data.highPrecisionMods[mod.name][mod.type]) or modPrecision)
140150
else

src/Classes/ModStore.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ function ModStoreClass:GetCondition(var, cfg, noMod)
250250
end
251251

252252
function ModStoreClass:GetMultiplier(var, cfg, noMod)
253-
return (self.multipliers[var] or 0) + (self.parent and self.parent:GetMultiplier(var, cfg, true) or 0) + (not noMod and self:Sum("BASE", cfg, multiplierName[var]) or 0)
253+
return (not noMod and self:Override(cfg, multiplierName[var])) or (self.multipliers[var] or 0) + (self.parent and self.parent:GetMultiplier(var, cfg, true) or 0) + (not noMod and self:Sum("BASE", cfg, multiplierName[var]) or 0)
254254
end
255255

256256
function ModStoreClass:GetStat(stat, cfg)

src/Data/ModCache.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ c["(17-23)% increased maximum Mana"]={nil,"(17-23)% increased maximum Mana "}
55
c["(17-23)% increased maximum Mana (15-25)% increased Mana Regeneration Rate"]={nil,"(17-23)% increased maximum Mana (15-25)% increased Mana Regeneration Rate "}
66
c["(2-3)% increased Cast Speed"]={nil,"(2-3)% increased Cast Speed "}
77
c["(2-3)% increased Movement Speed"]={nil,"(2-3)% increased Movement Speed "}
8-
c["(2-4)% chance to deal Double Damage"]={nil,"(2-4)% chance to deal Double Damage "}
9-
c["(2-4)% chance to deal Double Damage (25-35)% increased Physical Damage"]={nil,"(2-4)% chance to deal Double Damage (25-35)% increased Physical Damage "}
8+
c["(2-4)% chance to deal Double Damage"]={{[1]={[1]={globalLimit=100,globalLimitKey="DamageDoubledLimit",type="Multiplier",var="DamageDoubled"},flags=0,keywordFlags=0,name="Damage",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:DamageDoubled",type="OVERRIDE",value=1}},"(2-4)% chance to deal "}
9+
c["(2-4)% chance to deal Double Damage (25-35)% increased Physical Damage"]={{[1]={[1]={globalLimit=100,globalLimitKey="DamageDoubledLimit",type="Multiplier",var="DamageDoubled"},flags=0,keywordFlags=0,name="Damage",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:DamageDoubled",type="OVERRIDE",value=1}},"(2-4)% chance to deal (25-35)% increased Physical Damage "}
1010
c["(2-4)% increased effect of Non-Curse Auras from your Skills"]={nil,"(2-4)% increased effect of Non-Curse Auras from your Skills "}
1111
c["(2-4)% increased maximum Life"]={nil,"(2-4)% increased maximum Life "}
1212
c["(20-30)% increased Defences from Equipped Shield"]={nil,"(20-30)% increased Defences from Equipped Shield "}
@@ -2658,7 +2658,7 @@ c["90% increased Evasion Rating"]={{[1]={flags=0,keywordFlags=0,name="Evasion",t
26582658
c["90% increased Evasion and Energy Shield"]={{[1]={flags=0,keywordFlags=0,name="EvasionAndEnergyShield",type="INC",value=90}},nil}
26592659
c["90% increased Spell Damage"]={{[1]={flags=2,keywordFlags=0,name="Damage",type="INC",value=90}},nil}
26602660
c["A maximum of one Modifer can be granted this way"]={nil,"A maximum of one Modifer can be granted this way "}
2661-
c["Accuracy Rating is Doubled"]={{[1]={flags=0,keywordFlags=0,name="Accuracy",type="MORE",value=100}},nil}
2661+
c["Accuracy Rating is Doubled"]={{[1]={[1]={globalLimit=100,globalLimitKey="AccuracyDoubledLimit",type="Multiplier",var="AccuracyDoubled"},flags=0,keywordFlags=0,name="Accuracy",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:AccuracyDoubled",type="OVERRIDE",value=1}},nil}
26622662
c["Adds 1 to 10 Lightning Damage to Attacks per 20 Intelligence"]={{[1]={[1]={div=20,stat="Int",type="PerStat"},flags=0,keywordFlags=65536,name="LightningMin",type="BASE",value=1},[2]={[1]={div=20,stat="Int",type="PerStat"},flags=0,keywordFlags=65536,name="LightningMax",type="BASE",value=10}},nil}
26632663
c["Adds 1 to 100 Lightning Damage"]={{[1]={flags=0,keywordFlags=0,name="LightningMin",type="BASE",value=1},[2]={flags=0,keywordFlags=0,name="LightningMax",type="BASE",value=100}},nil}
26642664
c["Adds 1 to 120 Lightning Damage"]={{[1]={flags=0,keywordFlags=0,name="LightningMin",type="BASE",value=1},[2]={flags=0,keywordFlags=0,name="LightningMax",type="BASE",value=120}},nil}
@@ -3480,7 +3480,7 @@ c["Blind Chilled enemies on Hit"]={nil,"Blind Chilled enemies on Hit "}
34803480
c["Blind Enemies when they Stun you"]={nil,"Blind Enemies when they Stun you "}
34813481
c["Blind does not affect your Light Radius"]={nil,"Blind does not affect your Light Radius "}
34823482
c["Blind does not affect your Light Radius 25% more Melee Critical Hit Chance while Blinded"]={nil,"Blind does not affect your Light Radius 25% more Melee Critical Hit Chance while Blinded "}
3483-
c["Block Chance is doubled"]={{[1]={flags=0,keywordFlags=0,name="BlockChance",type="MORE",value=100}},nil}
3483+
c["Block Chance is doubled"]={{[1]={[1]={globalLimit=100,globalLimitKey="BlockChanceDoubledLimit",type="Multiplier",var="BlockChanceDoubled"},flags=0,keywordFlags=0,name="BlockChance",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:BlockChanceDoubled",type="OVERRIDE",value=1}},nil}
34843484
c["Block chance is Lucky"]={{[1]={flags=0,keywordFlags=0,name="BlockChanceIsLucky",type="FLAG",value=true}},nil}
34853485
c["Blocking Damage Poisons the Enemy as though dealing 100 Base Chaos Damage"]={nil,"Blocking Damage Poisons the Enemy as though dealing 100 Base Chaos Damage "}
34863486
c["Blocking Damage Poisons the Enemy as though dealing 100 Base Chaos Damage Blocking Damage Poisons the Enemy as though dealing 200 Base Chaos Damage"]={nil,"Blocking Damage Poisons the Enemy as though dealing 100 Base Chaos Damage Blocking Damage Poisons the Enemy as though dealing 200 Base Chaos Damage "}
@@ -3567,20 +3567,20 @@ c["Causes Bleeding on Hit"]={{[1]={[1]={type="Condition",var="{Hand}Attack"},fla
35673567
c["Causes Daze buildup equal to 100% of Damage dealt"]={nil,"Causes Daze buildup equal to 100% of Damage dealt "}
35683568
c["Causes Daze buildup equal to 100% of Damage dealt 172% increased Physical Damage"]={nil,"Causes Daze buildup equal to 100% of Damage dealt 172% increased Physical Damage "}
35693569
c["Causes Daze buildup equal to 100% of Damage dealt Adds 44 to 66 Fire Damage"]={{[1]={flags=0,keywordFlags=0,name="FireMin",type="BASE",value=44},[2]={flags=0,keywordFlags=0,name="FireMax",type="BASE",value=66}},"Causes Daze buildup equal to 100% of dealt "}
3570-
c["Causes Double Stun Buildup"]={nil,"Causes Double Stun Buildup "}
3570+
c["Causes Double Stun Buildup"]={{}," Stun Buildup "}
35713571
c["Causes Enemies to Explode on Critical kill, for 10% of their Life as Physical Damage"]={nil,"Causes Enemies to Explode on Critical kill, for 10% of their Life as Physical Damage "}
35723572
c["Causes Enemies to Explode on Critical kill, for 10% of their Life as Physical Damage 120% increased Physical Damage"]={nil,"Causes Enemies to Explode on Critical kill, for 10% of their Life as Physical Damage 120% increased Physical Damage "}
35733573
c["Causes Enemies to Explode on Critical kill, for 10% of their Life as Physical Damage 172% increased Physical Damage"]={nil,"Causes Enemies to Explode on Critical kill, for 10% of their Life as Physical Damage 172% increased Physical Damage "}
35743574
c["Causes Enemies to Explode on Critical kill, for 10% of their Life as Physical Damage Adds 62 to 94 Fire Damage"]={{[1]={flags=0,keywordFlags=0,name="FireMin",type="BASE",value=62},[2]={flags=0,keywordFlags=0,name="FireMax",type="BASE",value=94}},"Causes Enemies to Explode on Critical kill, for 10% of their as Physical Damage "}
3575-
c["Chance is doubled against Undead and Demons"]={nil,"Chance is doubled against Undead and Demons "}
3575+
c["Chance is doubled against Undead and Demons"]={{},"Chance against Undead and Demons "}
35763576
c["Chance to Hit with Attacks can exceed 100%"]={{[1]={[1]={skillType=1,type="Skilltype"},flags=0,keywordFlags=0,name="Condition:HitChanceCanExceed100",type="FLAG",value=true}},nil}
3577-
c["Chance to Ignite is doubled"]={{[1]={flags=0,keywordFlags=0,name="EnemyIgniteChance",type="MORE",value=100}},nil}
3577+
c["Chance to Ignite is doubled"]={{[1]={[1]={globalLimit=100,globalLimitKey="EnemyIgniteChanceDoubledLimit",type="Multiplier",var="EnemyIgniteChanceDoubled"},flags=0,keywordFlags=0,name="EnemyIgniteChance",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:EnemyIgniteChanceDoubled",type="OVERRIDE",value=1}},nil}
35783578
c["Chaos Damage from Hits also Contributes to Electrocute Buildup"]={nil,"Chaos Damage from Hits also Contributes to Electrocute Buildup "}
35793579
c["Chaos Damage from Hits also Contributes to Electrocute Buildup Attacks Gain 20% of Physical Damage as extra Chaos Damage"]={nil,"Chaos Damage from Hits also Contributes to Electrocute Buildup Attacks Gain 20% of Physical Damage as extra Chaos Damage "}
35803580
c["Chaos Damage from Hits also Contributes to Freeze Buildup"]={nil,"Chaos Damage from Hits also Contributes to Freeze Buildup "}
35813581
c["Chaos Damage from Hits also Contributes to Freeze Buildup Chaos Damage from Hits also Contributes to Electrocute Buildup"]={nil,"Chaos Damage from Hits also Contributes to Freeze Buildup Chaos Damage from Hits also Contributes to Electrocute Buildup "}
35823582
c["Chaos Damage from Hits also Contributes to Shock Chance"]={{[1]={flags=0,keywordFlags=0,name="ChaosCanShock",type="FLAG",value=true}},nil}
3583-
c["Chaos Resistance is doubled"]={{[1]={flags=0,keywordFlags=0,name="ChaosResist",type="MORE",value=100}},nil}
3583+
c["Chaos Resistance is doubled"]={{[1]={[1]={globalLimit=100,globalLimitKey="ChaosResistDoubledLimit",type="Multiplier",var="ChaosResistDoubled"},flags=0,keywordFlags=0,name="ChaosResist",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:ChaosResistDoubled",type="OVERRIDE",value=1}},nil}
35843584
c["Chaos Resistance is zero"]={{[1]={flags=0,keywordFlags=0,name="ChaosResist",type="OVERRIDE",value=0}},nil}
35853585
c["Charms applied to you have 10% increased Effect"]={{[1]={[1]={actor="player",type="ActorCondition"},flags=0,keywordFlags=0,name="CharmEffect",type="INC",value=10}},nil}
35863586
c["Charms applied to you have 25% increased Effect"]={{[1]={[1]={actor="player",type="ActorCondition"},flags=0,keywordFlags=0,name="CharmEffect",type="INC",value=25}},nil}
@@ -3707,7 +3707,7 @@ c["Dodge Roll cannot Avoid Damage"]={nil,"Dodge Roll cannot Avoid Damage "}
37073707
c["Dodge Roll cannot Avoid Damage Take 30% less Damage from Hits while Dodge Rolling"]={nil,"Dodge Roll cannot Avoid Damage Take 30% less Damage from Hits while Dodge Rolling "}
37083708
c["Dodge Roll passes through Enemies"]={nil,"Dodge Roll passes through Enemies "}
37093709
c["Double Activation Delay of Curses"]={{[1]={flags=0,keywordFlags=0,name="CurseDelay",type="MORE",value=100}},nil}
3710-
c["Double Stun Threshold while Shield is Raised"]={nil,"Double Stun Threshold while Shield is Raised "}
3710+
c["Double Stun Threshold while Shield is Raised"]={{[1]={[1]={globalLimit=100,globalLimitKey="StunThresholdDoubledLimit",type="Multiplier",var="StunThresholdDoubled"},flags=0,keywordFlags=0,name="StunThreshold",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:StunThresholdDoubled",type="OVERRIDE",value=1}}," while Shield is Raised "}
37113711
c["Double the number of your Poisons that targets can be affected by at the same time"]={{[1]={flags=0,keywordFlags=0,name="PoisonCanStack",type="FLAG",value=true},[2]={flags=0,keywordFlags=0,name="PoisonStacks",type="MORE",value=100}},nil}
37123712
c["Doubles Mana Costs"]={{[1]={flags=0,keywordFlags=0,name="ManaCost",type="MORE",value=100}},nil}
37133713
c["Drop Ignited Ground while moving, which lasts 8 seconds and Ignites as though dealing Fire Damage equal to 10% of your maximum Life"]={nil,"Drop Ignited Ground while moving, which lasts 8 seconds and Ignites as though dealing Fire Damage equal to 10% of your maximum Life "}
@@ -3752,7 +3752,7 @@ c["Enemies in your Presence are Ignited as though dealt 100 Base Fire Damage"]={
37523752
c["Enemies in your Presence are Intimidated"]={nil,"Enemies in your Presence are Intimidated "}
37533753
c["Enemies in your Presence are Slowed by 20%"]={nil,"Enemies in your Presence are Slowed by 20% "}
37543754
c["Enemies in your Presence count as being on Low Life"]={nil,"Enemies in your Presence count as being on Low Life "}
3755-
c["Enemies in your Presence count as having double Power"]={nil,"Enemies in your Presence count as having double Power "}
3755+
c["Enemies in your Presence count as having double Power"]={{},"Enemies in your Presence count as having Power "}
37563756
c["Enemies in your Presence have 10% reduced Cooldown Recovery Rate"]={nil,"Enemies in your Presence have 10% reduced Cooldown Recovery Rate "}
37573757
c["Enemies in your Presence have Fire Exposure"]={nil,"Enemies in your Presence have Fire Exposure "}
37583758
c["Enemies in your Presence have Lightning Resistance equal to yours"]={{[1]={flags=0,keywordFlags=0,name="EnemyLightningResistEqualToYours",type="FLAG",value=true}},nil}
@@ -3773,7 +3773,7 @@ c["Enemies you Mark have 10% reduced Accuracy Rating"]={{[1]={[1]={actor="enemy"
37733773
c["Enemies you Mark take 10% increased Damage"]={{[1]={[1]={actor="enemy",type="ActorCondition",var="Marked"},flags=0,keywordFlags=0,name="EnemyModifier",type="LIST",value={mod={flags=0,keywordFlags=0,name="DamageTaken",type="INC",value=10}}}},nil}
37743774
c["Enemies you apply Incision to take 2% increased Physical Damage per Incision"]={{[1]={flags=0,keywordFlags=0,name="EnemyModifier",type="LIST",value={mod={[1]={type="Multiplier",var="IncisionStack"},flags=0,keywordFlags=0,name="PhysicalDamageTaken",type="INC",value=2}}}},nil}
37753775
c["Enemies' Damage with Critical Hits against you is Lucky"]={nil,"Enemies' Damage with Critical Hits is Lucky "}
3776-
c["Energy Generation is doubled"]={nil,"Energy Generation is doubled "}
3776+
c["Energy Generation is doubled"]={{},"Energy Generation "}
37773777
c["Energy Shield Recharge is not interrupted by Damage if Recharge began Recently"]={nil,"Energy Shield Recharge is not interrupted by Damage if Recharge began Recently "}
37783778
c["Energy Shield Recharge starts on use"]={nil,"Energy Shield Recharge starts on use "}
37793779
c["Energy Shield Recharge starts when you use a Mana Flask"]={nil,"Energy Shield Recharge starts when you use a Mana Flask "}
@@ -4385,7 +4385,7 @@ c["Possessed by Spirit Of The Stag for 20 seconds on use"]={nil,"Possessed by Sp
43854385
c["Possessed by Spirit Of The Stag for 20 seconds on use Possessed by Spirit Of The Wolf for 20 seconds on use"]={nil,"Possessed by Spirit Of The Stag for 20 seconds on use Possessed by Spirit Of The Wolf for 20 seconds on use "}
43864386
c["Possessed by Spirit Of The Wolf for 20 seconds on use"]={nil,"Possessed by Spirit Of The Wolf for 20 seconds on use "}
43874387
c["Presence Gain 50% of Damage as Fire Damage"]={nil,"Presence Gain 50% of Damage as Fire Damage "}
4388-
c["Presence Radius is doubled"]={nil,"Presence Radius is doubled "}
4388+
c["Presence Radius is doubled"]={{[1]={[1]={globalLimit=100,globalLimitKey="AreaOfEffectDoubledLimit",type="Multiplier",var="AreaOfEffectDoubled"},flags=0,keywordFlags=0,name="AreaOfEffect",type="MORE",value=100},[2]={flags=0,keywordFlags=0,name="Multiplier:AreaOfEffectDoubled",type="OVERRIDE",value=1}},"Presence "}
43894389
c["Projectile Damage builds Pin"]={nil,"Projectile Damage builds Pin "}
43904390
c["Projectiles Pierce all Ignited enemies"]={nil,"Projectiles Pierce all Ignited enemies "}
43914391
c["Projectiles Pierce all Ignited enemies Attacks Gain 10% of Damage as Extra Fire Damage"]={nil,"Projectiles Pierce all Ignited enemies Attacks Gain 10% of Damage as Extra Fire Damage "}

0 commit comments

Comments
 (0)