• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Detecting When Skillpoints are Allocated

Status
Not open for further replies.
Level 2
Joined
Jan 8, 2018
Messages
12
I'm working on an ability for my map which is inspired by the 'Anoint' skill in "Build and Brawl"'s Naga race.
My hero starts with an ability (tentatively called 'Anoint') which provides a permanent buff to a target player-owned unit. Only one unit can be Anointed at a time, and the Anointed unit shares the same inventory as the hero, is the target of the hero's other skills, and (this is the part which isn't working yet) gets stat buffs which are dependent upon the hero's skillpoint allocation. For example, if the hero puts 2 points into their first skill (a healing spell which affects an AoE around the Anointed unit), the Anointed unit also passively gets a level 2 bonus to maximum health and health regeneration.
The problem that I'm having is that I want the Anointed unit's buffs to update when the hero allocates skill points. I can't work out how to detect this without setting up a recurring timer every second or so which checks the hero's skill levels against where they were, which seems inefficient. Is there some cool trick which I can use to detect this via triggers, or am I going to have to use a timer?
I'm working in JASS.

Thanks for your help.
 
Level 2
Joined
Jan 8, 2018
Messages
12
Maybe use this event?
JASS:
EVENT_PLAYER_HERO_SKILL

I am not sure what do you want.

I thought that would work, and I had something like the following set up:
JASS:
        private static method Trig_Anoint_Skillpoint_Allocation_Change_Actions takes nothing returns nothing
            call print("Trig_Anoint_Skillpoint_Allocation_Change_Actions")
        endmethod
      
        private static method InitTrig_Anoint_Skillpoint_Allocation_Change takes nothing returns nothing
            set gg_trg_Anoint_Skillpoint_Allocation_Change = CreateTrigger(  )
            call TriggerAddAction(gg_trg_Anoint_Skillpoint_Allocation_Change, function thistype.Trig_Anoint_Skillpoint_Allocation_Change_Actions)
            call TriggerRegisterAnyUnitEventBJ(gg_trg_Anoint_Skillpoint_Allocation_Change, EVENT_PLAYER_HERO_SKILL)
        endmethod
I couldn't to get this trigger to ever activate. It didn't trigger when a hero gained skillpoints, used them, or used skills. I assumed that EVENT_PLAYER_HERO_SKILL must not do what I wanted it to do, or had been dummied out.

Because you suggested it, I've spent a little more time on it, and I actually got it working.
This might not make much sense since you can't see the code, but instead of creating the trigger when the map initializes using
JASS:
TriggerRegisterAnyUnitEventBJ(gg_trg_Anoint_Skillpoint_Allocation_Change, EVENT_PLAYER_HERO_SKILL)
(and then filtering to make sure that the triggering unit was the hero), I've instead moved the trigger creation in the the struct's create() method and used
JASS:
TriggerRegisterUnitEvent(<structInstance>.Anoint_Skillpoint_Allocation_Change, hero, EVENT_UNIT_HERO_SKILL )
, and it actually works. I have no idea why it didn't work before, but this is fine. Instead of having one trigger which would fire when any hero allocated skill points, I'll have a trigger for each instance of the hero, which only fires when that specific hero allocates skill points.


tl;dr yeah, EVENT_PLAYER_HERO_SKILL is what I was looking for, but deceptively, it didn't work when I tried it before. I had to change the format of the trigger setup to get it to work. Thanks.
 
Status
Not open for further replies.
Top