immobilized (#52578)

Adds an immobilized trait.
    Adds procs for several variable changes so we can respond to their events.
    Adds some signals for said variables changing.

Need to turn the variation in number of usable legs and arms (get_num_legs() and get_num_arms()) into events we can respond to, but they are pretty annoying to do so. Probably for a different PR.
This commit is contained in:
Rohesie
2020-08-10 23:44:01 -03:00
committed by GitHub
parent 3f35d5edf6
commit 8f917ff1d9
14 changed files with 160 additions and 27 deletions
+2 -1
View File
@@ -79,7 +79,8 @@ GLOBAL_LIST_EMPTY(total_extraction_beacons)
if(isliving(A))
var/mob/living/M = A
M.Paralyze(320) // Keep them from moving during the duration of the extraction
M.buckled = 0 // Unbuckle them to prevent anchoring problems
if(M.buckled)
M.buckled.unbuckle_mob(M, TRUE) // Unbuckle them to prevent anchoring problems
else
A.set_anchored(TRUE)
A.density = FALSE
+52 -4
View File
@@ -267,7 +267,7 @@
AM.pulledby.stop_pulling() //an object can't be pulled by two mobs at once.
pulling = AM
AM.pulledby = src
AM.set_pulledby(src)
SEND_SIGNAL(src, COMSIG_LIVING_START_PULL, AM, state, force)
@@ -451,19 +451,26 @@
else
to_chat(src, "<span class='warning'>You fail to get up!</span>")
///Proc to hook behavior to the change of value in the resting variable.
/mob/living/proc/set_resting(rest, silent = TRUE)
if(rest == resting)
return
if(!silent)
if(rest)
to_chat(src, "<span class='notice'>You are now resting.</span>")
else
to_chat(src, "<span class='notice'>You get up.</span>")
. = rest
resting = rest
update_resting()
/mob/living/proc/update_resting()
update_rest_hud_icon()
update_mobility()
//Recursive function to find everything a mob is holding. Really shitty proc tbh.
/mob/living/get_contents()
var/list/ret = list()
@@ -1197,10 +1204,9 @@
var/has_legs = get_num_legs()
var/has_arms = get_num_arms()
var/paralyzed = IsParalyzed()
var/stun = IsStun()
var/knockdown = IsKnockdown()
var/ignore_legs = get_leg_ignore()
var/canmove = !IsImmobilized() && !stun && stat_conscious && !paralyzed && !buckled && (!stat_softcrit || !pulledby) && !chokehold && !IsFrozen() && !IS_IN_STASIS(src) && (has_arms || ignore_legs || has_legs)
var/canmove = !HAS_TRAIT(src, TRAIT_IMMOBILIZED) && (has_arms || ignore_legs || has_legs)
if(canmove)
mobility_flags |= MOBILITY_MOVE
else
@@ -1231,7 +1237,7 @@
var/canitem = !paralyzed && !stun && stat_conscious && !chokehold && !restrained && has_arms
var/canitem = !paralyzed && !IsStun() && stat_conscious && !chokehold && !restrained && has_arms
if(canitem)
mobility_flags |= (MOBILITY_USE | MOBILITY_PICKUP | MOBILITY_STORAGE)
else
@@ -1627,12 +1633,54 @@
if(isnull(.))
return
switch(.) //Previous stat.
if(CONSCIOUS)
if(stat >= UNCONSCIOUS)
ADD_TRAIT(src, TRAIT_IMMOBILIZED, TRAIT_KNOCKEDOUT)
if(SOFT_CRIT)
if(stat >= UNCONSCIOUS)
ADD_TRAIT(src, TRAIT_IMMOBILIZED, TRAIT_KNOCKEDOUT) //adding trait sources should come before removing to avoid unnecessary updates
if(pulledby)
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, PULLED_WHILE_SOFTCRIT_TRAIT)
if(UNCONSCIOUS)
cure_blind(UNCONSCIOUS_BLIND)
switch(stat) //Current stat.
if(CONSCIOUS)
if(. >= UNCONSCIOUS)
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, TRAIT_KNOCKEDOUT)
if(SOFT_CRIT)
if(pulledby)
ADD_TRAIT(src, TRAIT_IMMOBILIZED, PULLED_WHILE_SOFTCRIT_TRAIT) //adding trait sources should come before removing to avoid unnecessary updates
if(. >= UNCONSCIOUS)
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, TRAIT_KNOCKEDOUT)
if(UNCONSCIOUS)
become_blind(UNCONSCIOUS_BLIND)
///Reports the event of the change in value of the buckled variable.
/mob/living/proc/set_buckled(new_buckled)
if(new_buckled == buckled)
return
SEND_SIGNAL(src, COMSIG_LIVING_SET_BUCKLED, new_buckled)
. = buckled
buckled = new_buckled
if(buckled)
if(!.)
ADD_TRAIT(src, TRAIT_IMMOBILIZED, BUCKLED_TRAIT)
else if(.)
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, BUCKLED_TRAIT)
/mob/living/set_pulledby(new_pulledby)
. = ..()
if(. == FALSE) //null is a valid value here, we only want to return if FALSE is explicitly passed.
return
if(pulledby)
if(!. && stat == SOFT_CRIT)
ADD_TRAIT(src, TRAIT_IMMOBILIZED, PULLED_WHILE_SOFTCRIT_TRAIT)
else if(. && stat == SOFT_CRIT)
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, PULLED_WHILE_SOFTCRIT_TRAIT)
/// Only defined for carbons who can wear masks and helmets, we just assume other mobs have visible faces
/mob/living/proc/is_face_visible()
return TRUE
@@ -93,7 +93,7 @@
cut_overlay(fire_overlay)
/mob/living/silicon/robot/update_mobility()
if(stat || buckled || lockcharge)
if(HAS_TRAIT(src, TRAIT_IMMOBILIZED))
mobility_flags &= ~MOBILITY_MOVE
else
mobility_flags = MOBILITY_FLAGS_DEFAULT
+18 -5
View File
@@ -464,8 +464,7 @@
connected_ai.connected_robots -= src
src.connected_ai = null
lawupdate = FALSE
lockcharge = FALSE
mobility_flags |= MOBILITY_FLAGS_DEFAULT
set_lockcharge(FALSE)
scrambledcodes = TRUE
//Disconnect it's camera so it's not so easily tracked.
if(!QDELETED(builtInCamera))
@@ -487,17 +486,31 @@
W.attack_self(src)
/mob/living/silicon/robot/proc/SetLockdown(state = 1)
/mob/living/silicon/robot/proc/SetLockdown(state = TRUE)
// They stay locked down if their wire is cut.
if(wires.is_cut(WIRE_LOCKDOWN))
state = 1
state = TRUE
if(state)
throw_alert("locked", /obj/screen/alert/locked)
else
clear_alert("locked")
lockcharge = state
set_lockcharge(state)
///Reports the event of the change in value of the lockcharge variable.
/mob/living/silicon/robot/proc/set_lockcharge(new_lockcharge)
if(new_lockcharge == lockcharge)
return
. = lockcharge
lockcharge = new_lockcharge
if(lockcharge)
if(!.)
ADD_TRAIT(src, TRAIT_IMMOBILIZED, LOCKED_BORG_TRAIT)
else if(.)
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, LOCKED_BORG_TRAIT)
update_mobility()
/mob/living/silicon/robot/proc/SetEmagged(new_state)
emagged = new_state
module.rebuild_modules()
@@ -527,8 +527,17 @@
else
..()
/mob/living/simple_animal/update_resting()
if(resting)
ADD_TRAIT(src, TRAIT_IMMOBILIZED, RESTING_TRAIT)
else
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, RESTING_TRAIT)
return ..()
/mob/living/simple_animal/update_mobility(value_otherwise = TRUE)
if(HAS_TRAIT(src, TRAIT_KNOCKEDOUT) || IsParalyzed() || IsStun() || IsKnockdown() || IsParalyzed() || stat || resting)
if(HAS_TRAIT_NOT_FROM(src, TRAIT_IMMOBILIZED, BUCKLED_TRAIT))
drop_all_held_items()
mobility_flags = NONE
else if(buckled)