• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Loading integer from a hashtable problem!

Status
Not open for further replies.
Level 5
Joined
May 20, 2008
Messages
138
So, I'm currently triggering stackable damage over time spells in GUI using hashtables. I'm creating two spells that work in synergy

Lacerate
Instantly deals 200 damage and then deals 100 damage over 15 seconds to a unit. Stacks up to 3 times.


Pulverize
Deals 180 damage and reduces enemy armor by 2. Consumes all charges of Lacerate on the target to determine bonus damage. 120 bonus damage per charge.


This is handled through three triggers:
"Druid Lacerate cast" detects when lacerate is cast and adds a stack of Lacerate to the targetted unit, saved as an integer in a hashtable as Player number of (Owner of Triggering Unit) of Key(Target Unit of Ability Being Cast). The targetted unit is then saved in a unit group to be accessed in the next trigger:

"Druid Lacerate damage" is a preiodic event that picks all units in the unit group and deals damage to them depending on the number of stacks. The number of stacks each player has on the target is loaded from the hashtable and determines the damage dealt. Both these triggers are working exactly as they should.

The "Druid Pulverize cast BROKEN" trigger detects when Pulverize is cast on a target and is supposed to load the number of stacks of Lacerate the casting player has on the targetted unit from the hashtable, similar to the "Druid Lacerate damage" trigger. However, while the "Druid Lacerate damage" correctly loads for example 2 stacks if a player has cast Lacerate on the target 2 times, the "Druid Pulverize cast BROKEN" for some reason loads that there are 0 stacks of Lacerate on the targetted unit, even if the periodic trigger is running at the same time, loading the correct number of stacks both before and after "Druid Pulverize cast BROKEN" fails to load the correct number of stacks! Here is a screenshot to illustrate what I mean:
http://imageshack.us/photo/my-images/42/debuge.jpg/
The "2 stacks of lacerate" message is generated by the periodic trigger "Druid Lacerate damage".
The "0 stacks of lacerate" message is generated by the trigger that fires when Pulverize is cast "Druid Pulverize cast BROKEN".
What this image illustrates is how the periodic damage event detects the number of stacks and fires correctly, while the Pulverize cast, made between the periodic event "ticks", does not.

