Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Detect if player is in the game
Detect if player is in the game
Feb 8 2011, 12:02 am
By: iCCup.xboi209  

Feb 8 2011, 12:02 am iCCup.xboi209 Post #1



How do I detect if a player is in the game and if the player has left the game.(the player does not own any units or buildings)



None.

Feb 8 2011, 12:05 am poison_us Post #2

Back* from the grave

IIRC you simply run a trigger detecting if "Neutral" commands any units at anywhere. When players leave, their units go to Neutral, and thus you can set switches or DCs to keep track of what players are alive (by setting an initial DC, then checking to see if they still own units) if you want to detect who left, as well.

EDIT: The above assumes that people can't be alive with no units, either. Forgot to mention that, but I'd imagine you can think of a trigger to get around this fairly easily if you need to detect who is alive with no units.





Feb 8 2011, 12:06 am iCCup.xboi209 Post #3



Well what if they don't own any units



None.

Feb 8 2011, 12:11 am poison_us Post #4

Back* from the grave

To detect if the player's alive, period, have a trigger run for JUST that player, modifying a death count, and after that trigger (further down the list, but still in the same loop) have a trigger detecting if the death count is whatever you're setting it to. If the DC did not change, then the player left. Triggers do no run for inactive players.

Thus:
Code
Trigger("Player 1"){
Conditions:
    Always();

Actions:
    Set Deaths("Player 1", "Terran Marker", Set To, 1);
    Preserve Trigger();
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
    Deaths("Player 1", "Terran Marker", Exactly, 0);

Actions:
    Comment("Player is inactive.");
    Preserve Trigger();
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
    Deaths("Player 1", "Terran Marker", Exactly, 1);

Actions:
    Comment("Player is active.");
    Preserve Trigger();
    Set Deaths("Player 1", "Terran Marker", Set To, 0);
}

//-----------------------------------------------------------------//





Feb 8 2011, 12:12 am iCCup.xboi209 Post #5



ok



None.

Feb 8 2011, 12:57 am Vrael Post #6



That doesn't work because players who aren't in the game don't run triggers.

If you have a spare computer player, give the detection triggers to that player (as long as that computer is always in the game).

I usually use P8 for my computer player, and I set up a system like so:

Player 1:
Conditions:
Always;
Actions:
Set deaths for Current Player to 1 for Terran Marker;
Preserve Trigger;

Player 8:
Conditions:
Player 1 has Suffered exactly 0 deaths of Terran Marker;
Actions:
Set Switch "P1 is not in the game" SET;

Player 8:
Conditions:
Player 1 has suffered at least 1 deaths of Terran Marker;
Actions:
Set deaths for Player 1 to 0 for Terran Marker;
Preserve Trigger;

Since P1 triggers run before P8 triggers, if Player 1 is in the game he will set his death count to 1 before P8 can detect the 0. Then since P8 is the last player to have his triggers checked every trigger cycle, at the start of the next trigger cycle P1 will have 0 deaths of Terran Marker again. If P1 has left the game, his trigger won't run, so the DC will still be 0 and P8 will detect it. If P1 is still in the game, P1 will set his death to 1 again, and P8 will detect that P1 is in the game again.

Post has been edited 1 time(s), last time on Feb 8 2011, 1:04 am by Vrael.



None.

Feb 8 2011, 8:29 am Gigins Post #7



You don't need a computed player for player detection. Just run any king of trigger which actions you can detect for each player and store the information you gather in Deaths Counters for player 1. Player1 doesn't have to be in game to store death counters.

Triggers like create units, set deaths, bring unit will work.

Or just use switches. Have 8 of them cleared. And for each player make the first trigger to set his switch. All the set swithces indicate player in game, all cleared switches shows that there is no player.



None.

Feb 8 2011, 9:03 am rockz Post #8

ᴄʜᴇᴇsᴇ ɪᴛ!

When I tried to detect which player left, I think the only way I figured it would work is if I used player 8 computer by using vrael's method.

If you just want to know if a player is in the game at the start of the game, that's easy. set deaths to 1 for something, if the deaths as detected by another player are 0 for a player, that player did not start in the game. You further modify this by having the last triggers run by player 8 reset the "in game" DC to 0. However any sort of triggers which run off this information have to be run by player 8 if you do it that way.

the only truly flawless way would be to use binary countoffs I think, but that's a flaw in itself, due to "overkill".



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Feb 8 2011, 9:24 am Lanthanide Post #9



Gigins sort of method could be made to work, but I think it'd use a lot of triggers and is not very elegant. Using either player 1 or player 8 as a CPU an sentinel is much more straightforward and more likely to work without any hassles. I use in my Desert Strike map without issue.

An outline for how Gigin's one could work:
1. Each player owns a trigger that adds +1 to a death count for Current Player
2. Each player owns 7 triggers, one for each other player in the game, that says (for example P8's triggers 7 triggers are) "if current player DC at least 10 and Player 1/Player 2/Player 3/Player 4/Player 5/Player 6/Player 7 DC at least 1 and at most 9, then Player X must have left the game -> perform player X leave game action, set player X DC to 0"
3. Each player has a final trigger that if their DC is 10, set it back to 1.

So, for example:
Game starts with Player 3, Player 5, Player 7, Player 8.

Everything goes along happily, and no players have left so trigger #2 never fires, but trigger #1 and #3 keep firing. Then player 5 leaves the game when their DC count is 5. Everything goes along until player 3 has their DC incremented to 10, when they run trigger #2 for player 5 and determine that player 5 has left the game, so player 5 is cleaned up and their DC set to 0 - it now no longer increments past 0 because player 5 no longer runs triggers.

Things carry on as normal and player 7 and player 8 don't detect any players are missing because Player 3's trigger cycle already cleaned it up.

Eventually player 3 leaves when their DC is 7. Player 7 and 8 continue running until eventually player 7 runs trigger #2 and cleans player 3 up.

That's the general theory, it should work, but a bit messy. Reducing the threshold from 10 to a number like 2 or 3 would speed up leaver detection, I just used 10 for ease of comprehension.



None.

Feb 8 2011, 11:00 am Decency Post #10



...

Can't you just preplace an invulnerable unit for each player in an unused location of the map? Then run a trigger for a required player or computer (all players, if neither of the above is possible) making sure that each player owns a unit there. If a player doesn't, he's not in the game.

Preserve it to figure out if someone leaves, the unit will be given to Player 12.



None.

Feb 8 2011, 11:53 am Lanthanide Post #11



That works, if you want to have invincible units somewhere on the map providing vision and looking 'amateur'.



None.

Feb 8 2011, 12:20 pm Decency Post #12



Wouldn't bother me in the slightest to do either.

You could also just do it at the start and then remove them, removing both issues, though losing the leaver detection.



None.

Feb 8 2011, 5:35 pm rockz Post #13

ᴄʜᴇᴇsᴇ ɪᴛ!

This is why you just use some building somewhere which the player never loses control of.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
Please log in to shout.


Members Online: Roy