Request Emergency Temporary Access - RETA (#92753)

<img width="819" height="348" alt="image"
src="https://github.com/user-attachments/assets/0424ec76-2648-43d3-8e94-d44558b44bcf"
/>

## About The Pull Request

Follow up from #92751 - Not to conflict with it but as an idea on how to
change it for the long run.

Paramedics currently start with broad department access. This proposal
replaces that by granting temporary department access only when an
emergency is called.

When a player presses "Call X" on a Requests Console, responders called
receive temporary access to the common work areas of that department.

![image](https://hackmd.io/_uploads/r1xNOv0Fle.png)
> [Security] The Automated Announcement System coldly states, "SECURITY
EMERGENCY in Research Lab! (Called by Sloan Keppel, Scientist) RETA door
access granted to responders."

> [Science] The Automated Announcement System coldly states, "RETA
activated (Called by Sloan Keppel, Scientist). Security personnel now
have temporary access to your areas."

They do not receive access to sub rooms or high risk areas.

- Access lasts 5 minutes (configurable)  
- Access is removed when the timer expires or the emergency is resolved
- No mapping changes are required (uses existing request consoles)  
- Removes Paramedics round start access but gives them external access
to rescue bodies in space by default
- Flashing blue lights on doors affected by temporary access
<img width="897" height="837" alt="image"
src="https://github.com/user-attachments/assets/97980cb4-3481-44b6-9f96-fc241ca16f57"
/>


**The full document is here:
https://hackmd.io/@NM8HxpG_Toahg5pimrpsKw/Hk0tKq3Yxe**

**Wiki documentation for players and admins:
https://wiki.tgstation13.org/Guide_To_RETA**


## Why It's Good For The Game

- Removes paramedics’ broad “Doctor+” access.
- Keeps them effective as emergency responders.
- Responders must be called in OR access upgraded.
- Keeps sensitive areas secure.
- Prevents spam or stacking through cooldown.
- Scales across all maps without mapper work.
- Gives admins a new tool for temp department wide access
- Dedicated logging file and unit tests
- Very performant, only affects living players with connected mind
- Gives Request Consoles more use as an alarm button and further utility
- Imagine later on "Request Janitor" which sorts access and tells
Janitor where needed

## Changelog
🆑
add: RETA System - Request Consoles give temporary access to responders
when used for some areas. Paramedics lose broad access but get external
space access.
qol: Request consoles now show name and job role on call message &
Cooldown on spamming calls + sound prompt
qol: Medibot access no longer based on Paramedic trim ID - Still has
original access
image: Added "lights_reta" for temporary door access when in effect
admin: Gives admins "RETA door access" verb for giving department wide
area access on maps.
config: New config settings for RETA

/🆑
This commit is contained in:
SimplyLogan
2025-09-11 00:33:40 +01:00
committed by GitHub
parent 9f356f8b9a
commit a1fdc715df
20 changed files with 1052 additions and 16 deletions

View File

@@ -4,6 +4,7 @@
#define AIRLOCK_LIGHT_DENIED "denied"
#define AIRLOCK_LIGHT_CLOSING "closing"
#define AIRLOCK_LIGHT_OPENING "opening"
#define AIRLOCK_LIGHT_RETA "reta"
// Airlock physical states
#define AIRLOCK_CLOSED "closed"

View File

@@ -41,6 +41,8 @@ DECLARE_LOG_NAMED(harddel_log, "harddels", START_LOG)
DECLARE_LOG_NAMED(test_log, "tests", START_LOG)
#endif
DECLARE_LOG_NAMED(reta_log, "reta", START_LOG)
/// Picture logging
GLOBAL_VAR(picture_log_directory)

8
code/_globalvars/reta.dm Normal file
View File

@@ -0,0 +1,8 @@
/// Used by RETA system - code/modules/reta/reta_system.dm
GLOBAL_LIST_EMPTY(reta_job_trims)
GLOBAL_LIST_EMPTY(reta_dept_grants)
GLOBAL_LIST_EMPTY(reta_cooldown)
GLOBAL_LIST_EMPTY(reta_recent_calls)
GLOBAL_LIST_EMPTY(reta_active_grants)
GLOBAL_LIST_EMPTY(reta_consoles_by_origin)
GLOBAL_LIST_EMPTY(reta_active_cards)

View File

@@ -0,0 +1,20 @@
/**
* Request Emergency Temporary Access - RETA - Config
* code\modules\reta\reta_system.dm
*/
/// RETA system is enabled
/datum/config_entry/flag/reta_enabled
default = TRUE
/// Duration for how long temporary access lasts (default: 5 minutes)
/datum/config_entry/number/reta_duration_ds
default = 3000
min_val = 300
integer = FALSE
/// Cooldown between RETA calls from the same origin to the same target department (default: 15 seconds)
/datum/config_entry/number/reta_dept_cooldown_ds
default = 150
min_val = 0
integer = FALSE

View File

@@ -97,6 +97,13 @@ SUBSYSTEM_DEF(job)
if(CONFIG_GET(flag/load_jobs_from_txt))
load_jobs_from_config()
set_overflow_role(CONFIG_GET(string/overflow_job)) // this must always go after load_jobs_from_config() due to how the legacy systems operate, this always takes precedent.
// Initialize RETA system - must be after setup_occupations() so all jobs are loaded - code/modules/reta/reta_system.dm
log_game("RETA: Jobs subsystem Initialize() calling RETA initialization")
initialize_reta_system()
populate_reta_job_trims()
log_game("RETA: Jobs subsystem Initialize() RETA initialization completed")
return SS_INIT_SUCCESS
/// Returns a list of jobs that we are allowed to fuck with during random events

View File

@@ -417,6 +417,9 @@ SUBSYSTEM_DEF(id_access)
id_card.update_label()
id_card.update_icon()
// Apply any currently active RETA grants to this newly trimmed card
apply_active_reta_grants_to_card(id_card)
return TRUE
/**
@@ -459,6 +462,9 @@ SUBSYSTEM_DEF(id_access)
var/mob/living/carbon/human/owner = id_card.loc
owner.update_ID_card()
// Apply any currently active RETA grants to this card with updated trim override
apply_active_reta_grants_to_card(id_card)
/**
* Removes a trim from a ID card.
*
@@ -501,6 +507,9 @@ SUBSYSTEM_DEF(id_access)
var/datum/id_trim/job/job_trim = trim // Here is where we update a player's paycheck department for the purposes of discounts/paychecks.
id_card.registered_account.account_job.paycheck_department = job_trim.job.paycheck_department
// Apply any currently active RETA grants to this card with updated trim access
apply_active_reta_grants_to_card(id_card)
/**
* Tallies up all accesses the card has that have flags greater than or equal to the access_flag supplied.
*

View File

@@ -831,10 +831,11 @@
subdepartment_color = COLOR_MEDICAL_BLUE
sechud_icon_state = SECHUD_PARAMEDIC
minimal_access = list(
ACCESS_MAINT_TUNNELS,
ACCESS_MECH_MEDICAL,
ACCESS_EXTERNAL_AIRLOCKS,
ACCESS_MEDICAL,
ACCESS_MAINT_TUNNELS,
ACCESS_MORGUE,
ACCESS_MECH_MEDICAL,
)
extra_access = list(
ACCESS_BIT_DEN,

View File

@@ -503,6 +503,32 @@
/obj/machinery/door/airlock/proc/is_secure()
return (security_level > 0)
/// Checks if this door would be affected by any currently active RETA grants
/obj/machinery/door/airlock/proc/has_active_reta_access()
if(!CONFIG_GET(flag/reta_enabled))
return FALSE
if(!length(req_access) && !length(req_one_access))
return FALSE
// Check if this door belongs to a department providing access via RETA
for(var/target_dept in GLOB.reta_active_grants)
var/list/active_origins = GLOB.reta_active_grants[target_dept]
for(var/origin_dept in active_origins)
var/list/origin_dept_access = GLOB.reta_dept_grants[origin_dept]
if(!origin_dept_access)
continue
for(var/required_access in req_access)
if(required_access in origin_dept_access)
return TRUE
for(var/required_access in req_one_access)
if(required_access in origin_dept_access)
return TRUE
return FALSE
/**
* Set the airlock state to a new value, change the icon state
* and run the associated animation if required.
@@ -547,6 +573,8 @@
light_state = AIRLOCK_LIGHT_BOLTS
else if(emergency)
light_state = AIRLOCK_LIGHT_EMERGENCY
else if(has_active_reta_access())
light_state = AIRLOCK_LIGHT_RETA
if(AIRLOCK_DENY)
frame_state = AIRLOCK_FRAME_CLOSED
light_state = AIRLOCK_LIGHT_DENIED

View File

@@ -122,11 +122,23 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
GLOB.req_console_all += src
GLOB.req_console_ckey_departments[ckey(department)] = department // and then we set ourselves a listed name
// Register this console for RETA UI updates - code/modules/reta/reta_system.dm
var/dept_key = reta_get_user_department_by_name(department)
if(dept_key)
LAZYADD(GLOB.reta_consoles_by_origin[dept_key], src)
find_and_hang_on_wall()
/obj/machinery/requests_console/Destroy()
QDEL_LIST(messages)
GLOB.req_console_all -= src
// Remove from RETA console registry
var/dept_key = reta_get_user_department_by_name(department)
if(dept_key)
LAZYREMOVE(GLOB.reta_consoles_by_origin[dept_key], src)
return ..()
/obj/machinery/requests_console/ui_interact(mob/user, datum/tgui/ui)
@@ -162,14 +174,104 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
if("set_emergency")
if(emergency)
return
emergency = params["emergency"]
switch(params["emergency"])
if(REQ_EMERGENCY_SECURITY) //Security
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = department), null, list(RADIO_CHANNEL_SECURITY), REQ_EMERGENCY_SECURITY)
if(REQ_EMERGENCY_ENGINEERING) //Engineering
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = department), null, list(RADIO_CHANNEL_ENGINEERING), REQ_EMERGENCY_ENGINEERING)
if(REQ_EMERGENCY_MEDICAL) //Medical
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = department), null, list(RADIO_CHANNEL_MEDICAL), REQ_EMERGENCY_MEDICAL)
// Check for RETA eligibility
var/emergency_type = params["emergency"]
var/origin_dept = reta_get_user_department_by_name(department)
var/target_dept = null
switch(emergency_type)
if(REQ_EMERGENCY_SECURITY)
target_dept = "Security"
if(REQ_EMERGENCY_ENGINEERING)
target_dept = "Engineering"
if(REQ_EMERGENCY_MEDICAL)
target_dept = "Medical"
// Check if user can call this emergency (prevent self-calls) RETA
var/user_dept = reta_get_user_department(usr)
if(user_dept == target_dept)
to_chat(usr, span_alert("You cannot call your own department for emergency assistance."))
return
// Check cooldown RETA
if(origin_dept && target_dept && reta_on_cooldown(origin_dept, target_dept))
to_chat(usr, span_alert("Emergency calls to [target_dept] are on cooldown."))
return
emergency = emergency_type
// Grant RETA if conditions are met
if(origin_dept && target_dept && CONFIG_GET(flag/reta_enabled))
// Set cooldown
var/cooldown_ds = CONFIG_GET(number/reta_dept_cooldown_ds) || 150
reta_set_cooldown(origin_dept, target_dept, cooldown_ds)
// Find responders and grant access to their ID cards
var/duration_ds = CONFIG_GET(number/reta_duration_ds) || 3000
var/granted_count = reta_find_and_grant_access(target_dept, origin_dept, duration_ds)
// Track this call for multiple department analysis
reta_track_call(origin_dept, target_dept)
// Enhanced announcement with caller info
var/caller_info = ""
if(usr)
var/caller_name = usr.real_name || "Unknown"
var/caller_title = "Unknown Position"
if(usr?.mind?.assigned_role)
caller_title = usr.mind.assigned_role.title
caller_info = " (Called by [caller_name], [caller_title])"
var/enhanced_location = "[department][caller_info]"
switch(emergency_type)
if(REQ_EMERGENCY_SECURITY)
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_SECURITY), REQ_EMERGENCY_SECURITY)
if(REQ_EMERGENCY_ENGINEERING)
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_ENGINEERING), REQ_EMERGENCY_ENGINEERING)
if(REQ_EMERGENCY_MEDICAL)
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_MEDICAL), REQ_EMERGENCY_MEDICAL)
// Send confirmation to the calling department about the RETA activation
var/calling_message = "RETA activated[caller_info]. [target_dept] personnel now have temporary access to your areas."
// Get an announcement system to send simple radio messages
var/obj/machinery/announcement_system/announcer = get_announcement_system(null, null, list(RADIO_CHANNEL_COMMON))
if(announcer)
switch(origin_dept)
if("Security")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SECURITY)
if("Engineering")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_ENGINEERING)
if("Medical")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_MEDICAL)
if("Science")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SCIENCE)
if("Service")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SERVICE)
if("Command")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_COMMAND)
if("Cargo")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SUPPLY)
if("Mining")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SUPPLY)
// Log RETA activity
log_game("RETA: [origin_dept] called [target_dept] emergency, granted access to [granted_count] responder IDs for [duration_ds/10] seconds")
// Push UI updates to consoles in the same origin department
reta_push_ui_updates(origin_dept, target_dept)
else
// Normal emergency call without RETA
switch(emergency_type)
if(REQ_EMERGENCY_SECURITY)
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = department), null, list(RADIO_CHANNEL_SECURITY), REQ_EMERGENCY_SECURITY)
if(REQ_EMERGENCY_ENGINEERING)
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = department), null, list(RADIO_CHANNEL_ENGINEERING), REQ_EMERGENCY_ENGINEERING)
if(REQ_EMERGENCY_MEDICAL)
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = department), null, list(RADIO_CHANNEL_MEDICAL), REQ_EMERGENCY_MEDICAL)
update_appearance()
addtimer(CALLBACK(src, PROC_REF(clear_emergency)), 5 MINUTES)
return TRUE
@@ -290,6 +392,20 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
data["messages"] = list()
for (var/datum/request_message/message in messages)
data["messages"] += list(message.message_ui_data())
// Add RETA data
data["reta_enabled"] = CONFIG_GET(flag/reta_enabled)
var/origin_dept = reta_get_user_department_by_name(department)
var/user_dept = reta_get_user_department(user)
data["reta_cooldowns"] = list()
if(origin_dept)
data["reta_cooldowns"]["Security"] = reta_on_cooldown(origin_dept, "Security")
data["reta_cooldowns"]["Engineering"] = reta_on_cooldown(origin_dept, "Engineering")
data["reta_cooldowns"]["Medical"] = reta_on_cooldown(origin_dept, "Medical")
data["reta_user_dept"] = user_dept
return data
@@ -313,6 +429,10 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
emergency = null
update_appearance()
/// Updates the UI for all viewers
/obj/machinery/requests_console/proc/ui_update()
SStgui.update_uis(src)
/// From message_server.dm: Console.create_message(data)
/obj/machinery/requests_console/proc/create_message(data)
@@ -418,12 +538,12 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/requests_console/auto_name, 30)
/datum/aas_config_entry/rc_emergency
name = "RC Alert: Emergency"
announcement_lines_map = list(
"Security" = "Security emergency in %LOCATION!!!",
"Engineering" = "Engineering emergency in %LOCATION!!!",
"Medical" = "Medical emergency in %LOCATION!!!",
"Security" = "SECURITY EMERGENCY in %LOCATION - RETA door access granted to responders!",
"Engineering" = "ENGINEERING EMERGENCY in %LOCATION - RETA door access granted to responders!",
"Medical" = "MEDICAL EMERGENCY in %LOCATION - RETA door access granted to responders!",
)
vars_and_tooltips_map = list(
"LOCATION" = "will be replaced with the department name",
"LOCATION" = "will be replaced with the department name and caller information (Name, Job Title)",
)
/datum/aas_config_entry/rc_new_message

View File

@@ -148,6 +148,10 @@
update_label()
update_icon()
// Apply any active RETA grants to this new ID card
// This will only do something if there are active grants, so it's safe to call always
apply_active_reta_grants_to_card(src)
register_item_context()
register_context()
@@ -893,7 +897,14 @@
return .
/obj/item/card/id/GetAccess()
return access.Copy()
var/list/total_access = access.Copy()
// Add all RETA temporary access from all departments - code/modules/reta/reta_system.dm
for(var/dept in reta_temp_access)
if(reta_temp_access[dept])
total_access |= reta_temp_access[dept]
return total_access
/obj/item/card/id/GetID()
return src

View File

@@ -167,6 +167,9 @@ GLOBAL_VAR(restart_counter)
load_poll_data()
// Initialize RETA system - code/modules/reta/reta_system.dm
reta_init_config()
LoadVerbs(/datum/verbs/menu)
if(fexists(RESTART_COUNTER_PATH))

View File

@@ -0,0 +1,122 @@
/**
* Request Emergency Temporary Access - Admin Verbs
*/
/// Admin command to manually trigger RETA access grant for admins
ADMIN_VERB(reta_manual_trigger, R_ADMIN, "RETA Door Access", "Manually trigger RETA access for testing", ADMIN_CATEGORY_EVENTS)
var/calling_dept = tgui_input_list(user, "RETA - Which department is CALLING for help?", "Calling Department", list("Security", "Engineering", "Medical", "Science", "Service", "Command", "Cargo", "Mining"))
if(!calling_dept)
return
var/list/available_depts = list("Security", "Engineering", "Medical", "Science", "Service", "Command", "Cargo", "Mining")
available_depts -= calling_dept
// Multi-select using repeated input_list calls
var/list/selected_depts = list()
var/list/remaining_depts = available_depts.Copy()
while(length(remaining_depts))
remaining_depts += "DONE - Finish selection"
var/choice = tgui_input_list(user, "RETA - Select departments to RESPOND to [calling_dept]\nCurrently selected: [english_list(selected_depts)]\n\nSelect another department or DONE:", "Responding Departments", remaining_depts)
if(!choice || choice == "DONE - Finish selection")
break
selected_depts += choice
remaining_depts -= choice
remaining_depts -= "DONE - Finish selection"
if(!length(selected_depts))
message_admins("No departments selected for RETA response.")
return
var/duration = tgui_input_number(user, "Duration in minutes:", "RETA Duration", 5, 60, 1)
if(!duration)
return
message_admins("[key_name_admin(user)] is manually triggering RETA: [calling_dept] called for help, [english_list(selected_depts)] will get access to [calling_dept] areas for [duration] minutes.")
log_game("ADMIN: [key_name(user)] is manually triggering RETA: [calling_dept] called for help, [english_list(selected_depts)] will get access to [calling_dept] areas for [duration] minutes.")
// Grant access to each responding department and collect results
var/successful_grants = 0
var/list/granted_depts = list()
var/total_eligible_cards = 0
for(var/responding_dept in selected_depts)
var/dept_eligible_cards = 0
var/list/job_trims = GLOB.reta_job_trims[responding_dept]
for(var/mob/living/carbon/human/human_player as anything in GLOB.human_list)
if(!human_player.client || human_player.stat == DEAD)
continue
var/obj/item/card/id/id_card = human_player.get_idcard(hand_first = FALSE)
if(!id_card || !id_card.trim)
continue
if(is_type_in_list(id_card.trim, job_trims))
dept_eligible_cards++
total_eligible_cards += dept_eligible_cards
message_admins("[responding_dept] department: [dept_eligible_cards] eligible cards from living players")
// Note: RETA grants access FROM calling_dept TO responding_dept personnel
// So if Medical calls Security, Security personnel get Medical access
if(reta_find_and_grant_access(responding_dept, calling_dept, duration MINUTES))
successful_grants++
granted_depts += responding_dept
// Report results
if(successful_grants > 0)
message_admins("RETA access granted successfully: [english_list(granted_depts)] personnel now have [calling_dept] access. Total eligible cards: [total_eligible_cards]")
// Send department announcement like the normal system
var/caller_info = " (Called by CENTCOM)"
var/enhanced_location = "[calling_dept][caller_info]"
// Send announcements to all successfully granted departments
for(var/dept in granted_depts)
switch(dept)
if("Security")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_SECURITY), "Security")
if("Engineering")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_ENGINEERING), "Engineering")
if("Medical")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_MEDICAL), "Medical")
if("Science")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_SCIENCE), "Science")
if("Service")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_SERVICE), "Service")
if("Command")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_COMMAND), "Command")
if("Cargo")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_SUPPLY), "Cargo")
if("Mining")
aas_config_announce(/datum/aas_config_entry/rc_emergency, list("LOCATION" = enhanced_location), null, list(RADIO_CHANNEL_SUPPLY), "Mining")
// Send confirmation to the calling department about who has been given access
var/calling_message = "RETA activated[caller_info]. The following now have temporary door access: [english_list(granted_depts)]."
// Get an announcement system to send simple radio messages
var/obj/machinery/announcement_system/announcer = get_announcement_system(null, null, list(RADIO_CHANNEL_COMMON))
if(announcer)
switch(calling_dept)
if("Security")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SECURITY)
if("Engineering")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_ENGINEERING)
if("Medical")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_MEDICAL)
if("Science")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SCIENCE)
if("Service")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SERVICE)
if("Command")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_COMMAND)
if("Cargo")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SUPPLY)
if("Mining")
announcer.radio.talk_into(announcer, calling_message, RADIO_CHANNEL_SUPPLY)
else
message_admins("RETA access grant failed for all departments.")

