Permalink
Browse files

Merge pull request #733 from paprka/autoxfer

Adds crew transfer shuttle voting and auto vote creation
  • Loading branch information...
2 parents 299c91a + dacfca5 commit 58f703a5df1586b4f7b4e7186ca29e1764228a7b @Atskadan Atskadan committed Jun 24, 2014
View
@@ -103,6 +103,7 @@
#include "code\ATMOSPHERICS\components\unary\vent_pump.dm"
#include "code\ATMOSPHERICS\components\unary\vent_scrubber.dm"
#include "code\controllers\_DynamicAreaLighting_TG.dm"
+#include "code\controllers\autotransfer.dm"
#include "code\controllers\configuration.dm"
#include "code\controllers\failsafe.dm"
#include "code\controllers\garbage.dm"
@@ -0,0 +1,17 @@
+var/datum/controller/transfer_controller/transfer_controller
+
+datum/controller/transfer_controller
+ var/timerbuffer = 0 //buffer for time check
+ var/currenttick = 0
+datum/controller/transfer_controller/New()
+ timerbuffer = config.vote_autotransfer_initial
+ processing_objects += src
+
+datum/controller/transfer_controller/Del()
+ processing_objects -= src
+
+datum/controller/transfer_controller/proc/process()
+ currenttick = currenttick + 1
+ if (world.time >= timerbuffer - 600)
+ vote.autotransfer()
+ timerbuffer = timerbuffer + config.vote_autotransfer_interval
@@ -31,6 +31,8 @@
var/allow_vote_mode = 0 // allow votes to change mode
var/vote_delay = 6000 // minimum time between voting sessions (deciseconds, 10 minute default)
var/vote_period = 600 // length of voting period (deciseconds, default 1 minute)
+ var/vote_autotransfer_initial = 72000 // Length of time before the first autotransfer vote is called
+ var/vote_autotransfer_interval = 36000 // length of time before next sequential autotransfer vote
var/vote_no_default = 0 // vote does not default to nochange/norestart (tbi)
var/vote_no_dead = 0 // dead people can't vote (tbi)
var/del_new_on_log = 1 // del's new players if they log before they spawn in
@@ -226,6 +228,10 @@
config.vote_delay = text2num(value)
if("vote_period")
config.vote_period = text2num(value)
+ if("vote_autotransfer_initial")
+ config.vote_autotransfer_initial = text2num(value)
+ if("vote_autotransfer_interval")
+ config.vote_autotransfer_interval = text2num(value)
if("norespawn")
config.respawn = 0
if("servername")
@@ -35,18 +35,21 @@ datum/controller/vote
else
var/datum/browser/client_popup
while(i<=voting.len)
- var/client/C = voting[i]
+ var/client/C = voting[i]
if(C)
//C << browse(vote.interface(C),"window=vote;can_close=0")
client_popup = new(C, "vote", "Voting Panel")
client_popup.set_window_options("can_close=0")
client_popup.set_content(vote.interface(C))
client_popup.open(0)
-
+
i++
else
voting.Cut(i,i+1)
+ proc/autotransfer()
+ initiate_vote("crew_transfer","the server")
+
proc/reset()
initiator = null
time_remaining = 0
@@ -78,6 +81,23 @@ datum/controller/vote
choices[master_mode] += non_voters
if(choices[master_mode] >= greatest_votes)
greatest_votes = choices[master_mode]
+ else if(mode == "crew_transfer")
+ var/factor = 0.5
+ switch(world.time / (10 * 60)) // minutes
+ if(0 to 60)
+ factor = 0.5
+ if(61 to 120)
+ factor = 0.8
+ if(121 to 240)
+ factor = 1
+ if(241 to 300)
+ factor = 1.2
+ else
+ factor = 1.4
+ choices["Initiate Crew Transfer"] = round(choices["Initiate Crew Transfer"] * factor)
+ world << "<font color='purple'>Crew Transfer Factor: [factor]</font>"
+ greatest_votes = max(choices["Initiate Crew Transfer"], choices["Continue The Round"])
+
//get all options with that many votes and return them in a list
. = list()
if(greatest_votes)
@@ -126,7 +146,9 @@ datum/controller/vote
restart = 1
else
master_mode = .
-
+ if("crew_transfer")
+ if(. == "Initiate Crew Transfer")
+ init_shift_change(null, 1)
if(restart)
world << "World restarting due to vote..."
feedback_set_details("end_error","restart vote")
@@ -161,6 +183,19 @@ datum/controller/vote
switch(vote_type)
if("restart") choices.Add("Restart Round","Continue Playing")
if("gamemode") choices.Add(config.votable_modes)
+ if("crew_transfer")
+ if(check_rights(R_ADMIN, 0))
+ question = "End the shift?"
+ choices.Add("Initiate Crew Transfer", "Continue The Round")
+ else
+ if (get_security_level() == "red" || get_security_level() == "delta")
+ initiator_key << "The current alert status is too high to call for a crew transfer!"
+ return 0
+ if(ticker.current_state <= 2)
+ return 0
+ initiator_key << "The crew transfer button has been disabled!"
+ question = "End the shift?"
+ choices.Add("Initiate Crew Transfer", "Continue The Round")
if("custom")
question = html_encode(input(usr,"What is the vote for?") as text|null)
if(!question) return 0
@@ -177,6 +212,11 @@ datum/controller/vote
text += "\n[question]"
log_vote(text)
world << "\n<font color='purple'><b>[text]</b>\nType <b>vote</b> to place your votes.\nYou have [config.vote_period/10] seconds to vote.</font>"
+ switch(vote_type)
+ if("crew_transfer")
+ world << sound('sound/misc/votealarm.ogg')
+ if("gamemode")
+ world << sound('sound/misc/votealarm.ogg')
time_remaining = round(config.vote_period/10)
return 1
return 0
@@ -209,6 +249,11 @@ datum/controller/vote
. += "<a href='?src=\ref[src];vote=restart'>Restart</a>"
else
. += "<font color='grey'>Restart (Disallowed)</font>"
+ . += "</li><li>"
+ if(trialmin || config.allow_vote_restart)
+ . += "<a href='?src=\ref[src];vote=crew_transfer'>Crew Transfer</a>"
+ else
+ . += "<font color='grey'>Crew Transfer (Disallowed)</font>"
if(trialmin)
. += "\t(<a href='?src=\ref[src];vote=toggle_restart'>[config.allow_vote_restart?"Allowed":"Disallowed"]</a>)"
. += "</li><li>"
@@ -251,6 +296,9 @@ datum/controller/vote
if("gamemode")
if(config.allow_vote_mode || usr.client.holder)
initiate_vote("gamemode",usr.key)
+ if("crew_transfer")
+ if(config.allow_vote_restart || usr.client.holder)
+ initiate_vote("crew_transfer",usr.key)
if("custom")
if(usr.client.holder)
initiate_vote("custom",usr.key)
@@ -32,6 +32,7 @@ var/const/CALL_SHUTTLE_REASON_LENGTH = 12
var/const/STATE_ALERT_LEVEL = 8
var/const/STATE_CONFIRM_LEVEL = 9
var/const/STATE_TOGGLE_EMERGENCY = 10
+ var/const/STATE_CREWTRANSFER = 11
var/status_display_freq = "1435"
var/stat_msg1
@@ -605,6 +606,39 @@ var/const/CALL_SHUTTLE_REASON_LENGTH = 12
return
+/proc/init_shift_change(var/mob/user, var/force = 0)
+ if ((!( ticker ) || emergency_shuttle.location))
+ return
+
+ if(emergency_shuttle.direction == -1)
+ user << "The shuttle may not be called while returning to CentCom."
+ return
+
+ if(emergency_shuttle.online)
+ user << "The shuttle is already on its way."
+ return
+
+ // if force is 0, some things may stop the shuttle call
+ if(!force)
+
+ if(world.time < 54000) // 30 minute grace period to let the game get going
+ user << "The shuttle is refueling. Please wait another [round((54000-world.time)/600)] minutes before trying again."//may need to change "/600"
+ return
+
+ if(ticker.mode.name == "revolution" || ticker.mode.name == "AI malfunction" || ticker.mode.name == "sandbox")
+ //New version pretends to call the shuttle but cause the shuttle to return after a random duration.
+ emergency_shuttle.fake_recall = rand(300,500)
+
+ if(ticker.mode.name == "blob" || ticker.mode.name == "epidemic")
+ user << "Under directive 7-10, [station_name()] is quarantined until further notice."
+ return
+
+ emergency_shuttle.incall()
+ log_game("[key_name(user)] has called the shuttle.")
+ message_admins("[key_name_admin(user)] has called the shuttle.", 1)
+ priority_announce("A crew transfer has been initiated. The shuttle to Central Command has been called. It will arrive in [round(emergency_shuttle.timeleft()/60)] minutes.", null, 'sound/AI/attention.ogg', "Priority")
+
+ return
/proc/cancel_call_proc(var/mob/user)
if ((!( ticker ) || emergency_shuttle.location || emergency_shuttle.direction == 0))
View
@@ -80,6 +80,12 @@ VOTE_DELAY 6000
## time period (deciseconds) which voting session will last (default 1 minute)
VOTE_PERIOD 600
+## autovote initial delay (deciseconds) before first automatic transfer vote call (default 120 minutes)
+VOTE_AUTOTRANSFER_INITIAL 72000
+
+## autovote delay (deciseconds) before sequential automatic transfer votes are called (default 60 minutes)
+Vote_AUTOTRANSFER_INTERVAL 36000
+
## prevents dead players from voting or starting votes
# NO_DEAD_VOTE
Binary file not shown.

0 comments on commit 58f703a

Please sign in to comment.