Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Motorized Wheelchair improvements #1147

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/datums/components/crafting/equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
/obj/item/stack/rods = 8,
/obj/item/stock_parts/servo = 2,
/obj/item/stock_parts/capacitor = 1,
/obj/item/stock_parts/cell = 1,
)
parts = list(
/obj/item/stock_parts/servo = 2,
/obj/item/stock_parts/capacitor = 1,
/obj/item/stock_parts/cell = 1,
)
tool_behaviors = list(TOOL_WELDER, TOOL_SCREWDRIVER, TOOL_WRENCH)
time = 20 SECONDS
Expand Down
7 changes: 2 additions & 5 deletions code/datums/components/riding/riding_vehicle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,9 @@
return ..()

/datum/component/riding/vehicle/wheelchair/motorized/driver_move(obj/vehicle/vehicle_parent, mob/living/user, direction)
var/speed = 1 // Should never be under 1
var/delay_multiplier = 6.7 // magic number from wheelchair code

var/obj/vehicle/ridden/wheelchair/motorized/our_chair = parent
for(var/datum/stock_part/servo/servo in our_chair.component_parts)
speed += servo.tier
var/speed = our_chair.speed
var/delay_multiplier = our_chair.delay_multiplier
vehicle_move_delay = round(CONFIG_GET(number/movedelay/run_delay) * delay_multiplier) / speed
return ..()

Expand Down
80 changes: 52 additions & 28 deletions code/modules/vehicles/motorized_wheelchair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,30 @@
///stock parts for this chair
var/list/component_parts = list()

/obj/vehicle/ridden/wheelchair/motorized/Initialize(mapload)
. = ..()
// Add tier 1 stock parts so that non-crafted wheelchairs aren't empty
component_parts += GLOB.stock_part_datums[/datum/stock_part/capacitor]
component_parts += GLOB.stock_part_datums[/datum/stock_part/servo]
component_parts += GLOB.stock_part_datums[/datum/stock_part/servo]
power_cell = new /obj/item/stock_parts/cell(src)
refresh_parts()

/obj/vehicle/ridden/wheelchair/motorized/make_ridable()
AddElement(/datum/element/ridable, /datum/component/riding/vehicle/wheelchair/motorized)

/obj/vehicle/ridden/wheelchair/motorized/CheckParts(list/parts_list)
// This wheelchair was crafted, so clean out default parts
qdel(power_cell)
component_parts = list()

for(var/obj/item/stock_parts/part in parts_list)
// find macthing datum/stock_part for this part and add to component list
if(istype(part, /obj/item/stock_parts/cell)) // power cell, physically moves into the wheelchair
power_cell = part
part.forceMove(src)
continue

// find matching datum/stock_part for this part and add to component list
var/datum/stock_part/newstockpart = GLOB.stock_part_datums_per_object[part.type]
if(isnull(newstockpart))
CRASH("No corresponding datum/stock_part for [part.type]")
Expand Down Expand Up @@ -58,6 +76,9 @@
/obj/vehicle/ridden/wheelchair/motorized/atom_destruction(damage_flag)
for(var/datum/stock_part/part in component_parts)
new part.physical_object_type(drop_location())
if(!isnull(power_cell))
power_cell.forceMove(drop_location())
power_cell = null
return ..()

/obj/vehicle/ridden/wheelchair/motorized/relaymove(mob/living/user, direction)
Expand All @@ -81,28 +102,23 @@
user.put_in_hands(power_cell)
power_cell = null

/obj/vehicle/ridden/wheelchair/motorized/attackby(obj/item/I, mob/user, params)
if(I.tool_behaviour == TOOL_SCREWDRIVER)
I.play_tool_sound(src)
panel_open = !panel_open
user.visible_message(span_notice("[user] [panel_open ? "opens" : "closes"] the maintenance panel on [src]."), span_notice("You [panel_open ? "open" : "close"] the maintenance panel."))
return
/obj/vehicle/ridden/wheelchair/motorized/attackby(obj/item/attacking_item, mob/user, params)
if(!panel_open)
return ..()

if(istype(I, /obj/item/stock_parts/cell))
if(istype(attacking_item, /obj/item/stock_parts/cell))
if(power_cell)
to_chat(user, span_warning("There is a power cell already installed."))
else
I.forceMove(src)
power_cell = I
to_chat(user, span_notice("You install the [I]."))
attacking_item.forceMove(src)
power_cell = attacking_item
to_chat(user, span_notice("You install the [attacking_item]."))
refresh_parts()
return
if(!istype(I, /obj/item/stock_parts))
if(!istype(attacking_item, /obj/item/stock_parts))
return ..()

var/datum/stock_part/newstockpart = GLOB.stock_part_datums_per_object[I.type]
var/datum/stock_part/newstockpart = GLOB.stock_part_datums_per_object[attacking_item.type]
if(isnull(newstockpart))
CRASH("No corresponding datum/stock_part for [newstockpart.type]")
for(var/datum/stock_part/oldstockpart in component_parts)
Expand All @@ -114,8 +130,7 @@
if(istype(newstockpart, type_to_check) && istype(oldstockpart, type_to_check))
if(newstockpart.tier > oldstockpart.tier)
// delete the part in the users hand and add the datum part to the component_list
I.moveToNullspace()
qdel(I)
qdel(attacking_item)
component_parts += newstockpart
// create an new instance of the old datum stock part physical type & put it in the users hand
var/obj/item/stock_parts/part = new oldstockpart.physical_object_type
Expand All @@ -126,17 +141,26 @@
break
refresh_parts()

