From 0df5aa083bfc95445350bda744ef3fe077cc4b82 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Fri, 26 Jun 2020 23:41:44 -0700
Subject: [PATCH] policies and code hooks
---
code/__DEFINES/configuration.dm | 8 ++++++++
code/controllers/configuration/entries/policy.dm | 8 ++++++++
code/game/machinery/cloning.dm | 5 +++++
code/game/objects/items/defib.dm | 6 ++++++
.../reagents/chemistry/reagents/medicine_reagents.dm | 7 +++++++
code/modules/surgery/advanced/revival.dm | 8 +++++++-
tgstation.dme | 1 +
7 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 code/controllers/configuration/entries/policy.dm
diff --git a/code/__DEFINES/configuration.dm b/code/__DEFINES/configuration.dm
index 6b70eb1e0f..39f1385d3b 100644
--- a/code/__DEFINES/configuration.dm
+++ b/code/__DEFINES/configuration.dm
@@ -8,3 +8,11 @@
//flags
#define CONFIG_ENTRY_LOCKED 1 //can't edit
#define CONFIG_ENTRY_HIDDEN 2 //can't see value
+
+// Policy config keys
+/// Displayed to cloned patients
+#define POLICYCONFIG_ON_CLONE "ON_CLONE"
+/// Displayed to defibbed/revival surgery'd patients before the memory loss time threshold
+#define POLICYCONFIG_ON_DEFIB_INTACT "ON_DEFIB_INTACT"
+/// Displayed to defibbed/revival surgery'd patients after the memory loss time threshold
+#define POLICYCONFIG_ON_DEFIB_LATE "ON_DEFIB_LATE"
diff --git a/code/controllers/configuration/entries/policy.dm b/code/controllers/configuration/entries/policy.dm
new file mode 100644
index 0000000000..48bfa666a1
--- /dev/null
+++ b/code/controllers/configuration/entries/policy.dm
@@ -0,0 +1,8 @@
+/// Seconds for CMD on defib-with-memory-loss policy config to display instead of defib-intact config
+/datum/config_entry/number/defib_cmd_time_limit
+ config_entry_value = 300
+ integer = TRUE
+
+/datum/config_entry/keyed_list/policy_config
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_TEXT
diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm
index cfe9d14663..53e910e973 100644
--- a/code/game/machinery/cloning.dm
+++ b/code/game/machinery/cloning.dm
@@ -399,6 +399,11 @@
to_chat(occupant, "There is a bright flash!
You feel like a new being.")
mob_occupant.flash_act()
+ var/list/policies = CONFIG_GET(keyed_list/policyconfig)
+ var/policy = policies[POLICYCONFIG_ON_CLONE]
+ if(policy)
+ to_chat(occupant, policy)
+
occupant.forceMove(T)
update_icon()
mob_occupant.domutcheck(1) //Waiting until they're out before possible monkeyizing. The 1 argument forces powers to manifest.
diff --git a/code/game/objects/items/defib.dm b/code/game/objects/items/defib.dm
index 7cc76da312..676dec4088 100644
--- a/code/game/objects/items/defib.dm
+++ b/code/game/objects/items/defib.dm
@@ -619,6 +619,12 @@
if(req_defib)
if(defib.healdisk)
H.heal_overall_damage(25, 25)
+ var/list/policies = CONFIG_GET(keyed_list/policyconfig)
+ var/timelimit = CONFIG_GET(number/defib_cmd_time_limit)
+ var/late = timelimit && (tplus > timelimit)
+ var/policy = late? policies[POLICYCONFIG_ON_DEFIB_LATE] : policies[POLICYCONFIG_ON_DEFIB_INTACT]
+ if(policy)
+ to_chat(occupant, policy)
if(req_defib)
defib.deductcharge(revivecost)
cooldown = 1
diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm
index 0f53add567..f4af4b69c6 100644
--- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm
+++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm
@@ -928,10 +928,17 @@
M.adjustOxyLoss(-20, 0)
M.adjustToxLoss(-20, 0)
M.updatehealth()
+ var/tplus = world.time - M.timeofdeath
if(M.revive())
M.grab_ghost()
M.emote("gasp")
log_combat(M, M, "revived", src)
+ var/list/policies = CONFIG_GET(keyed_list/policyconfig)
+ var/timelimit = CONFIG_GET(number/defib_cmd_time_limit)
+ var/late = timelimit && (tplus > timelimit)
+ var/policy = late? policies[POLICYCONFIG_ON_DEFIB_LATE] : policies[POLICYCONFIG_ON_DEFIB_INTACT]
+ if(policy)
+ to_chat(occupant, policy)
..()
diff --git a/code/modules/surgery/advanced/revival.dm b/code/modules/surgery/advanced/revival.dm
index cf3a218d80..c93b5eefa5 100644
--- a/code/modules/surgery/advanced/revival.dm
+++ b/code/modules/surgery/advanced/revival.dm
@@ -60,6 +60,7 @@
playsound(get_turf(target), 'sound/magic/lightningbolt.ogg', 50, 1)
target.adjustOxyLoss(-50, 0)
target.updatehealth()
+ var/tplus = world.time - target.timeofdeath
if(target.revive())
user.visible_message("...[target] wakes up, alive and aware!", "IT'S ALIVE!")
target.visible_message("...[target] wakes up, alive and aware!")
@@ -68,7 +69,12 @@
for(var/obj/item/organ/O in target.internal_organs)//zap those buggers back to life!
if(O.organ_flags & ORGAN_FAILING)
O.applyOrganDamage(-5)
- return TRUE
+ var/list/policies = CONFIG_GET(keyed_list/policyconfig)
+ var/timelimit = CONFIG_GET(number/defib_cmd_time_limit)
+ var/late = timelimit && (tplus > timelimit)
+ var/policy = late? policies[POLICYCONFIG_ON_DEFIB_LATE] : policies[POLICYCONFIG_ON_DEFIB_INTACT]
+ if(policy)
+ to_chat(occupant, policy) return TRUE
else
user.visible_message("...[target.p_they()] convulses, then lies still.")
target.visible_message("...[target.p_they()] convulses, then lies still.")
diff --git a/tgstation.dme b/tgstation.dme
index b13f220eb5..20ed62974b 100644
--- a/tgstation.dme
+++ b/tgstation.dme
@@ -267,6 +267,7 @@
#include "code\controllers\configuration\entries\game_options.dm"
#include "code\controllers\configuration\entries\general.dm"
#include "code\controllers\configuration\entries\plushies.dm"
+#include "code\controllers\configuration\entries\policy.dm"
#include "code\controllers\subsystem\acid.dm"
#include "code\controllers\subsystem\adjacent_air.dm"
#include "code\controllers\subsystem\air.dm"