Page 1 of 1

in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 07 October 2021, 06:00
by developgame
Hi everyone, another newbie question here:
I am developing , Escape the curse of the temple, a realtime game, where all players are playing simultaneously.
In the game, after every player action in state 'playerTurn' the game goes back to state 'loadMusic'
occasionally, a player gains a curse from an action in 'playerTurn' state.
then state 'addressCurse' should only be triggered for the player that got the curse while the other players are still simultaneously doing 'playerTurn' state actions. I do not know how to do this.
In my game, it is triggered for all players.

here are my game states

Code: Select all

	2 => array(
    		"name" => "loadMusic",
    		"description" => "",
    		"type" => "game",
    		"action" => "stLoadMusic",
    		"transitions" => array( "playerTurn" => 6 )
    ),

    6 => array(
    		"name" => "playerTurn",
    		"description" => clienttranslate(''),
    		"descriptionmyturn" => clienttranslate('${you} may choose an action or surrender to fate'),
    		"type" => "multipleactiveplayer",
            "action" => "st_MultiPlayerInit",
    		"possibleactions" => array( "confirmAction","reRollDice","discoverChamber",
				"activateGem", "removeBlackMask", "moveChamber", "turnFate", "escape", "giveDie", 
				"addressCurse", "loadMusic", "endPeriod", "gameEnd"),
    		"transitions" => array(  "loadMusic" => 2, "addressCurse"=> 7, "turnFate" => 11, "players_win" => 12, "gameEnd" => 99 ), 
			'action' => 'st_MultiPlayerInit'
    ),
	
	7 => array(
    		"name" => "addressCurse",
    		"description" => clienttranslate(''),
    		"descriptionmyturn" => clienttranslate('${you} must select a die to remove'),
    		"type" => "multipleactiveplayer",
			"possibleactions" => array( "confirmResponse","loadMusic", "pass" ),			
    		"transitions" => array( "loadMusic" => 2 )
    ),

Thank you for any help and advice

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 07 October 2021, 06:15
by Tisaac
developgame wrote: 07 October 2021, 06:00 Hi everyone, another newbie question here:
I am developing , Escape the curse of the temple, a realtime game, where all players are playing simultaneously.
In the game, after every player action in state 'playerTurn' the game goes back to state 'loadMusic'
occasionally, a player gains a curse from an action in 'playerTurn' state.
then state 'addressCurse' should only be triggered for the player that got the curse while the other players are still simultaneously doing 'playerTurn actions. I do not know how to do this.
In my game, it is triggered for all players.

here are my game states

Code: Select all

	2 => array(
    		"name" => "loadMusic",
    		"description" => "",
    		"type" => "game",
    		"action" => "stLoadMusic",
    		"transitions" => array( "playerTurn" => 6 )
    ),

    6 => array(
    		"name" => "playerTurn",
    		"description" => clienttranslate(''),
    		"descriptionmyturn" => clienttranslate('${you} may choose an action or surrender to fate'),
    		"type" => "multipleactiveplayer",
            "action" => "st_MultiPlayerInit",
    		"possibleactions" => array( "confirmAction","reRollDice","discoverChamber",
				"activateGem", "removeBlackMask", "moveChamber", "turnFate", "escape", "giveDie", 
				"addressCurse", "loadMusic", "endPeriod", "gameEnd"),
    		"transitions" => array(  "loadMusic" => 2, "addressCurse"=> 7, "turnFate" => 11, "players_win" => 12, "gameEnd" => 99 ), 
			'action' => 'st_MultiPlayerInit'
    ),
	
	7 => array(
    		"name" => "addressCurse",
    		"description" => clienttranslate(''),
    		"descriptionmyturn" => clienttranslate('${you} must select a die to remove'),
    		"type" => "multipleactiveplayer",
			"possibleactions" => array( "confirmResponse","loadMusic", "pass" ),			
    		"transitions" => array( "loadMusic" => 2 )
    ),

Thank you for any help and advice
Not possible with current framework. State is global to all the players. I had to code myself a "parallel flow" module to handle this kind of situation (in Welcome To).

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 07 October 2021, 06:18
by developgame
Thanks Tisaac! I thought I could as it was done so well in 'Welcome To'