View File

@@ -0,0 +1,217 @@
/**
* Request Emergency Temporary Access - ID Card Extensions
* code\modules\reta\reta_system.dm
*/
/obj/item/card/id
/// Dictionary of temporary department access: dept_name -> list(access_flags)
var/list/reta_temp_access = list()
/// Dictionary of timer IDs for clearing temporary access: dept_name -> timer_id
var/list/reta_timers = list()
/// Grants temporary department access to this ID card
/obj/item/card/id/proc/grant_reta_access(dept, duration_ds)
if(!GLOB.reta_dept_grants[dept])
return FALSE
// Clear existing timer for this department if any (allows extending/refreshing access)
if(reta_timers[dept] && reta_timers[dept] != -1)
deltimer(reta_timers[dept])
reta_timers[dept] = null
// Grant access flags for this department
var/list/access_flags = GLOB.reta_dept_grants[dept]
var/list/new_access = list()
// Initialize department access list if needed
if(!reta_temp_access[dept])
reta_temp_access[dept] = list()
for(var/flag in access_flags)
if(!(flag in access)) // Only add if not permanently granted
// Add to department-specific temporary access
reta_temp_access[dept] |= flag
// Add to main access list
access += flag
new_access += flag
if(!LAZYLEN(new_access))
return FALSE // No new access granted
// Set timer for this specific department
reta_timers[dept] = addtimer(CALLBACK(src, PROC_REF(clear_reta_access_for_dept), dept), duration_ds, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_STOPPABLE)
// Add to global registry for mass operations
GLOB.reta_active_cards |= src
// User feedback
var/mob/living/carbon/human/holder = get_id_holder()
if(holder)
playsound(holder, 'sound/machines/cryo_warning.ogg', 25, TRUE)
holder.balloon_alert(holder, "emergency access: [dept]")
// Enhanced logging
var/access_names = list()
for(var/flag in new_access)
access_names += SSid_access.get_access_desc(flag)
var/holder_info = holder ? "held by [holder]" : "not being held"
log_reta("Granted [dept] temporary access ([english_list(access_names)]) to ID '[registered_name || "Unknown"]' ([holder_info]) for [duration_ds/10] seconds")
investigate_log("RETA: Granted [dept] temporary access ([english_list(access_names)]) to ID '[registered_name || "Unknown"]' ([holder_info])", INVESTIGATE_ACCESSCHANGES)
return TRUE
/// Clears temporary access for a specific department
/obj/item/card/id/proc/clear_reta_access_for_dept(dept)
if(!reta_temp_access[dept] || !LAZYLEN(reta_temp_access[dept]))
return
// User feedback before clearing
var/mob/living/carbon/human/holder = get_id_holder()
if(holder)
holder.balloon_alert(holder, "[dept] access expired")
to_chat(holder, span_warning("Emergency access to [dept] has expired."))
// Remove department's temporary access from the main access list
var/list/dept_access = reta_temp_access[dept]
for(var/flag in dept_access)
// Only remove if no other department also grants this access
var/still_needed = FALSE
for(var/other_dept in reta_temp_access)
if(other_dept != dept && reta_temp_access[other_dept] && (flag in reta_temp_access[other_dept]))
still_needed = TRUE
break
if(!still_needed)
access -= flag
// Enhanced logging
var/access_names = list()
for(var/flag in dept_access)
access_names += SSid_access.get_access_desc(flag)
var/holder_info = holder ? "held by [holder]" : "not being held"
log_reta("Cleared [dept] temporary access ([english_list(access_names)]) from ID '[registered_name || "Unknown"]' ([holder_info])")
investigate_log("RETA: Cleared [dept] temporary access ([english_list(access_names)]) from ID '[registered_name || "Unknown"]' ([holder_info])", INVESTIGATE_ACCESSCHANGES)
// Clean up department data
reta_temp_access[dept] = null
reta_timers[dept] = null
// Remove from global registry if no more temporary access
if(!has_any_reta_access())
GLOB.reta_active_cards -= src
/// Clears all temporary department access from this ID card
/obj/item/card/id/proc/clear_reta_access()
if(!LAZYLEN(reta_temp_access))
return
// User feedback before clearing
var/mob/living/carbon/human/holder = get_id_holder()
if(holder)
holder.balloon_alert(holder, "emergency access expired")
to_chat(holder, span_warning("Emergency access has expired."))
// Collect all temporary access flags for logging
var/list/all_temp_access = list()
for(var/dept in reta_temp_access)
if(reta_temp_access[dept])
all_temp_access |= reta_temp_access[dept]
// Remove all temporary access from the main access list
for(var/flag in all_temp_access)
access -= flag
// Enhanced logging
var/access_names = list()
for(var/flag in all_temp_access)
access_names += SSid_access.get_access_desc(flag)
var/holder_info = holder ? "held by [holder]" : "not being held"
log_reta("Cleared all temporary access ([english_list(access_names)]) from ID '[registered_name || "Unknown"]' ([holder_info])")
investigate_log("RETA: Cleared all temporary access ([english_list(access_names)]) from ID '[registered_name || "Unknown"]' ([holder_info])", INVESTIGATE_ACCESSCHANGES)
// Clear all timers
for(var/dept in reta_timers)
if(reta_timers[dept] && reta_timers[dept] != -1)
deltimer(reta_timers[dept])
LAZYCLEARLIST(reta_temp_access)
LAZYCLEARLIST(reta_timers)
// Remove from global registry
GLOB.reta_active_cards -= src
/// Checks if this ID card has any temporary access
/obj/item/card/id/proc/has_any_reta_access()
for(var/dept in reta_temp_access)
if(reta_temp_access[dept] && LAZYLEN(reta_temp_access[dept]))
return TRUE
return FALSE
/// Checks if this ID card has temporary access to a specific flag
/obj/item/card/id/proc/has_reta_access(access_flag)
for(var/dept in reta_temp_access)
if(reta_temp_access[dept] && (access_flag in reta_temp_access[dept]))
return TRUE
return FALSE
/// Checks if this ID card has temporary access for a specific department
/obj/item/card/id/proc/has_reta_access_for_dept(dept)
return reta_temp_access[dept] && LAZYLEN(reta_temp_access[dept])
/// Gets all current temporary access flags for this ID card
/obj/item/card/id/proc/get_reta_access()
var/list/all_access = list()
for(var/dept in reta_temp_access)
if(reta_temp_access[dept])
all_access |= reta_temp_access[dept]
return all_access
/// Gets temporary access flags for a specific department
/obj/item/card/id/proc/get_reta_access_for_dept(dept)
var/list/dept_access = reta_temp_access[dept]
return dept_access?.Copy() || list()
/// Gets a summary of all active RETA accesses (for debugging/display)
/obj/item/card/id/proc/get_reta_summary()
var/list/summary = list()
for(var/dept in reta_temp_access)
if(reta_temp_access[dept] && LAZYLEN(reta_temp_access[dept]))
var/time_left = "unknown"
if(reta_timers[dept])
var/remaining = timeleft(reta_timers[dept])
if(remaining > 0)
time_left = "[remaining/10]s"
summary += "[dept] ([LAZYLEN(reta_temp_access[dept])] access, [time_left] left)"
return summary
/// Helper to get the human holding this ID card
/obj/item/card/id/proc/get_id_holder()
var/mob/living/carbon/human/holder
if(istype(loc, /mob/living/carbon/human))
holder = loc
else if(istype(loc, /obj/item/card/id) && istype(loc.loc, /mob/living/carbon/human))
holder = loc.loc
else
// Check if worn in ID slot
for(var/mob/living/carbon/human/human in range(0, src))
if(human.get_idcard() == src)
holder = human
break
return holder
/// Cleanup temporary access when ID card is deleted
/obj/item/card/id/Destroy()
// Clear all department timers
for(var/dept in reta_timers)
if(reta_timers[dept] && reta_timers[dept] != -1)
deltimer(reta_timers[dept])
GLOB.reta_active_cards -= src
return ..()
/*
/mob/living/death(gibbed)
. = ..()
clear_temp_dept_access()
*/

