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

Will it leak?

Status
Not open for further replies.
Level 11
Joined
Jun 26, 2014
Messages
497
  • Player1
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Remove all units from WinLosePlayer[1]
      • Set WinLosePlayer[1] = (Units owned by Player 1 (Red) matching (((Matching unit) is A structure) Equal to True))
      • Unit Group - Pick every unit in WinLosePlayer[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in WinLosePlayer[1]) Equal to 0
            • Then - Actions
              • Game - Display to (All players) for 10.00 seconds the text: ((Name of Player 1 (Red)) + has been defeated!)
              • Game - Defeat Player 1 (Red) with the message: Defeat!
            • Else - Actions
      • Custom script: call DestroyGroup(udg_WinLosePlayer[1])
Will this thing leak?
 
Level 12
Joined
May 22, 2015
Messages
1,051
You don't need to use that loop. You can just make that check once. As is, that actually is looping like crazy because the Number of units in <group> function actually loops over all the units to count them. It's just a big waste of processing power.

It will also skip itself the one time it would pass!! The loop isn't hit when the number of units in the group is 0.

You don't need to do this every two seconds. Instead, you could check it when a unit dies. This way, it will happen as soon as the last building is destroyed.

Is WinLosePlayer[1] ever destroyed by other triggers? You don't need to do the "Remove all units from <group>". If the group is destroyed by something else, that might cause it to crash the game.

Otherwise your code is fine.
 
Level 11
Joined
Jun 26, 2014
Messages
497
Okay, yea it's not working.... DAMN!

  • Player1
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set WinLosePlayer[1] = (Units in (Playable map area) owned by Player 1 (Red))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (WinLosePlayer[1] is empty) Equal to True
        • Then - Actions
          • Game - Display to (All players) for 10.00 seconds the text: ((Name of Player 1 (Red)) + has been defeated!)
          • Game - Defeat Player 1 (Red) with the message: Defeat!
        • Else - Actions
      • Custom script: call DestroyGroup(udg_WinLosePlayer[1])
Still not working... what's wrong with it!? >.<
 
Level 12
Joined
May 22, 2015
Messages
1,051
Looks like you took out the check for if it is a structure. Did you try it where you kill all of player 1's units and not just their buildings?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I am not sure, how this is currently in Wc3. As far as I remember, once a unit dies, it is completely removed from the game after some time, but still, it could remain in your WinLosePlayer[1] group somehow. At least in such a way, that the group is not reported as empty anymore.
You might avoid this by just removing the dying unti from the group like this:

JASS:
if IsUnitInGroup( GetTriggerUnit(), udg_WinLosePlayer[1]) == TRUE then
    call GroupRemoveUnit( udg_WinLosePlayer[1], GetTriggerUnit())
endif

sry this is all Custom script, but it might avoid, that the unit is picked before and stored in the group forever ....
 
Status
Not open for further replies.
Top