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

[Trigger] Question about hashtables

Status
Not open for further replies.
I followed a certain tutorial on here and can't seem to get this working, could anyone help explain what I am doing wrong? Apparently I am able to save unique ID's of units and load them back again so I was trying to save the damage of every/any unit however it's only adding one value and loading it to display text...

[trigger=]
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Hashtable - Create a hashtable
Set BT_Table = (Last created hashtable)
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Unit - Create 1 Peasant for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
[/trigger]

[trigger=]
Events
Unit - A unit enters (Playable map area)
Conditions
Actions
Set aunit = (Triggering unit)
Hashtable - Save Handle Of(Triggering unit) as 0 of (Key aunit) in BT_Table
Hashtable - Save 0.00 as 1 of (Key aunit) in BT_Table
[/trigger]

[trigger=]
Events
Game - GDD_Event becomes Equal to 0.00
Conditions
Actions
Hashtable - Save ((Load 1 of (Key aunit) from BT_Table) + GDD_Damage) as 1 of (Key aunit) in BT_Table
Game - Display to (All players) the text: (Name of GDD_DamageSource)
Game - Display to (All players) the text: (String((Load 1 of (Key aunit) from BT_Table)))

[/trigger]
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Well, I am not exactly sure what your triggers supposed to do, so I will try to explain how hashtable works.Look picture below.

Hashtable - save SOMETHING as INTEGER1 of INTEGER2 in HASHTABLE

something, value you want to store
integer1, the little box you want to store something inside
integer2, the big box which contains little boxes
hashtable,


For example if you do this, you are saving the number "25.00" to the footman's ID.(Every unit in the game has a different unique key/ID value)

[trigger=]
Events
Unit - A unit enters (Playable map area)
Conditions
Actions
Set aunit = (Triggering unit)
Hashtable - Save 25.00 as 1 of (Key aunit) in BT_Table
[/trigger]

Then you can load value "25.00" from unit.

[trigger=]
Events
Game - GDD_Event becomes Equal to 0.00
Conditions
Actions
Game - Display to (All players) the text: (String((Load 1 of (GDD_DamageSource) from BT_Table)))

[/trigger]
 

Attachments

  • prohash.JPG
    prohash.JPG
    22.4 KB · Views: 121
Is it unique for every new unit and how do I increase it/set it to GDD_Damage?

It's a remake of an aggro/threat system just because there isn't any GUI ones.

Edit: How did you get GDD_Damagesource in there? There is no spot for any variables in hashtable stuff except for the table and handles...


It's still only working for one unit/all units add to one value... I even used unit groups this time, so can you only use unit groups with hashtables in order to make them of any use?
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
I just realized you can't use variables there, too much pain.

I hope I didn't get you wrong, this tracks how much damage a unit deal.

  • Enter Map Set Damage
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Hashtable - Save 0.00 as 1 of (Key (Triggering unit)) in BT_Table
  • Increase Damage
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • Hashtable - Save (GDD_Damage + (Load 1 of (Key (Damage source)) from BT_Table)) as 1 of (Key (Damage source)) in BT_Table
      • Game - Display to (All players) the text: (String((Load 1 of (Key (Damage source)) from BT_Table)))
 
I just realized you can't use variables there, too much pain.

I hope I didn't get you wrong, this tracks how much damage a unit deal.

  • Enter Map Set Damage
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Hashtable - Save 0.00 as 1 of (Key (Triggering unit)) in BT_Table
  • Increase Damage
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • Hashtable - Save (GDD_Damage + (Load 1 of (Key (Damage source)) from BT_Table)) as 1 of (Key (Damage source)) in BT_Table
      • Game - Display to (All players) the text: (String((Load 1 of (Key (Damage source)) from BT_Table)))

That doesn't work, have you tested it?
 

sentrywiz

S

sentrywiz

2ugm2z9.jpg


"A picture is worth a thousand words"

Sorry for being a smartass, but I believe this is your problem.
 
Status
Not open for further replies.
Top