Implements a new auto-tagging system for ID card which adds a config to auto-flag them as an intern. (#58236)

About The Pull Request

ID cards when equipped will check the player's living hours if the USE_LOW_LIVING_HOUR_INTERN flag is set. If their living hours is less than the first of the following (checked in order from 1st to 3rd until a valid value is found):

    Config USE_LOW_LIVING_HOUR_INTERN_HOURS
    Config USE_EXP_RESTRICTIONS_HEADS_HOURS
    Hardcoded 15 hours

Then their ID card is tagged as Intern Assignment, unless they're a Head of Staff in which case they become an Assignment-in-Training.

PDAs, Wallets and Tablets also update any ID cards they hold, so equipping a PDA, Tablet or Wallet will also update any ID cards inside it.

This occurs automatically, even if the card does not belong to the owner. This only occurs when the user's assigned_role is a station job.
This commit is contained in:
Timberpoes
2021-04-13 01:24:27 +01:00
committed by GitHub
parent a9892da81e
commit 9034dab179
5 changed files with 117 additions and 2 deletions

View File

@@ -205,6 +205,13 @@
/datum/config_entry/flag/use_exp_restrictions_admin_bypass /datum/config_entry/flag/use_exp_restrictions_admin_bypass
/datum/config_entry/flag/use_low_living_hour_intern
/datum/config_entry/number/use_low_living_hour_intern_hours
config_entry_value = 0
integer = FALSE
min_val = 0
/datum/config_entry/string/server /datum/config_entry/string/server
/datum/config_entry/string/banappeals /datum/config_entry/string/banappeals

View File

@@ -18,6 +18,8 @@ SUBSYSTEM_DEF(job)
/// A list of all jobs associated with the station. These jobs also have various icons associated with them including sechud and card trims. /// A list of all jobs associated with the station. These jobs also have various icons associated with them including sechud and card trims.
var/list/station_jobs var/list/station_jobs
/// A list of all Head of Staff jobs.
var/list/head_of_staff_jobs
/// A list of additional jobs that have various icons associated with them including sechud and card trims. /// A list of additional jobs that have various icons associated with them including sechud and card trims.
var/list/additional_jobs_with_icons var/list/additional_jobs_with_icons
/// A list of jobs associed with Centcom and should use the standard NT Centcom icons. /// A list of jobs associed with Centcom and should use the standard NT Centcom icons.
@@ -772,6 +774,8 @@ SUBSYSTEM_DEF(job)
"Atmospheric Technician", "Chief Medical Officer", "Medical Doctor", "Paramedic", "Chemist", "Geneticist", "Virologist", "Psychologist", \ "Atmospheric Technician", "Chief Medical Officer", "Medical Doctor", "Paramedic", "Chemist", "Geneticist", "Virologist", "Psychologist", \
"Research Director", "Scientist", "Roboticist", "Head of Security", "Warden", "Detective", "Security Officer", "Prisoner") "Research Director", "Scientist", "Roboticist", "Head of Security", "Warden", "Detective", "Security Officer", "Prisoner")
head_of_staff_jobs = list("Head of Personnel", "Chief Engineer", "Chief Medical Officer", "Research Director", "Head of Security", "Captain")
additional_jobs_with_icons = list("Emergency Response Team Commander", "Security Response Officer", "Engineering Response Officer", "Medical Response Officer", \ additional_jobs_with_icons = list("Emergency Response Team Commander", "Security Response Officer", "Engineering Response Officer", "Medical Response Officer", \
"Entertainment Response Officer", "Religious Response Officer", "Janitorial Response Officer", "Death Commando", "Security Officer (Engineering)", \ "Entertainment Response Officer", "Religious Response Officer", "Janitorial Response Officer", "Death Commando", "Security Officer (Engineering)", \
"Security Officer (Cargo)", "Security Officer (Medical)", "Security Officer (Science)") "Security Officer (Cargo)", "Security Officer (Medical)", "Security Officer (Science)")

View File

