• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is there a more efficient way of selecting all players?

Status
Not open for further replies.
Level 4
Joined
Nov 6, 2011
Messages
44
So I have this:
  • Alliance Win
    • Events
      • Unit - The Scourge Core 0073 <gen> Dies
    • Conditions
    • Actions
      • Camera - Shake the camera for Player 1 (Red) with magnitude 15.00
      • Camera - Shake the camera for Player 2 (Blue) with magnitude 15.00
      • Camera - Shake the camera for Player 3 (Teal) with magnitude 15.00
      • Camera - Shake the camera for Player 4 (Purple) with magnitude 15.00
      • Camera - Shake the camera for Player 5 (Yellow) with magnitude 15.00
      • Camera - Shake the camera for Player 6 (Orange) with magnitude 15.00
      • Camera - Shake the camera for Player 7 (Green) with magnitude 15.00
      • Camera - Shake the camera for Player 8 (Pink) with magnitude 15.00
      • Camera - Shake the camera for Player 9 (Gray) with magnitude 15.00
      • Camera - Shake the camera for Player 10 (Light Blue) with magnitude 15.00
      • Camera - Shake the camera for Player 11 (Dark Green) with magnitude 15.00
      • Camera - Shake the camera for Player 12 (Brown) with magnitude 15.00
      • Wait 3.00 seconds
      • Camera - Stop swaying/shaking the camera for Player 1 (Red)
      • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
Creating an action to shake the camera for each Player is sorta time-consuming(In my opinion), is there a way to select all the players instead of making one action for each of them?

Thanks :)
 
Level 4
Joined
Nov 6, 2011
Messages
44
Thank you.

Edit: Waiiit.
I did this:

  • Alliance Win
    • Events
      • Unit - The Scourge Core 0073 <gen> Dies
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
      • Camera - Shake the camera for (Picked player) with magnitude 15.00
      • Wait 3.00 seconds
      • Camera - Stop swaying/shaking the camera for (Picked player)
      • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
Am I doing it wrong? Because it doesn't seem to be working.
Sorry if I made an obvious mistake, because I'm new... -ish in triggers.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
This is how it should look like

  • Alliance Win
    • Events
      • Unit - The Scourge Core 0073 <gen> Dies
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Camera - Shake the camera for (Picked player) with magnitude 15.00
      • Wait 3.00 seconds
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Camera - Stop swaying/shaking the camera for (Picked player)
      • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
NOTE:
1. You should never use Wait action inside a loop.
2. You should put the Shaking Camera Action inside a loop (like I did) not outside the loop (like you did)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
1. You should never use Wait action inside a loop.
You can put TriggerSleepAction inside a loop/endloop block and it will do nothing more than cause a delay in execution every time the loop reaches that point in the code. This is useful for loops that could hit the op limit but are not time critical (such as setting up a map during an introduction).

Using TriggerSleepAction in any enumeration function causes an immediate thread crash. This is because they are designed that the function they run returns immediatly (which it can not if TriggerSleepAction is used).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
You can put TriggerSleepAction inside a loop/endloop block and it will do nothing more than cause a delay in execution every time the loop reaches that point in the code. This is useful for loops that could hit the oplimit but are not time critical (such as setting up a map during an introduction).

Using TriggerSleepAction in any enumeration function causes an immediate thread crash. This is because they are designed that the function they run returns immediatly (which it can not if TriggerSleepAction is used).
It is not dangerous at all to use. It will eithor work (you place it in a loop/endloop block) or it will cause the execution thread to crash and no more script to run after the call (if you place it in an enumeration function). These are absolutes with no risk involved.

There is a slight risk with the actual mechanics of TriggerSleepAction that can cause the delay to expire prematurly (as if all calls were passed a timeout of 0). This happens very randomly and I have only ever had it occur noticably twice (both in sessions of different versions of DBZ tribute). The cause of this is completly unknown.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
There is a difference between a native being dangerous, being poor practice and being used badly.

Examples of dangerous Natives
GetLocalPlayer() // returns the player that the client is in control (asyncrnious player). can cause splits
DestroyTrigger(trigger) // stability problem if an attached event is in an incorrect internal state. can cause game crashes

Examples of natives that are bad practice to use
TriggerSleepAction(real) // wait period is inconsistent and can vary depending on sessions. occassionally bugs so all wait is ignored (always waits 0)
DestroyGroup(group) // outside of using a group as an instance variable, this should never be used as a single group can be recycled for most purposes.

Example of bad usage
TriggerSleepAction() in a function that is not thread safe.
DestroyGroup() on an already destroyed group
GetLocalPlayer() as the target owner of a unit (will split multiplayer session into single players).
 
Status
Not open for further replies.
Top