@@ -65,29 +65,28 @@ local function checkForScalarMultiplier(modOrGroup, modList)
6565 return 1 + scale / 100
6666end
6767
68- local function getFlagFromBaseMods (baseMods , flag )
69- if baseMods then
70- for _ , baseMod in ipairs (baseMods ) do
71- if baseMod .type == " FLAG" and baseMod .name == flag then
68+ local function isGlobalEffect (modOrGroup )
69+ local modList = modOrGroup .name and { modOrGroup } or modOrGroup
70+ for _ , mod in ipairs (modList ) do
71+ for _ , tag in ipairs (mod ) do
72+ if tag .type == " GlobalEffect" then
7273 return true
7374 end
7475 end
7576 end
7677 return false
7778end
79+
7880-- Merge skill effect modifiers with given mod list
79- -- If a stat set is provided, only merge modifiers from that statset
81+ -- If a stat set is provided, merge it and global effects from the other stat sets
8082function calcs .mergeSkillInstanceMods (env , modList , skillEffect , statSet , extraStats )
8183 calcLib .validateGemLevel (skillEffect )
8284 -- Verify that statSet provided is from skillEffect
8385 if statSet and not isValueInArray (skillEffect .grantedEffect .statSets , statSet ) then
8486 return
8587 end
8688 local grantedEffect = skillEffect .grantedEffect
87- -- for some skills like Flame Wall, the Projectile Buff is on a separate statSet and we want to add it regardless of which statSet is active
88- -- enabled by adding '#baseMod flag("applyBuffsFromAllStatSets)' to the main/first skill txt
89- local applyBuffsFromAllStatSets = getFlagFromBaseMods (statSet and statSet .baseMods , " applyBuffsFromAllStatSets" )
90- for _ , set in ipairs ((applyBuffsFromAllStatSets and grantedEffect .statSets or (statSet and {statSet } or grantedEffect .statSets ))) do
89+ local function mergeStatSet (set , onlyGlobals )
9190 local stats = calcLib .buildSkillInstanceStats (skillEffect , grantedEffect , set )
9291 if extraStats and extraStats [1 ] then
9392 for _ , stat in pairs (extraStats ) do
@@ -99,16 +98,15 @@ function calcs.mergeSkillInstanceMods(env, modList, skillEffect, statSet, extraS
9998 if map then
10099 -- Some mods need different scalars for different stats, but the same value. Putting them in a group allows this
101100 for _ , modOrGroup in ipairs (map ) do
102- -- either we are adding the mods of the activeSkill like usual or we are adding only the Buffs from the other statSets
103- if not applyBuffsFromAllStatSets or (applyBuffsFromAllStatSets and modOrGroup [1 ] and modOrGroup [1 ].effectType == " Buff" ) then
101+ if not onlyGlobals or isGlobalEffect (modOrGroup ) then
104102 local scalar = checkForScalarMultiplier (modOrGroup , modList )
105103 -- Found a mod, since all mods have names
106104 if modOrGroup .name then
107105 modOrGroup .source = string.format (" Skill:%s" , grantedEffect .id )
108106 mergeLevelMod (modList , modOrGroup , map .value or statValue * (map .mult or 1 ) * scalar / (map .div or 1 ) + (map .base or 0 ))
109107 else
110108 for _ , mod in ipairs (modOrGroup ) do
111- local scalar = checkForScalarMultiplier (mod )
109+ local scalar = checkForScalarMultiplier (mod , modList )
112110 mod .source = string.format (" Skill:%s" , grantedEffect .id )
113111 mergeLevelMod (modList , mod , modOrGroup .value or statValue * (modOrGroup .mult or 1 ) * scalar / (modOrGroup .div or 1 ) + (modOrGroup .base or 0 ))
114112 end
@@ -117,8 +115,23 @@ function calcs.mergeSkillInstanceMods(env, modList, skillEffect, statSet, extraS
117115 end
118116 end
119117 end
118+ end
119+ for _ , set in ipairs (statSet and {statSet } or grantedEffect .statSets ) do
120+ mergeStatSet (set )
120121 modList :AddList (set .baseMods )
121122 end
123+ if statSet then
124+ for _ , set in ipairs (grantedEffect .statSets ) do
125+ if set ~= statSet then
126+ mergeStatSet (set , true )
127+ for _ , baseMod in ipairs (set .baseMods or { }) do
128+ if isGlobalEffect (baseMod ) then
129+ modList :AddMod (baseMod )
130+ end
131+ end
132+ end
133+ end
134+ end
122135end
123136
124137-- Create an active skill using the given active gem and list of support gems
0 commit comments