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

Healing Over Time

Status
Not open for further replies.
Level 3
Joined
Nov 9, 2013
Messages
23
Hey guys, I'm not totally sure if I should be asking this here, or in the Triggers & Scripts, as I'd much rather prefer to stay away from complicated triggers as I have seen online, but if there's no choice, then I suppose that is that. Basically, I'd like to know how to make a healing over time ability that I can choose its' healing intervals. Rejuvenation, as far as I can tell, heals once every three seconds, I want it to heal every .25-1 second. Is there any spell in the game that I can use to help me? If not, I could certainly use help in figuring out how I'd go about making such a thing. Any help regarding this matter would be deeply appreciated.
 
Last edited:
Level 3
Joined
Nov 9, 2013
Messages
23
Rejuvenation heals once a second.

This 2 Systems help alot when creating intervaled/delayed Actions in GUI.
[GUI-friendly] Timer System
GUI Spell System v1.8.0.0

Huh, I recall it back in the day healing once every three seconds vividly, yet I see no evidence that supports the reasoning, I stand enlightened. Thanks for the links, but I'm not sure how helpful they'll be, my mind is already starting to unravel itself the more I read them. If it requires any kind of JASS knowledge, I'm sure I'll be quite incapable of using it to my advantage.

@Chaosium I can't fathom how I'd use a periodic trigger to create a spell, perhaps I'm simply just not creative enough. I can't seem to draw a picture in my mind as to what a Hashtable is. I'll have to see if I can figure that out.
 
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
Here is some simple pseudocode to wrap your head around:
Code:
Event - Unit starts healing spell
Actions - Register Spell
  Register target = target of spell
  Register interval = 0.25s
  Register healingAmount = 20 * intelligence of caster
  Register time = 0
  Register maxTime = 2 * level of spell for caster
Code:
Event - Every 0.03 sec of game time
Actions - Loop through all registers
  maxTime = maxTime + 0.03
  Time = Time + 0.03
  If Interval >= Time
    Heal target for HealingAmount
    Time = Time - Interval
  If Time >= maxTime
   De-register

This is just the basic idea of what it would look like.
You will have to puff it a bit, add indexing, customize a bit, if you look around for any over-time spells, any DoTs, healings, follow-effects, etc. you will most probably find this same pseudocode in one variant or another.

PS: To simplify it, Pseudocode = idea

Hope this helps!
-Ned
 
Level 3
Joined
Nov 9, 2013
Messages
23
@Tasyen That's what I was thinking, it likely playing World of Warcraft for many years that made me think rejuvenation also worked that way in Warcraft III. But I remember it so vividly... it's so strange. Ah, either way, it matters little. Fact is, it's one second, as you said. I might just end up using it as it's kinda close to what I want.

@nedio95 Indexing? I'm not quite sure I understand. Index normally refers to recording data, right? I'm not quite sure I understand how this applies. Also, can I do this in the GUI?
 
Level 20
Joined
Aug 29, 2012
Messages
826
Basically, the idea would be to have one trigger store the unit receiving the heal somewhere, like in a group, and another trigger that heals every unit in that group every X seconds.

In this case, a hashtable would be useful to store values in a unit, like the amount healed and the duration of the HoT.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
@Chaosium please, stop offering hashtables. Hashtables should not be used for such simple spell/effect/system.
They have both advantages & disadvantages, which I am not going to go into now. The advantages are more present when working with a heavy/complicated system which requires an infinite(-ish) 2D or 3D array(-ish object storage) (Hold on, can you store arrays in Hashtable? as the whole array[z] on x of y ?)
For this you have an infinite(-ish) array for Spell Casts and a very finite and limited array of object types that you want to store (caster, target, time, heal amount)
This spell would be like Register[XXXX][5], for a hashtable you are looking at something more like Register[XXXXXXXX][YYYYYYYYYY]

@Dymetreus What you'd use indexing for is to "remember" your spell casts and keep your spell unbreakable.
Each time your healing spell is cast, you will store a reference to this particular cast.

