HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Last man standing trigger? =/

12-22-2003, 08:14 AM#1
Peacerich
I'm making a "arena-map" where you pick a group of custom units and fight against 6 other players in an arena. I made triggers so when a players units in arena reaches 0 he will be messaged and stuff on leaderboard. But how do i make the trigger like "if only player 1 red has units left in arena, start next round" ?

I know this might be a nooby question, im not that good on triggers:(

plz reply as fast as u can
12-22-2003, 09:16 AM#2
GabeStah
Well, there's a few ways you can do this, but I think using a counter variable is probably the most efficient as far as processing power, so hopefully this'll work (only thing I might have incorrect is the area in the third trigger where it says "(Dying unit)" may need to be "(Matching Unit)". I'm not totally sure on that, as I don't have time to test it right now, so if you have issues try changing that part and it should work fine. Also, I'm assuming here that all players are human, but if some are computer, use the line that is commented out in the first trigger in place of the one above it, and the same for the similar line in the third trigger.

Anyhow, here you go, it's three triggers:

This one simply creates your counting variable to keep track of the player's left in the battle arena.

Code:
trigPlayer Setup
    Events
        Map initialization
    Conditions
    Actions
        Set var_intHumanPlayerCount = (Number of players in (All players controlled by a User player))
        // Set var_intHumanPlayerCount = (((Number of players in (All players controlled by a Computer player)) + (Number of players in (All players controlled by a User player))) + 1)

This one assures your triggers don't get messed up if someone leaves in the middle of the game.
Code:
trigPlayer Leaves
    Events
        Player - Player 1 (Red) leaves the game
        Player - Player 2 (Blue) leaves the game
        Player - Player 3 (Teal) leaves the game
        Player - Player 4 (Purple) leaves the game
        Player - Player 5 (Yellow) leaves the game
        Player - Player 6 (Orange) leaves the game
        Player - Player 7 (Green) leaves the game
    Conditions
    Actions
        Set var_intHumanPlayerCount = (var_intHumanPlayerCount - 1)

This one checks every time a unit dies, whether that unit is the last remaining unit owned by any given player within the region (Region 000 will of course be your arena play area or what not), and if so, removes one (1) from our Player Counter, until it reaches one (1) total (meaning only one person is left standing) then resets the Player Counter and gives a message for the next round. You'll of course want to insert any additional code for activating the actual round.

Code:
trigUnits Remaining Check
    Events
        Unit - A unit Dies
    Conditions
        Or - Any (Conditions) are true
            Conditions
                ((Units owned by Player 1 (Red) matching ((Region 000 <gen> contains (Dying unit)) Equal to True)) is empty) Equal to True
                ((Units owned by Player 2 (Blue) matching ((Region 000 <gen> contains (Dying unit)) Equal to True)) is empty) Equal to True
                ((Units owned by Player 3 (Teal) matching ((Region 000 <gen> contains (Dying unit)) Equal to True)) is empty) Equal to True
                ((Units owned by Player 4 (Purple) matching ((Region 000 <gen> contains (Dying unit)) Equal to True)) is empty) Equal to True
                ((Units owned by Player 5 (Yellow) matching ((Region 000 <gen> contains (Dying unit)) Equal to True)) is empty) Equal to True
                ((Units owned by Player 6 (Orange) matching ((Region 000 <gen> contains (Dying unit)) Equal to True)) is empty) Equal to True
                ((Units owned by Player 7 (Green) matching ((Region 000 <gen> contains (Dying unit)) Equal to True)) is empty) Equal to True
    Actions
        Set var_intHumanPlayerCount = (var_intHumanPlayerCount - 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                var_intHumanPlayerCount Equal to 1
            Then - Actions
                Set var_intCurrentRound = (var_intCurrentRound + 1)
                Game - Display to (All players) the text: (Round  + ((String(var_intCurrentRound)) +  will be starting in 30 seconds!))
                Set var_intHumanPlayerCount = (Number of players in (All players controlled by a User player))
                // Set var_intHumanPlayerCount = (((Number of players in (All players controlled by a Computer player)) + (Number of players in (All players controlled by a User player))) + 1)
            Else - Actions
                Do nothing

Hope that helps, if not please let me know. Sorry if there's any grammar or spelling mistakes here, it's late =(

-GabeStah-
12-22-2003, 01:42 PM#3
Peacerich
wow thx alot dude, i was though it was like 1000x simpler than that, but ill try it. If it works i guess u can have a small credit in the end:D
12-22-2003, 02:49 PM#4
Peacerich
lol ive searched for the "units owned by player matching (region contains dying unit") - trigger for 20 min now. Cant find it lol... cud u tell me whetever its in unit comparison/integet/player comparison etc... ill keep searching, i edit this post if i find it

plz

edit: Ok... now i looked back through my own simple script, and i think i noticed a 200% easier way of making this....

event: number of living units in arena owned by random player in unit group (all players) equal to 0

actions: set var_players to var_players - 1

TRIGGER no 2:

event: var_players = 1

actions: start next round

shudnt that work?