• 🏆 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!

How to increase/decrease stats by percentage of the hero?

Level 17
Joined
Jun 2, 2009
Messages
1,148
Hello everyone. I have an item that increases stats by 10% but i want to make it like this
When you pick item, it will increase your stats by 10% (include bonuses)
It is the easy part. I am making this trigger runs when the hero acquires any of the items or increases level and it matches the updated stat bonuses.
Difficult part is taking back the 10% and i am totally confused in here.
How to do that properly?

Example: Let us make it 50%. Your hero has 20 strength and this item increases strength by 20 and by 50%
It will become like this 20+0 > 30 (because it increased 20 to 30) +20
When you drop this, it should revert it like this. 30+20 > 20+0
 
Last edited:
Assuming you can only have 1 item of that type per hero, it's super easy to store the added value to a hashtable or unit-indexed-array and when adding, set the stored value, when removing, remove what the stored value say.

But New Bonus [vJASS][LUA] is super useful and I'd recommend anyone who want slightly more complex bonuses.
 
Top