Cleans up mood and mood-related code (#90162)

## About The Pull Request

One of my upcoming PRs affects a significant chunk of the codebase so
I'm cleaning up messes that I've found along the way.
This PR adds wrappers for adjusting sanity/checking if a mob already has
a certain moodlet, fixes an oversight where attempting to set sanity
over passed maximum would abort the change outright (instead of actually
capping it out), moved jolly and depression processing into quirks
themselves (instead of having dedicated traits for them used solely by
said quirks and nothing else that are constantly checked for by mood
datums), and rewrote how blessings return their results to move omen's
deletion on blessing effect from constantly checking mood for a blessing
moodlet to a comsig.

## Why It's Good For The Game

Less jank handling of certain mechanics, we ***really*** shouldn't be
checking for blessings every time mood of all things is updated.

## Changelog
🆑
fix: Adjusting sanity over the allowed maximum will no longer completely
halt the change, and instead actually cap it at the maximum value.
code: Cleaned up mood and mood-adjacent code.
/🆑
This commit is contained in:
SmArtKar
2025-03-24 13:53:03 +01:00
committed by GitHub
parent 6db02f5cc2
commit cf131db497
27 changed files with 236 additions and 194 deletions
+24 -15
View File
@@ -204,25 +204,30 @@ GLOBAL_LIST_INIT(bibleitemstates, list(
/obj/item/book/bible/proc/bless(mob/living/blessed, mob/living/user)
if(GLOB.religious_sect)
return GLOB.religious_sect.sect_bless(blessed,user)
if(!ishuman(blessed))
return
return BLESSING_FAILED
var/mob/living/carbon/human/built_in_his_image = blessed
for(var/obj/item/bodypart/bodypart as anything in built_in_his_image.bodyparts)
if(!IS_ORGANIC_LIMB(bodypart))
balloon_alert(user, "can't heal inorganic!")
return FALSE
return BLESSING_IGNORED
var/heal_amt = 10
var/list/hurt_limbs = built_in_his_image.get_damaged_bodyparts(1, 1, BODYTYPE_ORGANIC)
if(length(hurt_limbs))
for(var/obj/item/bodypart/affecting as anything in hurt_limbs)
if(affecting.heal_damage(heal_amt, heal_amt, required_bodytype = BODYTYPE_ORGANIC))
built_in_his_image.update_damage_overlays()
built_in_his_image.visible_message(span_notice("[user] heals [built_in_his_image] with the power of [deity_name]!"))
to_chat(built_in_his_image, span_boldnotice("May the power of [deity_name] compel you to be healed!"))
playsound(built_in_his_image, SFX_PUNCH, 25, TRUE, -1)
built_in_his_image.add_mood_event("blessing", /datum/mood_event/blessing)
return TRUE
if(!length(hurt_limbs))
return BLESSING_IGNORED
for(var/obj/item/bodypart/affecting as anything in hurt_limbs)
if(affecting.heal_damage(heal_amt, heal_amt, required_bodytype = BODYTYPE_ORGANIC))
built_in_his_image.update_damage_overlays()
built_in_his_image.visible_message(span_notice("[user] heals [built_in_his_image] with the power of [deity_name]!"))
to_chat(built_in_his_image, span_boldnotice("May the power of [deity_name] compel you to be healed!"))
playsound(built_in_his_image, SFX_PUNCH, 25, TRUE, -1)
built_in_his_image.add_mood_event("blessing", /datum/mood_event/blessing)
return BLESSING_SUCCESS
/obj/item/book/bible/attack(mob/living/target_mob, mob/living/carbon/human/user, params, heal_mode = TRUE)
if(!ISADVANCEDTOOLUSER(user))
@@ -244,7 +249,7 @@ GLOBAL_LIST_INIT(bibleitemstates, list(
return ..()
if(target_mob.stat == DEAD)
if(!GLOB.religious_sect?.sect_dead_bless(target_mob, user))
if(GLOB.religious_sect?.sect_dead_bless(target_mob, user) == BLESSING_FAILED)
target_mob.visible_message(span_danger("[user] smacks [target_mob]'s lifeless corpse with [src]."))
playsound(target_mob, SFX_PUNCH, 25, TRUE, -1)
return
@@ -256,9 +261,13 @@ GLOBAL_LIST_INIT(bibleitemstates, list(
var/smack_chance = DEFAULT_SMACK_CHANCE
if(GLOB.religious_sect)
smack_chance = GLOB.religious_sect.smack_chance
var/success = !prob(smack_chance) && bless(target_mob, user)
if(success)
return
if(!prob(smack_chance))
var/bless_result = bless(target_mob, user)
if (bless_result != BLESSING_FAILED)
SEND_SIGNAL(target_mob, COMSIG_LIVING_BLESSED, user, src, bless_result)
return
if(iscarbon(target_mob))
var/mob/living/carbon/carbon_target = target_mob
if(!istype(carbon_target.head, /obj/item/clothing/head/helmet))