Updates wheelchair code for the new chair-lennium. (#12813)

This commit is contained in:
Wowzewow (Wezzy)
2021-12-07 13:52:58 -03:00
committed by GitHub
parent 95793597a0
commit 527698d6a8
28 changed files with 222 additions and 226 deletions
@@ -26,9 +26,11 @@
var/buckling_sound = 'sound/effects/buckle.ogg'
var/can_dismantle = TRUE
var/can_pad = TRUE
gfi_layer_rotation = GFI_ROTATION_DEFDIR
var/makes_rolling_sound = FALSE
var/held_item = null
var/held_item = null // Set to null if you don't want people to pick this up.
slowdown = 5
/obj/structure/bed/Initialize()
@@ -118,14 +120,16 @@
/obj/structure/bed/attackby(obj/item/W as obj, mob/user as mob)
if(W.iswrench())
if(can_dismantle)
playsound(src.loc, W.usesound, 50, 1)
dismantle()
dismantle(W, user)
else if(istype(W,/obj/item/stack))
if(!can_pad)
return
if(padding_material)
to_chat(user, "\The [src] is already padded.")
return
var/obj/item/stack/C = W
if(C.get_amount() < 1) // How??
to_chat(user, SPAN_WARNING("You don't have enough [C]!"))
qdel(C)
return
var/padding_type //This is awful but it needs to be like this until tiles are given a material var.
@@ -147,6 +151,8 @@
return
else if (W.iswirecutter())
if(!can_pad)
return
if(!padding_material)
to_chat(user, "\The [src] has no padding to remove.")
return
@@ -154,6 +160,15 @@
playsound(src, 'sound/items/wirecutter.ogg', 100, 1)
remove_padding()
else if (W.isscrewdriver())
if(anchored)
anchored = FALSE
to_chat(user, "You unfasten \the [src] from floor.")
else
anchored = TRUE
to_chat(user, "You fasten \the [src] to the floor.")
playsound(src, 'sound/items/screwdriver.ogg', 100, 1)
else if(istype(W, /obj/item/grab))
var/obj/item/grab/G = W
var/mob/living/affecting = G.affecting
@@ -163,9 +178,9 @@
spawn(0)
if(buckle(affecting))
affecting.visible_message(\
"<span class='danger'>[affecting.name] is buckled to [src] by [user.name]!</span>",\
"<span class='danger'>You are buckled to [src] by [user.name]!</span>",\
"<span class='notice'>You hear metal clanking.</span>")
SPAN_DANGER("[affecting.name] is buckled to [src] by [user.name]!"),\
SPAN_DANGER("You are buckled to [src] by [user.name]!"),\
SPAN_NOTICE("You hear metal clanking."))
qdel(W)
else if(istype(W, /obj/item/gripper) && buckled)
@@ -191,10 +206,14 @@
padding_material = SSmaterials.get_material_by_name(padding_type)
update_icon()
/obj/structure/bed/dismantle()
if(padding_material)
padding_material.place_sheet(get_turf(src))
..()
/obj/structure/bed/dismantle(obj/item/W, mob/user)
playsound(src.loc, W.usesound, 50, 1)
user.visible_message("<b>[user]</b> begins dismantling \the [src].", SPAN_NOTICE("You begin dismantling \the [src]."))
if(!do_after(user, 20 / W.toolspeed))
user.visible_message("\The [user] dismantles \the [src].", SPAN_NOTICE("You dismantle \the [src]."))
if(padding_material)
padding_material.place_sheet(get_turf(src))
..()
/obj/structure/bed/psych
name = "psychiatrist's couch"
@@ -3,6 +3,7 @@
desc = "You sit in this. Either by will or force."
icon_state = "chair_preview"
base_icon = "chair"
anchored = TRUE
build_amt = 1
buckle_dir = 0
buckle_lying = 0 //force people to sit up in chairs when buckled_to
@@ -14,12 +15,6 @@
. = ..()
LAZYADD(can_buckle, /mob/living)
/obj/structure/bed/stool/chair/MouseDrop(over_object, src_location, over_location)
if(padding_material) // No picking up padded chairs. For reasons.
return
else
. = ..()
/obj/structure/bed/stool/chair/do_simple_ranged_interaction(var/mob/user)
if(!buckled && user)
rotate(user)
@@ -86,8 +81,9 @@
return ..()
/obj/structure/bed/stool/chair/CanPass(atom/movable/mover, turf/target, height, air_group)
if(mover.density && isliving(mover) && (reverse_dir[dir] & angle2dir(Get_Angle(src, mover))))
return FALSE
if(anchored && padding_material)
if(mover.density && isliving(mover) && (reverse_dir[dir] & angle2dir(Get_Angle(src, mover))))
return FALSE
return ..()
/obj/structure/bed/stool/chair/padded/brown/New(var/newloc)
@@ -244,45 +240,59 @@
..(newloc, MATERIAL_STEEL, MATERIAL_CLOTH_LIME)
/obj/structure/bed/stool/chair/office
/obj/structure/bed/stool/chair/office // For the love of god, don't use this.
name = "office chair"
material_alteration = MATERIAL_ALTERATION_DESC
makes_rolling_sound = TRUE
anchored = 0
buckle_movable = 1
anchored = FALSE
buckle_movable = TRUE
build_amt = 5
held_item = null
/obj/structure/bed/stool/chair/office/attackby(obj/item/W as obj, mob/user as mob)
if(istype(W,/obj/item/stack) || W.iswirecutter())
return
..()
can_pad = FALSE
var/driving = FALSE // Shit for wheelchairs. Doesn't really get used here, but it's for code cleanliness.
var/mob/living/pulling = null
/obj/structure/bed/stool/chair/office/Move()
. = ..()
if(makes_rolling_sound)
playsound(src, 'sound/effects/roll.ogg', 100, 1)
playsound(src, 'sound/effects/roll.ogg', 50, 1)
if(buckled)
var/mob/living/occupant = buckled
occupant.buckled_to = null
occupant.Move(src.loc)
occupant.buckled_to = src
if (occupant && (src.loc != occupant.loc))
if (propelled)
for (var/mob/O in src.loc)
if (O != occupant)
Collide(O)
else
unbuckle()
if(!driving)
occupant.buckled_to = null
occupant.Move(src.loc)
occupant.buckled_to = src
if (occupant && (src.loc != occupant.loc))
if (propelled)
for (var/mob/O in src.loc)
if (O != occupant)
Collide(O)
else
unbuckle()
if (pulling && (get_dist(src, pulling) > 1))
pulling.pulledby = null
to_chat(pulling, SPAN_WARNING("You lost your grip!"))
pulling = null
else
if (occupant && (src.loc != occupant.loc))
src.forceMove(occupant.loc) // Failsafe to make sure the wheelchair stays beneath the occupant after driving
/obj/structure/bed/stool/chair/office/Collide(atom/A)
. = ..()
if(!buckled)
return
if(propelled)
if(propelled || (pulling && (pulling.a_intent == I_HURT)))
var/mob/living/occupant = unbuckle()
if (pulling && (pulling.a_intent == I_HURT))
occupant.throw_at(A, 3, 3, pulling)
else if (propelled)
occupant.throw_at(A, 3, propelled)
var/def_zone = ran_zone()
occupant.throw_at(A, 3, propelled)
occupant.apply_effect(6, STUN)
@@ -297,7 +307,14 @@
victim.apply_effect(6, WEAKEN)
victim.apply_effect(6, STUTTER)
victim.apply_damage(10, BRUTE, def_zone)
occupant.visible_message("<span class='danger'>[occupant] crashed into \the [A]!</span>")
if(pulling)
occupant.visible_message(SPAN_DANGER("[pulling] has thrusted \the [name] into \the [A], throwing \the [occupant] out of it!"))
pulling.attack_log += "\[[time_stamp()]\]<span class='warning'> Crashed [occupant.name]'s ([occupant.ckey]) [name] into \a [A]</span>"
occupant.attack_log += "\[[time_stamp()]\]<font color='orange'> Thrusted into \a [A] by [pulling.name] ([pulling.ckey]) with \the [name]</font>"
msg_admin_attack("[pulling.name] ([pulling.ckey]) has thrusted [occupant.name]'s ([occupant.ckey]) [name] into \a [A] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[pulling.x];Y=[pulling.y];Z=[pulling.z]'>JMP</a>)",ckey=key_name(pulling),ckey_target=key_name(occupant))
else
occupant.visible_message(SPAN_DANGER("[occupant] crashed into \the [A]!"))
/obj/structure/bed/stool/chair/office/light
icon_state = "officechair_white_preview"
@@ -312,7 +329,7 @@
desc = "It exudes authority... and looks about as comfortable as a brick."
icon_state = "bridge_preview"
base_icon = "bridge"
anchored = 1
anchored = TRUE
/obj/structure/bed/stool/chair/office/bridge/legion
name = "legion pilot seat"
@@ -337,6 +354,7 @@
base_icon = "hover_chair"
makes_rolling_sound = FALSE
can_dismantle = FALSE
can_pad = TRUE
held_item = null
/obj/structure/bed/stool/chair/office/hover/New(var/newloc)
@@ -361,11 +379,7 @@
material_alteration = MATERIAL_ALTERATION_NAME || MATERIAL_ALTERATION_DESC
build_amt = 3
held_item = /obj/item/material/stool/chair/wood
/obj/structure/bed/stool/chair/wood/attackby(obj/item/W as obj, mob/user as mob)
if(istype(W,/obj/item/stack) || W.iswirecutter())
return
..()
can_pad = FALSE
/obj/structure/bed/stool/chair/wood/New(var/newloc)
..(newloc, MATERIAL_WOOD)
@@ -438,7 +452,7 @@
desc = "Bar brawl essential. Now all that's missing is a ragtime piano."
desc_info = "Click it while in hand to right it."
icon = 'icons/obj/furniture.dmi'
icon_state = "chair_toppled"
icon_state = "chair_item"
item_state = "chair"
base_icon = "chair"
item_icons = list(
@@ -451,19 +465,19 @@
// Because wood chairs are snowflake sprites.
/obj/item/material/stool/chair/wood
icon_state = "wooden_chair_toppled"
icon_state = "wooden_chair_item"
item_state = "woodenchair"
base_icon = "wooden_chair"
origin_type = /obj/structure/bed/stool/chair/wood
/obj/item/material/stool/chair/wood/wings
icon_state = "wooden_chair_wings_toppled"
icon_state = "wooden_chair_wings_item"
item_state = "woodenchair"
base_icon= "wooden_chair_wings"
base_icon = "wooden_chair_wings"
origin_type = /obj/structure/bed/stool/chair/wood/wings
/obj/item/material/stool/chair/folding // Todo : "borrow" CM code for stacking and general tomfoolery.
icon_state = "folding_chair_toppled"
icon_state = "folding_chair_item"
item_state = "folding_chair"
base_icon = "folding_chair"
origin_type = /obj/structure/bed/stool/chair/folding
@@ -8,6 +8,7 @@
buckle_lying = FALSE //force people to sit up in chairs when buckled
build_amt = 2
held_item = /obj/item/material/stool // if null it can't be picked up. Automatically applies materials.
var/withdraw_verb = "grab" //Self explanatory. Replace if necessary.
/obj/structure/bed/stool/Initialize()
. = ..()
@@ -16,9 +17,9 @@
/obj/structure/bed/stool/MouseDrop(over_object, src_location, over_location)
. = ..()
if(over_object == usr && Adjacent(usr))
if(!held_item || use_check_and_message(usr) || buckled || !can_dismantle)
if(!held_item || use_check_and_message(usr) || buckled || !can_dismantle || (anchored && padding_material))
return
usr.visible_message(SPAN_NOTICE("[usr] grabs \the [src.name]."), SPAN_NOTICE("You grab \the [src.name]."))
usr.visible_message(SPAN_NOTICE("[usr] [withdraw_verb]s \the [src.name]."), SPAN_NOTICE("You [withdraw_verb] \the [src.name]."))
var/obj/item/material/stool/S = new held_item(src.loc, material.name, padding_material ? padding_material.name : null) // Handles all the material code so you don't have to.
TransferComponents(S)
if(material_alteration & MATERIAL_ALTERATION_COLOR) // For snowflakes like wood chairs.
@@ -68,6 +69,9 @@
/obj/structure/bed/stool/padded/lime/New(var/newloc)
..(newloc, MATERIAL_STEEL, MATERIAL_CLOTH_LIME)
/obj/structure/bed/stool/wood/New(var/newloc)
..(newloc, MATERIAL_WOOD)
/obj/structure/bed/stool/bar
name = "bar stool"
desc = "It has some unsavory stains on it..."
@@ -88,9 +92,6 @@
/obj/structure/bed/stool/bar/padded/red/New(var/newloc)
..(newloc, MATERIAL_STEEL, MATERIAL_CARPET)
/obj/structure/bed/stool/bar/padded/red/New(var/newloc)
..(newloc, MATERIAL_STEEL, MATERIAL_CARPET)
/obj/structure/bed/stool/bar/padded/teal/New(var/newloc)
..(newloc, MATERIAL_STEEL, MATERIAL_CLOTH_TEAL)
@@ -135,7 +136,7 @@
slot_l_hand_str = 'icons/mob/items/lefthand_chairs.dmi',
slot_r_hand_str = 'icons/mob/items/righthand_chairs.dmi',
)
icon_state = "stool_toppled_preview"
icon_state = "stool_item_preview"
item_state = "stool"
var/base_icon = "stool"
desc_info = "Use in-hand or alt-click to right this."
@@ -150,6 +151,7 @@
applies_material_colour = FALSE
var/material/padding_material
var/obj/structure/bed/stool/origin_type = /obj/structure/bed/stool
var/deploy_verb = "right"
/obj/item/material/stool/New(var/newloc, var/new_material, var/new_padding_material)
..(newloc, new_material) // new_material handled in material_weapons.dm
@@ -210,7 +212,7 @@
to_chat(user, SPAN_DANGER("There is already something here."))
return
user.visible_message(SPAN_NOTICE("[user] rights \the [src.name]."), SPAN_NOTICE("You right \the [name]."))
user.visible_message(SPAN_NOTICE("[user] [deploy_verb]s \the [src.name]."), SPAN_NOTICE("You [deploy_verb] \the [name]."))
// playsound(src, deploy_sound ? deploy_sound : drop_sound, DROP_SOUND_VOLUME)
user.drop_from_inventory(src)
var/obj/structure/bed/stool/S = new origin_type(get_turf(loc))
@@ -224,10 +226,10 @@
qdel(src)
/obj/item/material/stool/update_icon()
icon_state = "[base_icon]_toppled"
icon_state = "[base_icon]_item"
cut_overlays()
if(padding_material) // Handles padding overlay and inhand overlays.
var/image/padding_overlay = image(icon, "[base_icon]_toppled_padding")
var/image/padding_overlay = image(icon, "[base_icon]_item_padding")
padding_overlay.appearance_flags = RESET_COLOR
build_from_parts = TRUE
worn_overlay = "padding"
@@ -261,13 +263,13 @@
return
/obj/item/material/stool/bar
icon_state = "bar_stool_toppled_preview"
icon_state = "bar_stool_item_preview"
item_state = "bar_stool"
base_icon = "bar_stool"
origin_type = /obj/structure/bed/stool/bar
/obj/item/material/stool/hover
icon_state = "hover_stool_toppled"
icon_state = "hover_stool_item"
item_state = "hover_stool"
base_icon = "hover_stool"
origin_type = /obj/structure/bed/stool/hover
@@ -1,38 +1,34 @@
/obj/structure/bed/stool/chair/wheelchair
/obj/structure/bed/stool/chair/office/wheelchair
name = "wheelchair"
desc = "You sit in this. Either by will or force."
icon_state = "wheelchair"
anchored = 0
buckle_movable = 1
held_item = /obj/item/wheelchair
icon_state = "wheelchair_padded_preview"
base_icon = "wheelchair"
anchored = FALSE
buckle_movable = TRUE
material_alteration = MATERIAL_ALTERATION_DESC
held_item = /obj/item/material/stool/chair/wheelchair
withdraw_verb = "fold"
can_dismantle = FALSE
var/driving = 0
var/mob/living/pulling = null
var/bloodiness
slowdown = 0
/obj/structure/bed/stool/chair/wheelchair/update_icon()
cut_overlays()
add_overlay(image(icon = 'icons/obj/furniture.dmi', icon_state = "w_overlay", layer = FLY_LAYER))
/obj/structure/bed/stool/chair/office/wheelchair/New(var/newloc) // Colorable wheelchairs?
..(newloc, MATERIAL_STEEL, MATERIAL_CLOTH)
/obj/structure/bed/stool/chair/wheelchair/set_dir()
/obj/structure/bed/stool/chair/office/wheelchair/set_dir()
. = ..()
if(buckled)
buckled.set_dir(dir)
/obj/structure/bed/stool/chair/wheelchair/attackby(obj/item/W as obj, mob/user as mob)
if(W.iswrench() || istype(W,/obj/item/stack) || W.iswirecutter())
return
..()
/obj/structure/bed/stool/chair/wheelchair/relaymove(mob/user, direction)
/obj/structure/bed/stool/chair/office/wheelchair/relaymove(mob/user, direction)
// Redundant check?
if(user.stat || user.stunned || user.weakened || user.paralysis || user.lying || user.restrained())
if(user==pulling)
pulling = null
user.pulledby = null
to_chat(user, "<span class='warning'>You lost your grip!</span>")
to_chat(user, SPAN_WARNING("You've lost your grip!"))
return
if(buckled && pulling && user == buckled)
if(pulling.stat || pulling.stunned || pulling.weakened || pulling.paralysis || pulling.lying || pulling.restrained())
@@ -50,14 +46,14 @@
if(user==pulling)
return
if(pulling && (get_dir(src.loc, pulling.loc) == direction))
to_chat(user, "<span class='warning'>You cannot go there.</span>")
to_chat(user, SPAN_WARNING("You cannot go there."))
return
if(pulling && buckled && (buckled == user))
to_chat(user, "<span class='warning'>You cannot drive while being pushed.</span>")
to_chat(user, SPAN_WARNING("You cannot drive while being pushed."))
return
// Let's roll
driving = 1
driving = TRUE
var/turf/T = null
//--1---Move occupant---1--//
if(buckled)
@@ -85,44 +81,20 @@
pulling.set_dir(get_dir(pulling, src)) // When everything is right, face the wheelchair
if(bloodiness)
create_track()
driving = 0
driving = FALSE
/obj/structure/bed/stool/chair/wheelchair/Move()
. = ..()
playsound(src, 'sound/effects/roll.ogg', 75, 1)
if(buckled)
var/mob/living/occupant = buckled
if(!driving)
occupant.buckled_to = null
occupant.Move(src.loc)
occupant.buckled_to = src
if (occupant && (src.loc != occupant.loc))
if (propelled)
for (var/mob/O in src.loc)
if (O != occupant)
Collide(O)
else
unbuckle()
if (pulling && (get_dist(src, pulling) > 1))
pulling.pulledby = null
to_chat(pulling, "<span class='warning'>You lost your grip!</span>")
pulling = null
else
if (occupant && (src.loc != occupant.loc))
src.forceMove(occupant.loc) // Failsafe to make sure the wheelchair stays beneath the occupant after driving
/obj/structure/bed/stool/chair/wheelchair/attack_hand(mob/living/user as mob)
if (pulling)
MouseDrop(usr)
/obj/structure/bed/stool/chair/office/wheelchair/attack_hand(mob/living/user as mob)
if(pulling)
MouseDrop()
else
user_unbuckle(user)
return
/obj/structure/bed/stool/chair/wheelchair/CtrlClick(var/mob/user)
/obj/structure/bed/stool/chair/office/wheelchair/CtrlClick(var/mob/user)
if(in_range(src, user))
if(!ishuman(user)) return
if(user == buckled)
to_chat(user, "<span class='warning'>You realize you are unable to push the wheelchair you sit in.</span>")
to_chat(user, SPAN_WARNING("You realize you are unable to push the wheelchair you sit in."))
return
if(!pulling)
pulling = user
@@ -132,48 +104,12 @@
user.set_dir(get_dir(user, src))
to_chat(user, "You grip \the [name]'s handles.")
else
to_chat(usr, "You let go of \the [name]'s handles.")
to_chat(user, "You let go of \the [name]'s handles.")
pulling.pulledby = null
pulling = null
return
/obj/structure/bed/stool/chair/wheelchair/Collide(atom/A)
. = ..()
if(!buckled)
return
if(propelled || (pulling && (pulling.a_intent == I_HURT)))
var/mob/living/occupant = unbuckle()
if (pulling && (pulling.a_intent == I_HURT))
occupant.throw_at(A, 3, 3, pulling)
else if (propelled)
occupant.throw_at(A, 3, propelled)
var/def_zone = ran_zone()
occupant.throw_at(A, 3, propelled)
occupant.apply_effect(6, STUN)
occupant.apply_effect(6, WEAKEN)
occupant.apply_effect(6, STUTTER)
occupant.apply_damage(10, BRUTE, def_zone)
playsound(src.loc, "punch", 50, 1, -1)
if(isliving(A))
var/mob/living/victim = A
def_zone = ran_zone()
victim.apply_effect(6, STUN)
victim.apply_effect(6, WEAKEN)
victim.apply_effect(6, STUTTER)
victim.apply_damage(10, BRUTE, def_zone)
if(pulling)
occupant.visible_message("<span class='danger'>[pulling] has thrusted \the [name] into \the [A], throwing \the [occupant] out of it!</span>")
pulling.attack_log += "\[[time_stamp()]\]<span class='warning'> Crashed [occupant.name]'s ([occupant.ckey]) [name] into \a [A]</span>"
occupant.attack_log += "\[[time_stamp()]\]<font color='orange'> Thrusted into \a [A] by [pulling.name] ([pulling.ckey]) with \the [name]</font>"
msg_admin_attack("[pulling.name] ([pulling.ckey]) has thrusted [occupant.name]'s ([occupant.ckey]) [name] into \a [A] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[pulling.x];Y=[pulling.y];Z=[pulling.z]'>JMP</a>)",ckey=key_name(pulling),ckey_target=key_name(occupant))
else
occupant.visible_message("<span class='danger'>[occupant] crashed into \the [A]!</span>")
/obj/structure/bed/stool/chair/wheelchair/proc/create_track()
/obj/structure/bed/stool/chair/office/wheelchair/proc/create_track()
var/obj/effect/decal/cleanable/blood/tracks/B = new(loc)
var/newdir = get_dir(get_step(loc, dir), loc)
if(newdir == dir)
@@ -187,40 +123,22 @@
B.set_dir(newdir)
bloodiness--
/obj/structure/bed/stool/chair/wheelchair/buckle(mob/M as mob, mob/user as mob)
/obj/structure/bed/stool/chair/office/wheelchair/buckle(mob/M as mob, mob/user as mob)
if(M == pulling)
pulling = null
usr.pulledby = null
..()
/obj/item/wheelchair
/obj/item/material/stool/chair/wheelchair
name = "wheelchair"
desc = "A folded wheelchair that can be carried around."
icon = 'icons/obj/furniture.dmi'
icon_state = "wheelchair_folded"
icon_state = "wheelchair_item_preview"
item_state = "wheelchair"
base_icon = "wheelchair"
w_class = ITEMSIZE_HUGE // Can't be put in backpacks. Oh well.
/obj/item/wheelchair/attack_self(mob/user)
var/obj/structure/bed/stool/chair/wheelchair/R = new /obj/structure/bed/stool/chair/wheelchair(user.loc)
R.add_fingerprint(user)
R.name = src.name
R.desc = src.desc
R.color = src.color
qdel(src)
origin_type = /obj/structure/bed/stool/chair/office/wheelchair
deploy_verb = "deploy"
/obj/item/material/stool/chair/wheelchair/New(var/newloc)
..(newloc, MATERIAL_STEEL, MATERIAL_CLOTH)
/obj/structure/bed/stool/chair/wheelchair/MouseDrop(over_object, src_location, over_location)
..()
if(!ishuman(usr))
return FALSE
if(buckled)
return FALSE
if(!usr.Adjacent(src))
return FALSE
visible_message(SPAN_NOTICE("[usr] collapses [src]."))
var/obj/item/wheelchair/R = new(get_turf(src))
R.name = src.name
R.desc = src.desc
R.color = src.color
usr.put_in_hands(R)
qdel(src)