• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Hashtable Not Working

Status
Not open for further replies.
Level 10
Joined
Jun 10, 2007
Messages
554
Hi, so I have this spell that I want to create a set of 7 dummy units in an area which damage and cast spells on enemies inside of them every 0.50 seconds so I decided to use a Hashtable and it's not working and I can't figure out why.

  • Grove of the Wicked Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Grove of the Wicked (Despoiler)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in GroveoftheWickedGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn on Grove of the Wicked FX <gen>
        • Else - Actions
      • Set Location = (Target point of ability being cast)
      • Unit - Create 1 Grove of the Wicked (Despoiler) for (Owner of (Triggering unit)) at Location facing (Random real number between 1.00 and 360.00) degrees
      • Unit Group - Add (Last created unit) to GroveoftheWickedGroup
      • Hashtable - Save Handle OfLocation as 0 of (Key location) in GroveoftheWicked
      • Set Integer = (Level of Grove of the Wicked (Despoiler) for (Triggering unit))
      • Hashtable - Save (Level of Grove of the Wicked (Despoiler) for (Triggering unit)) as 1 of (Key level) in GroveoftheWicked
      • Hashtable - Save 10.00 as 2 of (Key duration) in GroveoftheWicked
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Location2 = (Location offset by 100.00 towards (60.00 x (Real((Integer A)))) degrees)
          • Unit - Create 1 Grove of the Wicked (Despoiler) for (Owner of (Triggering unit)) at Location2 facing (Random real number between 1.00 and 360.00) degrees
          • Custom script: call RemoveLocation (udg_Location2)
      • Set Integer = 0
      • Custom script: call RemoveLocation (udg_Location)
There's the casting trigger.

  • Grove of the Wicked FX
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in GroveoftheWickedGroup and do (Actions)
        • Loop - Actions
          • Set Location = (Load 0 of (Key location) in GroveoftheWicked)
          • Set Integer = (Load 1 of (Key level) from GroveoftheWicked)
          • Set GroveoftheWickedTime = (Load 2 of (Key duration) from GroveoftheWicked)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GroveoftheWickedTime Greater than 0.00
            • Then - Actions
              • Set Group = (Units within 250.00 of Location matching (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True))
              • For each (Integer A) from 1 to (Number of units in Group), do (Actions)
                • Loop - Actions
                  • Set Unit = (Random unit from Group)
                  • Unit - Cause (Picked unit) to damage Unit, dealing (6.00 x (Real(Integer))) damage of attack type Spells and damage type Normal
                  • Unit - Create 1 Dummy for (Owner of (Picked unit)) at Location facing Default building facing degrees
                  • Unit - Add Wicked Vines to (Last created unit)
                  • Unit - Set level of Wicked Vines for (Last created unit) to Integer
                  • Unit - Order (Last created unit) to Neutral Fire Lord - Soul Burn Unit
                  • Unit Group - Remove Unit from Group
                  • Hashtable - Save (GroveoftheWickedTime - 0.50) as 2 of (Key (Picked unit)) in GroveoftheWicked
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in GroveoftheWicked
              • Unit Group - Remove (Picked unit) from GroveoftheWickedGroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in GroveoftheWickedGroup) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
And there's the loop.

When I cast it it creates the 7 dummy units but nothing else happens; they don't do damage or create dummies to cast spells on units in the radius.

Can anybody find out what's wrong? +rep would be involved and thanks in advance!
 
You add last created unit to the unit group, so why would you use "triggering unit" as the key?

Because I want to preserve the level of the ability for the caster so I can apply damage and such based on it.

Also I don't get why people use

"save something as 0 of key something else in..."

Why don't you use:

save handle of location as location of...

Much easier to follow what's going on.

I mostly used strings there just in case it worked because my previous attempts did not.


Problem averted! Turns out I had the wrong idea of how keys worked in the first place. But +rep anyway for trying, guys.
 
For me hashtables work neither.

I initialized them with

  • Hashtable - Create a hashtable
  • Set hashtable = (Last created hashtable)
a trigger contains this actions:
  • Hashtable - Save (Integer A) as 1 of (Key (Picked unit)) in hashtable
(Integer A) is never zero, while the following action in ordering event trigger writes 0.

  • Game - Display to (All players) the text: (String((Key (Load 1 of (Key (Ordered unit)) in hashtable))))
It works correctly if I use custom values however.
 
@Mechanical Man - Try adding these in each of your triggers.

This one should go in the save trigger.
Custom script: call BJDebugMsg(I2S(GetHandleId(GetEnumUnit())))

And in the load trigger.
Custom script: call BJDebugMsg(I2S(GetHandleId(GetOrderedUnit())))

Tell me if each integers that are displayed are the same.
 
Status
Not open for further replies.
Back
Top