Skip to content

Commit

Permalink
Mobility Atomization 2: Incapacitation (#9491)
Browse files Browse the repository at this point in the history
* tgstation/tgstation#50321

* tgstation/tgstation#50327

* cleanup

* add trait to the globalvars
  • Loading branch information
Tsar-Salat authored Jul 31, 2023
1 parent ad25a6c commit 69c2e7f
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
33 changes: 33 additions & 0 deletions code/datums/status_effects/debuffs.dm
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
enter_stamcrit()
else if(stam_paralyzed)
stam_paralyzed = FALSE
REMOVE_TRAIT(src,TRAIT_INCAPACITATED, STAMINA)
else
return
update_health_hud()
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/status_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
to_chat(src, "<span class='notice'>You're too exhausted to keep going.</span>")
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)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/ai/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/robot/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/modules/multiz/movement/mob/living_zmove.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69c2e7f

Please sign in to comment.