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

Hashtables

Status
Not open for further replies.
Level 6
Joined
Jan 16, 2017
Messages
107
I was trying to create some system that would enable and disable abilities based on training specific unit.
For some reason when i disable some spell then it should change the value in hashtables and make it not work, but the unit still casts the spell.
Note: I am begginer at using hashtables so i am not sure if i setted up the hashtable correctly
  • Hashtable
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set SpellBookHashtable = (Last created hashtable)
      • For each (Integer B) from 1 to 8, do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 48, do (Actions)
            • Loop - Actions
              • Hashtable - Save True as (Integer A) of (Integer B) in SpellBookHashtable
  • EnableDisable
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Spell Book
    • Actions
      • Player - Make (Unit-type of (Trained unit)) Unavailable for training/construction by (Owner of (Triggering unit))
      • -------- Disable --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Defend
            • Then - Actions
              • Hashtable - Save False as 1 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Defend Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Heal
            • Then - Actions
              • Hashtable - Save False as 2 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Heal Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Inner Fire
            • Then - Actions
              • Hashtable - Save False as 3 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Inner Fire Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Dispel Magic
            • Then - Actions
              • Hashtable - Save False as 4 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Dispel Magic Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Invisibility
            • Then - Actions
              • Hashtable - Save False as 5 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Invisibility Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Polymorph
            • Then - Actions
              • Hashtable - Save False as 6 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Polymorph Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Slow
            • Then - Actions
              • Hashtable - Save False as 7 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Slow Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Spell Steal
            • Then - Actions
              • Hashtable - Save False as 8 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Spell Steal Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Cloud
            • Then - Actions
              • Hashtable - Save False as 9 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Cloud Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Disable Aerial Shackles
            • Then - Actions
              • Hashtable - Save False as 10 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Enable Aerial Shackles Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
        • Else - Actions
      • -------- Enable --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Defend
            • Then - Actions
              • Hashtable - Save True as 1 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Defend Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Heal
            • Then - Actions
              • Hashtable - Save True as 2 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Heal Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Inner Fire
            • Then - Actions
              • Hashtable - Save True as 3 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Inner Fire Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Dispel Magic
            • Then - Actions
              • Hashtable - Save True as 4 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Dispel Magic Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Invisibility
            • Then - Actions
              • Hashtable - Save True as 5 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Invisibility Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Polymorph
            • Then - Actions
              • Hashtable - Save True as 6 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Polymorph Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Slow
            • Then - Actions
              • Hashtable - Save True as 7 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Slow Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Spell Steal
            • Then - Actions
              • Hashtable - Save True as 8 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Spell Steal Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Cloud
            • Then - Actions
              • Hashtable - Save True as 9 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Cloud Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Enable Aerial Shackles
            • Then - Actions
              • Hashtable - Save True as 10 of (Player number of (Owner of (Triggering unit))) in SpellBookHashtable
              • Player - Make Disable Aerial Shackles Available for training/construction by (Owner of (Triggering unit))
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
        • Else - Actions
  • Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) is A Hero) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (1 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Defend
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (2 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Heal
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (3 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Inner Fire
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (4 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Dispel Magic
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (5 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Invisibility
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (6 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Polymorph
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (7 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Slow
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (8 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Spell Steal
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (9 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Cloud
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (10 is stored as a Boolean of (Custom value of (Casting unit)) in SpellBookHashtable) Equal to False
              • (Ability being cast) Equal to Aerial Shackles
            • Then - Actions
              • Unit - Remove (Ability being cast) from (Casting unit)
              • Skip remaining actions
            • Else - Actions
        • Else - Actions
 
Level 39
Joined
Feb 27, 2007
Messages
4,990
In your third trigger you are checking booleans stored under “Custom Value of (Casting Unit)” but from your second trigger you are saving them under Player numbers. I think you need to change all your references in trigger 3 to be “Player number of (Owner of (Triggering Unit))”.
 
Level 6
Joined
Jan 16, 2017
Messages
107
In your third trigger you are checking booleans stored under “Custom Value of (Casting Unit)” but from your second trigger you are saving them under Player numbers. I think you need to change all your references in trigger 3 to be “Player number of (Owner of (Triggering Unit))”.
Every unit has custom value based on who created the unit so when the unit changes owner then the trigger still works on the unit (Which is important in my map).
Also the units are controlled by AI.
 
Status
Not open for further replies.
Top