# Which is Better

Status
Not open for further replies.

Level 16
So there are two ways of filtering which units you want to be affected within a unit group.

• Set TempUnitGroup = (Units within 800.00 of TempPoint matching ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and ((((Owner of (Matching unit)) Not equal to Player 9 (Gray)) and ((Owner of (Matching unit)) Not equal to Neutral Passive)) and ((
• Unit Group - Pick every unit in TempUnitGroup and do (Actions)
• Loop - Actions
• Set TempUnitGroup = (Units within 800.00 of TempPoint)
• Unit Group - Pick every unit in TempUnitGroup and do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• ((Picked unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True
• (Owner of (Matching unit)) Not equal to Player 9 (Gray)
• (Owner of (Matching unit)) Not equal to Neutral Passive
• (Unit-type of (Picked unit)) Not equal to Bunker
• (Unit-type of (Picked unit)) Not equal to Firebat
• Then - Actions
• Else - Actions
Which is faster or are they both the same?
The second one is much nicer to work with and edit. Unless it is much slower I think it is ideal?

#### deathismyfriend

Level 29
The third is faster.

• Set TempUnitGroup = (Units within 800.00 of TempPoint)
• Unit Group - Pick every unit in TempUnitGroup and do (Actions)
• Loop - Actions
• Set tempUnit = (Picked unit)
• Set tempUnitType = (Unit-type of tempUnit)
• Set tempPlayer = (Owner of tempUnit)
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (tempUnit belongs to an enemy of tempPlayer) Equal to True
• tempPlayer Not equal to Player 9 (Gray)
• tempPlayer Not equal to Neutral Passive
• tempUnitType Not equal to Bunker
• tempUnitType Not equal to Firebat
• Then - Actions
• Else - Actions
• Set tempUnit = No unit
• Custom script: set udg_tempPlayer = null

Level 16
Interesting. Thanks for that. Kind of glad I don't need to use option 4 (modified option 1, lol). And I don't normally nullify points or variables, but will do if it helps performance. Thanks mate, I'd rep but I already did last night regarding the MUI question.

Edit: You seem to be nulling everything but not the Unit_Type. Should I null the unit type too?

• Set TempUnitType = No unit-type

#### deathismyfriend

Level 29
You do not need to null reals / integers / strings.
All others should be nulled.
Unit types along with ability types and item types are integers.

Level 16
I see. Thanks heaps.

Level 37
Option 2!

#### deathismyfriend

Level 29
Option 2!

Option 2 is still not the best option. I have posted the best option. Although as Cakemaster pointed out I missed the destroygroup call.

#### Nichilus

Level 23
Option 2 won't even work as there are (matching unit) in Condition block instead of (Picked unit)

#### Aeroblyctos

Level 37
Option 2 is still not the best option. I have posted the best option. Although as Cakemaster pointed out I missed the destroygroup call.
Well I don't actually use any of these examples. I just think that looks more clear to me. Hohoh.

Status
Not open for further replies.

Replies
1
Views
680
Replies
14
Views
848
Replies
3
Views
406
Replies
2
Views
409
Replies
9
Views
627