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

[Trigger] Constant hp?

Status
Not open for further replies.
Level 7
Joined
May 18, 2010
Messages
264
FINISHED Constant hp?

may i make som hp protection thingy im got this far but i got it all wrong for shure :D
  • Divine Shield
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cfff0e68cProtection Touch|r
    • Actions
      • Set Devine_Unit = (Triggering unit)
      • Set Devine_Hp = (Integer((Life of Devine_Unit)))
      • Set Devine_Count = (Devine_Count + (((Integer((Real((Level of Protectio touch for Devine_Unit))))) x 17) + 50))
      • Game - Display to (All players) the text: (String(Devine_Count))
      • Trigger - Turn on DevineShield03 <gen>
  • DevineShield03
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Real(Devine_Count)) Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of Devine_Unit to (Real(Devine_Hp))
          • Set Devine_Count = (Devine_Count - 1)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) the text: Turning off
its for 1 hero only...
btw when his hp is low like 5 hp and he got hit for 6+ dmg he dies :(
is there ani way to make a sistem to protect his hp ???
so he dosent die ?
 
Last edited:
Level 7
Joined
May 18, 2010
Messages
264
Uhmm? how i check attacking unit damage ?
before it hits a unit? is it possible?
i know it can be made in jass i saw it once but ? :D im new
 
Level 7
Joined
May 18, 2010
Messages
264
Thanks + rep
but this dosent work for me
  • Set PT_Dmg = (Integer((Damage taken)))
 
Level 8
Joined
Aug 21, 2009
Messages
333
Thanks + rep
but this dosent work for me
  • Set PT_Dmg = (Integer((Damage taken)))

Don't turn it into an integer. You will want to keep it Real ;) (sorry, that was lame).
Add (Damage Taken) to the current life of the unit whenever he takes damage.

EDIT: the "Unit takes Damage" event only works for a Specific Unit event.
You will have to write a trigger that
  1. checks for that ability to be cast; then...
  2. turns of this trigger
  3. adds the "(Casting Unit) takes Damage" to the events of DevineShield03
DevineShield03 should start out with nothing in its Events section.
 
Level 7
Joined
May 18, 2010
Messages
264
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has buff Protection Touch 1 ) Equal to True
    • Actions
      • Set PT_Unit = (Attacked unit)
      • Set PT_Tu = (Attacking unit)
      • Set PT_Dmg = (Integer((Damage taken)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Unit - Set life of PT_Unit to ((Life of PT_Unit) + (Real((Integer((Damage taken))))))
          • Game - Display to (All players) the text: ((String(PT_Dmg)) + damage healed)
          • Game - Display to (All players) the text: ((String((Damage taken))) + damage healed)
        • Else - Actions
i have this but intriget damage taken i got no idea how to keap it real
 
Level 8
Joined
Aug 21, 2009
Messages
333
  • Untitled Trigger 001
    • Events
    • Conditions
      • ((Attacked unit) has buff Protection Touch 1 ) Equal to True
    • Actions
      • Set PT_Unit = (Attacked unit)
      • Set PT_Tu = (Attacking unit)
      • Set PT_Dmg = (Damage taken) <-- make this variable a Real
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Unit - Set life of PT_Unit to ((Life of PT_Unit) + (Damage taken))) <-- removed "(Real(Integer("
          • Game - Display to (All players) the text: ((String(Integer(PT_Dmg))) + damage healed) <-- added "Integer("
          • Game - Display to (All players) the text: ((String((Damage taken))) + damage healed)
        • Else - Actions
EDIT: I edited my 3rd post, I don't know if you saw that.
 
Level 7
Joined
May 18, 2010
Messages
264
uhm ... im not scupid i get what u mean i scrolled evry well function theres nothing on damage tipe based only in the intriger
I get it THe PT_DMG its intriger il make it real and tell u what i done

EDIT: ok i figured out how to make it real and dmg tell u back in moment if it work

Edit:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has buff Protection Touch 1 ) Equal to True
    • Actions
      • Set PT_Unit = (Attacked unit)
      • Set PT_Tu = (Attacking unit)
      • Set PT_Dmg = (Damage taken)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Unit - Set life of PT_Unit to ((Life of PT_Unit) + PT_Dmg)
          • Game - Display to (All players) the text: ((String(PT_Dmg)) + damage taken)
          • Game - Display to (All players) the text: ((String((Damage taken))) + damage healed)
        • Else - Actions
aint working and counts are 0.000 and 0.000
 
