From afc1e44ee2922a316feb958249f7806568953bbe Mon Sep 17 00:00:00 2001 From: Luc <89928798+lewcc@users.noreply.github.com> Date: Mon, 7 Mar 2022 17:43:22 -0500 Subject: [PATCH] Tool act superpack 2 (#64428) About The Pull Request Continuation of #64375, extracting tool behavior from attackby() and moving it into discrete _act procs. This is about as many files as I had in the last version, as I still want this to be reviewable. As before, I've tested everything in game and it works as it previously did. Why It's Good For The Game The more code moved out of attackby, the more modular things become. Changelog cl refactor: Moves more tool behavior out of attackby(). /cl --- code/game/machinery/doors/door.dm | 57 +++++---- code/game/machinery/doors/firedoor.dm | 49 ++++---- code/game/objects/items/tools/weldingtool.dm | 7 +- code/game/objects/items/wall_mounted.dm | 30 ++--- code/game/objects/structures/barsigns.dm | 43 ++++--- code/game/objects/structures/bedsheet_bin.dm | 29 ++--- code/game/objects/structures/false_walls.dm | 51 ++++---- code/game/objects/structures/grille.dm | 44 ++++--- code/game/objects/structures/reflector.dm | 111 +++++++++--------- code/game/objects/structures/showcase.dm | 39 +++--- code/game/objects/structures/tables_racks.dm | 30 +++-- code/game/objects/structures/window.dm | 96 +++++++++------ .../abductor/equipment/abduction_gear.dm | 7 +- .../binary_devices/thermomachine.dm | 66 ++++++----- .../components/unary_devices/cryo.dm | 32 +++-- .../clothing/spacesuits/_spacesuits.dm | 48 ++++---- .../mob/living/simple_animal/bot/bot.dm | 40 ++++--- .../mob/living/simple_animal/bot/mulebot.dm | 38 +++--- .../friendly/drone/interaction.dm | 52 ++++---- .../modular_computers/hardware/ai_slot.dm | 11 +- .../modular_computers/hardware/card_slot.dm | 18 ++- code/modules/paperwork/paper_cutter.dm | 13 +- code/modules/photography/photos/frame.dm | 59 ++++++---- 23 files changed, 542 insertions(+), 428 deletions(-) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 461938288ef..0dc7421913c 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -245,38 +245,43 @@ /obj/machinery/door/proc/try_to_crowbar_secondary(obj/item/acting_object, mob/user) return +/obj/machinery/door/welder_act(mob/living/user, obj/item/tool) + try_to_weld(tool, user) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/machinery/door/crowbar_act(mob/living/user, obj/item/tool) + if(user.combat_mode) + return + + var/forced_open = FALSE + if(istype(tool, /obj/item/crowbar)) + var/obj/item/crowbar/crowbar = tool + forced_open = crowbar.force_opens + try_to_crowbar(tool, user, forced_open) + return TOOL_ACT_TOOLTYPE_SUCCESS + /obj/machinery/door/attackby(obj/item/I, mob/living/user, params) - if(!user.combat_mode && (I.tool_behaviour == TOOL_CROWBAR || istype(I, /obj/item/fireaxe))) - var/forced_open = FALSE - if(istype(I, /obj/item/crowbar)) - var/obj/item/crowbar/C = I - forced_open = C.force_opens - try_to_crowbar(I, user, forced_open) + if(!user.combat_mode && istype(I, /obj/item/fireaxe)) + try_to_crowbar(I, user, FALSE) return TRUE - else if(I.tool_behaviour == TOOL_WELDER) - try_to_weld(I, user, params) - return TRUE - else if((!(I.item_flags & NOBLUDGEON) && !user.combat_mode) && try_to_activate_door(user)) + else if(I.item_flags & NOBLUDGEON || user.combat_mode) + return FALSE + + else if(try_to_activate_door(user)) return TRUE return ..() -/obj/machinery/door/attackby_secondary(obj/item/weapon, mob/user, params) - if (weapon.tool_behaviour == TOOL_WELDER) - try_to_weld_secondary(weapon, user) +/obj/machinery/door/welder_act_secondary(mob/living/user, obj/item/tool) + try_to_weld_secondary(tool, user) + return TOOL_ACT_TOOLTYPE_SUCCESS - return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN - - if (weapon.tool_behaviour == TOOL_CROWBAR) - var/forced_open = FALSE - if(istype(weapon, /obj/item/crowbar)) - var/obj/item/crowbar/crowbar = weapon - forced_open = crowbar.force_opens - try_to_crowbar_secondary(weapon, user, forced_open) - - return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN - - ..() - return SECONDARY_ATTACK_CONTINUE_CHAIN +/obj/machinery/door/crowbar_act_secondary(mob/living/user, obj/item/tool) + var/forced_open = FALSE + if(istype(tool, /obj/item/crowbar)) + var/obj/item/crowbar/crowbar = tool + forced_open = crowbar.force_opens + try_to_crowbar_secondary(tool, user, forced_open) + return TOOL_ACT_TOOLTYPE_SUCCESS /obj/machinery/door/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, attack_dir) . = ..() diff --git a/code/game/machinery/doors/firedoor.dm b/code/game/machinery/doors/firedoor.dm index 8e5f7a1a80c..af18288d553 100644 --- a/code/game/machinery/doors/firedoor.dm +++ b/code/game/machinery/doors/firedoor.dm @@ -331,32 +331,33 @@ span_warning("You bash [src]!")) playsound(src, bash_sound, 100, TRUE) -/obj/machinery/door/firedoor/attackby(obj/item/C, mob/user, params) +/obj/machinery/door/firedoor/wrench_act(mob/living/user, obj/item/tool) add_fingerprint(user) - if(operating) - return - if(welded) - if(C.tool_behaviour == TOOL_WRENCH) - if(boltslocked) - to_chat(user, span_notice("There are screws locking the bolts in place!")) - return - C.play_tool_sound(src) - user.visible_message(span_notice("[user] starts undoing [src]'s bolts..."), \ - span_notice("You start unfastening [src]'s floor bolts...")) - if(!C.use_tool(src, user, DEFAULT_STEP_TIME)) - return - playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) - user.visible_message(span_notice("[user] unfastens [src]'s bolts."), \ - span_notice("You undo [src]'s floor bolts.")) - deconstruct(TRUE) - return - if(C.tool_behaviour == TOOL_SCREWDRIVER) - user.visible_message(span_notice("[user] [boltslocked ? "unlocks" : "locks"] [src]'s bolts."), \ + if(operating || !welded) + return FALSE + + if(boltslocked) + to_chat(user, span_notice("There are screws locking the bolts in place!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + tool.play_tool_sound(src) + user.visible_message(span_notice("[user] starts undoing [src]'s bolts..."), \ + span_notice("You start unfastening [src]'s floor bolts...")) + if(!tool.use_tool(src, user, DEFAULT_STEP_TIME)) + return TOOL_ACT_TOOLTYPE_SUCCESS + playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) + user.visible_message(span_notice("[user] unfastens [src]'s bolts."), \ + span_notice("You undo [src]'s floor bolts.")) + deconstruct(TRUE) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/machinery/door/firedoor/screwdriver_act(mob/living/user, obj/item/tool) + if(operating || !welded) + return FALSE + user.visible_message(span_notice("[user] [boltslocked ? "unlocks" : "locks"] [src]'s bolts."), \ span_notice("You [boltslocked ? "unlock" : "lock"] [src]'s floor bolts.")) - C.play_tool_sound(src) - boltslocked = !boltslocked - return - return ..() + tool.play_tool_sound(src) + boltslocked = !boltslocked + return TOOL_ACT_TOOLTYPE_SUCCESS /obj/machinery/door/firedoor/try_to_activate_door(mob/user, access_bypass = FALSE) return diff --git a/code/game/objects/items/tools/weldingtool.dm b/code/game/objects/items/tools/weldingtool.dm index 1f6e7e3d4fb..ff1358f9a71 100644 --- a/code/game/objects/items/tools/weldingtool.dm +++ b/code/game/objects/items/tools/weldingtool.dm @@ -98,11 +98,12 @@ user.visible_message(span_suicide("[user] welds [user.p_their()] every orifice closed! It looks like [user.p_theyre()] trying to commit suicide!")) return (FIRELOSS) +/obj/item/weldingtool/screwdriver_act(mob/living/user, obj/item/tool) + flamethrower_screwdriver(tool, user) + return TOOL_ACT_TOOLTYPE_SUCCESS /obj/item/weldingtool/attackby(obj/item/tool, mob/user, params) - if(tool.tool_behaviour == TOOL_SCREWDRIVER) - flamethrower_screwdriver(tool, user) - else if(istype(tool, /obj/item/stack/rods)) + if(istype(tool, /obj/item/stack/rods)) flamethrower_rods(tool, user) else . = ..() diff --git a/code/game/objects/items/wall_mounted.dm b/code/game/objects/items/wall_mounted.dm index 1a5610a6726..c9db09c50db 100644 --- a/code/game/objects/items/wall_mounted.dm +++ b/code/game/objects/items/wall_mounted.dm @@ -58,24 +58,26 @@ /obj/item/wallframe/proc/after_attach(obj/O) transfer_fingerprints_to(O) -/obj/item/wallframe/attackby(obj/item/W, mob/user, params) - ..() - if(W.tool_behaviour == TOOL_SCREWDRIVER) - // For camera-building borgs - var/turf/T = get_step(get_turf(user), user.dir) - if(iswallturf(T)) - T.attackby(src, user, params) +/obj/item/wallframe/screwdriver_act(mob/living/user, obj/item/tool) + // For camera-building borgs + var/turf/T = get_step(get_turf(user), user.dir) + if(iswallturf(T)) + T.attackby(user, tool) + return TOOL_ACT_TOOLTYPE_SUCCESS +/obj/item/wallframe/wrench_act(mob/living/user, obj/item/tool) var/metal_amt = round(custom_materials[GET_MATERIAL_REF(/datum/material/iron)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later var/glass_amt = round(custom_materials[GET_MATERIAL_REF(/datum/material/glass)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later - if(W.tool_behaviour == TOOL_WRENCH && (metal_amt || glass_amt)) - to_chat(user, span_notice("You dismantle [src].")) - if(metal_amt) - new /obj/item/stack/sheet/iron(get_turf(src), metal_amt) - if(glass_amt) - new /obj/item/stack/sheet/glass(get_turf(src), glass_amt) - qdel(src) + if(!metal_amt && !glass_amt) + return FALSE + to_chat(user, span_notice("You dismantle [src].")) + if(metal_amt) + new /obj/item/stack/sheet/iron(get_turf(src), metal_amt) + if(glass_amt) + new /obj/item/stack/sheet/glass(get_turf(src), glass_amt) + qdel(src) + return TOOL_ACT_TOOLTYPE_SUCCESS /obj/item/electronics desc = "Looks like a circuit. Probably is." diff --git a/code/game/objects/structures/barsigns.dm b/code/game/objects/structures/barsigns.dm index 1bb6f570483..7c3e74608b9 100644 --- a/code/game/objects/structures/barsigns.dm +++ b/code/game/objects/structures/barsigns.dm @@ -74,24 +74,26 @@ return pick_sign(user) -/obj/structure/sign/barsign/attackby(obj/item/I, mob/user) - if(I.tool_behaviour == TOOL_SCREWDRIVER) - if(!panel_open) - to_chat(user, span_notice("You open the maintenance panel.")) - set_sign(new /datum/barsign/hiddensigns/signoff) - panel_open = TRUE - else - to_chat(user, span_notice("You close the maintenance panel.")) - if(!broken) - if(!chosen_sign) - set_sign(new /datum/barsign/hiddensigns/signoff) - else - set_sign(chosen_sign) - else - set_sign(new /datum/barsign/hiddensigns/empbarsign) - panel_open = FALSE +/obj/structure/sign/barsign/screwdriver_act(mob/living/user, obj/item/tool) + tool.play_tool_sound(src) + if(!panel_open) + to_chat(user, span_notice("You open the maintenance panel.")) + set_sign(new /datum/barsign/hiddensigns/signoff) + panel_open = TRUE + return TOOL_ACT_TOOLTYPE_SUCCESS + to_chat(user, span_notice("You close the maintenance panel.")) - else if(istype(I, /obj/item/stack/cable_coil) && panel_open) + if(broken) + set_sign(new /datum/barsign/hiddensigns/empbarsign) + else if(!chosen_sign) + set_sign(new /datum/barsign/hiddensigns/signoff) + else + set_sign(chosen_sign) + panel_open = FALSE + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/sign/barsign/attackby(obj/item/I, mob/user) + if(istype(I, /obj/item/stack/cable_coil) && panel_open) var/obj/item/stack/cable_coil/C = I if(!broken) to_chat(user, span_warning("This sign is functioning properly!")) @@ -102,8 +104,11 @@ broken = FALSE else to_chat(user, span_warning("You need at least two lengths of cable!")) - else - return ..() + return TRUE + + if (broken) + return TRUE + return ..() /obj/structure/sign/barsign/emp_act(severity) diff --git a/code/game/objects/structures/bedsheet_bin.dm b/code/game/objects/structures/bedsheet_bin.dm index a24f26ed0f3..2306325f3c9 100644 --- a/code/game/objects/structures/bedsheet_bin.dm +++ b/code/game/objects/structures/bedsheet_bin.dm @@ -539,6 +539,21 @@ LINEN BINS update_appearance() ..() +/obj/structure/bedsheetbin/screwdriver_act(mob/living/user, obj/item/tool) + if(flags_1 & NODECONSTRUCT_1) + return FALSE + if(amount) + to_chat(user, span_warning("The [src] must be empty first!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + if(tool.use_tool(src, user, 0.5 SECONDS, volume=50)) + to_chat(user, span_notice("You disassemble the [src].")) + new /obj/item/stack/rods(loc, 2) + qdel(src) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/bedsheetbin/wrench_act(mob/living/user, obj/item/tool) + return default_unfasten_wrench(user, tool, 5) + /obj/structure/bedsheetbin/attackby(obj/item/I, mob/user, params) if(istype(I, /obj/item/bedsheet)) if(!user.transferItemToLoc(I, src)) @@ -548,20 +563,6 @@ LINEN BINS to_chat(user, span_notice("You put [I] in [src].")) update_appearance() - else if(default_unfasten_wrench(user, I, 5)) - return - - else if(I.tool_behaviour == TOOL_SCREWDRIVER) - if(flags_1 & NODECONSTRUCT_1) - return - if(amount) - to_chat(user, span_warning("The [src] must be empty first!")) - return - if(I.use_tool(src, user, 5, volume=50)) - to_chat(user, span_notice("You disassemble the [src].")) - new /obj/item/stack/rods(loc, 2) - qdel(src) - else if(amount && !hidden && I.w_class < WEIGHT_CLASS_BULKY) //make sure there's sheets to hide it among, make sure nothing else is hidden in there. if(!user.transferItemToLoc(I, src)) to_chat(user, span_warning("\The [I] is stuck to your hand, you cannot hide it among the sheets!")) diff --git a/code/game/objects/structures/false_walls.dm b/code/game/objects/structures/false_walls.dm index 5c97406c9ec..2cac5b155ae 100644 --- a/code/game/objects/structures/false_walls.dm +++ b/code/game/objects/structures/false_walls.dm @@ -83,30 +83,39 @@ qdel(src) return T +/obj/structure/falsewall/tool_act(mob/living/user, obj/item/tool) + if(!opening) + return ..() + to_chat(user, span_warning("You must wait until the door has stopped moving!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/falsewall/screwdriver_act(mob/living/user, obj/item/tool) + if(!density) + to_chat(user, span_warning("You can't reach, close it first!")) + return + var/turf/loc_turf = get_turf(src) + if(loc_turf.density) + to_chat(user, span_warning("[src] is blocked!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + if(!isfloorturf(loc_turf)) + to_chat(user, span_warning("[src] bolts must be tightened on the floor!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + user.visible_message(span_notice("[user] tightens some bolts on the wall."), span_notice("You tighten the bolts on the wall.")) + ChangeToWall() + return TOOL_ACT_TOOLTYPE_SUCCESS + + +/obj/structure/falsewall/welder_act(mob/living/user, obj/item/tool) + if(tool.use_tool(src, user, 0 SECONDS, volume=50)) + dismantle(user, TRUE) + return TOOL_ACT_TOOLTYPE_SUCCESS + return + /obj/structure/falsewall/attackby(obj/item/W, mob/user, params) - if(opening) + if(!opening) to_chat(user, span_warning("You must wait until the door has stopped moving!")) return - - if(W.tool_behaviour == TOOL_SCREWDRIVER) - if(density) - var/turf/T = get_turf(src) - if(T.density) - to_chat(user, span_warning("[src] is blocked!")) - return - if(!isfloorturf(T)) - to_chat(user, span_warning("[src] bolts must be tightened on the floor!")) - return - user.visible_message(span_notice("[user] tightens some bolts on the wall."), span_notice("You tighten the bolts on the wall.")) - ChangeToWall() - else - to_chat(user, span_warning("You can't reach, close it first!")) - - else if(W.tool_behaviour == TOOL_WELDER) - if(W.use_tool(src, user, 0, volume=50)) - dismantle(user, TRUE) - else - return ..() + return ..() /obj/structure/falsewall/proc/dismantle(mob/user, disassembled=TRUE, obj/item/tool = null) user.visible_message(span_notice("[user] dismantles the false wall."), span_notice("You dismantle the false wall.")) diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 700442fa3a1..8274b934286 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -171,28 +171,38 @@ if(istype(caller)) . = . || (caller.pass_flags & PASSGRILLE) +/obj/structure/grille/wirecutter_act(mob/living/user, obj/item/tool) + add_fingerprint(user) + if(shock(user, 100)) + return + tool.play_tool_sound(src, 100) + deconstruct() + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/grille/screwdriver_act(mob/living/user, obj/item/tool) + if(!isturf(loc) || !anchored) + return FALSE + add_fingerprint(user) + if(shock(user, 90)) + return FALSE + tool.play_tool_sound(src, 100) + set_anchored(!anchored) + user.visible_message(span_notice("[user] [anchored ? "fastens" : "unfastens"] [src]."), \ + span_notice("You [anchored ? "fasten [src] to" : "unfasten [src] from"] the floor.")) + return TOOL_ACT_TOOLTYPE_SUCCESS + /obj/structure/grille/attackby(obj/item/W, mob/user, params) user.changeNext_move(CLICK_CD_MELEE) add_fingerprint(user) - if(W.tool_behaviour == TOOL_WIRECUTTER) - if(!shock(user, 100)) - W.play_tool_sound(src, 100) - deconstruct() - else if((W.tool_behaviour == TOOL_SCREWDRIVER) && (isturf(loc) || anchored)) - if(!shock(user, 90)) - W.play_tool_sound(src, 100) - set_anchored(!anchored) - user.visible_message(span_notice("[user] [anchored ? "fastens" : "unfastens"] [src]."), \ - span_notice("You [anchored ? "fasten [src] to" : "unfasten [src] from"] the floor.")) + if(istype(W, /obj/item/stack/rods) && broken) + if(shock(user, 90)) return - else if(istype(W, /obj/item/stack/rods) && broken) var/obj/item/stack/rods/R = W - if(!shock(user, 90)) - user.visible_message(span_notice("[user] rebuilds the broken grille."), \ - span_notice("You rebuild the broken grille.")) - repair_grille() - R.use(1) - return + user.visible_message(span_notice("[user] rebuilds the broken grille."), \ + span_notice("You rebuild the broken grille.")) + repair_grille() + R.use(1) + return TRUE //window placing begin else if(is_glass_sheet(W) || istype(W, /obj/item/stack/sheet/bronze)) diff --git a/code/game/objects/structures/reflector.dm b/code/game/objects/structures/reflector.dm index b5b2f056cc1..1b4ecabe8a7 100644 --- a/code/game/objects/structures/reflector.dm +++ b/code/game/objects/structures/reflector.dm @@ -32,7 +32,7 @@ if(admin) can_rotate = FALSE - + AddComponent(/datum/component/usb_port, list( /obj/item/circuit_component/reflector, )) @@ -75,61 +75,62 @@ P.decayedRange = max(P.decayedRange--, 0) return BULLET_ACT_FORCE_PIERCE +/obj/structure/reflector/tool_act(mob/living/user, obj/item/tool, tool_type, is_right_clicking) + if(admin) + return FALSE + return ..() + +/obj/structure/reflector/screwdriver_act(mob/living/user, obj/item/tool) + can_rotate = !can_rotate + to_chat(user, span_notice("You [can_rotate ? "unlock" : "lock"] [src]'s rotation.")) + tool.play_tool_sound(src) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/reflector/wrench_act(mob/living/user, obj/item/tool) + if(anchored) + to_chat(user, span_warning("Unweld [src] from the floor first!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + user.visible_message(span_notice("[user] starts to dismantle [src]."), span_notice("You start to dismantle [src]...")) + if(!tool.use_tool(src, user, 8 SECONDS, volume=50)) + return + to_chat(user, span_notice("You dismantle [src].")) + new framebuildstacktype(drop_location(), framebuildstackamount) + if(buildstackamount) + new buildstacktype(drop_location(), buildstackamount) + qdel(src) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/reflector/welder_act(mob/living/user, obj/item/tool) + if(!tool.tool_start_check(user, amount=0)) + return + if(atom_integrity < max_integrity) + user.visible_message(span_notice("[user] starts to repair [src]."), + span_notice("You begin repairing [src]..."), + span_hear("You hear welding.")) + if(tool.use_tool(src, user, 4 SECONDS, volume=40)) + atom_integrity = max_integrity + user.visible_message(span_notice("[user] repairs [src]."), \ + span_notice("You finish repairing [src].")) + else if(!anchored) + user.visible_message(span_notice("[user] starts to weld [src] to the floor."), + span_notice("You start to weld [src] to the floor..."), + span_hear("You hear welding.")) + if (tool.use_tool(src, user, 2 SECONDS, volume=50)) + set_anchored(TRUE) + to_chat(user, span_notice("You weld [src] to the floor.")) + else + user.visible_message(span_notice("[user] starts to cut [src] free from the floor."), + span_notice("You start to cut [src] free from the floor..."), + span_hear("You hear welding.")) + if (tool.use_tool(src, user, 2 SECONDS, volume=50)) + set_anchored(FALSE) + to_chat(user, span_notice("You cut [src] free from the floor.")) + + return TOOL_ACT_TOOLTYPE_SUCCESS + /obj/structure/reflector/attackby(obj/item/W, mob/user, params) if(admin) return - - if(W.tool_behaviour == TOOL_SCREWDRIVER) - can_rotate = !can_rotate - to_chat(user, span_notice("You [can_rotate ? "unlock" : "lock"] [src]'s rotation.")) - W.play_tool_sound(src) - return - - if(W.tool_behaviour == TOOL_WRENCH) - if(anchored) - to_chat(user, span_warning("Unweld [src] from the floor first!")) - return - user.visible_message(span_notice("[user] starts to dismantle [src]."), span_notice("You start to dismantle [src]...")) - if(W.use_tool(src, user, 80, volume=50)) - to_chat(user, span_notice("You dismantle [src].")) - new framebuildstacktype(drop_location(), framebuildstackamount) - if(buildstackamount) - new buildstacktype(drop_location(), buildstackamount) - qdel(src) - else if(W.tool_behaviour == TOOL_WELDER) - if(atom_integrity < max_integrity) - if(!W.tool_start_check(user, amount=0)) - return - - user.visible_message(span_notice("[user] starts to repair [src]."), - span_notice("You begin repairing [src]..."), - span_hear("You hear welding.")) - if(W.use_tool(src, user, 40, volume=40)) - atom_integrity = max_integrity - user.visible_message(span_notice("[user] repairs [src]."), \ - span_notice("You finish repairing [src].")) - - else if(!anchored) - if(!W.tool_start_check(user, amount=0)) - return - - user.visible_message(span_notice("[user] starts to weld [src] to the floor."), - span_notice("You start to weld [src] to the floor..."), - span_hear("You hear welding.")) - if (W.use_tool(src, user, 20, volume=50)) - set_anchored(TRUE) - to_chat(user, span_notice("You weld [src] to the floor.")) - else - if(!W.tool_start_check(user, amount=0)) - return - - user.visible_message(span_notice("[user] starts to cut [src] free from the floor."), - span_notice("You start to cut [src] free from the floor..."), - span_hear("You hear welding.")) - if (W.use_tool(src, user, 20, volume=50)) - set_anchored(FALSE) - to_chat(user, span_notice("You cut [src] free from the floor.")) - //Finishing the frame else if(istype(W, /obj/item/stack/sheet)) if(finished) @@ -264,10 +265,10 @@ display_name = "Reflector" desc = "Allows you to adjust the angle of a reflector." circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL - + ///angle the reflector will be set to at trigger unless locked var/datum/port/input/angle - + var/obj/structure/reflector/attached_reflector /obj/item/circuit_component/reflector/populate_ports() diff --git a/code/game/objects/structures/showcase.dm b/code/game/objects/structures/showcase.dm index c23039f5c72..915b390e70d 100644 --- a/code/game/objects/structures/showcase.dm +++ b/code/game/objects/structures/showcase.dm @@ -108,25 +108,30 @@ //Showcases can be any sprite, so it makes sense that they can't be constructed. //However if a player wants to move an existing showcase or remove one, this is for that. -/obj/structure/showcase/attackby(obj/item/W, mob/user) - if(W.tool_behaviour == TOOL_SCREWDRIVER && !anchored) - if(deconstruction_state == SHOWCASE_SCREWDRIVERED) - to_chat(user, span_notice("You screw the screws back into the showcase.")) - W.play_tool_sound(src, 100) - deconstruction_state = SHOWCASE_CONSTRUCTED - else if (deconstruction_state == SHOWCASE_CONSTRUCTED) - to_chat(user, span_notice("You unscrew the screws.")) - W.play_tool_sound(src, 100) - deconstruction_state = SHOWCASE_SCREWDRIVERED +/obj/structure/showcase/screwdriver_act(mob/living/user, obj/item/tool) + if(anchored) + return FALSE + if(deconstruction_state == SHOWCASE_SCREWDRIVERED) + to_chat(user, span_notice("You screw the screws back into the showcase.")) + tool.play_tool_sound(src, 100) + deconstruction_state = SHOWCASE_CONSTRUCTED + else if (deconstruction_state == SHOWCASE_CONSTRUCTED) + to_chat(user, span_notice("You unscrew the screws.")) + tool.play_tool_sound(src, 100) + deconstruction_state = SHOWCASE_SCREWDRIVERED + return TOOL_ACT_TOOLTYPE_SUCCESS - if(W.tool_behaviour == TOOL_CROWBAR && deconstruction_state == SHOWCASE_SCREWDRIVERED) - if(W.use_tool(src, user, 20, volume=100)) - to_chat(user, span_notice("You start to crowbar the showcase apart...")) - new /obj/item/stack/sheet/iron(drop_location(), 4) - qdel(src) - - if(deconstruction_state == SHOWCASE_CONSTRUCTED && default_unfasten_wrench(user, W)) +/obj/structure/showcase/crowbar_act(mob/living/user, obj/item/tool) + if(!tool.use_tool(src, user, 2 SECONDS, volume=100)) return + to_chat(user, span_notice("You start to crowbar the showcase apart...")) + new /obj/item/stack/sheet/iron(drop_location(), 4) + qdel(src) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/showcase/wrench_act(mob/living/user, obj/item/tool) + if(deconstruction_state == SHOWCASE_CONSTRUCTED && default_unfasten_wrench(user, tool)) + return TOOL_ACT_TOOLTYPE_SUCCESS //Feedback is given in examine because showcases can basically have any sprite assigned to them diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index 284ba14fc96..41279cb13b8 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -184,21 +184,25 @@ log_combat(user, pushed_mob, "head slammed", null, "against [src]") SEND_SIGNAL(pushed_mob, COMSIG_ADD_MOOD_EVENT, "table", /datum/mood_event/table_limbsmash, banged_limb) +/obj/structure/table/screwdriver_act_secondary(mob/living/user, obj/item/tool) + if(flags_1 & NODECONSTRUCT_1 || !deconstruction_ready) + return FALSE + to_chat(user, span_notice("You start disassembling [src]...")) + if(tool.use_tool(src, user, 2 SECONDS, volume=50)) + deconstruct(TRUE) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/table/wrench_act_secondary(mob/living/user, obj/item/tool) + if(flags_1 & NODECONSTRUCT_1 || !deconstruction_ready) + return FALSE + to_chat(user, span_notice("You start deconstructing [src]...")) + if(tool.use_tool(src, user, 4 SECONDS, volume=50)) + playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE) + deconstruct(TRUE, 1) + return TOOL_ACT_TOOLTYPE_SUCCESS + /obj/structure/table/attackby(obj/item/I, mob/living/user, params) var/list/modifiers = params2list(params) - if(!(flags_1 & NODECONSTRUCT_1) && LAZYACCESS(modifiers, RIGHT_CLICK)) - if(I.tool_behaviour == TOOL_SCREWDRIVER && deconstruction_ready) - to_chat(user, span_notice("You start disassembling [src]...")) - if(I.use_tool(src, user, 20, volume=50)) - deconstruct(TRUE) - return - - if(I.tool_behaviour == TOOL_WRENCH && deconstruction_ready) - to_chat(user, span_notice("You start deconstructing [src]...")) - if(I.use_tool(src, user, 40, volume=50)) - playsound(src.loc, 'sound/items/deconstruct.ogg', 50, TRUE) - deconstruct(TRUE, 1) - return if(istype(I, /obj/item/storage/bag/tray)) var/obj/item/storage/bag/tray/T = I diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index a8c7ac774b5..803791df77d 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -180,50 +180,67 @@ return ..() +/obj/structure/window/tool_act(mob/living/user, obj/item/tool, tool_type, is_right_clicking) + if(!can_be_reached(user)) + return TRUE //skip the afterattack + add_fingerprint(user) + return ..() + +/obj/structure/window/welder_act(mob/living/user, obj/item/tool) + if(atom_integrity >= max_integrity) + to_chat(user, span_warning("[src] is already in good condition!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + if(!tool.tool_start_check(user, amount = 0)) + return FALSE + to_chat(user, span_notice("You begin repairing [src]...")) + if(tool.use_tool(src, user, 4 SECONDS, volume = 50)) + atom_integrity = max_integrity + update_nearby_icons() + to_chat(user, span_notice("You repair [src].")) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/window/screwdriver_act(mob/living/user, obj/item/tool) + if((flags_1 & NODECONSTRUCT_1) || (reinf && state >= RWINDOW_FRAME_BOLTED)) + return + to_chat(user, span_notice("You begin to [anchored ? "unscrew the window from":"screw the window to"] the floor...")) + if(tool.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_anchored, anchored))) + set_anchored(!anchored) + to_chat(user, span_notice("You [anchored ? "fasten the window to":"unfasten the window from"] the floor.")) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/window/wrench_act(mob/living/user, obj/item/tool) + if(anchored) + return FALSE + if((flags_1 & NODECONSTRUCT_1) || (reinf && state >= RWINDOW_FRAME_BOLTED)) + return FALSE + + to_chat(user, span_notice("You begin to disassemble [src]...")) + if(!tool.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored))) + return TOOL_ACT_TOOLTYPE_SUCCESS + var/obj/item/stack/sheet/G = new glass_type(user.loc, glass_amount) + if (!QDELETED(G)) + G.add_fingerprint(user) + playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE) + to_chat(user, span_notice("You successfully disassemble [src].")) + qdel(src) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/structure/window/crowbar_act(mob/living/user, obj/item/tool) + if(!anchored || !reinf) + return FALSE + if((flags_1 & NODECONSTRUCT_1) || (state != WINDOW_OUT_OF_FRAME)) + return FALSE + to_chat(user, span_notice("You begin to lever the window into the frame...")) + if(tool.use_tool(src, user, 10 SECONDS, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored))) + state = RWINDOW_SECURE + to_chat(user, span_notice("You pry the window into the frame.")) + return TOOL_ACT_TOOLTYPE_SUCCESS + /obj/structure/window/attackby(obj/item/I, mob/living/user, params) if(!can_be_reached(user)) return TRUE //skip the afterattack add_fingerprint(user) - - if(I.tool_behaviour == TOOL_WELDER) - if(atom_integrity < max_integrity) - if(!I.tool_start_check(user, amount = 0)) - return - - to_chat(user, span_notice("You begin repairing [src]...")) - if(I.use_tool(src, user, 40, volume = 50)) - atom_integrity = max_integrity - update_nearby_icons() - to_chat(user, span_notice("You repair [src].")) - else - to_chat(user, span_warning("[src] is already in good condition!")) - return - - if(!(flags_1&NODECONSTRUCT_1) && !(reinf && state >= RWINDOW_FRAME_BOLTED)) - if(I.tool_behaviour == TOOL_SCREWDRIVER) - to_chat(user, span_notice("You begin to [anchored ? "unscrew the window from":"screw the window to"] the floor...")) - if(I.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_anchored, anchored))) - set_anchored(!anchored) - to_chat(user, span_notice("You [anchored ? "fasten the window to":"unfasten the window from"] the floor.")) - return - else if(I.tool_behaviour == TOOL_WRENCH && !anchored) - to_chat(user, span_notice("You begin to disassemble [src]...")) - if(I.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored))) - var/obj/item/stack/sheet/G = new glass_type(user.loc, glass_amount) - if (!QDELETED(G)) - G.add_fingerprint(user) - playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE) - to_chat(user, span_notice("You successfully disassemble [src].")) - qdel(src) - return - else if(I.tool_behaviour == TOOL_CROWBAR && reinf && (state == WINDOW_OUT_OF_FRAME) && anchored) - to_chat(user, span_notice("You begin to lever the window into the frame...")) - if(I.use_tool(src, user, 100, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored))) - state = RWINDOW_SECURE - to_chat(user, span_notice("You pry the window into the frame.")) - return - return ..() /obj/structure/window/AltClick(mob/user) @@ -395,6 +412,7 @@ //this is shitcode but all of construction is shitcode and needs a refactor, it works for now //If you find this like 4 years later and construction still hasn't been refactored, I'm so sorry for this //Adding a timestamp, I found this in 2020, I hope it's from this year -Lemon //2021 AND STILLLL GOING STRONG +//2022 BABYYYYY ~lewc /obj/structure/window/reinforced/attackby_secondary(obj/item/tool, mob/user, params) switch(state) if(RWINDOW_SECURE) diff --git a/code/modules/antagonists/abductor/equipment/abduction_gear.dm b/code/modules/antagonists/abductor/equipment/abduction_gear.dm index 2be0af405e8..a9b2dc1299b 100644 --- a/code/modules/antagonists/abductor/equipment/abduction_gear.dm +++ b/code/modules/antagonists/abductor/equipment/abduction_gear.dm @@ -652,10 +652,9 @@ Congratulations! You are now trained for invasive xenobiology research!"} . = ..() AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS)) -/obj/item/radio/headset/abductor/attackby(obj/item/W, mob/user, params) - if(W.tool_behaviour == TOOL_SCREWDRIVER) - return // Stops humans from disassembling abductor headsets. - return ..() +// Stops humans from disassembling abductor headsets. +/obj/item/radio/headset/abductor/screwdriver_act(mob/living/user, obj/item/tool) + return TOOL_ACT_TOOLTYPE_SUCCESS /obj/item/abductor_machine_beacon name = "machine beacon" diff --git a/code/modules/atmospherics/machinery/components/binary_devices/thermomachine.dm b/code/modules/atmospherics/machinery/components/binary_devices/thermomachine.dm index 9cba27a70c6..09f00451eb6 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/thermomachine.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/thermomachine.dm @@ -259,25 +259,30 @@ use_power(power_usage) update_parents() -/obj/machinery/atmospherics/components/binary/thermomachine/attackby(obj/item/item, mob/user, params) - if(!on && item.tool_behaviour == TOOL_SCREWDRIVER) - if(!anchored) - to_chat(user, span_notice("Anchor [src] first!")) - return - if(default_deconstruction_screwdriver(user, "thermo-open", "thermo-0", item)) - change_pipe_connection(panel_open) - return - if(default_change_direction_wrench(user, item)) - return - if(default_deconstruction_crowbar(item)) - return +/obj/machinery/atmospherics/components/binary/thermomachine/screwdriver_act(mob/living/user, obj/item/tool) + if(on) + to_chat("You can't open [src] while it's on!") + return TOOL_ACT_TOOLTYPE_SUCCESS + if(!anchored) + to_chat(user, span_notice("Anchor [src] first!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + if(default_deconstruction_screwdriver(user, "thermo-open", "thermo-0", tool)) + change_pipe_connection(panel_open) + return TOOL_ACT_TOOLTYPE_SUCCESS - if(panel_open && item.tool_behaviour == TOOL_MULTITOOL) - piping_layer = (piping_layer >= PIPING_LAYER_MAX) ? PIPING_LAYER_MIN : (piping_layer + 1) - to_chat(user, span_notice("You change the circuitboard to layer [piping_layer].")) - update_appearance() +/obj/machinery/atmospherics/components/binary/thermomachine/wrench_act(mob/living/user, obj/item/tool) + return default_change_direction_wrench(user, tool) + +/obj/machinery/atmospherics/components/binary/thermomachine/crowbar_act(mob/living/user, obj/item/tool) + return default_deconstruction_crowbar(tool) + +/obj/machinery/atmospherics/components/binary/thermomachine/multitool_act(mob/living/user, obj/item/multitool/multitool) + if(!panel_open) return - return ..() + piping_layer = (piping_layer >= PIPING_LAYER_MAX) ? PIPING_LAYER_MIN : (piping_layer + 1) + to_chat(user, span_notice("You change the circuitboard to layer [piping_layer].")) + update_appearance() + return TOOL_ACT_TOOLTYPE_SUCCESS /obj/machinery/atmospherics/components/binary/thermomachine/default_change_direction_wrench(mob/user, obj/item/I) if(!..()) @@ -322,18 +327,21 @@ if(parents[2]) nullify_pipenet(parents[2]) -/obj/machinery/atmospherics/components/binary/thermomachine/attackby_secondary(obj/item/item, mob/user, params) - . = ..() - if(panel_open && item.tool_behaviour == TOOL_WRENCH && !check_pipe_on_turf()) - if(default_unfasten_wrench(user, item)) - return SECONDARY_ATTACK_CONTINUE_CHAIN - if(panel_open && item.tool_behaviour == TOOL_MULTITOOL) - color_index = (color_index >= GLOB.pipe_paint_colors.len) ? (color_index = 1) : (color_index = 1 + color_index) - pipe_color = GLOB.pipe_paint_colors[GLOB.pipe_paint_colors[color_index]] - visible_message("You set [src] pipe color to [GLOB.pipe_color_name[pipe_color]].") - update_appearance() - return SECONDARY_ATTACK_CONTINUE_CHAIN - return SECONDARY_ATTACK_CONTINUE_CHAIN +/obj/machinery/atmospherics/components/binary/thermomachine/wrench_act_secondary(mob/living/user, obj/item/tool) + if(!panel_open || check_pipe_on_turf()) + return + if(default_unfasten_wrench(user, tool)) + return TOOL_ACT_TOOLTYPE_SUCCESS + return + +/obj/machinery/atmospherics/components/binary/thermomachine/multitool_act_secondary(mob/living/user, obj/item/tool) + if(!panel_open) + return + color_index = (color_index >= GLOB.pipe_paint_colors.len) ? (color_index = 1) : (color_index = 1 + color_index) + pipe_color = GLOB.pipe_paint_colors[GLOB.pipe_paint_colors[color_index]] + visible_message("You set [src] pipe color to [GLOB.pipe_color_name[pipe_color]].") + update_appearance() + return TOOL_ACT_TOOLTYPE_SUCCESS /obj/machinery/atmospherics/components/binary/thermomachine/proc/check_pipe_on_turf() for(var/obj/machinery/atmospherics/device in get_turf(src)) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm index d66acd61298..77f33fa1b0b 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm @@ -375,6 +375,28 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics if (do_after(user, 2.5 SECONDS, target=target)) close_machine(target) +/obj/machinery/atmospherics/components/unary/cryo_cell/screwdriver_act(mob/living/user, obj/item/tool) + + if(!on && !occupant && !state_open && (default_deconstruction_screwdriver(user, "pod-off", "pod-off", tool))) + update_appearance() + else + to_chat(user, "You can't access the maintenance panel while the pod is " \ + + (on ? "active" : (occupant ? "full" : "open")) + "!") + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/machinery/atmospherics/components/unary/cryo_cell/crowbar_act(mob/living/user, obj/item/tool) + if(on || occupant || state_open) + return FALSE + if(default_pry_open(tool) || default_deconstruction_crowbar(tool)) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/machinery/atmospherics/components/unary/cryo_cell/wrench_act(mob/living/user, obj/item/tool) + if(on || occupant || state_open) + return FALSE + if(default_change_direction_wrench(user, tool)) + update_appearance() + return TOOL_ACT_TOOLTYPE_SUCCESS + /obj/machinery/atmospherics/components/unary/cryo_cell/attackby(obj/item/I, mob/user, params) if(istype(I, /obj/item/reagent_containers/glass)) . = 1 //no afterattack @@ -389,16 +411,6 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics var/reagentlist = pretty_string_from_reagent_list(I.reagents.reagent_list) log_game("[key_name(user)] added an [I] to cryo containing [reagentlist]") return - if(!on && !occupant && !state_open && (default_deconstruction_screwdriver(user, "pod-off", "pod-off", I)) \ - || default_change_direction_wrench(user, I) \ - || default_pry_open(I) \ - || default_deconstruction_crowbar(I)) - update_appearance() - return - else if(I.tool_behaviour == TOOL_SCREWDRIVER) - to_chat(user, "You can't access the maintenance panel while the pod is " \ - + (on ? "active" : (occupant ? "full" : "open")) + "!") - return return ..() /obj/machinery/atmospherics/components/unary/cryo_cell/ui_state(mob/user) diff --git a/code/modules/clothing/spacesuits/_spacesuits.dm b/code/modules/clothing/spacesuits/_spacesuits.dm index 6720dad4791..d925769863f 100644 --- a/code/modules/clothing/spacesuits/_spacesuits.dm +++ b/code/modules/clothing/spacesuits/_spacesuits.dm @@ -135,33 +135,35 @@ else . += "\The [cell] is firmly in place." +/obj/item/clothing/suit/space/crowbar_act(mob/living/user, obj/item/tool) + toggle_spacesuit_cell(user) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/obj/item/clothing/suit/space/screwdriver_act(mob/living/user, obj/item/tool) + var/range_low = 20 // Default min temp c + var/range_high = 45 // default max temp c + if(obj_flags & EMAGGED) + range_low = -20 // emagged min temp c + range_high = 120 // emagged max temp c + + var/deg_c = input(user, "What temperature would you like to set the thermal regulator to? \ + ([range_low]-[range_high] degrees celcius)") as null|num + if(deg_c && deg_c >= range_low && deg_c <= range_high) + temperature_setting = round(T0C + deg_c, 0.1) + to_chat(user, span_notice("You see the readout change to [deg_c] c.")) + return TOOL_ACT_TOOLTYPE_SUCCESS + // object handling for accessing features of the suit /obj/item/clothing/suit/space/attackby(obj/item/I, mob/user, params) - if(I.tool_behaviour == TOOL_CROWBAR) - toggle_spacesuit_cell(user) + if(!cell_cover_open || !istype(I, /obj/item/stock_parts/cell)) + return ..() + if(cell) + to_chat(user, span_warning("[src] already has a cell installed.")) return - else if(cell_cover_open && I.tool_behaviour == TOOL_SCREWDRIVER) - var/range_low = 20 // Default min temp c - var/range_high = 45 // default max temp c - if(obj_flags & EMAGGED) - range_low = -20 // emagged min temp c - range_high = 120 // emagged max temp c - - var/deg_c = input(user, "What temperature would you like to set the thermal regulator to? \ - ([range_low]-[range_high] degrees celcius)") as null|num - if(deg_c && deg_c >= range_low && deg_c <= range_high) - temperature_setting = round(T0C + deg_c, 0.1) - to_chat(user, span_notice("You see the readout change to [deg_c] c.")) + if(user.transferItemToLoc(I, src)) + cell = I + to_chat(user, span_notice("You successfully install \the [cell] into [src].")) return - else if(cell_cover_open && istype(I, /obj/item/stock_parts/cell)) - if(cell) - to_chat(user, span_warning("[src] already has a cell installed.")) - return - if(user.transferItemToLoc(I, src)) - cell = I - to_chat(user, span_notice("You successfully install \the [cell] into [src].")) - return - return ..() /// Open the cell cover when ALT+Click on the suit /obj/item/clothing/suit/space/AltClick(mob/living/user) diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index aabea740a9f..27a836de830 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -388,13 +388,31 @@ return TRUE /mob/living/simple_animal/bot/screwdriver_act(mob/living/user, obj/item/tool) - if(!(bot_cover_flags & BOT_COVER_LOCKED)) - bot_cover_flags ^= BOT_COVER_OPEN - to_chat(user, span_notice("The maintenance panel is now [bot_cover_flags & BOT_COVER_OPEN ? "opened" : "closed"].")) - else + if(bot_cover_flags & BOT_COVER_LOCKED) to_chat(user, span_warning("The maintenance panel is locked!")) + return TOOL_ACT_TOOLTYPE_SUCCESS - return TRUE + tool.play_tool_sound(src) + bot_cover_flags ^= BOT_COVER_OPEN + to_chat(user, span_notice("The maintenance panel is now [bot_cover_flags & BOT_COVER_OPEN ? "opened" : "closed"].")) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/mob/living/simple_animal/bot/welder_act(mob/living/user, obj/item/tool) + user.changeNext_move(CLICK_CD_MELEE) + if(user.combat_mode) + return FALSE + + if(health >= maxHealth) + to_chat(user, span_warning("[src] does not need a repair!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + if(!(bot_cover_flags & BOT_COVER_OPEN)) + to_chat(user, span_warning("Unable to repair with the maintenance panel closed!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + + if(tool.use_tool(src, user, 0 SECONDS, volume=40)) + adjustHealth(-10) + user.visible_message(span_notice("[user] repairs [src]!"),span_notice("You repair [src].")) + return TOOL_ACT_TOOLTYPE_SUCCESS /mob/living/simple_animal/bot/attackby(obj/item/attacking_item, mob/living/user, params) if(attacking_item.GetID()) @@ -410,18 +428,6 @@ if (paicard) user.visible_message(span_notice("[user] uses [attacking_item] to pull [paicard] out of [initial(src.name)]!"),span_notice("You pull [paicard] out of [initial(src.name)] with [attacking_item].")) ejectpai(user) - else if(attacking_item.tool_behaviour == TOOL_WELDER && !user.combat_mode) - user.changeNext_move(CLICK_CD_MELEE) - if(health >= maxHealth) - to_chat(user, span_warning("[src] does not need a repair!")) - return - if(!(bot_cover_flags & BOT_COVER_OPEN)) - to_chat(user, span_warning("Unable to repair with the maintenance panel closed!")) - return - - if(attacking_item.use_tool(src, user, 0, volume=40)) - adjustHealth(-10) - user.visible_message(span_notice("[user] repairs [src]!"),span_notice("You repair [src].")) else if(attacking_item.force) //if force is non-zero do_sparks(5, TRUE, src) diff --git a/code/modules/mob/living/simple_animal/bot/mulebot.dm b/code/modules/mob/living/simple_animal/bot/mulebot.dm index fe851556b0a..08991730da1 100644 --- a/code/modules/mob/living/simple_animal/bot/mulebot.dm +++ b/code/modules/mob/living/simple_animal/bot/mulebot.dm @@ -149,34 +149,38 @@ reached_target = FALSE /mob/living/simple_animal/bot/mulebot/screwdriver_act(mob/living/user, obj/item/tool) - ..() + . = ..() update_appearance() - return TRUE + +/mob/living/simple_animal/bot/mulebot/crowbar_act(mob/living/user, obj/item/tool) + if(!(bot_cover_flags & BOT_COVER_OPEN) || user.combat_mode) + return + if(!cell) + to_chat(user, span_warning("[src] doesn't have a power cell!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + cell.add_fingerprint(user) + if(Adjacent(user) && !issilicon(user)) + user.put_in_hands(cell) + else + cell.forceMove(drop_location()) + visible_message(span_notice("[user] crowbars [cell] out from [src]."), + span_notice("You pry [cell] out of [src].")) + cell = null + diag_hud_set_mulebotcell() + return TOOL_ACT_TOOLTYPE_SUCCESS /mob/living/simple_animal/bot/mulebot/attackby(obj/item/I, mob/living/user, params) if(istype(I, /obj/item/stock_parts/cell) && bot_cover_flags & BOT_COVER_OPEN) if(cell) to_chat(user, span_warning("[src] already has a power cell!")) - return + return TRUE if(!user.transferItemToLoc(I, src)) - return + return TRUE cell = I diag_hud_set_mulebotcell() visible_message(span_notice("[user] inserts \a [cell] into [src]."), span_notice("You insert [cell] into [src].")) - else if(I.tool_behaviour == TOOL_CROWBAR && bot_cover_flags & BOT_COVER_OPEN && !user.combat_mode) - if(!cell) - to_chat(user, span_warning("[src] doesn't have a power cell!")) - return - cell.add_fingerprint(user) - if(Adjacent(user) && !issilicon(user)) - user.put_in_hands(cell) - else - cell.forceMove(drop_location()) - visible_message(span_notice("[user] crowbars [cell] out from [src]."), - span_notice("You pry [cell] out of [src].")) - cell = null - diag_hud_set_mulebotcell() + return TRUE else if(is_wire_tool(I) && bot_cover_flags & BOT_COVER_OPEN) return attack_hand(user) else if(load && ismob(load)) // chance to knock off rider diff --git a/code/modules/mob/living/simple_animal/friendly/drone/interaction.dm b/code/modules/mob/living/simple_animal/friendly/drone/interaction.dm index c2a3ec82b3d..305c221f319 100644 --- a/code/modules/mob/living/simple_animal/friendly/drone/interaction.dm +++ b/code/modules/mob/living/simple_animal/friendly/drone/interaction.dm @@ -89,28 +89,36 @@ to_chat(user, span_warning("You need to remain still to reactivate [src]!")) -/mob/living/simple_animal/drone/attackby(obj/item/I, mob/user) - if(I.tool_behaviour == TOOL_SCREWDRIVER && stat != DEAD) - if(health < maxHealth) - to_chat(user, span_notice("You start to tighten loose screws on [src]...")) - if(I.use_tool(src, user, 80)) - adjustBruteLoss(-getBruteLoss()) - visible_message(span_notice("[user] tightens [src == user ? "[user.p_their()]" : "[src]'s"] loose screws!"), span_notice("[src == user ? "You tighten" : "[user] tightens"] your loose screws.")) - else - to_chat(user, span_warning("You need to remain still to tighten [src]'s screws!")) - else - to_chat(user, span_warning("[src]'s screws can't get any tighter!")) - return //This used to not exist and drones who repaired themselves also stabbed the shit out of themselves. - else if(I.tool_behaviour == TOOL_WRENCH && user != src) //They aren't required to be hacked, because laws can change in other ways (i.e. admins) - user.visible_message(span_notice("[user] starts resetting [src]..."), \ - span_notice("You press down on [src]'s factory reset control...")) - if(I.use_tool(src, user, 50, volume=50)) - user.visible_message(span_notice("[user] resets [src]!"), \ - span_notice("You reset [src]'s directives to factory defaults!")) - update_drone_hack(FALSE) - return - else - ..() +/mob/living/simple_animal/drone/screwdriver_act(mob/living/user, obj/item/tool) + if(stat == DEAD) + return FALSE + if(health >= maxHealth) + to_chat(user, span_warning("[src]'s screws can't get any tighter!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + to_chat(user, span_notice("You start to tighten loose screws on [src]...")) + + if(!tool.use_tool(src, user, 8 SECONDS, volume=50)) + to_chat(user, span_warning("You need to remain still to tighten [src]'s screws!")) + return TOOL_ACT_TOOLTYPE_SUCCESS + + adjustBruteLoss(-getBruteLoss()) + visible_message(span_notice("[user] tightens [src == user ? "[user.p_their()]" : "[src]'s"] loose screws!"), span_notice("[src == user ? "You tighten" : "[user] tightens"] your loose screws.")) + return TOOL_ACT_TOOLTYPE_SUCCESS + +/mob/living/simple_animal/drone/wrench_act(mob/living/user, obj/item/tool) + if(user == src) + return FALSE + user.visible_message( + span_notice("[user] starts resetting [src]..."), + span_notice("You press down on [src]'s factory reset control...") + ) + if(tool.use_tool(src, user, 5 SECONDS, volume=50)) + user.visible_message( + span_notice("[user] resets [src]!"), + span_notice("You reset [src]'s directives to factory defaults!") + ) + update_drone_hack(FALSE) + return TOOL_ACT_TOOLTYPE_SUCCESS /mob/living/simple_animal/drone/transferItemToLoc(obj/item/item, newloc, force, silent) return !(item.type in drone_item_whitelist_flat) && ..() diff --git a/code/modules/modular_computers/hardware/ai_slot.dm b/code/modules/modular_computers/hardware/ai_slot.dm index 8740b59b352..8a99e67a7e4 100644 --- a/code/modules/modular_computers/hardware/ai_slot.dm +++ b/code/modules/modular_computers/hardware/ai_slot.dm @@ -60,10 +60,7 @@ return TRUE return FALSE -/obj/item/computer_hardware/ai_slot/attackby(obj/item/I, mob/living/user) - if(..()) - return - if(I.tool_behaviour == TOOL_SCREWDRIVER) - to_chat(user, span_notice("You press down on the manual eject button with \the [I].")) - try_eject(user, TRUE) - return +/obj/item/computer_hardware/ai_slot/screwdriver_act(mob/living/user, obj/item/tool) + to_chat(user, span_notice("You press down on the manual eject button with [tool].")) + try_eject(user, TRUE) + return TOOL_ACT_TOOLTYPE_SUCCESS diff --git a/code/modules/modular_computers/hardware/card_slot.dm b/code/modules/modular_computers/hardware/card_slot.dm index 5fbc6daa2ab..f2cf4285b64 100644 --- a/code/modules/modular_computers/hardware/card_slot.dm +++ b/code/modules/modular_computers/hardware/card_slot.dm @@ -102,16 +102,14 @@ return TRUE -/obj/item/computer_hardware/card_slot/attackby(obj/item/I, mob/living/user) - if(..()) - return - if(I.tool_behaviour == TOOL_SCREWDRIVER) - if(stored_card) - to_chat(user, span_notice("You press down on the manual eject button with \the [I].")) - try_eject(user) - return - swap_slot() - to_chat(user, span_notice("You adjust the connecter to fit into [expansion_hw ? "an expansion bay" : "the primary ID bay"].")) +/obj/item/computer_hardware/card_slot/screwdriver_act(mob/living/user, obj/item/tool) + if(stored_card) + to_chat(user, span_notice("You press down on the manual eject button with [tool].")) + try_eject(user) + return TOOL_ACT_TOOLTYPE_SUCCESS + swap_slot() + to_chat(user, span_notice("You adjust the connecter to fit into [expansion_hw ? "an expansion bay" : "the primary ID bay"].")) + return TOOL_ACT_TOOLTYPE_SUCCESS /** *Swaps the card_slot hardware between using the dedicated card slot bay on a computer, and using an expansion bay. diff --git a/code/modules/paperwork/paper_cutter.dm b/code/modules/paperwork/paper_cutter.dm index e2aa89cb059..dedb5ea65ad 100644 --- a/code/modules/paperwork/paper_cutter.dm +++ b/code/modules/paperwork/paper_cutter.dm @@ -43,6 +43,14 @@ if(storedpaper) . += "paper" +/obj/item/papercutter/screwdriver_act(mob/living/user, obj/item/tool) + if(!storedcutter) + return + tool.play_tool_sound(src) + to_chat(user, span_notice("[storedcutter] has been [cuttersecured ? "unsecured" : "secured"].")) + cuttersecured = !cuttersecured + return TOOL_ACT_TOOLTYPE_SUCCESS + /obj/item/papercutter/attackby(obj/item/P, mob/user, params) if(istype(P, /obj/item/paper) && !storedpaper) @@ -61,11 +69,6 @@ storedcutter = P update_appearance() return - if(P.tool_behaviour == TOOL_SCREWDRIVER && storedcutter) - P.play_tool_sound(src) - to_chat(user, span_notice("[storedcutter] has been [cuttersecured ? "unsecured" : "secured"].")) - cuttersecured = !cuttersecured - return ..() /obj/item/papercutter/attack_hand(mob/user, list/modifiers) diff --git a/code/modules/photography/photos/frame.dm b/code/modules/photography/photos/frame.dm index 819c1c675d1..6bdc79215b4 100644 --- a/code/modules/photography/photos/frame.dm +++ b/code/modules/photography/photos/frame.dm @@ -116,31 +116,46 @@ if(in_range(src, user)) framed?.show(user) +/// Internal proc +/obj/structure/sign/picture_frame/proc/try_deconstruct(mob/living/user, obj/item/tool) + if(!can_decon) + return FALSE + to_chat(user, span_notice("You start unsecuring [name]...")) + if(tool.use_tool(src, user, 3 SECONDS, volume=50)) + playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE) + to_chat(user, span_notice("You unsecure [name].")) + deconstruct() + return TRUE + +/obj/structure/sign/picture_frame/screwdriver_act(mob/living/user, obj/item/tool) + return try_deconstruct(user, tool) + +/obj/structure/sign/picture_frame/wrench_act(mob/living/user, obj/item/tool) + return try_deconstruct(user, tool) + +/obj/structure/sign/picture_frame/wirecutter_act(mob/living/user, obj/item/tool) + if (!framed) + return FALSE + tool.play_tool_sound(src) + framed.forceMove(drop_location()) + user.visible_message(span_warning("[user] cuts away [framed] from [src]!")) + framed = null + update_appearance() + return TOOL_ACT_TOOLTYPE_SUCCESS + + /obj/structure/sign/picture_frame/attackby(obj/item/I, mob/user, params) - if(can_decon && (I.tool_behaviour == TOOL_SCREWDRIVER || I.tool_behaviour == TOOL_WRENCH)) - to_chat(user, span_notice("You start unsecuring [name]...")) - if(I.use_tool(src, user, 30, volume=50)) - playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE) - to_chat(user, span_notice("You unsecure [name].")) - deconstruct() - else if(I.tool_behaviour == TOOL_WIRECUTTER && framed) - framed.forceMove(drop_location()) - user.visible_message(span_warning("[user] cuts away [framed] from [src]!")) - framed = null - update_appearance() - return - - else if(istype(I, /obj/item/photo)) - if(!framed) - var/obj/item/photo/P = I - if(!user.transferItemToLoc(P, src)) - return - framed = P - update_appearance() - else + if(istype(I, /obj/item/photo)) + if(framed) to_chat(user, span_warning("\The [src] already contains a photo.")) - + return TRUE + var/obj/item/photo/P = I + if(!user.transferItemToLoc(P, src)) + return + framed = P + update_appearance() + return TRUE ..() /obj/structure/sign/picture_frame/attack_hand(mob/user, list/modifiers)