#How to make random imposter generator in multiplayer 3d
1 messages · Page 1 of 1 (latest)
Iterate trough each existing player and just mark them in some way, like seeting a variable in them
Can u explain more clearly?
How does your networking code work?
It really depends on that.
It will be helpful to use an FSM (finite state machine) for this to manage your game states between your server, and clients.
The server will be driving the FSM
So youll want to think through the states of a game. Among Us is going to be something like:
Start ->
The initial state. you load the level. When done loading transition into WaitingForPlayers
WaitingForPlayers ->
Clients can now connect to the server. This can have some sort of timeout just in case clients drop or something. Place them wherever is appropriate (waiting room forex)
When all players are logged in transition into SetupGame
SetupGame ->
this is where you select the roles for the players, include the imposter
You transmit this to the clients , get an ack, and transition into StartingGame
StartingGame ->
Count to 5 for the start of the game. Transition into PlayingGame
PlayingGame ->
on the transition into playing game open the door keeping folks into the waiting room
Transition into GamePhase1
GamePhase1 ->
Players run around doing whatever tehyre suppsed to do. At some point, this phase wil be over, and we'll go into GamePhase2
GamePhase2 ->
Voting and such.
If any win or loss conditions are met, go into EndGame, other go back to GamePhase1
EndGame ->
Display info, let player smack talk, etc and the end of this transition into ShutdownGame.
I appreciate your opinion but I only want to set random imposter generator. I thought of using RNG(RandomNumberGenerator)
but if 4 or more player are playing most of them will become imposters if i set :
if rng==1:
print("You are imposter! ")
else:
print("You are innocent")
Because this is random, but sometimes it will make by random only one player imposter
but if all the players by chance get 1 they would be imposters all of them.
I only want that if there are for eg 4 or more players playing then one of them should be imposter which rng should be only set 1 in only in one player and 2 in other players and they will be innocent.This is what i want.
I haven't used UPNP/Port forwarding, I am making local multiplayer by using tutorial of GWIZZ Dev.
save the playerlist to an array an choose a random index
playerList[] = {Player1, Player2, Player3, Player4}
imposter = playerList[rng]
You have the RandomNumberGenerator for making random numbers, and arrays have "pick_random()" if you don't want to generate the number yourself.
Ahh. Thats pretty trivial then. Put them in a list, shuffle it, pick the first N
I still can't find a way to add random imposter because I am an absolute beginner. can someone else do this?
Do you have a system for turning someone into an "imposter"?
Or any code relating to that?
Here:
var rng = RandomNumberGenerator.new()
func _ready():
var nrg = rng.randf_range(0, 1)
if nrg == 1:
print("U are the imposter!")
else:
print("U are innocent")
This is pretty close to what you need.
But first you need a list of all players.
Once you do you can put them in an Array and select a random one.
var imposter: Node = player_list[nrg]
print(imposter.name + " is the imposter")
And nrg would need to be limited to the amount of players:
var nrg = rng.randi_range(0, player_list.size() - 1)
Oh wait, these games tend to have more than 1, right?