@@ -1009,11 +1009,11 @@ function calcs.defence(env, actor)
10091009 end
10101010
10111011 local resourceList = {
1012- { name = " Armour" , extraBase = gearArmour , conversionRate = { }, mods = { " Armour" , " ArmourAndEvasion" , " Defences" }, defence = true },
1013- { name = " Evasion" , extraBase = gearEvasion , conversionRate = { }, mods = { " Evasion" , " ArmourAndEvasion" , " Defences" }, defence = true },
1014- { name = " EnergyShield" , extraBase = gearEnergyShield , conversionRate = { }, mods = { " EnergyShield" , " Defences" }, defence = true },
1015- { name = " Life" , extraBase = 0 , conversionRate = { }, mods = { " Life" }, },
1016- { name = " Mana" , extraBase = 0 , conversionRate = { }, mods = { " Mana" }, },
1012+ { name = " Armour" , basePerSlot = {}, globalBase = 0 , conversionRate = { }, mods = { " Armour" , " ArmourAndEvasion" , " Defences" }, defence = true },
1013+ { name = " Evasion" , basePerSlot = {}, globalBase = 0 , conversionRate = { }, mods = { " Evasion" , " ArmourAndEvasion" , " Defences" }, defence = true },
1014+ { name = " EnergyShield" , basePerSlot = {}, globalBase = 0 , conversionRate = { }, mods = { " EnergyShield" , " Defences" }, defence = true },
1015+ { name = " Life" , basePerSlot = {}, globalBase = 0 , conversionRate = { }, mods = { " Life" }, },
1016+ { name = " Mana" , basePerSlot = {}, globalBase = 0 , conversionRate = { }, mods = { " Mana" }, },
10171017 }
10181018 for _ , source in ipairs (resourceList ) do
10191019 output [source .name ] = (output [source .name ] or 0 )
@@ -1030,33 +1030,60 @@ function calcs.defence(env, actor)
10301030 end
10311031 end
10321032 source .totalConversion = totalConversion
1033+ for _ , slot in pairs ({" Helmet" ," Gloves" ," Boots" ," Body Armour" ," Weapon 2" ," Weapon 3" }) do
1034+ source .basePerSlot [slot ] = actor .itemList [slot ] and actor .itemList [slot ].armourData and actor .itemList [slot ].armourData [source .name ] or 0
1035+ end
10331036 end
10341037 for _ , source in ipairs (resourceList ) do
1035- local sourceBase = modDB :Sum (" BASE" , nil , unpack (source .mods )) + source .extraBase
1036- if sourceBase > 0 then
1037- for _ , target in ipairs (resourceList ) do
1038- if source .name ~= target .name then
1039- local gainRate = modDB :Sum (" BASE" , nil , source .name .. " GainAs" .. target .name )
1038+ local globalBase = modDB :Sum (" BASE" , nil , unpack (source .mods )) + source .globalBase
1039+ for _ , target in ipairs (resourceList ) do
1040+ if source .name ~= target .name then
1041+ if source .defence then
1042+ local gainRate = modDB :Sum (" BASE" , nil , source .name .. " GainAs" .. target .name )
1043+ local rate = source .conversionRate [target .name ] + gainRate
1044+ if rate > 0 then
1045+ for _ , slot in pairs ({ " Helmet" , " Gloves" , " Boots" , " Body Armour" , " Weapon 2" , " Weapon 3" }) do
1046+ if source .basePerSlot [slot ] > 0 then
1047+ local targetBase = source .basePerSlot [slot ] * rate / 100
1048+ if target .defence then
1049+ target .basePerSlot [slot ] = target .basePerSlot [slot ] + targetBase
1050+ else
1051+ target .globalBase = target .globalBase + targetBase
1052+ end
1053+ if breakdown then
1054+ breakdown .slot (slot , source .name .. " to " .. target .name .. " conversion" , { slotName = slot }, targetBase , nil , unpack (target .mods ))
1055+ end
1056+ source .basePerSlot [slot ] = source .basePerSlot [slot ] * (100 - source .totalConversion ) / 100
1057+ end
1058+ end
1059+ target .globalBase = target .globalBase + globalBase * rate / 100
1060+ if breakdown then
1061+ breakdown .slot (" Global" , source .name .. " to " .. target .name .. " conversion" , nil , globalBase , nil , unpack (target .mods ))
1062+ end
1063+ end
1064+ source .globalBase = globalBase * (100 - source .totalConversion ) / 100
1065+ else
1066+ local gainRate = modDB :Sum (" BASE" , nil , source .name .. " GainAs" .. target .name )
10401067 local rate = source .conversionRate [target .name ] + gainRate
10411068 if rate > 0 then
1042- local targetBase = sourceBase * rate / 100
1043- target .extraBase = target .extraBase + targetBase
1069+ local targetBase = globalBase * rate / 100
1070+ target .globalBase = target .globalBase + targetBase
10441071 if breakdown then
1045- breakdown .slot (" Conversion" , source .name .. " to " .. target .name , nil , targetBase , nil , unpack (target .mods ))
1072+ breakdown .slot (" Conversion" , source .name .. " to " .. target .name , nil , targetBase , nil , unpack (target .mods ))
10461073 end
10471074 end
10481075 end
10491076 end
10501077 end
1051- if source .defence then
1052- source .extraBase = sourceBase * (100 - source .totalConversion ) / 100
1053- end
10541078 end
10551079 for _ , res in ipairs (resourceList ) do
10561080 if res .defence then
1057- output [res .name ] = output [res .name ] + res .extraBase * calcLib .mod (modDB , nil , unpack (res .mods ))
1081+ for _ , slot in pairs ({" Helmet" ," Gloves" ," Boots" ," Body Armour" ," Weapon 2" ," Weapon 3" }) do
1082+ output [res .name ] = output [res .name ] + res .basePerSlot [slot ] * calcLib .mod (modDB , { slotName = slot }, unpack (res .mods ))
1083+ end
1084+ output [res .name ] = output [res .name ] + res .globalBase * calcLib .mod (modDB , nil , unpack (res .mods ))
10581085 else
1059- modDB :NewMod (" Extra" .. res .name , " BASE" , res .extraBase , " Conversion" )
1086+ modDB :NewMod (" Extra" .. res .name , " BASE" , res .globalBase , " Conversion" )
10601087 end
10611088 end
10621089 output .EnergyShield = modDB :Override (nil , " EnergyShield" ) or m_max (round (output .EnergyShield ), 0 )
0 commit comments