[Solved] Living units detection

Status
Not open for further replies.
You just need to loop through all of them and increase some sort of counter variable for each alive unit:
  • Set COUNT = 0
  • Set GROUP = Units in (Playable Map Area)
  • Unit Group - Pick every unit in GROUP and do (Actions)
    • Loop - Actions
      • If (All conditions are true) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current life of (Picked Unit)) greater than 0.405 //units die at 0.405 hp, not at 0 or 1. It's weird, just go with it.
        • Then - Actions
          • Set COUNT = COUNT + 1
        • Else - Actions
  • Custom script: call DestroyGroup(udg_GROUP) //cleans the group leak; change the variable name to match yours but keep the udg_ prefix
  • -------- here COUNT is how many alive units were in GROUP --------
 
upload_2018-11-13_17-6-26.png


Thanks, I'll test it, but I have another question regarding the group leak, if I set a group to a variable and recicle it, will it leak?
 
You can 'recycle' the group by using the "Unit Group - Remove all units from GROUP" action. This clears it so new units can be added later. However, you can only add units to it using the "Unit Group - Add UNIT to GROUP" action; if you try to 'add' units like "Set GROUP = Units in (Playable map area)" it will create a new group, assign it to the GROUP variable, and 'leak' the group that was already stored in GROUP.

Calling DestroyGroup() isn't really recycling, but it does remove the leak.
 
Status
Not open for further replies.
Back
Top