Skip to content

Commit

Permalink
Replaces rigged storyteller with automatic transfer votes (#3278)
Browse files Browse the repository at this point in the history
* Replaces rigged storyteller with automatic transfer votes

* meow

* Refactor to use `SSautotransfer`
  • Loading branch information
Absolucy authored Sep 22, 2024
1 parent d08f587 commit 1860e5b
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 82 deletions.
18 changes: 18 additions & 0 deletions code/controllers/configuration/entries/monkestation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,21 @@
/datum/config_entry/flag/disable_particle_weather

/datum/config_entry/flag/disable_storyteller

/datum/config_entry/number/transfer_vote_time
default = 90 MINUTES
min_val = 0

/datum/config_entry/number/transfer_vote_time/ValidateAndSet(str_val)
. = ..()
if(.)
config_entry_value *= 600 // documented as minutes

/datum/config_entry/number/subsequent_transfer_vote_time
default = 30 MINUTES
min_val = 0

/datum/config_entry/number/subsequent_transfer_vote_time/ValidateAndSet(str_val)
. = ..()
if(.)
config_entry_value *= 600 // documented as minutes
16 changes: 12 additions & 4 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ SUBSYSTEM_DEF(vote)
var/to_display = current_vote.get_result_text(winners, final_winner, non_voters)

log_vote(to_display)
to_chat(world, span_infoplain(vote_font("\n[to_display]")))
to_chat(world, "\n" + examine_block(span_infoplain(vote_font("[to_display]"))) + "\n", type = MESSAGE_TYPE_OOC) // monkestation edit: wrap in examine block, use MESSAGE_TYPE_OOC

// Finally, doing any effects on vote completion
if (final_winner) // if no one voted final_winner will be null
Expand All @@ -103,6 +103,10 @@ SUBSYSTEM_DEF(vote)
return
if(CONFIG_GET(flag/no_dead_vote) && voter.stat == DEAD && !voter.client?.holder)
return
// monkestation start
if(!current_vote.can_vote(voter))
return
// monkestation end

// If user has already voted, remove their specific vote
if(voter.ckey in current_vote.choices_by_ckey)
Expand Down Expand Up @@ -133,9 +137,12 @@ SUBSYSTEM_DEF(vote)
return
if(!voter?.ckey)
return
// monkestation start
if(!current_vote.can_vote(voter))
return
// monkestation end
if(CONFIG_GET(flag/no_dead_vote) && voter.stat == DEAD && !voter.client?.holder)
return

else
voted += voter.ckey

Expand Down Expand Up @@ -226,9 +233,9 @@ SUBSYSTEM_DEF(vote)
var/to_display = current_vote.initiate_vote(vote_initiator_name, duration)

log_vote(to_display)
to_chat(world, span_infoplain(vote_font("\n[span_bold(to_display)]\n\
to_chat(world, "\n" + examine_block(span_infoplain(vote_font("[span_bold(to_display)]\n\
Type <b>vote</b> or click <a href='byond://winset?command=vote'>here</a> to place your votes.\n\
You have [DisplayTimeText(duration)] to vote.")))
You have [DisplayTimeText(duration)] to vote."))) + "\n", type = MESSAGE_TYPE_OOC) // monkestation edit: wrap in examine block, use MESSAGE_TYPE_OOC

// And now that it's going, give everyone a voter action
for(var/client/new_voter as anything in GLOB.clients)
Expand Down Expand Up @@ -304,6 +311,7 @@ SUBSYSTEM_DEF(vote)
"countMethod" = current_vote.count_method,
"choices" = choices,
"vote" = vote_data,
"canVote" = current_vote.can_vote(user), // monkestation edit
)

all_vote_data += list(vote_data)
Expand Down
2 changes: 0 additions & 2 deletions code/modules/events/_event.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@
return FALSE
if(roundstart && ((SSticker.round_start_time && (world.time - SSticker.round_start_time) >= 2 MINUTES) || (SSgamemode.ran_roundstart && !fake_check)))
return FALSE
if(istype(src, /datum/round_event_control/antagonist/solo/from_ghosts) && (SSautotransfer.starttime + 85 MINUTES <= world.time))
return TRUE // we allow all ghost roles to run at this point and dont care about other checks
// monkestation end
if(occurrences >= max_occurrences)
return FALSE
Expand Down
8 changes: 8 additions & 0 deletions config/game_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,14 @@ METACURRENCY_NAME Metacoin

TWITCH_KEY mrhouse

## How long (in minutes) after roundstart should the server start an automatic crew transfer vote?
## Defaults to 90 minutes. Set to 0 to completely disable automatic crew transfer votes.
TRANSFER_VOTE_TIME 90

## If players vote against a crew transfer, how long (in minutes) until another automatic transfer vote will be initiated?
## Defaults to 30 minutes. Set to 0 to completely disable subsequent crew transfer votes.
SUBSEQUENT_TRANSFER_VOTE_TIME 30

## Gamemode configurations

## Multipliers for points gained over time for event tracks.
Expand Down
57 changes: 57 additions & 0 deletions monkestation/code/controllers/subsystem/autotransfer.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
SUBSYSTEM_DEF(autotransfer)
name = "Autotransfer Vote"
flags = SS_KEEP_TIMING | SS_BACKGROUND
wait = 1 MINUTES
runlevels = RUNLEVEL_GAME

var/doing_transfer_vote = FALSE
COOLDOWN_DECLARE(next_transfer_vote)

/datum/controller/subsystem/autotransfer/Initialize(timeofday)
if(!CONFIG_GET(number/transfer_vote_time))
flags |= SS_NO_FIRE
return SS_INIT_NO_NEED
SSticker.OnRoundstart(CALLBACK(src, PROC_REF(crew_transfer_setup)))
return SS_INIT_SUCCESS

/datum/controller/subsystem/autotransfer/fire()
if(can_run_transfer_vote())
SSvote.initiate_vote(/datum/vote/shuttle_call, "automatic shuttle vote", forced = TRUE)

/datum/controller/subsystem/autotransfer/proc/can_run_transfer_vote()
. = TRUE
if(doing_transfer_vote)
return FALSE
if(!CONFIG_GET(number/transfer_vote_time))
return FALSE
if(!next_transfer_vote || !COOLDOWN_FINISHED(src, next_transfer_vote))
return FALSE
if(SSvote.current_vote)
return FALSE
if(EMERGENCY_PAST_POINT_OF_NO_RETURN)
return FALSE
if(SSshuttle.supermatter_cascade)
return FALSE

/datum/controller/subsystem/autotransfer/proc/crew_transfer_setup()
COOLDOWN_START(src, next_transfer_vote, CONFIG_GET(number/transfer_vote_time))

/datum/controller/subsystem/autotransfer/proc/crew_transfer_passed()
if(!SSticker.IsRoundInProgress())
CRASH("Somehow tried to initiate crew transfer, even tho there is not ongoing round!")
SSshuttle.admin_emergency_no_recall = TRUE
if(SSshuttle.emergency?.mode == SHUTTLE_DISABLED || EMERGENCY_PAST_POINT_OF_NO_RETURN)
return
if(EMERGENCY_IDLE_OR_RECALLED)
SSshuttle.emergency.request(
red_alert = (SSsecurity_level.get_current_level_as_number() >= SEC_LEVEL_RED)
)
crew_transfer_continue() // safety measure

/datum/controller/subsystem/autotransfer/proc/crew_transfer_continue()
SSgamemode.point_gain_multipliers[EVENT_TRACK_ROLESET]++
var/subsequent_transfer_vote_time = CONFIG_GET(number/subsequent_transfer_vote_time)
if(!subsequent_transfer_vote_time)
next_transfer_vote = 0
return
COOLDOWN_START(src, next_transfer_vote, subsequent_transfer_vote_time)
2 changes: 2 additions & 0 deletions monkestation/code/datums/votes/_vote_datum.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/datum/vote/proc/can_vote(mob/voter)
return TRUE
50 changes: 50 additions & 0 deletions monkestation/code/datums/votes/transfer_vote.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#define CHOICE_CALL "Call Shuttle"
#define CHOICE_CONTINUE "Continue Round"

/// If a map vote is called before the emergency shuttle leaves the station, the players can call another vote to re-run the vote on the shuttle leaving.
/datum/vote/shuttle_call
name = "Call Shuttle"
message = "Should we go home?"
default_choices = list(
CHOICE_CALL,
CHOICE_CONTINUE,
)
player_startable = FALSE

/datum/vote/shuttle_call/reset()
. = ..()
SSautotransfer.doing_transfer_vote = FALSE

/datum/vote/shuttle_call/can_be_initiated(mob/by_who, forced = FALSE)
. = ..()
if(!.)
return FALSE
if(!SSticker.IsRoundInProgress())
return FALSE
if(EMERGENCY_PAST_POINT_OF_NO_RETURN)
return FALSE
if(SSautotransfer.doing_transfer_vote)
return FALSE

/datum/vote/shuttle_call/initiate_vote(initiator, duration)
. = ..()
SSautotransfer.doing_transfer_vote = TRUE

/datum/vote/shuttle_call/finalize_vote(winning_option)
switch(winning_option)
if(CHOICE_CALL)
SSautotransfer.crew_transfer_passed()
if(CHOICE_CONTINUE)
SSautotransfer.crew_transfer_continue()
else
CRASH("[type] wasn't passed a valid winning choice. (Got: [winning_option || "null"])")

/datum/vote/shuttle_call/can_vote(mob/voter = usr)
. = TRUE
if(voter.client?.holder)
return TRUE
if(isobserver(voter) || voter.stat == DEAD || !(voter.ckey in GLOB.joined_player_list)) // only living crew gets to vote
return FALSE

#undef CHOICE_CONTINUE
#undef CHOICE_CALL
72 changes: 0 additions & 72 deletions monkestation/code/modules/goonimizations/shuttle_votes.dm

This file was deleted.

2 changes: 0 additions & 2 deletions monkestation/code/modules/virology/living/spread_disease.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
return TRUE

/mob/dead/new_player/proc/DiseaseCarrierCheck(mob/living/carbon/human/H)
if(world.time < SSautotransfer.starttime + 30 MINUTES)
return
// 10% of players are joining the station with some minor disease if latejoined
if(prob(10))
var/virus_choice = pick(subtypesof(/datum/disease/advanced)- typesof(/datum/disease/advanced/premade))
Expand Down
4 changes: 3 additions & 1 deletion tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5805,6 +5805,7 @@
#include "monkestation\code\area\areas\direction_names.dm"
#include "monkestation\code\area\areas\ruins.dm"
#include "monkestation\code\area\areas\station.dm"
#include "monkestation\code\controllers\subsystem\autotransfer.dm"
#include "monkestation\code\controllers\subsystem\economy.dm"
#include "monkestation\code\controllers\subsystem\glowshroom.dm"
#include "monkestation\code\controllers\subsystem\job.dm"
Expand Down Expand Up @@ -5867,6 +5868,8 @@
#include "monkestation\code\datums\status_effects\food_buffs.dm"
#include "monkestation\code\datums\status_effects\debuffs\drunk.dm"
#include "monkestation\code\datums\storage\storage.dm"
#include "monkestation\code\datums\votes\_vote_datum.dm"
#include "monkestation\code\datums\votes\transfer_vote.dm"
#include "monkestation\code\datums\weather\weather_types\radiation_storm.dm"
#include "monkestation\code\datums\wires\particle_accelerator.dm"
#include "monkestation\code\game\atom.dm"
Expand Down Expand Up @@ -7056,7 +7059,6 @@
#include "monkestation\code\modules\ghost_players\job_helpers\injured_spawner.dm"
#include "monkestation\code\modules\ghost_players\job_helpers\organ_printer.dm"
#include "monkestation\code\modules\goonimizations\goon_keybinds.dm"
#include "monkestation\code\modules\goonimizations\shuttle_votes.dm"
#include "monkestation\code\modules\guns\laser.dm"
#include "monkestation\code\modules\holomaps\areas.dm"
#include "monkestation\code\modules\holomaps\base_datum.dm"
Expand Down
7 changes: 6 additions & 1 deletion tgui/packages/tgui/interfaces/VotePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ActiveVote = {
timeRemaining: number;
choices: Option[];
countMethod: number;
canVote?: BooleanLike;
};

type UserData = {
Expand Down Expand Up @@ -192,7 +193,10 @@ const ChoicesPanel = (props) => {
buttons={
<Button
tooltip={choice.desc}
disabled={user.singleSelection === choice.name}
disabled={
!currentVote.canVote ||
user.singleSelection === choice.name
}
onClick={() => {
act('voteSingle', { voteOption: choice.name });
}}
Expand Down Expand Up @@ -232,6 +236,7 @@ const ChoicesPanel = (props) => {
buttons={
<Button
tooltip={choice.desc}
disabled={!currentVote.canVote}
onClick={() => {
act('voteMulti', { voteOption: choice.name });
}}
Expand Down

0 comments on commit 1860e5b

Please sign in to comment.