Hekili / hekili

Hekili Priority Helper for DPS and Tanks (WoW Retail)
427 stars 220 forks source link

[REC] "spend" hooks within class files behavior possibly erratic #1664

Closed Wyste closed 2 years ago

Wyste commented 2 years ago

Before You Begin

Describe the Issue

"spend" hooks within class files fire irregularly.

I've detailed more for Protection warrior in the How to Reproduce section, but I have also tested Warlock(Destruction) and found the spend hook fires when OOC and flying on a mount as well.

Destro Warlock (ooc - flying around): image

Protection Warrior, very quick combat (some melee, 2 abilities used and then the mob was dead: image

How to Reproduce

(Using v9.2.7-1.0.0b release freshly installed except the following changes:)

  1. Change TOC version field to @project-version@ to enable print functions to work
  2. Add whatever debugging prints you feel are necessary within class file within spec:RegisterHook( "spend", function( amt, resource )
  3. Observe behavior in-game.

In my case for Prot Warrior: During a fight, just after a fight, during rage decay, or even when at 0 rage flying around with 0 interaction with anything, have seen the spend hook fire for a multitude of reasons.

  1. "spend" hook is fired repeatedly, sometimes multiple times per query_time
  2. depending on the incoming values for the recommended action, this potentially will run code further down and falsely deflate/inflate various cooldowns, in protection warrior's case, the Anger Management cooldown will be potentially see several new CD reductions on Shield Wall that don't actually occur in-game.

Note FYI for the below pictures - "charge" was the recommended action here, which would net me +20 rage. image (code used to reproduce) image

Snapshot (Link)

https://pastebin.com/pctDU9U6

Raidbots Sim Report (Link)

No response

Additional Information

No response

Contact Information

Wyste#8631

Hekili commented 2 years ago

Spend hooks are for virtual/emulated behavior, not real spend. I.e., it fires when the addon recommends an ability and needs to spend resources before generating the next recommendation.

Hekili commented 2 years ago

For reference, compare the spend hook here: https://github.com/Hekili/hekili/blob/dragonflight/Classes/WarriorArms.lua#L331

To the UNIT_POWER_FREQUENT handler here: https://github.com/Hekili/hekili/blob/dragonflight/Classes/WarriorArms.lua#L369

The spend hook is what the addon does virtually when it is generating multiple recommendations in one moment (i.e., use Bladestorm then Mortal Strike then whatever).

The UNIT_POWER_FREQUENT handler is where real expenditures are caught. Actual Rage expenditures are counted here (https://github.com/Hekili/hekili/blob/dragonflight/Classes/WarriorArms.lua#L323) in the rageSpent variable, while the "state" environment creates rage_spent for the same data. rage_spent defaults to rageSpent, but can be updated moving step to step and then reset again (https://github.com/Hekili/hekili/blob/dragonflight/Classes/WarriorArms.lua#L398) for the next set of recommendations.

One of the most challenging things to keep track of, when coding for the addon, is keeping track of what is "real" vs. what is a projection out into the future.