Skip to content

Commit 55dffcd

Browse files
authored
Fix quirks not processing (#5223)
Ports my additional refactors from tgstation/tgstation#89075, and the fix from tgstation/tgstation#89265
1 parent d914fcc commit 55dffcd

File tree

6 files changed

+28
-34
lines changed

6 files changed

+28
-34
lines changed

code/datums/quirks/_quirk.dm

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@
3333
/// The base weight for the each quirk's mail goodies list to be selected is 5
3434
/// then the item selected is determined by pick(selected_quirk.mail_goodies)
3535
var/list/mail_goodies = list() //Monkestation Edit BLOOD_DATUM: Why? this is already a list all this does is mess confuse us.
36-
/// The minimum stat where this quirk can process (if it has QUIRK_PROCESSES)
37-
var/minimum_process_stat = HARD_CRIT
36+
/// The maximum stat below which this quirk can process (if it has QUIRK_PROCESSES), and above which it stops.
37+
var/maximum_process_stat = HARD_CRIT
3838
/// A list of additional signals to register with update_process()
3939
var/list/process_update_signals
40+
/// A list of traits that should stop this quirk from processing.
41+
/// Signals for adding and removing this trait will automatically be added to `process_update_signals`.
42+
var/list/no_process_traits
43+
44+
/datum/quirk/New()
45+
. = ..()
46+
for(var/trait in no_process_traits)
47+
LAZYADD(process_update_signals, list(SIGNAL_ADDTRAIT(trait), SIGNAL_REMOVETRAIT(trait)))
4048

4149
/datum/quirk/Destroy()
4250
if(quirk_holder)
@@ -81,7 +89,8 @@
8189
add(client_source)
8290

8391
if(quirk_flags & QUIRK_PROCESSES)
84-
RegisterSignal(quirk_holder, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_changed))
92+
if(!isnull(maximum_process_stat))
93+
RegisterSignal(quirk_holder, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_changed))
8594
if(process_update_signals)
8695
RegisterSignals(quirk_holder, process_update_signals, PROC_REF(update_process))
8796
if(should_process())
@@ -161,7 +170,16 @@
161170
/datum/quirk/proc/should_process()
162171
SHOULD_CALL_PARENT(TRUE)
163172
SHOULD_BE_PURE(TRUE)
164-
return (quirk_flags & QUIRK_PROCESSES) && !QDELETED(quirk_holder) && quirk_holder.stat <= minimum_process_stat
173+
if(QDELETED(quirk_holder))
174+
return FALSE
175+
if(!(quirk_flags & QUIRK_PROCESSES))
176+
return FALSE
177+
if(!isnull(maximum_process_stat) && quirk_holder.stat >= maximum_process_stat)
178+
return FALSE
179+
for(var/trait in no_process_traits)
180+
if(HAS_TRAIT(quirk_holder, trait))
181+
return FALSE
182+
return TRUE
165183

166184
/// Checks to see if the quirk should be processing, and starts/stops it.
167185
/datum/quirk/proc/update_process()

