From abe54462ca71e1b76d5d30c9810eb33b4b424ef2 Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Thu, 4 Mar 2021 07:48:15 +1100 Subject: [PATCH] Minor wheelchair refactor. --- code/game/jobs/job_controller.dm | 5 +- .../stool_bed_chair_nest/wheelchair.dm | 135 +++++------------- .../stool_bed_chair_nest/wheelchair_item.dm | 29 ++++ .../loadout/loadout_utility.dm | 24 ++-- .../preference_setup/loadout/loadout_xeno.dm | 4 +- polaris.dme | 1 + 6 files changed, 79 insertions(+), 119 deletions(-) create mode 100644 code/game/objects/structures/stool_bed_chair_nest/wheelchair_item.dm diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 30a27d19ad..049acb9dbe 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -484,11 +484,12 @@ var/global/datum/controller/occupations/job_master var/obj/item/organ/external/l_foot = H.get_organ("l_foot") var/obj/item/organ/external/r_foot = H.get_organ("r_foot") var/obj/item/weapon/storage/S = locate() in H.contents - var/obj/item/wheelchair/R = null + var/obj/item/wheelchair/R if(S) R = locate() in S.contents if(!l_foot || !r_foot || R) - var/obj/structure/bed/chair/wheelchair/W = new /obj/structure/bed/chair/wheelchair(H.loc) + var/wheelchair_type = R?.unfolded_type || /obj/structure/bed/chair/wheelchair + var/obj/structure/bed/chair/wheelchair/W = new wheelchair_type(H.loc) W.buckle_mob(H) H.update_canmove() W.set_dir(H.dir) diff --git a/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm b/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm index 239f730fb3..7459fcab6c 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm @@ -5,73 +5,55 @@ icon_state = "wheelchair" anchored = 0 buckle_movable = 1 - var/wheelchairtype = /obj/structure/bed/chair/wheelchair - var/wheelchairitemtype = /obj/item/wheelchair + var/folded_type = /obj/item/wheelchair var/driving = 0 var/mob/living/pulling = null var/bloodiness - var/min_mob_buckle_size = MOB_SMALL var/max_mob_buckle_size = MOB_LARGE -/obj/structure/bed/chair/wheelchair/smallmotor - name = "small electric wheelchair" - desc = "A small motorized wheelchair, it looks around the right size for a Teshari" - icon_state = "teshchair" - wheelchairtype = /obj/structure/bed/chair/wheelchair/smallmotor - wheelchairitemtype = /obj/item/smallmotorwheelchair - min_mob_buckle_size = MOB_SMALL - max_mob_buckle_size = MOB_MEDIUM +/obj/structure/bed/chair/wheelchair/Initialize() + . = ..() + update_icon() /obj/structure/bed/chair/wheelchair/motor name = "electric wheelchair" desc = "A motorized wheelchair controlled with a joystick on one armrest" icon_state = "motorchair" - wheelchairtype = /obj/structure/bed/chair/wheelchair/motor - wheelchairitemtype = /obj/item/motorwheelchair + folded_type = /obj/item/wheelchair/motor + +/obj/structure/bed/chair/wheelchair/smallmotor + name = "small electric wheelchair" + desc = "A small motorized wheelchair, it looks around the right size for a Teshari" + icon_state = "teshchair" + min_mob_buckle_size = MOB_SMALL + max_mob_buckle_size = MOB_MEDIUM + folded_type = /obj/item/wheelchair/motor/small /obj/structure/bed/chair/wheelchair/can_buckle_check(mob/living/M, forced = FALSE) - . = ..() - if(. && (M.mob_size < min_mob_buckle_size || M.mob_size >= max_mob_buckle_size)) - to_chat(M, SPAN_WARNING("You are the wrong size to use \the [src].")) - . = FALSE + . = ..() + if(.) + if(M.mob_size < min_mob_buckle_size) + to_chat(M, SPAN_WARNING("You are too small to use \the [src].")) + . = FALSE + else if(M.mob_size >= max_mob_buckle_size) + to_chat(M, SPAN_WARNING("You are too large to use \the [src].")) + . = FALSE /obj/structure/bed/chair/wheelchair/update_icon() - return + cut_overlays() + var/image/O = image(icon = icon, icon_state = "[icon_state]_overlay", layer = ABOVE_MOB_LAYER) + O.plane = MOB_PLANE + add_overlay(O) /obj/structure/bed/chair/wheelchair/set_dir() - ..() - cut_overlays() - var/image/O = image(icon = 'icons/obj/wheelchair.dmi', icon_state = "wheelchair_overlay", layer = ABOVE_MOB_LAYER, dir = src.dir) - O.plane = MOB_PLANE - add_overlay(O) - if(has_buckled_mobs()) - for(var/A in buckled_mobs) - var/mob/living/L = A - L.set_dir(dir) - -/obj/structure/bed/chair/wheelchair/smallmotor/set_dir() - ..() - cut_overlays() - var/image/O = image(icon = 'icons/obj/wheelchair.dmi', icon_state = "teshchair_overlay", layer = ABOVE_MOB_LAYER, dir = src.dir) - O.plane = MOB_PLANE - add_overlay(O) - if(has_buckled_mobs()) - for(var/A in buckled_mobs) - var/mob/living/L = A - L.set_dir(dir) - -/obj/structure/bed/chair/wheelchair/motor/set_dir() - ..() - cut_overlays() - var/image/O = image(icon = 'icons/obj/wheelchair.dmi', icon_state = "motorchair_overlay", layer = ABOVE_MOB_LAYER, dir = src.dir) - O.plane = MOB_PLANE - add_overlay(O) - if(has_buckled_mobs()) - for(var/A in buckled_mobs) - var/mob/living/L = A - L.set_dir(dir) + . = ..() + if(.) + if(has_buckled_mobs()) + for(var/A in buckled_mobs) + var/mob/living/L = A + L.set_dir(dir) /obj/structure/bed/chair/wheelchair/attackby(obj/item/weapon/W as obj, mob/user as mob) if(W.is_wrench() || W.is_wirecutter() || istype(W,/obj/item/stack)) @@ -144,8 +126,6 @@ /obj/structure/bed/chair/wheelchair/Moved(atom/old_loc, direction, forced = FALSE) . = ..() - - cut_overlays() playsound(src, 'sound/effects/roll.ogg', 75, 1) if(has_buckled_mobs()) for(var/A in buckled_mobs) @@ -254,64 +234,13 @@ usr.pulledby = null ..() -/obj/item/wheelchair - name = "wheelchair" - desc = "A folded wheelchair that can be carried around." - icon = 'icons/obj/wheelchair.dmi' - icon_state = "wheelchair_folded" - item_state = "wheelchair" - w_class = ITEMSIZE_HUGE // Can't be put in backpacks. Oh well. - var/wheelchairtype = /obj/structure/bed/chair/wheelchair - var/wheelchairitemtype = /obj/item/wheelchair - -/obj/item/wheelchair/attack_self(mob/user) - var/obj/structure/bed/chair/wheelchair/R = new wheelchairtype(user.loc) - R.add_fingerprint(user) - R.name = src.name - R.color = src.color - qdel(src) - -/obj/item/smallmotorwheelchair // need it like this cause the spawning code for wheelchairs in the loadout is funky - name = "small electric wheelchair" - desc = "A small motorized wheelchair, it looks around the right size for a Teshari." - icon = 'icons/obj/wheelchair.dmi' - icon_state = "teshchair_folded" - item_state = "teshchair" - w_class = ITEMSIZE_HUGE // Can't be put in backpacks. Oh well. - var/wheelchairtype = /obj/structure/bed/chair/wheelchair/smallmotor - var/wheelchairitemtype = /obj/item/smallmotorwheelchair - -/obj/item/motorwheelchair - name = "electric wheelchair" - desc = "A motorized wheelchair controlled with a joystick on one armrest" - icon = 'icons/obj/wheelchair.dmi' - icon_state = "motorchair_folded" - item_state = "motorchair" - w_class = ITEMSIZE_HUGE // Can't be put in backpacks. Oh well. - var/wheelchairtype = /obj/structure/bed/chair/wheelchair/motor - var/wheelchairitemtype = /obj/item/motorwheelchair - -/obj/item/smallmotorwheelchair/attack_self(mob/user) - var/obj/structure/bed/chair/wheelchair/R = new wheelchairtype(user.loc) - R.add_fingerprint(user) - R.name = src.name - R.color = src.color - qdel(src) - -/obj/item/motorwheelchair/attack_self(mob/user) - var/obj/structure/bed/chair/wheelchair/R = new wheelchairtype(user.loc) - R.add_fingerprint(user) - R.name = src.name - R.color = src.color - qdel(src) - /obj/structure/bed/chair/wheelchair/MouseDrop(over_object, src_location, over_location) ..() if((over_object == usr && (in_range(src, usr) || usr.contents.Find(src)))) if(!ishuman(usr)) return if(has_buckled_mobs()) return 0 visible_message("[usr] collapses \the [src.name].") - var/obj/item/wheelchair/R = new wheelchairitemtype(get_turf(src)) + var/obj/item/wheelchair/R = new folded_type(get_turf(src)) R.name = src.name R.color = src.color spawn(0) diff --git a/code/game/objects/structures/stool_bed_chair_nest/wheelchair_item.dm b/code/game/objects/structures/stool_bed_chair_nest/wheelchair_item.dm new file mode 100644 index 0000000000..d18a9a88f1 --- /dev/null +++ b/code/game/objects/structures/stool_bed_chair_nest/wheelchair_item.dm @@ -0,0 +1,29 @@ +/obj/item/wheelchair + name = "wheelchair" + desc = "A folded wheelchair that can be carried around." + icon = 'icons/obj/wheelchair.dmi' + icon_state = "wheelchair_folded" + item_state = "wheelchair" + w_class = ITEMSIZE_HUGE // Can't be put in backpacks. Oh well. + var/unfolded_type = /obj/structure/bed/chair/wheelchair + +/obj/item/wheelchair/attack_self(mob/user) + var/obj/structure/bed/chair/wheelchair/R = new unfolded_type(user.loc) + R.add_fingerprint(user) + R.name = src.name + R.color = src.color + qdel(src) + +/obj/item/wheelchair/motor + name = "electric wheelchair" + desc = "A motorized wheelchair controlled with a joystick on one armrest" + icon_state = "motorchair_folded" + item_state = "motorchair" + unfolded_type = /obj/structure/bed/chair/wheelchair/motor + +/obj/item/wheelchair/motor/small + name = "small electric wheelchair" + desc = "A small motorized wheelchair, it looks around the right size for a Teshari." + icon_state = "teshchair_folded" + item_state = "teshchair" + unfolded_type = /obj/structure/bed/chair/wheelchair/smallmotor diff --git a/code/modules/client/preference_setup/loadout/loadout_utility.dm b/code/modules/client/preference_setup/loadout/loadout_utility.dm index f51662de14..1029a27376 100644 --- a/code/modules/client/preference_setup/loadout/loadout_utility.dm +++ b/code/modules/client/preference_setup/loadout/loadout_utility.dm @@ -158,15 +158,6 @@ display_name = "Fountain Pen" path = /obj/item/weapon/pen/fountain -/datum/gear/utility/wheelchair/color - display_name = "wheelchair" - path = /obj/item/wheelchair - cost = 4 - -/datum/gear/utility/wheelchair/color/New() - ..() - gear_tweaks += gear_tweak_free_color_choice - /datum/gear/utility/umbrella display_name = "Umbrella" path = /obj/item/weapon/melee/umbrella @@ -176,10 +167,19 @@ ..() gear_tweaks += gear_tweak_free_color_choice -/datum/gear/utility/motorchair - display_name = "electric wheelchair" - path = /obj/item/motorwheelchair +/datum/gear/utility/wheelchair + display_name = "wheelchair selection" + path = /obj/item/wheelchair cost = 4 + +/datum/gear/utility/wheelchair/New() + ..() + gear_tweaks += gear_tweak_free_color_choice + var/list/wheelchairs = list( + "wheelchair" = /obj/item/wheelchair, + "motorized wheelchair" = /obj/item/wheelchair/motor + ) + gear_tweaks += new/datum/gear_tweak/path(wheelchairs) /**************** modular computers diff --git a/code/modules/client/preference_setup/loadout/loadout_xeno.dm b/code/modules/client/preference_setup/loadout/loadout_xeno.dm index ce9b01f063..a04feb1d6b 100644 --- a/code/modules/client/preference_setup/loadout/loadout_xeno.dm +++ b/code/modules/client/preference_setup/loadout/loadout_xeno.dm @@ -673,7 +673,7 @@ /datum/gear/utility/teshchair display_name = "small electric wheelchair (Teshari)" - path = /obj/item/smallmotorwheelchair //can't use the normal wheelchair item cause of funky spawning code, it would just give you a normal wheelchair even if you selected a subtype + path = /obj/item/wheelchair/motor/small whitelisted = SPECIES_TESHARI sort_category = "Xenowear" - cost = 4 \ No newline at end of file + cost = 4 diff --git a/polaris.dme b/polaris.dme index 7a422151d6..f2899f577d 100644 --- a/polaris.dme +++ b/polaris.dme @@ -1295,6 +1295,7 @@ #include "code\game\objects\structures\stool_bed_chair_nest\chairs.dm" #include "code\game\objects\structures\stool_bed_chair_nest\stools.dm" #include "code\game\objects\structures\stool_bed_chair_nest\wheelchair.dm" +#include "code\game\objects\structures\stool_bed_chair_nest\wheelchair_item.dm" #include "code\game\turfs\simulated.dm" #include "code\game\turfs\turf.dm" #include "code\game\turfs\turf_changing.dm"