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

Units don't get removed as expected

Status
Not open for further replies.
Level 7
Joined
Jul 1, 2008
Messages
1,025
  • Arcane Nexus Dies
    • Events
      • Unit - Arcane Nexus 0429 <gen> Dies
    • Conditions
    • Actions
      • Set Crystals01 = (Units in Crystal Destroy 01 <gen> owned by Player 6 (Orange))
      • Unit Group - Pick every unit in Crystals01 and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_Crystals01)
It is supposed to remove all units in unit group Crystals01 when the Arcane Nexus unit dies, however nothing is happening at all.
 
Level 19
Joined
Apr 10, 2010
Messages
2,789
Just a tip, you can make your trigger to this:
  • Arcane Nexus Dies
    • Events
      • Unit - Arcane Nexus 0429 <gen> Dies
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Crystal Destroy 01 <gen> owned by Player 6 (Orange)) and do Unit - Remove (Picked unit) from the game
Something like that for efficiency.
Not sure though.
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
Ahh its because the units I want removing have the locust ability! I did not realize this ability made units un-selectable via triggers?

These Crystal units still need to un-selectable by players and invulnerable, Does anyone know how I can get around this?
 
Level 4
Joined
Dec 5, 2011
Messages
75
You can't pick Locust units.Maybe you can remove Locust ability and use Selection actions to make it unselectable with new trigger
 
Each time when you create unit with locust ability store it into variable.
Now dunno how much units you want to handle but array can do.

If you have like 5-6 players then do next.

set counter[PlayerNumber] = counter[PlayerNumber] + 1
set locust_unit[ PlayerNumber * 1000 + counter[PlayerNumber] ] = CreateUnit...

when you decide to remove units just do next

loop
exitwhen counter[PlayerNumber] == 0

call RemoveUnit( locust_unit[ PlayerNumber * 1000 + counter[PlayerNumber] ] )

set counter[PlayerNumber] = counter[PlayerNumber] - 1
endloop

Another way is to add unit to unit group, then just remove it when you defeat player.
Another way -> hashtables.
 
Level 5
Joined
Jun 16, 2004
Messages
108
Just manually add every locust unit you want to consider to a unit group upon the unit's creation. Then, when removing units inside "Crystals01", just loop through the aforementioned unit group and check if the unit is in the region before removing the unit.

Locust units can still be part of unit groups. You just have to make sure you add them manually rather than try to find them all at once with a "pick every unit in region" or some such action.

The action would be this for a single locust unit being added to the group after creation:
  • Unit Group - Add (Last created unit) to thegroup
Or this if you create n > 1 units:
  • Unit Group - Add all units of (Last created unit group) to thegroup
Then removal becomes this:
  • Unit Group - Pick every unit in thegroup and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (theregion contains (Picked unit)) Equal to True
        • Then - Actions
          • Unit - Remove (Picked unit) from the game
        • Else - Actions
 
Status
Not open for further replies.
Top