code/datums/quirks/negative_quirks/allergic.dm

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
hardcore_value = 3
1010
quirk_flags = QUIRK_HUMAN_ONLY | QUIRK_PROCESSES
1111
mail_goodies = list(/obj/item/reagent_containers/hypospray/medipen) // epinephrine medipen stops allergic reactions
12-
process_update_signals = list(
13-
SIGNAL_ADDTRAIT(TRAIT_STASIS),
14-
SIGNAL_REMOVETRAIT(TRAIT_STASIS),
15-
)
12+
no_process_traits = list(TRAIT_STASIS)
1613
var/list/allergies = list()
1714
var/list/blacklist = list(
1815
/datum/reagent/medicine/c2,
@@ -64,6 +61,3 @@
6461
if(SPT_PROB(10, seconds_per_tick))
6562
carbon_quirk_holder.vomit()
6663
carbon_quirk_holder.adjustOrganLoss(pick(ORGAN_SLOT_BRAIN,ORGAN_SLOT_APPENDIX,ORGAN_SLOT_LUNGS,ORGAN_SLOT_HEART,ORGAN_SLOT_LIVER,ORGAN_SLOT_STOMACH),10)
67-
68-
/datum/quirk/item_quirk/allergic/should_process()
69-
return iscarbon(quirk_holder) && ..() && !HAS_TRAIT(quirk_holder, TRAIT_STASIS)

code/datums/quirks/negative_quirks/brain_problems.dm

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
hardcore_value = 12
1515
quirk_flags = QUIRK_HUMAN_ONLY | QUIRK_PROCESSES | QUIRK_DONT_CLONE // monkestation edit: QUIRK_DONT_CLONE (the cloner isn't gonna clone ur tumor lol)
1616
mail_goodies = list(/obj/item/storage/pill_bottle/mannitol/braintumor)
17-
process_update_signals = list(
18-
SIGNAL_ADDTRAIT(TRAIT_TUMOR_SUPPRESSED),
19-
SIGNAL_REMOVETRAIT(TRAIT_TUMOR_SUPPRESSED),
20-
)
17+
no_process_traits = list(TRAIT_TUMOR_SUPPRESSED)
2118

2219
/datum/quirk/item_quirk/brainproblems/add_unique(client/client_source)
2320
give_item_to_holder(
@@ -33,6 +30,3 @@
3330

3431
/datum/quirk/item_quirk/brainproblems/process(seconds_per_tick)
3532
quirk_holder.adjustOrganLoss(ORGAN_SLOT_BRAIN, 0.2 * seconds_per_tick)
36-
37-
/datum/quirk/item_quirk/brainproblems/should_process()
38-
return ..() && !HAS_TRAIT(quirk_holder, TRAIT_TUMOR_SUPPRESSED)

code/datums/quirks/negative_quirks/claustrophobia.dm

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66
medical_record_text = "Patient demonstrates a fear of tight spaces."
77
hardcore_value = 5
88
quirk_flags = QUIRK_HUMAN_ONLY | QUIRK_PROCESSES
9-
minimum_process_stat = CONSCIOUS
9+
maximum_process_stat = SOFT_CRIT
1010
mail_goodies = list(/obj/item/reagent_containers/syringe/convermol) // to help breathing
11-
process_update_signals = list(
12-
SIGNAL_ADDTRAIT(TRAIT_FEARLESS),
13-
SIGNAL_REMOVETRAIT(TRAIT_FEARLESS),
14-
)
11+
no_process_traits = list(TRAIT_FEARLESS)
1512

1613
/datum/quirk/claustrophobia/remove()
1714
quirk_holder.clear_mood_event("claustrophobia")
@@ -36,9 +33,6 @@
3633
else
3734
to_chat(quirk_holder, span_warning("You feel trapped! Must escape... can't breathe..."))
3835

39-
/datum/quirk/claustrophobia/should_process()
40-
return ..() && !HAS_TRAIT(quirk_holder, TRAIT_FEARLESS)
41-
4236
///investigates whether possible_saint_nick possesses a high level of christmas cheer
4337
/datum/quirk/claustrophobia/proc/evaluate_jolly_levels(mob/living/carbon/human/possible_saint_nick)
4438
if(!istype(possible_saint_nick))

code/datums/quirks/negative_quirks/junkie.dm

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
hardcore_value = 4
99
quirk_flags = QUIRK_HUMAN_ONLY | QUIRK_PROCESSES | QUIRK_DONT_CLONE
1010
mail_goodies = list(/obj/effect/spawner/random/contraband/narcotics)
11-
process_update_signals = list(
12-
SIGNAL_ADDTRAIT(TRAIT_LIVERLESS_METABOLISM),
13-
SIGNAL_REMOVETRAIT(TRAIT_LIVERLESS_METABOLISM),
14-
)
11+
no_process_traits = list(TRAIT_LIVERLESS_METABOLISM)
1512
var/drug_list = list(/datum/reagent/drug/blastoff, /datum/reagent/drug/krokodil, /datum/reagent/medicine/painkiller/morphine, /datum/reagent/drug/happiness, /datum/reagent/drug/methamphetamine) //List of possible IDs
1613
var/datum/reagent/reagent_type //!If this is defined, reagent_id will be unused and the defined reagent type will be instead.
1714
var/datum/reagent/reagent_instance //! actual instanced version of the reagent
@@ -86,9 +83,6 @@
8683
for(var/addiction in reagent_instance.addiction_types)
8784
human_holder.last_mind?.add_addiction_points(addiction, 1000) ///Max that shit out
8885

89-
/datum/quirk/item_quirk/junkie/should_process()
90-
return ..() && !HAS_TRAIT(quirk_holder, TRAIT_LIVERLESS_METABOLISM)
91-
9286
/datum/quirk/item_quirk/junkie/smoker
9387
name = "Smoker"
9488
desc = "Sometimes you just really want a smoke. Probably not great for your lungs."

code/datums/quirks/positive_quirks/drunk_healing.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
lose_text = span_danger("You no longer feel like drinking would ease your pain.")
88
medical_record_text = "Patient has unusually efficient liver metabolism and can slowly regenerate wounds by drinking alcoholic beverages."
99
quirk_flags = QUIRK_HUMAN_ONLY | QUIRK_PROCESSES
10-
minimum_process_stat = DEAD // it processed before while dead, so I'm keeping it that way
10+
maximum_process_stat = DEAD // it processed before while dead, so I'm keeping it that way
1111
mail_goodies = list(/obj/effect/spawner/random/food_or_drink/booze)
1212

1313
/datum/quirk/drunkhealing/process(seconds_per_tick)

0 commit comments

Comments
 (0)