What would be the best way to handle a 4 player board game type map, where only 1 player can "make a move" per turn. Say the game was monopoly, what would be the best way to handle each players turn?
I believe the easiest way is to use 1 variable to track which players turn it is.
Then have all your turn action triggers with the following condition.
Event: Player does an action during their turn
Condition: Triggering player is CurrentPlayer
Action: Whatever actions
This way if any player tries to do anything when it's not their turn, the trigger will not execute for them.
Once the player ends their turn, just increment the player variable using CurrentPlayer = (CurrentPlayer+1)/TotalPlayers
This is just a basic algorithm, you will need to take into account people might leave, so you will want to check each time you increment the player (Using a while loop?) to see if the player is playing.
Advanced
Disable the interface for players that are waiting their turn.
Additional note
I've tried making a turn based game before, and I personally believe its very hard to pull off, simply because most people are impatient and will leave if they have to wait too long for their turn. My recommendation is to consider a simultaneous turn implementation for your map. After every player finishes their actions, the 'round' ends and the queued actions or whatnot are processed.
TurnclockEventsLocalVariablesConditionsActionsTimer-DestroyCurrenttimerwindowPlayerGroup-Pickeachplayerin(Allplayers)anddo(Actions)ActionsCamera-Panthecameraforplayer(Pickedplayer)to(Player1facing270.0degrees)over0.5secondswithExistingVelocity%initialvelocity,10%deceleration,andDoNotusesmartpanningCamera-Lockcamerainputforplayer(Pickedplayer)Visibility-Reveal(Region((Centerof(Anyunitsin(Entiremap)ownedbyplayer1matchingExcluded:Missile,Dead,Hidden,withatmostAnyAmount)),1.0))forplayer(Pickedplayer)for15.0secondsandDoNotcheckclifflevelUI-HideCommandPanelfor(Playergroup((Pickedplayer)))UnitGroup-Pickeachunitin(Anyunitsin(Entiremap)ownedbyplayer(Pickedplayer)matching(NoValue),withatmostAnyAmount)anddo(Actions)ActionsUnit-Pause(Pickedunit)Unit-Make(Pickedunit)UncommandablePlayerGroup-Removeplayer4fromPlayerwithTurnPlayerGroup-Addplayer1toPlayerwithTurnTimer-StartTurnClockasaOneShottimerthatwillexpirein15.0GameTimesecondsVariable-SetCurrenttimer=(Laststartedtimer)PlayerGroup-PickeachplayerinPlayerwithTurnanddo(Actions)ActionsTimer-Createatimerwindowfor(Laststartedtimer),withthetitle("Time until "+((Nameofplayer(Pickedplayer))+"'s turn is over:")),usingRemainingtime(initiallyVisible)Variable-SetCurrenttimerwindow=(Lastcreatedtimerwindow)Camera-Unlockcamerainputforplayer(Pickedplayer)UI-ShowCommandPanelfor(Playergroup((Pickedplayer)))UnitGroup-Pickeachunitin(Anyunitsin(Entiremap)ownedbyplayer(Pickedplayer)matching(NoValue),withatmostAnyAmount)anddo(Actions)ActionsUnit-Unpause(Pickedunit)Unit-Make(Pickedunit)CommandableGeneral-Wait15.0GameTimesecondsTrigger-RunTurnclock2(CheckConditions,Don'tWaituntilitfinishes)
This is a blanket trigger, just change the few places where player number matters to the correct player number.
Here is the map in case you want to check my work or whatever:
Basic Turn System
Rollback Post to RevisionRollBack
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
To post a comment, please login or register a new account.
I need some help.
What would be the best way to handle a 4 player board game type map, where only 1 player can "make a move" per turn. Say the game was monopoly, what would be the best way to handle each players turn?
even pseudo code would be fine
@jmac321wky: Go
I believe the easiest way is to use 1 variable to track which players turn it is.
Then have all your turn action triggers with the following condition.
Event: Player does an action during their turn
Condition: Triggering player is CurrentPlayer
Action: Whatever actions
This way if any player tries to do anything when it's not their turn, the trigger will not execute for them.
Once the player ends their turn, just increment the player variable using CurrentPlayer = (CurrentPlayer+1)/TotalPlayers
This is just a basic algorithm, you will need to take into account people might leave, so you will want to check each time you increment the player (Using a while loop?) to see if the player is playing.
Advanced
Disable the interface for players that are waiting their turn.
Additional note
I've tried making a turn based game before, and I personally believe its very hard to pull off, simply because most people are impatient and will leave if they have to wait too long for their turn. My recommendation is to consider a simultaneous turn implementation for your map. After every player finishes their actions, the 'round' ends and the queued actions or whatnot are processed.
This can be done many ways, but here is one:
Note: This is excluding all other actions and things you might want done during a players turn, this is just a turn system, that's all.
Here are the variables:
Now the loop start trigger:
now the trigger itself:
This is a blanket trigger, just change the few places where player number matters to the correct player number.
Here is the map in case you want to check my work or whatever: Basic Turn System