• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to detect a hero's exp to next level?

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,657
There is a cheap way to do it.
Which is creating a dummy hero and leveling it up via triggers.
Then each time, you check how much EXP he has.
Then you store that in an array, and then you can read from that array how much it was.

The "proper" way is to implement the formula of required exp into the game.
That way, you can do it without the need of dummies nor anything else.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
No, I cannot show you triggers.
But the theory is pretty simple.
1, create hero.
2, loop from 1 to 10 (maximum level of heroes)
- increase hero level
- store current exp of hero in array with index A (from the loop)
3, remove the hero from the game.

Then you have the required exp per level in an array.
 
Level 11
Joined
Jun 2, 2004
Messages
849
The dummy unit one does have the advantage of only having 1 place where the xp curve is defined. If you want to change it later, you only need to modify gameplay constants, instead of having to modify your initialization trigger as well. Duplicated data is a big cause of unnecessary bugs, as people forget to update every place something is defined.
 
Status
Not open for further replies.
Top