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

[vJASS] Best Way to Prevent Damage

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hi guys,

I am developing a spell for someone which requires a damage shield. It is supposed to block ALL incoming damage from the unit that has the shield. What would be the best way to do this?

I have AIDS and Dirac's Damage struct. I know he has a shield library, but I would like to try create my own.

Thanks for any help!
 
Level 13
Joined
Mar 16, 2008
Messages
941
Just track all damage and heal it.
Be aware that there are some problems.
To maximise the chance of surviving heal up as much damage as possible BEFOR the damage is dealt (max hp - current hp).
Heal up the rest of the damage afterwards.
At full hp a nuke that one-shots you can't be avoided.
At 1 hp a nuke that deals twice your hp as damage can't be avoided.
There are posibilities with increasing the maximum hp that are sort of unlimited.
Since most times there are no one-hit nukes or only if the game is very unbalanced, last solution is nearly never needed.
 
Easy.

JASS:
call UnitAddAbility(yourUnit, LIFE_BONUS)
call SetWidgetLife(yourUnit, GetWidgetLife(yourUnit) + Damage.amount)
call UnitRemoveAbility(yourUnit, LIFE_BONUS)

LIFE_BONUS is an ability that gives your units millions of HP.

edit
Or, simply:
call Damage.prevent(Damage.amount)

Dirac's Damage system is pretty awesome :p
I still use Nes' though.
I'm using Dirac's library cut in half for damage blocking =p
 
Status
Not open for further replies.
Top