• 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.

[Trigger] Optimization

Status
Not open for further replies.
Level 12
Joined
Feb 11, 2008
Messages
809
I made this trigger to detect the units needed to go along with the rest of my code and it works but it looks really ugly is there any way to optimize it?

  • SetUp Units
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Point[1] = (Position of SystemUnit[1])
      • Set Temp_Point[2] = (Position of SystemUnit[2])
      • Set AttackingUnitGroup[1] = (Units within DistanceToAttack[1] of Temp_Point[1])
      • Set AttackingUnitGroup[2] = (Units within DistanceToAttack[2] of Temp_Point[2])
      • Custom script: call RemoveLocation(udg_Temp_Point[1])
      • Custom script: call RemoveLocation(udg_Temp_Point[2])
 
First off use
  • || [ /trigger] tags.
  • Secondly, you leak the Unit Groups too
  • [trigger]Custom script: call DestroyGroup (udg_AttackingUnitGroup[1])
and the same for [2].
You can do this, if you like:
  • For each (IntegerA) from 1 to 2, do (Actions)
    • Loop - Actions
      • Set Temp_Point[(IntegerA)] = (Position of SystemUnit[(IntegerA)])
      • Set AttackingUnitGroup[(IntegerA)] = (Units within DistanceToAttack[(IntegerA)] of Temp_Point[(IntegerA)]
      • Custom script: call RemoveLocation (udg_Temp_Point[bj_forLoopAIndex])
      • Custom script: call DestroyGroup (udg_AttackingUnitGroup[bj_forLoopAIndex])
Actually, there is nothing wrong with your trigger.
Just a heads up; everytime I used Unit Group variables with array, they tended to bug/crash or not working at all. I advise you to be careful with that.
 
Level 12
Joined
Feb 11, 2008
Messages
809
First off use
  • || [ /trigger] tags.
  • Secondly, you leak the Unit Groups too
  • [trigger]Custom script: call DestroyGroup (udg_AttackingUnitGroup[1])
and the same for [2].
You can do this, if you like:
  • For each (IntegerA) from 1 to 2, do (Actions)
    • Loop - Actions
      • Set Temp_Point[(IntegerA)] = (Position of SystemUnit[(IntegerA)])
      • Set AttackingUnitGroup[(IntegerA)] = (Units within DistanceToAttack[(IntegerA)] of Temp_Point[(IntegerA)]
      • Custom script: call RemoveLocation (udg_Temp_Point[bj_forLoopAIndex])
      • Custom script: call DestroyGroup (udg_AttackingUnitGroup[bj_forLoopAIndex])
Actually, there is nothing wrong with your trigger.
Just a heads up; everytime I used Unit Group variables with array, they tended to bug/crash or not working at all. I advise you to be careful with that.

alright i fixed the tags and thanks for the info also this isnt working for some reason...
i think it has to do with destroying the unit group too quickly...
 
Status
Not open for further replies.
Top