Files
Yogstation/code/game/objects/structures/beds_chairs/chair.dm
kevinz000 1f7a76ade0 Combat/Stun (slip) overhaul staging, mobility flags, adds crawling (#39967)
Aiming to implement the framework oranges has detailed in https://tgstation13.org/phpBB/viewtopic.php?f=10&t=19102
Moves canmove to a bitflag in a new variable called mobility_flags, that will allow finer grain control of what someone can do codewise, for example, letting them move but not stand up, or stand up but not move.

Adds Immobilize()d status effect that freezes movement but does not prevent anything else.
Adds Paralyze()d which is oldstun "You can't do anything at all and knock down).
Stun() will now prevent any item/UI usage and movement (which is similar to before).
Knockdown() will now only knockdown without preventing item usage/movement.
People knocked down will be able to crawl at softcrit-speeds
Refactors some /mob variables and procs to /mob/living.
update_canmove() refactored to update_mobility() and will handle mobility_flags instead of the removed canmove

cl
rscadd: Crawling is now possible if you are down but not stunned. Obviously, you will be slower.
/cl
Refactors are done. I'd rather get this merged faster than try to fine tune stuff like slips. The most obvious gameplay effect this pr has will be crawling, and I believe I made tiny tweaks but I can't find it Anything I missed or weird behavior should be reported.
2018-10-10 23:21:27 +01:00

421 lines
12 KiB
Plaintext

/obj/structure/chair
name = "chair"
desc = "You sit in this. Either by will or force."
icon = 'icons/obj/chairs.dmi'
icon_state = "chair"
anchored = TRUE
can_buckle = 1
buckle_lying = 0 //you sit in a chair, not lay
resistance_flags = NONE
max_integrity = 250
integrity_failure = 25
var/buildstacktype = /obj/item/stack/sheet/metal
var/buildstackamount = 1
var/item_chair = /obj/item/chair // if null it can't be picked up
layer = OBJ_LAYER
/obj/structure/chair/examine(mob/user)
..()
to_chat(user, "<span class='notice'>It's held together by a couple of <b>bolts</b>.</span>")
if(!has_buckled_mobs())
to_chat(user, "<span class='notice'>Drag your sprite to sit in it.</span>")
/obj/structure/chair/Initialize()
. = ..()
if(!anchored) //why would you put these on the shuttle?
addtimer(CALLBACK(src, .proc/RemoveFromLatejoin), 0)
/obj/structure/chair/ComponentInitialize()
. = ..()
AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE, CALLBACK(src, .proc/can_user_rotate),CALLBACK(src, .proc/can_be_rotated),null)
/obj/structure/chair/proc/can_be_rotated(mob/user)
return TRUE
/obj/structure/chair/proc/can_user_rotate(mob/user)
var/mob/living/L = user
if(istype(L))
if(!user.canUseTopic(src, BE_CLOSE, ismonkey(user)))
return FALSE
else
return TRUE
else if(isobserver(user) && CONFIG_GET(flag/ghost_interaction))
return TRUE
return FALSE
/obj/structure/chair/Destroy()
RemoveFromLatejoin()
return ..()
/obj/structure/chair/proc/RemoveFromLatejoin()
SSjob.latejoin_trackers -= src //These may be here due to the arrivals shuttle
/obj/structure/chair/deconstruct()
// If we have materials, and don't have the NOCONSTRUCT flag
if(buildstacktype && (!(flags_1 & NODECONSTRUCT_1)))
new buildstacktype(loc,buildstackamount)
..()
/obj/structure/chair/attack_paw(mob/user)
return attack_hand(user)
/obj/structure/chair/narsie_act()
var/obj/structure/chair/wood/W = new/obj/structure/chair/wood(get_turf(src))
W.setDir(dir)
qdel(src)
/obj/structure/chair/ratvar_act()
var/obj/structure/chair/brass/B = new(get_turf(src))
B.setDir(dir)
qdel(src)
/obj/structure/chair/attackby(obj/item/W, mob/user, params)
if(W.tool_behaviour == TOOL_WRENCH && !(flags_1&NODECONSTRUCT_1))
W.play_tool_sound(src)
deconstruct()
else if(istype(W, /obj/item/assembly/shock_kit))
if(!user.temporarilyRemoveItemFromInventory(W))
return
var/obj/item/assembly/shock_kit/SK = W
var/obj/structure/chair/e_chair/E = new /obj/structure/chair/e_chair(src.loc)
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, 1)
E.setDir(dir)
E.part = SK
SK.forceMove(E)
SK.master = E
qdel(src)
else
return ..()
/obj/structure/chair/attack_tk(mob/user)
if(!anchored || has_buckled_mobs() || !isturf(user.loc))
..()
else
setDir(turn(dir,-90))
/obj/structure/chair/proc/handle_rotation(direction)
handle_layer()
if(has_buckled_mobs())
for(var/m in buckled_mobs)
var/mob/living/buckled_mob = m
buckled_mob.setDir(direction)
/obj/structure/chair/proc/handle_layer()
if(has_buckled_mobs() && dir == NORTH)
layer = ABOVE_MOB_LAYER
else
layer = OBJ_LAYER
/obj/structure/chair/post_buckle_mob(mob/living/M)
. = ..()
handle_layer()
/obj/structure/chair/post_unbuckle_mob()
. = ..()
handle_layer()
/obj/structure/chair/setDir(newdir)
..()
handle_rotation(newdir)
// Chair types
/obj/structure/chair/wood
icon_state = "wooden_chair"
name = "wooden chair"
desc = "Old is never too old to not be in fashion."
resistance_flags = FLAMMABLE
max_integrity = 70
buildstacktype = /obj/item/stack/sheet/mineral/wood
buildstackamount = 3
item_chair = /obj/item/chair/wood
/obj/structure/chair/wood/narsie_act()
return
/obj/structure/chair/wood/normal //Kept for map compatibility
/obj/structure/chair/wood/wings
icon_state = "wooden_chair_wings"
item_chair = /obj/item/chair/wood/wings
/obj/structure/chair/comfy
name = "comfy chair"
desc = "It looks comfy."
icon_state = "comfychair"
color = rgb(255,255,255)
resistance_flags = FLAMMABLE
max_integrity = 70
buildstackamount = 2
item_chair = null
var/mutable_appearance/armrest
/obj/structure/chair/comfy/Initialize()
armrest = GetArmrest()
armrest.layer = ABOVE_MOB_LAYER
return ..()
/obj/structure/chair/comfy/proc/GetArmrest()
return mutable_appearance('icons/obj/chairs.dmi', "comfychair_armrest")
/obj/structure/chair/comfy/Destroy()
QDEL_NULL(armrest)
return ..()
/obj/structure/chair/comfy/post_buckle_mob(mob/living/M)
. = ..()
update_armrest()
/obj/structure/chair/comfy/proc/update_armrest()
if(has_buckled_mobs())
add_overlay(armrest)
else
cut_overlay(armrest)
/obj/structure/chair/comfy/post_unbuckle_mob()
. = ..()
update_armrest()
/obj/structure/chair/comfy/brown
color = rgb(255,113,0)
/obj/structure/chair/comfy/beige
color = rgb(255,253,195)
/obj/structure/chair/comfy/teal
color = rgb(0,255,255)
/obj/structure/chair/comfy/black
color = rgb(167,164,153)
/obj/structure/chair/comfy/lime
color = rgb(255,251,0)
/obj/structure/chair/comfy/shuttle
name = "shuttle seat"
desc = "A comfortable, secure seat. It has a more sturdy looking buckling system, for smoother flights."
icon_state = "shuttle_chair"
/obj/structure/chair/comfy/shuttle/GetArmrest()
return mutable_appearance('icons/obj/chairs.dmi', "shuttle_chair_armrest")
/obj/structure/chair/office
anchored = FALSE
buildstackamount = 5
item_chair = null
/obj/structure/chair/office/Moved()
. = ..()
if(has_gravity())
playsound(src, 'sound/effects/roll.ogg', 100, 1)
/obj/structure/chair/office/light
icon_state = "officechair_white"
/obj/structure/chair/office/dark
icon_state = "officechair_dark"
//Stool
/obj/structure/chair/stool
name = "stool"
desc = "Apply butt."
icon_state = "stool"
can_buckle = 0
buildstackamount = 1
item_chair = /obj/item/chair/stool
/obj/structure/chair/stool/narsie_act()
return
/obj/structure/chair/MouseDrop(over_object, src_location, over_location)
. = ..()
if(over_object == usr && Adjacent(usr))
if(!item_chair || !usr.can_hold_items() || has_buckled_mobs() || src.flags_1 & NODECONSTRUCT_1)
return
if(!usr.canUseTopic(src, BE_CLOSE, ismonkey(usr)))
return
usr.visible_message("<span class='notice'>[usr] grabs \the [src.name].</span>", "<span class='notice'>You grab \the [src.name].</span>")
var/C = new item_chair(loc)
TransferComponents(C)
usr.put_in_hands(C)
qdel(src)
/obj/structure/chair/stool/bar
name = "bar stool"
desc = "It has some unsavory stains on it..."
icon_state = "bar"
item_chair = /obj/item/chair/stool/bar
/obj/item/chair
name = "chair"
desc = "Bar brawl essential."
icon = 'icons/obj/chairs.dmi'
icon_state = "chair_toppled"
item_state = "chair"
lefthand_file = 'icons/mob/inhands/misc/chairs_lefthand.dmi'
righthand_file = 'icons/mob/inhands/misc/chairs_righthand.dmi'
w_class = WEIGHT_CLASS_HUGE
force = 8
throwforce = 10
throw_range = 3
hitsound = 'sound/items/trayhit1.ogg'
hit_reaction_chance = 50
materials = list(MAT_METAL = 2000)
var/break_chance = 5 //Likely hood of smashing the chair.
var/obj/structure/chair/origin_type = /obj/structure/chair
/obj/item/chair/suicide_act(mob/living/carbon/user)
user.visible_message("<span class='suicide'>[user] begins hitting [user.p_them()]self with \the [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
playsound(src,hitsound,50,1)
return BRUTELOSS
/obj/item/chair/narsie_act()
var/obj/item/chair/wood/W = new/obj/item/chair/wood(get_turf(src))
W.setDir(dir)
qdel(src)
/obj/item/chair/attack_self(mob/user)
plant(user)
/obj/item/chair/proc/plant(mob/user)
for(var/obj/A in get_turf(loc))
if(istype(A, /obj/structure/chair))
to_chat(user, "<span class='danger'>There is already a chair here.</span>")
return
if(A.density && !(A.flags_1 & ON_BORDER_1))
to_chat(user, "<span class='danger'>There is already something here.</span>")
return
user.visible_message("<span class='notice'>[user] rights \the [src.name].</span>", "<span class='notice'>You right \the [name].</span>")
var/obj/structure/chair/C = new origin_type(get_turf(loc))
TransferComponents(C)
C.setDir(dir)
qdel(src)
/obj/item/chair/proc/smash(mob/living/user)
var/stack_type = initial(origin_type.buildstacktype)
if(!stack_type)
return
var/remaining_mats = initial(origin_type.buildstackamount)
remaining_mats-- //Part of the chair was rendered completely unusable. It magically dissapears. Maybe make some dirt?
if(remaining_mats)
for(var/M=1 to remaining_mats)
new stack_type(get_turf(loc))
qdel(src)
/obj/item/chair/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(attack_type == UNARMED_ATTACK && prob(hit_reaction_chance))
owner.visible_message("<span class='danger'>[owner] fends off [attack_text] with [src]!</span>")
return 1
return 0
/obj/item/chair/afterattack(atom/target, mob/living/carbon/user, proximity)
. = ..()
if(!proximity)
return
if(prob(break_chance))
user.visible_message("<span class='danger'>[user] smashes \the [src] to pieces against \the [target]</span>")
if(iscarbon(target))
var/mob/living/carbon/C = target
if(C.health < C.maxHealth*0.5)
C.Paralyze(20)
smash(user)
/obj/item/chair/stool
name = "stool"
icon_state = "stool_toppled"
item_state = "stool"
origin_type = /obj/structure/chair/stool
break_chance = 0 //It's too sturdy.
/obj/item/chair/stool/bar
name = "bar stool"
icon_state = "bar_toppled"
item_state = "stool_bar"
origin_type = /obj/structure/chair/stool/bar
/obj/item/chair/stool/narsie_act()
return //sturdy enough to ignore a god
/obj/item/chair/wood
name = "wooden chair"
icon_state = "wooden_chair_toppled"
item_state = "woodenchair"
resistance_flags = FLAMMABLE
max_integrity = 70
hitsound = 'sound/weapons/genhit1.ogg'
origin_type = /obj/structure/chair/wood
materials = null
break_chance = 50
/obj/item/chair/wood/narsie_act()
return
/obj/item/chair/wood/wings
icon_state = "wooden_chair_wings_toppled"
origin_type = /obj/structure/chair/wood/wings
/obj/structure/chair/old
name = "strange chair"
desc = "You sit in this. Either by will or force. Looks REALLY uncomfortable."
icon_state = "chairold"
item_chair = null
/obj/structure/chair/brass
name = "brass chair"
desc = "A spinny chair made of brass. It looks uncomfortable."
icon_state = "brass_chair"
max_integrity = 150
buildstacktype = /obj/item/stack/tile/brass
buildstackamount = 1
item_chair = null
var/turns = 0
/obj/structure/chair/brass/Destroy()
STOP_PROCESSING(SSfastprocess, src)
. = ..()
/obj/structure/chair/brass/process()
setDir(turn(dir,-90))
playsound(src, 'sound/effects/servostep.ogg', 50, FALSE)
turns++
if(turns >= 8)
STOP_PROCESSING(SSfastprocess, src)
/obj/structure/chair/brass/ratvar_act()
return
/obj/structure/chair/brass/AltClick(mob/living/user)
turns = 0
if(!istype(user) || !user.canUseTopic(src, BE_CLOSE, ismonkey(user)))
return
if(!(datum_flags & DF_ISPROCESSING))
user.visible_message("<span class='notice'>[user] spins [src] around, and Ratvarian technology keeps it spinning FOREVER.</span>", \
"<span class='notice'>Automated spinny chairs. The pinnacle of Ratvarian technology.</span>")
START_PROCESSING(SSfastprocess, src)
else
user.visible_message("<span class='notice'>[user] stops [src]'s uncontrollable spinning.</span>", \
"<span class='notice'>You grab [src] and stop its wild spinning.</span>")
STOP_PROCESSING(SSfastprocess, src)
/obj/structure/chair/bronze
name = "brass chair"
desc = "A spinny chair made of bronze. It has little cogs for wheels!"
anchored = FALSE
icon_state = "brass_chair"
buildstacktype = /obj/item/stack/tile/bronze
buildstackamount = 1
item_chair = null
/obj/structure/chair/bronze/Moved()
. = ..()
if(has_gravity())
playsound(src, 'sound/machines/clockcult/integration_cog_install.ogg', 50, TRUE)