• 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.

[Trigger] Detect how many levels a unit gained

Status
Not open for further replies.
Level 6
Joined
Jul 14, 2020
Messages
128
Greetings Hive

I want to save in a variable the number of levels a unit gains. For example, I use the event unit gains a level, after that, a variable increases by 1.

But it does not detect when a unit goes up a single level, instead of that , he also does it when he gain many levels.

That is, if a unit goes from level 1 to 4, what will be stored in my levels variable will be 1. I would like to know if there is any way to detect how many levels a unit has gained, thanks. :grin:
 
Level 6
Joined
Jul 14, 2020
Messages
128
Hello Rasamayu. I dont understand what you want in the trigger. Can you post and share your current trigger so that I can better understand what you want in the trigger?

Can you tell me simple what you want the trigger to do again? I dont understand.
Hello,
I would like to know if there is any way to detect how many levels a unit has gained, thanks.
 
Level 9
Joined
Oct 20, 2010
Messages
228
This is not MUI, but I think I get what you're saying.
1. You will need to store the level of the unit so you can later reference it. This way you'll have access to the new and old level of the unit upon level up.
2. You will need to calculate the difference between the new level of the unit (after leveling up) and the old level of the unit (before leveling up). This will tell you how many levels were granted.

I highly recommend using Unit Indexer and saving the level of the hero as an array if you intend to use this for more than 1 unit.
  • Init
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Set VariableSet v_difLevel = ((Hero level of (Triggering unit)) - v_level)
      • Set VariableSet v_level = (Hero level of (Triggering unit))
      • For each (Integer A) from 1 to v_difLevel, do (Actions)
        • Loop - Actions
          • -------- do something for each level gained --------
 
Status
Not open for further replies.
Top