Here are all my triggers (the first two work perfectly as far as I can tell):

  • Druid Lacerate cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (Druid) Lacerate
    • Actions
      • -------- deal initial damage --------
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing 200.00 damage of attack type Chaos and damage type Normal
      • -------- save the caster --------
      • Set HDRUID_Lacerate_caster[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
      • -------- refresh the lacerate DoT duration --------
      • Hashtable - Save 15 as (Player number of (Owner of (Triggering unit))) of (Key (Target unit of ability being cast)) in HDRUID_Laceratetime_table
      • -------- Add another stack of Lacerate unless the unit already has 3 stacks --------
      • Set GEN_INTEGER_1 = (Load (Player number of (Owner of (Triggering unit))) of (Key (Target unit of ability being cast)) from HDRUID_Laceratestacks_table)
      • Game - Display to (All players) the text: (String(GEN_INTEGER_1))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GEN_INTEGER_1 Less than 3
        • Then - Actions
          • Set GEN_INTEGER_1 = (GEN_INTEGER_1 + 1)
          • Game - Display to (All players) the text: (String(GEN_INTEGER_1))
        • Else - Actions
      • Hashtable - Save GEN_INTEGER_1 as (Player number of (Owner of (Triggering unit))) of (Key (Target unit of ability being cast)) in HDRUID_Laceratestacks_table
      • -------- add debuff effect --------
      • Unit - Add (Druid) Lacerate effect to (Target unit of ability being cast)
      • -------- save the target in a unit group to be loaded in the periodic event trigger --------
      • Unit Group - Add (Target unit of ability being cast) to HDRUID_Lacerate_targets
      • -------- create text --------
      • Floating Text - Create floating text that reads ((String(GEN_INTEGER_1)) + stacks of Lacerate) above (Target unit of ability being cast) with Z offset 0.00, using font size 10.00, color (100.00%, 75.00%, 0.00%), and 0.00%
  • transparency
    • Floating Text - Change (Last created floating text): Disable permanence
    • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
    • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
    • Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
    • Floating Text - Hide (Last created floating text) for (All players)
    • Floating Text - Show (Last created floating text) for (All players matching ((Owner of (Casting unit)) Equal to (Matching player)))

  • Druid Lacerate damage
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Number of units in HDRUID_Lacerate_targets) Greater than 0
    • Actions
      • -------- pick every unit that has been saved as a flame shock target --------
      • Unit Group - Pick every unit in HDRUID_Lacerate_targets and do (Actions)
        • Loop - Actions
          • -------- boolean sätts till att alla spelares DoT är färdig. Om det visar sig att den inte är färdig för någon spelare sätts den till "false". Annars om den behålls som true så kollar triggern det efter, och i
  • såna fall tas enheten i Explshot_targets bort s --------
    • Set HDRUID_Lacerate_finished = True
    • For each (Integer A) from 1 to 10, do (Actions)
      • Loop - Actions
        • Set GEN_INTEGER_1 = (Load (Integer A) of (Key (Picked unit)) from HDRUID_Laceratetime_table)
        • -------- each players flameshock duration has been saved as (key - players number), this goes trhough all the units and checks if the flameshock duration on them is greater than 0 --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • GEN_INTEGER_1 Greater than 0
          • Then - Actions
            • -------- reduce duration for each player --------
            • Set GEN_INTEGER_1 = (GEN_INTEGER_1 - 1)
            • Hashtable - Save GEN_INTEGER_1 as (Integer A) of (Key (Picked unit)) in HDRUID_Laceratetime_table
            • -------- the flameshock duration is not finished --------
            • Set HDRUID_Lacerate_finished = False
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Or - Any (Conditions) are true
                  • Conditions
                    • GEN_INTEGER_1 Equal to 12
                    • GEN_INTEGER_1 Equal to 9
                    • GEN_INTEGER_1 Equal to 6
                    • GEN_INTEGER_1 Equal to 3
                    • GEN_INTEGER_1 Equal to 0
              • Then - Actions
                • -------- load the number of stacks and heal --------
                • Set GEN_INTEGER_2 = (Load (Integer A) of (Key (Picked unit)) from HDRUID_Laceratestacks_table)
                • Unit - Cause HDRUID_Lacerate_caster[(Integer A)] to damage (Picked unit), dealing (20.00 x (Real(GEN_INTEGER_2))) damage of attack type Spells and damage type Fire
                • Game - Display to (All players) the text: ((String(GEN_INTEGER_2)) + stacks of lacerate)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • GEN_INTEGER_1 Equal to 0
                  • Then - Actions
                    • -------- set stacks to 0, heal is finsiehd --------
                    • Hashtable - Save 0 as (Integer A) of (Key (Picked unit)) in HDRUID_Laceratestacks_table
                    • -------- final damage, remove fire effect --------
                    • Floating Text - Create floating text that reads Lacerate fades above (Picked unit) with Z offset -50.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                    • Floating Text - Change (Last created floating text): Disable permanence
                    • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                    • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
                    • Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
                    • Floating Text - Hide (Last created floating text) for (All players)
                    • Floating Text - Show (Last created floating text) for (All players matching ((Player number of (Matching player)) Equal to (Integer A)))
                  • Else - Actions
              • Else - Actions
          • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • HDRUID_Lacerate_finished Equal to True
      • Then - Actions
        • Unit - Remove (Druid) Lacerate effect from (Picked unit)
        • Unit Group - Remove (Picked unit) from HDRUID_Lacerate_targets
      • Else - Actions
  • Druid Pulverize cast BROKEN
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (Druid) Pulverize
    • Actions
      • -------- Load the number of Lacerate stacks the owner of the Pulverize caster has on the target --------
      • Set GEN_INTEGER_1 = (Load (Player number of (Owner of (Triggering unit))) of (Key (Target unit of ability being cast)) from HDRUID_Laceratestacks_table)
      • Game - Display to (All players) the text: ((String(GEN_INTEGER_1)) + stacks of lacerate PULVERIZE)
      • -------- Deal extra damage if more stacks than 0 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GEN_INTEGER_1 Greater than 0
        • Then - Actions
          • -------- If there are stacks of Lacerate on the target, remove all stacks and deal extra damage --------
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (180.00 + (120.00 x (Real(GEN_INTEGER_1)))) damage of attack type Chaos and damage type Normal
          • Hashtable - Save 0 as (Player number of (Owner of (Triggering unit))) of (Key (Target unit of ability being cast)) in HDRUID_Laceratestacks_table
          • -------- Show --------
          • Floating Text - Create floating text that reads Lacerate fades above (Target unit of ability being cast) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
          • Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
          • Floating Text - Hide (Last created floating text) for (All players)
          • Floating Text - Show (Last created floating text) for (All players matching ((Owner of (Triggering unit)) Equal to (Matching player)))
        • Else - Actions
          • -------- if there are no stacks of Lacerate on the target, deal normal damage --------
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 180.00 damage of attack type Chaos and damage type Normal
      • Set GEN_TEMP_POINT_single = (Position of (Target unit of ability being cast))
      • Unit - Create 1 Dummy Caster for (Owner of (Triggering unit)) at GEN_TEMP_POINT_single facing Default building facing degrees
      • Unit - Hide (Last created unit)
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Unit - Add (Druid) Faerie Fire dummy to (Last created unit)
      • Unit - Order (Last created unit) to Night Elf Druid Of The Talon - Faerie Fire (Target unit of ability being cast)
      • Custom script: call RemoveLocation(udg_GEN_TEMP_POINT_single)
 
