HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Units hanging around after removal?

07-21-2010, 05:17 PM#1
rakshassa
I have one trigger which replaces units of one type with different units (trigger 1)
Then, later, I have a trigger which checks of a user owns more than 5 units of a given type.

For some reason, (trigger 1) is not actually removnig the units I replace "in memory" because (trigger 2) is finding all the removed units and all the newly created ones.

TRIGGER 1:
Trigger:
Actions
-------- Randomize them --------
Collapse For each (Integer tmpInt) from 0 to 4, do (Actions)
Collapse Loop - Actions
Set tempUnitGroup2 = (Units of type mobsAvatar[tmpInt])
Collapse Unit Group - Pick every unit in tempUnitGroup2 and do (Actions)
Collapse Loop - Actions
Set tmpUnit = (Picked unit)
-------- Store starting information --------
Set tmpPoint = (Position of tmpUnit)
Set tmpPlayer = (Owner of tmpUnit)
Set tempi = (Custom value of tmpUnit)
Unit - Remove tmpUnit from the game
-------- Replace the Unit --------
Set tmpInt2 = (Random integer number between 0 and 3)
Unit - Create 1 mobsAvatar[tmpInt2] for tmpPlayer at tmpPoint facing tmpPoint
Set tmpUnit = (Last created unit)
Selection - Add tmpUnit to selection
-------- Set new unit with the pre-existing values --------
Unit - Set the custom value of tmpUnit to tempi
Trigger - Run Cripple specific Avatar <gen> (checking conditions)
Custom script: call DestroyGroup (udg_tempUnitGroup2)


Trigger 2:
Trigger:
Actions
Set tempBool = False
Collapse For each (Integer tmpInt) from 0 to 3, do (Actions)
Collapse Loop - Actions
Set tempUnitGroup2 = (Units owned by CurrentPlayer matching (((Unit-type of (Matching unit)) Equal to mobsAvatar[tmpInt]) and (((Matching unit) is alive) Equal to True)))
Game - Display to players_playing the text: ((String(mobsAvatar[tmpInt])) + (String((Number of units in tempUnitGroup2))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in tempUnitGroup2) Greater than or equal to 6
Collapse Then - Actions
Player - Set CurrentPlayer Current lumber to ((CurrentPlayer Current lumber) + 1)
Game - Display to players_playing the text: ((Name of CurrentPlayer) + gains 1 Achievement Point for the 'Bingo' Achievement.)
Set tempBool = True
Collapse Else - Actions
Do nothing
Custom script: call DestroyGroup (udg_tempUnitGroup2)
-------- Play sound if we got an achievement --------
If (tempBool Equal to True) then do (Sound - Play SorceressPissed6 <gen>) else do (Do nothing)
07-21-2010, 08:30 PM#2
Tot
Trigger:
Set tmpPoint = (Position of tmpUnit)
leaks a location

Trigger:
Unit - Remove tmpUnit from the game
add a debug line after it, which shows the unit's name; if it was removed properly the name should be either a default string or equal to an empty string

you could also try to replace this
Trigger:
Set tempUnitGroup2 = (Units owned by CurrentPlayer matching (((Unit-type of (Matching unit)) Equal to mobsAvatar[tmpInt]) and (((Matching unit) is alive) Equal to True)))
group enumeration with another one, enumerating all units on the map, checking if their owner is equal to CurrentPlayer and the upper conditions
cause i vaguely remember something special about unit-enumeration with
Trigger:
Units owned by <player>
07-21-2010, 09:49 PM#3
Anitarf
Quote:
Originally Posted by Tot
group enumeration with another one, enumerating all units on the map, checking if their owner is equal to CurrentPlayer and the upper conditions
cause i vaguely remember something special about unit-enumeration with
Trigger:
Units owned by <player>
Aside from it enumerating locusted units, I can not remember anything special about it. Definitely not something that would warrant your roundabout solution.