From 65d4dca8681c286dc9b9641512388011d520ea04 Mon Sep 17 00:00:00 2001 From: emmanuelbassil <6874235+emmanuelbassil@users.noreply.github.com> Date: Tue, 23 Jan 2024 00:31:35 +0300 Subject: [PATCH] [MIRROR] Turf to use_tool --- .../game/gamemodes/cult/cultify/de-cultify.dm | 18 +- code/game/machinery/floorlayer.dm | 2 +- code/game/turfs/simulated.dm | 4 +- code/game/turfs/simulated/floor_attackby.dm | 157 +++++++++-------- code/game/turfs/simulated/floor_static.dm | 6 +- code/game/turfs/simulated/wall_attacks.dm | 166 ++++++++---------- code/game/turfs/space/space.dm | 46 ++--- code/modules/mining/mine_turfs.dm | 42 +++-- code/modules/multiz/turf.dm | 43 +++-- code/modules/overmap/exoplanets/turfs.dm | 20 ++- test/check-paths.sh | 2 +- 11 files changed, 259 insertions(+), 247 deletions(-) diff --git a/code/game/gamemodes/cult/cultify/de-cultify.dm b/code/game/gamemodes/cult/cultify/de-cultify.dm index f34da0848cc1a..601280befd00e 100644 --- a/code/game/gamemodes/cult/cultify/de-cultify.dm +++ b/code/game/gamemodes/cult/cultify/de-cultify.dm @@ -1,29 +1,29 @@ -/turf/unsimulated/wall/cult/attackby(obj/item/I, mob/user) +/turf/unsimulated/wall/cult/use_tool(obj/item/I, mob/living/user, list/click_params) if(istype(I, /obj/item/nullrod)) user.visible_message(SPAN_NOTICE("\The [user] touches \the [src] with \the [I], and it shifts."), SPAN_NOTICE("You touch \the [src] with \the [I], and it shifts.")) ChangeTurf(/turf/unsimulated/wall) - return - ..() + return TRUE + return ..() -/turf/simulated/wall/cult/attackby(obj/item/I, mob/user) +/turf/simulated/wall/cult/use_tool(obj/item/I, mob/living/user, list/click_params) if (istype(I, /obj/item/nullrod)) user.visible_message( SPAN_NOTICE("\The [user] touches \the [src] with \the [I], and it shifts."), SPAN_NOTICE("You touch \the [src] with \the [I], and it shifts.") ) decultify_wall() - return - ..() + return TRUE + return ..() -/turf/simulated/floor/cult/attackby(obj/item/I, mob/user) +/turf/simulated/floor/cult/use_tool(obj/item/I, mob/living/user, list/click_params) if (istype(I, /obj/item/nullrod)) user.visible_message( SPAN_NOTICE("\The [user] touches \the [src] with \the [I], and it shifts."), SPAN_NOTICE("You touch \the [src] with \the [I], and it shifts.") ) decultify_floor() - return - ..() + return TRUE + return ..() /turf/proc/decultify_wall() var/turf/simulated/wall/cult/wall = src diff --git a/code/game/machinery/floorlayer.dm b/code/game/machinery/floorlayer.dm index fe1f9be8449f0..8284dca768e8b 100644 --- a/code/game/machinery/floorlayer.dm +++ b/code/game/machinery/floorlayer.dm @@ -105,7 +105,7 @@ if(!T) if(!TakeNewStack()) return 0 - w_turf.attackby(T , src) + w_turf.use_tool(T , src) return 1 /obj/machinery/floorlayer/proc/TakeTile(obj/item/stack/tile/tile) diff --git a/code/game/turfs/simulated.dm b/code/game/turfs/simulated.dm index 78baf8d0c573e..1d318050c752c 100644 --- a/code/game/turfs/simulated.dm +++ b/code/game/turfs/simulated.dm @@ -159,11 +159,11 @@ /turf/simulated/proc/can_build_cable(mob/user) return 0 -/turf/simulated/attackby(obj/item/thing, mob/user) +/turf/simulated/use_tool(obj/item/thing, mob/living/user, list/click_params) if(isCoil(thing) && can_build_cable(user)) var/obj/item/stack/cable_coil/coil = thing coil.PlaceCableOnTurf(src, user) - return + return TRUE return ..() /turf/simulated/Initialize() diff --git a/code/game/turfs/simulated/floor_attackby.dm b/code/game/turfs/simulated/floor_attackby.dm index 67d64603e8a71..385ed1245d277 100644 --- a/code/game/turfs/simulated/floor_attackby.dm +++ b/code/game/turfs/simulated/floor_attackby.dm @@ -1,28 +1,22 @@ -/turf/simulated/floor/attackby(obj/item/C, mob/user) - +/turf/simulated/floor/use_tool(obj/item/C, mob/living/user, list/click_params) var/area/A = get_area(src) if (!A.can_modify_area()) visible_message("\The [src] cannot be dismantled or modified in any way!") - return - - if(!C || !user) - return 0 + return TRUE if(isCoil(C) || (flooring && istype(C, /obj/item/stack/material/rods))) return ..(C, user) if(!(isScrewdriver(C) && flooring && (flooring.flags & TURF_REMOVE_SCREWDRIVER)) && try_graffiti(user, C)) - return + return TRUE if(flooring) if(isCrowbar(C)) - if(user.a_intent != I_HELP) - return if(broken || burnt) to_chat(user, SPAN_NOTICE("You remove the broken [flooring.descriptor].")) make_plating() else if(flooring.flags & TURF_IS_FRAGILE) - to_chat(user, SPAN_DANGER("You forcefully pry off the [flooring.descriptor], destroying them in the process.")) + to_chat(user, SPAN_DANGER("You forcefully pry off \the [flooring.descriptor], destroying them in the process.")) make_plating() else if(flooring.flags & TURF_REMOVE_CROWBAR) if (flooring.remove_timer) @@ -38,17 +32,19 @@ ) make_plating(TRUE) playsound(src, 'sound/items/Crowbar.ogg', 80, 1) - return + return TRUE else - to_chat(user, SPAN_NOTICE("You lever off the [flooring.descriptor].")) + to_chat(user, SPAN_NOTICE("You lever off \the [flooring.descriptor].")) make_plating(TRUE) else - return + return ..() + playsound(src, 'sound/items/Crowbar.ogg', 80, 1) - return + return TRUE + else if(isScrewdriver(C) && (flooring.flags & TURF_REMOVE_SCREWDRIVER)) if(broken || burnt) - return + return ..() if (flooring.remove_timer) user.visible_message( SPAN_NOTICE("\The [user] begins unscrewing \the [flooring.descriptor] with \the [C]!"), @@ -62,12 +58,13 @@ ) make_plating(TRUE) playsound(src, 'sound/items/Screwdriver.ogg', 80, 1) - return + return TRUE else - to_chat(user, SPAN_NOTICE("You unscrew and remove the [flooring.descriptor].")) + to_chat(user, SPAN_NOTICE("You unscrew and remove \the [flooring.descriptor].")) make_plating(TRUE) playsound(src, 'sound/items/Screwdriver.ogg', 80, 1) - return + return TRUE + else if(isWrench(C) && (flooring.flags & TURF_REMOVE_WRENCH)) if (flooring.remove_timer) user.visible_message( @@ -82,35 +79,43 @@ ) make_plating(TRUE) playsound(src, 'sound/items/Ratchet.ogg', 80, 1) - return + return TRUE else - to_chat(user, SPAN_NOTICE("You unwrench and remove the [flooring.descriptor].")) + to_chat(user, SPAN_NOTICE("You unwrench and remove \the [flooring.descriptor].")) make_plating(TRUE) playsound(src, 'sound/items/Ratchet.ogg', 80, 1) - return + return TRUE + else if(istype(C, /obj/item/shovel) && (flooring.flags & TURF_REMOVE_SHOVEL)) - to_chat(user, SPAN_NOTICE("You shovel off the [flooring.descriptor].")) + to_chat(user, SPAN_NOTICE("You shovel off \the [flooring.descriptor].")) make_plating(1) playsound(src, 'sound/items/Deconstruct.ogg', 80, 1) - return + return TRUE + else if(isCoil(C)) - to_chat(user, SPAN_WARNING("You must remove the [flooring.descriptor] first.")) - return - else + to_chat(user, SPAN_WARNING("You must remove \the [flooring.descriptor] first.")) + return TRUE + else if(istype(C, /obj/item/stack)) if(broken || burnt) to_chat(user, SPAN_WARNING("This section is too damaged to support anything. Use a welder to fix the damage.")) - return + return TRUE //first check, catwalk? Else let flooring do its thing if(locate(/obj/structure/catwalk, src)) - return + return ..() + if (istype(C, /obj/item/stack/material/rods)) var/obj/item/stack/material/rods/R = C - if (R.use(2)) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - new /obj/structure/catwalk(src) - return + if (!R.can_use(2)) + USE_FEEDBACK_STACK_NOT_ENOUGH(R, 2, "to build the catwalk.") + return TRUE + + R.use(2) + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + new /obj/structure/catwalk(src) + return TRUE + var/obj/item/stack/S = C var/singleton/flooring/use_flooring var/list/singletons = GET_SINGLETON_SUBTYPE_MAP(/singleton/flooring) @@ -122,70 +127,72 @@ use_flooring = F break if(!use_flooring) - return - // Do we have enough? + return TRUE + if(use_flooring.build_cost && S.get_amount() < use_flooring.build_cost) - to_chat(user, SPAN_WARNING("You require at least [use_flooring.build_cost] [S.name] to complete the [use_flooring.descriptor].")) - return - // Stay still and focus... + to_chat(user, SPAN_WARNING("You require at least [use_flooring.build_cost] [S.name] to complete \the [use_flooring.descriptor].")) + return TRUE + if(use_flooring.build_time && !do_after(user, use_flooring.build_time, src, DO_REPAIR_CONSTRUCT)) - return + return TRUE if(flooring || !S || !user || !use_flooring) - return + return TRUE if(S.use(use_flooring.build_cost)) set_flooring(use_flooring) playsound(src, 'sound/items/Deconstruct.ogg', 80, 1) - return + return TRUE + // Repairs and Deconstruction. - else if(isCrowbar(C)) - if(broken || burnt) - playsound(src, 'sound/items/Crowbar.ogg', 80, 1) - visible_message(SPAN_NOTICE("[user] has begun prying off the damaged plating.")) - var/turf/T = GetBelow(src) - if(T) - T.visible_message(SPAN_WARNING("The ceiling above looks as if it's being pried off.")) - if(do_after(user, (C.toolspeed * 10) SECONDS, src, DO_REPAIR_CONSTRUCT)) - if(!istype(src, /turf/simulated/floor)) - return - if(!broken && !burnt || !(is_plating())) - return - visible_message(SPAN_WARNING("[user] has pried off the damaged plating.")) - new /obj/item/stack/tile/floor(src) - src.ReplaceWithLattice() - playsound(src, 'sound/items/Deconstruct.ogg', 80, 1) - if(T) - T.visible_message(SPAN_DANGER("The ceiling above has been pried off!")) - else - return - return + else if (isCrowbar(C) && (broken || burnt)) + playsound(src, 'sound/items/Crowbar.ogg', 80, 1) + visible_message(SPAN_NOTICE("\The [user] has begun prying off the damaged plating.")) + var/turf/T = GetBelow(src) + if(T) + T.visible_message(SPAN_WARNING("The ceiling above looks as if it's being pried off.")) + if (!do_after(user, (C.toolspeed * 10) SECONDS, src, DO_REPAIR_CONSTRUCT)) + return TRUE + if (!istype(src, /turf/simulated/floor)) + return TRUE + if (!broken && !burnt || !(is_plating())) + return TRUE + visible_message(SPAN_WARNING("\The [user] has pried off the damaged plating.")) + new /obj/item/stack/tile/floor(src) + ReplaceWithLattice() + playsound(src, 'sound/items/Deconstruct.ogg', 80, 1) + if(T) + T.visible_message(SPAN_DANGER("The ceiling above has been pried off!")) + return TRUE + else if(isWelder(C)) var/obj/item/weldingtool/welder = C if(welder.can_use(2, user) && (is_plating())) if(broken || burnt) - if(welder.remove_fuel(2, user)) - to_chat(user, SPAN_NOTICE("You fix some dents on the broken plating.")) - playsound(src, 'sound/items/Welder.ogg', 80, 1) - icon_state = "plating" - burnt = null - broken = null - return + welder.remove_fuel(2, user) + to_chat(user, SPAN_NOTICE("You fix some dents on the broken plating.")) + playsound(src, 'sound/items/Welder.ogg', 80, 1) + icon_state = "plating" + burnt = null + broken = null + return TRUE else - if(welder.remove_fuel(2, user)) + welder.remove_fuel(2, user) + playsound(src, 'sound/items/Welder.ogg', 80, 1) + visible_message(SPAN_NOTICE("\The [user] has started melting the plating's reinforcements!")) + if(do_after(user, (C.toolspeed * 5) SECONDS, src, DO_REPAIR_CONSTRUCT) && welder.isOn() && welder_melt()) + visible_message(SPAN_WARNING("\The [user] has melted the plating's reinforcements! It should be possible to pry it off.")) playsound(src, 'sound/items/Welder.ogg', 80, 1) - visible_message(SPAN_NOTICE("[user] has started melting the plating's reinforcements!")) - if(do_after(user, (C.toolspeed * 5) SECONDS, src, DO_REPAIR_CONSTRUCT) && welder.isOn() && welder_melt()) - visible_message(SPAN_WARNING("[user] has melted the plating's reinforcements! It should be possible to pry it off.")) - playsound(src, 'sound/items/Welder.ogg', 80, 1) - return + return TRUE + else if(istype(C, /obj/item/gun/energy/plasmacutter) && (is_plating()) && !broken && !burnt) var/obj/item/gun/energy/plasmacutter/cutter = C if(!cutter.slice(user)) return ..() playsound(src, 'sound/items/Welder.ogg', 80, 1) - visible_message(SPAN_NOTICE("[user] has started slicing through the plating's reinforcements!")) + visible_message(SPAN_NOTICE("\The [user] has started slicing through the plating's reinforcements!")) if(do_after(user, (C.toolspeed * 3) SECONDS, src, DO_PUBLIC_UNIQUE) && welder_melt()) visible_message(SPAN_WARNING("[user] has sliced through the plating's reinforcements! It should be possible to pry it off.")) playsound(src, 'sound/items/Welder.ogg', 80, 1) + return TRUE return ..() diff --git a/code/game/turfs/simulated/floor_static.dm b/code/game/turfs/simulated/floor_static.dm index 13f77cb755126..4ac85751b0c36 100644 --- a/code/game/turfs/simulated/floor_static.dm +++ b/code/game/turfs/simulated/floor_static.dm @@ -8,7 +8,7 @@ initial_flooring = null footstep_type = /singleton/footsteps/plating -/turf/simulated/floor/fixed/attackby(obj/item/C, mob/user) +/turf/simulated/floor/fixed/use_tool(obj/item/C, mob/living/user, list/click_params) if(istype(C, /obj/item/stack) && !isCoil(C)) return return ..() @@ -28,10 +28,10 @@ icon = 'icons/turf/flooring/alium.dmi' icon_state = "jaggy" -/turf/simulated/floor/fixed/alium/attackby(obj/item/C, mob/user) +/turf/simulated/floor/fixed/alium/use_tool(obj/item/C, mob/living/user, list/click_params) if(isCrowbar(C)) to_chat(user, SPAN_NOTICE("There aren't any openings big enough to pry it away...")) - return + return TRUE return ..() /turf/simulated/floor/fixed/alium/New() diff --git a/code/game/turfs/simulated/wall_attacks.dm b/code/game/turfs/simulated/wall_attacks.dm index 0ab3e4789babb..b0f8014eabf92 100644 --- a/code/game/turfs/simulated/wall_attacks.dm +++ b/code/game/turfs/simulated/wall_attacks.dm @@ -150,86 +150,85 @@ return fail_smash(user) -/turf/simulated/wall/attackby(obj/item/W, mob/user) - +/turf/simulated/wall/use_tool(obj/item/W, mob/living/user, list/click_params) var/area/A = get_area(src) if (!A.can_modify_area()) to_chat(user, SPAN_NOTICE("\The [src] deflects all attempts to interact with it!")) - return + return TRUE user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(!construction_stage && try_graffiti(user, W)) - return + return TRUE if (!user.IsAdvancedToolUser()) to_chat(user, SPAN_WARNING("You don't have the dexterity to do this!")) - return + return TRUE - //get the user's location - if(!istype(user.loc, /turf)) return //can't do this stuff whilst inside objects and such + if(!istype(user.loc, /turf)) + return ..() - if(W) - radiate() - var/heat_value = W.IsHeatSource() - if (heat_value) - burn(heat_value) + radiate() + var/heat_value = W.IsHeatSource() + if (heat_value) + burn(heat_value) if(locate(/obj/overlay/wallrot) in src) if(isWelder(W)) var/obj/item/weldingtool/WT = W - if( WT.remove_fuel(1,user) ) - to_chat(user, SPAN_NOTICE("You burn away the fungi with \the [WT].")) - playsound(src, 'sound/items/Welder.ogg', 10, 1) - for(var/obj/overlay/wallrot/WR in src) - qdel(WR) - return + if(!WT.can_use(1, user)) + return TRUE + + WT.remove_fuel(1,user) + to_chat(user, SPAN_NOTICE("You burn away the fungi with \the [WT].")) + playsound(src, 'sound/items/Welder.ogg', 10, 1) + for(var/obj/overlay/wallrot/WR in src) + qdel(WR) + return TRUE + else if(!is_sharp(W) && W.force >= 10 || W.force >= 20) to_chat(user, SPAN_NOTICE("\The [src] crumbles away under the force of your [W.name].")) kill_health() - return + return TRUE //THERMITE related stuff. Calls src.thermitemelt() which handles melting simulated walls and the relevant effects if(thermite) if(isWelder(W)) var/obj/item/weldingtool/WT = W - if( WT.remove_fuel(1,user) ) - thermitemelt(user) - return + if(!WT.can_use(1, user)) + return TRUE + WT.remove_fuel(1, user) + thermitemelt(user) + return TRUE else if(istype(W, /obj/item/gun/energy/plasmacutter)) thermitemelt(user) - return + return TRUE else if( istype(W, /obj/item/melee/energy/blade) ) var/obj/item/melee/energy/blade/EB = W - EB.spark_system.start() to_chat(user, SPAN_NOTICE("You slash \the [src] with \the [EB]; the thermite ignites!")) playsound(src, "sparks", 50, 1) playsound(src, 'sound/weapons/blade1.ogg', 50, 1) - thermitemelt(user) - return + return TRUE var/turf/T = user.loc //get user's location for delay checks var/damage = get_damage_value() if(damage && istype(W, /obj/item/weldingtool)) - var/obj/item/weldingtool/WT = W - if(WT.can_use(2, user)) to_chat(user, SPAN_NOTICE("You start repairing the damage to [src].")) playsound(src, 'sound/items/Welder.ogg', 100, 1) if(do_after(user, max(5, damage / 5), src, DO_REPAIR_CONSTRUCT) && WT.remove_fuel(2, user)) to_chat(user, SPAN_NOTICE("You finish repairing the damage to [src].")) restore_health(damage) - return + return TRUE // Basic dismantling. if(isnull(construction_stage) || !reinf_material) - var/cut_delay = 60 - material.cut_delay var/dismantle_verb var/dismantle_sound @@ -237,20 +236,23 @@ if(istype(W,/obj/item/weldingtool)) var/obj/item/weldingtool/WT = W - if(!WT.remove_fuel(1,user)) - return + if(!WT.can_use(1,user)) + return TRUE dismantle_verb = "cutting" dismantle_sound = 'sound/items/Welder.ogg' cut_delay *= 0.7 + WT.remove_fuel(1, user) + else if(istype(W,/obj/item/melee/energy/blade) || istype(W,/obj/item/psychic_power/psiblade/master) || istype(W, /obj/item/gun/energy/plasmacutter)) if(istype(W, /obj/item/gun/energy/plasmacutter)) var/obj/item/gun/energy/plasmacutter/cutter = W if(!cutter.slice(user)) - return + return TRUE dismantle_sound = "sparks" dismantle_verb = "slicing" cut_delay *= 0.5 strict_timer_flags = TRUE + else if(istype(W,/obj/item/pickaxe)) var/obj/item/pickaxe/P = W dismantle_verb = P.drill_verb @@ -259,7 +261,6 @@ strict_timer_flags = TRUE if(dismantle_verb) - to_chat(user, SPAN_NOTICE("You begin [dismantle_verb] through the outer plating.")) if(dismantle_sound) playsound(src, dismantle_sound, 100, 1) @@ -270,156 +271,141 @@ if (do_after(user, cut_delay, src, strict_timer_flags ? DO_PUBLIC_UNIQUE : DO_REPAIR_CONSTRUCT)) dismantle_wall() user.visible_message(SPAN_WARNING("\The [src] was torn open by [user]!"), SPAN_NOTICE("You remove the outer plating.")) - return - else - return + return TRUE //Reinforced dismantling. else switch(construction_stage) if(6) - if(istype(W, /obj/item/psychic_power/psiblade/master/grand/paramount)) - to_chat(user, SPAN_NOTICE("You sink \the [W] into the wall and begin trying to rip out the support frame...")) playsound(src, 'sound/items/Welder.ogg', 100, 1) if(!do_after(user, 6 SECONDS, src, DO_PUBLIC_UNIQUE)) - return + return TRUE to_chat(user, SPAN_NOTICE("You tear through the wall's support system and plating!")) kill_health() user.visible_message(SPAN_WARNING("The wall was torn open by [user]!")) playsound(src, 'sound/items/Welder.ogg', 100, 1) + return TRUE else if(isWirecutter(W)) - playsound(src, 'sound/items/Wirecutter.ogg', 100, 1) construction_stage = 5 new /obj/item/stack/material/rods( src ) to_chat(user, SPAN_NOTICE("You cut the outer grille.")) update_icon() - return + return TRUE if(5) if(isScrewdriver(W)) to_chat(user, SPAN_NOTICE("You begin removing the support lines.")) playsound(src, 'sound/items/Screwdriver.ogg', 100, 1) if(!do_after(user, (W.toolspeed * 4) SECONDS, src, DO_REPAIR_CONSTRUCT) || construction_stage != 5) - return + return TRUE construction_stage = 4 update_icon() to_chat(user, SPAN_NOTICE("You remove the support lines.")) - return + return TRUE else if( istype(W, /obj/item/stack/material/rods) ) var/obj/item/stack/O = W - if(O.use(1)) - construction_stage = 6 - update_icon() - to_chat(user, SPAN_NOTICE("You replace the outer grille.")) - return + if (!O.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(O, user, "to replace the outer grille.") + return TRUE + O.use(1) + construction_stage = 6 + update_icon() + to_chat(user, SPAN_NOTICE("You replace the outer grille.")) + return TRUE if(4) var/cut_cover var/strict_timer_flags = FALSE if(istype(W,/obj/item/weldingtool)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(1,user)) - cut_cover=1 - else - return + if(!WT.can_use(1, user)) + return TRUE + WT.remove_fuel(1, user) + cut_cover=1 + else if (istype(W, /obj/item/gun/energy/plasmacutter) || istype(W, /obj/item/psychic_power/psiblade/master)) if(istype(W, /obj/item/gun/energy/plasmacutter)) var/obj/item/gun/energy/plasmacutter/cutter = W if(!cutter.slice(user)) - return + return TRUE cut_cover = 1 strict_timer_flags = TRUE + if(cut_cover) to_chat(user, SPAN_NOTICE("You begin slicing through the metal cover.")) playsound(src, 'sound/items/Welder.ogg', 100, 1) if(!do_after(user, (W.toolspeed * 6) SECONDS, src, strict_timer_flags ? DO_PUBLIC_UNIQUE : DO_REPAIR_CONSTRUCT) || construction_stage != 4) - return + return TRUE construction_stage = 3 update_icon() to_chat(user, SPAN_NOTICE("You press firmly on the cover, dislodging it.")) - return + return TRUE if(3) if(isCrowbar(W)) to_chat(user, SPAN_NOTICE("You struggle to pry off the cover.")) playsound(src, 'sound/items/Crowbar.ogg', 100, 1) if(!do_after(user, (W.toolspeed * 10) SECONDS, src, DO_REPAIR_CONSTRUCT) || construction_stage != 3) - return + return TRUE construction_stage = 2 update_icon() to_chat(user, SPAN_NOTICE("You pry off the cover.")) - return + return TRUE if(2) if(isWrench(W)) to_chat(user, SPAN_NOTICE("You start loosening the anchoring bolts which secure the support rods to their frame.")) playsound(src, 'sound/items/Ratchet.ogg', 100, 1) if(!do_after(user, (W.toolspeed * 4) SECONDS, src, DO_REPAIR_CONSTRUCT) || construction_stage != 2) - return + return TRUE construction_stage = 1 update_icon() to_chat(user, SPAN_NOTICE("You remove the bolts anchoring the support rods.")) - return + return TRUE if(1) var/cut_cover var/strict_timer_flags = FALSE if(istype(W, /obj/item/weldingtool)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(1,user)) - cut_cover=1 - else - return + if(!WT.can_use(1, user)) + return TRUE + WT.remove_fuel(1, user) + cut_cover=1 + else if(istype(W, /obj/item/gun/energy/plasmacutter) || istype(W,/obj/item/psychic_power/psiblade/master)) if(istype(W, /obj/item/gun/energy/plasmacutter)) var/obj/item/gun/energy/plasmacutter/cutter = W if(!cutter.slice(user)) - return + return TRUE cut_cover = 1 strict_timer_flags = TRUE + if(cut_cover) to_chat(user, SPAN_NOTICE("You begin slicing through the support rods.")) playsound(src, 'sound/items/Welder.ogg', 100, 1) if(!do_after(user, (W.toolspeed * 7) SECONDS, src, strict_timer_flags ? DO_PUBLIC_UNIQUE : DO_REPAIR_CONSTRUCT) || construction_stage != 1) - return + return TRUE construction_stage = 0 update_icon() new /obj/item/stack/material/rods(src) to_chat(user, SPAN_NOTICE("The support rods drop out as you cut them loose from the frame.")) - return + return TRUE if(0) if(isCrowbar(W)) to_chat(user, SPAN_NOTICE("You struggle to pry off the outer sheath.")) playsound(src, 'sound/items/Crowbar.ogg', 100, 1) - if(!do_after(user, (W.toolspeed * 10) SECONDS, src, DO_REPAIR_CONSTRUCT) || !W || !T ) return + if(!do_after(user, (W.toolspeed * 10) SECONDS, src, DO_REPAIR_CONSTRUCT) || !W || !T ) + return TRUE if(user.loc == T && user.get_active_hand() == W ) to_chat(user, SPAN_NOTICE("You pry off the outer sheath.")) dismantle_wall() - return + return TRUE if(istype(W,/obj/item/frame)) var/obj/item/frame/F = W F.try_build(src) - return + return TRUE - else if(!istype(W,/obj/item/rcd) && !istype(W, /obj/item/reagent_containers)) - if(!W.force) - return attack_hand(user) - - if (!can_damage_health(W.force, W.damtype)) - playsound(src, hitsound, 25, 1) - user.visible_message( - SPAN_WARNING("\The [user] attacks \the [src] with \the [W], but it bounces off!"), - SPAN_WARNING("You attack \the [src] with \the [W], but it bounces off! You need something stronger."), - SPAN_WARNING("You hear the sound of something hitting a wall.") - ) - return - playsound(src, hitsound, 50, 1) - user.visible_message( - SPAN_DANGER("\The [user] attacks \the [src] with \the [W]!"), - SPAN_WARNING("You attack \the [src] with \the [W]!"), - SPAN_WARNING("You hear the sound of something hitting a wall.") - ) - damage_health(W.force, W.damtype, skip_can_damage_check = TRUE) - return + return ..() diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index 016e0d2e26ad0..9c73f4d0374ba 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -76,31 +76,37 @@ if(TURF_IS_AMBIENT_LIT_UNSAFE(src)) remove_starlight() -/turf/space/attackby(obj/item/C as obj, mob/user as mob) - +/turf/space/use_tool(obj/item/C, mob/living/user, list/click_params) if (istype(C, /obj/item/stack/material/rods)) var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) if(L) - return L.attackby(C, user) + return L.use_tool(C, user) var/obj/item/stack/material/rods/R = C - if (R.use(1)) - to_chat(user, SPAN_NOTICE("You lay down the support lattice.")) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - ReplaceWithLattice(R.material.name) - return + if (!R.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.") + return TRUE + + to_chat(user, SPAN_NOTICE("You lay down the support lattice.")) + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + ReplaceWithLattice(R.material.name) + R.use(1) + return TRUE if (istype(C, /obj/item/stack/tile)) var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) - if(L) - var/obj/item/stack/tile/floor/S = C - if (!S.use(1)) - return - qdel(L) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE) - return - else + if(!L) to_chat(user, SPAN_WARNING("The plating is going to need some support.")) + return TRUE + var/obj/item/stack/tile/floor/S = C + if (!S.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to place the plating.") + return TRUE + + qdel(L) + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE) + S.use(1) + return TRUE //Checking if the user attacked with a cable coil if(isCoil(C)) @@ -108,12 +114,12 @@ var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) if(L) coil.PlaceCableOnTurf(src, user) - return + return TRUE else to_chat(user, SPAN_WARNING("The cable needs something to be secured to.")) - return + return TRUE - return + return ..() // Ported from unstable r355 diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index 4ed4f2d0d8a23..6f3fcea1303b5 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -145,29 +145,28 @@ var/global/list/mining_floors = list() ore_overlay.turf_decal_layerise() update_icon() -//Not even going to touch this pile of spaghetti -/turf/simulated/mineral/attackby(obj/item/W as obj, mob/user as mob) +/turf/simulated/mineral/use_tool(obj/item/W, mob/living/user, list/click_params) if (!user.IsAdvancedToolUser()) to_chat(usr, SPAN_WARNING("You don't have the dexterity to do this!")) - return + return TRUE if (istype(W, /obj/item/device/core_sampler)) geologic_data.UpdateNearbyArtifactInfo(src) var/obj/item/device/core_sampler/C = W C.sample_item(src, user) - return + return TRUE if (istype(W, /obj/item/device/depth_scanner)) var/obj/item/device/depth_scanner/C = W C.scan_atom(user, src) - return + return TRUE if (istype(W, /obj/item/device/measuring_tape)) var/obj/item/device/measuring_tape/P = W user.visible_message(SPAN_NOTICE("\The [user] extends [P] towards [src]."),SPAN_NOTICE("You extend [P] towards [src].")) if(do_after(user, 1 SECOND, src, DO_PUBLIC_UNIQUE)) to_chat(user, SPAN_NOTICE("\The [src] has been excavated to a depth of [excavation_level]cm.")) - return + return TRUE if (istype(W, /obj/item/pickaxe)) if(!istype(user.loc, /turf)) @@ -175,9 +174,10 @@ var/global/list/mining_floors = list() var/obj/item/pickaxe/P = W if(last_act + P.digspeed > world.time)//prevents message spam - return - last_act = world.time + to_chat(user, SPAN_WARNING("You cannot use \the [W] again so soon!")) + return TRUE + last_act = world.time playsound(user, P.drill_sound, 20, 1) var/newDepth = excavation_level + P.excavation_amount // Used commonly below @@ -226,7 +226,7 @@ var/global/list/mining_floors = list() GetDrilled(0) else GetDrilled(1) - return + return TRUE excavation_level += P.excavation_amount var/updateIcon = 0 @@ -270,6 +270,7 @@ var/global/list/mining_floors = list() var/obj/item/ore/O = new(src) geologic_data.UpdateNearbyArtifactInfo(src) O.geologic_data = geologic_data + return TRUE else return ..() @@ -447,10 +448,7 @@ var/global/list/mining_floors = list() /turf/simulated/floor/asteroid/is_plating() return !density -/turf/simulated/floor/asteroid/attackby(obj/item/W as obj, mob/user as mob) - if(!W || !user) - return 0 - +/turf/simulated/floor/asteroid/use_tool(obj/item/W, mob/living/user, list/click_params) var/list/usable_tools = list( /obj/item/shovel, /obj/item/pickaxe/diamonddrill, @@ -467,7 +465,7 @@ var/global/list/mining_floors = list() if(valid_tool) if (dug) to_chat(user, SPAN_WARNING("This area has already been dug")) - return + return TRUE var/turf/T = user.loc if (!(istype(T))) @@ -476,27 +474,27 @@ var/global/list/mining_floors = list() to_chat(user, SPAN_WARNING("You start digging.")) playsound(user.loc, 'sound/effects/rustle1.ogg', 50, 1) - if(!do_after(user, 4 SECONDS, src, DO_DEFAULT | DO_PUBLIC_PROGRESS)) return + if (!do_after(user, 4 SECONDS, src, DO_DEFAULT | DO_PUBLIC_PROGRESS)) + return TRUE to_chat(user, SPAN_NOTICE("You dug a hole.")) gets_dug() + return TRUE else if(istype(W,/obj/item/storage/ore)) var/obj/item/storage/ore/S = W if(!S.quick_gather_single) for(var/obj/item/ore/O in contents) - O.attackby(W,user) - return + O.use_tool(W, user) + return TRUE else if(istype(W,/obj/item/storage/bag/fossils)) var/obj/item/storage/bag/fossils/S = W if(!S.quick_gather_single) for(var/obj/item/fossil/F in contents) - F.attackby(W,user) - return - + F.use_tool(W,user) + return TRUE else - ..(W,user) - + return ..() /turf/simulated/floor/asteroid/proc/gets_dug() diff --git a/code/modules/multiz/turf.dm b/code/modules/multiz/turf.dm index 9d30f234c8d45..0126675703b1d 100644 --- a/code/modules/multiz/turf.dm +++ b/code/modules/multiz/turf.dm @@ -63,40 +63,47 @@ /turf/simulated/open/is_open() return TRUE -/turf/simulated/open/attackby(obj/item/C, mob/user) +/turf/simulated/open/use_tool(obj/item/C, mob/living/user, list/click_params) if (istype(C, /obj/item/stack/material/rods)) var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) if(L) - return L.attackby(C, user) + return L.use_tool(C, user) var/obj/item/stack/material/rods/R = C - if (R.use(1)) - to_chat(user, SPAN_NOTICE("You lay down the support lattice.")) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - new /obj/structure/lattice(locate(src.x, src.y, src.z), R.material.name) - return + if (!R.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.") + return TRUE + to_chat(user, SPAN_NOTICE("You lay down the support lattice.")) + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + new /obj/structure/lattice(locate(src.x, src.y, src.z), R.material.name) + return TRUE if (istype(C, /obj/item/stack/tile)) var/obj/structure/lattice/L = locate(/obj/structure/lattice, src) - if(L) - var/obj/item/stack/tile/floor/S = C - if (!S.use(1)) - return - qdel(L) - playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) - ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE) - return - else + if(!L) to_chat(user, SPAN_WARNING("The plating is going to need some support.")) + return TRUE + + var/obj/item/stack/tile/floor/S = C + if (!S.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to plate the lattice.") + return TRUE + + qdel(L) + playsound(src, 'sound/weapons/Genhit.ogg', 50, 1) + ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE) + return TRUE //To lay cable. if(isCoil(C)) var/obj/item/stack/cable_coil/coil = C coil.PlaceCableOnTurf(src, user) - return + return TRUE for(var/atom/movable/M in below) if(M.movable_flags & MOVABLE_FLAG_Z_INTERACT) - return M.attackby(C, user) + return C.resolve_attackby(M, user) + + return ..() /turf/simulated/open/attack_hand(mob/user) for(var/atom/movable/M in below) diff --git a/code/modules/overmap/exoplanets/turfs.dm b/code/modules/overmap/exoplanets/turfs.dm index 1d19f30786657..eecf4e39e0c12 100644 --- a/code/modules/overmap/exoplanets/turfs.dm +++ b/code/modules/overmap/exoplanets/turfs.dm @@ -25,7 +25,7 @@ ChangeArea(src, E.planetary_area) ..() -/turf/simulated/floor/exoplanet/attackby(obj/item/C, mob/user) +/turf/simulated/floor/exoplanet/use_tool(obj/item/C, mob/living/user, list/click_params) if(diggable && istype(C,/obj/item/shovel)) visible_message(SPAN_NOTICE("\The [user] starts digging \the [src]")) if(do_after(user, 5 SECONDS, src, DO_PUBLIC_UNIQUE)) @@ -34,15 +34,22 @@ diggable = 0 else to_chat(user,SPAN_NOTICE("You stop shoveling.")) + return TRUE + else if(istype(C, /obj/item/stack/tile)) var/obj/item/stack/tile/T = C - if(T.use(1)) - playsound(src, 'sound/items/Deconstruct.ogg', 80, 1) - ChangeTurf(/turf/simulated/floor, FALSE, FALSE, TRUE) + if(!T.can_use(1)) + USE_FEEDBACK_STACK_NOT_ENOUGH(T, 1, "to place a tile.") + return TRUE + T.use(1) + playsound(src, 'sound/items/Deconstruct.ogg', 80, 1) + ChangeTurf(/turf/simulated/floor, FALSE, FALSE, TRUE) + return TRUE + else if (isCrowbar(C) || isWelder(C) || istype(C, /obj/item/gun/energy/plasmacutter)) return else - ..() + return ..() /turf/simulated/floor/exoplanet/ex_act(severity) switch(severity) @@ -93,11 +100,12 @@ footstep_type = /singleton/footsteps/water var/reagent_type = /datum/reagent/water -/turf/simulated/floor/exoplanet/water/shallow/attackby(obj/item/O, mob/living/user) +/turf/simulated/floor/exoplanet/water/shallow/use_tool(obj/item/O, mob/living/user, list/click_params) var/obj/item/reagent_containers/RG = O if (reagent_type && istype(RG) && RG.is_open_container() && RG.reagents) RG.reagents.add_reagent(reagent_type, min(RG.volume - RG.reagents.total_volume, RG.amount_per_transfer_from_this)) user.visible_message(SPAN_NOTICE("[user] fills \the [RG] from \the [src]."),SPAN_NOTICE("You fill \the [RG] from \the [src].")) + return TRUE else return ..() diff --git a/test/check-paths.sh b/test/check-paths.sh index 675da9575af68..1f17ac986142d 100755 --- a/test/check-paths.sh +++ b/test/check-paths.sh @@ -57,7 +57,7 @@ exactly 0 "simulated = 0/1" 'simulated\s*=\s*\d' -P exactly 2 "var/ in proc arguments" '(^/[^/].+/.+?\(.*?)var/' -P exactly 0 "tmp/ vars" 'var.*/tmp/' -P exactly 7 "uses of .len" '\.len\b' -P -exactly 207 "attackby() override" '\/attackby\((.*)\)' -P +exactly 193 "attackby() override" '\/attackby\((.*)\)' -P exactly 15 "uses of examine()" '[.|\s]examine\(' -P # If this fails it's likely because you used '/atom/proc/examine(mob)' instead of '/proc/examinate(mob, atom)' - Exception: An examine()-proc may call other examine()-procs exactly 7 "direct modifications of overlays list" '\boverlays((\s*[|^=+&-])|(\.(Cut)|(Add)|(Copy)|(Remove)|(Remove)))' -P exactly 0 "new/list list instantiations" 'new\s*/list' -P