@@ -4,6 +4,9 @@
*/ */
#define ID_ICON_BORDERS 1, 9, 32, 24 #define ID_ICON_BORDERS 1, 9, 32, 24
/// Fallback time if none of the config entries are set for USE_LOW_LIVING_HOUR_INTERN
#define INTERN_THRESHOLD_FALLBACK_HOURS 15
/* Cards /* Cards
* Contains: * Contains:
* DATA CARD * DATA CARD
@@ -106,6 +109,9 @@
/// List of wildcard slot names as keys with lists of wildcard data as values. /// List of wildcard slot names as keys with lists of wildcard data as values.
var/list/wildcard_slots = list() var/list/wildcard_slots = list()
/// Boolean value. If TRUE, the [Intern] tag gets prepended to this ID card when the label is updated.
var/is_intern = FALSE
/obj/item/card/id/Initialize(mapload) /obj/item/card/id/Initialize(mapload)
. = ..() . = ..()
@@ -618,8 +624,18 @@
/// Updates the name based on the card's vars and state. /// Updates the name based on the card's vars and state.
/obj/item/card/id/proc/update_label() /obj/item/card/id/proc/update_label()
var/blank = !registered_name var/name_string = registered_name ? "[registered_name]'s ID Card" : initial(name)
name = "[blank ? initial(name) : "[registered_name]'s ID Card"][(!assignment) ? "" : " ([assignment])"]" var/assignment_string
if(is_intern)
if(assignment)
assignment_string = (assignment in SSjob.head_of_staff_jobs) ? " ([assignment]-in-Training)" : " (Intern [assignment])"
else
assignment_string = " (Intern)"
else
assignment_string = " ([assignment])"
name = "[name_string][assignment_string]"
/obj/item/card/id/away /obj/item/card/id/away
name = "\proper a perfectly generic identification card" name = "\proper a perfectly generic identification card"
@@ -716,6 +732,88 @@
/// If this is set, will manually override the trim's assignmment for SecHUDs. Intended for admins to VV edit and chameleon ID cards. /// If this is set, will manually override the trim's assignmment for SecHUDs. Intended for admins to VV edit and chameleon ID cards.
var/trim_assignment_override var/trim_assignment_override
/obj/item/card/id/advanced/Initialize(mapload)
. = ..()
RegisterSignal(src, COMSIG_ITEM_EQUIPPED, .proc/update_intern_status)
RegisterSignal(src, COMSIG_ITEM_DROPPED, .proc/remove_intern_status)
/obj/item/card/id/advanced/Destroy()
UnregisterSignal(src, COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)
return ..()
/obj/item/card/id/advanced/proc/update_intern_status(datum/source, mob/user)
SIGNAL_HANDLER
if(!user?.client)
return
if(!CONFIG_GET(flag/use_exp_tracking))
return
if(!CONFIG_GET(flag/use_low_living_hour_intern))
return
if(!SSdbcore.Connect())
return
var/intern_threshold = (CONFIG_GET(number/use_low_living_hour_intern_hours) * 60) || (CONFIG_GET(number/use_exp_restrictions_heads_hours) * 60) || INTERN_THRESHOLD_FALLBACK_HOURS * 60
var/playtime = user.client.get_exp_living(pure_numeric = TRUE)
if((intern_threshold >= playtime) && (user.mind?.assigned_role in SSjob.station_jobs))
is_intern = TRUE
update_label()
return
if(!is_intern)
return
is_intern = FALSE
update_label()
/obj/item/card/id/advanced/proc/remove_intern_status(datum/source, mob/user)
SIGNAL_HANDLER
if(!is_intern)
return
is_intern = FALSE
update_label()
/obj/item/card/id/advanced/proc/on_holding_card_slot_moved(obj/item/computer_hardware/card_slot/source, atom/old_loc, dir, forced)
if(istype(old_loc, /obj/item/modular_computer/tablet))
UnregisterSignal(old_loc, COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)
if(istype(source.loc, /obj/item/modular_computer/tablet))
RegisterSignal(source.loc, COMSIG_ITEM_EQUIPPED, .proc/update_intern_status)
RegisterSignal(source.loc, COMSIG_ITEM_DROPPED, .proc/remove_intern_status)
/obj/item/card/id/advanced/Moved(atom/OldLoc, Dir)
. = ..()
if(istype(OldLoc, /obj/item/pda) || istype(OldLoc, /obj/item/storage/wallet))
UnregisterSignal(OldLoc, COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)
if(istype(OldLoc, /obj/item/computer_hardware/card_slot))
var/obj/item/computer_hardware/card_slot/slot = OldLoc
UnregisterSignal(OldLoc, COMSIG_MOVABLE_MOVED)
if(istype(slot.holder, /obj/item/modular_computer/tablet))
var/obj/item/modular_computer/tablet/slot_holder = slot.holder
UnregisterSignal(slot_holder, COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)
if(istype(loc, /obj/item/pda) || istype(OldLoc, /obj/item/storage/wallet))
RegisterSignal(loc, COMSIG_ITEM_EQUIPPED, .proc/update_intern_status)
RegisterSignal(loc, COMSIG_ITEM_DROPPED, .proc/remove_intern_status)
if(istype(loc, /obj/item/computer_hardware/card_slot))
var/obj/item/computer_hardware/card_slot/slot = loc
RegisterSignal(loc, COMSIG_MOVABLE_MOVED, .proc/on_holding_card_slot_moved)
if(istype(slot.holder, /obj/item/modular_computer/tablet))
var/obj/item/modular_computer/tablet/slot_holder = slot.holder
RegisterSignal(slot_holder, COMSIG_ITEM_EQUIPPED, .proc/update_intern_status)
RegisterSignal(slot_holder, COMSIG_ITEM_DROPPED, .proc/remove_intern_status)
/obj/item/card/id/advanced/update_overlays() /obj/item/card/id/advanced/update_overlays()
. = ..() . = ..()
@@ -1171,4 +1269,5 @@
desc = "A card used to identify members of the green team for CTF" desc = "A card used to identify members of the green team for CTF"
icon_state = "ctf_green" icon_state = "ctf_green"
#undef INTERN_THRESHOLD_FALLBACK_HOURS
#undef ID_ICON_BORDERS #undef ID_ICON_BORDERS

View File

@@ -118,6 +118,7 @@ GLOBAL_LIST_EMPTY(PDAs)
else else
inserted_item = new /obj/item/pen(src) inserted_item = new /obj/item/pen(src)
RegisterSignal(src, COMSIG_LIGHT_EATER_ACT, .proc/on_light_eater) RegisterSignal(src, COMSIG_LIGHT_EATER_ACT, .proc/on_light_eater)
update_appearance() update_appearance()
/obj/item/pda/equipped(mob/user, slot) /obj/item/pda/equipped(mob/user, slot)

View File

@@ -74,6 +74,10 @@ ENABLE_LOCALHOST_RANK
#USE_EXP_RESTRICTIONS_OTHER #USE_EXP_RESTRICTIONS_OTHER
## Allows admins to bypass job playtime requirements. ## Allows admins to bypass job playtime requirements.
#USE_EXP_RESTRICTIONS_ADMIN_BYPASS #USE_EXP_RESTRICTIONS_ADMIN_BYPASS
## Unhash this to have intern tags automatically added to ID cards for station roles depending on the living hours of the player holding them.
#USE_LOW_LIVING_HOUR_INTERN
## If USE_LOW_LIVING_HOUR_INTERN is unhashed, players under this number of living hours have [Intern] added to their ID card. If this isn't set, uses USE_EXP_RESTRICTIONS_HEADS_HOURS instead. If that isn't set, it finally defaults to a hardcoded fallback of 15 hours.
#USE_LOW_LIVING_HOUR_INTERN_HOURS 50
## log OOC channel ## log OOC channel
LOG_OOC LOG_OOC