• 🏆 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] I can't get this spell to work right, can you take a look?

Status
Not open for further replies.
If anyone's played the Legend of Zelda games for the DS then you remember the boomerang item that lets you draw out its path before unleashing it. I tried to carry over that to Wc3 and so far it works great, except for 1 issue:

-The boomerang is supposed to stun the units it hits once, and not be able to hit them again until the caster gives it another throw. This works fine for player 1, but when player 2 gives it a whirl it hits the enemies multiple times, contrary to what I want it to do. I looked at my stun trigger multiple times, and yet I still can't find out why it's not functioning correctly. As from this, the problem may be in another trigger as all the triggers are closely connected (at least the stun is connected closely to the throw and boomerang movement triggers).

Could you take a look at it and see if you can find the error?

Here's the stun trigger:
  • Boomerang Stun
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Tb_BoomerangGroup and do (Actions)
        • Loop - Actions
          • Set P = (Position of (Picked unit))
          • Set Tb_ReferenceUnit = (Picked unit)
          • Set Tb_StunGroup = (Units within 250.00 of P matching (((Owner of (Matching unit)) is an enemy of (Owner of Tb_ReferenceUnit)) Equal to True))
          • Game - Display to (All players) the text: (Name of (Owner of (Picked unit)))
          • Unit Group - Pick every unit in Tb_StunGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in Tb_AlreadyStunned[(Player number of (Owner of Tb_ReferenceUnit))]) Equal to False
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to Tb_AlreadyStunned[(Player number of (Owner of Tb_ReferenceUnit))]
                      • Set P2 = (Position of (Picked unit))
                      • Unit - Create 1 Boomerang Cast Dummy for (Owner of Tb_ReferenceUnit) at P facing Default building facing degrees
                      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                      • Unit - Order (Last created unit) to Neutral - Firebolt (Picked unit)
                      • Sound - Play BoomerangHit <gen> at 100.00% volume, located at P2 with Z offset 0.00
                      • -------- Unnecassary Stuff --------
                      • Set Tb_RandomInt = (Random integer number between 1 and 5)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 1
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Whap!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 2
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Smack!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 3
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Thwap!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 4
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Shmack!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 5
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Shwap!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
                      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                      • -------- ------------------------------------------ --------
                      • Custom script: call RemoveLocation(udg_P2)
                    • Else - Actions
                • Else - Actions
          • Custom script: call RemoveLocation(udg_P)
      • Unit Group - Pick every unit in Tb_BoomerangGroup2 and do (Actions)
        • Loop - Actions
          • Set P = (Position of (Picked unit))
          • Set Tb_ReferenceUnit = (Picked unit)
          • Set Tb_StunGroup = (Units within 250.00 of P matching (((Owner of (Matching unit)) is an enemy of (Owner of Tb_ReferenceUnit)) Equal to True))
          • Unit Group - Pick every unit in Tb_StunGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in Tb_AlreadyStunned[(Player number of (Owner of Tb_ReferenceUnit))]) Equal to False
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to Tb_AlreadyStunned[(Player number of (Owner of Tb_ReferenceUnit))]
                      • Set P2 = (Position of (Picked unit))
                      • Unit - Create 1 Boomerang Cast Dummy for (Owner of Tb_ReferenceUnit) at P facing Default building facing degrees
                      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                      • Unit - Order (Last created unit) to Neutral - Firebolt (Picked unit)
                      • Sound - Play BoomerangHit <gen> at 100.00% volume, located at P2 with Z offset 0.00
                      • -------- Unnecassary Stuff --------
                      • Set Tb_RandomInt = (Random integer number between 1 and 5)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 1
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Whap!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 2
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Smack!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 3
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Thwap!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 4
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Shmack!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Tb_RandomInt Equal to 5
                        • Then - Actions
                          • Floating Text - Create floating text that reads *Shwap!* at P2 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                        • Else - Actions
                      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
                      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                      • -------- ------------------------------------------ --------
                      • Custom script: call RemoveLocation(udg_P2)
                    • Else - Actions
                • Else - Actions
          • Custom script: call RemoveLocation(udg_P)
Of course I know this leaks in a few places and that it can be optimized a bit, but that's besides the point and not helping. I need to know why it only works right for player 1.


Heres the spell map itself
 

Attachments

  • Tracer Boomerang.w3x
    48.4 KB · Views: 32
Level 9
Joined
Nov 4, 2007
Messages
931
Increase the size of your arrays to incorporate more players, I raised all of their sizes to 2 instead of 1 and it worked... but its your map so decide which ones need to be raised and which ones don't really need to, my eyes hurt after trying to understand your trigger so I didn't figure out which array was causing it, but at least you'll know the problem is in those variables and their size.
 
Well i cant help you but i really need to say it was a epic spell dude! But you NEED to remove the "slow" things that is created behind the tracer when the spell has been cast :)

Well those spell things are used to show the path of the boomerang - if their lagging up your computer I can choose a less busy model are perhaps place them at less intervals

Increase the size of your arrays to incorporate more players, I raised all of their sizes to 2 instead of 1 and it worked... but its your map so decide which ones need to be raised and which ones don't really need to, my eyes hurt after trying to understand your trigger so I didn't figure out which array was causing it, but at least you'll know the problem is in those variables and their size.

Exactly what are you talking about? I used a hash table for most of the array like functions but I could try your suggestion if I understand what your trying to say a bit better
 
Level 9
Joined
Nov 4, 2007
Messages
931
The size of all your variable arrays are 1, I raised them up to 2, such as your Unit Group Array variable Tb_AlreadyStunned had a size of 1, I raised it to 2, did that with all the arrays and the boomerang worked for both players.
 
Level 9
Joined
Nov 4, 2007
Messages
931
I don't really have an explanation, I was just fed up with attempting to find what was player specific in your triggers, and instead tried to find if there was something player specific in your variables, leaving the size to 1 just seemed to be the root cause at the moment so I raised em all, and voila (can't do the accent on the a) it worked... like a peanut, like a peanut.
 
Level 13
Joined
Mar 16, 2008
Messages
941
To explain it:
Arrays ALWAYS have a size of 8192, no matter what you do.
The number you insert in the GUI-window is how many of those indizes will be initialized. For most variables thats unimportant, but if you use groups to keep track of units, only the first will be initialized, the same for timers... so you need this number.
 
Status
Not open for further replies.
Top