• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is there any difference between these 2 triggers?

Status
Not open for further replies.
Level 18
Joined
Jun 2, 2009
Messages
1,233
I know how to use that but i just wanted to make sure about it 100% percent.
Both of the triggers are doing the same thing right?
 

Attachments

  • test2.png
    test2.png
    29 KB · Views: 25
Level 45
Joined
Feb 27, 2007
Messages
5,578
It is almost always preferable to clean up leaking objects in the same scope that they are created/assigned a value. Since the group was not created/generated inside the If block it’s best to destroy it after the if block. One also wants to reduce duplicate code in both halves of the If-block, so putting it in both is unnecessary.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
Unrelated: You're leaking a Point when you do: (Center of CurrentTarget[...])

The fix:
  • Set Variable TempPoint = (Center of CurrentTarget[...])
  • Unit - Order YourUnit to Attack-Move to TempPoint
  • Custom script: call RemoveLocation(udg_TempPoint)
The same goes for PreviousTarget[].

And like Pyro said about duplicate code, you can separate this Point from the If Then Else so you don't have to do the same thing twice.

Edit: On second thought, you wouldn't want to separate it since it gets Set to two different places.
 
Last edited:
Status
Not open for further replies.
Top