/obj/vehicle/ridden/wheelchair/motorized/wrench_act(mob/living/user, obj/item/I)
to_chat(user, span_notice("You begin to detach the wheels..."))
if(!I.use_tool(src, user, 40, volume=50))
return TRUE
/obj/vehicle/ridden/wheelchair/motorized/wrench_act(mob/living/user, obj/item/tool)
balloon_alert(user, "disassembling")
if(!tool.use_tool(src, user, 4 SECONDS, volume=50))
return ITEM_INTERACT_SUCCESS
to_chat(user, span_notice("You detach the wheels and deconstruct the chair."))
new /obj/item/stack/rods(drop_location(), 8)
new /obj/item/stack/sheet/iron(drop_location(), 10)
for(var/datum/stock_part/part in component_parts)
new part.physical_object_type(drop_location())
if(!isnull(power_cell))
power_cell.forceMove(drop_location())
power_cell = null
qdel(src)
return TRUE
return ITEM_INTERACT_SUCCESS

/obj/vehicle/ridden/wheelchair/motorized/screwdriver_act(mob/living/user, obj/item/tool)
tool.play_tool_sound(src)
panel_open = !panel_open
user.visible_message(span_notice("[user] [panel_open ? "opens" : "closes"] the maintenance panel on [src]."), span_notice("You [panel_open ? "open" : "close"] the maintenance panel."))
return ITEM_INTERACT_SUCCESS

/obj/vehicle/ridden/wheelchair/motorized/examine(mob/user)
. = ..()
Expand All @@ -159,30 +183,30 @@
if(!(guy in buckled_mobs))
Bump(guy)

/obj/vehicle/ridden/wheelchair/motorized/Bump(atom/A)
/obj/vehicle/ridden/wheelchair/motorized/Bump(atom/bumped_atom)
. = ..()
// Here is the shitty emag functionality.
if(obj_flags & EMAGGED && (isclosedturf(A) || isliving(A)))
if(obj_flags & EMAGGED && (isclosedturf(bumped_atom) || isliving(bumped_atom)))
explosion(src, devastation_range = -1, heavy_impact_range = 1, light_impact_range = 3, flash_range = 2, adminlog = FALSE)
visible_message(span_boldwarning("[src] explodes!!"))
return
// If the speed is higher than delay_multiplier throw the person on the wheelchair away
if(A.density && speed > delay_multiplier && has_buckled_mobs())
if(bumped_atom.density && speed > delay_multiplier && has_buckled_mobs())
var/mob/living/disabled = buckled_mobs[1]
var/atom/throw_target = get_edge_target_turf(disabled, pick(GLOB.cardinals))
unbuckle_mob(disabled)
disabled.throw_at(throw_target, 2, 3)
disabled.Knockdown(100)
disabled.Knockdown(10 SECONDS)
disabled.adjustStaminaLoss(40)
if(isliving(A))
var/mob/living/ramtarget = A
if(isliving(bumped_atom))
var/mob/living/ramtarget = bumped_atom
throw_target = get_edge_target_turf(ramtarget, pick(GLOB.cardinals))
ramtarget.throw_at(throw_target, 2, 3)
ramtarget.Knockdown(80)
ramtarget.Knockdown(8 SECONDS)
ramtarget.adjustStaminaLoss(35)
visible_message(span_danger("[src] crashes into [ramtarget], sending [disabled] and [ramtarget] flying!"))
else
visible_message(span_danger("[src] crashes into [A], sending [disabled] flying!"))
visible_message(span_danger("[src] crashes into [bumped_atom], sending [disabled] flying!"))
playsound(src, 'sound/effects/bang.ogg', 50, 1)

/obj/vehicle/ridden/wheelchair/motorized/emag_act(mob/user, obj/item/card/emag/emag_card)
Expand Down
17 changes: 9 additions & 8 deletions code/modules/vehicles/wheelchair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@
. = ..()
update_appearance()

/obj/vehicle/ridden/wheelchair/wrench_act(mob/living/user, obj/item/I) //Attackby should stop it attacking the wheelchair after moving away during decon
/obj/vehicle/ridden/wheelchair/wrench_act(mob/living/user, obj/item/tool) //Attackby should stop it attacking the wheelchair after moving away during decon
..()
to_chat(user, span_notice("You begin to detach the wheels..."))
if(I.use_tool(src, user, 40, volume=50))
to_chat(user, span_notice("You detach the wheels and deconstruct the chair."))
new /obj/item/stack/rods(drop_location(), 6)
new /obj/item/stack/sheet/iron(drop_location(), 4)
qdel(src)
return TRUE
balloon_alert(user, "disassembling")
if(!tool.use_tool(src, user, 4 SECONDS, volume=50))
return ITEM_INTERACT_SUCCESS
to_chat(user, span_notice("You detach the wheels and deconstruct the chair."))
new /obj/item/stack/rods(drop_location(), 6)
new /obj/item/stack/sheet/iron(drop_location(), 4)
qdel(src)
return ITEM_INTERACT_SUCCESS

/obj/vehicle/ridden/wheelchair/AltClick(mob/user)
return ..() // This hotkey is BLACKLISTED since it's used by /datum/component/simple_rotation
Expand Down
Loading