How to set a var before a talent is used?
Posted: Tue Feb 06, 2018 7:02 am
I try to make an addon for a class that has a sustained talent that gives great benefits to melee attacks, but forbids all regular attacks (bump, attacks from technique, cunning, etc). Only automatic attacks (TK or retaliation attacks provided by the class) or attacks from some specific talents would be allowed. (because a rand boss or an adventurer with flurry and this sustain would be too unbalanced)
To do that, bumpInto can be superloaded to check if the attack is valid. Attacks triggered by talents are trickier. One solution is to use a turn_procs variable that forbids attacks and to hook or superload attackTarget (and ditto for attackTargetWith) to take into account this turn_procs.
The problem is how to set this turn_procs var?
The initial idea was to use the Actor:preUseTalent hook. According to the wiki, it triggers just before a talent is used. It can check if the sustain is on and if the talent has some characteristics to set the turn proc. (Actually only talents with a psi or sustain_psi field could be allowed to trigger if the sustain is on).
It happens that the Actor:preUseTalent hook is not checked right before the use of a talent, but for all the actor talents at the start of a turn (like the on_pre_use talent field). and this solution does not work.
Indeed, what I would need is to set my turn_procs variable just at the beginning of useTalent in ActorTalents.lua in the engine. AFAIK, engine methods cannot be superloaded, but maybe there is a way...
The other solution that I see is to superload the action field of all the talents in the game to set the turn_procs. It is somehow painful because some talents can do attacks without a "action" (BTF, for instance, but maybe there are others talents like that in vanilla or in addons).
Is there a way that I miss to hook right before before a talent is used?
Do you see any other way to do that?
To do that, bumpInto can be superloaded to check if the attack is valid. Attacks triggered by talents are trickier. One solution is to use a turn_procs variable that forbids attacks and to hook or superload attackTarget (and ditto for attackTargetWith) to take into account this turn_procs.
The problem is how to set this turn_procs var?
The initial idea was to use the Actor:preUseTalent hook. According to the wiki, it triggers just before a talent is used. It can check if the sustain is on and if the talent has some characteristics to set the turn proc. (Actually only talents with a psi or sustain_psi field could be allowed to trigger if the sustain is on).
It happens that the Actor:preUseTalent hook is not checked right before the use of a talent, but for all the actor talents at the start of a turn (like the on_pre_use talent field). and this solution does not work.
Indeed, what I would need is to set my turn_procs variable just at the beginning of useTalent in ActorTalents.lua in the engine. AFAIK, engine methods cannot be superloaded, but maybe there is a way...
The other solution that I see is to superload the action field of all the talents in the game to set the turn_procs. It is somehow painful because some talents can do attacks without a "action" (BTF, for instance, but maybe there are others talents like that in vanilla or in addons).
Is there a way that I miss to hook right before before a talent is used?
Do you see any other way to do that?