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

Spell request

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
Once he learned the spell, start an Event - Periodic Event that triggers once per 10 second (until the end of the game)
Each interval, save the variable of that unit's HP like this:

  • Set CurrentHP = (Life of *YourUnit*)
This is to trigger upon hit:

  • Unit - Set life of *YourUnit* to ((Life of *YourUnit) + CurrentHP)
*YourUnit* is a Unit-variable
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
That won't work since if he gets damaged just after the trigger saves it'll turn his life into the one in 1 second ago... You have to use it with a chain of variables to track the HP change for up to 10 seconds and only take the last value but don't lose the-let's say- 5th second's value since in 5 seconds it may come handy
So use
for each integer (i) from 1 to 9 do
Set CurrentHP = CurrentHP[i+1]
then after the loop:
Set CurrentHP[10] = (Life of *YourUnit*)
and do it every second

sry for not making it properly but I'm tired so I'm gone sleep see you
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If you use logic, you'll understand my trigger, related to the thread's problem :)
It relates the HP with 10 seconds ago, meaning that it doesn't take into account of 9 seconds ago or 11 seconds after that, it is exact 10 second per interval

Situation:
You learned the spell at time (15:40)
You have 500/500 HP at a time of (23:44) (but the HP reset is saved at 23:40, because you learned it at xx:40, which means it increases 10 seconds per interval (per save variable))
You received damage of 200 at 23:41
The spell is triggered
Your HP will be reset to the last saved variable which is the 23:40

If you receive damage at 23:39, your HP will be reset to the time of 23:30, glad you understand concept of logic and time-inteval

You doesn't need to save it every once a second, WHY ?
- It is because this spell works for the last 10 seconds, not for the last 1 second.
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
The but the last didN't mean in the LAST 10 SECONDS but 10 SECONDS AGO-means if you take damage at 13:44 your hp has to be reset to 13:34 but for that you have to track the hp every second. If the system tracked the hp and you could ask for "Unit - get hp 10 seconds ago" it would work good, but you need to track back ALWAYS the one 10 seconds ago, NOT the last 10 second interval (saved a 13:40 and hit at 13:44 means 4 seconds ago...)

I didn't take into account the one 11 seconds ago but you need 9 seconds ago at 13:43 because it will reset to that value after a second...
 
Status
Not open for further replies.
Top