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

[Solved] Help with hashtables

Status
Not open for further replies.
What I'm trying to achieve is create a trigger that reorders units that are grouped in a battalion after one of them dies (currently we assume that the commander dies last).

The battalion looks like this:
5 3 1 2 4
10 8 6 7 9

Where number 1 is the commander unit.
The following values are stored in hash tables:

Units in the group
0 of unit handle in battalions = commander unit handle
1 of unit handle in battalions = unit number in group

The commander
3 of commander unit handle in unitproperties = number of units in group
2-n of commander unit handle in battalions = unit handle of units in group

With n the number of units in the group.
Two hashtables have been used which is specific to my map and needs no optimizing to one hashtable.

The trigger looks like this:

  • -------- Set Variables --------
  • Set TemporaryHandle1 = (Load 0 of (Key (Triggering unit)) in Battalions)
  • Set TemporaryHandle2 = (Load (Load 3 of (Key TemporaryHandle1) from UnitProperties) of (Key TemporaryHandle1) in Battalions)
  • Set TemporaryUnit1 = (Load (Load 3 of (Key TemporaryHandle1) from UnitProperties) of (Key TemporaryHandle1) in Battalions)
  • -------- Save Variables --------
  • Hashtable - Save Handle OfTemporaryUnit1 as (Load 1 of (Key (Triggering unit)) from Battalions) of (Key TemporaryHandle1) in Battalions
  • Hashtable - Save (Load 1 of (Key (Triggering unit)) from Battalions) as 1 of (Key TemporaryHandle2) in Battalions
  • Hashtable - Save ((Load 3 of (Key TemporaryHandle1) from UnitProperties) - 1) as 3 of (Key TemporaryHandle1) in UnitProperties
The idea is that:
-------- Set Variables --------
* TemporaryHandle1 becomes the handle of the commander unit
* TemporaryHandle2 becomes the handle of the unit with the highest group number (so when the first unit dies this is unit number 10, when the next one dies 9, etc.)
* TemporaryUnit1 is the same as TemporaryHandle2, used once later to use 'Save handle of...'
-------- Save Variables --------
* Here TemporaryUnit1 is saved to its new position in the commanders part of the battalion hashtable (for instance if unit number 3 dies in a group of 10 units, unit number 10 takes the place unit number 3)
* Then the new number is assigned to the unit itself in his part of the battalion hashtable
* The last action reduces the number of units in the group by one, which is stored in unitproperies for the commander unit

I can't seem to figure out whats wrong, however the following is happening:
- When the first unit dies, its place is taken correctly like this:
number 2 dies
5 3 1 - 4
10 8 6 7 9
number 10 takes is place
5 3 1 10 4
- 8 6 7 9
- The second time, number 9 does no longer take the position of the next dying unit
- Later on, (Load 3 of (Key TemporaryHandle1) from UnitProperties) gets stuck on 8 (it does go down to 9 on first death and 8 on second death)

If more information is required please post it, and if you know the solution, let me know!
Thanks!
 

Attachments

  • LOTR - Trashing Middle-earth (2).w3x
    1.8 MB · Views: 52
Status
Not open for further replies.
Top