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

[Trigger] Unit unable to take damage

Status
Not open for further replies.
Level 4
Joined
Jun 25, 2008
Messages
67
How could I make a unit not take damage while casting a spell, but the enemy units can still attack the unit. For example, the spell im using is Omnislash, i dont want the enemies to run away when i cast this spell (because this spell currently make you invincible)
 
Level 23
Joined
Oct 18, 2008
Messages
938
Setting it to 0, mean no damage. Setting it to a negative, means heal damage based on damage dealt.

no it buggs

E:
I've used it when trying to reduce damage taken. If damage taken increase is set to a negative value, then it heals whenever the unit is attacked, but I'm not entirely sure if setting it to 0 stops damage.

no wtf i tried that and it just didnt take damage
 
Level 13
Joined
Sep 14, 2008
Messages
1,407
If the unit is a specific unit you could try a trigger...:

Event: "YourUnit" is dealt damage.
Condition:
Action: Set "YourUnit"s life to current life + "dealt damage"

But I am not sure what happens if the unit has ~1 hp and is attacked then...
(I think it dies because it's dead before the trigger runs, but I am not sure)
 
Level 27
Joined
Feb 22, 2006
Messages
3,052
If the unit is a specific unit you could try a trigger...:

Event: "YourUnit" is dealt damage.
Condition:
Action: Set "YourUnit"s life to current life + "dealt damage"

But I am not sure what happens if the unit has ~1 hp and is attacked then...
(I think it dies because it's dead before the trigger runs, but I am not sure)

Unit takes damage as well as unit is attacked work in strange ways. They actually work right before the damage/attack occurs, so yes, this trigger would work even if the unit's current health is lower than the damage being taken. If the unit's lost health is less than the damage, however, you have to wait a second and let the unit take the damage and then heal it. The only time in which this doesn't work is when the unit has less total HP than the damage of the spell, in which you have to do tricky JASS maneuvers.
--donut3.5--
 
Level 6
Joined
Sep 5, 2007
Messages
264
@donut3.5: I've had it all working 100% right, with everything happening at "unit takes damage".

Unless you use a "damage-detection" approach, Enemy hero damage still happen. I found this out in the past when working on the ability I was talking about earlier. The "defend" approach works, yes, but not 100% effectively.
 
Status
Not open for further replies.
Top