Backtrack like spell help

naughty

New Member
Reaction score
12
I really don't know why this is happening but lets say we have this trigger:
Trigger:
  • Untitled Trigger 001 Copy
    • Events
      • Unit - Footman 0000 <gen> Takes damage
    • Conditions
    • Actions
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))

It all works fine if the unit is not at max full health. If the unit have max full health it doesn't work the first time. After that it works just fine.
I also tried like this:

Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - Footman 0000 <gen> Takes damage
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Triggering unit)) Equal to (Max life of (Triggering unit))
        • Then - Actions
          • Unit - Set life of (Triggering unit) to (Max life of (Triggering unit))
        • Else - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))

It still wont work. I'm really curious how to make it work every time even though the unit is on max hit points.
 

Ashlebede

New Member
Reaction score
43
Save the unit's health as custom value. That would "save" an integer "inside" the unit, and you can retrieve it later.

Trigger:
  • //
    • Events
      • {Whatever makes the other trigger start...}
    • Conditions
    • Actions
      • Unit - Set Custom Value of (Triggering Unit) to (Life of (Triggering Unit))
      • Trigger - Add to {Other Trigger} the event (Unit - (Triggering Unit) Takes damage)


For the damage detection trigger :

Trigger:
  • //
    • Events
      • {Those are added in the other trigger...}
    • Conditions
    • Actions
      • Unit - Set life of (Triggering Unit) to ((Triggering Unit) Custom value)


(Handwritten)
 

naughty

New Member
Reaction score
12
Save the unit's health as custom value. That would "save" an integer "inside" the unit, and you can retrieve it later.

Trigger:
  • //
    • Events
      • <b>{Whatever makes the other trigger start...}</b>
    • Conditions
    • Actions
      • Unit - Set Custom Value of (Triggering Unit) to (Life of (Triggering Unit))
      • Trigger - Add to {Other Trigger} the event (Unit - (Triggering Unit) Takes damage)


For the damage detection trigger :

Trigger:
  • //
    • Events
      • {Those are added in the other trigger...}
    • Conditions
    • Actions
      • Unit - Set life of (Triggering Unit) to ((Triggering Unit) Custom value)


(Handwritten)

And what would i make the first trigger to start with? And it doesn't matter if i store that integer value as a custom value of a unit it still doesn't work. The problem in my trigger is that it doesn't occur when the unit is on max hit points.
Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - Footman 0000 &lt;gen&gt; Takes damage
    • Conditions
    • Actions
      • Set u = (Triggering unit)
      • Set r = (Damage taken)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of u) Equal to (Max life of u)
        • Then - Actions
          • Wait 0.00 seconds
          • Unit - Set life of u to ((Life of u) + r)
        • Else - Actions
          • Unit - Set life of u to ((Life of u) + r)

Like this it happens. But if the unit has more damage than the max life of the unit the unit will die which i dislike.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
it doesnt work because the event fires before the damage is dealt.

example:
Footman got 100 hitpoints.
Footman is attacked by grunt.
your trigger is running.
your trigger set footman life (100) = footman life (100) + damage dealt (12)
footman life is maxed at 100 and thus its life stays 100
12 damage is being dealt to footman
life of footman is 88

are you using the custom value of your unit right now? if not i could give you an easy solution to solve this. if you need the custom value for something else i would suggest hashtables which might not be that easy to understand for beginners.
 

naughty

New Member
Reaction score
12
I figured out that it fires before the damage is dealt myself. Thats why i put that wait there and it worked. I think i need that custom value, but still, can't i save the custom value before i change it and after i'm done with it to change it back it was? If that doesn't work i think i can handle hashtables if you explain it to me right, i'm not that much of a beginner though (in GUI) :p
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
waits are bad to use in triggers which run frequently and need data to be stored.

just imagine 2 footmans are being attacked same time, the damage taken for the first one of them will be overwritten by the second.

the idea behind using the custom value is following, when taking damage, the custom value of the triggering unit is set to the damage taken.
after the wait you set the life of the triggering unit to be its life + its custom value.
(triggering unit is one of the very few things which will not be overwritten by other triggers running)
this way you could use the wait.

using a hashtable you can save unlimited data and attach it to unit handles.
a handle is a unique number given to any object ingame.
this way you can save all the damage taken appropriate to the handle id of your footmans and thus heal the right amount of damage.
(same as using custom value but a little more complicated.)
 

Goober4473

TH.net Regular
Reaction score
7
Here's what I did for a spell:

In the trigger where I would have put in the reset life:
Trigger:
  • Countdown Timer - Start FlickerTimer as a One-shot timer that will expire in 0.00 seconds
    • Set FlickerUnit = (Triggering unit)
    • Set FlickerDamageDealt = (Damage taken)


FlickerUnit is a unit variable. FlickerDamageDealt is a real.

And then:
Trigger:
  • Fix Life
    • Events
      • Time - FlickerTimer expires
    • Conditions
    • Actions
      • Unit - Set life of FlickerUnit to ((Life of FlickerUnit) + FlickerDamageDealt)
      • Set FlickerUnit = No unit


This has worked fine for me.
 

naughty

New Member
Reaction score
12
Here's what I did for a spell:

In the trigger where I would have put in the reset life:
Trigger:
  • Countdown Timer - Start FlickerTimer as a One-shot timer that will expire in 0.00 seconds
    • Set FlickerUnit = (Triggering unit)
    • Set FlickerDamageDealt = (Damage taken)


FlickerUnit is a unit variable. FlickerDamageDealt is a real.

And then:
Trigger:
  • Fix Life
    • Events
      • Time - FlickerTimer expires
    • Conditions
    • Actions
      • Unit - Set life of FlickerUnit to ((Life of FlickerUnit) + FlickerDamageDealt)
      • Set FlickerUnit = No unit


This has worked fine for me.

This really works fine but still lets say
Footman has 100 max hit points.
The damaging unit has 200 damage.
Footman dies then the trigger runs.

I don't want the unit to die since i have spells that deal lots of damage. How do i fix that? :)
 

naughty

New Member
Reaction score
12
waits are bad to use in triggers which run frequently and need data to be stored.

just imagine 2 footmans are being attacked same time, the damage taken for the first one of them will be overwritten by the second.

the idea behind using the custom value is following, when taking damage, the custom value of the triggering unit is set to the damage taken.
after the wait you set the life of the triggering unit to be its life + its custom value.
(triggering unit is one of the very few things which will not be overwritten by other triggers running)
this way you could use the wait.

using a hashtable you can save unlimited data and attach it to unit handles.
a handle is a unique number given to any object ingame.
this way you can save all the damage taken appropriate to the handle id of your footmans and thus heal the right amount of damage.
(same as using custom value but a little more complicated.)

And again i'm using waits. That means that the unit can die. Thats the biggest problem here actually. I don't want the unit to die receiving no matter what damage.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
you have to add bonus life (ability) to your units and removing it again after the healing. this way they wont die.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top