• 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.

[Trigger] Sounds wont run a second time?

Status
Not open for further replies.
Level 17
Joined
Jun 12, 2007
Messages
1,261
I made a trigger for a rematch system in a mini game I made as it's pretty short.
The first time the trigger runs the sounds play fine.

Now, the second time it wont run the sounds!
Is this because I destroyed the sounds?

  • Start
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Camera - Set the camera bounds for (Player((Integer A))) to Z Play <gen>
      • Trigger - Turn off (This trigger)
      • Sound - Play ArrangedTeamInvitation <gen>
      • Set Sound[1] = (Last played sound)
      • Game - Display to (All players) the text: (PlayerColor[13] + Prepare yourselves!)
      • Wait 3.00 seconds
      • Sound - Play BattleNetTick <gen>
      • Set Sound[2] = (Last played sound)
      • Game - Display to (All players) the text: (PlayerColor[13] + Ready....)
      • Wait 3.00 seconds
      • Sound - Play BattleNetTick <gen>
      • Set Sound[3] = (Last played sound)
      • Game - Display to (All players) the text: (PlayerColor[13] + Set....)
      • Wait 3.00 seconds
      • Sound - Play ClanInvitation <gen>
      • Set Sound[4] = (Last played sound)
      • Game - Display to (All players) the text: (PlayerColor[13] + GO!)
      • Trigger - Run Multiboard <gen> (ignoring conditions)
      • Trigger - Turn on Tips <gen>
      • Trigger - Turn on Tips Off <gen>
      • Trigger - Turn on Tips On <gen>
      • Trigger - Turn on Item Crystal Spawn <gen>
      • For each (Integer A) from 1 to PlayersAlive, do (Actions)
        • Loop - Actions
          • Set ItemPoint = (Random point in The Pit <gen>)
          • Special Effect - Create a special effect at ItemPoint using AImaTarget.mdx
          • Special Effect - Destroy (Last created special effect)
          • Item - Create SpawnItem[(Random integer number between 1 and 23)] at ItemPoint
          • Custom script: call RemoveLocation(udg_ItemPoint)
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Sound - Destroy Sound[(Integer A)]
      • Wait 2.00 seconds
      • Trigger - Turn on Golem Left Is 1 <gen>
      • Trigger - Turn on Create <gen>
      • Trigger - Turn on Increase <gen>
The trigger is btw activated by an other trigger so don't even dare saying it has no event.
 
Level 11
Joined
Mar 31, 2009
Messages
732
Can you post the other trigger that is calling this one so I can check for segfaults (type mismatches, index out of bounds, things that make wc3 just stop running your trigger without telling you).

I'm not sure how Sounds work myself, but since you appear to be just using common sound setting methods, its more likely the trigger isn't getting called the second time.

Otherwise, put in some debugging messages "Display to all players the text blah" to see if the trigger gets run properly, put it in a few places in your trigger to make sure they're all run. If one gets skipped, then you're getting a segfault.
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
I haven't made the into yet lol. :p
  • Intro
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Trigger - Run Start <gen> (ignoring conditions)
The second time it runs however you get this trigger.
  • Place Winner
    • Events
    • Conditions
    • Actions
      • Set ItemPoint = (Center of Winner <gen>)
      • Cinematic - Turn cinematic mode On for (All players)
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Camera - Reset camera for (Player((Integer A))) to standard game-view over 0.00 seconds
          • Camera - Pan camera for (Player((Integer A))) to ItemPoint over 0.10 seconds
      • Wait 0.30 seconds
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Camera - Set the camera bounds for (Player((Integer A))) to Z Win <gen>
      • Unit - Create 1 Crystal Golem for (Player(WinningPlayer)) at ItemPoint facing 270.00 degrees
      • Game - Display to (All players) the text: (PlayerColor[10] + And our winner is....)
      • Wait 1.05 seconds
      • Cinematic - Hide filter
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Camera - Rotate camera 360.00 degrees around ItemPoint for (Player((Integer A))) over 10.00 seconds
      • Wait 3.00 seconds
      • Game - Display to (All players) the text: (PlayerColor[(Player number of (Player(WinningPlayer)))] + ((Name of (Player(WinningPlayer))) + ( with a stunning + ((String(HighestInteger)) + points!))))
      • Custom script: call RemoveLocation(udg_ItemPoint)
      • Wait 7.00 seconds
      • Cinematic - Turn cinematic mode Off for (All players)
      • Game - Display to (All players) the text: (PlayerColor[13] + A rematch will start in 10 seconds.)
      • Wait 10.00 seconds
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Camera - Reset camera for (Player((Integer A))) to standard game-view over 0.00 seconds
          • Camera - Set the camera bounds for (Player((Integer A))) to (Entire map)
      • Wait 0.30 seconds
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Camera - Pan camera for (Player((Integer A))) to PlayerPoint[9] over 0.10 seconds
      • Wait 0.30 seconds
      • Trigger - Run Start <gen> (ignoring conditions)
However, if I destroy a sound right after it played in the start trigger, it wont run a second time either.
My problem is, sounds leak. And I want to clean them. But they wont play after I cleaned them.

@ Ghostwolf, you destroy them because they leak. You destroy leaks. And sounds can run a lot and I hate leaks so there.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
God, stop thinking that everything in this world leaks.
Yes, this world is a big garbage, but it doesn't have such a bad bag.

It's the same as saying "oh, I have this global location which I need to use multiple times and yet I destroy it after one time, why doesn't it exist at the other times?"... just use your brain before you destroy things that don't need to be destroyed.

It's the same as happened in the previous thread.
What's better, this scheme:

Create Object every iteration
Destroy Object every iteration


Or this scheme:

Create Object once at the start of the game and forget it was ever created

Just think about it.
 
Level 11
Joined
Mar 31, 2009
Messages
732
God, stop being an ass every time you reply to me.

If you can't help me go away >.>
I clean leaks cause I don't want much lag ffs, don't you get that?

It's the same thing as coding the jass you use to be as effective as possible.

The nice version of his post:

You're using global variables for the sounds, so you don't need to clean the leaks (ie destroy the sounds), because they don't actually leak.

A leak is when a piece of memory that is no longer used by any piece of current or future code to be executed remains locked. This does not apply to global variables because they can continue to be used by any piece of code anywhere in your program now or when that trigger is executed.

Tl;dr version: Create the sound variable at map initialization. Destroy the sound variable before giving victory to a player*, not after playing the sound.




* Or not. Ceasing running of the map automatically frees up all memory the map used, leaked or not.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
It does apply to global variables too. Pretty obviously it does, because you can only use global variables in GUI.

It's pretty easy to detect and resolve leaks. Just ask yourself the question:
"Will I ever use this object again during the game".
If the answer is no, you have to clean the leak.
If the answer is yes, it's simply not a leak because you're going to be using it again.

Some examples:
Position of (triggering unit): As soon as I've used this location, I don't need it anymore, so it leaks. Got to fix the leak
Triggering player: I obviously want to keep the player in the game for the rest of the duration of the game. It doesn't leak and I don't need to call RemovePlayer()
A sound handle: I probably want to play this sound again every time I cast a certain spell. It doesn't leak, I don't have to remove it.
 
Status
Not open for further replies.
Top