Skip to content

Commit 9c7a72d

Browse files
github-actions[bot]PeecheyLocalIdentity
authored
Add support baseFlag and player actor support (#9859)
* Apply changes from PathOfBuildingCommunity/PathOfBuilding-PoE2#1846 * Fix merge I only wanted the actor and basFlag changes * Fix baseFlag implementation --------- Co-authored-by: Peechey <Peechey@users.noreply.github.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 7763400 commit 9c7a72d

3 files changed

Lines changed: 68 additions & 21 deletions

File tree

spec/System/TestSkills_spec.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,25 @@ describe("TestAttacks", function()
228228
local finalCost = build.calcsTab.mainOutput.ManaCost
229229
assert.are.equals(7, round(finalCost))
230230
end)
231+
232+
it("evaluates BaseFlag tags using PoB 1 skill data", function()
233+
build.skillsTab:PasteSocketGroup("Absolution 20/0 1\n")
234+
runCallback("OnFrame")
235+
236+
local durationSkill = build.calcsTab.mainEnv.player.mainSkill
237+
durationSkill.skillModList:NewMod("BaseFlagTest", "BASE", 1, "Test", { type = "BaseFlag", baseFlag = "duration" })
238+
durationSkill.skillModList:NewMod("NegatedBaseFlagTest", "BASE", 1, "Test", { type = "BaseFlag", baseFlag = "duration", neg = true })
239+
assert.are.equals(1, durationSkill.skillModList:Sum("BASE", durationSkill.skillCfg, "BaseFlagTest"))
240+
assert.are.equals(0, durationSkill.skillModList:Sum("BASE", durationSkill.skillCfg, "NegatedBaseFlagTest"))
241+
242+
newBuild()
243+
build.skillsTab:PasteSocketGroup("Fireball 20/0 1\n")
244+
runCallback("OnFrame")
245+
246+
local nonDurationSkill = build.calcsTab.mainEnv.player.mainSkill
247+
nonDurationSkill.skillModList:NewMod("BaseFlagTest", "BASE", 1, "Test", { type = "BaseFlag", baseFlag = "duration" })
248+
nonDurationSkill.skillModList:NewMod("NegatedBaseFlagTest", "BASE", 1, "Test", { type = "BaseFlag", baseFlag = "duration", neg = true })
249+
assert.are.equals(0, nonDurationSkill.skillModList:Sum("BASE", nonDurationSkill.skillCfg, "BaseFlagTest"))
250+
assert.are.equals(1, nonDurationSkill.skillModList:Sum("BASE", nonDurationSkill.skillCfg, "NegatedBaseFlagTest"))
251+
end)
231252
end)

src/Classes/CalcBreakdownControl.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ function CalcBreakdownClass:AddModSection(sectionData, modList)
474474
if not desc then
475475
desc = "Skill type: "..(tag.neg and "Not " or "").."?"
476476
end
477+
elseif tag.type == "BaseFlag" then
478+
desc = "Base flag: "..(tag.neg and "Not " or "")..self:FormatModName(tostring(tag.baseFlag))
477479
elseif tag.type == "SlotNumber" then
478480
desc = "When in slot #"..tag.num
479481
elseif tag.type == "GlobalEffect" then

src/Classes/ModStore.lua

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ local ModStoreClass = newClass("ModStore", function(self, parent)
3434
self.conditions = { }
3535
end)
3636