View File

@@ -0,0 +1,319 @@
/**
* Request Emergency Temporary Access - RETA System
* Provides temporary department access when Requests Console emergency calls are made.
*/
/// Helper function for RETA-specific logging
/proc/log_reta(text)
WRITE_LOG(GLOB.reta_log, "[time_stamp()] RETA: [text]")
log_game("RETA: [text]")
/proc/initialize_reta_system()
// Define which access flags are granted for each department
GLOB.reta_dept_grants = list(
"Medical" = list(ACCESS_MEDICAL, ACCESS_SURGERY),
"Security" = list(ACCESS_SECURITY, ACCESS_BRIG, ACCESS_BRIG_ENTRANCE),
"Engineering" = list(ACCESS_ENGINEERING, ACCESS_ATMOSPHERICS),
"Science" = list(ACCESS_SCIENCE, ACCESS_RESEARCH),
"Service" = list(ACCESS_SERVICE, ACCESS_BAR, ACCESS_KITCHEN, ACCESS_HYDROPONICS),
"Cargo" = list(ACCESS_CARGO),
"Mining" = list(ACCESS_MINING, ACCESS_MINING_STATION, ACCESS_CARGO),
"Command" = list(ACCESS_COMMAND), // Admin-only, not available through request consoles
)
/// Checks if an origin department is on cooldown for calling a target department
/proc/reta_on_cooldown(origin, target)
var/list/by_target = GLOB.reta_cooldown[origin]
if(!by_target)
return FALSE
var/next_ok = by_target[target] || 0
return world.time < next_ok
/// Sets a cooldown for an origin department calling a target department
/proc/reta_set_cooldown(origin, target, cd_ds)
if(!GLOB.reta_cooldown[origin])
GLOB.reta_cooldown[origin] = list()
GLOB.reta_cooldown[origin][target] = world.time + cd_ds
/// Tracks recent emergency calls for multiple department analysis
/proc/reta_track_call(origin, target)
var/list/call_info = list(
"time" = world.time,
"origin" = origin
)
if(!GLOB.reta_recent_calls[target])
GLOB.reta_recent_calls[target] = list()
GLOB.reta_recent_calls[target] += list(call_info)
// Clean old calls (older than 10 minutes)
var/cutoff_time = world.time - 6000 // 10 minutes
if(GLOB.reta_recent_calls[target])
var/list/recent_calls = GLOB.reta_recent_calls[target]
GLOB.reta_recent_calls[target] = recent_calls.Copy()
for(var/list/old_call in GLOB.reta_recent_calls[target])
if(old_call["time"] < cutoff_time)
GLOB.reta_recent_calls[target] -= list(old_call)
// Check for multiple calls scenario
if(LAZYLEN(GLOB.reta_recent_calls[target]) >= 3)
var/list/origins = list()
for(var/list/call_data in GLOB.reta_recent_calls[target])
origins |= call_data["origin"]
if(LAZYLEN(origins) >= 3)
message_admins("RETA: Multiple emergency scenario detected! [target] has been called by [english_list(origins)] in the last 10 minutes. Consider station-wide emergency protocols.")
log_game("RETA: Multiple department emergency - [target] called by [english_list(origins)]")
/// Finds eligible responders and grants them temporary access
/proc/reta_find_and_grant_access(target_dept, origin_dept, duration_ds)
. = 0
var/list/job_trims = GLOB.reta_job_trims[target_dept]
if(!LAZYLEN(job_trims))
log_reta("No job trims defined for department '[target_dept]'")
return FALSE
var/granted_count = 0
var/total_players_checked = 0
var/matching_trim_players = 0
// Check ID cards being carried by living players (fast and efficient)
for(var/mob/living/carbon/human/human_player as anything in GLOB.human_list)
// Only check players who are alive and have clients (actively playing)
if(!human_player.client || human_player.stat == DEAD)
continue
total_players_checked++
// Get their ID card (worn_id, hands, or belt)
var/obj/item/card/id/id_card = human_player.get_idcard(hand_first = FALSE)
if(!id_card || !id_card.trim)
continue
// Check if this card's trim matches the target department
if(!is_type_in_list(id_card.trim, job_trims))
continue
matching_trim_players++
if(id_card.grant_reta_access(origin_dept, duration_ds))
granted_count++
if(granted_count > 0)
// Register this as an active RETA grant for new cards
if(!GLOB.reta_active_grants[target_dept])
GLOB.reta_active_grants[target_dept] = list()
GLOB.reta_active_grants[target_dept][origin_dept] = world.time + duration_ds
// Set up automatic cleanup when the grant expires
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(cleanup_expired_reta_grant), target_dept, origin_dept), duration_ds)
// Update all doors to show RETA lights for newly activated grants
update_all_doors_reta_lights()
log_reta("Granted temporary [origin_dept] access to [granted_count] [target_dept] department ID cards from a call by [origin_dept].")
. = TRUE
else
log_reta("No [target_dept] personnel found who needed [origin_dept] access from a call by [origin_dept]. (Checked [total_players_checked] living players, [matching_trim_players] had matching trims)")
return .
/// Populates the job trims list for RETA system
/proc/populate_reta_job_trims()
GLOB.reta_job_trims = list(
"Medical" = list(),
"Security" = list(),
"Engineering" = list(),
"Science" = list(),
"Service" = list(),
"Command" = list(),
"Cargo" = list(),
"Mining" = list()
)
log_game("RETA: Starting job trim population...")
var/total_trims = 0
for(var/job_trim_path in subtypesof(/datum/id_trim/job))
var/datum/id_trim/job/trim = new job_trim_path()
total_trims++
if(!trim.job)
log_game("RETA: Trim [job_trim_path] has no job")
continue
if(!trim.job.departments_bitflags)
log_game("RETA: Trim [job_trim_path] job [trim.job] has no departments_bitflags")
continue
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_MEDICAL)
GLOB.reta_job_trims["Medical"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_SECURITY)
GLOB.reta_job_trims["Security"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_ENGINEERING)
GLOB.reta_job_trims["Engineering"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_SCIENCE)
GLOB.reta_job_trims["Science"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_SERVICE)
GLOB.reta_job_trims["Service"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND)
GLOB.reta_job_trims["Command"] += job_trim_path
if(trim.job.departments_bitflags & DEPARTMENT_BITFLAG_CARGO)
GLOB.reta_job_trims["Cargo"] += job_trim_path
GLOB.reta_job_trims["Mining"] += job_trim_path // Mining uses CARGO bitflag
log_game("RETA: Processed [total_trims] trims. Final counts: Medical=[LAZYLEN(GLOB.reta_job_trims["Medical"])], Security=[LAZYLEN(GLOB.reta_job_trims["Security"])], Engineering=[LAZYLEN(GLOB.reta_job_trims["Engineering"])], Science=[LAZYLEN(GLOB.reta_job_trims["Science"])], Service=[LAZYLEN(GLOB.reta_job_trims["Service"])], Command=[LAZYLEN(GLOB.reta_job_trims["Command"])], Cargo=[LAZYLEN(GLOB.reta_job_trims["Cargo"])], Mining=[LAZYLEN(GLOB.reta_job_trims["Mining"])]")
/// Pushes UI updates to all consoles in the same origin department
/proc/reta_push_ui_updates(origin, target)
for(var/obj/machinery/requests_console/console in GLOB.reta_consoles_by_origin[origin])
console.ui_update()
/// Gets the department string for a user based on their job
/proc/reta_get_user_department(mob/user)
if(!user?.mind?.assigned_role)
return null
var/datum/job/job = user.mind.assigned_role
if(job.departments_bitflags & DEPARTMENT_BITFLAG_ENGINEERING)
return "Engineering"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_SCIENCE)
return "Science"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_CARGO)
return "Cargo"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_SERVICE)
return "Service"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_MEDICAL)
return "Medical"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_SECURITY)
return "Security"
if(job.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND)
return "Command"
return null
/// Gets the standardized department string from a console department name
/proc/reta_get_user_department_by_name(dept_name)
if(!dept_name)
return null
var/dept_lower = LOWER_TEXT(dept_name)
// Check for partial matches to handle variations in console naming
if(findtext(dept_lower, "engineering") || findtext(dept_lower, "engine"))
return "Engineering"
if(findtext(dept_lower, "science") || findtext(dept_lower, "research"))
return "Science"
if(findtext(dept_lower, "cargo") || findtext(dept_lower, "supply"))
return "Cargo"
if(findtext(dept_lower, "mining") || findtext(dept_lower, "mine"))
return "Mining"
if(findtext(dept_lower, "service") || findtext(dept_lower, "civilian"))
return "Service"
if(findtext(dept_lower, "medical") || findtext(dept_lower, "medbay"))
return "Medical"
if(findtext(dept_lower, "security") || findtext(dept_lower, "sec"))
return "Security"
if(findtext(dept_lower, "command") || findtext(dept_lower, "bridge"))
return "Command"
// Autonamed areas that belong to service department
if(findtext(dept_lower, "kitchen") || findtext(dept_lower, "bar") || findtext(dept_lower, "cafeteria") || findtext(dept_lower, "diner"))
return "Service"
if(findtext(dept_lower, "hydroponics") || findtext(dept_lower, "botany"))
return "Service"
if(findtext(dept_lower, "janitor") || findtext(dept_lower, "custodial"))
return "Service"
// Autonamed areas for medical
if(findtext(dept_lower, "pharmacy") || findtext(dept_lower, "chemistry") || findtext(dept_lower, "chem"))
return "Medical"
if(findtext(dept_lower, "morgue") || findtext(dept_lower, "virology"))
return "Medical"
if(findtext(dept_lower, "surgery") || findtext(dept_lower, "operating") || findtext(dept_lower, "cryo"))
return "Medical"
if(findtext(dept_lower, "patients") || findtext(dept_lower, "exam"))
return "Medical"
// Autonamed areas for engineering
if(findtext(dept_lower, "atmospherics") || findtext(dept_lower, "atmos"))
return "Engineering"
if(findtext(dept_lower, "supermatter") || findtext(dept_lower, "engine"))
return "Engineering"
if(findtext(dept_lower, "gravity") || findtext(dept_lower, "telecomm") || findtext(dept_lower, "tcomm"))
return "Engineering"
// Autonamed areas for science department
if(findtext(dept_lower, "xenobiology") || findtext(dept_lower, "xenobio"))
return "Science"
if(findtext(dept_lower, "robotics") || findtext(dept_lower, "genetics"))
return "Science"
if(findtext(dept_lower, "ordnance") || findtext(dept_lower, "cytology"))
return "Science"
// Handle specific autonamed areas that belong to security department
if(findtext(dept_lower, "brig") || findtext(dept_lower, "holding"))
return "Security"
if(findtext(dept_lower, "armory") || findtext(dept_lower, "checkpoint"))
return "Security"
return null
/// Cleans up an expired RETA grant from the active grants registry
/proc/cleanup_expired_reta_grant(target_dept, origin_dept)
if(!GLOB.reta_active_grants[target_dept])
return
GLOB.reta_active_grants[target_dept] -= origin_dept
if(!length(GLOB.reta_active_grants[target_dept]))
GLOB.reta_active_grants -= target_dept
log_reta("Cleaned up expired [origin_dept] grant for [target_dept] department")
// Update all doors to remove RETA lights for expired grants
update_all_doors_reta_lights()
/// Updates RETA lighting for all doors in the game
/proc/update_all_doors_reta_lights()
for(var/obj/machinery/door/airlock/door as anything in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/door/airlock))
door.update_appearance(UPDATE_OVERLAYS)
/// Applies any currently active RETA grants to a newly created/spawned ID card
/// This should be called when ID cards are created, spawned, or have their trim changed
/proc/apply_active_reta_grants_to_card(obj/item/card/id/id_card)
if(!id_card || !id_card.trim)
return
// If no active grants, nothing to do (prevents spam during round start)
if(!LAZYLEN(GLOB.reta_active_grants))
return
// Check if this card's department has any active incoming RETA grants
for(var/target_dept in GLOB.reta_active_grants)
var/list/job_trims = GLOB.reta_job_trims[target_dept]
if(!LAZYLEN(job_trims))
continue
// Check if this card's trim matches the target department
if(!is_type_in_list(id_card.trim, job_trims))
continue
log_reta("Card trim [id_card.trim] matches [target_dept] department - applying active grants")
// Apply all active grants for this department
for(var/origin_dept in GLOB.reta_active_grants[target_dept])
var/expiry_time = GLOB.reta_active_grants[target_dept][origin_dept]
if(world.time >= expiry_time)
continue // Grant expired, skip it
var/remaining_time = expiry_time - world.time
if(id_card.grant_reta_access(origin_dept, remaining_time))
log_reta("Auto-granted [origin_dept] access to newly created [id_card] ([target_dept] department)")
// Default config values
#define RETA_DEFAULT_DURATION_DS 3000 // 5 minutes
#define RETA_DEFAULT_COOLDOWN_DS 150 // 15 seconds
/// Initialize RETA config values
/proc/reta_init_config()
log_world("RETA: System initialized with duration=[CONFIG_GET(number/reta_duration_ds)]ds, cooldown=[CONFIG_GET(number/reta_dept_cooldown_ds)]ds, enabled=[CONFIG_GET(flag/reta_enabled)]")
#undef RETA_DEFAULT_DURATION_DS
#undef RETA_DEFAULT_COOLDOWN_DS