Level 8
Joined
Aug 21, 2009
Messages
333
uhm ... im not scupid i get what u mean i scrolled evry well function theres nothing on damage tipe based only in the intriger
I get it THe PT_DMG its intriger il make it real and tell u what i done

EDIT: ok i figured out how to make it real and dmg tell u back in moment if it work

Edit:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has buff Protection Touch 1 ) Equal to True
    • Actions
      • Set PT_Unit = (Attacked unit)
      • Set PT_Tu = (Attacking unit)
      • Set PT_Dmg = (Damage taken)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Unit - Set life of PT_Unit to ((Life of PT_Unit) + PT_Dmg)
          • Game - Display to (All players) the text: ((String(PT_Dmg)) + damage taken)
          • Game - Display to (All players) the text: ((String((Damage taken))) + damage healed)
        • Else - Actions
aint working and counts are 0.000 and 0.000

Did you do what I said in the third post? "Unit is Attacked" can't be used as the Event. "Unit Takes Damage" must be used.
 
Level 7
Joined
May 18, 2010
Messages
264
ok man im stomping my ba@lz. only on specific unit
no generic eavent i need som SCY FY jass script for that ... oh christ
 
Level 8
Joined
Aug 21, 2009
Messages
333
ok man im stomping my ba@lz. only on specific unit
no generic eavent i need som SCY FY jass script for that ... oh christ

lol, no you don't... as I said before.

You will have to write an additional trigger that:
  1. checks for that ability to be cast; then...
  2. turns of this trigger
  3. adds the "(Casting Unit) takes Damage" to the events of DevineShield03
DevineShield03 should start out with nothing in its Events section.

This way, the first time your unit casts the spell, the specific unit event for your unit is added to the trigger. (of course, this assumes that this is the only unit that will be casting this spell)
 
Level 7
Joined
May 18, 2010
Messages
264
ok i dont know if i tiped but in not that pro aniway FUCK THIS im going to own some PRO dota players... i cant figure it out yet from all 10000mil combinations of things... mby later th on try aniway
 
Level 7
Joined
May 18, 2010
Messages
264
lol, well if you change your mind... I can write the three triggers out for you.

just lost ... oh well still had a positive score :)
that would be like epic if u did... i cut down all trigers and going fresh
  • Protection Touch1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cfff0e68cProtection Touch|r
    • Actions
      • Set PT_cast = (Triggering unit)
      • Set PT_tar = (Target unit of ability being cast)
      • Trigger - Turn on Protection Touch2 <gen>
  • Protection Touch2
    • Events
      • Unit - YOUR MAGIC works here?
    • Conditions
      • ((YOUR MAGIC) has buff Protection Touch ) Equal to True
    • Actions
i .. im just tired... going to sleep... clear my head

EDIT: i dont know i just need the protection for a unit so it hp dosent go down or it had 4 hp and hit by 6 so it dosent die..thx infront off i go
 
Level 8
Joined
Aug 21, 2009
Messages
333
Before you try these triggers, there are two abilities you should look into:
Defend (item) - not sure if you can block melee attacks with this one, but you can definitely make it block spells and ranged attacks.
Hardened Skin - not sure if it will block spells, but it will block melee and ranged damage.

The only problem with these spells is that I can't think of a good way to track the amount of damage or times they block damage.

If those are no help, try the following:

Devine_Count should be an Integer.
Devine_Hp should be an be a Real.

  • Divine Shield
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cfff0e68cProtection Touch|r
    • Actions
      • Set Devine_Unit = (Triggering unit)
      • Set Devine_Hp = (Life of Devine_Unit)
      • Set Devine_Count = (Devine_Count + (((Level of Protection touch for Devine_Unit) x 17) + 50))
      • Game - Display to (All players) the text: (String(Devine_Count))
      • Trigger - Turn on DivineShield03 <gen>
  • DivineShield01
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cfff0e68cProtection Touch|r
    • Actions
      • Trigger - Add to DivineShield03 <gen> the event (Unit - (Casting unit) Takes damage)
      • Trigger - Turn off (this trigger)
  • DivineShield03
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Devine_Count) Greater than 0
        • Then - Actions
          • Unit - Set life of Devine_Unit to (Devine_Hp)
          • Set Devine_Count = (Devine_Count - 1)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) the text: Turning off
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The unit takes damage event fires before damage is actually dealt. As such any rehealing has to be done after a delay. To stop the unit dieing, you will need tobuff its hitpoints until the end of the delay as multiple further attacks may occur between now and then.

Timer with 0 delay is valid and enough of a delay but is not instant.
 
