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

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
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
  • 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
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
here u go its fixed and im an idiot lol. u made a simple error u saved a real instead of an integer. that way when it loaded the integer it was loading 0 because u didnt convert it to integer. so instead i just saved it as an integer and works perfectly. also can i use the black hole model ?
 

Attachments

  • Black hole.w3x
    20.1 KB · Views: 43
Status
Not open for further replies.
Top