• 🏆 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] Cannon trigger system doesn't work properly

Status
Not open for further replies.

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,266
I cannot see what's wrong with this trigger

  • Adding Projectiles System
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Port Cannons
    • Actions
      • -------- Port Cannon Slot 1 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Port Cannons
          • (Item-class of (Item carried by (Triggering unit) in slot 1)) Equal to Artifact
        • Then - Actions
          • Set RandomAngle = ((Facing of (Triggering unit)) + (Random real number between 70.00 and 90.00))
          • Set TempPoint2 = (Position of (Triggering unit))
          • Set TempPoint1 = (TempPoint2 offset by (Random real number between 10.00 and 64.00) towards RandomAngle degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot 1) Equal to (Item carried by (Triggering unit) of type Basic Cannon (Cannon))
            • Then - Actions
              • Unit - Create 1 Cannon Ball for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
              • Unit - Add Basic Cannon (Projectile) to (Last created unit)
              • Unit Group - Add (Last created unit) to MoveSlow
              • Unit - Add a 1.32 second Generic expiration timer to (Last created unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item carried by (Triggering unit) in slot 1) Equal to (Item carried by (Triggering unit) of type Sail Ripper (Cannon))
                • Then - Actions
                  • Unit - Create 1 Sail Ripper for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
                  • Unit Group - Add (Last created unit) to MoveSlow
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item carried by (Triggering unit) in slot 1) Equal to (Item carried by (Triggering unit) of type Basic Culverine (Cannon))
                    • Then - Actions
                      • Unit - Create 1 Culverine Ball for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
                      • Unit Group - Add (Last created unit) to MoveFast
                      • Unit - Add a 0.85 second Generic expiration timer to (Last created unit)
                    • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint1)
          • Custom script: call RemoveLocation(udg_TempPoint2)
        • Else - Actions
      • -------- Port Cannon Slot 3 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Port Cannons
          • (Item-class of (Item carried by (Triggering unit) in slot 3)) Equal to Artifact
        • Then - Actions
          • Set RandomAngle = ((Facing of (Triggering unit)) + (Random real number between 80.00 and 100.00))
          • Set TempPoint2 = (Position of (Triggering unit))
          • Set TempPoint1 = (TempPoint2 offset by (Random real number between 10.00 and 64.00) towards RandomAngle degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot 3) Equal to (Item carried by (Triggering unit) of type Basic Cannon (Cannon))
            • Then - Actions
              • Unit - Create 1 Cannon Ball for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
              • Unit - Add Basic Cannon (Projectile) to (Last created unit)
              • Unit Group - Add (Last created unit) to MoveSlow
              • Unit - Add a 1.32 second Generic expiration timer to (Last created unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item carried by (Triggering unit) in slot 3) Equal to (Item carried by (Triggering unit) of type Sail Ripper (Cannon))
                • Then - Actions
                  • Unit - Create 1 Sail Ripper for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
                  • Unit Group - Add (Last created unit) to MoveSlow
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item carried by (Triggering unit) in slot 3) Equal to (Item carried by (Triggering unit) of type Basic Culverine (Cannon))
                    • Then - Actions
                      • Unit - Create 1 Culverine Ball for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
                      • Unit Group - Add (Last created unit) to MoveFast
                      • Unit - Add a 0.85 second Generic expiration timer to (Last created unit)
                    • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint1)
          • Custom script: call RemoveLocation(udg_TempPoint2)
        • Else - Actions
      • -------- Port Cannon Slot 5 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Port Cannons
          • (Item-class of (Item carried by (Triggering unit) in slot 5)) Equal to Artifact
        • Then - Actions
          • Set RandomAngle = ((Facing of (Triggering unit)) + (Random real number between 90.00 and 110.00))
          • Set TempPoint2 = (Position of (Triggering unit))
          • Set TempPoint1 = (TempPoint2 offset by (Random real number between 10.00 and 64.00) towards RandomAngle degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot 5) Equal to (Item carried by (Triggering unit) of type Basic Cannon (Cannon))
            • Then - Actions
              • Unit - Create 1 Cannon Ball for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
              • Unit - Add Basic Cannon (Projectile) to (Last created unit)
              • Unit Group - Add (Last created unit) to MoveSlow
              • Unit - Add a 1.32 second Generic expiration timer to (Last created unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item carried by (Triggering unit) in slot 5) Equal to (Item carried by (Triggering unit) of type Sail Ripper (Cannon))
                • Then - Actions
                  • Unit - Create 1 Sail Ripper for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
                  • Unit Group - Add (Last created unit) to MoveSlow
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item carried by (Triggering unit) in slot 5) Equal to (Item carried by (Triggering unit) of type Basic Culverine (Cannon))
                    • Then - Actions
                      • Unit - Create 1 Culverine Ball for (Owner of (Triggering unit)) at TempPoint1 facing RandomAngle degrees
                      • Unit Group - Add (Last created unit) to MoveFast
                      • Unit - Add a 0.85 second Generic expiration timer to (Last created unit)
                    • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint1)
          • Custom script: call RemoveLocation(udg_TempPoint2)
        • Else - Actions

The ship only fires 1 projectile, instead of 3 when the inventory is full. I've tried different solutions, but I cannot fix it. Neither can't I see what's wrong with the trigger causing it only to make 1 cannonballs instead of 3.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
FoA:
(Ability being cast) Equal to Port Cannons
in all the conditions inside the actions block are just slowing this down.
Help me debug this one:
swap the items in the inventory and say which one fired.
P.s. Are you sure all the items are artifacts?
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,266
They are all artifacts

btw I've fixed the problem

  • (Item carried by (Triggering unit) in slot 1) Equal to (Item carried by (Triggering unit) of type Basic Cannon (Cannon))
Doesn't work properly

But
  • (Item-type of (Item carried by (Triggering unit) in slot 1)) Equal to Basic Cannon (Cannon)
This works.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Oh, yeah.
When I see such a long code, I tend to avoid examining it thoroughly ;)
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,266
Well I shortened the trigger into just these 3 chunks. My current trigger is MUCH MUCH longer. This is example only 3 items is included, not 27 with 9 chunk multipled with 27 (30kb.... text)

btw the first condition sounded logical to me. I discovered it by guessing.
 
Status
Not open for further replies.
Top