• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Difference of Gain a level and Level up trigger.

Status
Not open for further replies.
Level 9
Joined
Sep 20, 2015
Messages
385
Hello. I'm creating a map where when a hero level up the owner of the hero will have +1 wood. If i use this trigger

Event
A unit gain a level
-
Actions
Player - Add 1 to owner of (leveling hero) Wood

it seems to work but if the units gain a lot of experience and level up for 2 levels at one time, the wood added will be still 1 instead of 2 or more.

The problem is that the
Units - Level Up
event need an existing units in the map. There is a way i can make this second triggers work with a units variable? so if the hero levels up for 2 or more levels, the player who control him recieves an exact amount of wood for each level gained.

Thank you
 
Level 12
Joined
May 22, 2015
Messages
1,051
Hello. I'm creating a map where when a hero level up the owner of the hero will have +1 wood. If i use this trigger

Event
A unit gain a level
-
Actions
Player - Add 1 to owner of (leveling hero) Wood

it seems to work but if the units gain a lot of experience and level up for 2 levels at one time, the wood added will be still 1 instead of 2 or more.

The problem is that the
Units - Level Up
event need an existing units in the map. There is a way i can make this second triggers work with a units variable? so if the hero levels up for 2 or more levels, the player who control him recieves an exact amount of wood for each level gained.

Thank you

Might need to look at this myself (I have some ugly / hacky code to make the first one work, but I didn't know about the second one).

Anyway, this is possible. You can add events to a trigger while the map is being played. Something like:
  • Hero
  • Events
    • Unit - A unit enters <Playable map area>
  • Conditions
    • (Triggering unit) is a hero
  • Actions
    • Trigger - Add the event "Unit - (Triggering unit) levels up" to LevelupTrigger <gen>
It might not look exactly like that, and you might also need to use a variable, but it is possible to do something along those lines.
 
Level 9
Joined
Sep 20, 2015
Messages
385
Might need to look at this myself (I have some ugly / hacky code to make the first one work, but I didn't know about the second one).

Anyway, this is possible. You can add events to a trigger while the map is being played. Something like:
  • Hero
  • Events
    • Unit - A unit enters <Playable map area>
  • Conditions
    • (Triggering unit) is a hero
  • Actions
    • Trigger - Add the event "Unit - (Triggering unit) levels up" to LevelupTrigger <gen>
It might not look exactly like that, and you might also need to use a variable, but it is possible to do something along those lines.

Thank you, i will try
 
I am assuming a player cannot have 2 of these heroes.
If that is true then this should work:

  • Events
    • Unit - a unit enters the playable map
  • Conditions
    • Unit-type of (triggering unit) equal to <unit name> type unit
  • Actions
    • Set p = (Player number of (owner of (triggering unit)))
    • Set Triggering unit = LumberHero
    • Set PriorLevel = (Level of (triggering unit))
That will save the heroes level so that when the event runs, we will know how many levels the hero increased.

  • Events
    • Unit - a unit gains a level
  • Condictions
  • Actions
    • Set p = (Player number of owner of (triggering unit))
    • Set CurrentLevel = (Level of (triggering unit))
    • Set LevelsGained = (Current Level - PriorLevel)
    • Set x = LevelsGained
    • Player - Add X to owner of (leveling hero) Wood
    • Set PriorLevel = (Level of (triggering unit))
This will then add 1 wood for each level gained.
 
Status
Not open for further replies.
Top