From 3f260298e799b72af96e7e036bb27884d9a08ebf Mon Sep 17 00:00:00 2001
From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com>
Date: Sat, 28 May 2022 21:05:51 +0100
Subject: [PATCH 1/3] adds processing_quirk to control if a quirk should start
processing or not
---
code/datums/traits/_quirk.dm | 7 +++++--
code/datums/traits/good.dm | 1 +
code/datums/traits/negative.dm | 7 +++++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/code/datums/traits/_quirk.dm b/code/datums/traits/_quirk.dm
index 99fa6e73c5..ce1796346a 100644
--- a/code/datums/traits/_quirk.dm
+++ b/code/datums/traits/_quirk.dm
@@ -14,6 +14,7 @@
/// should we immediately call on_spawn or add a timer to trigger
var/on_spawn_immediate = TRUE
var/mob/living/quirk_holder
+ var/processing_quirk = FALSE
/datum/quirk/New(mob/living/quirk_mob, spawn_effects)
if(!quirk_mob || (human_only && !ishuman(quirk_mob)) || quirk_mob.has_quirk(type))
@@ -25,7 +26,8 @@
quirk_holder.roundstart_quirks += src
if(mob_trait)
ADD_TRAIT(quirk_holder, mob_trait, ROUNDSTART_TRAIT)
- START_PROCESSING(SSquirks, src)
+ if(processing_quirk)
+ START_PROCESSING(SSquirks, src)
add()
if(spawn_effects)
if(on_spawn_immediate)
@@ -35,7 +37,8 @@
addtimer(CALLBACK(src, .proc/post_add), 30)
/datum/quirk/Destroy()
- STOP_PROCESSING(SSquirks, src)
+ if(processing_quirk)
+ STOP_PROCESSING(SSquirks, src)
remove()
if(quirk_holder)
to_chat(quirk_holder, lose_text)
diff --git a/code/datums/traits/good.dm b/code/datums/traits/good.dm
index a0f62a32b8..3bcca275a5 100644
--- a/code/datums/traits/good.dm
+++ b/code/datums/traits/good.dm
@@ -72,6 +72,7 @@
mob_trait = TRAIT_JOLLY
mood_quirk = TRUE
medical_record_text = "Patient demonstrates constant euthymia irregular for environment. It's a bit much, to be honest."
+ processing_quirk = TRUE
/datum/quirk/jolly/on_process()
if(prob(0.05))
diff --git a/code/datums/traits/negative.dm b/code/datums/traits/negative.dm
index 8958226ff4..147549b9cb 100644
--- a/code/datums/traits/negative.dm
+++ b/code/datums/traits/negative.dm
@@ -25,6 +25,7 @@
lose_text = "You no longer feel depressed." //if only it were that easy!
medical_record_text = "Patient has a severe mood disorder, causing them to experience acute episodes of depression."
mood_quirk = TRUE
+ processing_quirk = TRUE
/datum/quirk/depression/on_process()
if(prob(0.05))
@@ -38,6 +39,7 @@
medical_record_text = "Patient demonstrates an unnatural attachment to a family heirloom."
var/obj/item/heirloom
var/where
+ processing_quirk = TRUE
GLOBAL_LIST_EMPTY(family_heirlooms)
@@ -102,6 +104,7 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
gain_text = "You feel smooth."
lose_text = "You feel wrinkled again."
medical_record_text = "Patient has a tumor in their brain that is slowly driving them to brain death."
+ processing_quirk = TRUE
/datum/quirk/brainproblems/on_process()
quirk_holder.adjustOrganLoss(ORGAN_SLOT_BRAIN, 0.2)
@@ -128,6 +131,7 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
desc = "As far as you can remember, you've always been afraid of the dark. While in the dark without a light source, you instinctually act careful, and constantly feel a sense of dread."
value = -1
medical_record_text = "Patient demonstrates a fear of the dark. (Seriously?)"
+ processing_quirk = TRUE
/datum/quirk/nyctophobia/on_process()
var/mob/living/carbon/human/H = quirk_holder
@@ -156,6 +160,7 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
gain_text = "Bright lights seem irritating."
lose_text = "Enlightening."
medical_record_text = "Despite my warnings, the patient refuses turn on the lights, only to end up rolling down a full flight of stairs and into the cellar."
+ processing_quirk = TRUE
/datum/quirk/lightless/on_process()
var/turf/T = get_turf(quirk_holder)
@@ -236,6 +241,7 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
gain_text = "..."
lose_text = "You feel in tune with the world again."
medical_record_text = "Patient suffers from acute Reality Dissociation Syndrome and experiences vivid hallucinations."
+ processing_quirk = TRUE
/datum/quirk/insanity/on_process()
if(quirk_holder.reagents.has_reagent(/datum/reagent/toxin/mindbreaker))
@@ -261,6 +267,7 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
lose_text = "You feel easier about talking again." //if only it were that easy!
medical_record_text = "Patient is usually anxious in social encounters and prefers to avoid them."
var/dumb_thing = TRUE
+ processing_quirk = TRUE
/datum/quirk/social_anxiety/add()
RegisterSignal(quirk_holder, COMSIG_MOB_EYECONTACT, .proc/eye_contact)
From ea173b01e0c259b039ac7e52ac908c868b907225 Mon Sep 17 00:00:00 2001
From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com>
Date: Sat, 28 May 2022 21:13:54 +0100
Subject: [PATCH 2/3] swap nyctophobia and lightless for tg code versions
---
code/datums/traits/negative.dm | 76 ++++++++++++++++++++++++++--------
1 file changed, 58 insertions(+), 18 deletions(-)
diff --git a/code/datums/traits/negative.dm b/code/datums/traits/negative.dm
index 147549b9cb..f98ddfe1f3 100644
--- a/code/datums/traits/negative.dm
+++ b/code/datums/traits/negative.dm
@@ -131,27 +131,38 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
desc = "As far as you can remember, you've always been afraid of the dark. While in the dark without a light source, you instinctually act careful, and constantly feel a sense of dread."
value = -1
medical_record_text = "Patient demonstrates a fear of the dark. (Seriously?)"
- processing_quirk = TRUE
-/datum/quirk/nyctophobia/on_process()
- var/mob/living/carbon/human/H = quirk_holder
- if(H.dna.species.id in list("shadow", "nightmare"))
- return //we're tied with the dark, so we don't get scared of it; don't cleanse outright to avoid cheese
- var/turf/T = get_turf(quirk_holder)
- var/lums = T.get_lumcount()
- if(lums <= 0.2)
- if(quirk_holder.m_intent == MOVE_INTENT_RUN)
- addtimer(CALLBACK(src, .proc/recheck),2) //0.2 seconds of being in the dark
- SEND_SIGNAL(quirk_holder, COMSIG_ADD_MOOD_EVENT, "nyctophobia", /datum/mood_event/nyctophobia)
- else
+ RegisterSignal(quirk_holder, COMSIG_MOVABLE_MOVED, .proc/on_holder_moved)
+
+/datum/quirk/nyctophobia/remove()
+ UnregisterSignal(quirk_holder, COMSIG_MOVABLE_MOVED)
+ SEND_SIGNAL(quirk_holder, COMSIG_CLEAR_MOOD_EVENT, "nyctophobia")
+
+/// Called when the quirk holder moves. Updates the quirk holder's mood.
+/datum/quirk/nyctophobia/proc/on_holder_moved(mob/living/source, atom/old_loc, dir, forced)
+ if(quirk_holder.stat != CONSCIOUS || quirk_holder.IsSleeping() || quirk_holder.IsUnconscious())
+ return
+
+ var/mob/living/carbon/human/human_holder = quirk_holder
+
+ if(human_holder.dna?.species.id in list(SPECIES_SHADOW, SPECIES_NIGHTMARE))
+ return
+
+ if((human_holder.sight & SEE_TURFS) == SEE_TURFS)
+ return
+
+ var/turf/holder_turf = get_turf(quirk_holder)
+
+ var/lums = holder_turf.get_lumcount()
+
+ if(lums > 0.2)
SEND_SIGNAL(quirk_holder, COMSIG_CLEAR_MOOD_EVENT, "nyctophobia")
+ return
-/datum/quirk/nyctophobia/proc/recheck()
- var/turf/T = get_turf(quirk_holder)
- var/lums = T.get_lumcount()
- if(lums <= 0.2) //check again, did they remain in the dark for 0.2 seconds?
- to_chat(quirk_holder, "Easy, easy, take it slow... you're in the dark...")
+ if(quirk_holder.m_intent == MOVE_INTENT_RUN)
+ to_chat(quirk_holder, span_warning("Easy, easy, take it slow... you're in the dark..."))
quirk_holder.toggle_move_intent()
+ SEND_SIGNAL(quirk_holder, COMSIG_ADD_MOOD_EVENT, "nyctophobia", /datum/mood_event/nyctophobia)
/datum/quirk/lightless
name = "Light Sensitivity"
@@ -160,7 +171,36 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
gain_text = "Bright lights seem irritating."
lose_text = "Enlightening."
medical_record_text = "Despite my warnings, the patient refuses turn on the lights, only to end up rolling down a full flight of stairs and into the cellar."
- processing_quirk = TRUE
+
+/datum/quirk/lightless/add()
+ RegisterSignal(quirk_holder, COMSIG_MOVABLE_MOVED, .proc/on_holder_moved)
+
+/datum/quirk/lightless/remove()
+ UnregisterSignal(quirk_holder, COMSIG_MOVABLE_MOVED)
+ SEND_SIGNAL(quirk_holder, COMSIG_CLEAR_MOOD_EVENT, "brightlight")
+
+/datum/quirk/lightless/proc/on_holder_moved(mob/living/source, atom/old_loc, dir, forced)
+ if(quirk_holder.stat != CONSCIOUS || quirk_holder.IsSleeping() || quirk_holder.IsUnconscious())
+ return
+
+ var/mob/living/carbon/human/human_holder = quirk_holder
+
+ if(human_holder.dna?.species.id in list(SPECIES_SHADOW, SPECIES_NIGHTMARE))
+ return
+
+ if((human_holder.sight & SEE_TURFS) == SEE_TURFS)
+ return
+
+ var/turf/holder_turf = get_turf(quirk_holder)
+
+ var/lums = holder_turf.get_lumcount()
+
+ if(lums < 0.8)
+ SEND_SIGNAL(quirk_holder, COMSIG_CLEAR_MOOD_EVENT, "brightlight")
+ return
+
+ SEND_SIGNAL(quirk_holder, COMSIG_ADD_MOOD_EVENT, "brightlight", /datum/mood_event/brightlight)
+
/datum/quirk/lightless/on_process()
var/turf/T = get_turf(quirk_holder)
From 9ceb1394d833ba3f39183e136316ae71b09f0d18 Mon Sep 17 00:00:00 2001
From: Timothy Teakettle <59849408+timothyteakettle@users.noreply.github.com>
Date: Sat, 28 May 2022 21:14:10 +0100
Subject: [PATCH 3/3] missing line from previous commit
---
code/datums/traits/negative.dm | 1 +
1 file changed, 1 insertion(+)
diff --git a/code/datums/traits/negative.dm b/code/datums/traits/negative.dm
index f98ddfe1f3..3d0588a112 100644
--- a/code/datums/traits/negative.dm
+++ b/code/datums/traits/negative.dm
@@ -132,6 +132,7 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
value = -1
medical_record_text = "Patient demonstrates a fear of the dark. (Seriously?)"
+/datum/quirk/nyctophobia/add()
RegisterSignal(quirk_holder, COMSIG_MOVABLE_MOVED, .proc/on_holder_moved)
/datum/quirk/nyctophobia/remove()