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,463
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,463
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,463
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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      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