• 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.

Hash tables

Status
Not open for further replies.
Hey guys, I'm working with triggers for about a month and things are going well but I still don't understand hash tables that well. I googled a tutrial on hive and tried do use it for a custom spell. This is what my spell looks like:
  • Black hole spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Black hole
    • Actions
      • Hashtable - Create a hashtable
      • Set VoidHash = (Last created hashtable)
      • Unit - Create 1 Black Hole for (Owner of (Casting unit)) at (Position of (Target unit of ability being cast)) facing Default building facing degrees
      • Unit - Order (Last created unit) to Neutral - Devour (Target unit of ability being cast)
      • Hashtable - Save 5.00 as 0 of (Key (Last created unit)) in VoidHash
  • Black hole loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in VoidGroup and do (Actions)
        • Loop - Actions
          • Set Void_remaining = (Load 0 of (Key (Picked unit)) from VoidHash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Void_remaining Greater than 0
            • Then - Actions
              • Hashtable - Save (Void_remaining - 1) as 0 of (Key (Picked unit)) in VoidHash
            • Else - Actions
              • Unit Group - Remove (Picked unit) from VoidGroup
              • Unit - Remove (Picked unit) from the game
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in VoidHash
For some reason, the black hole doesn't disappear. Any help please?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
  • Hashtable - Create a hashtable
  • Set VoidHash = (Last created hashtable)
should not be in the trigger, it should be in trigger with event Map Initialization, because you can only have 255(or 256) hashtables and you cant destroy them when you create them

the real problem is that the units are never add to the unit group so you pick 0 units
 
  • Hashtable - Create a hashtable
  • Set VoidHash = (Last created hashtable)
should not be in the trigger, it should be in trigger with event Map Initialization, because you can only have 255(or 256) hashtables and you cant destroy them when you create them

the real problem is that the units are never add to the unit group so you pick 0 units

wow im slipping lol how did i miss that. thats what i get for doing GUI for only a month lol

and by check the model i mean try to place the black hole in the world editor and see if it shows up or is a green and black checkered box or nothing
 
Got it! thanks. but uhm... I've just found another problem; when I cast the ability, the black hole is removed almost instantly. WHY?
---------------------------------------
and by check the model i mean try to place the black hole in the world editor and see if it shows up or is a green and black checkered box or nothing
Yes I'm sure its there. as I said before: 'the black hole doesn't disappear'. It must actually BE there so that I can see that it doesn't disappear. :ogre_icwydt:
 
Last edited:
  • Varibles
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VoidHash = (Last created hashtable)
  • Black hole spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Black hole
    • Actions
      • Unit - Create 1 Black Hole for (Owner of (Casting unit)) at (Position of (Target unit of ability being cast)) facing Default building facing degrees
      • Unit - Order (Last created unit) to Neutral - Devour (Target unit of ability being cast)
      • Hashtable - Save 10.00 as 0 of (Key (Last created unit)) in VoidHash
      • Unit Group - Add (Last created unit) to VoidGroup
  • Black hole loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in VoidGroup and do (Actions)
        • Loop - Actions
          • Set Void_remaining = (Load 0 of (Key (Picked unit)) from VoidHash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Void_remaining Greater than 0
            • Then - Actions
              • Hashtable - Save (Void_remaining - 1) as 0 of (Key (Picked unit)) in VoidHash
            • Else - Actions
              • Unit Group - Remove (Picked unit) from VoidGroup
              • Unit - Remove (Picked unit) from the game
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in VoidHash
 
its because of these change them to this

basically in the first one u r setting it to -1 so it only lasts 2 seconds instead of 5

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • Void_remaining Greater than 0
  • Then - Actions
  • Hashtable - Save Void_remaining as 0 of (Key (Picked unit)) in VoidHash
  • Else - Actions
  • Unit Group - Remove (Picked unit) from VoidGroup
  • Unit - Remove (Picked unit) from the game
change to this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • Void_remaining Greater than 0
  • Then - Actions
  • Set Void_remaining = (Void_remaining - 1)
  • Hashtable - Save (Void_remaining - 1) as 0 of (Key (Picked unit)) in VoidHash
  • Else - Actions
  • Unit Group - Remove (Picked unit) from VoidGroup
  • Unit - Remove (Picked unit) from the game
 
sry about tht try this i had a typo in the last one


  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • Void_remaining Greater than 0
  • Then - Actions
  • Set Void_remaining = (Void_remaining - 1)
  • Hashtable - Save Void_remaining as 0 of (Key (Picked unit)) in VoidHash
  • Else - Actions
  • Unit Group - Remove (Picked unit) from VoidGroup
  • Unit - Remove (Picked unit) from the game
 
Status
Not open for further replies.
Top