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

[General] Question about using the "and" for conditions and else for ITE functions

Status
Not open for further replies.
Level 6
Joined
Feb 10, 2011
Messages
188
so for my trigger there is multiple conditions that need to be met for it to run, if i do not use the and thing for the conditions if only one of the needed conditions is met will it fire?

also, when using ITE functions if i want something to happen when the conditions are NOT met, can i just put it in the else sections?

here is my trigger, should i be using the and in the first ITE that needs 3 conditions, also in the Last ITE? (wich i will put into the else part of the first ITE if my second question is a yes)

  • Change Defender
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Select New Defender
          • ((Target unit of ability being cast) is in BaseDefenders) Equal to False
          • ((Target unit of ability being cast) is An Ancient) Equal to False
        • Then - Actions
          • -------- Set Casting Unit --------
          • Set tempPoint = (Position of (Casting unit))
          • -------- Set Current Defender & Position --------
          • Set tempGroup = (Units within 500.00 of tempPoint)
          • Unit Group - Pick every unit in tempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in BaseDefenders) Equal to True
                • Then - Actions
                  • Set tempUnit1 = (Picked unit)
                • Else - Actions
          • Set tempPoint1 = (Position of tempUnit1)
          • -------- Set New Defender & Position --------
          • Set tempUnit2 = (Target unit of ability being cast)
          • Set tempPoint2 = (Position of tempUnit2)
          • -------- Swap Defenders & Remove/Add Buffs --------
          • Unit - Remove All buffs from tempUnit1
          • Unit Group - Remove tempUnit1 from BaseDefenders
          • Unit - Move tempUnit1 instantly to tempPoint2
          • Unit - Move tempUnit2 instantly to tempPoint1
          • Unit Group - Add tempUnit2 to BaseDefenders
          • Set tempGroup1 = (Units within 500.00 of (Position of tempUnit2))
          • Unit Group - Pick every unit in tempGroup1 and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Guardtower Normal
                • Then - Actions
                  • Set tempUnit3 = (Picked unit)
                  • Unit - Order tempUnit3 to Orc Raider - Ensnare tempUnit2
                • Else - Actions
          • -------- Clear Leaks --------
          • Custom script: call RemoveLocation( udg_tempPoint )
          • Custom script: call RemoveLocation( udg_tempPoint1 )
          • Custom script: call RemoveLocation( udg_tempPoint2 )
          • Custom script: set udg_tempUnit1 = null
          • Custom script: set udg_tempUnit2 = null
          • Custom script: set udg_tempUnit3 = null
          • Custom script: call DestroyGroup( udg_tempGroup )
          • Custom script: call DestroyGroup( udg_tempGroup1 )
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Select New Defender
          • ((Target unit of ability being cast) is in BaseDefenders) Equal to True
        • Then - Actions
          • Set tempUnit = (Casting unit)
          • Unit - Order tempUnit to Stop
          • Set tempPlayer = (Owner of tempUnit)
          • Game - Display to (All players matching ((Owner of tempUnit) Equal to tempPlayer)) the text: That unit is alread...
          • Custom script: set udg_tempUnit = null
          • Custom script: set udg_tempPlayer = null
        • Else - Actions
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
When condition is not met in a ITE, it should automatically go into an Else because it is the opposite of Then.

See it this way: Then = Condition is met for If
Else = COnditon is not met for If

And if you use And for a condition, as what the name said, you should MET ALL CONDITON FOR IT TO RUN THE ACTIONS. For its opposite Or, even only one of the conditions you met, the action will run.

You can use And for the first And action but I think with your triggers If will work fine even without And. Because sometimes triggers even without And acts like one too.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
The AND keyword indicates that all conditions must be met for the Then block to fire. Conversely, the OR keyword fires the Then block if any of the condition is met. That being said, you can put the code for the Else block accordingly and it will fire when the condition block returns a false (not met)

edit
Whatever :p I am slow once again.
 
Level 6
Joined
Feb 10, 2011
Messages
188
When condition is not met in a ITE, it should automatically go into an Else because it is the opposite of Then.

See it this way: Then = Condition is met for If
Else = COnditon is not met for If

And if you use And for a condition, as what the name said, you should MET ALL CONDITON FOR IT TO RUN THE ACTIONS. For its opposite Or, even only one of the conditions you met, the action will run.

You can use And for the first And action but I think with your triggers If will work fine even without And. Because sometimes triggers even without And acts like one too.

ahh ok i see, thanks for the answer. i know it was a pretty simple thing but i wasnt to sure.

turns out im going to have to use AND, i just tested it but the last actions of the last ITE into the else part of the first and it it fired the else anyways.

The AND keyword indicates that all conditions must be met for the Then block to fire. Conversely, the OR keyword fires the Then block if any of the condition is met. That being said, you can put the code for the Else block accordingly and it will fire when the condition block returns a false (not met)

edit
Whatever :p I am slow once again.

at least u tried :)
 
Status
Not open for further replies.
Top