mafia_controller
The mafia controller handles the mafia minigame in progress. It is first created when the first ghost signs up to play.
Vars | |
all_roles | all roles in the game, dead or alive. check their game status if you only want living or dead. |
---|---|
current_map | template picked when the game starts. used for the name and desc reading |
current_setup_text | Readable list of roles in current game, sent to the tgui panel for roles list > list("Psychologist x1", "Clown x2") |
custom_setup | for debugging and testing a full game, or adminbuse. If this is not empty, it will use this as a setup. clears when game is over |
day_phase_period | talk with others about the last night |
debug | used for debugging in testing (doesn't put people out of the game, some other shit i forgot, who knows just don't set this in live) honestly kinda deprecated |
first_day_phase_period | first day has no voting, and thus is shorter |
judgement_abstain_votes | and these (judgement_innocent_votes, judgement_abstain_votes and judgement_guilty_votes) are the judgement phase votes, aka people sorting themselves into guilty and innocent, and "eh, i don't really care" lists. whichever has more inno or guilty wins! |
judgement_lynch_period | guilty or innocent, we want a bit of time for players to process the outcome of the vote |
judgement_phase_period | defend yourself! don't get lynched! sometimes skipped if nobody votes. |
landmarks | spawn points for players, each one has a house |
map_deleter | map generation tool that deletes the current map after the game finishes |
next_phase_timer | current timer for phase |
night_phase_period | mafia talk at night and pick someone to kill, some town roles use their actions, etc etc. |
on_trial | current role on trial for the judgement phase, will die if guilty is greater than innocent |
phase | what part of the game you're playing in. day phases, night phases, judgement phases, etc. |
player_outfit | starting outfit for all mafia players. it's just a grey jumpsuit. |
player_role_lookup | exists to speed up role retrieval, it's a dict. player_role_lookup[player ckey] will give you the role they play |
spectators | list of observers that should get game updates. |
speed_up | if enabled, the game has fallen under half pop and is sped up |
town_center_landmark | town center for when people get put on trial |
turn | how long the game has gone on for, changes with every sunrise. day one, night one, day two, etc. |
victory_lap_period | like the lynch period, players need to see what the other players in the game's roles were |
votes | group voting on one person, like putting people to trial or choosing who to kill as mafia |
voting_phase_period | vote someone to get put on trial |
Procs | |
add_setup_role | Helper proc that adds a random role of a type to a setup. if it doesn't exist in the setup, it adds the path to the list and otherwise bumps the path in the list up one. unique roles can only get added once. |
award_role | PHASE ONE: TALLY UP ALL NUMBERS OF PEOPLE STILL ALIVE PHASE TWO: SEND STATS TO SOLO ANTAGS, SEE IF THEY WON OR TEAMS CANNOT WIN Lets the game award roles with all their checks and sanity, prevents achievements given out for debug games |
basic_setup | Called when enough players have signed up to fill a setup. DOESN'T NECESSARILY MEAN THE GAME WILL START. |
check_signups | Filters inactive player into a different list until they reconnect, and removes players who are no longer ghosts. |
check_trial | Players have voted someone up, and now the person must defend themselves while the town votes innocent or guilty. |
check_victory | Checks to see if a faction (or solo antagonist) has won. |
create_bodies | Called when the game is setting up, AFTER map is loaded but BEFORE the phase timers start. Creates and places each role's body and gives the correct player key |
display_votes | Adds mutable appearances to people who get publicly voted on (so not night votes) showing how many people are picking them Arguments: |
end_game | Cleans up the game, resetting variables back to the beginning and removing the map with the generator. |
generate_random_setup | Returns a semirandom setup with 12 roles. balance not guaranteed! |
get_random_voter | Returns a random person who voted for whatever vote (day vote, night kill vote) Arguments: |
get_vote_count | Returns how many people voted for the role, in whatever vote (day vote, night kill vote) Arguments: |
get_vote_winner | Returns whichever role got the most votes, in whatever vote (day vote, night kill vote) returns null if no votes Arguments: |
lockdown | After the voting and judgement phases, the game goes to night shutting the windows and beginning night with a proc. |
lynch | Players have voted innocent or guilty on the person on trial, and that person is now killed or returned home. |
prepare_game | Triggers at beginning of the game when there is a confirmed list of valid, ready players. Creates a 100% ready game that has NOT started (no players in bodies) Followed by start game |
reset_votes | Clears out the votes of a certain type (day votes, mafia kill votes) while leaving others untouched |
resolve_night | The end of the night, and a series of signals for the order of events on a night. |
send_home | Teenie helper proc to move players back to their home. Used in the above, but also used in the debug button "send all players home" Arguments: |
start_day | How every day starts. |
start_game | The game by this point is now all set up, and so we can put people in their bodies and start the first phase. |
start_night | The actual start of night for players. Mostly info is given at the start of the night as the end of the night is when votes and actions are submitted and tried. |
start_the_end | The end of the game is in two procs, because we want a bit of time for players to see eachothers roles. Because of how check_victory works, the game is halted in other places by this point. |
start_voting_phase | Players have finished the discussion period, and now must put up someone to the chopping block. |
toggle_night_curtains | Shuts poddoors attached to mafia. Arguments: |
try_autostart | Called when someone signs up, and sees if there are enough people in the signup list to begin. |
vote_for | Proc that goes off when players vote for something with their mafia panel. |
Var Details
all_roles
all roles in the game, dead or alive. check their game status if you only want living or dead.
current_map
template picked when the game starts. used for the name and desc reading
current_setup_text
Readable list of roles in current game, sent to the tgui panel for roles list > list("Psychologist x1", "Clown x2")
custom_setup
for debugging and testing a full game, or adminbuse. If this is not empty, it will use this as a setup. clears when game is over
day_phase_period
talk with others about the last night
debug
used for debugging in testing (doesn't put people out of the game, some other shit i forgot, who knows just don't set this in live) honestly kinda deprecated
first_day_phase_period
first day has no voting, and thus is shorter
judgement_abstain_votes
and these (judgement_innocent_votes, judgement_abstain_votes and judgement_guilty_votes) are the judgement phase votes, aka people sorting themselves into guilty and innocent, and "eh, i don't really care" lists. whichever has more inno or guilty wins!
judgement_lynch_period
guilty or innocent, we want a bit of time for players to process the outcome of the vote
judgement_phase_period
defend yourself! don't get lynched! sometimes skipped if nobody votes.
landmarks
spawn points for players, each one has a house
map_deleter
map generation tool that deletes the current map after the game finishes
next_phase_timer
current timer for phase
night_phase_period
mafia talk at night and pick someone to kill, some town roles use their actions, etc etc.
on_trial
current role on trial for the judgement phase, will die if guilty is greater than innocent
phase
what part of the game you're playing in. day phases, night phases, judgement phases, etc.
player_outfit
starting outfit for all mafia players. it's just a grey jumpsuit.
player_role_lookup
exists to speed up role retrieval, it's a dict. player_role_lookup[player ckey]
will give you the role they play
spectators
list of observers that should get game updates.
speed_up
if enabled, the game has fallen under half pop and is sped up
town_center_landmark
town center for when people get put on trial
turn
how long the game has gone on for, changes with every sunrise. day one, night one, day two, etc.
victory_lap_period
like the lynch period, players need to see what the other players in the game's roles were
votes
group voting on one person, like putting people to trial or choosing who to kill as mafia
voting_phase_period
vote someone to get put on trial
Proc Details
add_setup_role
Helper proc that adds a random role of a type to a setup. if it doesn't exist in the setup, it adds the path to the list and otherwise bumps the path in the list up one. unique roles can only get added once.
award_role
PHASE ONE: TALLY UP ALL NUMBERS OF PEOPLE STILL ALIVE PHASE TWO: SEND STATS TO SOLO ANTAGS, SEE IF THEY WON OR TEAMS CANNOT WIN Lets the game award roles with all their checks and sanity, prevents achievements given out for debug games
Arguments:
- award: path of the award
- role: mafia_role datum to reward.
basic_setup
Called when enough players have signed up to fill a setup. DOESN'T NECESSARILY MEAN THE GAME WILL START.
Checks for a custom setup, if so gets the required players from that and if not it sets the player requirement to MAFIA_MAX_PLAYER_COUNT and generates one IF basic setup starts a game. Checks if everyone signed up is an observer, and is still connected. If people aren't, they're removed from the list. If there aren't enough players post sanity, it aborts. otherwise, it selects enough people for the game and starts preparing the game for real.
check_signups
Filters inactive player into a different list until they reconnect, and removes players who are no longer ghosts.
If a disconnected player gets a non-ghost mob and reconnects, they will be first put back into mafia_signup then filtered by that.
check_trial
Players have voted someone up, and now the person must defend themselves while the town votes innocent or guilty.
What players do in this phase:
- Vote innocent or guilty, if they are not on trial.
- Defend themselves and wait for judgement, if they are.
- Leads to the lynch phase. Arguments:
- verbose: boolean, announces whether there were votes or not. after judgement it goes back here with no voting period to end the day.
check_victory
Checks to see if a faction (or solo antagonist) has won.
Calculates in this order:
- counts up town, mafia, and solo
- solos can count as town members for the purposes of mafia winning
- sends the amount of living people to the solo antagonists, and see if they won OR block the victory of the teams
- checks if solos won from above, then if town, then if mafia
- starts the end of the game if a faction won
- returns TRUE if someone won the game, halting other procs from continuing in the case of a victory
create_bodies
Called when the game is setting up, AFTER map is loaded but BEFORE the phase timers start. Creates and places each role's body and gives the correct player key
Notably:
- Toggles godmode so the mafia players cannot kill themselves
- Adds signals for voting overlays, see display_votes proc
- gives mafia panel
- sends the greeting text (goals, role name, etc)
display_votes
Adds mutable appearances to people who get publicly voted on (so not night votes) showing how many people are picking them Arguments:
- source: the body of the role getting the overlays
- overlay_list: signal var passing the overlay list of the mob
end_game
Cleans up the game, resetting variables back to the beginning and removing the map with the generator.
generate_random_setup
Returns a semirandom setup with 12 roles. balance not guaranteed!
please check the variables at the top of the proc to see how much of each role types it picks
get_random_voter
Returns a random person who voted for whatever vote (day vote, night kill vote) Arguments:
- vote_type: vote type (getting a random day voter, or mafia night voter)
get_vote_count
Returns how many people voted for the role, in whatever vote (day vote, night kill vote) Arguments:
- role: the mafia role the proc tries to get the amount of votes for
- vote_type: the vote type (getting how many day votes were for the role, or mafia night votes for the role)
get_vote_winner
Returns whichever role got the most votes, in whatever vote (day vote, night kill vote) returns null if no votes Arguments:
- vote_type: the vote type (getting the role that got the most day votes, or the role that got the most mafia votes)
lockdown
After the voting and judgement phases, the game goes to night shutting the windows and beginning night with a proc.
lynch
Players have voted innocent or guilty on the person on trial, and that person is now killed or returned home.
What players do in this phase:
- r/watchpeopledie
- If the accused is killed, their true role is revealed to the rest of the players.
prepare_game
Triggers at beginning of the game when there is a confirmed list of valid, ready players. Creates a 100% ready game that has NOT started (no players in bodies) Followed by start game
Does the following:
- Picks map, and loads it
- Grabs landmarks if it is the first time it's loading
- Sets up the role list
- Puts players in each role randomly Arguments:
- setup_list: list of all the datum setups (fancy list of roles) that would work for the game
- ready_players: list of filtered, sane players (so not playing or disconnected) for the game to put into roles
reset_votes
Clears out the votes of a certain type (day votes, mafia kill votes) while leaving others untouched
resolve_night
The end of the night, and a series of signals for the order of events on a night.
Order of events, and what they mean:
- Start of resolve (NIGHT_START) is for activating night abilities that MUST go first
- Action phase (NIGHT_ACTION_PHASE) is for non-lethal day abilities
- Mafia then tallies votes and kills the highest voted person (note: one random voter visits that person for the purposes of roleblocking)
- Killing phase (NIGHT_KILL_PHASE) is for lethal night abilities
- End of resolve (NIGHT_END) is for cleaning up abilities that went off and i guess doing some that must go last
- Finally opens the curtains and calls the start of day phase, completing the cycle until check victory returns TRUE
send_home
Teenie helper proc to move players back to their home. Used in the above, but also used in the debug button "send all players home" Arguments:
- role: mafia role that is getting sent back to the game.
start_day
How every day starts.
What players do in this phase:
- If day one, just a small starting period to see who is in the game and check role, leading to the night phase.
- Otherwise, it's a longer period used to discuss events that happened during the night, leading to the voting phase.
start_game
The game by this point is now all set up, and so we can put people in their bodies and start the first phase.
Does the following:
- Creates bodies for all of the roles with the first proc
- Starts the first day manually (so no timer) with the second proc
start_night
The actual start of night for players. Mostly info is given at the start of the night as the end of the night is when votes and actions are submitted and tried.
What players do in this phase:
- Mafia are told to begin voting on who to kill
- Powers that are picked during the day announce themselves right now
start_the_end
The end of the game is in two procs, because we want a bit of time for players to see eachothers roles. Because of how check_victory works, the game is halted in other places by this point.
What players do in this phase:
- See everyone's role postgame
- See who won the game Arguments:
- message: string, if non-null it sends it to all players. used to announce team victories while solos are handled in check victory
start_voting_phase
Players have finished the discussion period, and now must put up someone to the chopping block.
What players do in this phase:
- Vote on which player to put up for lynching, leading to the judgement phase.
- If no votes are case, the judgement phase is skipped, leading to the night phase.
toggle_night_curtains
Shuts poddoors attached to mafia. Arguments:
- close: boolean, the state you want the curtains in.
try_autostart
Called when someone signs up, and sees if there are enough people in the signup list to begin.
Only checks if everyone is actually valid to start (still connected and an observer) if there are enough players (basic_setup)
vote_for
Proc that goes off when players vote for something with their mafia panel.
If teams, it hides the tally overlay and only sends the vote messages to the team that is voting Arguments:
- voter: the mafia role that is trying to vote for...
- target: the mafia role that is getting voted for
- vote_type: type of vote submitted (is this the day vote? is this the mafia night vote?)
- teams: see mafia team defines for what to put in, makes the messages only send to a specific team (so mafia night votes only sending messages to mafia at night)