Scripting Damage Reduction

bugbear

New Member
Reaction score
3
I'm scripting a custom spell that reduces damage taken by a certain percentage. I've made a trigger to add the unit to the event when it takes damage. My question is, "To reduce damage by 20%, would the following functions work properly?":

Trigger:
  • Actions
    • Set TempReal = ((Damage taken) x 0.20)
    • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + TempReal)


Will this refund the correct amount of damage? Also, will this prevent the character from dying if they have hit points left after this triggered reduction? For example: I have 19 hp left, and my opponent deals 20 damage to me, but after this triggered reduction I should still have 3 hp left.
 

Dirac

22710180
Reaction score
147
1.- No need to use a tempreal, just write the function down in the life gaining.
2.- The code works but...
3.- If you have 20 hp left and you recieve 20 damage you die instead of having 4 hp left.. why? because the unit dies before it regains hp back
 

bugbear

New Member
Reaction score
3
I just did some heavy testing and it appears that the unit will not actually die, it does keep them alive. Apparently the hard coded trigger to kill the unit happens after they take the damage, allowing custom triggers, such as this, to interfere.

Also, it will still kill the unit if the final amount (after triggered) is a negative value.

This is a good thing.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top