• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

RPG left/uncontrolled players control system

Status
Not open for further replies.
Level 2
Joined
Jan 4, 2010
Messages
15
Hello everyone!

I'm working on my programing skills and I can't find the solution to one of my problems. Here is what I want to do:

The map would be a RPG. There can be 6 players (red, orange, yellow, blue, purple and green). When there is only one player, that player gets kicked (no problem until now).

When there are two players, the system must check who are the actual players and for each of them, give control of 2 other uncontrolled players (at random I guess, but of course they must not control the same players). For example, if red and blue are playing, red gets control of green and yellow, blue gets control of orange and purple. I have no idea how I can do that, or I do but it's gonna be a huge mess of if then else if then else if then else... And I'm sure there must be a better way.

When there are 3 players, each of them gets control of another uncontrolled player, so the system is similar to the one before.

Nothing happens when there are 4 or more players (well... no problem with that part of course).

If anyone has a clue about the way I must solve this... Please tell me ;)

Thank you for your answers people! :)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
When there is only one player, that player gets kicked (no problem until now).
Why? It seems a bit random that you do this yet allow 2 people to play without kicking them.

If the game is single player custom (where you can cheat) then kick them.
If the game is multiplayer but with only 1 player, then give him control of all other heroes. You cannot cheat in multiplayer, even if you are alone.

When there are two players, the system must check who are the actual players and for each of them, give control of 2 other uncontrolled players (at random I guess, but of course they must not control the same players). For example, if red and blue are playing, red gets control of green and yellow, blue gets control of orange and purple. I have no idea how I can do that, or I do but it's gonna be a huge mess of if then else if then else if then else... And I'm sure there must be a better way.
Give all active players control over all players who are not playing. Let them decide who controls what hero rather than them being assigned one randomly. This also solves the 4 and 5 player problem as then there is 2 or 1 hero that is shared between all active players fairly.

Control is an alliance setting. You do not need mutual control, only for the non-playing/left player to treat all players who are playing with control. You may even want full unit control so they can spend their resources and things.
 
Level 2
Joined
Jan 4, 2010
Messages
15
Good idea, but how do you check that the player is playing alone in lan and not in single player?

About the sharing system, what's the best way to do that?

The only way I know is by the if conditions. Something like that:

If 2 players
Then
{ if player 1 is real
then
{if player 2 isn't real, give control
if player 3 isn't real, give control
etc.}
else
{ if player 2 is real...

dafuq, I'm sure I need to find a better way :/ my programing skills aren't good enough for this yet...
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Good idea, but how do you check that the player is playing alone in lan and not in single player?
You can do this with game caches:
  • Custom script : set udg_SinglePlayerMode = ReloadGameCachesFromDisk()
(I got this trigger from Almia)
This will set the boolean variable "SinglePlayerMode" to true if the player is playing in single player, and to false if the player is playing LAN / on b.net.

Kicking players while they cannot cheat (LAN/b.net) is indeed a bit harsh.
Personally, I really enjoy it when a map has a single-player mode (custom game only), where you cannot save, but have extra stuff (like infinite repicks, commands to teleport anywhere you like, or get experience) as a means to test the map.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
A player group acts as a container for many player. You can loop through all players in a player group (like you can with unit groups) and then do an action.

You can also nest those loops (which is what you want to do here).

For every player who is not playing then...
For every player who is playing then...
Get picked player who is not playing to treat picked player who is playing as shared with full control.
Get picked player who is playing to treat picked player who is not playing as shared vision.
 
Level 2
Joined
Jan 4, 2010
Messages
15
Thank you both for your answers!

I have a problem with the for loop: I can only use integers, which give "for every integer A, then..."

How can I use something else than a simple integer? :/
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
A player group loop can be found under the action type "Player Group".
It is called "Pick every player in group and do multiple actions"
  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked player) slot status) Equal to Is playing
        • Then - Actions
        • Else - Actions
Though an integer-loop would also work (convert the integer to a player with "Conversion - Convert player index to player").
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player((Integer A))) slot status) Equal to Is playing
        • Then - Actions
        • Else - Actions
 
Status
Not open for further replies.
Top