mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Mood Code Improvements [Merge-Ready?] (#39075)
fix: having higher sanity is no longer punished by making you enter crit faster balance: you can have 100 mood instead of 99 before it starts slowly decreasing Remember higher sanity is BETTER You want crit_modifier (now crit_threshold) to be LOW so you can stay in fights more (you go into crit at 5hp vs 0hp). Why: Proc overhead, puts the load on mood, proper abstraction of mood component, values > defines, etc.
This commit is contained in:
committed by
yogstation13-bot
parent
1e2e6a7952
commit
872817b70b
@@ -15,7 +15,7 @@
|
||||
if(prob(4))
|
||||
if(prob(33) && (owner.IsStun() || owner.IsKnockdown() || owner.IsUnconscious()))
|
||||
speak("unstun", TRUE)
|
||||
else if(prob(60) && owner.health <= owner.crit_modifier())
|
||||
else if(prob(60) && owner.health <= owner.crit_threshold)
|
||||
speak("heal", TRUE)
|
||||
else if(prob(30) && owner.a_intent == INTENT_HARM)
|
||||
speak("aggressive")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#define MINOR_INSANITY_PEN 5
|
||||
#define MAJOR_INSANITY_PEN 10
|
||||
|
||||
/datum/component/mood
|
||||
var/mood //Real happiness
|
||||
var/sanity = 100 //Current sanity
|
||||
@@ -6,6 +9,8 @@
|
||||
var/mood_modifier = 1 //Modifier to allow certain mobs to be less affected by moodlets
|
||||
var/datum/mood_event/list/mood_events = list()
|
||||
var/mob/living/owner
|
||||
var/insanity_effect = 0 //is the owner being punished for low mood? If so, how much?
|
||||
var/holdmyinsanityeffect = 0 //before we edit our sanity lets take a look
|
||||
|
||||
/datum/component/mood/Initialize()
|
||||
if(!isliving(parent))
|
||||
@@ -120,13 +125,13 @@
|
||||
|
||||
switch(mood_level)
|
||||
if(1)
|
||||
DecreaseSanity(0.2, 0)
|
||||
DecreaseSanity(0.2)
|
||||
if(2)
|
||||
DecreaseSanity(0.125, 25)
|
||||
DecreaseSanity(0.125, SANITY_CRAZY)
|
||||
if(3)
|
||||
DecreaseSanity(0.075, 50)
|
||||
DecreaseSanity(0.075, SANITY_UNSTABLE)
|
||||
if(4)
|
||||
DecreaseSanity(0.025, 75)
|
||||
DecreaseSanity(0.025, SANITY_DISTURBED)
|
||||
if(5)
|
||||
IncreaseSanity(0.1)
|
||||
if(6)
|
||||
@@ -134,9 +139,15 @@
|
||||
if(7)
|
||||
IncreaseSanity(0.20)
|
||||
if(8)
|
||||
IncreaseSanity(0.25, 125)
|
||||
IncreaseSanity(0.25, SANITY_GREAT)
|
||||
if(9)
|
||||
IncreaseSanity(0.4, 125)
|
||||
IncreaseSanity(0.4, SANITY_GREAT)
|
||||
|
||||
if(insanity_effect != holdmyinsanityeffect)
|
||||
if(insanity_effect > holdmyinsanityeffect)
|
||||
owner.crit_threshold += (insanity_effect - holdmyinsanityeffect)
|
||||
else
|
||||
owner.crit_threshold -= (holdmyinsanityeffect - insanity_effect)
|
||||
|
||||
if(owner.has_trait(TRAIT_DEPRESSION))
|
||||
if(prob(0.05))
|
||||
@@ -147,17 +158,29 @@
|
||||
add_event("jolly", /datum/mood_event/jolly)
|
||||
clear_event("depression")
|
||||
|
||||
/datum/component/mood/proc/DecreaseSanity(amount, limit = 0)
|
||||
if(sanity < limit) //This might make KevinZ stop fucking pinging me.
|
||||
holdmyinsanityeffect = insanity_effect
|
||||
|
||||
/datum/component/mood/proc/DecreaseSanity(amount, minimum = SANITY_INSANE)
|
||||
if(sanity < minimum) //This might make KevinZ stop fucking pinging me.
|
||||
IncreaseSanity(0.5)
|
||||
else
|
||||
sanity = max(0, sanity - amount)
|
||||
sanity = max(minimum, sanity - amount)
|
||||
if(sanity < SANITY_UNSTABLE)
|
||||
if(sanity < SANITY_CRAZY)
|
||||
insanity_effect = (MAJOR_INSANITY_PEN)
|
||||
else
|
||||
insanity_effect = (MINOR_INSANITY_PEN)
|
||||
|
||||
/datum/component/mood/proc/IncreaseSanity(amount, limit = 99)
|
||||
if(sanity > limit)
|
||||
/datum/component/mood/proc/IncreaseSanity(amount, maximum = SANITY_NEUTRAL)
|
||||
if(sanity > maximum)
|
||||
DecreaseSanity(0.5) //Removes some sanity to go back to our current limit.
|
||||
else
|
||||
sanity = min(limit, sanity + amount)
|
||||
sanity = min(maximum, sanity + amount)
|
||||
if(sanity > SANITY_CRAZY)
|
||||
if(sanity > SANITY_UNSTABLE)
|
||||
insanity_effect = 0
|
||||
else
|
||||
insanity_effect = MINOR_INSANITY_PEN
|
||||
|
||||
/datum/component/mood/proc/add_event(category, type, param) //Category will override any events in the same category, should be unique unless the event is based on the same thing like hunger.
|
||||
var/datum/mood_event/the_event
|
||||
@@ -183,3 +206,6 @@
|
||||
mood_events -= category
|
||||
qdel(event)
|
||||
update_mood()
|
||||
|
||||
#undef MINOR_INSANITY_PEN
|
||||
#undef MAJOR_INSANITY_PEN
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
if(prob(20))
|
||||
if(carbon_owner)
|
||||
carbon_owner.handle_dreams()
|
||||
if(prob(10) && owner.health > owner.crit_modifier())
|
||||
if(prob(10) && owner.health > owner.crit_threshold)
|
||||
owner.emote("snore")
|
||||
|
||||
/obj/screen/alert/status_effect/asleep
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
/obj/item/organ/regenerative_core/on_life()
|
||||
..()
|
||||
if(owner.health < owner.crit_modifier())
|
||||
if(owner.health < owner.crit_threshold)
|
||||
ui_action_click()
|
||||
|
||||
/obj/item/organ/regenerative_core/afterattack(atom/target, mob/user, proximity_flag)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
if(health<= -maxHealth || !getorgan(/obj/item/organ/brain))
|
||||
death()
|
||||
return
|
||||
if(IsUnconscious() || IsSleeping() || getOxyLoss() > 50 || (has_trait(TRAIT_FAKEDEATH)) || health <= crit_modifier())
|
||||
if(IsUnconscious() || IsSleeping() || getOxyLoss() > 50 || (has_trait(TRAIT_FAKEDEATH)) || health <= crit_threshold)
|
||||
if(stat == CONSCIOUS)
|
||||
stat = UNCONSCIOUS
|
||||
blind_eyes(1)
|
||||
|
||||
@@ -599,7 +599,7 @@
|
||||
if(!client)
|
||||
return
|
||||
|
||||
if(health <= crit_modifier())
|
||||
if(health <= crit_threshold)
|
||||
var/severity = 0
|
||||
switch(health)
|
||||
if(-20 to -10)
|
||||
@@ -728,7 +728,7 @@
|
||||
stat = UNCONSCIOUS
|
||||
blind_eyes(1)
|
||||
else
|
||||
if(health <= crit_modifier() && !has_trait(TRAIT_NOSOFTCRIT))
|
||||
if(health <= crit_threshold && !has_trait(TRAIT_NOSOFTCRIT))
|
||||
stat = SOFT_CRIT
|
||||
else
|
||||
stat = CONSCIOUS
|
||||
|
||||
@@ -372,12 +372,3 @@
|
||||
var/obj/item/organ/ears/ears = getorganslot(ORGAN_SLOT_EARS)
|
||||
if(istype(ears) && !ears.deaf)
|
||||
. = TRUE
|
||||
|
||||
/mob/living/carbon/crit_modifier()
|
||||
. = ..()
|
||||
GET_COMPONENT(mood, /datum/component/mood)
|
||||
if(mood)
|
||||
if(mood.sanity >= SANITY_UNSTABLE)
|
||||
. += 5
|
||||
else if(mood.sanity >= SANITY_CRAZY)
|
||||
. += 10
|
||||
|
||||
@@ -656,7 +656,7 @@
|
||||
var/they_breathe = !C.has_trait(TRAIT_NOBREATH)
|
||||
var/they_lung = C.getorganslot(ORGAN_SLOT_LUNGS)
|
||||
|
||||
if(C.health > C.crit_modifier())
|
||||
if(C.health > C.crit_threshold)
|
||||
return
|
||||
|
||||
src.visible_message("[src] performs CPR on [C.name]!", "<span class='notice'>You perform CPR on [C.name].</span>")
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
var/L = getorganslot(ORGAN_SLOT_LUNGS)
|
||||
|
||||
if(!L)
|
||||
if(health >= crit_modifier())
|
||||
if(health >= crit_threshold)
|
||||
adjustOxyLoss(HUMAN_MAX_OXYLOSS + 1)
|
||||
else if(!has_trait(TRAIT_NOCRITDAMAGE))
|
||||
adjustOxyLoss(HUMAN_CRIT_MAX_OXYLOSS)
|
||||
|
||||
@@ -709,7 +709,7 @@ GLOBAL_LIST_EMPTY(roundstart_races)
|
||||
H.losebreath = 0
|
||||
|
||||
var/takes_crit_damage = (!H.has_trait(TRAIT_NOCRITDAMAGE))
|
||||
if((H.health < H.crit_modifier()) && takes_crit_damage)
|
||||
if((H.health < H.crit_threshold) && takes_crit_damage)
|
||||
H.adjustBruteLoss(1)
|
||||
|
||||
/datum/species/proc/spec_death(gibbed, mob/living/carbon/human/H)
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
if(health <= HEALTH_THRESHOLD_FULLCRIT || (pulledby && pulledby.grab_state >= GRAB_KILL))
|
||||
losebreath++ //You can't breath at all when in critical or when being choked, so you're going to miss a breath
|
||||
|
||||
else if(health <= crit_modifier())
|
||||
else if(health <= crit_threshold)
|
||||
losebreath += 0.25 //You're having trouble breathing in soft crit, so you'll miss a breath one in four times
|
||||
|
||||
//Suffocate
|
||||
@@ -154,7 +154,7 @@
|
||||
|
||||
else //Enough oxygen
|
||||
failed_last_breath = 0
|
||||
if(health >= crit_modifier())
|
||||
if(health >= crit_threshold)
|
||||
adjustOxyLoss(-5)
|
||||
oxygen_used = breath_gases[/datum/gas/oxygen][MOLES]
|
||||
clear_alert("not_enough_oxy")
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
return TRUE
|
||||
|
||||
/mob/living/proc/InCritical()
|
||||
return (health <= crit_modifier() && (stat == SOFT_CRIT || stat == UNCONSCIOUS))
|
||||
return (health <= crit_threshold && (stat == SOFT_CRIT || stat == UNCONSCIOUS))
|
||||
|
||||
/mob/living/proc/InFullCritical()
|
||||
return (health <= HEALTH_THRESHOLD_FULLCRIT && stat == UNCONSCIOUS)
|
||||
@@ -807,7 +807,7 @@
|
||||
var/stam = getStaminaLoss()
|
||||
if(stam)
|
||||
var/total_health = (health - stam)
|
||||
if(total_health <= crit_modifier() && !stat && !IsKnockdown())
|
||||
if(total_health <= crit_threshold && !stat && !IsKnockdown())
|
||||
to_chat(src, "<span class='notice'>You're too exhausted to keep going...</span>")
|
||||
Knockdown(100)
|
||||
update_health_hud()
|
||||
|
||||
@@ -61,9 +61,6 @@
|
||||
else
|
||||
return 0
|
||||
|
||||
/mob/living/proc/crit_modifier()
|
||||
return HEALTH_THRESHOLD_CRIT
|
||||
|
||||
/mob/living/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE)
|
||||
if(istype(AM, /obj/item))
|
||||
var/obj/item/I = AM
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
var/fireloss = 0 //Burn damage caused by being way too hot, too cold or burnt.
|
||||
var/cloneloss = 0 //Damage caused by being cloned or ejected from the cloner early. slimes also deal cloneloss damage to victims
|
||||
var/staminaloss = 0 //Stamina damage, or exhaustion. You recover it slowly naturally, and are knocked down if it gets too high. Holodeck and hallucinations deal this.
|
||||
var/crit_threshold = HEALTH_THRESHOLD_CRIT // when the mob goes from "normal" to crit
|
||||
|
||||
var/confused = 0 //Makes the mob move in random directions.
|
||||
|
||||
|
||||
@@ -54,11 +54,11 @@
|
||||
var/sound/fastbeat = sound('sound/health/fastbeat.ogg', repeat = TRUE)
|
||||
var/mob/living/carbon/H = owner
|
||||
|
||||
if(H.health <= H.crit_modifier() && beat != BEAT_SLOW)
|
||||
if(H.health <= H.crit_threshold && beat != BEAT_SLOW)
|
||||
beat = BEAT_SLOW
|
||||
H.playsound_local(get_turf(H), slowbeat,40,0, channel = CHANNEL_HEARTBEAT)
|
||||
to_chat(owner, "<span class = 'notice'>You feel your heart slow down...</span>")
|
||||
if(beat == BEAT_SLOW && H.health > H.crit_modifier())
|
||||
if(beat == BEAT_SLOW && H.health > H.crit_threshold)
|
||||
H.stop_sound_channel(CHANNEL_HEARTBEAT)
|
||||
beat = BEAT_NONE
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
if(!breath || (breath.total_moles() == 0))
|
||||
if(H.reagents.has_reagent(crit_stabilizing_reagent))
|
||||
return
|
||||
if(H.health >= H.crit_modifier())
|
||||
if(H.health >= H.crit_threshold)
|
||||
H.adjustOxyLoss(HUMAN_MAX_OXYLOSS)
|
||||
else if(!H.has_trait(TRAIT_NOCRITDAMAGE))
|
||||
H.adjustOxyLoss(HUMAN_CRIT_MAX_OXYLOSS)
|
||||
@@ -111,7 +111,7 @@
|
||||
H.throw_alert("not_enough_oxy", /obj/screen/alert/not_enough_oxy)
|
||||
else
|
||||
H.failed_last_breath = FALSE
|
||||
if(H.health >= H.crit_modifier())
|
||||
if(H.health >= H.crit_threshold)
|
||||
H.adjustOxyLoss(-5)
|
||||
gas_breathed = breath_gases[/datum/gas/oxygen][MOLES]
|
||||
H.clear_alert("not_enough_oxy")
|
||||
@@ -139,7 +139,7 @@
|
||||
H.throw_alert("nitro", /obj/screen/alert/not_enough_nitro)
|
||||
else
|
||||
H.failed_last_breath = FALSE
|
||||
if(H.health >= H.crit_modifier())
|
||||
if(H.health >= H.crit_threshold)
|
||||
H.adjustOxyLoss(-5)
|
||||
gas_breathed = breath_gases[/datum/gas/nitrogen][MOLES]
|
||||
H.clear_alert("nitro")
|
||||
@@ -176,7 +176,7 @@
|
||||
H.throw_alert("not_enough_co2", /obj/screen/alert/not_enough_co2)
|
||||
else
|
||||
H.failed_last_breath = FALSE
|
||||
if(H.health >= H.crit_modifier())
|
||||
if(H.health >= H.crit_threshold)
|
||||
H.adjustOxyLoss(-5)
|
||||
gas_breathed = breath_gases[/datum/gas/carbon_dioxide][MOLES]
|
||||
H.clear_alert("not_enough_co2")
|
||||
@@ -206,7 +206,7 @@
|
||||
H.throw_alert("not_enough_tox", /obj/screen/alert/not_enough_tox)
|
||||
else
|
||||
H.failed_last_breath = FALSE
|
||||
if(H.health >= H.crit_modifier())
|
||||
if(H.health >= H.crit_threshold)
|
||||
H.adjustOxyLoss(-5)
|
||||
gas_breathed = breath_gases[/datum/gas/plasma][MOLES]
|
||||
H.clear_alert("not_enough_tox")
|
||||
|
||||
Reference in New Issue
Block a user