[READY TO MERGE] Port's RS's anti job camping to Anomoly (#8618)

This commit is contained in:
tacoguy7765093
2024-07-18 01:52:45 -04:00
committed by GitHub
parent 6423d0ff47
commit c3b129f1a3
8 changed files with 83 additions and 14 deletions

View File

@@ -33,6 +33,7 @@
var/discord_ahelps_disabled = 0 //Turn this off if you don't want the TGS bot sending you messages whenever an ahelp ticket is created. var/discord_ahelps_disabled = 0 //Turn this off if you don't want the TGS bot sending you messages whenever an ahelp ticket is created.
var/discord_ahelps_all = 0 //Turn this on if you want all admin-PMs to go to be sent to discord, and not only the first message of a ticket. var/discord_ahelps_all = 0 //Turn this on if you want all admin-PMs to go to be sent to discord, and not only the first message of a ticket.
var/list/ip_whitelist = list() var/list/ip_whitelist = list()
/hook/startup/proc/read_ch_config() /hook/startup/proc/read_ch_config()
@@ -102,6 +103,8 @@
config.role_request_id_expedition = value config.role_request_id_expedition = value
if ("role_request_id_silicon") if ("role_request_id_silicon")
config.role_request_id_silicon = value config.role_request_id_silicon = value
if("job_camp_time_limit")
config.job_camp_time_limit = value MINUTES
var/list/ip_whitelist_lines = file2list("config/ip_whitelist.txt") var/list/ip_whitelist_lines = file2list("config/ip_whitelist.txt")

View File

@@ -65,3 +65,6 @@
/datum/config_entry/str_list/ip_whitelist /datum/config_entry/str_list/ip_whitelist
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
/datum/config_entry/number/job_camp_time_limit
default = 10 MINUTES

View File

@@ -10,12 +10,20 @@ SUBSYSTEM_DEF(job)
var/list/department_datums = list() var/list/department_datums = list()
var/debug_messages = FALSE var/debug_messages = FALSE
var/savepath = "data/job_camp_list.json" // CHOMPadd
var/list/shift_keys = list() // CHOMPadd
var/list/restricted_keys = list() // CHOMPadd
/datum/controller/subsystem/job/Initialize() // CHOMPEdit /datum/controller/subsystem/job/Initialize() // CHOMPEdit
if(!department_datums.len) if(!department_datums.len)
setup_departments() setup_departments()
if(!occupations.len) if(!occupations.len)
setup_occupations() setup_occupations()
//CHOMPadd begin
if(CONFIG_GET(number/job_camp_time_limit))
load_camp_lists()
//CHOMPadd end
return SS_INIT_SUCCESS // CHOMPEdit return SS_INIT_SUCCESS // CHOMPEdit
/datum/controller/subsystem/job/proc/setup_occupations(faction = "Station") /datum/controller/subsystem/job/proc/setup_occupations(faction = "Station")
@@ -141,3 +149,24 @@ SUBSYSTEM_DEF(job)
/datum/controller/subsystem/job/proc/job_debug_message(message) /datum/controller/subsystem/job/proc/job_debug_message(message)
if(debug_messages) if(debug_messages)
log_debug("JOB DEBUG: [message]") log_debug("JOB DEBUG: [message]")
//CHOMPadd start
/datum/controller/subsystem/job/proc/load_camp_lists()
if(fexists(savepath))
restricted_keys = json_decode(file2text(savepath))
fdel(savepath)
/datum/controller/subsystem/job/Shutdown(Addr, Natural)
. = ..()
if(fexists(savepath))
fdel(savepath)
var/json_to_file = json_encode(shift_keys)
if(!json_to_file)
log_debug("Saving: [savepath] failed jsonencode")
return
//Write it out
rustg_file_write(json_to_file, savepath)
if(!fexists(savepath))
log_debug("Saving: failed to save [savepath]")
//CHOMPadd end

View File

@@ -39,6 +39,10 @@
// Description of the job's role and minimum responsibilities. // Description of the job's role and minimum responsibilities.
var/job_description = "This Job doesn't have a description! Please report it!" var/job_description = "This Job doesn't have a description! Please report it!"
var/camp_protection = FALSE //CHOMPadd
var/list/restricted_keys = list() //CHOMPadd
var/list/shift_keys = list() //CHOMPadd
/datum/job/New() /datum/job/New()
. = ..() . = ..()
department_accounts = department_accounts || departments_managed department_accounts = department_accounts || departments_managed
@@ -189,6 +193,13 @@
return TRUE return TRUE
*/ */
//CHOMPadd start
/datum/job/proc/register_shift_key(key)
if(key)
var/list/keylist = list(key)
SSjob.shift_keys[title] += keylist
//CHOMPadd end
//CHOMPAdd Start //CHOMPAdd Start
/datum/job/proc/update_limit(var/comperator) /datum/job/proc/update_limit(var/comperator)
return return

View File

@@ -72,6 +72,10 @@ var/global/datum/controller/occupations/job_master
player.mind.role_alt_title = GetPlayerAltTitle(player, rank) player.mind.role_alt_title = GetPlayerAltTitle(player, rank)
unassigned -= player unassigned -= player
job.current_positions++ job.current_positions++
//CHOMPadd START
if(job.camp_protection && round_duration_in_ds < transfer_controller.shift_hard_end - 30 MINUTES)
job.register_shift_key(player.client.ckey)
//CHOMPadd END
return 1 return 1
Debug("AR has failed, Player: [player], Rank: [rank]") Debug("AR has failed, Player: [player], Rank: [rank]")
return 0 return 0

View File

@@ -177,7 +177,17 @@
return return
if(newassignment != newjob.title && !(newassignment in newjob.alt_titles)) if(newassignment != newjob.title && !(newassignment in newjob.alt_titles))
return return
//CHOMPadd START
if(newjob.camp_protection && round_duration_in_ds < CONFIG_GET(number/job_camp_time_limit))
if(SSjob.restricted_keys.len)
var/list/check = SSjob.restricted_keys[newjob.title]
if(usr.client.ckey in check)
to_chat(usr,span_danger("[newjob.title] is not presently selectable because you played as it last round. It will become available to you in [round((CONFIG_GET(number/job_camp_time_limit) - round_duration_in_ds) / 600)] minutes, if slots remain open."))
return
//CHOMPadd END
if(newjob) if(newjob)
newjob.register_shift_key(usr.client.ckey)//CHOMPadd
card.access = newjob.get_access() card.access = newjob.get_access()
card.rank = newjob.title card.rank = newjob.title
card.assignment = newassignment card.assignment = newassignment

View File

@@ -74,6 +74,14 @@
if(points_left < 0 || traits_left < 0) if(points_left < 0 || traits_left < 0)
pass = FALSE pass = FALSE
to_chat(src,"<span class='warning'>Your custom species is not playable. Reconfigure your traits on the VORE tab.</span>") to_chat(src,"<span class='warning'>Your custom species is not playable. Reconfigure your traits on the VORE tab.</span>")
//CHOMPadd start
if(J.camp_protection && round_duration_in_ds < CONFIG_GET(number/job_camp_time_limit))
if(SSjob.restricted_keys.len)
var/list/check = SSjob.restricted_keys[J.title]
if(client.ckey in check)
to_chat(client,span_danger("[J.title] is not presently selectable because you played as it last round. It will become available to you in [round(CONFIG_GET(number/job_camp_time_limit - round_duration_in_ds) / 600)] minutes, if slots remain open."))
pass = FALSE
//CHOMPadd end
//CHOMP Addition Begin //CHOMP Addition Begin
if(client?.prefs?.neu_traits) if(client?.prefs?.neu_traits)

View File

@@ -45,6 +45,7 @@
assignable = FALSE assignable = FALSE
account_allowed = 0 account_allowed = 0
offmap_spawn = TRUE offmap_spawn = TRUE
camp_protection = TRUE //So far leave this for shadekin
outfit_type = /decl/hierarchy/outfit/noncrew outfit_type = /decl/hierarchy/outfit/noncrew
job_description = {"Players taking a role of an outsider not employed by NT with no special mechanics. One superpose pod is provided. job_description = {"Players taking a role of an outsider not employed by NT with no special mechanics. One superpose pod is provided.