- use integers instead of Player number...
- 1 hashtable is enough for this, you just have to assign unique childkeys for it, including the counter...
samples:
of course you must save it after this trigger in the 'IF' part...
  • Set GEN_INTEGER_1 = (Load 999) of (Key (Target unit of ability being cast)) from HDRUID_Laceratestacks_table)
assign the stacks as 1,2,3 or any (100, 101, 102) so that it shoudlnt collide with each other...

- lastly, use integer to save the Key (Target unit of ability being cast) for better use...
 
Level 5
Joined
May 20, 2008
Messages
138
The only thing I can think of is if the last trigger has the wrong arguments for loading.

Try displaying a message to display "Key(Target unit of ability being cast)". If it shows up as 0, then "Target unit of ability being cast" is null.

Thanks for your reply!
How, more specifically, would I display what the "Key(target unit of ability being cast)" in the hashtable "HDRUID_Laceratestacks_table" is as a ingame Text message?

Edit:
- use integers instead of Player number...

Isn't a player number an integer? :eek:

- 1 hashtable is enough for this, you just have to assign unique childkeys for it, including the counter...
samples:
of course you must save it after this trigger in the 'IF' part...
  • Set GEN_INTEGER_1 = (Load 999) of (Key (Target unit of ability being cast)) from HDRUID_Laceratestacks_table)
assign the stacks as 1,2,3 or any (100, 101, 102) so that it shoudlnt collide with each other...

- lastly, use integer to save the Key (Target unit of ability being cast) for better use...

I'm not sure I follow you. The way I do it now I save "Integer number of stacks belonging to a certain player" to "player number of owner of stacks" of Key("Unit that has the stacks on it") in "stackhashtable".

As an example, this enables Player 1 to have 2 stacks x 120 damage deal damage at game time 1, 4, 7, 10 and so on while player Player 2 independently has 3 stacks x 120 damage dealing damage at game time 2, 5, 8, 11 and so on.

I'm not sure I understand your way of doing it very well. Would it enable me to do the same thing or could you elaborate? The damage dealing works, it's just that the last trigger gives me the stack number "null" (from what I can tell) even though it loads the stack number in almost exactly the same manner as the periodic trigger.
 
Last edited by a moderator:
Level 17
Joined
Jan 21, 2010
Messages
2,111
why dont you use the ability?
when the lacerate learned, add the "Stack" ability to the hero
then when lacerarte casted, increase the level of the "Stack " ability by 1
the tool tip of the "stack" ability must be:
Current Stack: X
where X determine the number of stack
 
