Skip to content

Commit

Permalink
Status Effects - Part 3A (v2) - Daze Refactor (#5153)
Browse files Browse the repository at this point in the history
# About the pull request

Depends on Part 2 (#4842), reopening of #4844

Refactors daze and speech problems handling to back them by new
status_effect-s and traits, fixes a few bugs, and gets rid of an unused
and horrible bay12 relic horsehead with snowflake speech handling

This just generally makes it more reliable timewise and allows further
interactions in the future

:cl:
code: Refactored Daze to use new Status backend
fix: Dazed screen effect now applies immediately
fix: Stuttering now starts properly when dazed
del: Removed unused disabilities code
del: Removed an old, goofy and unused decade old horse mask
/:cl:

---------

Co-authored-by: forest2001 <[email protected]>
  • Loading branch information
2 people authored and Doubleumc committed Jul 23, 2024
1 parent 7138e0d commit d434c1d
Show file tree
Hide file tree
Showing 27 changed files with 134 additions and 163 deletions.
4 changes: 1 addition & 3 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@

//disabilities
#define NEARSIGHTED (1<<0)
#define EPILEPSY (1<<1)
#define COUGHING (1<<2)
#define TOURETTES (1<<3)

#define NERVOUS (1<<4)
#define OPIATE_RECEPTOR_DEFICIENCY (1<<5)
//=================================================
Expand Down
6 changes: 6 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
#define TRAIT_FORCED_STANDING "forcedstanding"
/// Stuns preventing movement and using objects but without further impairement
#define TRAIT_INCAPACITATED "incapacitated"
/// Disoriented. Unable to talk properly, and unable to use some skills as Xeno
#define TRAIT_DAZED "dazed"
/// Apply this to identify a mob as merged with weeds
#define TRAIT_MERGED_WITH_WEEDS "merged_with_weeds"

Expand Down Expand Up @@ -310,6 +312,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_IMMOBILIZED" = TRAIT_IMMOBILIZED,
"TRAIT_INCAPACITATED" = TRAIT_INCAPACITATED,
"TRAIT_FLOORED" = TRAIT_FLOORED,
"TRAIT_DAZED" = TRAIT_DAZED,
"TRAIT_UNDENSE" = TRAIT_UNDENSE,
"TRAIT_YAUTJA_TECH" = TRAIT_YAUTJA_TECH,
"TRAIT_SUPER_STRONG" = TRAIT_SUPER_STRONG,
Expand All @@ -336,6 +339,8 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_VULTURE_USER" = TRAIT_VULTURE_USER,
"TRAIT_CLOAKED" = TRAIT_CLOAKED,
),
// /mob/living/carbon/human = list(
// ),
/mob/living/carbon/xenomorph = list(
"TRAIT_ABILITY_NO_PLASMA_TRANSFER" = TRAIT_ABILITY_NO_PLASMA_TRANSFER,
"TRAIT_ABILITY_OVIPOSITOR" = TRAIT_ABILITY_OVIPOSITOR,
Expand Down Expand Up @@ -411,6 +416,7 @@ GLOBAL_LIST(trait_name_map)
#define TRAIT_SOURCE_ATTACHMENT(slot) "t_s_attachment_[slot]"
///Status trait coming from ability
#define TRAIT_SOURCE_ABILITY(ability) "t_s_ability_[ability]"
#define TRAIT_SOURCE_LIMB(limb) "t_s_limb_[limb]"
///Status trait forced by the xeno action charge
#define TRAIT_SOURCE_XENO_ACTION_CHARGE "t_s_xeno_action_charge"
///Status trait coming from a xeno nest
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ var/global/image/action_purple_power_up
)
. = FALSE
break
if(user_flags & INTERRUPT_DAZED && busy_user.dazed)
if(user_flags & INTERRUPT_DAZED && HAS_TRAIT(busy_user, TRAIT_DAZED))
. = FALSE
break
if(user_flags & INTERRUPT_EMOTE && !busy_user.flags_emote)
Expand Down
3 changes: 0 additions & 3 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,6 @@ DEFINE_BITFIELD(flags_area, list(

DEFINE_BITFIELD(disabilities, list(
"NEARSIGHTED" = NEARSIGHTED,
"EPILEPSY" = EPILEPSY,
"COUGHING" = COUGHING,
"TOURETTES" = TOURETTES,
"NERVOUS" = NERVOUS,
"OPIATE_RECEPTOR_DEFICIENCY" = OPIATE_RECEPTOR_DEFICIENCY,
))
Expand Down
16 changes: 16 additions & 0 deletions code/datums/status_effects/debuffs/debuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,19 @@
name = "Unconscious"
desc = "You've been knocked out."
icon_state = ALERT_KNOCKEDOUT

/// DAZED:
/// This prevents talking as human or using abilities as Xenos, mainly
/datum/status_effect/incapacitating/dazed
id = "dazed"
needs_update_stat = TRUE

/datum/status_effect/incapacitating/dazed/on_apply()
. = ..()
if(!.)
return
ADD_TRAIT(owner, TRAIT_DAZED, TRAIT_STATUS_EFFECT(id))

/datum/status_effect/incapacitating/dazed/on_remove()
REMOVE_TRAIT(owner, TRAIT_DAZED, TRAIT_STATUS_EFFECT(id))
return ..()
5 changes: 2 additions & 3 deletions code/game/objects/items/devices/megaphone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
return
// we know user is a human now, so adjust user for this check
var/mob/living/carbon/human/humanoid = user
if(humanoid.speech_problem_flag)
var/list/new_message = humanoid.handle_speech_problems(message)
message = new_message[1]
var/list/new_message = humanoid.handle_speech_problems(message)
message = new_message[1]
message = capitalize(message)
log_admin("[key_name(user)] used a megaphone to say: >[message]<")

Expand Down
3 changes: 0 additions & 3 deletions code/modules/character_traits/biology_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,10 @@
return

ADD_TRAIT(target, TRAIT_LISPING, ROUNDSTART_TRAIT)
target.speech_problem_flag = TRUE

..()

/datum/character_trait/biology/lisp/unapply_trait(mob/living/carbon/human/target)
REMOVE_TRAIT(target, TRAIT_LISPING, ROUNDSTART_TRAIT)
target.speech_problem_flag = FALSE
..()

/datum/character_trait/biology/bad_leg
Expand Down
13 changes: 0 additions & 13 deletions code/modules/clothing/masks/miscellaneous.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,6 @@
siemens_coefficient = 0.9
flags_armor_protection = BODY_FLAG_HEAD|BODY_FLAG_FACE|BODY_FLAG_EYES

/obj/item/clothing/mask/horsehead
name = "horse head mask"
desc = "A mask made of soft vinyl and latex, representing the head of a horse."
icon_state = "horsehead"
item_state = "horsehead"
flags_inventory = COVERMOUTH|COVEREYES
flags_inv_hide = HIDEFACE|HIDEALLHAIR|HIDEEYES|HIDEEARS
flags_armor_protection = BODY_FLAG_HEAD|BODY_FLAG_FACE|BODY_FLAG_EYES
w_class = SIZE_SMALL
var/voicechange = 0
siemens_coefficient = 0.9


/obj/item/clothing/mask/balaclava
name = "balaclava"
desc = "A basic single eye-hole balaclava, available in almost every sporting goods, outdoor supply, or military surplus store in existance, protects your face from the cold almost as well as it conceals it. This one is in a standard black color."
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ CULT

/datum/action/human_action/activable/can_use_action()
var/mob/living/carbon/human/H = owner
if(istype(H) && !H.is_mob_incapacitated() && !H.dazed)
if(istype(H) && !H.is_mob_incapacitated() && !HAS_TRAIT(H, TRAIT_DAZED))
return TRUE

// Called when the action is clicked on.
Expand Down
3 changes: 1 addition & 2 deletions code/modules/mob/living/carbon/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t
apply_damage(burn, BURN, picked, sharp, edge)
UpdateDamageIcon()
updatehealth()
speech_problem_flag = TRUE


//Heal MANY limbs, in random order
Expand All @@ -308,7 +307,7 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t

parts -= picked
updatehealth()
speech_problem_flag = TRUE

if(update) UpdateDamageIcon()

// damage MANY limbs, in random order
Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@

var/voice

var/speech_problem_flag = FALSE

var/special_voice = "" // For changing our voice. Used by a symptom.

var/last_dam = -1 //Used for determining if we need to process all limbs or just some or even none.
Expand Down
35 changes: 0 additions & 35 deletions code/modules/mob/living/carbon/human/life/handle_disabilities.dm
Original file line number Diff line number Diff line change
@@ -1,42 +1,7 @@
//Refer to life.dm for caller

/mob/living/carbon/human/proc/handle_disabilities()

if(disabilities & EPILEPSY)
if(prob(1) && !HAS_TRAIT(src, TRAIT_KNOCKEDOUT))
visible_message(SPAN_DANGER("\The [src] starts having a seizure!"), \
SPAN_DANGER("You start having a seizure!"), null, 5)
apply_effect(10, PARALYZE)
make_jittery(1000)
return

if(disabilities & COUGHING)
if(prob(5) && !HAS_TRAIT(src, TRAIT_KNOCKEDOUT))
drop_held_item()
INVOKE_ASYNC(src, PROC_REF(emote), "cough")
return

if(disabilities & TOURETTES)
speech_problem_flag = TRUE
if((prob(10) && !HAS_TRAIT(src, TRAIT_KNOCKEDOUT)))
apply_effect(10, STUN)
spawn()
switch(rand(1, 3))
if(1)
emote("twitch")
if(2 to 3)
say("[prob(50) ? ";" : ""][pick("SHIT", "PISS", "FUCK", "CUNT", "COCKSUCKER", "MOTHERFUCKER", "TITS")]")
var/old_x = pixel_x
var/old_y = pixel_y
pixel_x += rand(-2, 2)
pixel_y += rand(-1, 1)
sleep(2)
pixel_x = old_x
pixel_y = old_y
return

if(disabilities & NERVOUS)
speech_problem_flag = TRUE
if(prob(10))
stuttering = max(10, stuttering)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@
else
clear_fullscreen("blind")

if(dazed)
overlay_fullscreen("eye_blurry", /atom/movable/screen/fullscreen/impaired, 5)
else
clear_fullscreen("eye_blurry")
///Pain should override the SetEyeBlur(0) should the pain be painful enough to cause eyeblur in the first place. Also, peepers is essential to make sure eye damage isn't overriden.
var/datum/internal_organ/eyes/peepers = internal_organs_by_name["eyes"]
if((disabilities & NEARSIGHTED) && !HAS_TRAIT(src, TRAIT_NEARSIGHTED_EQUIPMENT) && pain.current_pain < 80 && peepers.organ_status == ORGAN_HEALTHY)
Expand Down Expand Up @@ -163,6 +159,12 @@
interactee.check_eye(src)
return TRUE

/mob/living/carbon/human/on_dazed_trait_gain(datum/source)
. = ..()
overlay_fullscreen("eye_blurry", /atom/movable/screen/fullscreen/impaired, 5)
/mob/living/carbon/human/on_dazed_trait_loss(datum/source)
. = ..()
clear_fullscreen("eye_blurry")

/mob/living/carbon/human/proc/check_status_effects()
var/status_effect_placement = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
if(regular_update && halloss > 0)
apply_damage(-3, HALLOSS)
else if(sleeping)
speech_problem_flag = TRUE
if(regular_update)
handle_dreams()
apply_damage(-3, HALLOSS)
Expand Down Expand Up @@ -100,13 +99,14 @@

AdjustEarDeafness(-1)

if(!ear_deaf && client && client.soundOutput)
client.soundOutput.status_flags ^= EAR_DEAF_MUTE
client.soundOutput.apply_status()

else if(ear_damage)
ear_damage = max(ear_damage - 0.05, 0)

// This should be done only on updates abvoe, or even better in the AdjsutEarDeafnes handlers
if(!ear_deaf && (client?.soundOutput?.status_flags & EAR_DEAF_MUTE))
client.soundOutput.status_flags ^= EAR_DEAF_MUTE
client.soundOutput.apply_status()

//Resting
if(resting)
dizziness = max(0, dizziness - 15)
Expand All @@ -121,7 +121,6 @@
handle_statuses()

if(paralyzed)
speech_problem_flag = TRUE
apply_effect(1, WEAKEN)
silent = 1
blinded = TRUE
Expand Down
32 changes: 7 additions & 25 deletions code/modules/mob/living/carbon/human/life/life_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -187,31 +187,6 @@
if(G.lighting_alpha < lighting_alpha)
lighting_alpha = G.lighting_alpha

/mob/living/carbon/human/handle_silent()
if(..())
speech_problem_flag = TRUE
return silent

/mob/living/carbon/human/handle_slurring()
if(..())
speech_problem_flag = TRUE
return slurring

/mob/living/carbon/human/handle_dazed()
if(dazed)
var/skill_resistance = skills ? (skills.get_skill_level(SKILL_ENDURANCE)-1)*0.1 : 0

var/final_reduction = skill_resistance + 1
adjust_effect(-final_reduction, DAZE, EFFECT_FLAG_LIFE)
if(dazed)
speech_problem_flag = TRUE
return dazed

/mob/living/carbon/human/handle_stuttering()
if(..())
speech_problem_flag = TRUE
return stuttering

#define HUMAN_TIMER_TO_EFFECT_CONVERSION (0.05) //(1/20) //once per 2 seconds, with effect equal to endurance, which is used later

/mob/living/carbon/human/GetStunDuration(amount)
Expand All @@ -232,6 +207,13 @@
var/final_reduction = (1 - skill_resistance) / species.knock_out_reduction
return . * final_reduction

/mob/living/carbon/human/GetDazeDuration(amount)
. = ..()
var/skill_resistance = skills ? (skills.get_skill_level(SKILL_ENDURANCE)-1)*0.08 : 0
var/final_reduction = (1 - skill_resistance)
return . * final_reduction


/mob/living/carbon/human/proc/handle_revive()
SEND_SIGNAL(src, COMSIG_HUMAN_REVIVED)
track_revive(job)
Expand Down
33 changes: 6 additions & 27 deletions code/modules/mob/living/carbon/human/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,9 @@
message = capitalize(trim(message))
message = process_chat_markup(message, list("~", "_"))

if(speech_problem_flag)
var/list/handle_r = handle_speech_problems(message)
message = handle_r[1]
verb = handle_r[2]
speech_problem_flag = handle_r[3]

var/list/handle_r = handle_speech_problems(message)
message = handle_r[1]
verb = handle_r[2]
if(!message)
return

Expand Down Expand Up @@ -260,57 +257,39 @@ for it but just ignore it.
return verb

/mob/living/carbon/human/proc/handle_speech_problems(message)
var/list/returns[3]
var/list/returns[2]
var/verb = "says"
var/handled = FALSE
if(silent)
message = ""
handled = TRUE
if(sdisabilities & DISABILITY_MUTE)
message = ""
handled = TRUE
if(wear_mask)
if(istype(wear_mask, /obj/item/clothing/mask/horsehead))
var/obj/item/clothing/mask/horsehead/hoers = wear_mask
if(hoers.voicechange)
message = pick("NEEIIGGGHHHH!", "NEEEIIIIGHH!", "NEIIIGGHH!", "HAAWWWWW!", "HAAAWWW!")
verb = pick("whinnies","neighs", "says")
handled = TRUE

var/braindam = getBrainLoss()
if(slurring || stuttering || dazed || braindam >= 60)
if(slurring || stuttering || HAS_TRAIT(src, TRAIT_DAZED) || braindam >= 60)
msg_admin_niche("[key_name(src)] stuttered while saying: \"[message]\"") //Messages that get modified by the 4 reasons below have their original message logged too
if(slurring)
message = slur(message)
verb = pick("stammers","stutters")
handled = TRUE
if(stuttering)
message = NewStutter(message)
verb = pick("stammers", "stutters")
handled = TRUE
if(dazed)
if(HAS_TRAIT(src, TRAIT_DAZED))
message = DazedText(message)
verb = pick("mumbles", "babbles")
handled = TRUE
if(braindam >= 60)
handled = TRUE
if(prob(braindam/4))
message = stutter(message, stuttering)
verb = pick("stammers", "stutters")
if(prob(braindam))
message = uppertext(message)
verb = pick("yells like an idiot","says rather loudly")
if(HAS_TRAIT(src, TRAIT_LISPING))
handled = TRUE
var/old_message = message
message = lisp_replace(message)
if(old_message != message)
verb = "lisps"

returns[1] = message
returns[2] = verb
returns[3] = handled

return returns

/mob/living/carbon/human/hear_apollo()
Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/living/carbon/xenomorph/Xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
var/pounce_distance = 0

// Life reduction variables.
var/life_daze_reduction = -1.5
var/life_slow_reduction = -1.5

//////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit d434c1d

Please sign in to comment.