From 264a657a2207b3591399ad007d5c6cd0f12e39e4 Mon Sep 17 00:00:00 2001
From: nikothedude <59709059+nikothedude@users.noreply.github.com>
Date: Sun, 10 Apr 2022 21:32:10 -0400
Subject: [PATCH] [SEMI-MODULAR] Somewhat refactors the way records are
handled, adds a traitor panel + OPFOR override for exploitables to allow
non-antags to use them. Also adds some text to exploitables to let people
know to not put sex shit in there. (#12277)
* bap
* client/proc
* woops
* last changes
* whoops
* Update view_exploitables.dm
* awduhiawdujhiawdujh
* Update flavor_defines.dm
---
.../~skyrat_defines/flavor_defines.dm | 7 +++
code/datums/mind.dm | 18 +++----
code/modules/admin/antag_panel.dm | 1 +
.../antagonists/_common/antag_datum.dm | 7 ++-
.../mob/living/carbon/human/examine.dm | 19 ++++---
code/modules/mob/living/carbon/human/human.dm | 10 ++--
.../antagonists/_common/antag_datum.dm | 2 +-
.../modules/client/preferences/flavor_text.dm | 3 ++
.../opposing_force/code/equipment/services.dm | 11 ++++
.../modules/records_on_examine/code/mind.dm | 21 --------
.../code/record_manifest.dm | 8 +--
.../code/record_variables.dm | 7 +++
.../records_on_examine/code/records_procs.dm | 50 +++++++++++++++++++
.../code/view_exploitables.dm | 18 ++-----
tgstation.dme | 3 +-
15 files changed, 116 insertions(+), 69 deletions(-)
delete mode 100644 modular_skyrat/modules/records_on_examine/code/mind.dm
create mode 100644 modular_skyrat/modules/records_on_examine/code/record_variables.dm
create mode 100644 modular_skyrat/modules/records_on_examine/code/records_procs.dm
diff --git a/code/__DEFINES/~skyrat_defines/flavor_defines.dm b/code/__DEFINES/~skyrat_defines/flavor_defines.dm
index bc2795b7dc8..ccc055f0da0 100644
--- a/code/__DEFINES/~skyrat_defines/flavor_defines.dm
+++ b/code/__DEFINES/~skyrat_defines/flavor_defines.dm
@@ -1,2 +1,9 @@
/// How many characters will be displayed in the flavor text preview before we cut it off?
#define FLAVOR_PREVIEW_LIMIT 110
+/// The default value that will go in any new player's exploitables.
+#define EXPLOITABLE_DEFAULT_TEXT "Used by antagonists. DO NOT PUT SEXUAL THINGS IN HERE. This is where you put flaws that can be exploited in any way. This will be viewable by antagonists if you modify this string, but only if there's anything at all in this box."
+/// The length of records at which they will not show up, to prevent empty records from appearing.
+#define RECORDS_INVISIBLE_THRESHOLD 0
+/// The message displayed when someone received the View Crew Exploitables verb.
+#define VIEW_CREW_EXPLOITABLES_GAIN_TEXT "You now have access to the View Crew Exploitables verb, which shows all crew who currently have exploitable info and a link to view it!"
+
diff --git a/code/datums/mind.dm b/code/datums/mind.dm
index 084f9d5abd9..023e03b538f 100644
--- a/code/datums/mind.dm
+++ b/code/datums/mind.dm
@@ -92,9 +92,6 @@
var/list/active_addictions
///List of objective-specific equipment that couldn't properly be given to the mind
var/list/failed_special_equipment
- // SKYRAT EDIT ADDITION -- EXPLOITABLE MENU
- ///Tracks if the target has the view_exploitables_verb verb. THIS MUST BE CHANGED IF THE VERB IS ADDED OR REMOVED OR ELSE STUFF BREAKS.
- var/has_exploitable_menu = FALSE
/datum/mind/New(_key)
key = _key
@@ -301,7 +298,7 @@
antag_team.add_member(src)
INVOKE_ASYNC(A, /datum/antagonist.proc/on_gain)
log_game("[key_name(src)] has gained antag datum [A.name]([A.type])")
- src.handle_exploitables_menu() //SKYRAT EDIT ADDITION - EXPLOITABLES MENU
+ handle_exploitables() //SKYRAT EDIT ADDITION - EXPLOITABLES MENU
return A
/datum/mind/proc/remove_antag_datum(datum_type)
@@ -310,7 +307,6 @@
var/datum/antagonist/A = has_antag_datum(datum_type)
if(A)
A.on_removal()
- src.handle_exploitables_menu() //SKYRAT EDIT ADDITION - EXPLOITABLE MENU
return TRUE
@@ -319,11 +315,6 @@
for(var/a in antag_datums)
var/datum/antagonist/A = a
A.on_removal()
- //SKYRAT EDIT ADDITION BEGIN - EXPLOITABLE MENU
- if (has_exploitable_menu)
- remove_verb(current, /mob/proc/view_exploitables_verb)
- has_exploitable_menu = FALSE
- //SKYRAT EDIT ADDITION END
/datum/mind/proc/has_antag_datum(datum_type, check_subtypes = TRUE)
if(!datum_type)
@@ -727,6 +718,13 @@
log_admin("[key_name(usr)] tried and failed to give [current] an uplink.")
else
log_admin("[key_name(usr)] gave [current] an uplink.")
+ //SKYRAT EDIT ADDITION BEGIN -- EXPLOITABLES
+ if("toggle_exploitables")
+ has_exploitables_override = !has_exploitables_override //First we set the override to be the opposite of whatever it was apon execution, then we
+ handle_exploitables() // use ternaries to convert this into true/false for admin logs.
+ log_admin("[key_name(usr)] toggled [current]'s exploitables override to [(has_exploitables_override) ? "true" : "false"].")
+ message_admins("[key_name(usr)] toggled [current]'s exploitables override to [(has_exploitables_override) ? "true" : "false"].")
+ //SKYRAT EDIT ADDITION END
else if (href_list["obj_announce"])
announce_objectives()
diff --git a/code/modules/admin/antag_panel.dm b/code/modules/admin/antag_panel.dm
index abfd02f158c..ebdb7f6da2c 100644
--- a/code/modules/admin/antag_panel.dm
+++ b/code/modules/admin/antag_panel.dm
@@ -71,6 +71,7 @@ GLOBAL_VAR(antag_prototypes)
if (R.emagged)
common_commands += "Unemag slaved cyborgs"
break
+ common_commands += "Toggle exploitables override" //SKYRAT EDIT ADDITION -- EXPLOITABLES
return common_commands
/datum/mind/proc/get_special_statuses()
diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm
index 841b8094cb7..d9c80bd664d 100644
--- a/code/modules/antagonists/_common/antag_datum.dm
+++ b/code/modules/antagonists/_common/antag_datum.dm
@@ -221,12 +221,11 @@ GLOBAL_LIST_EMPTY(antagonists)
for (var/datum/atom_hud/alternate_appearance/basic/has_antagonist/antag_hud as anything in GLOB.has_antagonist_huds)
if (!antag_hud.mobShouldSee(current))
antag_hud.remove_hud_from(current)
- // SKYRAT EDIT START
- if(owner.has_exploitable_menu)
- remove_verb(owner.current?.client, /mob/proc/view_exploitables_verb)
- // SKYRAT EDIT END
qdel(src)
+ // SKYRAT EDIT START
+ owner.handle_exploitables() //Inefficient here, but on_removal() is called in multiple locations
+ // SKYRAT EDIT END
/**
* Proc that sends fluff or instructional messages to the player when they are given this antag datum.
diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm
index e0dbaa35519..f775ca22f26 100644
--- a/code/modules/mob/living/carbon/human/examine.dm
+++ b/code/modules/mob/living/carbon/human/examine.dm
@@ -430,7 +430,7 @@
. += "\[Medical evaluation\]
"
. += "\[See quirks\]"
//SKYRAT EDIT ADDITION BEGIN - EXAMINE RECORDS
- if (R && length(R.fields["past_records"]) >= 2)
+ if (R && length(R.fields["past_records"]) > RECORDS_INVISIBLE_THRESHOLD)
. += "\[View medical records\]"
//SKYRAT EDIT END
@@ -450,23 +450,22 @@
"\[View comment log\]",
"\[Add comment\]"), "")
// SKYRAT EDIT ADDITION BEGIN - EXAMINE RECORDS
- if (R && length(R.fields["past_records"]) >= 2)
+ if (R && length(R.fields["past_records"]) > RECORDS_INVISIBLE_THRESHOLD)
. += "Security record: \[View security records\]"
- if (R_cache && length(R_cache.fields["past_records"]) >= 2)
+ if (R_cache && length(R_cache.fields["past_records"]) > RECORDS_INVISIBLE_THRESHOLD)
. += "\[View general records\]"
//SKYRAT EDIT ADDITION END
else if(isobserver(user))
. += "Traits: [get_quirk_string(FALSE, CAT_QUIRK_ALL)]"
//SKYRAT EDIT ADDITION BEGIN - EXAMINE RECORDS
- if (is_special_character(user))
- var/datum/data/record/is_in_world = find_record("name", perpname, GLOB.data_core.general) //apparantly golden is okay with offstation roles having no records, FYI
- if (is_in_world && length(is_in_world.fields["exploitable_records"]) >= 2)
- for(var/datum/antagonist/antag_datum in user.mind.antag_datums)
- if (antag_datum.view_exploitables)
- . += "\[View exploitable info\]"
- break
+ if (mind.can_see_exploitables || mind.has_exploitables_override)
+ var/datum/data/record/target_records = find_record("name", perpname, GLOB.data_core.general) //apparantly golden is okay with offstation roles having no records, FYI
+ var/exploitable_text = target_records.fields["exploitable_records"]
+ if (target_records && ((length(exploitable_text) > RECORDS_INVISIBLE_THRESHOLD) && ((exploitable_text) != EXPLOITABLE_DEFAULT_TEXT)))
+ . += "\[View exploitable info\]"
+
//SKYRAT EDIT END
//SKYRAT EDIT ADDITION BEGIN - GUNPOINT
if(gunpointing)
diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm
index 05fada2a19d..7a422477de0 100644
--- a/code/modules/mob/living/carbon/human/human.dm
+++ b/code/modules/mob/living/carbon/human/human.dm
@@ -392,11 +392,11 @@
return
//SKYRAT EDIT ADDITION BEGIN - VIEW RECORDS
- if (is_special_character(usr))
- var/perpname = get_face_name(get_id_name(""))
- var/datum/data/record/EXP = find_record("name", perpname, GLOB.data_core.general)
- if(href_list["exprecords"])
- to_chat(usr, "Exploitable information: [EXP.fields["exploitable_records"]]")
+ if(href_list["exprecords"])
+ if (mind.can_see_exploitables || mind.has_exploitables_override)
+ var/examined_name = get_face_name(get_id_name("")) //Named as such because this is the name we see when we examine
+ var/datum/data/record/target_general_records = find_record("name", examined_name, GLOB.data_core.general)
+ to_chat(usr, "Exploitable information: [target_general_records.fields["exploitable_records"]]")
//SKYRAT EDIT END
..() //end of this massive fucking chain. TODO: make the hud chain not spooky. - Yeah, great job doing that.
diff --git a/modular_skyrat/master_files/code/modules/antagonists/_common/antag_datum.dm b/modular_skyrat/master_files/code/modules/antagonists/_common/antag_datum.dm
index 78ff1c4427d..9f76177881f 100644
--- a/modular_skyrat/master_files/code/modules/antagonists/_common/antag_datum.dm
+++ b/modular_skyrat/master_files/code/modules/antagonists/_common/antag_datum.dm
@@ -1,5 +1,5 @@
/datum/antagonist
- //Should this antagonist be allowed to view exploitable information?
+ /// Should this antagonist be allowed to view exploitable information?
var/view_exploitables = FALSE
/datum/antagonist/heretic
diff --git a/modular_skyrat/master_files/code/modules/client/preferences/flavor_text.dm b/modular_skyrat/master_files/code/modules/client/preferences/flavor_text.dm
index 4d7248e79ad..6ae60eae2db 100644
--- a/modular_skyrat/master_files/code/modules/client/preferences/flavor_text.dm
+++ b/modular_skyrat/master_files/code/modules/client/preferences/flavor_text.dm
@@ -69,6 +69,9 @@
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "exploitable_info"
+/datum/preference/text/exploitable/create_default_value()
+ return EXPLOITABLE_DEFAULT_TEXT
+
/datum/preference/text/exploitable/apply_to_human(mob/living/carbon/human/target, value, datum/preferences/preferences)
return FALSE
diff --git a/modular_skyrat/modules/opposing_force/code/equipment/services.dm b/modular_skyrat/modules/opposing_force/code/equipment/services.dm
index 256f987cbc9..6221cd2e762 100644
--- a/modular_skyrat/modules/opposing_force/code/equipment/services.dm
+++ b/modular_skyrat/modules/opposing_force/code/equipment/services.dm
@@ -61,7 +61,18 @@
var/datum/round_event_control/event = locate(/datum/round_event_control/market_crash) in SSevents.control
event.runEvent()
+/datum/opposing_force_equipment/service/give_exploitables
+ name = "Exploitables Access"
+ description = "You will be given access to a network of exploitable information of certain crewmates, viewable using either a verb or on examine."
+ item_type = /obj/effect/gibspawner/generic
+ admin_note = "Same effect as using the traitor panel Toggle Exploitables Override button. Usually safe to give."
+
+/datum/opposing_force_equipment/service/give_exploitables/on_issue(mob/living/target)
+ target.mind.has_exploitables_override = TRUE
+ target.mind.handle_exploitables()
+
/datum/opposing_force_equipment/service/fake_announcer
name = "Fake Announcement"
item_type = /obj/item/device/traitor_announcer
description = "A one-use device that lets you make an announcement of your choice, sending it to the station under the guise of the captain's authority."
+
diff --git a/modular_skyrat/modules/records_on_examine/code/mind.dm b/modular_skyrat/modules/records_on_examine/code/mind.dm
deleted file mode 100644
index 829dd0574f9..00000000000
--- a/modular_skyrat/modules/records_on_examine/code/mind.dm
+++ /dev/null
@@ -1,21 +0,0 @@
-/datum/mind/proc/handle_exploitables_menu()
- //Only returns true if no datums are present in the mind. Without this, the for loop would end prematurely, as it would be null.
- if (!antag_datums)
- if (has_exploitable_menu)
- remove_verb(current, /mob/proc/view_exploitables_verb)
- has_exploitable_menu = FALSE
- return
- var/should_see_exploitables = FALSE
- for(var/datum/antagonist/antag_datum in src?.antag_datums)
- // Players are allowed to view exploitables if they have at least one antag_datum datum with view_exploitables set to TRUE.
- if (antag_datum.view_exploitables)
- should_see_exploitables = TRUE
- break
- if(!has_exploitable_menu && should_see_exploitables)
- add_verb(current, /mob/proc/view_exploitables_verb)
- has_exploitable_menu = TRUE
- to_chat(current, span_danger("You now have access to the View-Crew-Exploitables verb, which shows all crew who currently have exploitable info and a link to view it!"))
-
- else if(has_exploitable_menu && !should_see_exploitables)
- remove_verb(current, /mob/proc/view_exploitables_verb)
- has_exploitable_menu = FALSE
diff --git a/modular_skyrat/modules/records_on_examine/code/record_manifest.dm b/modular_skyrat/modules/records_on_examine/code/record_manifest.dm
index 9d6943d0892..3dbc27d074d 100644
--- a/modular_skyrat/modules/records_on_examine/code/record_manifest.dm
+++ b/modular_skyrat/modules/records_on_examine/code/record_manifest.dm
@@ -9,7 +9,7 @@
var/list/departments_by_type = SSjob.joinable_departments_by_type
for(var/datum/data/record/general_record in GLOB.data_core.general)
var/exploitables = general_record.fields["exploitable_records"]
- var/exploitables_empty = (length(general_record.fields["exploitable_records"]) < 2)
+ var/exploitables_empty = ((length(exploitables) < 1) || ((exploitables) == EXPLOITABLE_DEFAULT_TEXT))
if (exploitables_empty)
continue
var/name = general_record.fields["name"]
@@ -54,7 +54,7 @@
return GLOB.always_state
/datum/record_manifest/ui_status(mob/user, datum/ui_state/state)
- return (is_special_character(user)) ? UI_INTERACTIVE : UI_CLOSE
+ return ((user.mind.can_see_exploitables) || (user.mind.has_exploitables_override)) ? UI_INTERACTIVE : UI_CLOSE
/datum/record_manifest/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
@@ -68,8 +68,8 @@
return
if(action == "show_exploitables")
var/exploitable_id = params["exploitable_id"]
- var/datum/data/record/exploitable_record = find_record("name", exploitable_id, GLOB.data_core.general)
- to_chat(usr, "Exploitable information: [exploitable_record.fields["exploitable_records"]]")
+ var/datum/data/record/general_record = find_record("name", exploitable_id, GLOB.data_core.general)
+ to_chat(usr, "Exploitable information: [general_record.fields["exploitable_records"]]")
/datum/record_manifest/ui_data(mob/user)
var/list/positions = list()
diff --git a/modular_skyrat/modules/records_on_examine/code/record_variables.dm b/modular_skyrat/modules/records_on_examine/code/record_variables.dm
new file mode 100644
index 00000000000..d1fe3852118
--- /dev/null
+++ b/modular_skyrat/modules/records_on_examine/code/record_variables.dm
@@ -0,0 +1,7 @@
+/datum/mind
+ /// The standard way we check for access to exploitables, given to antags. If true, and handles_exploitables() is ran, the user will be given exploitables access + menu.
+ var/can_see_exploitables = FALSE
+ /// The nonstandard way we check for access to exploitables, given by admins and OPFOR. Acts like can_see_exploitables, but will always, unconditionally set it to true and succeed.
+ var/has_exploitables_override = FALSE
+ ///Tracks if the target has the view_exploitables_verb verb. THIS MUST BE CHANGED IF THE VERB IS ADDED OR REMOVED OR ELSE STUFF BREAKS.
+ var/has_exploitable_menu = FALSE
diff --git a/modular_skyrat/modules/records_on_examine/code/records_procs.dm b/modular_skyrat/modules/records_on_examine/code/records_procs.dm
new file mode 100644
index 00000000000..ecae42cf82f
--- /dev/null
+++ b/modular_skyrat/modules/records_on_examine/code/records_procs.dm
@@ -0,0 +1,50 @@
+/**
+ * Checks antag datums for any datums with view_exploitables. If it finds one, sets can_see_exploitables to true, and if not, false.
+ * Always calls handle_exploitables_menu. Also sets can_see_exploitables to true if has_exploitables_override is true and skips the rest.
+ */
+/datum/mind/proc/handle_exploitables()
+
+ if (has_exploitables_override)
+ if (!can_see_exploitables)
+ can_see_exploitables = TRUE
+ handle_exploitables_menu()
+ return
+
+ if (!antag_datums)
+ can_see_exploitables = FALSE
+ handle_exploitables_menu()
+ return
+
+ can_see_exploitables = FALSE
+ for(var/datum/antagonist/antag_datum in src?.antag_datums)
+ if (!antag_datum.view_exploitables)
+ continue
+ else
+ can_see_exploitables = TRUE
+ break
+
+ handle_exploitables_menu()
+
+/**
+ * Called by handle_exploitables(). Checks for a discrepency between has_exploitable_menu and can_see_exploitable, and gives/takes the verb accordingly (if can_see_exploitables is true/false).
+ * Always makes sure the user has the exploitable menu if has_exploitables_override is true.
+ */
+/datum/mind/proc/handle_exploitables_menu()
+
+ if (has_exploitables_override)
+ if (!has_exploitable_menu)
+ add_verb(current, /mob/proc/view_exploitables_verb)
+ has_exploitable_menu = TRUE
+ to_chat(current, span_danger(VIEW_CREW_EXPLOITABLES_GAIN_TEXT))
+ return
+
+ if(!has_exploitable_menu && can_see_exploitables)
+ add_verb(current, /mob/proc/view_exploitables_verb)
+ has_exploitable_menu = TRUE
+ to_chat(current, span_danger(VIEW_CREW_EXPLOITABLES_GAIN_TEXT))
+
+ else if(has_exploitable_menu && !can_see_exploitables)
+ remove_verb(current, /mob/proc/view_exploitables_verb)
+ has_exploitable_menu = FALSE
+
+
diff --git a/modular_skyrat/modules/records_on_examine/code/view_exploitables.dm b/modular_skyrat/modules/records_on_examine/code/view_exploitables.dm
index cc6efa381c0..fe166390cb3 100644
--- a/modular_skyrat/modules/records_on_examine/code/view_exploitables.dm
+++ b/modular_skyrat/modules/records_on_examine/code/view_exploitables.dm
@@ -6,17 +6,9 @@
return
client.crew_manifest_delay = world.time + (1 SECONDS)
- if(is_special_character(src))
- for(var/datum/antagonist/antag_datum in src?.mind?.antag_datums)
- if(!(antag_datum.view_exploitables) || !(is_special_character(src)))
- continue
- if (antag_datum.view_exploitables)
-
- if(!GLOB.record_manifest_tgui)
- GLOB.record_manifest_tgui = new /datum/record_manifest(src)
-
- GLOB.record_manifest_tgui.ui_interact(src)
- break
+ if(mind.can_see_exploitables || mind.has_exploitables_override)
+ if(!GLOB.record_manifest_tgui)
+ GLOB.record_manifest_tgui = new /datum/record_manifest(src)
+ GLOB.record_manifest_tgui.ui_interact(src)
else
- to_chat(src, span_danger("You're not an antagonist that can view exploitables! This message should not appear!"))
- return
+ to_chat(src, span_danger("You do not have access to this verb! This message should not appear!"))
diff --git a/tgstation.dme b/tgstation.dme
index 3ca59d58045..21e9bdea5bd 100644
--- a/tgstation.dme
+++ b/tgstation.dme
@@ -5525,8 +5525,9 @@
#include "modular_skyrat\modules\reagent_forging\code\smith_skill.dm"
#include "modular_skyrat\modules\reagent_forging\code\tool_override.dm"
#include "modular_skyrat\modules\reagent_forging\code\water_basin.dm"
-#include "modular_skyrat\modules\records_on_examine\code\mind.dm"
#include "modular_skyrat\modules\records_on_examine\code\record_manifest.dm"
+#include "modular_skyrat\modules\records_on_examine\code\record_variables.dm"
+#include "modular_skyrat\modules\records_on_examine\code\records_procs.dm"
#include "modular_skyrat\modules\records_on_examine\code\view_exploitables.dm"
#include "modular_skyrat\modules\roboclothes\code\robotics_clothing.dm"
#include "modular_skyrat\modules\roboclothes\code\wardrobes.dm"