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

[Trigger] Detecting if unit is null or not

Status
Not open for further replies.
Level 6
Joined
Nov 1, 2015
Messages
62
So i have this trigger which picks a single unit that meets some conditions, but then later in the trigger i need to detect whether any units met those conditions or not.
  • Clothing Gathering
    • Events
      • Jednotka - A unit Finishes Training of Unit
    • Conditions
      • (Unit-type of (Trained unit)) Equals Clothing
    • Actions
      • Jednotka - Remove (Trained unit) from the game
      • Set Nearest_Bod = (Position of (Triggering unit))
      • Set Nearest_Real = 1000000.00
      • -------- Resource that is being created --------
      • Custom script: set bj_wantDestroyGroup = true
      • Skupina jednotky - Pick every unit in (Units within 4000.00 of Nearest_Bod matching (((Owner of (Matching unit)) Equals se (Owner of (Trained unit))) and (((Level of Clothing Stock for (Matching unit)) Nerovná se 0) and ((Level of Clothing Stock for (Matching unit)) MenšĂ* nebo rovno ((Custom and do (Actions)
        • Loop - akce
          • Set Nearest_Bod2 = (Position of (Picked unit))
          • Set Nearest_Real2 = (Distance between Nearest_Bod and Nearest_Bod2)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • JestliĹľe - podmĂ*nky
              • Nearest_Real Greater Than Nearest_Real2
            • Potom - akce
              • Custom script: set udg_Nearest_Unit = null
              • Set Nearest_Real = Nearest_Real2
              • Set Nearest_Unit = (Picked unit)
            • Jinak - akce
          • Custom script: call RemoveLocation(udg_Nearest_Bod2)
      • -------- Resource that is required --------
      • Set Nearest_Skupina = (Units within 4000.00 of Nearest_Bod matching (((Owner of (Matching unit)) Equals se (Owner of (Trained unit))) and ((Level of Wool Stock for (Matching unit)) Greater Than 1)))
      • Skupina jednotky - Pick every unit in Nearest_Skupina and do (Actions)
        • SmyÄŤka - akce
          • Set Nearest_Bod2 = (Position of (Picked unit))
          • Set Nearest_Real2 = (Distance between Nearest_Bod and Nearest_Bod2)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • JestliĹľe - podmĂ*nky
              • Nearest_Real Greater Than Nearest_Real2
            • Potom - akce
              • Custom script: set udg_Nearest_Unit2 = null
              • Set Nearest_Real = Nearest_Real2
              • Set Nearest_Unit2 = (Picked unit)
            • Jinak - akce
          • Custom script: call RemoveLocation(udg_Nearest_Bod2)
      • -------- Checking for final outcome --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • JestliĹľe - podmĂ*nky
          • (Number of units in Nearest_Skupina) VÄ›tšĂ* neĹľ 0
        • Potom - akce
          • Jednotka - Set level of Wool Stock for Nearest_Unit2 to ((Level of Wool Stock for Nearest_Unit) - 1)
          • Jednotka - Set level of Flour Stock for Nearest_Unit to ((Level of Flour Stock for Nearest_Unit) + 1)
          • Jednotka - Order (Triggering unit) to train/upgrade to a Flour
        • Jinak - akce
          • Hra - Display to (All players matching ((Owner of (Trained unit)) Rovná se (Matching player))) the text: No wool left to ma...
          • Animace - Ping minimap for (All players matching ((Owner of (Trained unit)) Rovná se (Matching player))) at Nearest_Bod for 2.00 seconds
      • Custom script: call RemoveLocation(udg_Nearest_Bod)
      • Custom script: call DestroyGroup(udg_Nearest_Skupina)
      • Custom script: set udg_Nearest_Unit = null
      • Custom script: set udg_Nearest_Unit2 = null
(PS: Sorry that some stuff may be unreadable, i have a translated version of WE but atleast some of it is fixed)
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,381
You could check if (Your_unit is equal to (No unit)). That basically checks if your_unit == null.

Also, you should consider using only one language for your stuff. Not a mix of both languages, as some words are written same in both languages, but in each language they mean something different (e.g. list = array in english or leaf in czech. Then it would be confusing if you had name e.g. "myList" right?)
 
Status
Not open for further replies.
Top