#How to make random imposter generator in multiplayer 3d

1 messages · Page 1 of 1 (latest)

sacred timber
#

I am making a Among us clone in which I want when a player joins, one of them should be an imposter but randomly.

safe eagle
#

Iterate trough each existing player and just mark them in some way, like seeting a variable in them

safe eagle
#

It really depends on that.

modern plinth
#

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.

sacred timber
# modern plinth It will be helpful to use an FSM (finite state machine) for this to manage your ...

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.

sacred timber
terse walrus
safe eagle
#

You have the RandomNumberGenerator for making random numbers, and arrays have "pick_random()" if you don't want to generate the number yourself.

modern plinth
sacred timber
#

I still can't find a way to add random imposter because I am an absolute beginner. can someone else do this?

safe eagle
sacred timber
#

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")

safe eagle
#

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?