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

[General] Items that give % of base stats.

Status
Not open for further replies.
Level 8
Joined
Feb 11, 2016
Messages
232
Greetings! I want to make Items that give % of base, including level up stats and tomes, stats to hero when carried.

Stats I want include:
Health, Health regeneration, Mana, Mana regeneration, Armor, Strength, Agility, Intelligence.

Examples:
Rod of age gives 10% of base intelligence, two of them wouldn't be: base*0,1*0,1 but base*0,2.
 
Level 9
Joined
Jul 30, 2018
Messages
445
I'm not sure if setting a stat with triggers will affect the bonuses, but basically you could just use the trigger action: Set Hero Attribute and set it to (Int of Hero (exclude bonuses) + (Int of Hero (exclude bonuses) * 0.1)).

But setting stats with triggers can be quite a hassle, so think twice before going that way. On the other hand, I guess a percent-based bonus is only doable with triggers.
 
Level 8
Joined
Feb 11, 2016
Messages
232
United257.png
 
Level 5
Joined
May 12, 2014
Messages
133
When adding the percentage bonus, just save the heroes' stats before and after the change. Add them to a loop where you compare their currents stats to previous stats. If it's different, then it means they've gotten more stats outside of the percentage. Subtract the percentage bonus and reapply the percentage based on their new stats.
 
Level 5
Joined
May 12, 2014
Messages
133
Sorry, I forgot to make an example trigger after work. I can throw an example right now though.

So let's say a hero has 100 strength when he acquires an item that gives 10% bonus STR. If you add the hero to a loop, and save the 100 (their base STR) and save 10% of that (10, which is the bonus amount) BEFORE you add the bonus.

Recap: The hero is saved inside of a loop with the numbers 100 and 10, so 3 different variables in a loop. The hero currently has 110 strength.

So periodically you would take the hero's current strength (110) and subtract the bonus amount (10). If it matches up with the base strength (100) then nothing has changed.

Now let's say the hero levels up and gains 10 strength. Now he's at 120. When the loop runs, you get 120 - 10 = 110, which is not 100. So you know his strength value has changed.

Subtract the bonus value from his current strength (120 - 10 = 110) and reapply the original stat adjustment. ( the hero has a base strength of 110, bonus is now 11). Add the bonus and now he's at 121 as he should be.

Hopefully this makes sense! :)
This same logic can be applied to agility, intelligence, HP, and MP. Other stats like armor, attack speed, etc. could possibly work if you have an easy way to track them.
 
Status
Not open for further replies.
Top