• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Why this doesn't work?

Status
Not open for further replies.
  • Disapperance and automate harvesting continue
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(resumeharvesting))
        • Then - Actions
          • Set CustomValue = (Custom value of (Triggering unit))
          • Set HarverstingWorker[CustomValue] = (Triggering unit)
          • Set OccupiedBuilidng[CustomValue] = (Target unit of issued order)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer((Distance between (Position of HarverstingWorker[CustomValue]) and (Position of OccupiedBuilidng[CustomValue])))) Equal to 150
            • Then - Actions
              • Unit - Hide HarverstingWorker[CustomValue]
              • Wait 3.00 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (OccupiedBuilidng[CustomValue] is alive) Equal to True
                • Then - Actions
                  • Unit - Unhide HarverstingWorker[CustomValue]
                  • Set OccupiedBuilidng[CustomValue] = No unit
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Tree_Cutter[CustomValue] Equal to No destructible
                    • Then - Actions
                    • Else - Actions
                      • Unit - Order HarverstingWorker[CustomValue] to Harvest Tree_Cutter[CustomValue]
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Mine_Target[CustomValue] Equal to No unit
                    • Then - Actions
                    • Else - Actions
                      • Unit - Order HarverstingWorker[CustomValue] to Harvest Mine_Target[CustomValue]
                • Else - Actions
                  • Unit - Kill HarverstingWorker[CustomValue]
            • Else - Actions
        • Else - Actions
please inspect
 
Level 9
Joined
Jan 23, 2008
Messages
384
  • (Integer((Distance between (Position of HarverstingWorker[CustomValue]) and (Position of OccupiedBuilidng[CustomValue])))) Equal to 150
Maybe this is the problem because the distance isn't exact 150 and the trigger goes directly to else function and does nothing (probably) ... but tell me what happens that you think that the trigger does not work ?
 
Level 7
Joined
Jul 18, 2009
Messages
272
1) I guess the problem is this line:
  • (Integer((Distance between (Position of HarverstingWorker[CustomValue]) and (Position of OccupiedBuilidng[CustomValue])))) Equal to 150
It returns false if the distance is not exactly 150 (for example: 149.99 --> false).

2) "CustomValue" can have a different value after the 3sec wait. If there are 2 or more Workers in your map, this will probably cause bugs.
 
Level 4
Joined
Nov 7, 2009
Messages
83
I would write this slightly different

  • Disapperance and automate harvesting continue
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(resumeharvesting))
    • Actions
      • Set CustomValue = (Custom value of (Ordered unit))
      • Set HarverstingWorker[CustomValue] = (Ordered unit)
      • Set OccupiedBuilding[CustomValue] = (Target unit of issued order)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Distance between (Position of HarverstingWorker[CustomValue]) and (Position of OccupiedBuilding[CustomValue])))) Equal to 150
        • Then - Actions
          • Unit - Hide HarverstingWorker[CustomValue]
          • Wait 3.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (OccupiedBuilding[CustomValue] is alive) Equal to True
            • Then - Actions
              • Unit - Unhide HarverstingWorker[CustomValue]
              • Set OccupiedBuilding[CustomValue] = No unit
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Tree_Cutter[CustomValue] Not Equal to No destructible
                • Then - Actions
                  • Unit - Order HarverstingWorker[CustomValue] to Harvest Tree_Cutter[CustomValue]
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Mine_Target[CustomValue] Not Equal to No unit
                • Then - Actions
                  • Unit - Order HarverstingWorker[CustomValue] to Harvest Mine_Target[CustomValue]
                • Else - Actions
            • Else - Actions
              • Unit - Kill HarverstingWorker[CustomValue]
        • Else - Actions
Now, I don't know if triggering unit will work for sure, so I changed it to ordered unit (should work the same way).
Maybe the trouble is, as you've been pointed out before me, that you are comparing to a distance strictly equal to 150, maybe you should be using
  • (Integer((Distance between (Position of HarverstingWorker[CustomValue]) and (Position of OccupiedBuilding[CustomValue])))) Lower or Equal to 150
that way, your ability will work in the area sorrounded by the circle with radius 150 (which by the way I don't remember if it's a long or short distance) and not only on the circle of radius 150.

Lower or equal to 150
step3_circle.gif


Equal to 150
Circle1.gif


I also don't know where you set that tree/mine harvest, but I asume you are doing that the right way in another trigger (if not, then maybe that's also a problem).

Hope this is of any help.
I also hope the code is the same, I have checked it about 20 times so that it is the same way, but I'm human.
 
Status
Not open for further replies.
Top