Level 8
Joined
Aug 21, 2009
Messages
333
The unit takes damage event fires before damage is actually dealt. As such any rehealing has to be done after a delay. To stop the unit dieing, you will need tobuff its hitpoints until the end of the delay as multiple further attacks may occur between now and then.

Timer with 0 delay is valid and enough of a delay but is not instant.

Thank you! I always wondered about that. So...
What this means is that you can just add the event damage to the current health of the unit without using that delay and that will keep the unit from dying... so try this...

  • Divine Shield
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cfff0e68cProtection Touch|r
    • Actions
      • Set Devine_Unit = (Triggering unit)
      • Set Devine_Count = (Devine_Count + (((Level of Protection touch for Devine_Unit) x 17) + 50))
      • Game - Display to (All players) the text: (String(Devine_Count))
      • Trigger - Turn on DivineShield03 <gen>
  • DivineShield01
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cfff0e68cProtection Touch|r
    • Actions
      • Trigger - Add to DivineShield03 <gen> the event (Unit - (Casting unit) Takes damage)
      • Trigger - Turn off (this trigger)
  • DivineShield03
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Devine_Count) Greater than 0
        • Then - Actions
          • Unit - Set life of Devine_Unit to (Current life of Devine_Unit + (Damage Taken))
          • Set Devine_Count = (Devine_Count - 1)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) the text: Turning off
 
Level 7
Joined
May 18, 2010
Messages
264
nah im ok il stick with my original one
... i writed it in a sec ... th on the item and magic shield thingy
helpt
 
Level 8
Joined
Aug 21, 2009
Messages
333
No, as a unit can not exceede its maximum health and as such if the event damage + current health exceedes its maximum health it will not get healed properly.

yes, that is a good point :) but it will still prevent the unit from dying, unless the unit is being hurt his full health... I suppose that putting a delay in and then setting the health back to the original amount wouldn't be a bad idea as long as the unit is still given enough health before the damage so that it also doesn't die.
 
Level 7
Joined
May 18, 2010
Messages
264
No, as a unit can not exceede its maximum health and as such if the event damage + current health exceedes its maximum health it will not get healed properly.

on that i make a condition if that what u writed >then its max hp then set the unit to max hp
EDIT: i cant send u my map would take me long to upload + i got no idea how> y i can split it out ... but just post a trigger
  • Protection Touch1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to |cfff0e68cProtection Touch|r
    • Actions
      • Set PT_cast = (Triggering unit)
      • Set PT_tar = (Target unit of ability being cast)
      • Set PT_Hp = (Integer((Life of PT_tar)))
      • Set PT_Time = (((Level of |cfff0e68cProtection Touch|r for PT_cast) x 60) + 100)
      • Trigger - Turn on Protection Touch2 <gen>
      • Unit - Add |cfff0e68cProtection|r to PT_tar
      • Unit - Create 1 DummyUnit for (Owner of PT_cast) at (Position of PT_cast) facing (Random point in (Playable map area))
      • Set pt_dummy = (Last created unit)
      • Unit - Order pt_dummy to Human Priest - Inner Fire PT_tar
      • Unit - Add a 1.00 second Generic expiration timer to pt_dummy
  • Protection Touch2
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PT_Time Greater than or equal to 1
        • Then - Actions
          • Unit - Set life of PT_tar to (Real(PT_Hp))
          • Set PT_Time = (PT_Time - 1)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Unit - Remove |cfff0e68cProtection|r from PT_tar
          • Unit - Remove Anti-magic Shell buff from PT_tar
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Show me, test map.

Too simple for a test map:
  • Example ofc
    • Events
      • Unit - Unit Takes damage (with damage detection system)
    • Conditions
      • ((Triggering unit) has buff Shallow Grave) Equal to True
      • (Damage taken) Greater than or equal to (Life of (Triggering unit))
    • Actions
      • Unit - Set life of (Triggering unit) to Damage taken + 0.50
Of course,it would require damage detection system.
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
The "Set Life" Action is done AFTER the unit has taken the damage
If the unit has taken damage of 70 and his current HP is 50, wouldn't that unit dies first, after the trigger is fired ?
His HP should be -20 and the trigger just started to fire up ?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
"Unit takes damage" event fires before the damage is taken,so this works,i've tested it.
That is what I said ages ago...
The unit takes damage event fires before damage is actually dealt
.

To prevent death you have to fully reheal the unit, add a large HP bonus ability and then keep track of its actual hitpoints over the delay period via triggering. A delay of 0 seconds is sub frame so you should not notice anything.
 
Status
Not open for further replies.
Top