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

how to make Unit doing nothing do something?

Status
Not open for further replies.
  • Trigger
  • Events
    • Time - Every 5.00 seconds of game-time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in (Group) and do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Current order of (Picked unit)) Equal to (order(<Empty String>))
          • Then - Actions
            • Unit - Order (Picked unit) to Attack (Random unit from (Temp_Group))
          • Else - Actions
The <Empty String>: When you have to type an order, delete the default "stop" order and press Enter; simply don't type anything.
 
Level 8
Joined
Nov 21, 2008
Messages
316
  • Orc Attack
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set DoingNothingGroup = (Units in (Playable map area) matching (((Owner of (Matching unit)) Equal to Player 11 (Dark Green)) or ((Owner of (Matching unit)) Equal to Player 12 (Brown))))
      • Set TempGroup2 = (Units in (Playable map area) matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
      • Set Unitposition = (Position of (Random unit from TempGroup2))
      • Unit Group - Pick every unit in DoingNothingGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of (Picked unit)) Equal to (Order(<Empty String>))
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To Unitposition
            • Else - Actions
      • Custom script: call DestroyGroup(udg_DoingNothingGroup)
      • Custom script: call DestroyGroup(udg_TempGroup2)
      • Custom script: call RemoveLocation(udg_Unitposition)
is it leak free now?
 
Level 8
Joined
Apr 30, 2009
Messages
338
I don't think it's leak free; you should set tempunit = random unit from group and then clear it. Random unit from group leaks.
 
I don't know, maybe you should use "bj_..." (as I know, but I'm not so good with Jass) but it's OK for now. If you want all the units attack the same target, it's OK, but if not, put Set Unitposition after the Then command. And put the condition I wrote above to the If Part :D

People say to use set bj_wantDestroyGroup = true but it actually makes no difference. You can either use a global group and use the "call DestroyGroup(udg_MyGroupVariable)" or you can use the bj_wantDestroy. Most people in GUI use bj_wantDestroy though because it saves you from creating one extra global variable, but speed-wise they are the same. =D

I don't think it's leak free; you should set tempunit = random unit from group and then clear it. Random unit from group leaks.

Random unit from group doesn't leak, no need to worry about it. =) It uses the group you currently input, and aside from that it doesn't use any handles except for the unit it returns (which doesn't necessarily leak).
 
Status
Not open for further replies.
Top