Great job on the game!

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 08 October 2021, 00:31
by gilthe
It might be an alternative to lump the state and check/verify the unique actions available via the database not the state machine (so keep everything in one multiactive state). I don't know whether that aspect is relevant for your game, but it might have the advantage that state doesn't change (which means that it is not immediately visible to others that the curse event happened).

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 12 October 2021, 06:40
by developgame
gilthe wrote: 08 October 2021, 00:31 It might be an alternative to lump the state and check/verify the unique actions available via the database not the state machine (so keep everything in one multiactive state). I don't know whether that aspect is relevant for your game, but it might have the advantage that state doesn't change (which means that it is not immediately visible to others that the curse event happened).
Thanks for your suggestion, gilthe
Following your suggestion, I know longer go between states loadMusic and playerTurn
The game seems to be faster

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 16 October 2021, 13:25
by JonChambers
I'm about to do something I hate done to me. I'm not going to answer your question (because I don't know the answer) but I will offer you advice on something you didn't ask that's tangentially related to your question, even though you probably know it already. (But on the off chance you don't know it, this could be a life saver. Sorry in advance if you already know.):

As soon as you introduce synchronous and real time into any internet based game, you open up the can of worms that is ping. The time difference between the client and server is much slower than video games would have you believe. So it must work in such a way that players can be one or two seconds ahead of each other and never know.

Video games hide this masterfully well, but it's all smoke and mirrors. The illusion is broken somewhat if you duck for cover, wait a few seconds, and then get shot from your completely safe position. That's not the game glitching out, but it doing the best it can with the constraints it has. You genuinely were shot before you dove for cover, but there was no way for this information to be communicated to you in time.

Sorry again if this is stuff you already know. I hope someone at least finds it interesting.

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 16 October 2021, 15:39
by Tisaac
JonChambers wrote: 16 October 2021, 13:25 I'm about to do something I hate done to me. I'm not going to answer your question (because I don't know the answer) but I will offer you advice on something you didn't ask that's tangentially related to your question, even though you probably know it already. (But on the off chance you don't know it, this could be a life saver. Sorry in advance if you already know.):

As soon as you introduce synchronous and real time into any internet based game, you open up the can of worms that is ping. The time difference between the client and server is much slower than video games would have you believe. So it must work in such a way that players can be one or two seconds ahead of each other and never know.

Video games hide this masterfully well, but it's all smoke and mirrors. The illusion is broken somewhat if you duck for cover, wait a few seconds, and then get shot from your completely safe position. That's not the game glitching out, but it doing the best it can with the constraints it has. You genuinely were shot before you dove for cover, but there was no way for this information to be communicated to you in time.

Sorry again if this is stuff you already know. I hope someone at least finds it interesting.
How is that related to OP question ?
If I understand his question correctly, he is wondering how players can be in different states at a given time, which is just not possible with the current framework unless you DIY with some extra code.

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 17 October 2021, 01:55
by Yasten
Depends, Hand and Foot's state is exclusive to the player whose turn it is when the turn is still going.

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 17 October 2021, 05:16
by JonChambers
Tisaac wrote: 16 October 2021, 15:39 How is that related to OP question ?
If I understand his question correctly, he is wondering how players can be in different states at a given time, which is just not possible with the current framework unless you DIY with some extra code.
Yes, that's exactly why I apologised in advance. This observation was the exact thing I was apologising for. I don't know how I could have made it any more clear.

Re: in a synchronous multiplayer game, how do I create a state that only affects one player

Posted: 17 October 2021, 07:31
by Tisaac
JonChambers wrote: 17 October 2021, 05:16
Tisaac wrote: 16 October 2021, 15:39 How is that related to OP question ?
If I understand his question correctly, he is wondering how players can be in different states at a given time, which is just not possible with the current framework unless you DIY with some extra code.
Yes, that's exactly why I apologised in advance. This observation was the exact thing I was apologising for. I don't know how I could have made it any more clear.
No i mean how is that even "tangentially" related to question/issue. Genuinely wondering.