HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Victory/defeat seem to happen randomly

04-17-2009, 09:27 PM#1
flatleyld
My map is almost a typical melee map but at the end of 15 minutes all players are transported to an area where a fight to the death occurs. Each time a unit dies a variable and leader board that count the units for a player is updated for that player. When that variable hits 0 it should display defeat for that player. If all other players variable is 0, the the remaining player is the winner. My game, at random it seems like, just chooses the winner. Mostly player 1. And this is all before the timer is even run out. I should mention that before the timer runs out, all units are allys and can't attack each other. Here are my defeat and victory triggers for player 1. They would be the same for all other players just substitute.

Trigger:
P1WinDef
Events
Conditions
Collapse Actions
Set P1count = (Number of units in (Units owned by Player 1 (Red)))
If (P1count Equal to 0) then do (Game - Defeat Player 1 (Red) with the message: Defeat!) else do (Do nothing)

Trigger:
VictoryP1
Events
Collapse Conditions
Collapse And - All (Conditions) are true
Collapse Conditions
P2count Equal to 0
P3count Equal to 0
P4count Equal to 0
P5count Equal to 0
P6count Equal to 0
P7count Equal to 0
P8count Equal to 0
Collapse Actions
Game - Victory Player 1 (Red) (Show dialogs, Show scores)
04-17-2009, 09:43 PM#2
Michael Peppers
I bet the issue is caused by: "(Number of units in (Units owned by Player 1 (Red)))"
It always caused such problems for me.

A boolean variable checking this: "(All Units of (Units owned by Player 1 (Red)) are dead)" would work better, so...

Try this, it's my Victory Defeat trigger, tweaked for the purpose...

Trigger:
Victory Defeat
Collapse Events
Unit - A unit dies
Collapse Conditions
((Owner of (Dying unit)) slot status) Equal to In Game
(All Units of (Units owned by (Owner of (Dying unit))) are dead) Equal to True
(Owner of (Dying unit)) different from Neutral-hostile
Collapse Actions
Game - Defeat (Owner of (Dying unit)) with the message: Defeat!
Game - Display to (All players controlled by an User player) the text: ((Name of (Owner of (Dying unit))) + has been defeated.)
Wait 2.00 seconds
Collapse Player Group - Pick Every Player in (All Players matching (((Matching player) Slot status) Equal to In Game)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are true) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of players in (All players Matching ((((Matching player) is an enemy of (Picked player)) Equal to True) and (((Matching Player) slot status) Equal to In Game)))) Equal to 0
Collapse Then - Actions
Game - Victory (Picked player) (Show dialogs, Show scores)
Collapse Else - Actions
Do Nothing
1. Just copy it and make it "Initially disabled", when the timer you're talking about expires, do:

Trigger:
Timer Expires
Collapse Events
YourTimer expires
Conditions
Collapse Actions
Trigger - Turn On Victory Defeat

2. Or you could use this (when the timer expires):
Trigger:
Timer Expires
Collapse Events
YourTimer expires
Conditions
Collapse Actions
Set TimerExpired = True

And add this condition to the Victory/Defeat trigger:
Trigger:
Victory Defeat
Collapse Conditions
TimerExpired Equal to True

Let me know if it works! Meh, one of the two options will work for sure :P

Last thing, if you find a simpler way than mine to code a Victory Defeat trigger, feel free to smash my head xD
04-18-2009, 06:18 PM#3
flatleyld
Well I tried out your triggers and so far they seem to be working. My problem now is that everyone but the host lags and eventually will disconnect (LAN and B.net). I've got a few things to try with the triggers to see if I can resolve the disconnects.
04-18-2009, 08:23 PM#4
Michael Peppers
Quote:
Originally Posted by flatleyld
Well I tried out your triggers and so far they seem to be working. My problem now is that everyone but the host lags and eventually will disconnect (LAN and B.net). I've got a few things to try with the triggers to see if I can resolve the disconnects.

When does the problem occur? At the start of the game or when the players are transported? Is it caused by my trigger?

If you need help, post the code of the triggers that are running when lag happens and I'll be glad to help you.

If it's caused by my trigger, try removing the wait or using "Wait (Game-Time)".
04-20-2009, 08:09 PM#5
flatleyld
The problem doesn't happen at a specific time. It's during the timer counting down. The host is fine, but the joined players' game lags every few seconds. There's no set time. Eventually it just will disconnect. So I'm not sure which code is causing the lag. I assume it's the code where the time is, but it's been fine ever since I started this map, and it's been unchanged. I'll try it out tonight again and let you know.