@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