From 528af3e3ea09ee04fec2b58d0effac0fc5c41c55 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:21:32 +0200 Subject: [PATCH] [MIRROR] mood is more reactive to area beauty changes, also flips it for people with morbid trait. (#28691) * mood is more reactive to area beauty changes, also flips it for people with morbid trait. (#84641) ## About The Pull Request Previously, the mood datum would only react to beauty when entering an area, any later changes to the room wouldn't update it for the mood datum. Also, mobs with the morbid trait (ie. the cononer) now like degradated-looking rooms and dislike (if they also have the snob trait), well-decorated ones. ## Why It's Good For The Game Feature and improvement. ## Changelog :cl: qol: Mood more promptly reacts to the beauty of an area as it changes, and not just when changing areas. add: Coroners (and potentially other mobs with the morbid trait), now like degradated-looking rooms. /:cl: * mood is more reactive to area beauty changes, also flips it for people with morbid trait. --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/__DEFINES/dcs/signals/signals_area.dm | 3 ++ code/datums/mood.dm | 38 +++++++++++++++++++++- code/datums/mood_events/beauty_events.dm | 4 +++ code/game/area/areas.dm | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/dcs/signals/signals_area.dm b/code/__DEFINES/dcs/signals/signals_area.dm index 762431788f2..b136f46467f 100644 --- a/code/__DEFINES/dcs/signals/signals_area.dm +++ b/code/__DEFINES/dcs/signals/signals_area.dm @@ -35,3 +35,6 @@ #define COMSIG_WEATHER_BEGAN_IN_AREA(event_type) "weather_began_in_area_[event_type]" /// Called when some weather ends in this area #define COMSIG_WEATHER_ENDED_IN_AREA(event_type) "weather_ended_in_area_[event_type]" + +///From base of area/update_beauty() +#define COMSIG_AREA_BEAUTY_UPDATED "area_beauty_updated" diff --git a/code/datums/mood.dm b/code/datums/mood.dm index a9400d12347..79d95ae35e5 100644 --- a/code/datums/mood.dm +++ b/code/datums/mood.dm @@ -48,10 +48,15 @@ RegisterSignal(mob_to_make_moody, COMSIG_MOB_HUD_CREATED, PROC_REF(modify_hud)) RegisterSignal(mob_to_make_moody, COMSIG_ENTER_AREA, PROC_REF(check_area_mood)) + RegisterSignal(mob_to_make_moody, COMSIG_EXIT_AREA, PROC_REF(exit_area)) RegisterSignal(mob_to_make_moody, COMSIG_LIVING_REVIVE, PROC_REF(on_revive)) RegisterSignal(mob_to_make_moody, COMSIG_MOB_STATCHANGE, PROC_REF(handle_mob_death)) RegisterSignal(mob_to_make_moody, COMSIG_QDELETING, PROC_REF(clear_parent_ref)) + var/area/our_area = get_area(mob_to_make_moody) + if(our_area) + check_area_mood(mob_to_make_moody, our_area) + mob_to_make_moody.become_area_sensitive(MOOD_DATUM_TRAIT) if(mob_to_make_moody.hud_used) modify_hud() @@ -63,7 +68,10 @@ unmodify_hud() mob_parent.lose_area_sensitivity(MOOD_DATUM_TRAIT) - UnregisterSignal(mob_parent, list(COMSIG_MOB_HUD_CREATED, COMSIG_ENTER_AREA, COMSIG_LIVING_REVIVE, COMSIG_MOB_STATCHANGE, COMSIG_QDELETING)) + UnregisterSignal(mob_parent, list(COMSIG_MOB_HUD_CREATED, COMSIG_ENTER_AREA, COMSIG_EXIT_AREA, COMSIG_LIVING_REVIVE, COMSIG_MOB_STATCHANGE, COMSIG_QDELETING)) + var/area/our_area = get_area(mob_parent) + if(our_area) + UnregisterSignal(our_area, COMSIG_AREA_BEAUTY_UPDATED) mob_parent = null @@ -439,6 +447,8 @@ /datum/mood/proc/check_area_mood(datum/source, area/new_area) SIGNAL_HANDLER + RegisterSignal(new_area, COMSIG_AREA_BEAUTY_UPDATED, PROC_REF(update_beauty)) + update_beauty(new_area) if (new_area.mood_bonus && (!new_area.mood_trait || HAS_TRAIT(source, new_area.mood_trait))) add_mood_event("area", /datum/mood_event/area, new_area.mood_bonus, new_area.mood_message) @@ -447,10 +457,32 @@ /// Updates the mob's given beauty moodie, based on the area /datum/mood/proc/update_beauty(area/area_to_beautify) + SIGNAL_HANDLER if (area_to_beautify.outdoors) // if we're outside, we don't care clear_mood_event(MOOD_CATEGORY_AREA_BEAUTY) return + if(HAS_TRAIT(mob_parent, TRAIT_MORBID)) + if(HAS_TRAIT(mob_parent, TRAIT_SNOB)) + switch(area_to_beautify.beauty) + if(BEAUTY_LEVEL_DECENT to BEAUTY_LEVEL_GOOD) + add_mood_event(MOOD_CATEGORY_AREA_BEAUTY, /datum/mood_event/ehroom) + return + if(BEAUTY_LEVEL_GOOD to BEAUTY_LEVEL_GREAT) + add_mood_event(MOOD_CATEGORY_AREA_BEAUTY, /datum/mood_event/badroom) + return + if(BEAUTY_LEVEL_GREAT to INFINITY) + add_mood_event(MOOD_CATEGORY_AREA_BEAUTY, /datum/mood_event/horridroom) + return + switch(area_to_beautify.beauty) + if(-INFINITY to BEAUTY_LEVEL_HORRID) + add_mood_event(MOOD_CATEGORY_AREA_BEAUTY, /datum/mood_event/greatroom) + if(BEAUTY_LEVEL_HORRID to BEAUTY_LEVEL_BAD) + add_mood_event(MOOD_CATEGORY_AREA_BEAUTY, /datum/mood_event/goodroom) + if(BEAUTY_LEVEL_BAD to BEAUTY_LEVEL_DECENT) + clear_mood_event(MOOD_CATEGORY_AREA_BEAUTY) + return + if(HAS_TRAIT(mob_parent, TRAIT_SNOB)) switch(area_to_beautify.beauty) if(-INFINITY to BEAUTY_LEVEL_HORRID) @@ -469,6 +501,10 @@ if(BEAUTY_LEVEL_GREAT to INFINITY) add_mood_event(MOOD_CATEGORY_AREA_BEAUTY, /datum/mood_event/greatroom) +/datum/mood/proc/exit_area(datum/source, area/old_area) + SIGNAL_HANDLER + UnregisterSignal(old_area, COMSIG_AREA_BEAUTY_UPDATED) + /// Called when parent is ahealed. /datum/mood/proc/on_revive(datum/source, full_heal) SIGNAL_HANDLER diff --git a/code/datums/mood_events/beauty_events.dm b/code/datums/mood_events/beauty_events.dm index 31e199c47e1..ec89a9b41b9 100644 --- a/code/datums/mood_events/beauty_events.dm +++ b/code/datums/mood_events/beauty_events.dm @@ -6,6 +6,10 @@ description = "This room looks really bad." mood_change = -3 +/datum/mood_event/ehroom + description = "This room looks kinda bad." + mood_change = -1 + /datum/mood_event/decentroom description = "This room looks alright." mood_change = 1 diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 36ce8c5a24f..0c6847e7db3 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -567,6 +567,7 @@ GLOBAL_LIST_EMPTY(teleportlocs) beauty = 0 return FALSE //Too big beauty = totalbeauty / areasize + SEND_SIGNAL(src, COMSIG_AREA_BEAUTY_UPDATED) /** * Setup an area (with the given name)