Converts vehicles to use item_interaction/tool_acts (#95399)

## About The Pull Request

More attackby()s gone

## Changelog
🆑
refactor: Converted vehicles to use item_interaction/tool_acts
/🆑
This commit is contained in:
SmArtKar
2026-03-15 20:34:49 +00:00
committed by GitHub
parent 0009cf22e5
commit c3fdebbe4f
8 changed files with 169 additions and 122 deletions
@@ -339,11 +339,11 @@
log_message("Deactivated.", LOG_MECHA)
return TRUE
/obj/item/mecha_parts/mecha_equipment/generator/attackby(obj/item/weapon, mob/user, list/modifiers, list/attack_modifiers)
. = ..()
if(!istype(weapon, fuel))
return FALSE
load_fuel(weapon, user)
/obj/item/mecha_parts/mecha_equipment/generator/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(istype(tool, fuel))
load_fuel(tool, user)
return ITEM_INTERACT_SUCCESS
return NONE
/obj/item/mecha_parts/mecha_equipment/generator/process(seconds_per_tick)
if(!chassis)
+12 -8
View File
@@ -76,17 +76,21 @@
recharge_console.update_appearance()
/obj/machinery/mech_bay_recharge_port/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers)
if(default_deconstruction_screwdriver(user, "recharge_port-o", "recharge_port", I))
return
/obj/machinery/mech_bay_recharge_port/screwdriver_act(mob/living/user, obj/item/tool)
if(default_deconstruction_screwdriver(user, "recharge_port-o", "recharge_port", tool))
return ITEM_INTERACT_SUCCESS
return NONE
if(default_change_direction_wrench(user, I))
/obj/machinery/mech_bay_recharge_port/wrench_act(mob/living/user, obj/item/tool)
if(default_change_direction_wrench(user, tool))
recharging_turf = get_step(loc, dir)
return
return ITEM_INTERACT_SUCCESS
return NONE
if(default_deconstruction_crowbar(I))
return
return ..()
/obj/machinery/mech_bay_recharge_port/crowbar_act(mob/living/user, obj/item/tool)
if(default_deconstruction_crowbar(tool))
return ITEM_INTERACT_SUCCESS
return NONE
/obj/machinery/computer/mech_bay_power_console
name = "mech bay power control console"
+38 -25
View File
@@ -98,44 +98,57 @@
user.put_in_hands(power_cell)
power_cell = null
/obj/vehicle/ridden/wheelchair/motorized/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers)
if(!panel_open)
return ..()
/obj/vehicle/ridden/wheelchair/motorized/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
. = ..()
if(.)
return
if(istype(attacking_item, /obj/item/stock_parts/power_store/cell))
if(!panel_open || user.combat_mode)
return NONE
if(istype(tool, /obj/item/stock_parts/power_store/cell))
if(power_cell)
to_chat(user, span_warning("There is a power cell already installed."))
else
attacking_item.forceMove(src)
power_cell = attacking_item
to_chat(user, span_notice("You install the [attacking_item]."))
refresh_parts()
return
if(!istype(attacking_item, /obj/item/stock_parts))
return ..()
return ITEM_INTERACT_BLOCKING
var/datum/stock_part/newstockpart = GLOB.stock_part_datums_per_object[attacking_item.type]
tool.forceMove(src)
power_cell = tool
to_chat(user, span_notice("You install the [tool]."))
refresh_parts()
return ITEM_INTERACT_SUCCESS
if(!istype(tool, /obj/item/stock_parts))
return NONE
var/datum/stock_part/newstockpart = GLOB.stock_part_datums_per_object[tool.type]
if(isnull(newstockpart))
CRASH("No corresponding datum/stock_part for [newstockpart.type]")
var/replacement_occured = FALSE
for(var/datum/stock_part/oldstockpart in component_parts)
var/type_to_check
for(var/pathtype in required_parts)
if(ispath(oldstockpart.type, pathtype))
type_to_check = pathtype
break
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
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
user.put_in_hands(part)
component_parts -= oldstockpart
// user message
user.visible_message(span_notice("[user] replaces [oldstockpart.name()] with [newstockpart.name()] in [src]."), span_notice("You replace [oldstockpart.name()] with [newstockpart.name()]."))
break
if(!istype(newstockpart, type_to_check) || !istype(oldstockpart, type_to_check) || newstockpart.tier <= oldstockpart.tier)
continue
// delete the part in the users hand and add the datum part to the component_list
qdel(tool)
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
user.put_in_hands(part)
component_parts -= oldstockpart
// user message
user.visible_message(span_notice("[user] replaces [oldstockpart.name()] with [newstockpart.name()] in [src]."), span_notice("You replace [oldstockpart.name()] with [newstockpart.name()]."))
replacement_occured = TRUE
break
refresh_parts()
return replacement_occured ? ITEM_INTERACT_SUCCESS : ITEM_INTERACT_BLOCKING
/obj/vehicle/ridden/wheelchair/motorized/handle_deconstruct(disassembled)
. = ..()
+34 -21
View File
@@ -34,39 +34,52 @@
if (installed_upgrade)
. += "It has been upgraded with [installed_upgrade], which can be removed with a screwdriver."
/obj/vehicle/ridden/janicart/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers)
if(istype(I, /obj/item/storage/bag/trash))
/obj/vehicle/ridden/janicart/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
. = ..()
if(.)
return
if(istype(tool, /obj/item/storage/bag/trash))
if(trash_bag)
to_chat(user, span_warning("[src] already has a trashbag hooked!"))
return
if(!user.transferItemToLoc(I, src))
return
return ITEM_INTERACT_BLOCKING
if(!user.transferItemToLoc(tool, src))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You hook the trashbag onto [src]."))
trash_bag = I
trash_bag = tool
RegisterSignal(trash_bag, COMSIG_QDELETING, PROC_REF(bag_deleted))
SEND_SIGNAL(src, COMSIG_VACUUM_BAG_ATTACH, I)
SEND_SIGNAL(src, COMSIG_VACUUM_BAG_ATTACH, tool)
update_appearance()
else if(istype(I, /obj/item/janicart_upgrade))
return ITEM_INTERACT_SUCCESS
if(istype(tool, /obj/item/janicart_upgrade))
if(installed_upgrade)
to_chat(user, span_warning("[src] already has an upgrade installed! Use a screwdriver to remove it."))
return
var/obj/item/janicart_upgrade/new_upgrade = I
return ITEM_INTERACT_BLOCKING
var/obj/item/janicart_upgrade/new_upgrade = tool
new_upgrade.forceMove(src)
new_upgrade.install(src)
installed_upgrade = new_upgrade
to_chat(user, span_notice("You upgrade [src] with [new_upgrade]."))
update_appearance()
else if (istype(I, /obj/item/screwdriver) && installed_upgrade)
installed_upgrade.uninstall(src)
installed_upgrade.forceMove(get_turf(user))
user.put_in_hands(installed_upgrade)
to_chat(user, span_notice("You remove [installed_upgrade] from [src]"))
installed_upgrade = null
update_appearance()
else if(trash_bag && (!is_key(I) || is_key(inserted_key))) // don't put a key in the trash when we need it
trash_bag.atom_storage.attempt_insert(I, user)
else
return ..()
return ITEM_INTERACT_SUCCESS
if(trash_bag && (!is_key(tool) || is_key(inserted_key))) // don't put a key in the trash when we need it
trash_bag.atom_storage.attempt_insert(tool, user)
return ITEM_INTERACT_SUCCESS
return NONE
/obj/vehicle/ridden/janicart/screwdriver_act(mob/living/user, obj/item/tool)
if (!installed_upgrade)
return ITEM_INTERACT_BLOCKING
installed_upgrade.uninstall(src)
installed_upgrade.forceMove(get_turf(user))
user.put_in_hands(installed_upgrade)
to_chat(user, span_notice("You remove [installed_upgrade] from [src]"))
installed_upgrade = null
update_appearance()
return ITEM_INTERACT_SUCCESS
/obj/vehicle/ridden/janicart/update_overlays()
. = ..()
+9 -8
View File
@@ -29,16 +29,17 @@
add_occupant(M)
return ..()
/obj/vehicle/ridden/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers)
if(!key_type || is_key(inserted_key) || !is_key(I))
return ..()
if(!user.transferItemToLoc(I, src))
to_chat(user, span_warning("[I] seems to be stuck to your hand!"))
return
to_chat(user, span_notice("You insert \the [I] into \the [src]."))
/obj/vehicle/ridden/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(!key_type || is_key(inserted_key) || !is_key(tool))
return NONE
if(!user.transferItemToLoc(tool, src))
to_chat(user, span_warning("[tool] seems to be stuck to your hand!"))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You insert \the [tool] into \the [src]."))
if(inserted_key) //just in case there's an invalid key
inserted_key.forceMove(drop_location())
inserted_key = I
inserted_key = tool
return ITEM_INTERACT_SUCCESS
/obj/vehicle/ridden/click_alt(mob/user)
if(!inserted_key)
+28 -24
View File
@@ -12,10 +12,10 @@
/obj/vehicle/ridden/scooter/proc/make_ridable()
AddElement(/datum/element/ridable, /datum/component/riding/vehicle/scooter)
/obj/vehicle/ridden/scooter/wrench_act(mob/living/user, obj/item/I)
/obj/vehicle/ridden/scooter/wrench_act(mob/living/user, obj/item/tool)
..()
to_chat(user, span_notice("You begin to remove the handlebars..."))
if(!I.use_tool(src, user, 40, volume=50))
if(!tool.use_tool(src, user, 40, volume=50))
return TRUE
var/obj/vehicle/ridden/scooter/skateboard/improvised/skater = new(drop_location())
new /obj/item/stack/rods(drop_location(), 2)
@@ -248,37 +248,40 @@
w_class = WEIGHT_CLASS_NORMAL
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 5)
/obj/item/scooter_frame/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers)
if(!istype(I, /obj/item/stack/sheet/iron))
return ..()
if(!I.tool_start_check(user, amount=5))
return
/obj/item/scooter_frame/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(!istype(tool, /obj/item/stack/sheet/iron))
return NONE
if(!tool.tool_start_check(user, amount=5))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You begin to add wheels to [src]."))
if(!I.use_tool(src, user, 80, volume=50, amount=5))
return
if(!tool.use_tool(src, user, 80, volume = 50, amount = 5))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You finish making wheels for [src]."))
new /obj/vehicle/ridden/scooter/skateboard/improvised(user.loc)
qdel(src)
return ITEM_INTERACT_SUCCESS
/obj/item/scooter_frame/wrench_act(mob/living/user, obj/item/I)
..()
/obj/item/scooter_frame/wrench_act(mob/living/user, obj/item/tool)
to_chat(user, span_notice("You deconstruct [src]."))
new /obj/item/stack/rods(drop_location(), 10)
I.play_tool_sound(src)
tool.play_tool_sound(src)
qdel(src)
return TRUE
return ITEM_INTERACT_SUCCESS
/obj/vehicle/ridden/scooter/skateboard/wrench_act(mob/living/user, obj/item/I)
/obj/vehicle/ridden/scooter/skateboard/wrench_act(mob/living/user, obj/item/tool)
return
/obj/vehicle/ridden/scooter/skateboard/improvised/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers)
if(!istype(I, /obj/item/stack/rods))
return ..()
if(!I.tool_start_check(user, amount=2))
/obj/vehicle/ridden/scooter/skateboard/improvised/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
. = ..()
if (.)
return
if(!istype(tool, /obj/item/stack/rods))
return NONE
if(!tool.tool_start_check(user, amount=2))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You begin making handlebars for [src]."))
if(!I.use_tool(src, user, 25, volume=50, amount=2))
return
if(!tool.use_tool(src, user, 25, volume=50, amount=2))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You add the rods to [src], creating handlebars."))
var/obj/vehicle/ridden/scooter/skaterskoot = new(loc)
if(has_buckled_mobs())
@@ -286,14 +289,15 @@
unbuckle_mob(skaterboy)
skaterskoot.buckle_mob(skaterboy)
qdel(src)
return ITEM_INTERACT_SUCCESS
/obj/vehicle/ridden/scooter/skateboard/improvised/screwdriver_act(mob/living/user, obj/item/I)
/obj/vehicle/ridden/scooter/skateboard/improvised/screwdriver_act(mob/living/user, obj/item/tool)
. = ..()
if(.)
return
to_chat(user, span_notice("You begin to deconstruct and remove the wheels on [src]..."))
if(!I.use_tool(src, user, 20, volume=50))
return
if(!tool.use_tool(src, user, 20, volume=50))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You deconstruct the wheels on [src]."))
new /obj/item/stack/sheet/iron(drop_location(), 5)
new /obj/item/scooter_frame(drop_location())
@@ -301,7 +305,7 @@
var/mob/living/carbon/skatergirl = buckled_mobs[1]
unbuckle_mob(skatergirl)
qdel(src)
return TRUE
return ITEM_INTERACT_SUCCESS
//Wheelys
/obj/vehicle/ridden/scooter/skateboard/wheelys
+14 -12
View File
@@ -108,18 +108,20 @@
/obj/vehicle/sealed/proc/exit_location(M)
return drop_location()
/obj/vehicle/sealed/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers)
if(key_type && !is_key(inserted_key) && is_key(I))
if(user.transferItemToLoc(I, src))
to_chat(user, span_notice("You insert [I] into [src]."))
if(inserted_key) //just in case there's an invalid key
inserted_key.forceMove(drop_location())
inserted_key = I
inserted_key.forceMove(src)
else
to_chat(user, span_warning("[I] seems to be stuck to your hand!"))
return
return ..()
/obj/vehicle/sealed/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(!key_type || is_key(inserted_key) || !is_key(tool))
return NONE
if(!user.transferItemToLoc(tool, src))
to_chat(user, span_warning("[tool] seems to be stuck to your hand!"))
return ITEM_INTERACT_BLOCKING
to_chat(user, span_notice("You insert [tool] into [src]."))
if(inserted_key) // Just in case there's an invalid key
inserted_key.forceMove(drop_location())
inserted_key = tool
inserted_key.forceMove(src)
return ITEM_INTERACT_SUCCESS
/obj/vehicle/sealed/proc/remove_key(mob/user)
if(!inserted_key)
+29 -19
View File
@@ -32,44 +32,54 @@
return
do_smoke(0, src, src)
/obj/vehicle/ridden/secway/welder_act(mob/living/user, obj/item/W)
/obj/vehicle/ridden/secway/welder_act(mob/living/user, obj/item/tool)
if(user.combat_mode)
return
. = TRUE
return NONE
if(DOING_INTERACTION(user, src))
balloon_alert(user, "you're already repairing it!")
return
return ITEM_INTERACT_BLOCKING
if(atom_integrity >= max_integrity)
balloon_alert(user, "it's not damaged!")
return
if(!W.tool_start_check(user, amount=1, heat_required = HIGH_TEMPERATURE_REQUIRED))
return
return ITEM_INTERACT_BLOCKING
if(!tool.tool_start_check(user, amount=1, heat_required = HIGH_TEMPERATURE_REQUIRED))
return ITEM_INTERACT_BLOCKING
user.balloon_alert_to_viewers("started welding [src]", "started repairing [src]")
audible_message(span_hear("You hear welding."))
var/did_the_thing
while(atom_integrity < max_integrity)
if(W.use_tool(src, user, 2.5 SECONDS, volume=50))
if(tool.use_tool(src, user, 2.5 SECONDS, volume=50))
did_the_thing = TRUE
atom_integrity += min(10, (max_integrity - atom_integrity))
audible_message(span_hear("You hear welding."))
else
break
if(did_the_thing)
user.balloon_alert_to_viewers("[(atom_integrity >= max_integrity) ? "fully" : "partially"] repaired [src]")
else
user.balloon_alert_to_viewers("stopped welding [src]", "interrupted the repair!")
return ITEM_INTERACT_SUCCESS
/obj/vehicle/ridden/secway/attackby(obj/item/W, mob/living/user, list/modifiers, list/attack_modifiers)
if(!istype(W, /obj/item/food/grown/banana))
return ..()
user.balloon_alert_to_viewers("stopped welding [src]", "interrupted the repair!")
return ITEM_INTERACT_BLOCKING
/obj/vehicle/ridden/secway/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
. = ..()
if(.)
return
if(!istype(tool, /obj/item/food/grown/banana))
return NONE
// ignore the occupants because they're presumably too distracted to notice the guy stuffing fruit into their vehicle's exhaust. do segways have exhausts? they do now!
user.visible_message(span_warning("[user] begins stuffing [W] into [src]'s tailpipe."), span_warning("You begin stuffing [W] into [src]'s tailpipe..."), ignored_mobs = occupants)
user.visible_message(span_warning("[user] begins stuffing [tool] into [src]'s tailpipe."), span_warning("You begin stuffing [tool] into [src]'s tailpipe..."), ignored_mobs = occupants)
if(!do_after(user, 3 SECONDS, src))
return TRUE
if(user.transferItemToLoc(W, src))
user.visible_message(span_warning("[user] stuffs [W] into [src]'s tailpipe."), span_warning("You stuff [W] into [src]'s tailpipe."), ignored_mobs = occupants)
eddie_murphy = W
return TRUE
return ITEM_INTERACT_BLOCKING
if(!user.transferItemToLoc(tool, src))
return ITEM_INTERACT_BLOCKING
user.visible_message(span_warning("[user] stuffs [tool] into [src]'s tailpipe."), span_warning("You stuff [tool] into [src]'s tailpipe."), ignored_mobs = occupants)
eddie_murphy = tool
return ITEM_INTERACT_SUCCESS
/obj/vehicle/ridden/secway/attack_hand(mob/living/user, list/modifiers)
if(!eddie_murphy)