From 297d2a9ad30ced4bb916c1cbfed64af1af6f338f Mon Sep 17 00:00:00 2001 From: Zonespace <41448081+Zonespace27@users.noreply.github.com> Date: Fri, 7 Jul 2023 03:28:23 +0200 Subject: [PATCH] Fixes some tool checks (#3813) # About the pull request Converts some istype checks into tool trait checks # Explain why it's good for the game So stuff like maint jacks work properly. # Changelog :cl: fix: The maintenance jack should work a little better at crowbarring things. /:cl: --------- Co-authored-by: John Doe --- code/game/machinery/autolathe.dm | 2 +- code/game/machinery/computer/ai_core.dm | 6 +++--- code/game/machinery/computer/buildandrepair.dm | 4 ++-- code/game/machinery/constructable_frame.dm | 2 +- code/game/machinery/doors/windowdoor.dm | 2 +- code/game/machinery/telecomms/machine_interactions.dm | 2 +- code/game/objects/items/tools/maintenance_tools.dm | 4 +--- code/game/objects/structures/props.dm | 4 ++-- code/game/objects/structures/watercloset.dm | 2 +- code/game/turfs/floor.dm | 2 +- code/modules/power/port_gen.dm | 2 +- 11 files changed, 15 insertions(+), 17 deletions(-) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 7a10a3ffa1df..6ccb0b5b18f7 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -284,7 +284,7 @@ return //Dismantle the frame. - if(istype(O, /obj/item/tool/crowbar)) + if(HAS_TRAIT(O, TRAIT_TOOL_CROWBAR)) dismantle() return diff --git a/code/game/machinery/computer/ai_core.dm b/code/game/machinery/computer/ai_core.dm index fd246d2d640a..bb6972a58ac3 100644 --- a/code/game/machinery/computer/ai_core.dm +++ b/code/game/machinery/computer/ai_core.dm @@ -51,7 +51,7 @@ to_chat(user, SPAN_NOTICE(" You screw the circuit board into place.")) state = 2 icon_state = "2" - if(istype(P, /obj/item/tool/crowbar) && circuit) + if(HAS_TRAIT(P, TRAIT_TOOL_CROWBAR) && circuit) playsound(loc, 'sound/items/Crowbar.ogg', 25, 1) to_chat(user, SPAN_NOTICE(" You remove the circuit board.")) state = 1 @@ -121,7 +121,7 @@ to_chat(usr, "Added [mmi].") icon_state = "3b" - if(istype(P, /obj/item/tool/crowbar) && brain) + if(HAS_TRAIT(P, TRAIT_TOOL_CROWBAR) && brain) playsound(loc, 'sound/items/Crowbar.ogg', 25, 1) to_chat(user, SPAN_NOTICE(" You remove the brain.")) brain.forceMove(loc) @@ -129,7 +129,7 @@ icon_state = "3" if(4) - if(istype(P, /obj/item/tool/crowbar)) + if(HAS_TRAIT(P, TRAIT_TOOL_CROWBAR)) playsound(loc, 'sound/items/Crowbar.ogg', 25, 1) to_chat(user, SPAN_NOTICE(" You remove the glass panel.")) state = 3 diff --git a/code/game/machinery/computer/buildandrepair.dm b/code/game/machinery/computer/buildandrepair.dm index bd42b31ea573..07c960807205 100644 --- a/code/game/machinery/computer/buildandrepair.dm +++ b/code/game/machinery/computer/buildandrepair.dm @@ -52,7 +52,7 @@ to_chat(user, SPAN_NOTICE(" You screw the circuit board into place.")) src.state = 2 src.icon_state = "2" - if(istype(P, /obj/item/tool/crowbar) && circuit) + if(HAS_TRAIT(P, TRAIT_TOOL_CROWBAR) && circuit) playsound(src.loc, 'sound/items/Crowbar.ogg', 25, 1) to_chat(user, SPAN_NOTICE(" You remove the circuit board.")) src.state = 1 @@ -99,7 +99,7 @@ src.state = 4 src.icon_state = "4" if(4) - if(istype(P, /obj/item/tool/crowbar)) + if(HAS_TRAIT(P, TRAIT_TOOL_CROWBAR)) playsound(src.loc, 'sound/items/Crowbar.ogg', 25, 1) to_chat(user, SPAN_NOTICE(" You remove the glass panel.")) src.state = 3 diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index 0288b7eb2426..357ef48fff37 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -114,7 +114,7 @@ A.amount = 5 if(CONSTRUCTION_STATE_FINISHED) - if(istype(P, /obj/item/tool/crowbar)) + if(HAS_TRAIT(P, TRAIT_TOOL_CROWBAR)) if(!skillcheck(user, SKILL_ENGINEER, required_dismantle_skill)) to_chat(user, SPAN_WARNING("You are not trained to dismantle machines...")) return diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm index 6d96daf3152f..e9006a9f2fb4 100644 --- a/code/game/machinery/doors/windowdoor.dm +++ b/code/game/machinery/doors/windowdoor.dm @@ -167,7 +167,7 @@ return //If it's emagged, crowbar can pry electronics out. - if (src.operating == -1 && istype(I, /obj/item/tool/crowbar)) + if (src.operating == -1 && HAS_TRAIT(I, TRAIT_TOOL_CROWBAR)) playsound(src.loc, 'sound/items/Crowbar.ogg', 25, 1) user.visible_message("[user] removes the electronics from the windoor.", "You start to remove electronics from the windoor.") if (do_after(user, 40, INTERRUPT_ALL, BUSY_ICON_BUILD)) diff --git a/code/game/machinery/telecomms/machine_interactions.dm b/code/game/machinery/telecomms/machine_interactions.dm index cded8a1148c7..a370356ad60b 100644 --- a/code/game/machinery/telecomms/machine_interactions.dm +++ b/code/game/machinery/telecomms/machine_interactions.dm @@ -62,7 +62,7 @@ stat &= ~BROKEN // the machine's not borked anymore! else to_chat(user, SPAN_WARNING("You need five coils of wire for this.")) - if(istype(P, /obj/item/tool/crowbar)) + if(HAS_TRAIT(P, TRAIT_TOOL_CROWBAR)) to_chat(user, "You begin prying out the circuit board other components...") playsound(src.loc, 'sound/items/Crowbar.ogg', 25, 1) if(do_after(user, 60 * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD)) diff --git a/code/game/objects/items/tools/maintenance_tools.dm b/code/game/objects/items/tools/maintenance_tools.dm index 25bcefc1cc34..2560c5ff91e8 100644 --- a/code/game/objects/items/tools/maintenance_tools.dm +++ b/code/game/objects/items/tools/maintenance_tools.dm @@ -557,8 +557,6 @@ if(attacked_door.locked) //Bolted to_chat(user, SPAN_DANGER("You can't pry open [attacked_door] while it is bolted shut.")) return - if(!attacked_door.arePowerSystemsOn()) //Opens like normal if unpowered - return FALSE if(requires_superstrength_pry) if(!HAS_TRAIT(user, TRAIT_SUPER_STRONG)) //basically IS_PRY_CAPABLE_CROWBAR @@ -645,7 +643,7 @@ resin_door.Open() return - if(istype(attacked_obj, /turf/open/floor)) + else if(istype(attacked_obj, /turf/open/floor)) var/turf/open/floor/flooring = attacked_obj if(crowbar_mode && user.a_intent == INTENT_HELP) //Only pry flooring on help intent diff --git a/code/game/objects/structures/props.dm b/code/game/objects/structures/props.dm index f6905d4d044d..1a91650c620a 100644 --- a/code/game/objects/structures/props.dm +++ b/code/game/objects/structures/props.dm @@ -24,7 +24,7 @@ . = ..() if(isxeno(user)) return - else if (ishuman(user) && istype(W, /obj/item/tool/wrench)) + else if (ishuman(user) && HAS_TRAIT(W, TRAIT_TOOL_WRENCH)) on = !on visible_message("You wrench the controls of \the [src]. The drill jumps to life." , "[user] wrenches the controls of \the [src]. The drill jumps to life.") @@ -501,7 +501,7 @@ . = ..() if(isxeno(user)) return - else if (ishuman(user) && istype(W, /obj/item/tool/crowbar)) + else if (ishuman(user) && HAS_TRAIT(W, TRAIT_TOOL_CROWBAR)) on = !on visible_message("You pry at the control valve on [src]. The machine shudders." , "[user] pries at the control valve on [src]. The entire machine shudders.") diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index 5c084ce94cbc..cccc1211bfb0 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -121,7 +121,7 @@ cistern_overlay.icon_state = "cistern[cistern]" /obj/structure/toilet/attackby(obj/item/I, mob/living/user) - if(istype(I, /obj/item/tool/crowbar)) + if(HAS_TRAIT(I, TRAIT_TOOL_CROWBAR)) to_chat(user, SPAN_NOTICE("You start to [cistern ? "replace the lid on the cistern" : "lift the lid off the cistern"].")) playsound(loc, 'sound/effects/stonedoor_openclose.ogg', 25, 1) if(do_after(user, 30, INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD)) diff --git a/code/game/turfs/floor.dm b/code/game/turfs/floor.dm index 4a600d4d033b..dc2cda0c2c2a 100644 --- a/code/game/turfs/floor.dm +++ b/code/game/turfs/floor.dm @@ -148,7 +148,7 @@ if(src.weeds) return weeds.attackby(hitting_item,user) - if(istype(hitting_item, /obj/item/tool/crowbar) && (tool_flags & (REMOVE_CROWBAR|BREAK_CROWBAR))) + if(HAS_TRAIT(hitting_item, TRAIT_TOOL_CROWBAR) && (tool_flags & (REMOVE_CROWBAR|BREAK_CROWBAR))) if(broken || burnt) to_chat(user, SPAN_WARNING("You remove the broken tiles.")) else diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm index 5a335002d71d..6a20e9cfe78e 100644 --- a/code/modules/power/port_gen.dm +++ b/code/modules/power/port_gen.dm @@ -264,7 +264,7 @@ display round(lastgen) and phorontank amount to_chat(user, SPAN_NOTICE(" You open the access panel.")) else to_chat(user, SPAN_NOTICE(" You close the access panel.")) - else if(istype(O, /obj/item/tool/crowbar) && open) + else if(HAS_TRAIT(O, TRAIT_TOOL_CROWBAR) && open) var/obj/structure/machinery/constructable_frame/new_frame = new /obj/structure/machinery/constructable_frame(src.loc) for(var/obj/item/I in component_parts) if(I.reliability < 100)