HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Wait trigger in multiplayer??

09-03-2002, 07:00 AM#1
Guest
Ok, what's the deal with "wait" in multiplayer. I have heard that there is a bug with it. My questions are: What exactly happens when you try to use wait in multiplayer? What is the correct way to wait in multiplayer?

My last question is related to my specific situation. I want to be able to wait until a hero is revived.

Ex.:
- A hero dies
- Wait 30 seconds
- Revive the hero

Here is my exact code:
Events: Unit - A unit owned by Player 1 (Red) Dies
Actions: Wait 30.00 seconds
Hero - Instantly revive (Dying unit) at (Owner of (Dying unit)) start location), Show revival graphics


How would I translate this into "multiplayer code?"
09-03-2002, 03:48 PM#2
Guest
Would my original way do the job?
09-03-2002, 04:32 PM#3
Guest
I spent some time lookin for a good explanation in a previous post but didn't find one quickly, so I'll do my best to explain it again.

There is a bug with ALL delays in multiplayer. To overcome this you need to send a wait to each player.

First you need to know how many players are actually playing. I use the variable; (integer) NumPlayers. You could set it during map initialization. Then you need to be sure that you reduce the value of NumPlayers whenever a player leaves the game.

Whenever you need a wait in a multiplayer game, use:

For each (Integer A) from 1 to NumPlayers, do (wait X seconds)

There are still a few problems that you need to be aware of:
- Transmissions should be set to "Dont Wait", instead use the wait method above.
- Don't Use the "Wait for last played sound to be finnished", instead use the wait method above for the duration of that sound.
- Inside Multiplayer Cinematics, this method is NOT reliable, instead use one-shot timers whenever possible.
- Whenever Blizzard decides to fix this "bug" the delays will become too long.

I'd recommend making your map easy to change the NumPlayers value to a constant '1' after that fix, so you wont have too much of a headache to adjust your map to work correctly then. (Plan ahead)
09-03-2002, 04:34 PM#4
Guest
ok, thx man. I'll try that.
09-03-2002, 04:49 PM#5
Guest
I tried what you said, but i used this method

pick every player in (player controller is user) do if (picked player slot status is playing) then Wait 5secs else do nothing.

now, when i play it single player, it doesn't wait at all. is this because maybe it doesn't consider me a user since it's not on multiplayer? will it work in multiplayer?
09-03-2002, 05:00 PM#6
Guest
Quote:
Originally posted by TheMega
I tried what you said, but i used this method

pick every player in (player controller is user) do if (picked player slot status is playing) then Wait 5secs else do nothing.

now, when i play it single player, it doesn't wait at all. is this because maybe it doesn't consider me a user since it's not on multiplayer? will it work in multiplayer?

I honestly don't know, without making a test map to find out.

You may want to use the (integer) NumPlayers because doing the "pick every player" uses quite a bit of cpu time and may contribue to lag (dunno). You seem to be on the right track though.
09-03-2002, 05:01 PM#7
Guest
k, thx again
09-03-2002, 05:42 PM#8
Guest
Quote:
pick every player in (player controller is user) do if (picked player slot status is playing) then Wait 5secs else do nothing.

That's NOT what he said to do. Pick player isn't doing ANYTHING for you here because your action is not effecting the picked player. You are saying, Pick players and wait 5 seconds, not Pick players and wait 5 seconds for ever player picked (which you can't really do).

At the start of your game, set a variable for the number of players playing (using a For Loop to check the status and increase the variable) and then Run a For Loop for 1 to the variable with a wait for your action.
09-04-2002, 12:22 AM#9
Guest
I posted a little tutorial on an alternate way to do wait triggers for each player. Basically, it runs along the same lines as the old "custom counter" trick in StarEdit. It doesn't actually use "Wait" triggers at all, but it accomplishes the same effect (and is perhaps more versatile as well.)

Just be warned - it's more complex than a straightforward wait trigger (it uses 5 triggers and 2 variable arrays.)

Here ya go...
Multiple wait triggers
Hope that helps ^_^