All in all, indexing would look like:
  • Set Index = 0
  • Set MyNumber[Index] = 0
  • Set Index = Index +1
  • Set MyNumber[Index] = 1
  • Set Index = Index +1
  • Set MyNumber[Index] = 2
  • Set Index = Index +1
  • Set MyNumber[Index] = 77
MyNumber[0] is 0
MyNumber[1] is 1
MyNumber[2] is 2
MyNumber[3] is 77


If you do:
Register Spell Cast
Heal Spell is cast
Register
Start Healing


And then loop:
Healing
Every X sec of game time
Heal Target for Z
If heal is over stop Healing

Imagine what happens if a second cast is done while the previous is active?
The previous one would be overwritten. Or else, depending what you've done.

BUT if you do:
Register Spell Cast
Heal Spell is cast
Register
Spell as [index+1]
Start Healing

and:
Healing
Every X sec of game time
loop through all registered indexes
Heal Target[loop index] for HealAmount[loop index]
If spell time[loop index] is over de-register spell[loop index]
If all healings are over stop Healing

Each spell cast is registered under index and thus does not interfere with other spell casts.

This all may sound very complicated, but it is not actually. You could imagine it as:
Your company has 1 car(spell casts) and 2 employees(units).
Employee 1 uses the car between 7 to 15, employee 2 uses the car 9 to 17.
Employee 2 hijacks the car at 9 so at that time Employee 1 says "No car = no work"

Solution 1 (MUI, this is war3 code term, will explain later):
Get 2 cars.
Each employee would have their own car.
So now we have:
C1 & C2 for E1 & E2

Solution 2 (SUMI):
Rent a car for each employee that needs a car.
So, now you have no cars, until somebody needs one.
Also, employees may use multiple cars at the same time (maybe they need to pick a group of clients from the airport?)


MUI = Multi Unit Instance = The spell works for each unit. The spell may break if the same unit uses it multiple times. If you upload a spell to the resource section, minimal standard is MUI. (May differ depending on purpose and effect, e.g weather effect systems, you need it to work only for the game)
SUMI - Same Unit Multi Instance = The spell works as many times as it is cast by as many units as can cast it. Practically unbreakable. (Software & Hardware limitations though ;) )


Ok, I hope this all makes sense.
Regards
-Ned
 
Level 20
Joined
Aug 29, 2012
Messages
826
@nedio95 No offense, but what you suggest seems much more complicated than using a simple hashtable.

I mean, there is literally a well-made tutorial on the Hive about them and one of the examples is about creating a healing over time effect (Hashtables and MUI)

It requires two triggers and at best 2 variables while being perfectly MUI. No arrays needed.

Anyway, it's up to OP to decide what solution best suits their needs, having multiple choices is always useful.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
@Chaosium This tutorial has nothing to do with healing over time, the creator just took healing over time as it is an easy to understand and explain system to represent MUI and hashtables principles.
It also does not cover low-level details which are the main reason why hashtables are unsuitable for simple systems.

As I said, Hashtables have both disadvantages and advantages that should be considered.
  • - They are slower, both set-up and look-up time take longer than arrays, usually negligible for practical purposes, very noticeable when spammed often on big maps e.g. multiple over-time effects with short periods (0.01-0.03)
  • - They are limited, max of 256 hashtables - Use it for every spell and you are buggered
  • + They have faster if you need to look-up a single handle
  • + They are infinite-ish (array size is 2^13 for <1.28 (about 8,000) and 2^15 for 1.29 (about 32,000), hash size is 2^31 (or was it 2^32?) )
There are more, but, all in all, it very much depends on what you are doing with it, not only for this particular system, but also for the whole map.
When you take those in consideration, using a hashtable for simple things is silly, especially when you do not need the functionality that they provide over arrays.

One more thing, if you register the spell cast with the unit handle under a hashtable with bad design you'll turn your spell into MUI instead of SUMI, which I'd prefer for a Heal over Time.

Regards
-Ned
 
Status
Not open for further replies.
Top