diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index c7e154c932d..a58deacd624 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -732,4 +732,3 @@ /// Checking flags for [/mob/proc/can_read()] #define READING_CHECK_LITERACY (1<<0) #define READING_CHECK_LIGHT (1<<1) - diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 280746b6d32..afb0415092c 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -320,7 +320,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai /// prevents the damage done by a brain tumor #define TRAIT_TUMOR_SUPPRESSED "brain_tumor_suppressed" /// Prevents hallucinations from the hallucination brain trauma (RDS) -#define TRAIT_HALLUCINATION_SUPPRESSED "hallucination_suppressed" +#define TRAIT_RDS_SUPPRESSED "rds_suppressed" /// overrides the update_fire proc to always add fire (for lava) #define TRAIT_PERMANENTLY_ONFIRE "permanently_onfire" /// Galactic Common Sign Language diff --git a/code/datums/brain_damage/mild.dm b/code/datums/brain_damage/mild.dm index 45dfafb56b7..d4e6507ebee 100644 --- a/code/datums/brain_damage/mild.dm +++ b/code/datums/brain_damage/mild.dm @@ -14,7 +14,7 @@ /datum/brain_trauma/mild/hallucinations/on_life(delta_time, times_fired) if(owner.stat != CONSCIOUS || owner.IsSleeping() || owner.IsUnconscious()) return - if(HAS_TRAIT(owner, TRAIT_HALLUCINATION_SUPPRESSED)) + if(HAS_TRAIT(owner, TRAIT_RDS_SUPPRESSED)) return owner.adjust_hallucinations_up_to(10 SECONDS * delta_time, 100 SECONDS) diff --git a/code/datums/mood.dm b/code/datums/mood.dm index 20f0cae212f..ca359454357 100644 --- a/code/datums/mood.dm +++ b/code/datums/mood.dm @@ -499,6 +499,13 @@ mob_parent.remove_movespeed_modifier(MOVESPEED_ID_SANITY) mob_parent.add_actionspeed_modifier(/datum/actionspeed_modifier/high_sanity) sanity_level = SANITY_LEVEL_GREAT + + // Crazy or insane = add some uncommon hallucinations + if(sanity_level >= SANITY_CRAZY) + mob_parent.apply_status_effect(/datum/status_effect/hallucination/sanity) + else + mob_parent.remove_status_effect(/datum/status_effect/hallucination/sanity) + update_mood_icon() /// Sets the insanity effect on the mob diff --git a/code/datums/quirks/negative.dm b/code/datums/quirks/negative.dm index ba39936d2c8..2a469672d4b 100644 --- a/code/datums/quirks/negative.dm +++ b/code/datums/quirks/negative.dm @@ -525,6 +525,8 @@ medical_record_text = "Patient suffers from acute Reality Dissociation Syndrome and experiences vivid hallucinations." hardcore_value = 6 mail_goodies = list(/obj/item/storage/pill_bottle/lsdpsych) + /// Weakref to the trauma we give out + var/datum/weakref/added_trama_ref /datum/quirk/insanity/add() if(!iscarbon(quirk_holder)) @@ -543,6 +545,7 @@ added_trauma.lose_text = null carbon_quirk_holder.gain_trauma(added_trauma) + added_trama_ref = WEAKREF(added_trauma) /datum/quirk/insanity/post_add() if(!quirk_holder.mind || quirk_holder.mind.special_role) @@ -552,6 +555,9 @@ to_chat(quirk_holder, "Please note that your [lowertext(name)] does NOT give you the right to attack people or otherwise cause any interference to \ the round. You are not an antagonist, and the rules will treat you the same as other crewmembers.") +/datum/quirk/insanity/remove() + QDEL_NULL(added_trama_ref) + /datum/quirk/social_anxiety name = "Social Anxiety" desc = "Talking to people is very difficult for you, and you often stutter or even lock up." diff --git a/code/datums/status_effects/debuffs/hallucination.dm b/code/datums/status_effects/debuffs/hallucination.dm index 123f2332bab..d2e9c2f4e65 100644 --- a/code/datums/status_effects/debuffs/hallucination.dm +++ b/code/datums/status_effects/debuffs/hallucination.dm @@ -15,11 +15,12 @@ /datum/status_effect/hallucination/on_creation( mob/living/new_owner, - duration = 10 SECONDS, + duration, affects_silicons = FALSE, ) - src.duration = duration + if(isnum(duration)) + src.duration = duration src.affects_silicons = affects_silicons return ..() @@ -89,3 +90,41 @@ var/datum/hallucination/picked_hallucination = pick_weight(GLOB.random_hallucination_weighted_list) owner.cause_hallucination(picked_hallucination, "[id] status effect") COOLDOWN_START(src, hallucination_cooldown, rand(lower_tick_interval, upper_tick_interval)) + +// Sanity related hallucinations +/datum/status_effect/hallucination/sanity + id = "low sanity" + status_type = STATUS_EFFECT_REFRESH + duration = -1 // This lasts "forever", only goes away with sanity gain + +/datum/status_effect/hallucination/sanity/on_apply() + if(!owner.mob_mood) + return FALSE + + update_intervals() + return ..() + +/datum/status_effect/hallucination/sanity/refresh(...) + update_intervals() + +/datum/status_effect/hallucination/sanity/tick(delta_time, times_fired) + // Using psicodine / happiness / whatever to become fearless will stop sanity based hallucinations + if(HAS_TRAIT(owner, TRAIT_FEARLESS)) + return + + return ..() + +/// Updates our upper and lower intervals based on our owner's current sanity level. +/datum/status_effect/hallucination/sanity/proc/update_intervals() + switch(owner.mob_mood.sanity_level) + if(SANITY_LEVEL_CRAZY) + upper_tick_interval = 8 MINUTES + lower_tick_interval = 4 MINUTES + + if(SANITY_LEVEL_INSANE) + upper_tick_interval = 4 MINUTES + lower_tick_interval = 2 MINUTES + + else + stack_trace("[type] was assigned a mob which was not crazy or insane. (was: [owner.mob_mood.sanity_level])") + qdel(src) diff --git a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm index 8d568755963..afdee908776 100644 --- a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm @@ -309,11 +309,11 @@ /datum/reagent/toxin/mindbreaker/on_mob_metabolize(mob/living/metabolizer) . = ..() - ADD_TRAIT(metabolizer, TRAIT_HALLUCINATION_SUPPRESSED, type) + ADD_TRAIT(metabolizer, TRAIT_RDS_SUPPRESSED, type) /datum/reagent/toxin/mindbreaker/on_mob_end_metabolize(mob/living/metabolizer) . = ..() - REMOVE_TRAIT(metabolizer, TRAIT_HALLUCINATION_SUPPRESSED, type) + REMOVE_TRAIT(metabolizer, TRAIT_RDS_SUPPRESSED, type) /datum/reagent/toxin/mindbreaker/on_mob_life(mob/living/carbon/metabolizer, delta_time, times_fired) // mindbreaker toxin assuages hallucinations in those plagued with it, mentally