• 🏆 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] Order Structure to Stop Construction

Status
Not open for further replies.
Level 39
Joined
Feb 27, 2007
Messages
5,010
  • Can't put waits in group or force callbacks; the thread crashes when it encounters a wait in either of these, so the actions after the wait are not executed.
  • The 'Do Nothing' command is (unsurprisingly) useless and never needs to be used; simply don't put any actions there.
  • You are leaking a few points, a unit group, and a force (player group) which you should avoid. Here's a good resource to explain what leaking is and how to fix it: Things That Leak
  • Wait has a minimum duration of ~0.27 seconds, so it won't actually wait 0.01 here.
  • The method you're doing is kind of silly. No need to compare the distance to all AI controlled units, just look in a 96 radius around the structure and see if there are any. This means you don't have to do the distance comparison yourself, the unit group getting is doing that internally for you.
  • AntiBuild
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempP = (Position of (Constructing Structure)) //point variable
      • Set Count = 0 //integer variable
      • Custom script: set bj_wantDestroyGroup = true //this cleans the group leak in the next line automatically
      • Unit Group - Pick every unit in (Units within 96.00 of TempP matching ((Owner of (Matching Unit)) controller equal to Computer) and do (Actions)
        • Loop - Actions
          • Set Count = (Count + 1)
      • Custom script: call RemoveLocation(udg_TempP) //cleaning point leak
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Count greater than 0
        • Then - Actions
          • Set TempF = (Player group((Owner of (Constructing structure)))) //Player Group variable
          • Game - Display to TempF the text: |c0000cdf9Possible ...
          • Custom script: call DestroyForce(udg_TempF) //cleaning force leak
          • Wait 0.01 seconds
          • Custom script: call IssueImmediateOrderById(GetConstructingStructure(), 851976)
        • Else - Actions
 
Level 8
Joined
May 21, 2019
Messages
435
The 'Do Nothing' command is (unsurprisingly) useless and never needs to be used; simply don't put any actions there.
It's not useless in single-line if actions, as the GUI needs something in the "else" field to be able to close the dialog.
It's entirely pointless in a multi-line though.
 
Level 8
Joined
May 21, 2019
Messages
435
Yes dude I am fully aware of that. Single line ifs are also entirely pointless because the multi ones can be collapsed to take the same visual space.
I know that you're aware, I'm just stating it for readers of the thread.
Single lines are neat for short things, as it remains readable, whereas a collapsed multiline does not. Granted it isn't terribly useful, but it has its moments.
 
Status
Not open for further replies.
Top