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

Annoying part of a trigger that refuses to work

Status
Not open for further replies.
Level 6
Joined
Jul 13, 2006
Messages
140
So, this is a part of a trigger that refuses to work, and I can't figure out why.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Charges remaining in (Item carried by (Picked unit) of type ITEM)) Less than 10
          • (Owner of (Picked unit)) Not equal to Neutral Passive
          • (Owner of (Picked unit)) Not equal to Neutral Hostile
    • Then - Actions
      • Set OtherPoint = (Position of (Picked unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of OtherPoint) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to Something Centre
                  • (Unit-type of (Picked unit)) Equal to Something
                  • (Unit-type of (Picked unit)) Equal to Something
                  • (Unit-type of (Picked unit)) Equal to Something
                  • (Unit-type of (Picked unit)) Equal to Something
                  • (Unit-type of (Picked unit)) Equal to Something Battleship
                  • (Unit-type of (Picked unit)) Equal to Something
                  • (Unit-type of (Picked unit)) Equal to Something
            • Then - Actions
            • Else - Actions
              • Item - Set charges remaining in (Item carried by (Picked unit) of type ITEM) to ((Charges remaining in (Item carried by (Picked unit) of type ITEM)) + 1)
      • Custom script: call RemoveLocation(udg_OtherPoint)
    • Else - Actions
It's the second part that doesn't work, it's supposed to check if this or that unit is nearby and then, if they are, it does nothing but if not then it proceeds as usual.

Oh and I have like 7 different copies of this same trigger (and another one that is about this large (EDIT: MUCH larger)) and it's causing loads of lag, is there anyway to optimise it?

BTW, I've tried doing the conditions as not equal to and the Then action as the set charges, but it didn't work either.
 
Last edited:
Do it like this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
        • Conditions
        • (Charges remaining in (Item carried by (Picked unit) of type ITEM)) Less than 10
        • (Owner of (Picked unit)) Not equal to Neutral Passive
        • (Owner of (Picked unit)) Not equal to Neutral Hostile
    • Then - Actions
      • Set Unit1 = (Picked unit)
      • Set OtherPoint = (Position of (Unit1))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of OtherPoint) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Not Equal to Something Centre
                  • (Unit-type of (Picked unit)) Not Equal to Something
                  • (Unit-type of (Picked unit)) Not Equal to Something
                  • (Unit-type of (Picked unit)) Not Equal to Something
                  • (Unit-type of (Picked unit)) Not Equal to Something
                  • (Unit-type of (Picked unit)) Not Equal to Something Battleship
                  • (Unit-type of (Picked unit)) Not Equal to Something
                  • (Unit-type of (Picked unit)) Not Equal to Something
            • Then - Actions
              • Item - Set charges remaining in (Item carried by (Picked unit) of type ITEM) to ((Charges remaining in (Item carried by (Picked unit) of type ITEM)) + 1)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_OtherPoint)
    • Else - Actions
Changes made:

• The comparisons for the Unit-type are set to Not Equal
• Used a unit variable for the "Picked" unit [called Unit1], because, since you involve another unit group pick afterwards, the "Picked unit" will not refer to the unit you initially picked.
 
Level 13
Joined
Mar 24, 2010
Messages
950
would it be better to pick all units and do the if then's inside it.. that way you have the units you want to reference.. also instead of using Custom script: set bj_wantDestroyGroup = true
Assign it to a temp group and then remove it that way the trigger can work over and over again.

If thats your whole trigger why are you addressing picked units before you even pick a unit? It shouldnt know what the picked unit even is yet at that point in the trigger.
 
Status
Not open for further replies.
Top