Isn't a player number an integer? :eek:
true but in jass it's GetPlayerId() and GetOwningPlayer(), which calls 2 natives, so
better to directly use 0, 1, 2 etc...

I really cant elaborate it very well coz I dont have my WE at the moment, if
you want I can give you a test map tonight on how to stack things just like
what I said...
 
Here's what I mean...uses 1 hashtables & unique id's...


  • Stackable DoT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Custom script: set udg_KeyID = GetHandleId(udg_Target)
      • Set Checker = (Load 999 of KeyID from Hash)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Checker Less than 3
        • Then - Actions
          • Set Stackdam = (Load 2 of KeyID from Hash)
          • Hashtable - Save Handle OfCaster as 1000 of KeyID in Hash
          • Hashtable - Save 15.00 as 1 of KeyID in Hash
          • Hashtable - Save (Stackdam + 3.00) as 2 of KeyID in Hash
          • Set Stackdam = (Load 2 of KeyID from Hash)
          • Hashtable - Save Stackdam as 3 of KeyID in Hash
          • Set Index = (Index + 1)
          • Hashtable - Save (Checker + 1) as 999 of KeyID in Hash
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target is in Grp) Equal to False
            • Then - Actions
              • Unit Group - Add Target to Grp
            • Else - Actions
        • Else - Actions
      • Trigger - Turn on Looper <gen>
  • Looper
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Grp and do (Actions)
        • Loop - Actions
          • Set Target = (Picked unit)
          • Custom script: set udg_KeyID = GetHandleId(udg_Target)
          • Set Caster = (Load 1000 of KeyID in Hash)
          • Set Duration = (Load 1 of KeyID from Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target is alive) Equal to True
              • Duration Greater than 0.00
            • Then - Actions
              • Game - Display to (All players) the text: (Duration + (String(Duration)))
              • Hashtable - Save (Duration - 1.00) as 1 of KeyID in Hash
              • Set TotalDamage = (Load 3 of KeyID from Hash)
              • Unit - Cause Caster to damage Target, dealing TotalDamage damage of attack type Chaos and damage type Normal
              • Floating Text - Create floating text that reads (String(TotalDamage)) above Target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
            • Else - Actions
              • Hashtable - Clear all child hashtables of child KeyID in Hash
              • Set Index = (Index - 1)
              • Unit Group - Remove Target from Grp
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Level 5
Joined
May 20, 2008
Messages
138
why dont you use the ability?
when the lacerate learned, add the "Stack" ability to the hero
then when lacerarte casted, increase the level of the "Stack " ability by 1
the tool tip of the "stack" ability must be:
Current Stack: X
where X determine the number of stack

With this method, a hero can't have a different number of stacks on different units. This is how it works with my method; Hero casts Lacerate 3 times on Enemyunit1 and 2 times on Enemyunit2. Enemyunit1 then has 3 stacks and Enemyunit2 has 2 stacks, and are damaged accordingly (and the damage is credited to the Hero).

You would do an integer -> string conversion to display the Key(Target unit of Ability Being Cast).
  • Game - Display to (All Players) the text: String(Key(Target unit of ability being cast))

I added that as a text message, and strengely enough it managed to successfully load the same unit ID (or whatever the number that was printed is :p) in both triggers, and now all the triggers suddenly work! I wonder if that somehow fixed it or if the compilation of the triggers simply bugged out yesterday? ;o

