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

[Trigger] Hashtable Problems!

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2012
Messages
158
Hello!
I'm not very good at hashtables still.
The triggers below are the bits in in my trigger that doesn't work. The problem is that the values aren't stored into the hashtable.
In my example shown below the value is just set to Manifestations_Index.
  • Test 3 Initial
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set MarksOfBarrowDen_Hash = (Last created hashtable)
      • For each (Integer Manifestations_Index) from 1 to 4, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))) and do (Actions)
            • Loop - Actions
              • Set MarksOfBarrowDen_Target = (Picked unit)
              • Custom script: set udg_MarksOfBarrowDen_Handle = GetHandleId(udg_MarksOfBarrowDen_Target)
              • Set MarksOfBarrowDen_Stack[Manifestations_Index] = Manifestations_Index
              • Hashtable - Save MarksOfBarrowDen_Stack[Manifestations_Index] as Manifestations_Index of MarksOfBarrowDen_Handle in MarksOfBarrowDen_Hash
  • Test 3
    • Events
      • Player - Player 1 (Red) types a chat message containing !!! as An exact match
    • Conditions
    • Actions
      • For each (Integer Manifestations_Index) from 1 to 4, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))) and do (Actions)
            • Loop - Actions
              • Set MarksOfBarrowDen_Target = (Picked unit)
              • Custom script: set udg_MarksOfBarrowDen_Handle = GetHandleId(udg_MarksOfBarrowDen_Target)
              • Set MarksOfBarrowDen_Stack[Manifestations_Index] = (Key (Load Manifestations_Index of MarksOfBarrowDen_Handle in MarksOfBarrowDen_Hash))
              • Game - Display to (All players) the text: (String(MarksOfBarrowDen_Stack[Manifestations_Index]))
When I try to load them, the integer's value is 0.
 
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
I do not see what can go wrong here except the handles and unit group look weird (to me)
This trigger does not make much sense, maybe if you explain what it does, probably we can come up with better solution or at least see flaws in the design which may lead to the problem.

  • Test 3 Initial
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set MarksOfBarrowDen_Hash = (Last created hashtable)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set MarksOfBarrowDen_Target = (Picked unit)
          • Custom script: set udg_MarksOfBarrowDen_Handle = GetHandleId(udg_MarksOfBarrowDen_Target)
          • For each (Integer Manifestations_Index) from 1 to 4, do (Actions)
            • Loop - Actions
              • -------- NEXT 2 LINES--------
              • Set MarksOfBarrowDen_Stack[Manifestations_Index] = Manifestations_Index //Why ?
              • Hashtable - Save MarksOfBarrowDen_Stack[Manifestations_Index] as Manifestations_Index of MarksOfBarrowDen_Handle in MarksOfBarrowDen_Hash
              • -------- TURN INTO--------
              • Hashtable - Save Manifestations_Index as Manifestations_Index of MarksOfBarrowDen_Handle in MarksOfBarrowDen_Hash
  • Set TempGroup = Units in region matching conditions
  • Unit Group - pick every unit in group and do actions
    • Actions
  • call DestroyGroup(udg_TempGroup)
3rd Stick a debug message in the first trigger to see if teh hashtable is being populated at all (fail conditions ?)
 
Last edited:
Level 6
Joined
Oct 31, 2014
Messages
170
Hashtable - Save MarksOfBarrowDen_Stack[Manifestations_Index] as Manifestations_Index of MarksOfBarrowDen_Handle in MarksOfBarrowDen_Hash

doesn't it save it 4 times at the same place as you have a loop action?

I don't know but this double loop action sounds weird to me.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Nah, the index changes from 1 to 4 so it saves like this:

< Index >
1 - 2 - 3 - 4
===========
X - X - X - X =
X - X - X - X =
X - X - X - X = ^
X - X - X - X = UnitHandle
X - X - X - X = v
X - X - X - X =
X - X - X - X =
X - X - X - X =

And yes, the double loop is a bit weird.
 
Last edited:
Level 7
Joined
Jul 9, 2012
Messages
158
Thank you for the responses!
It's a boss encounter where the room is split into 4 areas, thus the indexing from 1 to 4 :). Each area in the room will give the heroes a stacking damaging debuff every now and then. The heroes have to move out of the specific area before the area's debuff stacks too much.

The triggers I posted didn't give much sense because they're only a part of the original trigger - but i guessed that posting the whole trigger would only cause confusion.
The trigger was supposed to store the stacks for each hero in the area, they were in.

I hope I didn't confuse further :D
Sorry to ask, but what double loop?
 
Level 6
Joined
Oct 31, 2014
Messages
170
Well I don't see why you have this : "Pick every unit in map area matching:" if this only concern one hero. You should just save the handle of your hero somewhere in the first hashtable and call the value when you need it. I always save my main hero as 1 on 1 in my ashtable.

Events
Player - Player 1 (Red) types a chat message containing !!! as An exact match
Conditions
Actions
For each (Integer Manifestations_Index) from 1 to 4, do (Actions)
Loop - Actions
Custom script: set bj_wantDestroyGroup = true
Set MarksOfBarrowDen_Target = (your unit handle like 1 on 1)
Custom script: set udg_MarksOfBarrowDen_Handle = GetHandleId(udg_MarksOfBarrowDen_Target)
Set MarksOfBarrowDen_Stack[Manifestations_Index] = (Key (Load Manifestations_Index of MarksOfBarrowDen_Handle in MarksOfBarrowDen_Hash))
Game - Display to (All players) the text: (String(MarksOfBarrowDen_Stack[Manifestations_Index]))
 
Level 6
Joined
Oct 31, 2014
Messages
170
Index
1 - 2 - 3 - 4
===========
X - X - X - X =
X - X - X - X =
X - X - X - X =
X - X - X - X = UnitHandle
X - X - X - X =
X - X - X - X =
X - X - X - X =
X - X - X - X =

That's very pretty ^^" (what the hell is that?)
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Sorry to ask, but what double loop?
Double loop is a loop inside a loop as:
  • Unit Group - Pick Units in UnitGroup
    • Loop
      • For Integer 1 to 5
        • Loop
Index
1 - 2 - 3 - 4
===========
X - X - X - X =
X - X - X - X =
X - X - X - X =
X - X - X - X = UnitHandle
X - X - X - X =
X - X - X - X =
X - X - X - X =
X - X - X - X =

That's very pretty ^^" (what the hell is that?)

It is supposed to be a visual representation of a hashtable where "X" is a cell, "Index" & "UnitHandle" are handles...
Apparantly failed...
 
Level 6
Joined
Oct 31, 2014
Messages
170
Then just save the handle of each players heros like

player one's hero : 1on1
player two hero: 1on2
players 3 ect ...

and just copy and paste your trigger for each handle ^^ it should be working.
 
Status
Not open for further replies.
Top