# [Trigger]Detect how many levels a unit gained

Status
Not open for further replies.

#### Rasamayu

Level 6
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.

#### Duckfarter

Level 20
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.

#### Rasamayu

Level 6
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.

#### Duckfarter

Level 20
Hello,
I would like to know if there is any way to detect how many levels a unit has gained, thanks.
The event "Unit - A unit gains a level" should work for that if there is no trigger that sets hero level or anything that resets levels.

Unit - A unit gains a level
Set Level = Level + 1

#### Uncle

Warcraft Moderator
Level 65
You can always compare the Integer to their current level and calculate the difference. I don't really see the need for this variable though.

#### Rasamayu

Level 6
Thanks, I did this, the problem with unit gain a level is that it activates even when it gains more than one level, this is the best solution. Thanks
You can always compare the Integer to their current level and calculate the difference. I don't really see the need for this variable though.

#### Bain_Rebirth

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

Replies
2
Views
969
Replies
2
Views
539
Replies
1
Views
560
Replies
4
Views
295
Replies
6
Views
861