37+
local function getActor(self, actorType)
38+
if actorType == "player" then
39+
return self.actor.player or (self.actor.parent and self.actor.parent.player) or (self.actor.enemy and self.actor.enemy.player)
40+
else
41+
return self.actor[actorType]
42+
end
43+
end
44+
3745
function ModStoreClass:ScaleAddMod(mod, scale, replace)
3846
local unscalable = false
3947
for _, effects in ipairs(mod) do
@@ -323,15 +331,17 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
323331
-- This explicit target is necessary because even though the GetMultiplier method does call self.parent.GetMultiplier, it does so with noMod = true,
324332
-- disabling the summation (3rd part): (not noMod and self:Sum("BASE", cfg, multiplierName[var]) or 0)
325333
if tag.limitActor then
326-
if self.actor[tag.limitActor] then
327-
limitTarget = self.actor[tag.limitActor].modDB
334+
local limitActor = getActor(self, tag.limitActor)
335+
if limitActor then
336+
limitTarget = limitActor.modDB
328337
else
329338
return
330339
end
331340
end
332341
if tag.actor then
333-
if self.actor[tag.actor] then
334-
target = self.actor[tag.actor].modDB
342+
local actor = getActor(self, tag.actor)
343+
if actor then
344+
target = actor.modDB
335345
else
336346
return
337347
end
@@ -398,15 +408,17 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
398408
local target = self
399409
local thresholdTarget = self
400410
if tag.thresholdActor then
401-
if self.actor[tag.thresholdActor] then
402-
thresholdTarget = self.actor[tag.thresholdActor].modDB
411+
local thresholdActor = getActor(self, tag.thresholdActor)
412+
if thresholdActor then
413+
thresholdTarget = thresholdActor.modDB
403414
else
404415
return
405416
end
406417
end
407418
if tag.actor then
408-
if self.actor[tag.actor] then
409-
target = self.actor[tag.actor].modDB
419+
local actor = getActor(self, tag.actor)
420+
if actor then
421+
target = actor.modDB
410422
else
411423
return
412424
end
@@ -428,8 +440,9 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
428440
local target = self
429441
-- This functions similar to the above tagTypes in regard to which actor to use, but for PerStat
430442
-- if the actor is 'parent', we don't want to return if we're already using 'parent', just keep using 'self'
431-
if tag.actor and self.actor[tag.actor] then
432-
target = self.actor[tag.actor].modDB
443+
local actor = getActor(self, tag.actor)
444+
if actor then
445+
target = actor.modDB
433446
end
434447
if tag.statList then
435448
base = 0
@@ -450,7 +463,7 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
450463
limitTotal = limit
451464
else
452465
mult = m_min(mult, limit)
453-
end
466+
end
454467
end
455468
if type(value) == "table" then
456469
value = copyTable(value)
@@ -476,8 +489,9 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
476489
local target = self
477490
-- This functions similar to the above tagTypes in regard to which actor to use, but for PercentStat
478491
-- if the actor is 'parent', we don't want to return if we're already using 'parent', just keep using 'self'
479-
if tag.actor and self.actor[tag.actor] then
480-
target = self.actor[tag.actor].modDB
492+
local actor = getActor(self, tag.actor)
493+
if actor then
494+
target = actor.modDB
481495
end
482496
if tag.statList then
483497
base = 0
@@ -499,7 +513,7 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
499513
limitTotal = limit
500514
else
501515
mult = m_min(mult, limit)
502-
end
516+
end
503517
end
504518
if type(value) == "table" then
505519
value = copyTable(value)
@@ -555,17 +569,17 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
555569
end
556570
end
557571
end
558-
-- Syntax: { type = "MeleeProximity", ramp = {MaxBonusPct,MinBonusPct} }
559-
-- Both MaxBonusPct and MinBonusPct are percent in decimal form (1.0 = 100%)
560-
-- Example: { type = "MeleeProximity", ramp = {1,0} } ## Duelist-Slayer: Impact
572+
-- Syntax: { type = "MeleeProximity", ramp = {MaxBonusPct,MinBonusPct} }
573+
-- Both MaxBonusPct and MinBonusPct are percent in decimal form (1.0 = 100%)
574+
-- Example: { type = "MeleeProximity", ramp = {1,0} } ## Duelist-Slayer: Impact
561575
elseif tag.type == "MeleeProximity" then
562576
if not cfg or not cfg.skillDist then
563577
return
564578
end
565579
-- Max potency is 0-15 units of distance
566580
if cfg.skillDist <= 15 then
567581
value = value * tag.ramp[1]
568-
-- Reduced potency (linear) until 40 units
582+
-- Reduced potency (linear) until 40 units
569583
elseif cfg.skillDist >= 16 and cfg.skillDist <= 39 then
570584
value = value * (tag.ramp[1] - ((tag.ramp[1] / 25) * (cfg.skillDist - 15)))
571585
elseif cfg.skillDist >= 40 then
@@ -608,7 +622,8 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
608622
local match = false
609623
local target = self
610624
if tag.actor then
611-
target = self.actor[tag.actor] and self.actor[tag.actor].modDB
625+
local actor = getActor(self, tag.actor)
626+
target = actor and actor.modDB
612627
end
613628
if target and (tag.var or tag.varList) then
614629
if tag.varList then
@@ -713,7 +728,7 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
713728
end
714729
return false
715730
end
716-
731+
717732
local match = {}
718733
if tag.slotName then
719734
match["slotName"] = (tag.slotName == cfg.slotName) or false
@@ -820,6 +835,15 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
820835
if not match then
821836
return
822837
end
838+
elseif tag.type == "BaseFlag" then
839+
local baseFlags = cfg and ((cfg.skillGrantedEffect and cfg.skillGrantedEffect.baseFlags) or cfg.baseFlags)
840+
local match = baseFlags and baseFlags[tag.baseFlag] or false
841+
if tag.neg then
842+
match = not match
843+
end
844+
if not match then
845+
return
846+
end
823847
elseif tag.type == "SlotName" then
824848
if not cfg then
825849
return
@@ -901,4 +925,4 @@ function ModStoreClass:EvalMod(mod, cfg, globalLimits)
901925
end
902926
end
903927
return value
904-
end
928+
end

0 commit comments

Comments
 (0)