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

[Trigger] Problem with picking units

Status
Not open for further replies.
Level 5
Joined
Dec 25, 2018
Messages
110
  • Wait 12.00 seconds
  • Set LocalGroup2 = (Units within 3000.00 of LocalPoint3 matching ((((Matching unit) belongs to an ally of (Owner of LocalUnit)) Equal to True) and (((Matching unit) is alive) Equal to True)))
  • Unit Group - Pick every unit in LocalGroup2 and do (Actions)
    • Loop - Actions
      • Set DelUnit = (Picked unit)
      • Game - Display to (All players) the text: del
      • Custom script: call UnitRemoveAbility(udg_DelUnit ,'B01Q')
      • Custom script: call UnitRemoveAbility(udg_DelUnit ,'B01R')
  • Custom script: call DestroyGroup(udg_LocalGroup2)
LocalUnit is local created by
Custom script: local unit udg_LocalUnit.

Pick every unit in every LocalGroup2 works fine if I use this code before the wait, how can I make it work after wait?
 
Last edited:
You cannot use local variables inside conditinal statements in GUI, since they create separate functions in the JASS script, so I'm not even sure why it would work before the wait. It should not work as intended at all (unless the owner of the global LocalUnit happens to be the same as the local). Also, you have to null local unit variables at the end of each trigger that you use them in, unless that unit is never supposed to be removed from the game.

  • Custom script: set udg_LocalUnit = null
Would you mind posting the entire trigger? Might be easier to debug that way.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,019
You can just assign some other global right before that LocalGroup2 set line:
  • Wait 12.00 seconds
  • Set USE_THIS_GLOBAL = LocalUnit
  • Set LocalGroup2 = (Units within 3000.00 of LocalPoint3 matching ((((Matching unit) belongs to an ally of (Owner of USE_THIS_UNIT)) Equal to True) and (((Matching unit) is alive) Equal to True)))
 
Level 5
Joined
Dec 25, 2018
Messages
110
You can just assign some other global right before that LocalGroup2 set line:
  • Wait 12.00 seconds
  • Set USE_THIS_GLOBAL = LocalUnit
  • Set LocalGroup2 = (Units within 3000.00 of LocalPoint3 matching ((((Matching unit) belongs to an ally of (Owner of USE_THIS_UNIT)) Equal to True) and (((Matching unit) is alive) Equal to True)))
This worked, thanks.
 
Status
Not open for further replies.
Top