Here's what I mean...uses 1 hashtables & unique id's...


  • Stackable DoT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Custom script: set udg_KeyID = GetHandleId(udg_Target)
      • Set Checker = (Load 999 of KeyID from Hash)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Checker Less than 3
        • Then - Actions
          • Set Stackdam = (Load 2 of KeyID from Hash)
          • Hashtable - Save Handle OfCaster as 1000 of KeyID in Hash
          • Hashtable - Save 15.00 as 1 of KeyID in Hash
          • Hashtable - Save (Stackdam + 3.00) as 2 of KeyID in Hash
          • Set Stackdam = (Load 2 of KeyID from Hash)
          • Hashtable - Save Stackdam as 3 of KeyID in Hash
          • Set Index = (Index + 1)
          • Hashtable - Save (Checker + 1) as 999 of KeyID in Hash
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target is in Grp) Equal to False
            • Then - Actions
              • Unit Group - Add Target to Grp
            • Else - Actions
        • Else - Actions
      • Trigger - Turn on Looper <gen>
  • Looper
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Grp and do (Actions)
        • Loop - Actions
          • Set Target = (Picked unit)
          • Custom script: set udg_KeyID = GetHandleId(udg_Target)
          • Set Caster = (Load 1000 of KeyID in Hash)
          • Set Duration = (Load 1 of KeyID from Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target is alive) Equal to True
              • Duration Greater than 0.00
            • Then - Actions
              • Game - Display to (All players) the text: (Duration + (String(Duration)))
              • Hashtable - Save (Duration - 1.00) as 1 of KeyID in Hash
              • Set TotalDamage = (Load 3 of KeyID from Hash)
              • Unit - Cause Caster to damage Target, dealing TotalDamage damage of attack type Chaos and damage type Normal
              • Floating Text - Create floating text that reads (String(TotalDamage)) above Target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
            • Else - Actions
              • Hashtable - Clear all child hashtables of child KeyID in Hash
              • Set Index = (Index - 1)
              • Unit Group - Remove Target from Grp
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions

