Skip to content

Commit

Permalink
status_procs.dm cleaning. (#864)
Browse files Browse the repository at this point in the history
* Update mobs.dm

* Update _ammo_datums.dm

* begone 1000 line file

* delete useless is*status-ed* procs

* Update tgmc.dme
  • Loading branch information
Helg2 authored Dec 23, 2024
1 parent ec74869 commit 3fd2c38
Show file tree
Hide file tree
Showing 56 changed files with 984 additions and 1,045 deletions.
3 changes: 1 addition & 2 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ GLOBAL_LIST_INIT(xenoupgradetiers, list(XENO_UPGRADE_BASETYPE, XENO_UPGRADE_INVA
#define HIVE_CAN_HIJACK (1<<0)

#define XENO_PULL_CHARGE_TIME 2 SECONDS
#define XENO_SLOWDOWN_REGEN 0.4

#define XENO_DEADHUMAN_DRAG_SLOWDOWN 2

Expand Down Expand Up @@ -744,8 +743,8 @@ GLOBAL_LIST_INIT(xenoupgradetiers, list(XENO_UPGRADE_BASETYPE, XENO_UPGRADE_INVA
#define TIME_TO_DISSOLVE 5 SECONDS

//misc

#define STANDARD_SLOWDOWN_REGEN 0.3
#define XENO_SLOWDOWN_REGEN 0.4

#define HYPERVENE_REMOVAL_AMOUNT 8

Expand Down
2 changes: 1 addition & 1 deletion code/datums/actions/ability_actions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
carbon_owner.balloon_alert(carbon_owner, "Cannot while buckled")
return FALSE

if(!(flags_to_check & ABILITY_USE_STAGGERED) && carbon_owner.IsStaggered())
if(!(flags_to_check & ABILITY_USE_STAGGERED) && carbon_owner.has_status_effect(STATUS_EFFECT_STAGGER))
if(!silent)
carbon_owner.balloon_alert(carbon_owner, "Cannot while staggered")
return FALSE
Expand Down
6 changes: 3 additions & 3 deletions code/datums/components/shield.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@
if(parent_item.obj_integrity <= parent_item.integrity_failure)
return incoming_damage

if(affected.IsSleeping() || affected.IsUnconscious() || affected.IsAdminSleeping()) //We don't do jack if we're literally KOed/sleeping/paralyzed.
if(affected.has_status_effect(STATUS_EFFECT_SLEEPING) || affected.has_status_effect(STATUS_EFFECT_UNCONSCIOUS) || affected.IsAdminSleeping()) //We don't do jack if we're literally KOed/sleeping/paralyzed.
return incoming_damage

if(affected.IsStun() || affected.IsKnockdown() || affected.IsParalyzed()) //Halve shield cover if we're paralyzed or stunned
if(affected.has_status_effect(STATUS_EFFECT_STUN) || affected.has_status_effect(STATUS_EFFECT_KNOCKDOWN) || affected.has_status_effect(STATUS_EFFECT_PARALYZED)) //Halve shield cover if we're paralyzed or stunned
status_cover_modifier *= 0.5

if(iscarbon(affected))
var/mob/living/carbon/C = affected
if(C.IsStaggered()) //Lesser penalty to shield cover for being staggered.
if(C.has_status_effect(STATUS_EFFECT_STAGGER)) //Lesser penalty to shield cover for being staggered.
status_cover_modifier *= 0.75

switch(attack_type)
Expand Down
6 changes: 3 additions & 3 deletions code/datums/components/stun_mitigation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@
if(parent_item.obj_integrity <= parent_item.integrity_failure)
return FALSE

if(affected.IsSleeping() || affected.IsUnconscious() || affected.IsAdminSleeping())
if(affected.has_status_effect(STATUS_EFFECT_SLEEPING) || affected.has_status_effect(STATUS_EFFECT_UNCONSCIOUS) || affected.IsAdminSleeping())
return FALSE

if(affected.IsStun() || affected.IsKnockdown() || affected.IsParalyzed())
if(affected.has_status_effect(STATUS_EFFECT_STUN) || affected.has_status_effect(STATUS_EFFECT_KNOCKDOWN) || affected.has_status_effect(STATUS_EFFECT_PARALYZED))
mitigation_prob *= 0.5

if(iscarbon(affected))
var/mob/living/carbon/C = affected
if(C.IsStaggered())
if(C.has_status_effect(STATUS_EFFECT_STAGGER))
mitigation_prob *= 0.4

if(!prob(mitigation_prob))
Expand Down
36 changes: 21 additions & 15 deletions code/datums/status_effects/status_effect.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,17 @@
var/datum/status_effect/S1 = effect
LAZYINITLIST(status_effects)
for(var/datum/status_effect/S in status_effects)
if(S.id == initial(S1.id) && S.status_type)
if(S.status_type == STATUS_EFFECT_REPLACE)
qdel(S)
else if(S.status_type == STATUS_EFFECT_REFRESH)
S.refresh()
return
else
return
if(S.id != initial(S1.id))
continue
if(!S.status_type)
continue
if(S.status_type == STATUS_EFFECT_REPLACE)
qdel(S)
else if(S.status_type == STATUS_EFFECT_REFRESH)
S.refresh()
return
else
return
var/list/arguments = args.Copy()
arguments[1] = src
S1 = new effect(arguments)
Expand All @@ -125,25 +128,28 @@
if(status_effects)
var/datum/status_effect/S1 = effect
for(var/datum/status_effect/S in status_effects)
if(initial(S1.id) == S.id)
qdel(S)
. = TRUE
if(initial(S1.id) != S.id)
continue
qdel(S)
. = TRUE

/mob/living/proc/has_status_effect(effect) //returns the effect if the mob calling the proc owns the given status effect
. = FALSE
if(status_effects)
var/datum/status_effect/S1 = effect
for(var/datum/status_effect/S in status_effects)
if(initial(S1.id) == S.id)
return S
if(initial(S1.id) != S.id)
continue
return S

/mob/living/proc/has_status_effect_list(effect) //returns a list of effects with matching IDs that the mod owns; use for effects there can be multiple of
. = list()
if(status_effects)
var/datum/status_effect/S1 = effect
for(var/datum/status_effect/S in status_effects)
if(initial(S1.id) == S.id)
. += S
if(initial(S1.id) != S.id)
continue
. += S

/mob/living/proc/remove_all_status_effect()
. = 0
Expand Down
18 changes: 9 additions & 9 deletions code/game/data_huds/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if(!client) //Nobody home.
status_hud.icon_state = "afk"
return TRUE
if(IsUnconscious()) //Should hopefully get out of it soon.
if(has_status_effect(STATUS_EFFECT_UNCONSCIOUS)) //Should hopefully get out of it soon.
status_hud.icon_state = "knockout"
return TRUE
status_hud.icon_state = "sleep" //Regular sleep, else.
Expand All @@ -101,13 +101,13 @@
if(!key) //Nobody home. Shouldn't affect aghosting.
status_hud.icon_state = "afk"
return TRUE
if(IsParalyzed()) //I've fallen and I can't get up.
if(has_status_effect(STATUS_EFFECT_PARALYZED)) //I've fallen and I can't get up.
status_hud.icon_state = "knockdown"
return TRUE
if(IsStun())
if(has_status_effect(STATUS_EFFECT_STUN))
status_hud.icon_state = "stun"
return TRUE
if(IsStaggered())
if(has_status_effect(STATUS_EFFECT_STAGGER))
return TRUE
if(slowdown)
status_hud.icon_state = "slowdown"
Expand Down Expand Up @@ -170,7 +170,7 @@
if(!client) //Nobody home.
simple_status_hud.icon_state = "afk"
return TRUE
if(IsUnconscious()) //Should hopefully get out of it soon.
if(has_status_effect(STATUS_EFFECT_UNCONSCIOUS)) //Should hopefully get out of it soon.
simple_status_hud.icon_state = "knockout"
return TRUE
simple_status_hud.icon_state = "sleep"
Expand All @@ -179,13 +179,13 @@
if(!key) //Nobody home. Shouldn't affect aghosting.
simple_status_hud.icon_state = "afk"
return TRUE
if(IsParalyzed()) //I've fallen and I can't get up.
if(has_status_effect(STATUS_EFFECT_PARALYZED)) //I've fallen and I can't get up.
simple_status_hud.icon_state = "knockdown"
return TRUE
if(IsStun())
if(has_status_effect(STATUS_EFFECT_STUN))
simple_status_hud.icon_state = "stun"
return TRUE
if(IsStaggered())
if(has_status_effect(STATUS_EFFECT_STAGGER))
simple_status_hud.icon_state = "stagger"
return TRUE
if(slowdown)
Expand Down Expand Up @@ -287,7 +287,7 @@
xeno_debuff.overlays.Cut()
xeno_debuff.icon_state = ""

if(stat != DEAD && IsMute())
if(stat != DEAD && has_status_effect(STATUS_EFFECT_MUTED))
xeno_debuff.overlays += hunter_silence_image

if(HAS_TRAIT(src, TRAIT_HIVE_TARGET))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/twohanded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@
else
stun = knockback ? knockback_stun_amount : crush_stun_amount

if(!M.IsStun() && !M.IsParalyzed() && !isxenoqueen(M) && !isxenoking(M)) //Prevent chain stunning. Queen and King are protected.
if(!M.has_status_effect(STATUS_EFFECT_STUN) && !M.has_status_effect(STATUS_EFFECT_PARALYZED) && !isxenoqueen(M) && !isxenoking(M)) //Prevent chain stunning. Queen and King are protected.
M.apply_effects(stun,weaken)

return ..()
2 changes: 1 addition & 1 deletion code/game/objects/machinery/overwatch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ GLOBAL_LIST_EMPTY(active_cas_targets)
to_chat(src, span_warning("You cannot give an order in your current state."))
return

if(IsMute())
if(has_status_effect(STATUS_EFFECT_MUTED))
to_chat(src, span_warning("You cannot give an order while muted."))
return

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/crates_lockers/closets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@

/mob/living/proc/on_closet_dump(obj/structure/closet/origin)
SetStun(origin.closet_stun_delay)//Action delay when going out of a closet
if(!lying_angle && IsStun())
if(!lying_angle && has_status_effect(STATUS_EFFECT_STUN))
balloon_alert_to_viewers("Gets out of [origin]", ignored_mobs = src)
balloon_alert(src, "You struggle to get your bearings")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
else
visible_message(span_notice("[usr] climbs into [src]."), 3)
M.forceMove(src)
if(M.health > -100 && (M.health < 0 || M.IsSleeping()))
if(M.health > -100 && (M.health < 0 || M.has_status_effect(STATUS_EFFECT_SLEEPING)))
to_chat(M, span_boldnotice("You feel a cold liquid surround you. Your skin starts to freeze up."))
occupant = M
occupant.time_entered_cryo = world.time
Expand Down
2 changes: 1 addition & 1 deletion code/modules/flufftext/Dreaming.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GLOBAL_LIST_INIT(dream_topics, list(
/mob/living/carbon/proc/dream()
if(!dream_amounts)
dream_amounts = rand(1,5)
if(!IsUnconscious())
if(!has_status_effect(STATUS_EFFECT_UNCONSCIOUS))
dream_amounts = 0
return FALSE
to_chat(src, span_notice("<i>... [pick(GLOB.dream_topics)] ...</i>"))
Expand Down
8 changes: 4 additions & 4 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@
to_chat(shaker, span_highdanger("This player has been admin slept, do not interfere with them."))
return

if(lying_angle || IsSleeping())
if(lying_angle || has_status_effect(STATUS_EFFECT_SLEEPING))
if(client)
AdjustSleeping(-10 SECONDS)
if(!IsSleeping())
if(!has_status_effect(STATUS_EFFECT_SLEEPING))
set_resting(FALSE)
shaker.visible_message(span_notice("[shaker] shakes [src] trying to get [p_them()] up!"),
span_notice("You shake [src] trying to get [p_them()] up!"), null, 4)

AdjustUnconscious(-6 SECONDS)
AdjustStun(-6 SECONDS)
if(IsParalyzed())
if(has_status_effect(STATUS_EFFECT_PARALYZED))
if(staminaloss)
adjustStaminaLoss(-20, FALSE)
AdjustParalyzed(-6 SECONDS)
Expand Down Expand Up @@ -234,7 +234,7 @@
if(species.species_flags & ROBOTIC_LIMBS)
to_chat(src, span_warning("Your artificial body does not require sleep."))
return
if(IsSleeping())
if(has_status_effect(STATUS_EFFECT_SLEEPING))
to_chat(src, span_warning("You are already sleeping"))
return
if(tgui_alert(src, "You sure you want to sleep for a while?", "Sleep", list("Yes","No")) == "Yes")
Expand Down
6 changes: 6 additions & 0 deletions code/modules/mob/living/carbon/carbon_status_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@
if(old_nutrition > NUTRITION_OVERFED)
return
add_movespeed_modifier(MOVESPEED_ID_HUNGRY, TRUE, 0, NONE, TRUE, 0.5)

/mob/living/carbon/dizzy(amount)
dizziness = clamp(dizziness + amount, 0, 1000)

if(dizziness > 100 && !is_dizzy)
INVOKE_ASYNC(src, PROC_REF(dizzy_process))
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
if(staminaloss > -max_stamina)
handle_staminaloss()

if(IsSleeping())
if(has_status_effect(STATUS_EFFECT_SLEEPING))
handle_dreams()
if(mind)
if((mind.active && client != null) || immune_to_ssd) //This also checks whether a client is connected, if not, sleep is not reduced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ GLOBAL_LIST_INIT(boiler_glob_image_list, list(
gas = new /datum/effect_system/smoke_spread/xeno/acid/light

owner.add_movespeed_modifier(MOVESPEED_ID_BOILER_DUMP, TRUE, 0, NONE, TRUE, BOILER_DUMP_SPEED)
if(caster.IsStun() || caster.IsParalyzed())
if(caster.has_status_effect(STATUS_EFFECT_STUN) || caster.has_status_effect(STATUS_EFFECT_PARALYZED))
to_chat(caster, span_xenohighdanger("We try to emit acid but are disabled!"))
owner.remove_movespeed_modifier(MOVESPEED_ID_BOILER_DUMP)
toggle_particles(FALSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
if(stat == DEAD)
hugger_overlays_icon.overlays += mutable_appearance(effects_icon, "clinger_[i] Knocked Down")
else if(lying_angle)
if((resting || IsSleeping()) && (!IsParalyzed() && !IsUnconscious() && health > 0))
if((resting || has_status_effect(STATUS_EFFECT_SLEEPING)) && (!has_status_effect(STATUS_EFFECT_PARALYZED) && !has_status_effect(STATUS_EFFECT_UNCONSCIOUS) && health > 0))
hugger_overlays_icon.overlays += mutable_appearance(effects_icon, "clinger_[i] Sleeping")
else
hugger_overlays_icon.overlays += mutable_appearance(effects_icon, "clinger_[i] Knocked Down")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
add_cooldown()
succeed_activate()

if(X.IsStaggered()) //If we got staggered, return
if(X.has_status_effect(STATUS_EFFECT_STAGGER)) //If we got staggered, return
to_chat(X, span_xenowarning("We try to emit toxins but are staggered!"))
return fail_activate()

Expand Down Expand Up @@ -237,11 +237,11 @@
if(/datum/reagent/toxin/acid)
emitted_gas = new /datum/effect_system/smoke_spread/xeno/acid/light(defiler_owner)

if(defiler_owner.IsStaggered()) //If we got staggered, return
if(defiler_owner.has_status_effect(STATUS_EFFECT_STAGGER)) //If we got staggered, return
to_chat(defiler_owner, span_xenowarning("We try to emit toxins but are staggered!"))
toggle_particles(FALSE)
return
if(defiler_owner.IsStun() || defiler_owner.IsParalyzed())
if(defiler_owner.has_status_effect(STATUS_EFFECT_STUN) || defiler_owner.has_status_effect(STATUS_EFFECT_PARALYZED))
to_chat(defiler_owner, span_xenowarning("We try to emit toxins but are disabled!"))
toggle_particles(FALSE)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
icon_state = "[bloody][base_icon_state] Cuff"

else if(lying_angle)
if((resting || IsSleeping()) && (!IsParalyzed() && !IsUnconscious() && health > 0))
if((resting || has_status_effect(STATUS_EFFECT_SLEEPING)) && (!has_status_effect(STATUS_EFFECT_PARALYZED) && !has_status_effect(STATUS_EFFECT_UNCONSCIOUS) && health > 0))
icon_state = "[bloody][base_icon_state] Sleeping"
else
icon_state = "[bloody][base_icon_state] Stunned"
Expand Down Expand Up @@ -195,7 +195,7 @@
icon_state = "[base_icon_state] Cuff"

else if(lying_angle)
if((resting || IsSleeping()) && (!IsParalyzed() && !IsUnconscious() && health > 0))
if((resting || has_status_effect(STATUS_EFFECT_SLEEPING)) && (!has_status_effect(STATUS_EFFECT_PARALYZED) && !has_status_effect(STATUS_EFFECT_UNCONSCIOUS) && health > 0))
icon_state = "[base_icon_state] Sleeping"
else
icon_state = "[base_icon_state] Stunned"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/embryo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
affected_mob.emote("[pick("sneeze", "cough")]")
if(4)
if(prob(1))
if(!affected_mob.IsUnconscious())
if(!affected_mob.has_status_effect(STATUS_EFFECT_UNCONSCIOUS))
affected_mob.visible_message(span_danger("\The [affected_mob] starts shaking uncontrollably!"), \
span_danger("You start shaking uncontrollably!"))
affected_mob.Unconscious(20 SECONDS)
Expand Down
6 changes: 3 additions & 3 deletions code/modules/mob/living/carbon/xenomorph/update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
else if(HAS_TRAIT(src, TRAIT_BURROWED))
icon_state = "[xeno_caste.caste_name] Burrowed"
else if(lying_angle)
if((resting || IsSleeping()) && (!IsParalyzed() && !IsUnconscious() && health > 0))
if((resting || has_status_effect(STATUS_EFFECT_SLEEPING)) && (!has_status_effect(STATUS_EFFECT_PARALYZED) && !has_status_effect(STATUS_EFFECT_UNCONSCIOUS) && health > 0))
icon_state = "[xeno_caste.caste_name] Sleeping"
else
icon_state = "[xeno_caste.caste_name] Knocked Down"
Expand Down Expand Up @@ -119,7 +119,7 @@
health_thresholds = 3
var/overlay_to_show
if(lying_angle)
if((resting || IsSleeping()) && (!IsParalyzed() && !IsUnconscious() && health > 0))
if((resting || has_status_effect(STATUS_EFFECT_SLEEPING)) && (!has_status_effect(STATUS_EFFECT_PARALYZED) && !has_status_effect(STATUS_EFFECT_UNCONSCIOUS) && health > 0))
overlay_to_show = "wounded_resting_[health_thresholds]"
else
overlay_to_show = "wounded_stunned_[health_thresholds]"
Expand Down Expand Up @@ -183,7 +183,7 @@
icon_state = ""
return
layer = layer + 0.4
if((!owner.lying_angle && !owner.resting && !owner.IsSleeping()))
if((!owner.lying_angle && !owner.resting && !owner.has_status_effect(STATUS_EFFECT_SLEEPING)))
icon_state = "alien_fire"
else
icon_state = "alien_fire_lying"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/xenoprocs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@
playsound(C, SFX_ALIEN_DROOL, 15, TRUE)
do
face_atom(C)
if(IsStaggered())
if(has_status_effect(STATUS_EFFECT_STAGGER))
return FALSE
do_attack_animation(C)
C.reagents.add_reagent(toxin, transfer_amount)
Expand Down
Loading

0 comments on commit 3fd2c38

Please sign in to comment.