View File

@@ -258,6 +258,7 @@
#include "reagent_transfer.dm"
#include "required_map_items.dm"
#include "resist.dm"
#include "reta_system.dm"
#include "say.dm"
#include "screenshot_airlocks.dm"
#include "screenshot_antag_icons.dm"

View File

@@ -0,0 +1,152 @@
/**
* Unit Tests for Request Emergency Temporary Access (RETA) System
*
* Main system file: code\modules\reta\reta_system.dm
*/
/datum/unit_test/reta_basic_functions
/datum/unit_test/reta_basic_functions/Run()
// Initialize RETA system for testing
initialize_reta_system()
// Test department mapping
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Engineering"), "Engineering", "Engineering department mapping failed")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("engineering"), "Engineering", "Engineering lowercase mapping failed")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Medical Department"), "Medical", "Medical department mapping failed")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("medbay"), "Medical", "Medbay alias mapping failed")
TEST_ASSERT_NULL(reta_get_user_department_by_name("Unknown"), "Unknown department should return null")
// Test cooldown system
TEST_ASSERT(!reta_on_cooldown("Engineering", "Medical"), "Fresh cooldown should be false")
reta_set_cooldown("Engineering", "Medical", 100)
TEST_ASSERT(reta_on_cooldown("Engineering", "Medical"), "Set cooldown should be true")
// Test department grants - check that departments get appropriate access levels
TEST_ASSERT(GLOB.reta_dept_grants["Engineering"], "Engineering grants should exist")
TEST_ASSERT(ACCESS_ENGINEERING in GLOB.reta_dept_grants["Engineering"], "Engineering should grant ACCESS_ENGINEERING")
TEST_ASSERT(ACCESS_ATMOSPHERICS in GLOB.reta_dept_grants["Engineering"], "Engineering should grant ACCESS_ATMOSPHERICS")
TEST_ASSERT(!(ACCESS_CONSTRUCTION in GLOB.reta_dept_grants["Engineering"]), "Engineering should NOT grant ACCESS_CONSTRUCTION")
TEST_ASSERT(GLOB.reta_dept_grants["Medical"], "Medical grants should exist")
TEST_ASSERT(ACCESS_MEDICAL in GLOB.reta_dept_grants["Medical"], "Medical should grant ACCESS_MEDICAL")
TEST_ASSERT(ACCESS_SURGERY in GLOB.reta_dept_grants["Medical"], "Medical should grant ACCESS_SURGERY")
TEST_ASSERT(GLOB.reta_dept_grants["Security"], "Security grants should exist")
TEST_ASSERT(ACCESS_SECURITY in GLOB.reta_dept_grants["Security"], "Security should grant ACCESS_SECURITY")
TEST_ASSERT(ACCESS_BRIG in GLOB.reta_dept_grants["Security"], "Security should grant ACCESS_BRIG")
TEST_ASSERT(ACCESS_BRIG_ENTRANCE in GLOB.reta_dept_grants["Security"], "Security should grant ACCESS_BRIG_ENTRANCE")
TEST_ASSERT(!(ACCESS_ARMORY in GLOB.reta_dept_grants["Security"]), "Security should NOT grant ACCESS_ARMORY")
// Test new departments
TEST_ASSERT(GLOB.reta_dept_grants["Command"], "Command grants should exist")
TEST_ASSERT(ACCESS_COMMAND in GLOB.reta_dept_grants["Command"], "Command should grant ACCESS_COMMAND")
TEST_ASSERT(!(ACCESS_CAPTAIN in GLOB.reta_dept_grants["Command"]), "Command should NOT grant ACCESS_CAPTAIN")
TEST_ASSERT(GLOB.reta_dept_grants["Cargo"], "Cargo grants should exist")
TEST_ASSERT(ACCESS_CARGO in GLOB.reta_dept_grants["Cargo"], "Cargo should grant ACCESS_CARGO")
TEST_ASSERT(!(ACCESS_MINING in GLOB.reta_dept_grants["Cargo"]), "Cargo should NOT grant ACCESS_MINING")
TEST_ASSERT(GLOB.reta_dept_grants["Mining"], "Mining grants should exist")
TEST_ASSERT(ACCESS_MINING in GLOB.reta_dept_grants["Mining"], "Mining should grant ACCESS_MINING")
TEST_ASSERT(ACCESS_MINING_STATION in GLOB.reta_dept_grants["Mining"], "Mining should grant ACCESS_MINING_STATION")
TEST_ASSERT(ACCESS_CARGO in GLOB.reta_dept_grants["Mining"], "Mining should grant ACCESS_CARGO")
// Test department name mapping including new Mining support
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Mining Station"), "Mining", "Mining Station should map to Mining")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Command"), "Command", "Command should map to Command")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Bridge"), "Command", "Bridge should map to Command")
// Test autonamed service areas
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Kitchen"), "Service", "Kitchen should map to Service")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Bar"), "Service", "Bar should map to Service")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Cafeteria"), "Service", "Cafeteria should map to Service")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Diner"), "Service", "Diner should map to Service")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Hydroponics"), "Service", "Hydroponics should map to Service")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Botany"), "Service", "Botany should map to Service")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Janitor"), "Service", "Janitor should map to Service")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Custodial"), "Service", "Custodial should map to Service")
// Test autonamed medical areas
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Pharmacy"), "Medical", "Pharmacy should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Chemistry"), "Medical", "Chemistry should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Chem"), "Medical", "Chem should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Morgue"), "Medical", "Morgue should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Virology"), "Medical", "Virology should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Surgery"), "Medical", "Surgery should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Operating"), "Medical", "Operating should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Cryo"), "Medical", "Cryo should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Patients"), "Medical", "Patients should map to Medical")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Exam"), "Medical", "Exam should map to Medical")
// Test autonamed engineering areas
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Atmospherics"), "Engineering", "Atmospherics should map to Engineering")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Atmos"), "Engineering", "Atmos should map to Engineering")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Supermatter"), "Engineering", "Supermatter should map to Engineering")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Gravity"), "Engineering", "Gravity should map to Engineering")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Telecomm"), "Engineering", "Telecomm should map to Engineering")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Tcomm"), "Engineering", "Tcomm should map to Engineering")
// Test autonamed science areas
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Xenobiology"), "Science", "Xenobiology should map to Science")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Xenobio"), "Science", "Xenobio should map to Science")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Robotics"), "Science", "Robotics should map to Science")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Genetics"), "Science", "Genetics should map to Science")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Ordnance"), "Science", "Ordnance should map to Science")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Cytology"), "Science", "Cytology should map to Science")
// Test autonamed security areas
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Brig"), "Security", "Brig should map to Security")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Holding"), "Security", "Holding should map to Security")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Armory"), "Security", "Armory should map to Security")
TEST_ASSERT_EQUAL(reta_get_user_department_by_name("Checkpoint"), "Security", "Checkpoint should map to Security")
/datum/unit_test/reta_id_card_access
/datum/unit_test/reta_id_card_access/Run()
// Initialize RETA system for testing
initialize_reta_system()
var/obj/item/card/id/test_card = allocate(/obj/item/card/id)
test_card.registered_name = "Test User"
// Test temporary access granting
TEST_ASSERT(!test_card.has_reta_access(ACCESS_ENGINEERING), "ID card should not have temp access initially")
TEST_ASSERT(!(ACCESS_ENGINEERING in test_card.access), "ID card should not have engineering access initially")
test_card.grant_reta_access("Engineering", 100)
TEST_ASSERT(test_card.has_reta_access(ACCESS_ENGINEERING), "ID card should have temp access after granting")
TEST_ASSERT(ACCESS_ENGINEERING in test_card.access, "ID card should have engineering access in main access list")
// Test access clearing
test_card.clear_reta_access()
TEST_ASSERT(!test_card.has_reta_access(ACCESS_ENGINEERING), "ID card should not have temp access after clearing")
TEST_ASSERT(!(ACCESS_ENGINEERING in test_card.access), "ID card should not have engineering access in main access list after clearing")
// Test that permanent access is not affected
test_card.access += ACCESS_ENGINEERING // Simulate HoP giving permanent access
test_card.grant_reta_access("Engineering", 100)
TEST_ASSERT(!test_card.has_reta_access(ACCESS_ENGINEERING), "ID card should not add temp access if already has permanent")
TEST_ASSERT(ACCESS_ENGINEERING in test_card.access, "ID card should retain permanent access")
test_card.clear_reta_access()
TEST_ASSERT(ACCESS_ENGINEERING in test_card.access, "ID card should still have permanent access after clearing temp access")
/datum/unit_test/reta_paramedic_access
/datum/unit_test/reta_paramedic_access/Run()
// Initialize RETA system for testing
initialize_reta_system()
var/datum/id_trim/job/paramedic/paramedic_trim = SSid_access.trim_singletons_by_path[/datum/id_trim/job/paramedic]
// Test that paramedic no longer has broad access
TEST_ASSERT(!(ACCESS_CARGO in paramedic_trim.minimal_access), "Paramedic should not have cargo access")
TEST_ASSERT(!(ACCESS_SCIENCE in paramedic_trim.minimal_access), "Paramedic should not have science access")
TEST_ASSERT(!(ACCESS_CONSTRUCTION in paramedic_trim.minimal_access), "Paramedic should not have construction access")
TEST_ASSERT(!(ACCESS_HYDROPONICS in paramedic_trim.minimal_access), "Paramedic should not have hydroponics access")
TEST_ASSERT(!(ACCESS_MINING in paramedic_trim.minimal_access), "Paramedic should not have mining access")
// Test that paramedic still has basic medical access
TEST_ASSERT(ACCESS_MEDICAL in paramedic_trim.minimal_access, "Paramedic should have medical access")
TEST_ASSERT(ACCESS_MAINT_TUNNELS in paramedic_trim.minimal_access, "Paramedic should have maintenance access")
TEST_ASSERT(ACCESS_MORGUE in paramedic_trim.minimal_access, "Paramedic should have morgue access")
TEST_ASSERT(ACCESS_MECH_MEDICAL in paramedic_trim.minimal_access, "Paramedic should have medical mech access")

