[Trigger] Is this trigger MUI?

Status
Not open for further replies.
Level 7
Joined
Sep 8, 2011
Messages
208
Hey guys, so I'm creating a heartbeat mechanic which kicks into effect when other players come within range of player ones unit (killer). The game is a 1v4, 1 killer vs 4 survivors.

The closer a survivor gets to the killer, the louder the heartbeats. I currently cannot test it with other players but I have been able to test it with myself (I gave player one a killer and a survivor) and it worked well. What I am wondering is if the trigger will be MUI.

Setting the variables and stuff is all fine and working, I just don't know if it will work for multiple people.

Example: Survivor 1 is within 400 units of the killer, the heartbeat should only play for the player who owns that survivor at 100% volume, survivor 2 is 800 units of the killer so the heartbeat should only be playing for him but at 65% volume.

Does the trigger below work correctly for different players?


Thanks. :)
  • Heartbeat Range
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Point[22] = (Position of Killer)
      • For each (Integer A) from 23 to 26, do (Actions)
        • Loop - Actions
          • Set Temp_Point[(Integer A)] = (Position of Survivors[((Integer A) - 22)])
          • Set Temp_Player = (Owner of Survivors[((Integer A) - 22)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Temp_Point[22] and Temp_Point[(Integer A)]) Less than or equal to 400.00
            • Then - Actions
              • Custom script: if GetLocalPlayer() == udg_Temp_Player then
              • Sound - Set volume of (Last played sound) to 100.00%
              • Custom script: endif
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Temp_Point[22] and Temp_Point[(Integer A)]) Less than or equal to 600.00
                • Then - Actions
                  • Custom script: if GetLocalPlayer() == udg_Temp_Player then
                  • Sound - Set volume of (Last played sound) to 85.00%
                  • Custom script: endif
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Temp_Point[22] and Temp_Point[(Integer A)]) Less than or equal to 800.00
                    • Then - Actions
                      • Custom script: if GetLocalPlayer() == udg_Temp_Player then
                      • Sound - Set volume of (Last played sound) to 65.00%
                      • Custom script: endif
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Distance between Temp_Point[22] and Temp_Point[(Integer A)]) Less than or equal to 1000.00
                        • Then - Actions
                          • Custom script: if GetLocalPlayer() == udg_Temp_Player then
                          • Sound - Play HeartBeat
                          • Sound - Set volume of (Last played sound) to 45.00%
                          • Custom script: endif
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Distance between Temp_Point[22] and Temp_Point[(Integer A)]) Greater than or equal to 1001.00
                            • Then - Actions
                              • Custom script: if GetLocalPlayer() == udg_Temp_Player then
                              • Sound - Stop HeartBeat Immediately
                              • Custom script: endif
                            • Else - Actions
 
You've done it properly, but there are three things to note:
  • Your second to last if block checks if <= 1000 and your last if-block checks if >= 1001. So if the unit is 1000.50 away from the killer it won't play a sound! Change the last one to "> 1000.00"
  • You're referring to "last played sound", which could and will get messed up if you play any other sound via triggers. When you first play the heartbeat sound save it into a sound-type variable and then modify the volume of THAT variable instead of "last played sound".
  • You're leaking the points, so you need to clean them up after you're done with each of them: Temp_Point[(Integer A)] at the end of the loop and Temp_Point[22] after the loop. There are some leak fixing tutorials you should easily be able to find.
Why are you using such weird indices of Temp_Point and looping from 23 to 26? There's no need for that because you don't need to keep the Temp_Point locations stored any longer than this trigger takes to use them, and there are no waits. Nothing is going to get overwritten.

Instead of "Integer A/B" loops it's generally better to use your own loop counter variable: "For each integer <VARIABLE>..."
 
Last edited:
You've done it properly, but there are two things to note:
  • Your second to last if block checks if <= 1000 and your last if-block checks if >= 1001. So if the unit is 1000.50 away from the killer it won't play a sound! Change the last one to "> 1000.00"
  • You're referring to "last played sound", which could and will get messed up if you play any other sound via triggers. When you first play the heartbeat sound save it into a sound-type variable and then modify the volume of THAT variable instead of "last played sound".
Oh I didn't know that would happen with the range. I'll put heartbeat sound var into an array and use it like that. Thanks for the help! :)
 
I use temp point a LOT, each time I use a temp point for something, I increase what position in the array it is, this is so I can use temp point in many triggers with out having to create brand new temp point vars. I do this so if there ever is a case where temp point is used twice at the same time, it will never use the same index array because I choose a different array index each time I use it.

Also, is it more efficient using a variable loop instead of the A/B?

Lastly, that was the one thing I kept forgetting to do, clean the leaks -.- lol I'm usually good at being on top of that.
 
No two triggers can execute simultaneously; as I am aware it's a limitation built into the wc3 engine that even applies to things like ExecuteFunc(). Even if it was possible for simultaneous code in wc3, long triggers run in tiny fractions of a second so the chance of any two things happening at the same time would be absolutely miniscule.

If a trigger has 0 waits in it it is impossible for any other trigger to overwrite its data while its running. Most maps don't need more than 2 or 3 TempPoints/TempUnits/TempGroups. If you are doing something with a wait or need to keep the variable around for longer than the lifetime of the trigger instance, then its better to create a one-off variable for specifically that purpose.
 
No two triggers can execute simultaneously; as I am aware it's a limitation built into the wc3 engine that even applies to things like ExecuteFunc(). Even if it was possible for simultaneous code in wc3, long triggers run in tiny fractions of a second so the chance of any two things happening at the same time would be absolutely miniscule.

If a trigger has 0 waits in it it is impossible for any other trigger to overwrite its data while its running. Most maps don't need more than 2 or 3 TempPoints/TempUnits/TempGroups. If you are doing something with a wait or need to keep the variable around for longer than the lifetime of the trigger instance, then its better to create a one-off variable for specifically that purpose.

I never knew that, I'll keep that in mind thanks!
 
Triggers can't run simultaneously, but they can be briefly "paused" if they fire an event from another trigger. For example, dealing damage to a unit and killing them will briefly pause your loop and run any trigger that has those events. Another example would be creating units that enter a region.
Oh Interesting, I didn't know GUI acted like that.
 
Status
Not open for further replies.
Back
Top