From 69c2e7f56e8238d17164f749538c8b0e1241dbc1 Mon Sep 17 00:00:00 2001 From: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:19:51 -0400 Subject: [PATCH] Mobility Atomization 2: Incapacitation (#9491) * https://github.com/tgstation/tgstation/pull/50321 * https://github.com/tgstation/tgstation/pull/50327 * cleanup * add trait to the globalvars --- code/__DEFINES/traits.dm | 1 + code/_globalvars/traits.dm | 1 + code/datums/status_effects/debuffs.dm | 33 +++++++++++++++++++ code/modules/mob/living/carbon/carbon.dm | 1 + .../modules/mob/living/carbon/status_procs.dm | 1 + code/modules/mob/living/living.dm | 4 +-- code/modules/mob/living/silicon/ai/ai.dm | 2 +- code/modules/mob/living/silicon/robot/life.dm | 2 +- .../multiz/movement/mob/living_zmove.dm | 2 +- 9 files changed, 42 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index b111697722392..8d95472b67dc9 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -127,6 +127,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai */ //mob traits +#define TRAIT_INCAPACITATED "incapacitated" #define TRAIT_BLIND "blind" #define TRAIT_MUTE "mute" #define TRAIT_EMOTEMUTE "emotemute" diff --git a/code/_globalvars/traits.dm b/code/_globalvars/traits.dm index 86dc9ed4e2faa..1750d493b005f 100644 --- a/code/_globalvars/traits.dm +++ b/code/_globalvars/traits.dm @@ -5,6 +5,7 @@ */ GLOBAL_LIST_INIT(traits_by_type, list( /mob = list( + "TRAIT_INCAPACITATED" = TRAIT_INCAPACITATED, "TRAIT_BLIND" = TRAIT_BLIND, "TRAIT_MUTE" = TRAIT_MUTE, "TRAIT_EMOTEMUTE " = TRAIT_EMOTEMUTE, diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm index 1ab609d74d774..439c306a8b545 100644 --- a/code/datums/status_effects/debuffs.dm +++ b/code/datums/status_effects/debuffs.dm @@ -1,3 +1,5 @@ +#define TRAIT_STATUS_EFFECT(effect_id) "[effect_id]-trait" + //Largely negative status effects go here, even if they have small benificial effects //STUN EFFECTS /datum/status_effect/incapacitating @@ -20,11 +22,22 @@ owner.update_mobility() if(needs_update_stat || issilicon(owner)) //silicons need stat updates in addition to normal canmove updates owner.update_stat() + return ..() //STUN /datum/status_effect/incapacitating/stun id = "stun" +/datum/status_effect/incapacitating/stun/on_apply() + . = ..() + if(!.) + return + ADD_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) + +/datum/status_effect/incapacitating/stun/on_remove() + REMOVE_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) + return ..() + //KNOCKDOWN /datum/status_effect/incapacitating/knockdown id = "knockdown" @@ -36,11 +49,31 @@ /datum/status_effect/incapacitating/paralyzed id = "paralyzed" +/datum/status_effect/incapacitating/paralyzed/on_apply() + . = ..() + if(!.) + return + ADD_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) + +/datum/status_effect/incapacitating/paralyzed/on_remove() + REMOVE_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) + return ..() + //UNCONSCIOUS /datum/status_effect/incapacitating/unconscious id = "unconscious" needs_update_stat = TRUE +/datum/status_effect/incapacitating/unconscious/on_apply() + . = ..() + if(!.) + return + ADD_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) + +/datum/status_effect/incapacitating/unconscious/on_remove() + REMOVE_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) + return ..() + /datum/status_effect/incapacitating/unconscious/tick() if(owner.getStaminaLoss()) owner.adjustStaminaLoss(-0.3) //reduce stamina loss by 0.3 per tick, 6 per 2 seconds diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index d25419a528450..a32f71af12a83 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -516,6 +516,7 @@ enter_stamcrit() else if(stam_paralyzed) stam_paralyzed = FALSE + REMOVE_TRAIT(src,TRAIT_INCAPACITATED, STAMINA) else return update_health_hud() diff --git a/code/modules/mob/living/carbon/status_procs.dm b/code/modules/mob/living/carbon/status_procs.dm index ce4a140224939..ed6f9e48d3f4f 100644 --- a/code/modules/mob/living/carbon/status_procs.dm +++ b/code/modules/mob/living/carbon/status_procs.dm @@ -15,6 +15,7 @@ to_chat(src, "You're too exhausted to keep going.") stam_regen_start_time = world.time + STAMINA_CRIT_TIME stam_paralyzed = TRUE + ADD_TRAIT(src, TRAIT_INCAPACITATED, STAMINA) update_mobility() /mob/living/carbon/adjust_drugginess(amount) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index b2baada142ecc..b72241b6f83cc 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -418,8 +418,8 @@ death() -/mob/living/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE, check_immobilized = FALSE, ignore_stasis = FALSE) - if(stat || IsUnconscious() || IsStun() || IsParalyzed() || (check_immobilized && IsImmobilized()) || (!ignore_restraints && restrained(ignore_grab)) || (!ignore_stasis && IsInStasis())) +/mob/living/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE, ignore_stasis = FALSE) + if(stat || HAS_TRAIT(src, TRAIT_INCAPACITATED) || (!ignore_restraints && restrained(ignore_grab)) || (!ignore_stasis && IsInStasis())) return TRUE /mob/living/canUseStorage() diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 7e08da0fec8dd..34edee756f176 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -850,7 +850,7 @@ /mob/living/silicon/ai/can_buckle() return 0 -/mob/living/silicon/ai/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE, check_immobilized = FALSE, ignore_stasis = FALSE) +/mob/living/silicon/ai/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE, ignore_stasis = FALSE) if(aiRestorePowerRoutine) return TRUE return ..() diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index 4753a41437616..c0b9560139a22 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -99,7 +99,7 @@ cut_overlay(fire_overlay) /mob/living/silicon/robot/update_mobility() - if(stat || buckled || lockcharge || incapacitated(check_immobilized = TRUE)) + if(stat || buckled || lockcharge || incapacitated()) mobility_flags &= ~MOBILITY_MOVE else mobility_flags = MOBILITY_FLAGS_DEFAULT diff --git a/code/modules/multiz/movement/mob/living_zmove.dm b/code/modules/multiz/movement/mob/living_zmove.dm index 9602e97d3c637..4c8ddb00b9809 100644 --- a/code/modules/multiz/movement/mob/living_zmove.dm +++ b/code/modules/multiz/movement/mob/living_zmove.dm @@ -12,7 +12,7 @@ /// Returns a movement type that is allowed, given a source and target turf. /// pre_move controls if things like fuel are consumed for jetpacks. /mob/living/canZMove(dir, turf/source, turf/target, pre_move = TRUE) - if(incapacitated(check_immobilized = TRUE) || resting || zmoving || IsKnockdown()) + if(incapacitated() || resting || zmoving || IsKnockdown()) return MOVETYPE_NONE if(incorporeal_move || (movement_type & PHASING)) return MOVETYPE_JAUNT