Wow thanks! I'll have to examine that trigger very closely as I don't understand that much of it currently (I'm quite new to hashtables and their inner workings. If I didn't put trigger comments on my own hashtable triggers I wouldn't understand wtf was going on if I was away from the editor a month or two :p). Your method looks very efficient compared to my triggers. Are there any other benefits except it using less lines of code and only one hashtable instead of two? (Are hashtables memory intensive?)
 
Level 5
Joined
May 20, 2008
Messages
138
using less lines of codes makes reading things easy, less size/calls/lag...
I can say that 1 hashtable is enough for 1 map although you can create
a maximum of 255, which is I doubt that people will create even 3...

Really? Then I have too many already. :/ My map currently has five different damage/healing over time spells (and I need to add more) with their own unique durations and damage intervals, that use their own hashtable (see below).

But from what I can understand from your trigger is that it can't have two different players' unique sets of stacks on the same target. Say if Player 1's hero puts a couple of stacks on the target and then Player 2's hero does the same, won't Player 1's stacks be completely overwritten by Player 2's stacks then? The spell has to be MPI and MUI.

(It saves 15 (the duration) as 1 of KeyID in Hashtable, but then won't GetHandleId(udg_Target) give the same value to KeyID the next time the ability is cast on the same target, overwriting the current duration saved as 1 of KeyID, to 15 again?)
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
KeyID are unique, that's what makes them MUI. If you use the same ability, affecting the same value (1) of the same KeyID, yes, they will get overwriten, but you can save Time (15 seconds) as (Player Number of Owner of Casting Unit) of KeyID in Hashtable.

If you want it to be reaaaaaaaaaally MUI, you can save 15 as (Key(CastingUnit)) of (Key(TargetUnit)) in Hashtable.
 
the trigger I posted stacks the timer as well, so ofc it will be overwritten, if you
dont want that then use a dummy unit for your timer and DoT except your
counter/checker...

creating a dummy unit uses unique keyID's, add the dummy unit to the group
then loop all values there...

(Key(CastingUnit)) and PlayerNUmber is not 'always 'unique, coz what if the
caster will cast again to the same unit?...
 
Level 5
Joined
May 20, 2008
Messages
138
KeyID are unique, that's what makes them MUI. If you use the same ability, affecting the same value (1) of the same KeyID, yes, they will get overwriten, but you can save Time (15 seconds) as (Player Number of Owner of Casting Unit) of KeyID in Hashtable.

This is what I have been doing for both the duration and the number of stacks and it works fine ;D The issue is how to get the same functionality with mckill2009's trigger.

mckill2009 said:
the trigger I posted stacks the timer as well, so ofc it will be overwritten, if you
dont want that then use a dummy unit for your timer and DoT except your
counter/checker...

creating a dummy unit uses unique keyID's, add the dummy unit to the group
then loop all values there...

(Key(CastingUnit)) and PlayerNUmber is not 'always 'unique, coz what if the
caster will cast again to the same unit?...

Hmm it's not entirely clear to me what you mean here.

Here is an example of how the ability works:

Player 1's hero casts Stacks on Enemyunit1. Enemyunit1 gets one Stack belonging to Player 1 that deals damage to it over 15 seconds.

2 seconds later, Player 2's hero casts Stacks on Enemyunit1 as well. Enemyunit1 gets one Stack belonging to Player 2 that deals damage to it over 15 seconds.
Player 1's stack on Enemyunit1 is NOT affected by this; it's remaining duration is now 13 seconds.

3 seconds after that, Player 2's hero casts Stacks on Enemyunit1 again. The duration of Player 2's Stacks on Enemyunit1 is refreshed to 15 seconds again and it now has TWO Stacks belonging to Player 2, that deal double damage.
Player 1's stack on Enemyunit1 is NOT affected by this; it's remaining duration is now 10 seconds.

Essentially this works like damage over time spells like Flameshock do in World of Warcraft, but with a stacking component.
 
Here, timer is different on every cast, uses dummy unit for unique ID's...


  • Stackable DoT 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Custom script: set udg_KeyIDTarget = GetHandleId(udg_Target)
      • Set Checker = (Load 999 of KeyIDTarget from Hash)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Checker Less than 3
        • Then - Actions
          • Hashtable - Save (Checker + 1) as 999 of KeyIDTarget in Hash
          • -------- saves all keyID's for dummy unit --------
          • Set TempLoc = (Position of Caster)
          • Unit - Create 1 Chicken for (Triggering player) at TempLoc facing Default building facing degrees
          • Set Dummy = (Last created unit)
          • Custom script: call RemoveLocation(udg_TempLoc)
          • Custom script: set udg_KeyID = GetHandleId(udg_Dummy)
          • Hashtable - Save 15.00 as 1 of KeyID in Hash
          • Hashtable - Save Handle OfCaster as 2 of KeyID in Hash
          • Hashtable - Save Handle OfTarget as 3 of KeyID in Hash
          • Hashtable - Save 3.00 as 4 of KeyID in Hash
          • Set Index = (Index + 1)
          • Unit Group - Add Dummy to Grp
          • Trigger - Turn on Looper 2 <gen>
          • Unit - Hide Dummy
        • Else - Actions
  • Looper 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Grp and do (Actions)
        • Loop - Actions
          • Custom script: set udg_KeyID = GetHandleId(GetEnumUnit())
          • Set Duration = (Load 1 of KeyID from Hash)
          • Set Caster = (Load 2 of KeyID in Hash)
          • Set Target = (Load 3 of KeyID in Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target is alive) Equal to True
              • Duration Greater than 0.00
            • Then - Actions
              • Game - Display to (All players) the text: (Duration + (String(Duration)))
              • Hashtable - Save (Duration - 1.00) as 1 of KeyID in Hash
              • Set Stackdam = (Load 4 of KeyID from Hash)
              • Unit - Cause Caster to damage Target, dealing Stackdam damage of attack type Chaos and damage type Normal
              • Floating Text - Create floating text that reads (String(Stackdam)) above Target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
            • Else - Actions
              • Custom script: set udg_KeyIDTarget = GetHandleId(udg_Target)
              • Set Checker = (Load 999 of KeyIDTarget from Hash)
              • Hashtable - Save (Checker - 1) as 999 of KeyIDTarget in Hash
              • Hashtable - Clear all child hashtables of child KeyID in Hash
              • Set Index = (Index - 1)
              • Unit Group - Remove (Picked unit) from Grp
              • Unit - Kill (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 

Attachments

  • Staked DoT.w3x
    16.9 KB · Views: 63
Status
Not open for further replies.
Top