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

Reducing unit hp many times on 1.26

Level 9
Joined
May 24, 2016
Messages
298
Hello my friends. I'd like to make a mechanic that help hero get revived instantly if he presses the abil to do so in exchange of his hp.

I belive I should do that via giving an hp increase abil with negative values.
The question is, is it possible to encounter bugs or crashes if hp abils would be around 50-100 on hero by the end of the game? Are there any limits of maximum abils for unit to carry?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,563
I'm confused, why would you need an ability with negative values and why would you need so many abilities?
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to YourAbility
  • Actions
    • Set Life of (Casting unit) to (Life of (Casting unit)) - 100.00)
Also, to clarify, this is basically a suicide ability? Why doesn't it just kill the hero outright? Or does it revive a different hero?
 
Level 9
Joined
May 24, 2016
Messages
298
I'm confused, why would you need an ability with negative values and why would you need so many abilities?
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to YourAbility
  • Actions
    • Set Life of (Casting unit) to (Life of (Casting unit)) - 100.00)
Also, to clarify, this is basically a suicide ability? Why doesn't it just kill the hero outright? Or does it revive a different hero?
This abil is directed to let instantly revive the hero in exhcange of reducing hero's MAX hp by 200.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,563
This abil is directed to let instantly revive the hero in exhcange of reducing hero's MAX hp by 200.
Ah, max is the important word here, people will assume you mean current otherwise.

I still don't understand how a dead hero can use an ability, but I imagine you've got it figured out.

Anyway, you probably want to trigger it so the hero cannot use the ability if it's Max Hp is already less than 200.

Cancel when too low life:
  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to YourAbility
    • (Max Life of (Triggering unit)) Less than or equal to 200.00
  • Actions
    • Unit - Order (Triggering unit) to Stop
Otherwise, add a Item Life Bonus ability with a -200 value:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to YourAbility
  • Actions
    • Unit - Add Max Hp -200 to (Triggering unit)
A lot of Item abilities will stack. If not, you can try the Set Level method, it should be fine.
 
Level 39
Joined
Feb 27, 2007
Messages
5,023
Wahoo I get to correct Uncle. Those item life bonus abilities have an issue with level which is what BonusMod was built on:

Leveling them up will not change the stats they ‘give’. They will be stuck at the level 1 value. However, when they are removed from the unit, they will remove the correct amount of stats they should have added for the level they’re at.

Level 1 should add 0 hp, then level 2 should add 200 hp. Give the ability, level it to 2, and remove the ability = (+0 - 200) = -200 hp.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
For maximum life you can use a tome of life ability on the unit to remove the life. This was the really old, classic, way to do it.

I also think it is one of the few attributes you could use the item ability level change bug to modify permanently as well. This was the best way to do it before Reforged.

For the item ability level change bug you rely on item abilities not having code to handle level changes, they often only have code to handle addition and removal of the ability. So to remove 200 HP you would create an item health bonus ability with 2 levels.
Code:
Level 1 -> 0 HP
Level 2 -> 200 HP
When you want to remove the maximum health you give the unit the ability. Then you level it up to level 2 and remove the ability. The result would be the unit has 200 less maximum health. This is because when you give it to the unit it gains 0 health, when you change the level to level 2 it gains 0 health due to missing level up handler code, and then when you remove the ability it loses 200 health because the removal handler removes the level appropriate amount of maximum health even though the level up handler did not adjust maximum health to reflect the level change. This could be used to add health as well using similar logic. For a more flexible system, make the multi-level ability use powers of 2 so you could efficiently change any amount of max health in a large range.

This is no longer needed in Reforged as you can just modify unit maximum health with triggers directly.
 
Top