View File

@@ -103,6 +103,16 @@ ALLOW_ADMIN_ASAYCOLOR
## Job slot open/close by identification consoles delay in seconds
ID_CONSOLE_JOBSLOT_DELAY 30
## Request Emergency Temporary Access - RETA System
## Enables temporary department access when Requests Console emergency calls are made
RETA_ENABLED
## Duration in deciseconds for how long temporary access lasts (default: 3000 = 5 minutes)
RETA_DURATION_DS 3000
## Cooldown in deciseconds between RETA calls from the same origin to the same target department (default: 150 = 15 seconds)
RETA_DEPT_COOLDOWN_DS 150
## allow players to initiate a restart vote
#ALLOW_VOTE_RESTART

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -543,6 +543,7 @@
#include "code\_globalvars\pipe_info.dm"
#include "code\_globalvars\rcd.dm"
#include "code\_globalvars\religion.dm"
#include "code\_globalvars\reta.dm"
#include "code\_globalvars\silo.dm"
#include "code\_globalvars\tgui.dm"
#include "code\_globalvars\time_vars.dm"
@@ -652,6 +653,7 @@
#include "code\controllers\configuration\entries\jobs.dm"
#include "code\controllers\configuration\entries\lua.dm"
#include "code\controllers\configuration\entries\resources.dm"
#include "code\controllers\configuration\entries\reta.dm"
#include "code\controllers\subsystem\achievements.dm"
#include "code\controllers\subsystem\addiction.dm"
#include "code\controllers\subsystem\admin_verbs.dm"
@@ -6125,6 +6127,9 @@
#include "code\modules\research\xenobiology\vatgrowing\samples\cell_lines\common.dm"
#include "code\modules\research\xenobiology\vatgrowing\samples\cell_lines\organs.dm"
#include "code\modules\research\xenobiology\vatgrowing\samples\viruses\_virus.dm"
#include "code\modules\reta\reta_debug.dm"
#include "code\modules\reta\reta_id_card.dm"
#include "code\modules\reta\reta_system.dm"
#include "code\modules\security_levels\keycard_authentication.dm"
#include "code\modules\security_levels\security_level_datums.dm"
#include "code\modules\shuttle\shuttle.dm"

View File

@@ -22,7 +22,7 @@ const EmergencyBox = (props) => {
<>
{!!emergency && (
<NoticeBox danger>
{emergency} has been dispatched to this location
{emergency} called! RETA may open doors in area to them.
</NoticeBox>
)}
{!emergency && (