- Joined
- Feb 4, 2009
- Messages
- 1,314
How to save a unitgroup in a hashtable and how to add more units to it?
I'm interested in leakless ways to do this so I do NOT want to destroy a unitgroup every time I add a unit
And if there is an alternative to saving units in a hashtable when making something like the following I'd like to know it as well:
pick all units in group blah
set i = id of picked unit
damage all units in (load group with key 0 and i)
edit:
tested a few things myself and it seems like saving a unitgroup to a hashtable does not save the unitgroup but a reference to the group instead
for example:
so hashtable unitgroups have to be destroyed and can't be recycled most likely :/
I'm interested in leakless ways to do this so I do NOT want to destroy a unitgroup every time I add a unit
And if there is an alternative to saving units in a hashtable when making something like the following I'd like to know it as well:
pick all units in group blah
set i = id of picked unit
damage all units in (load group with key 0 and i)
edit:
tested a few things myself and it seems like saving a unitgroup to a hashtable does not save the unitgroup but a reference to the group instead
for example:
-
Ini
-
Events
- Map initialization
- Conditions
-
Actions
- Hashtable - Create a hashtable
- Set g = (Units of type Footman)
- Hashtable - Save Handle Ofg as 0 of 0 in (Last created hashtable)
- Game - Display to (All players) for 20.00 seconds the text: (String((Number of units in (Load 0 of 0 in (Last created hashtable)))))
- Unit Group - Remove all units from g
- Game - Display to (All players) for 20.00 seconds the text: (String((Number of units in (Load 0 of 0 in (Last created hashtable)))))
- Unit Group - Add Footman 0005 <gen> to (Load 0 of 0 in (Last created hashtable))
- Game - Display to (All players) for 20.00 seconds the text: (String((Number of units in (Load 0 of 0 in (Last created hashtable)))))
- Custom script: call DestroyGroup(udg_g)
- Game - Display to (All players) for 20.00 seconds the text: (String((Number of units in (Load 0 of 0 in (Last created hashtable)))))
-
Events
so hashtable unitgroups have to be destroyed and can't be recycled most likely :/