diff --git a/baystation12.dme b/baystation12.dme index df69b65a3ce..b192c4fd087 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1239,6 +1239,7 @@ #include "code\game\objects\items\tools\crowbar.dm" #include "code\game\objects\items\tools\screwdriver.dm" #include "code\game\objects\items\tools\surgery.dm" +#include "code\game\objects\items\tools\tools.dm" #include "code\game\objects\items\tools\welding.dm" #include "code\game\objects\items\tools\wirecutters.dm" #include "code\game\objects\items\tools\wrench.dm" diff --git a/code/__defines/sound.dm b/code/__defines/sound.dm index 54e64287ff3..01a1392377c 100644 --- a/code/__defines/sound.dm +++ b/code/__defines/sound.dm @@ -322,6 +322,9 @@ #define SFX_GEIGER_MODERATE "geiger_moderate" #define SFX_GEIGER_HIGH "geiger_high" #define SFX_GEIGER_VERY_HIGH "geiger_very_high" +#define SFX_WELDING "welding_sound" +#define SFX_WELDER_ACTIVATE "welder_activate" +#define SFX_WELDER_DEACTIVATE "welder_deactivate" // MISC #define SFX_VENT "vent" diff --git a/code/__defines/tools.dm b/code/__defines/tools.dm index 30770381497..a108290abda 100644 --- a/code/__defines/tools.dm +++ b/code/__defines/tools.dm @@ -7,3 +7,7 @@ #define TOOL_SCREWDRIVER "screwdriver" #define TOOL_MULTITOOL "multitool" #define TOOL_CROWBAR "crowbar" + +/// Minimal duration of tool's use_tool(). If less than MIN_TOOL_SOUND_DELAY, then +/// tool_sound is played only when use_tool() is started. If more, then it is played twice. +#define MIN_TOOL_SOUND_DELAY 2 SECONDS diff --git a/code/_global_vars/sfx.dm b/code/_global_vars/sfx.dm index 02ed503e433..47c4dac88cf 100644 --- a/code/_global_vars/sfx.dm +++ b/code/_global_vars/sfx.dm @@ -1655,6 +1655,16 @@ GLOBAL_LIST_INIT(sfx_list, list( 'sound/effects/geiger/geiger_very_high_1.ogg', 'sound/effects/geiger/geiger_very_high_2.ogg' ), + SFX_WELDING = list( + 'sound/items/Welder.ogg', + 'sound/items/Welder2.ogg' + ), + SFX_WELDER_ACTIVATE = list( + 'sound/effects/welderactivate.ogg' + ), + SFX_WELDER_DEACTIVATE = list( + 'sound/effects/welderdeactivate.ogg' + ), // FOOTSTEPS SFX_DISTANT_MOVEMENT = list( 'sound/effects/footstep/distant/distant1.ogg', diff --git a/code/_helpers/mobs.dm b/code/_helpers/mobs.dm index 3a741d4b949..298c16abd91 100644 --- a/code/_helpers/mobs.dm +++ b/code/_helpers/mobs.dm @@ -128,7 +128,7 @@ /proc/get_exposed_defense_zone(atom/movable/target) return pick(BP_HEAD, BP_L_HAND, BP_R_HAND, BP_L_FOOT, BP_R_FOOT, BP_L_ARM, BP_R_ARM, BP_L_LEG, BP_R_LEG, BP_CHEST, BP_GROIN) -/proc/do_mob(atom/movable/affecter, mob/target, time = 30, target_zone = 0, uninterruptible = 0, progress = 1, incapacitation_flags = INCAPACITATION_DEFAULT, can_multitask = FALSE) +/proc/do_mob(atom/movable/affecter, mob/target, time = 30, target_zone = 0, uninterruptible = 0, progress = 1, incapacitation_flags = INCAPACITATION_DEFAULT, can_multitask = FALSE, datum/callback/extra_checks) if(!affecter || !target) return FALSE @@ -189,13 +189,17 @@ . = 0 break + if(extra_checks && !extra_checks.Invoke(user, target)) + . = FALSE + break + if(progbar) qdel(progbar) if(!can_multitask) LAZYREMOVE(GLOB.domobs, uniqueid) -/proc/do_after(mob/user, delay, atom/target = null, needhand = TRUE, progress = TRUE, incapacitation_flags = INCAPACITATION_DEFAULT, same_direction = FALSE, can_move = FALSE) +/proc/do_after(mob/user, delay, atom/target = null, needhand = TRUE, progress = TRUE, incapacitation_flags = INCAPACITATION_DEFAULT, same_direction = FALSE, can_move = FALSE, datum/callback/extra_checks) if(!user) return FALSE @@ -248,6 +252,10 @@ . = 0 break + if(extra_checks && !extra_checks.Invoke(user, target)) + . = FALSE + break + if(progbar) qdel(progbar) diff --git a/code/datums/surgery/steps/misc.dm b/code/datums/surgery/steps/misc.dm index 7307a286e47..4e8ebbe78f8 100644 --- a/code/datums/surgery/steps/misc.dm +++ b/code/datums/surgery/steps/misc.dm @@ -32,8 +32,8 @@ return FALSE if(isWelder(tool)) - var/obj/item/weldingtool/W = tool - if(!W.isOn() || !W.remove_fuel(1, user)) + var/obj/item/weldingtool/WT = tool + if(!WT.use_tool(target, user, amount = 1)) return FALSE return !(target.back.canremove) diff --git a/code/datums/surgery/steps/robotic.dm b/code/datums/surgery/steps/robotic.dm index 66eee76f5e0..df434e443b9 100644 --- a/code/datums/surgery/steps/robotic.dm +++ b/code/datums/surgery/steps/robotic.dm @@ -172,8 +172,8 @@ return if(isWelder(tool)) - var/obj/item/weldingtool/W = tool - if(!W.isOn() || !W.remove_fuel(1, user)) + var/obj/item/weldingtool/WT = tool + if(!WT.use_tool(target, user, amount = 1)) return FALSE if(parent_organ.hatch_state != HATCH_OPENED) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 1c1f275a790..713d90ac778 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -401,24 +401,11 @@ return null /obj/machinery/camera/proc/weld(obj/item/weldingtool/WT, mob/user) - - if(busy) - return 0 - if(!WT.isOn()) - return 0 - - // Do after stuff here to_chat(user, "You start to weld the [src]..") - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) - WT.eyecheck(user) - busy = 1 - if(do_after(user, 100, src)) - busy = 0 - if(!WT.isOn()) - return 0 - return 1 - busy = 0 - return 0 + if(WT.use_tool(src, user, delay = 10 SECONDS, amount = 5)) + return FALSE + + return TRUE /obj/machinery/camera/interact(mob/living/user as mob) if(!panel_open || istype(user, /mob/living/silicon/ai)) diff --git a/code/game/machinery/camera/camera_assembly.dm b/code/game/machinery/camera/camera_assembly.dm index c9404587d6e..cc6219ef90a 100644 --- a/code/game/machinery/camera/camera_assembly.dm +++ b/code/game/machinery/camera/camera_assembly.dm @@ -152,20 +152,12 @@ ..() /obj/item/camera_assembly/proc/weld(obj/item/weldingtool/WT, mob/user) + to_chat(user, SPAN_NOTICE("You start to weld \the [src].")) - if(busy) - return 0 - if(!WT.isOn()) - return 0 - - to_chat(user, "You start to weld \the [src]..") - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) - WT.eyecheck(user) - busy = 1 - if(do_after(user, 20, src)) - busy = 0 - if(!WT.isOn()) - return 0 - return 1 - busy = 0 - return 0 + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) + return FALSE + + if(QDELETED(src) || !user) + return FALSE + + return TRUE diff --git a/code/game/machinery/computer/ai_core.dm b/code/game/machinery/computer/ai_core.dm index 22470c862ac..6145813cd41 100644 --- a/code/game/machinery/computer/ai_core.dm +++ b/code/game/machinery/computer/ai_core.dm @@ -39,16 +39,16 @@ state = AI_STAGE_CIRCUIT if(isWelder(P)) var/obj/item/weldingtool/WT = P - if(!WT.isOn()) - to_chat(user, "The welder must be on for this task.") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) return - playsound(loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 20, src)) - if(!src || !WT.remove_fuel(0, user)) return - to_chat(user, SPAN("notice", "You deconstruct the frame.")) - new /obj/item/stack/material/plasteel(loc, 4) - qdel(src) + + if(QDELETED(src) || !user) return + + to_chat(user, SPAN("notice", "You deconstruct the frame.")) + new /obj/item/stack/material/plasteel(loc, 4) + qdel(src) + return if(AI_STAGE_CIRCUIT) if(isWrench(P)) playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) diff --git a/code/game/machinery/computer/buildandrepair.dm b/code/game/machinery/computer/buildandrepair.dm index 8f3081438e4..b165e9e06e9 100644 --- a/code/game/machinery/computer/buildandrepair.dm +++ b/code/game/machinery/computer/buildandrepair.dm @@ -24,15 +24,15 @@ src.state = 1 if(isWelder(P)) var/obj/item/weldingtool/WT = P - if(!WT.remove_fuel(0, user)) - to_chat(user, "The welding tool must be on to complete this task.") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) return - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 20, src)) - if(!src || !WT.isOn()) return - to_chat(user, "You deconstruct the frame.") - new /obj/item/stack/material/steel( src.loc, 5 ) - qdel(src) + + if(QDELETED(src) || !user) + return + + to_chat(user, SPAN_NOTICE("You deconstruct the frame.")) + new /obj/item/stack/material/steel( src.loc, 5 ) + qdel_self() if(1) if(isWrench(P)) playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index 3bf82f70084..82f84cf0e02 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -16,16 +16,15 @@ var/state = STAGE_CABLE /obj/machinery/constructable_frame/proc/deconstruct_frame(obj/item/weldingtool/WT, mob/user, amount=1) - if(!WT.remove_fuel(0, user)) - to_chat(user, "\The [WT] must be on to complete this task.") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 5)) return - playsound(loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 20, src)) - if(!src || !WT.isOn()) - return - to_chat(user, SPAN("notice", "You deconstruct \the [src]")) - new /obj/item/stack/material/steel(loc, amount) - qdel(src) + + if(QDELETED(src) || !user) + return + + to_chat(user, SPAN("notice", "You deconstruct \the [src]")) + new /obj/item/stack/material/steel(loc, amount) + qdel(src) /obj/machinery/constructable_frame/proc/wrench_frame(mob/user) playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index 67db995e973..1fc1b76cb67 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -524,11 +524,9 @@ About the new airlock wires panel: if(isWelder(item)) var/obj/item/weldingtool/WT = item - if(!WT.isOn()) - return 0 - if(!WT.remove_fuel(0,user)) - to_chat(user, "You need more welding fuel to complete this task.") - return 0 + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 5)) + return + cut_verb = "cutting" cut_sound = 'sound/items/Welder.ogg' @@ -635,16 +633,14 @@ About the new airlock wires panel: if(!repairing && isWelder(C) && !(operating > 0) && density) var/obj/item/weldingtool/W = C - if(W.remove_fuel(0, user)) - if(!welded) - welded = TRUE - else - src.welded = null - playsound(src, 'sound/items/Welder.ogg', 100, 1) - update_icon() + if(!W.use_tool(src, user, amount = 1)) return + + if(!welded) + welded = TRUE else - return + welded = null + update_icon() else if(isScrewdriver(C)) if(p_open) diff --git a/code/game/machinery/doors/braces.dm b/code/game/machinery/doors/braces.dm index bd7a7f42103..a1c6e6e406b 100644 --- a/code/game/machinery/doors/braces.dm +++ b/code/game/machinery/doors/braces.dm @@ -88,17 +88,20 @@ return if(isWelder(W)) - var/obj/item/weldingtool/C = W if(cur_health == max_health) to_chat(user, "\The [src] does not require repairs.") return - if(C.remove_fuel(0,user)) - playsound(src, 'sound/items/Welder.ogg', 100, 1) - cur_health = min(cur_health + rand(80,120), max_health) - if(cur_health == max_health) - to_chat(user, "You repair some dents on \the [src]. It is in perfect condition now.") - else - to_chat(user, "You repair some dents on \the [src].") + + var/obj/item/weldingtool/WT = W + + if(!WT.use_tool(src, user, amount = 1)) + return FALSE + + cur_health = min(cur_health + rand(80,120), max_health) + if(cur_health == max_health) + to_chat(user, "You repair some dents on \the [src]. It is in perfect condition now.") + else + to_chat(user, "You repair some dents on \the [src].") /obj/item/airlock_brace/proc/take_damage(amount) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 7e517c6f46d..28eafc65a6d 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -244,16 +244,20 @@ to_chat(user, "\The [src] must be closed before you can repair it.") return - var/obj/item/weldingtool/welder = I - if(welder.remove_fuel(0,user)) - to_chat(user, "You start to fix dents and weld \the [repairing] into place.") - playsound(src, 'sound/items/Welder.ogg', 100, 1) - if(do_after(user, 5 * repairing.amount, src) && welder && welder.isOn()) - to_chat(user, "You finish repairing the damage to \the [src].") - health = between(health, health + repairing.amount*DOOR_REPAIR_AMOUNT, maxhealth) - update_icon() - qdel(repairing) - repairing = null + var/obj/item/weldingtool/WT = I + + to_chat(user, SPAN_NOTICE("You start to fix dents and weld \the [repairing] into place.")) + if(!WT.use_tool(src, user, delay = 5 * repairing.amount, amount = 5)) + return + + if(QDELETED(src) || !user) + return + + to_chat(user, SPAN_NOTICE("You finish repairing the damage to \the [src].")) + health = between(health, health + repairing.amount*DOOR_REPAIR_AMOUNT, maxhealth) + update_icon() + qdel(repairing) + repairing = null return if(repairing && isCrowbar(I)) diff --git a/code/game/machinery/doors/firedoor.dm b/code/game/machinery/doors/firedoor.dm index fe01746f6b1..1d9b1dee88c 100644 --- a/code/game/machinery/doors/firedoor.dm +++ b/code/game/machinery/doors/firedoor.dm @@ -202,15 +202,16 @@ if(operating) return//Already doing something. if(isWelder(C) && !repairing) - var/obj/item/weldingtool/W = C - if(W.remove_fuel(0, user)) - blocked = !blocked - user.visible_message("\The [user] [blocked ? "welds" : "unwelds"] \the [src] with \a [W].",\ - "You [blocked ? "weld" : "unweld"] \the [src] with \the [W].",\ - "You hear something being welded.") - playsound(src, 'sound/items/Welder.ogg', 100, 1) - update_icon() - return + var/obj/item/weldingtool/WT = C + if(!WT.use_tool(src, user, amount = 1)) + return FALSE + + blocked = !blocked + user.visible_message(SPAN_DANGER("\The [user] [blocked ? "welds" : "unwelds"] \the [src] with \a [WT]."),\ + "You [blocked ? "weld" : "unweld"] \the [src] with \the [WT].",\ + "You hear something being welded.") + update_icon() + return if(density && isScrewdriver(C)) hatch_open = !hatch_open diff --git a/code/game/machinery/doors/firedoor_assembly.dm b/code/game/machinery/doors/firedoor_assembly.dm index edf36cf9e83..7407d8725a9 100644 --- a/code/game/machinery/doors/firedoor_assembly.dm +++ b/code/game/machinery/doors/firedoor_assembly.dm @@ -54,17 +54,18 @@ update_icon() else if(!anchored && isWelder(C)) var/obj/item/weldingtool/WT = C - if(WT.remove_fuel(0, user)) - user.visible_message("[user] dissassembles \the [src].", + user.visible_message("[user] dissassembles \the [src].", "You start to dissassemble \the [src].") - if(do_after(user, 40, src)) - if(!src || !WT.isOn()) return - user.visible_message("[user] has dissassembled \the [src].", - "You have dissassembled \the [src].") - new /obj/item/stack/material/steel(src.loc, 2) - qdel(src) - else - to_chat(user, "You need more welding fuel.") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 1)) + return + + if(QDELETED(src) || !user) + return + + user.visible_message("[user] has dissassembled \the [src].", + "You have dissassembled \the [src].") + new /obj/item/stack/material/steel(src.loc, 2) + qdel(src) else ..(C, user) diff --git a/code/game/machinery/floor_light.dm b/code/game/machinery/floor_light.dm index d7a6f0fd1df..5c687612566 100644 --- a/code/game/machinery/floor_light.dm +++ b/code/game/machinery/floor_light.dm @@ -86,24 +86,17 @@ /obj/machinery/floor_light/proc/_repair_damage(mob/user, obj/item/weldingtool/WT) - if(istype(WT)) + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 5)) return - if(!WT.remove_fuel(0, user)) - to_chat(user, "\The [WT] must be on to complete this task.") + if(QDELETED(src) || !user) return - playsound(loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 20, src)) - if(!WT.isOn()) - return - - visible_message(SPAN("notice", "\The [user] has repaired \the [src]")) - set_broken(FALSE) - damagekey = 0 - damage = 0 - update_icon() - + visible_message(SPAN("notice", "\The [user] has repaired \the [src]")) + set_broken(FALSE) + damagekey = 0 + damage = 0 + update_icon() /obj/machinery/floor_light/proc/_open_settings(mob/user) if(!length(settings)) diff --git a/code/game/machinery/nuclear_bomb.dm b/code/game/machinery/nuclear_bomb.dm index 94b238f26cd..eb02328140c 100644 --- a/code/game/machinery/nuclear_bomb.dm +++ b/code/game/machinery/nuclear_bomb.dm @@ -87,17 +87,15 @@ var/bomb_set if(0) if(isWelder(O)) var/obj/item/weldingtool/WT = O - if(!WT.isOn()) return - if(WT.get_fuel() < 5) // uses up 5 fuel. - to_chat(user, "You need more fuel to complete this task.") - return - user.visible_message("[user] starts cutting loose the anchoring bolt covers on [src].", "You start cutting loose the anchoring bolt covers with [O]...") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) + return FALSE + + if(QDELETED(src) || !user ) + return FALSE - if(do_after(user,40, src)) - if(!src || !user || !WT.remove_fuel(5, user)) return - user.visible_message("\The [user] cuts through the bolt covers on \the [src].", "You cut through the bolt cover.") - removal_stage = 1 + user.visible_message("\The [user] cuts through the bolt covers on \the [src].", "You cut through the bolt cover.") + removal_stage = 1 return if(1) @@ -113,17 +111,15 @@ var/bomb_set if(2) if(isWelder(O)) var/obj/item/weldingtool/WT = O - if(!WT.isOn()) return - if (WT.get_fuel() < 5) // uses up 5 fuel. - to_chat(user, "You need more fuel to complete this task.") - return - user.visible_message("[user] starts cutting apart the anchoring system sealant on [src].", "You start cutting apart the anchoring system's sealant with [O]...") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) + return FALSE + + if(QDELETED(src) || !user) + return FALSE - if(do_after(user, 40, src)) - if(!src || !user || !WT.remove_fuel(5, user)) return - user.visible_message("\The [user] cuts apart the anchoring system sealant on \the [src].", "You cut apart the anchoring system's sealant.") - removal_stage = 3 + user.visible_message("\The [user] cuts apart the anchoring system sealant on \the [src].", "You cut apart the anchoring system's sealant.") + removal_stage = 3 return if(3) diff --git a/code/game/machinery/turret/_turret_control.dm b/code/game/machinery/turret/_turret_control.dm index 1d58ffc06c8..9e004726920 100644 --- a/code/game/machinery/turret/_turret_control.dm +++ b/code/game/machinery/turret/_turret_control.dm @@ -105,16 +105,8 @@ if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - return - - if(WT.get_fuel() < 5) - show_splash_text(user, "Not enough fuel!") - - playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) - if(do_after(user, 30 SECONDS, src)) - if(QDELETED(src) || !WT.remove_fuel(5, user)) - return + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) + return FALSE show_splash_text(user, "External armor removed!") diff --git a/code/game/machinery/turret/_turret_control_frame.dm b/code/game/machinery/turret/_turret_control_frame.dm index 0e2deca3cf1..c79f32d8900 100644 --- a/code/game/machinery/turret/_turret_control_frame.dm +++ b/code/game/machinery/turret/_turret_control_frame.dm @@ -81,24 +81,20 @@ if(BUILDSTAGE_ARMOR_WELD) if(isWelder(I)) var/obj/item/weldingtool/WT = I - if(!WT.isOn()) - return - if(WT.get_fuel() < 5) - show_splash_text(user, "Not enough fuel!") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) + return FALSE - playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) - if(do_after(user, 30, src)) - if(QDELETED(src) || !WT.remove_fuel(5, user)) - return + if(QDELETED(src) || !user) + return - show_splash_text(user, "External armor welded") + show_splash_text(user, "External armor welded") - //The final step: create a full turret control panel - var/obj/machinery/turret_control_panel/tcp = new target_type(get_turf(src), signaler) - tcp.enabled = FALSE + //The final step: create a full turret control panel + var/obj/machinery/turret_control_panel/tcp = new target_type(get_turf(src), signaler) + tcp.enabled = FALSE - qdel_self() + qdel_self() else if(isCrowbar(I)) playsound(loc, 'sound/items/Crowbar.ogg', 75, 1) diff --git a/code/game/machinery/turret/_turret_frame.dm b/code/game/machinery/turret/_turret_frame.dm index dda7afdf06a..c8ed048ed44 100644 --- a/code/game/machinery/turret/_turret_frame.dm +++ b/code/game/machinery/turret/_turret_frame.dm @@ -71,22 +71,17 @@ else if(isWelder(I)) var/obj/item/weldingtool/WT = I - if(!WT.isOn()) + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) return - if(WT.get_fuel() < 5) - show_splash_text(user, "Not enough fuel!") - return - - playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) - if(do_after(user, 20, src)) - if(QDELETED(src) || !WT.remove_fuel(5, user)) - return - buildstage = BUILDSTAGE_IARMOR_ATTACH - show_splash_text(user, "Internal armor removed!") - new /obj/item/stack/material/steel(get_turf(src), 2) + if(QDELETED(src) || !user) return + buildstage = BUILDSTAGE_IARMOR_ATTACH + show_splash_text(user, "Internal armor removed!") + new /obj/item/stack/material/steel(get_turf(src), 2) + return + if(BUILDSTAGE_PROX) if(isprox(I)) if(!user.drop(I, src)) @@ -133,24 +128,19 @@ if(BUILDSTAGE_EARMOR_WELD) if(isWelder(I)) var/obj/item/weldingtool/WT = I - if(!WT.isOn()) - return - - if(WT.get_fuel() < 5) - show_splash_text(user, "Not enough fuel!") + if(!WT.use_tool(src, user, delay = 3 SECONDS, amount = 5)) + return FALSE - playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) - if(do_after(user, 30, src)) - if(QDELETED(src) || !WT.remove_fuel(5, user)) - return + if(QDELETED(src) || !user) + return - show_splash_text(user, "External armor welded") + show_splash_text(user, "External armor welded") - //The final step: create a full turret - var/obj/machinery/turret/T = new target_type(get_turf(src), signaler) - T.enabled = FALSE + //The final step: create a full turret + var/obj/machinery/turret/T = new target_type(get_turf(src), signaler) + T.enabled = FALSE - qdel_self() + qdel_self() else if(isCrowbar(I)) playsound(loc, 'sound/items/Crowbar.ogg', 75, 1) diff --git a/code/game/machinery/turret/_turrets.dm b/code/game/machinery/turret/_turrets.dm index df466054901..cb94d46c99e 100644 --- a/code/game/machinery/turret/_turrets.dm +++ b/code/game/machinery/turret/_turrets.dm @@ -232,16 +232,11 @@ GLOBAL_LIST_EMPTY(all_turrets) if(isWelder(I)) var/obj/item/weldingtool/WT = I - if(!WT.isOn()) + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) return - if(WT.get_fuel() < 5) - show_splash_text(user, "Not enough fuel!") - - playsound(loc, pick('sound/items/Welder.ogg', 'sound/items/Welder2.ogg'), 50, 1) - if(do_after(user, 30 SECONDS, src)) - if(QDELETED(src) || !WT.remove_fuel(5, user)) - return + if(QDELETED(src) || !user) + return show_splash_text(user, "External armor removed!") diff --git a/code/game/machinery/vending/_vending.dm b/code/game/machinery/vending/_vending.dm index b97c23accc6..d522abf395f 100644 --- a/code/game/machinery/vending/_vending.dm +++ b/code/game/machinery/vending/_vending.dm @@ -263,21 +263,24 @@ qdel(src) return FALSE -/obj/machinery/vending/proc/attempt_to_repair(mob/user, obj/item/weldingtool/W) - if(!istype(W) || !W.isOn()) +/obj/machinery/vending/proc/attempt_to_repair(mob/user, obj/item/weldingtool/WT) + if(!istype(WT)) return FALSE + if(health == max_health) to_chat(user, SPAN("notice", "\The [src] is undamaged.")) return FALSE - if(!W.remove_fuel(0, user)) - to_chat(user, SPAN("notice", "You need more welding fuel to complete this task.")) - return FALSE - playsound(src, 'sound/items/Welder.ogg', 100, 1) + user.visible_message(SPAN("notice", "[user] is repairing \the [src]..."), SPAN("notice", "You start repairing the damage to [src]...")) - if(do_after(user, 30, src) && W.isOn()) - health = max_health - user.visible_message(SPAN("notice", "[user] repairs \the [src]."), SPAN("notice", "You repair \the [src].")) - set_broken(0) + if(!WT.use_tool(src, user, delay = 3 SECONDS, amount = 5)) + return + + if(QDELETED(src) || !user) + return + + health = max_health + user.visible_message(SPAN("notice", "[user] repairs \the [src]."), SPAN("notice", "You repair \the [src].")) + set_broken(0) return TRUE /obj/machinery/vending/MouseDrop_T(obj/item/I, mob/user) diff --git a/code/game/machinery/vending_frame.dm b/code/game/machinery/vending_frame.dm index 8afefa1ea19..2ee36d7dfc9 100644 --- a/code/game/machinery/vending_frame.dm +++ b/code/game/machinery/vending_frame.dm @@ -66,15 +66,15 @@ create_vendomat() /obj/machinery/vending_frame/proc/deconstruct_frame(obj/item/weldingtool/WT, mob/user) - if(!WT.remove_fuel(0, user)) - to_chat(user, "The welding tool must be on to complete this task.") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 5)) return - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 20, src)) - if(!src || !WT.isOn()) return - to_chat(user, "You deconstruct the frame.") - new /obj/item/stack/material/steel(src.loc, 5) - qdel(src) + + if(QDELETED(src) || !user) + return + + to_chat(user, SPAN_NOTICE("You deconstruct the frame.")) + new /obj/item/stack/material/steel(src.loc, 5) + qdel(src) /obj/machinery/vending_frame/proc/wrench_frame(mob/user) playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 6533fcf24fe..5fc51b882a7 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -861,19 +861,23 @@ else if(isWelder(W) && user.a_intent != I_HURT) var/obj/item/weldingtool/WT = W - if (WT.remove_fuel(0,user)) - if (hasInternalDamage(MECHA_INT_TANK_BREACH)) - clearInternalDamage(MECHA_INT_TANK_BREACH) - to_chat(user, "You repair the damaged gas tank.") - user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) - else + + if(!WT.use_tool(src, user, amount = 1)) + return + + if(!hasInternalDamage(MECHA_INT_TANK_BREACH)) return - if(src.healthYou repair some damage to [src.name].") + + clearInternalDamage(MECHA_INT_TANK_BREACH) + to_chat(user, SPAN_NOTICE("You repair the damaged gas tank.")) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) + + if(health < initial(health)) + to_chat(user, SPAN_NOTICE("You repair some damage to [src.name].")) user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) - src.health += min(10, initial(src.health)-src.health) + src.health += min(10, initial(health) - health) else - to_chat(user, "The [src.name] is at full integrity") + to_chat(user, "\The [name] is at full integrity") return else if(istype(W, /obj/item/mecha_parts/mecha_tracking)) diff --git a/code/game/mecha/mecha_construction_paths.dm b/code/game/mecha/mecha_construction_paths.dm index 33026bd683c..93d802df6ed 100644 --- a/code/game/mecha/mecha_construction_paths.dm +++ b/code/game/mecha/mecha_construction_paths.dm @@ -7,11 +7,10 @@ if(!istype(I)) return 0 if(isWelder(I)) - var/obj/item/weldingtool/W = I - if (W.remove_fuel(0, user)) - playsound(holder, 'sound/items/Welder2.ogg', 50, 1) - else - return 0 + var/obj/item/weldingtool/WT = I + WT.use_tool(src, user, amount = 1) + return + else if(isWrench(I)) playsound(holder, 'sound/items/Ratchet.ogg', 50, 1) @@ -40,13 +39,13 @@ /datum/construction/reversible/mecha/custom_action(index, diff, atom/used_atom, mob/user) var/obj/item/I = used_atom if(!istype(I)) - return 0 + return FALSE + if(isWelder(I)) var/obj/item/weldingtool/W = I - if (W.remove_fuel(0, user)) - playsound(holder, 'sound/items/Welder2.ogg', 50, 1) - else - return 0 + W.use_tool(src, user, amount = 1) + return + else if(isWrench(I)) playsound(holder, 'sound/items/Ratchet.ogg', 50, 1) diff --git a/code/game/mecha/mecha_wreckage.dm b/code/game/mecha/mecha_wreckage.dm index 71376284c5c..de950672e4b 100644 --- a/code/game/mecha/mecha_wreckage.dm +++ b/code/game/mecha/mecha_wreckage.dm @@ -34,19 +34,21 @@ if(salvage_num <= 0) to_chat(user, "You don't see anything that can be cut with [W].") return - if (!isemptylist(welder_salvage) && WT.remove_fuel(0,user)) - var/type = prob(70)?pick(welder_salvage):null - if(type) - var/N = new type(get_turf(user)) - user.visible_message("[user] cuts [N] from [src]", "You cut [N] from [src]", "You hear a sound of welder nearby") - if(istype(N, /obj/item/mecha_parts/part)) - welder_salvage -= type - salvage_num-- - else - to_chat(user, "You failed to salvage anything valuable from [src].") - else - to_chat(user, "You need more welding fuel to complete this task.") + + if(!WT.use_tool(src, user, amount = 1) ) return + + if(isemptylist(welder_salvage)) + to_chat(user, "You failed to salvage anything valuable from [src].") + + var/type = prob(70) ? pick(welder_salvage) : null + if(type) + var/N = new type(get_turf(user)) + user.visible_message("[user] cuts [N] from [src]", "You cut [N] from [src]", "You hear a sound of welder nearby") + if(istype(N, /obj/item/mecha_parts/part)) + welder_salvage -= type + salvage_num-- + if(isWirecutter(W)) if(salvage_num <= 0) to_chat(user, "You don't see anything that can be cut with [W].") diff --git a/code/game/objects/effects/aliens.dm b/code/game/objects/effects/aliens.dm index 175f6366f4a..523775c5b84 100644 --- a/code/game/objects/effects/aliens.dm +++ b/code/game/objects/effects/aliens.dm @@ -253,9 +253,11 @@ if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) - qdel(src) - playsound(loc, 'sound/items/Welder.ogg', 100, 1) + + if(!WT.use_tool(src, user, amount = 1)) + return + + qdel_self() else if(prob(50)) diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index 2b5b2507957..94f91c007c9 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -113,9 +113,9 @@ steam.start() -- spawns the effect anchored = 1.0 mouse_opacity = 0 -/obj/effect/sparks/Initialize() +/obj/effect/sparks/Initialize(mapload, volume) . = ..() - playsound(src.loc, SFX_SPARK, 100, 1) + playsound(src.loc, SFX_SPARK, volume, 1) var/turf/T = loc if(istype(T, /turf)) T.hotspot_expose(1000, 100) @@ -134,6 +134,13 @@ steam.start() -- spawns the effect T.hotspot_expose(1000, 100) /datum/effect/effect/system/spark_spread + var/sparks_volume = 100 + +/datum/effect/effect/system/spark_spread/New(volume = null) + if(!isnull(volume)) + sparks_volume = volume + + return ..() /datum/effect/effect/system/spark_spread/set_up(n = 3, c = 0, loca) if(n > 10) @@ -153,7 +160,7 @@ steam.start() -- spawns the effect set waitfor = 0 if(holder) src.location = get_turf(holder) - var/obj/effect/sparks/sparks = new /obj/effect/sparks(location) + var/obj/effect/sparks/sparks = new /obj/effect/sparks(location, sparks_volume) var/direction if(src.cardinals) direction = pick(GLOB.cardinal) diff --git a/code/game/objects/effects/spiders.dm b/code/game/objects/effects/spiders.dm index 7fcdc24fcbe..17b6e1c313e 100644 --- a/code/game/objects/effects/spiders.dm +++ b/code/game/objects/effects/spiders.dm @@ -33,9 +33,8 @@ if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) + if(WT.use_tool(src, user, amount = 1)) damage = 15 - playsound(loc, 'sound/items/Welder.ogg', 100, 1) health -= damage healthcheck() diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 6c586e27b71..720323dcb35 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -100,6 +100,12 @@ var/tool_behaviour = 0 + /// Multipler of this tool's speed + var/toolspeed = 1 + + /// Sound played when this tool is used. Can be a list too. + var/tool_sound + /obj/item/New() ..() if(randpixel && (!pixel_x && !pixel_y) && isturf(loc)) //hopefully this will prevent us from messing with mapper-set pixel_x/y diff --git a/code/game/objects/items/devices/radio/intercom_frame.dm b/code/game/objects/items/devices/radio/intercom_frame.dm index f43ade2662b..d964f863e6a 100644 --- a/code/game/objects/items/devices/radio/intercom_frame.dm +++ b/code/game/objects/items/devices/radio/intercom_frame.dm @@ -111,19 +111,15 @@ update_icon() /obj/item/intercom_assembly/proc/deconstruct_frame(obj/item/weldingtool/WT, mob/user) - if(WT.remove_fuel(0, user)) - playsound(loc, 'sound/items/Welder2.ogg', 50, 1) - show_splash_text(user, "dissasembling...") - if(do_after(user, 40, src)) - if(!WT.isOn()) - return + show_splash_text(user, "dissasembling...") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) + return - new /obj/item/stack/material/steel(loc, 3) - qdel(src) - else - show_splash_text(user, "turn \the [WT] on first!") + if(QDELETED(src) || !user) return + new /obj/item/stack/material/steel(loc, 3) + qdel(src) /obj/item/intercom_assembly/proc/add_radio(obj/item/device/radio/R, mob/user) playsound(loc, 'sound/items/Screwdriver.ogg', 100, 1) diff --git a/code/game/objects/items/material/_material_weapons.dm b/code/game/objects/items/material/_material_weapons.dm index 85ad11faac9..31f69743715 100644 --- a/code/game/objects/items/material/_material_weapons.dm +++ b/code/game/objects/items/material/_material_weapons.dm @@ -106,30 +106,3 @@ if(!consumed && drops_debris) material.place_shard(T) qdel(src) -/* -Commenting this out pending rebalancing of radiation based on small objects. -/obj/item/material/process() - if(!material.radioactivity) - return - for(var/mob/living/L in range(1,src)) - L.apply_effect(round(material.radioactivity/30),IRRADIATE, blocked = L.get_flat_armor(null, "rad")) -*/ - -/* -// Commenting this out while fires are so spectacularly lethal, as I can't seem to get this balanced appropriately. -/obj/item/material/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume) - TemperatureAct(exposed_temperature) - -// This might need adjustment. Will work that out later. -/obj/item/material/proc/TemperatureAct(temperature) - health -= material.combustion_effect(get_turf(src), temperature, 0.1) - check_health(1) - -/obj/item/material/attackby(obj/item/W as obj, mob/user as mob) - if(isWelder(W)) - var/obj/item/weldingtool/WT = W - if(material.ignition_point && WT.remove_fuel(0, user)) - TemperatureAct(150) - else - return ..() -*/ diff --git a/code/game/objects/items/material/shards.dm b/code/game/objects/items/material/shards.dm index 0c9313bf223..af7f32f262b 100644 --- a/code/game/objects/items/material/shards.dm +++ b/code/game/objects/items/material/shards.dm @@ -68,10 +68,13 @@ /obj/item/material/shard/attackby(obj/item/W, mob/user) if(isWelder(W) && material.shard_can_repair) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) - material.place_sheet(loc) - qdel(src) + if(!WT.use_tool(src, user, amount = 1)) return + + material.place_sheet(loc) + qdel_self() + return + return ..() /obj/item/material/shard/Crossed(mob/M) diff --git a/code/game/objects/items/shooting_range.dm b/code/game/objects/items/shooting_range.dm index 43961738690..ef50a2dafc8 100644 --- a/code/game/objects/items/shooting_range.dm +++ b/code/game/objects/items/shooting_range.dm @@ -35,11 +35,13 @@ attackby(obj/item/W as obj, mob/user as mob) if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) - ClearOverlays() - to_chat(usr, "You slice off [src]'s uneven chunks of aluminum and scorch marks.") + if(!WT.use_tool(src, user, amount = 1)) return + ClearOverlays() + to_chat(usr, "You slice off [src]'s uneven chunks of aluminum and scorch marks.") + return + attack_hand(mob/user as mob) // taking pinned targets off! diff --git a/code/game/objects/items/stacks/assemblies.dm b/code/game/objects/items/stacks/assemblies.dm index ffbebc5e433..9d4bef72b22 100644 --- a/code/game/objects/items/stacks/assemblies.dm +++ b/code/game/objects/items/stacks/assemblies.dm @@ -27,23 +27,25 @@ if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0,user)) - var/obj/item/stack/material/steel/new_item - if(istype(src.loc,/turf)) - new_item = new(src.loc) - else - new_item = new(usr.loc) - new_item.add_fingerprint(user) - new_item.add_to_stacks(usr) - for (var/mob/M in viewers(src)) - M.show_message(SPAN_NOTICE("[src] is shaped into metal by [user.name] with the weldingtool."), 3, SPAN_NOTICE("You hear welding."), 2) - var/obj/item/stack/gassembly/R = src - src = null - var/replace = (user.get_inactive_hand()==R) - R.use(1) - if (!R && replace) - user.pick_or_drop(new_item) - return + if(!WT.use_tool(src, user, amount = 1)) + return + + var/obj/item/stack/material/steel/new_item + if(istype(src.loc,/turf)) + new_item = new(src.loc) + else + new_item = new(usr.loc) + new_item.add_fingerprint(user) + new_item.add_to_stacks(usr) + for (var/mob/M in viewers(src)) + M.show_message(SPAN_NOTICE("[src] is shaped into metal by [user.name] with the weldingtool."), 3, SPAN_NOTICE("You hear welding."), 2) + var/obj/item/stack/gassembly/R = src + src = null + var/replace = (user.get_inactive_hand()==R) + R.use(1) + if (!R && replace) + user.pick_or_drop(new_item) + if(isWrench(W) && !in_use) diff --git a/code/game/objects/items/stacks/rods.dm b/code/game/objects/items/stacks/rods.dm index fcc5eca2f1a..6cf622a091e 100644 --- a/code/game/objects/items/stacks/rods.dm +++ b/code/game/objects/items/stacks/rods.dm @@ -44,20 +44,24 @@ var/obj/item/weldingtool/WT = W if(get_amount() < 2) - to_chat(user, "You need at least two rods to do this.") + to_chat(user, SPAN_NOTICE("You need at least two rods to do this.")) return - if(WT.remove_fuel(0,user)) - var/obj/item/stack/material/steel/new_item = new(usr.loc) - new_item.add_to_stacks(usr) - for (var/mob/M in viewers(src)) - M.show_message("[src] is shaped into metal by [user.name] with the weldingtool.", 3, "You hear welding.", 2) - var/obj/item/stack/rods/R = src - src = null - var/replace = (user.get_inactive_hand()==R) - R.use(2) - if (!R && replace) - user.pick_or_drop(new_item) + + if(!WT.use_tool(src, user, amount = 1)) + return + + var/obj/item/stack/material/steel/new_item = new(usr.loc) + new_item.add_to_stacks(usr) + for(var/mob/M in viewers(src)) + M.show_message(SPAN_NOTICE("[src] is shaped into metal by [user.name] with the weldingtool."), 3, SPAN_NOTICE("You hear welding."), 2) + + var/obj/item/stack/rods/R = src + src = null + var/replace = (user.get_inactive_hand() == R) + R.use(2) + if(!R && replace) + user.pick_or_drop(new_item) return if (istype(W, /obj/item/tape_roll)) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index c1e9f35a14d..7759a1203a9 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -163,35 +163,32 @@ to_chat(user, "\The [recipe.title] must be constructed on the floor!") return - if((WT && WT.remove_fuel(0, user)) || uses_charge || craft_tool == 1) - - if (recipe.time) - to_chat(user, "Building [recipe.title] ...") - if (!do_after(user, recipe.time)) - return - - if (use(required)) - var/atom/O - if(recipe.use_material) - if(istype(src.loc,/turf)) - O = new recipe.result_type(src.loc, recipe.use_material) - else - O = new recipe.result_type(user.loc, recipe.use_material) + to_chat(user, "Building [recipe.title] ...") + if(!WT?.use_tool(src, user, delay = recipe.time, amount = 5) || uses_charge || craft_tool == 1) + return + + if(use(required)) + var/atom/O + if(recipe.use_material) + if(istype(src.loc,/turf)) + O = new recipe.result_type(src.loc, recipe.use_material) + else + O = new recipe.result_type(user.loc, recipe.use_material) + else + if(istype(src.loc,/turf)) + O = new recipe.result_type(src.loc) else - if(istype(src.loc,/turf)) - O = new recipe.result_type(src.loc) - else - O = new recipe.result_type(user.loc) - O.set_dir(user.dir) - O.add_fingerprint(user) - - if (recipe.goes_in_hands && !recipe.on_floor) - user.pick_or_drop(O) - - if (istype(O, /obj/item/stack)) - var/obj/item/stack/S = O - S.amount = produced - S.add_to_stacks(user, recipe.goes_in_hands) + O = new recipe.result_type(user.loc) + O.set_dir(user.dir) + O.add_fingerprint(user) + + if (recipe.goes_in_hands && !recipe.on_floor) + user.pick_or_drop(O) + + if (istype(O, /obj/item/stack)) + var/obj/item/stack/S = O + S.amount = produced + S.add_to_stacks(user, recipe.goes_in_hands) /obj/item/stack/Topic(href, href_list) ..() diff --git a/code/game/objects/items/tanks/tanks.dm b/code/game/objects/items/tanks/tanks.dm index 62099541bef..b7131c36982 100644 --- a/code/game/objects/items/tanks/tanks.dm +++ b/code/game/objects/items/tanks/tanks.dm @@ -185,37 +185,41 @@ var/list/global/tank_gauge_cache = list() if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(1,user)) - if(!valve_welded) - to_chat(user, "You begin welding the \the [src] emergency pressure relief valve.") - if(do_after(user, 40,src)) - to_chat(user, "You carefully weld \the [src] emergency pressure relief valve shut. \The [src] may now rupture under pressure!") - valve_welded = 1 - leaking = 0 - else - GLOB.bombers += "[key_name(user)] attempted to weld a [src]. [CONV_KELVIN_CELSIUS(air_contents.temperature)]" - message_admins("[key_name_admin(user)] attempted to weld a [src]. [CONV_KELVIN_CELSIUS(air_contents.temperature)]") - if(WT.welding) - to_chat(user, "You accidentally rake \the [W] across \the [src]!") - maxintegrity -= rand(2,6) - integrity = min(integrity,maxintegrity) - WT.eyecheck(user) - else - to_chat(user, "The emergency pressure relief valve has already been welded.") - if (src.air_contents) - var/const/welder_temperature = 1893.15 - var/const/welder_mean_energy = 26000 - var/const/welder_heat_capacity = welder_mean_energy / welder_temperature + if(valve_welded) + to_chat(user, SPAN_NOTICE("The emergency pressure relief valve has already been welded.")) + + to_chat(user, SPAN_NOTICE("You begin welding the \the [src] emergency pressure relief valve.")) + + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) + GLOB.bombers += "[key_name(user)] attempted to weld a [src]. [CONV_KELVIN_CELSIUS(air_contents.temperature)]" + message_admins("[key_name_admin(user)] attempted to weld a [src]. [CONV_KELVIN_CELSIUS(air_contents.temperature)]") + if(WT.welding) + to_chat(user, SPAN_DANGER("You accidentally rake \the [W] across \the [src]!")) + maxintegrity -= rand(2,6) + integrity = min(integrity,maxintegrity) + + if(QDELETED(src) || !user) + return + + to_chat(user, SPAN_NOTICE("You carefully weld \the [src] emergency pressure relief valve shut.")) + to_chat(user, SPAN_WARNING("\The [src] may now rupture under pressure!")) + valve_welded = 1 + leaking = 0 + + if(air_contents) + var/const/welder_temperature = 1893.15 + var/const/welder_mean_energy = 26000 + var/const/welder_heat_capacity = welder_mean_energy / welder_temperature - var/current_energy = src.air_contents.heat_capacity() * src.air_contents.temperature - var/total_capacity = src.air_contents.heat_capacity() + welder_heat_capacity - var/total_energy = current_energy + welder_mean_energy + var/current_energy = src.air_contents.heat_capacity() * src.air_contents.temperature + var/total_capacity = src.air_contents.heat_capacity() + welder_heat_capacity + var/total_energy = current_energy + welder_mean_energy - var/new_temperature = total_energy / total_capacity + var/new_temperature = total_energy / total_capacity - src.air_contents.temperature = new_temperature - set_next_think(world.time) + src.air_contents.temperature = new_temperature + set_next_think(world.time) add_fingerprint(user) diff --git a/code/game/objects/items/tools/surgery.dm b/code/game/objects/items/tools/surgery.dm index 627c176a1d5..5dc8b6b5535 100644 --- a/code/game/objects/items/tools/surgery.dm +++ b/code/game/objects/items/tools/surgery.dm @@ -244,17 +244,18 @@ if(CHANISAW_WELDING_CASE) if(!isWelder(W)) return ..() - var/obj/item/weldingtool/weldtool = W - if(weldtool.remove_fuel(5, user)) - playsound(user, 'sound/effects/flare.ogg', 50, 5, 7) - visible_message(SPAN("notice", "[usr] welded a case of \the [src]!")) - var/inhandy = (loc == user) && ishuman(user) - var/obj/item/material/twohanded/chainsaw/C = new /obj/item/material/twohanded/chainsaw(user.loc) - if(inhandy) - user.drop(src) - user.put_in_hands(C) - C.add_fingerprint(user) - qdel(src) + var/obj/item/weldingtool/WT = W + if(!WT.use_tool(src, user, amount = 5)) + return + + visible_message(SPAN("notice", "[usr] welded a case of \the [src]!")) + var/inhandy = (loc == user) && ishuman(user) + var/obj/item/material/twohanded/chainsaw/C = new /obj/item/material/twohanded/chainsaw(user.loc) + if(inhandy) + user.drop(src) + user.put_in_hands(C) + C.add_fingerprint(user) + qdel(src) ..() diff --git a/code/game/objects/items/tools/tools.dm b/code/game/objects/items/tools/tools.dm new file mode 100644 index 00000000000..3e1cbdd7495 --- /dev/null +++ b/code/game/objects/items/tools/tools.dm @@ -0,0 +1,58 @@ +/obj/item/proc/use_tool(atom/target, mob/living/user, delay = 0, amount = 0, volume = 0, quality = null, can_move = FALSE, datum/callback/extra_checks) + // No delay means there is no start message, and no reason to call tool_start_check before use_tool. + // Run the start check here so we wouldn't have to call it manually. + if(!tool_use_check(amount)) + return + + delay *= toolspeed + + // Play tool sound at the beginning of tool usage. + play_tool_sound(target, volume) + + if(delay) + var/datum/callback/tool_check = CALLBACK(src, nameof(.proc/tool_check_callback), user, amount, extra_checks, target) + if(ismob(target)) + if(!do_mob(user, target, delay, extra_checks = tool_check) || !is_tool_on()) + return + + else + if(!do_after(user, delay, target=target, can_move = can_move, extra_checks = tool_check) || !is_tool_on()) + return + + // Use tool's fuel, stack sheets or charges if amount is set. + if(amount && !use_tool_resources(amount, user)) + return + + // Play tool sound at the end of tool usage, + // but only if the delay between the beginning and the end is not too small + if(delay >= MIN_TOOL_SOUND_DELAY) + play_tool_sound(target, volume) + + return TRUE + +/// Plays tools's usesound. +/obj/item/proc/play_tool_sound(atom/target, volume = null) + if(target && tool_sound && volume) + var/played_sound = tool_sound + + if(islist(tool_sound)) + played_sound = pick(tool_sound) + + playsound(target, played_sound, 100, volume) + +/// Depending on the item checks whether it has enough resources (e.g. fuel) +/obj/item/proc/tool_use_check(used, mob/M = null) + return TRUE + +/// Depending on the item, it uses up fuel, charges, sheets, etc. +/obj/item/proc/use_tool_resources(used, mob/M = null) + return !used + +/// Returns whether or not the tool is currently on. +/obj/item/proc/is_tool_on() + return + +/// Callback to check during doafter. Do not override. Do not call it. +/obj/item/proc/tool_check_callback(mob/living/user, amount, datum/callback/extra_checks, target) + SHOULD_NOT_OVERRIDE(TRUE) + return tool_use_check(user, amount, target) && (!extra_checks || extra_checks.Invoke()) diff --git a/code/game/objects/items/tools/welding.dm b/code/game/objects/items/tools/welding.dm index 21115e6c71b..e678641ccf5 100644 --- a/code/game/objects/items/tools/welding.dm +++ b/code/game/objects/items/tools/welding.dm @@ -32,7 +32,10 @@ origin_tech = list(TECH_ENGINEERING = 1) //Welding tool specific stuff - var/welding = 0 //Whether or not the welding tool is off(0), on(1) or currently welding(2) + /// Whether or not the welding tool is off(FALSE) or on (TRUE) + var/welding = FALSE + /// Whether or not the welding tool is currently welding + VAR_PRIVATE/currently_welding = FALSE var/status = 1 //Whether the welder is secured or unsecured (able to attach rods to it to make a flamethrower) var/obj/item/welder_tank/tank = /obj/item/welder_tank // where the fuel is stored @@ -40,6 +43,10 @@ drop_sound = SFX_DROP_WELDINGTOOL pickup_sound = SFX_PICKUP_WELDINGTOOL + tool_sound = SFX_WELDING + var/toggle_on_sound = SFX_WELDER_ACTIVATE + var/toggle_off_sound = SFX_WELDER_DEACTIVATE + /obj/item/weldingtool/Initialize() if(ispath(tank)) tank = new tank @@ -189,7 +196,6 @@ /obj/item/weldingtool/proc/get_fuel() return tank ? tank.reagents.get_reagent_amount(/datum/reagent/fuel) : 0 - //Removes fuel from the welding tool. If a mob is passed, it will perform an eyecheck on the mob. This should probably be renamed to use() /obj/item/weldingtool/proc/remove_fuel(amount = 1, mob/M = null) if(!welding) @@ -229,11 +235,11 @@ location.hotspot_expose(700, 5) //Returns whether or not the welding tool is currently on. -/obj/item/weldingtool/proc/isOn() - return src.welding +/obj/item/weldingtool/is_tool_on() + return welding /obj/item/weldingtool/get_storage_cost() - if(isOn()) + if(is_tool_on()) return ITEM_SIZE_NO_CONTAINER return ..() @@ -270,6 +276,8 @@ to_chat(M, "You switch the [src] on.") else if(T) T.visible_message("\The [src] turns on.") + + playsound(get_turf(src), GET_SFX(toggle_on_sound), 100, TRUE) force = 15 damtype = "fire" hitsound = 'sound/effects/flare.ogg' // Surprisingly it sounds just perfect @@ -288,6 +296,7 @@ to_chat(M, "You switch \the [src] off.") else if(T) T.visible_message("\The [src] turns off.") + playsound(get_turf(src), GET_SFX(toggle_off_sound), 100, TRUE) force = 3 damtype = "brute" hitsound = initial(hitsound) @@ -336,8 +345,68 @@ spawn(100) H.disabilities &= ~NEARSIGHTED +/obj/item/weldingtool/use_tool(atom/target, mob/living/user, delay = 0, amount = 0, volume = 0, can_move = FALSE, datum/callback/extra_checks) + if(!is_tool_on()) + show_splash_text(user, "Welder must be turned on!") + return + + if(amount > get_fuel()) + show_splash_text(user, "Not enough fuel!") + return + + playsound(loc, 'sound/items/Welder.ogg', 100, 1) + var/atom/movable/fake_overlay/welding_overlay/effect = new(get_turf(target)) + var/datum/callback/checks = CALLBACK(src, nameof(.proc/check_active_and_extra), extra_checks) + INVOKE_ASYNC(src, nameof(.proc/start_welding), target) + . = ..(target, user, delay, amount, volume, extra_checks = checks) + stop_welding() + qdel(effect) + +/obj/item/weldingtool/use_tool_resources(amount, mob) + . = remove_fuel(amount, mob) + if(!.) + show_splash_text(mob, "Not enough fuel!") + +/obj/item/weldingtool/proc/start_welding(atom/target) // Process of welding something + var/datum/effect/effect/system/spark_spread/spark = new /datum/effect/effect/system/spark_spread(volume = 10) + spark.set_up(1, 1, target) + currently_welding = TRUE + while(currently_welding) + sleep(10) + spark.start() + +/obj/item/weldingtool/proc/check_active_and_extra(datum/callback/extra_checks) + if(!is_tool_on() || !get_fuel()) + return FALSE + + if(!extra_checks) + return TRUE + + return extra_checks.Invoke() + +/obj/item/weldingtool/proc/stop_welding() + currently_welding = FALSE + +/atom/movable/fake_overlay/welding_overlay + density = FALSE + anchored = TRUE + layer = ABOVE_PROJECTILE_LAYER + plane = DEFAULT_PLANE + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + + icon = 'icons/effects/effects.dmi' + icon_state = "welding_sparks" + +/atom/movable/fake_overlay/welding_overlay/Initialize(mapload) + . = ..() + set_light(0.6, 0.5, 1.5, 2, "#e38f46") + AddOverlays(emissive_appearance(icon, "[icon_state]-ea")) + +/obj/item/weldingtool/tool_use_check(mob/living/user, amount) + return get_fuel() >= amount + /obj/item/weldingtool/get_temperature_as_from_ignitor() - if(isOn()) + if(is_tool_on()) return 3800 return 0 diff --git a/code/game/objects/structures/barricade/security.dm b/code/game/objects/structures/barricade/security.dm index c7755ea3601..740f670e364 100644 --- a/code/game/objects/structures/barricade/security.dm +++ b/code/game/objects/structures/barricade/security.dm @@ -78,19 +78,13 @@ if(istype(WT)) return - if(!WT.remove_fuel(0, user)) - to_chat(user, "\The [WT] must be on to complete this task.") - return - - playsound(loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 20, src)) - if(!WT.isOn()) - return - visible_message(SPAN("notice", "\The [user] has repaired \the [src]")) - damage = 0 - update_icon() + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 3)) + return + visible_message(SPAN("notice", "\The [user] has repaired \the [src]")) + damage = 0 + update_icon() /obj/structure/barricade/security/wrench_floor_bolts(mob/user, delay) if(locked) diff --git a/code/game/objects/structures/catwalk.dm b/code/game/objects/structures/catwalk.dm index 0d62ffe3c20..1030b90c01a 100644 --- a/code/game/objects/structures/catwalk.dm +++ b/code/game/objects/structures/catwalk.dm @@ -59,15 +59,16 @@ /obj/structure/catwalk/attackby(obj/item/C, mob/user) if(isWelder(C)) var/obj/item/weldingtool/WT = C - if(WT.remove_fuel(0, user)) - playsound(src, 'sound/items/Welder.ogg', 100, 1) - to_chat(user, SPAN("notice", "Slicing catwalk joints ...")) - new /obj/item/stack/rods(loc) - new /obj/item/stack/rods(loc) - //Lattice would delete itself, but let's save ourselves a new obj - if((istype(loc, /turf/space) || istype(loc, /turf/simulated/open)) && !(locate(/obj/structure/lattice) in loc)) - new /obj/structure/lattice(loc) - qdel(src) + if(!WT.use_tool(src, user, amount = 1)) + return + + to_chat(user, SPAN("notice", "Slicing catwalk joints ...")) + new /obj/item/stack/rods(loc) + new /obj/item/stack/rods(loc) + //Lattice would delete itself, but let's save ourselves a new obj + if((istype(loc, /turf/space) || istype(loc, /turf/simulated/open)) && !(locate(/obj/structure/lattice) in loc)) + new /obj/structure/lattice(loc) + qdel_self() /obj/structure/catwalk/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd) if(the_rcd.mode == RCD_DECONSTRUCT) diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index 2a48ed120bf..7ad69caa5b3 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -431,11 +431,13 @@ return FALSE if(istype(W,/obj/item/tk_grab)) return FALSE + if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.isOn()) + if(WT.use_tool(src, user)) slice_into_parts(WT, user) return + if(istype(W, /obj/item/storage/laundry_basket) && W.contents.len) var/obj/item/storage/laundry_basket/LB = W var/turf/T = get_turf(src) @@ -508,12 +510,9 @@ return else if(isWelder(W) && (setup & CLOSET_CAN_BE_WELDED)) var/obj/item/weldingtool/WT = W - if(!WT.remove_fuel(0,user)) - if(!WT.isOn()) - return - else - to_chat(user, SPAN_NOTICE("You need more welding fuel to complete this task.")) - return + if(!WT.use_tool(src, user)) + return + src.welded = !src.welded src.update_icon() user.visible_message(SPAN_WARNING("\The [src] has been [welded?"welded shut":"unwelded"] by \the [user]."), blind_message = "You hear welding.", range = 3) @@ -542,9 +541,9 @@ src.attack_hand(user) /obj/structure/closet/proc/slice_into_parts(obj/item/weldingtool/WT, mob/user) - if(!WT.remove_fuel(0,user)) - to_chat(user, SPAN_NOTICE("You need more welding fuel to complete this task.")) + if(!WT.use_tool(src, user, amount = 1)) return + if(material != null) new material(loc) else diff --git a/code/game/objects/structures/door_assembly.dm b/code/game/objects/structures/door_assembly.dm index d7d599c6c93..fd422189ce7 100644 --- a/code/game/objects/structures/door_assembly.dm +++ b/code/game/objects/structures/door_assembly.dm @@ -154,34 +154,36 @@ if(isWelder(W) && ( (istext(glass)) || (glass == 1) || (!anchored) )) var/obj/item/weldingtool/WT = W - if (WT.remove_fuel(0, user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) - if(istext(glass)) - user.visible_message("[user] welds the [glass] plating off the airlock assembly.", "You start to weld the [glass] plating off the airlock assembly.") - if(do_after(user, 40,src)) - if(!src || !WT.isOn()) return - to_chat(user, "You welded the [glass] plating off!") - var/M = text2path("/obj/item/stack/material/[glass]") - new M(src.loc, 2) - glass = 0 - else if(glass == 1) - user.visible_message("[user] welds the glass panel out of the airlock assembly.", "You start to weld the glass panel out of the airlock assembly.") - if(do_after(user, 40,src)) - if(!src || !WT.isOn()) return - to_chat(user, "You welded the glass panel out!") - new /obj/item/stack/material/glass/reinforced(src.loc) - glass = 0 - else if(!anchored) - user.visible_message("[user] dissassembles the airlock assembly.", "You start to dissassemble the airlock assembly.") - if(do_after(user, 40,src)) - if(!src || !WT.isOn()) return - to_chat(user, "You dissasembled the airlock assembly!") - new /obj/item/stack/material/steel(src.loc, 4) - qdel (src) - else - to_chat(user, "You need more welding fuel.") + + if(istext(glass)) + user.visible_message("[user] welds the [glass] plating off the airlock assembly.", "You start to weld the [glass] plating off the airlock assembly.") + else if(glass == 1) + user.visible_message("[user] welds the glass panel out of the airlock assembly.", "You start to weld the glass panel out of the airlock assembly.") + else if(!anchored) + user.visible_message("[user] dissassembles the airlock assembly.", "You start to dissassemble the airlock assembly.") + + + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) return + if(QDELETED(src) || !user) + return + + if(istext(glass)) + to_chat(user, SPAN_NOTICE("You welded the [glass] plating off!")) + var/M = text2path("/obj/item/stack/material/[glass]") + new M(src.loc, 2) + glass = 0 + else if(glass == 1) + to_chat(user, SPAN_NOTICE("You welded the glass panel out!")) + new /obj/item/stack/material/glass/reinforced(src.loc) + glass = 0 + else if(!anchored) + to_chat(user, SPAN_NOTICE("You dissasembled the airlock assembly!")) + new /obj/item/stack/material/steel(src.loc, 4) + qdel_self() + + else if(isWrench(W) && state == 0) playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1) if(anchored) diff --git a/code/game/objects/structures/girders.dm b/code/game/objects/structures/girders.dm index 80b796b16d3..27ef5100395 100644 --- a/code/game/objects/structures/girders.dm +++ b/code/game/objects/structures/girders.dm @@ -135,19 +135,19 @@ else if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - return if(health == max_health) to_chat(user, SPAN("notice", "\The [src] is undamaged.")) return - if(!WT.remove_fuel(0,user)) - to_chat(user, SPAN("notice", "You need more welding fuel to complete this task.")) - return + user.visible_message(SPAN("notice", "[user] is repairing the damage to \the [src]..."), \ SPAN("notice", "You start repairing the damage to \the [src]...")) - playsound(src, 'sound/items/Welder.ogg', 100, 1) - if(!do_after(user, max(5, health / 3), src) && WT && WT.isOn()) + + if(!WT.use_tool(src, user, delay = max(5, health /3), amount = 5)) return + + if(QDELETED(src) || !user) + return + health = max_health user.visible_message(SPAN("notice", "[user] repairs \the [src]."), \ SPAN("notice", "You repair \the [src].")) diff --git a/code/game/objects/structures/lattice.dm b/code/game/objects/structures/lattice.dm index 713731d15b6..bb1b566d7be 100644 --- a/code/game/objects/structures/lattice.dm +++ b/code/game/objects/structures/lattice.dm @@ -56,11 +56,13 @@ return if(isWelder(C)) var/obj/item/weldingtool/WT = C - if(!WT.remove_fuel(0, user)) + if(!WT.use_tool(src, user, amount = 1)) return - to_chat(user, "Slicing lattice joints ...") + + to_chat(user, SPAN_NOTICE("Slicing lattice joints.")) new /obj/item/stack/rods(loc) qdel(src) + if (istype(C, /obj/item/stack/rods)) var/obj/item/stack/rods/R = C if(R.use(2)) diff --git a/code/game/objects/structures/pew.dm b/code/game/objects/structures/pew.dm index 928c90382aa..22b73f5edb1 100644 --- a/code/game/objects/structures/pew.dm +++ b/code/game/objects/structures/pew.dm @@ -22,19 +22,19 @@ to_chat(user, SPAN("notice", "\The [src] doesn't look like it can be disassembled. Breaking it up is the only way to get rid of it.")) else if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - return if(health == max_health) to_chat(user, SPAN("notice", "\The [src] is undamaged.")) return - if(!WT.remove_fuel(0,user)) - to_chat(user, SPAN("notice", "You need more welding fuel to complete this task.")) - return + user.visible_message(SPAN("notice", "[user] is repairing the damage to \the [src]..."), \ SPAN("notice", "You start repairing the damage to \the [src]...")) - playsound(src, 'sound/items/Welder.ogg', 100, 1) - if(!do_after(user, max(5, health / 3), src) && WT && WT.isOn()) + + if(!WT.use_tool(src, user, delay = max(5, health / 3), amount = 5)) return + + if(QDELETED(src) || !user) + return + health = max_health user.visible_message(SPAN("notice", "[user] repairs \the [src]."), \ SPAN("notice", "You repair \the [src].")) diff --git a/code/game/objects/structures/railing.dm b/code/game/objects/structures/railing.dm index 1fb7de71bd6..61f3b856302 100644 --- a/code/game/objects/structures/railing.dm +++ b/code/game/objects/structures/railing.dm @@ -212,12 +212,15 @@ // Repair if(health < maxhealth && isWelder(W)) var/obj/item/weldingtool/F = W - if(F.welding) - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 20, src)) - user.visible_message("\The [user] repairs some damage to \the [src].", "You repair some damage to \the [src].") - health = min(health+(maxhealth/4), maxhealth) // 25% repair per application - return + if(!F.use_tool(src, user, delay = 2 SECONDS, amount = 5)) + return + + if(QDELETED(src) || !user) + return + + user.visible_message(SPAN_NOTICE("\The [user] repairs some damage to \the [src]."), SPAN_NOTICE("You repair some damage to \the [src].")) + health = min(health + (maxhealth / 4), maxhealth) // 25% repair per application + return // (Un)Anchor if(isScrewdriver(W)) diff --git a/code/game/objects/structures/secure_door_assembly.dm b/code/game/objects/structures/secure_door_assembly.dm index b1b5f1ccde7..567cb86abae 100644 --- a/code/game/objects/structures/secure_door_assembly.dm +++ b/code/game/objects/structures/secure_door_assembly.dm @@ -66,20 +66,14 @@ return ..() /obj/structure/secure_door_assembly/proc/deconstruct_assembly(obj/item/weldingtool/WT, mob/user) - if (WT.remove_fuel(0, user)) - playsound(loc, 'sound/items/Welder2.ogg', 50, 1) - user.visible_message("[user] dissassembles \the [src] .", "You start to dissassemble \the [src] .") - if(do_after(user, 40, src)) - if(!WT.isOn()) - return - - to_chat(user, SPAN_NOTICE("You dissasembled \the [src] a!")) - new /obj/item/stack/material/steel(loc, 10) - qdel(src) - else - to_chat(user, SPAN_NOTICE("You need more welding fuel.")) + user.visible_message("[user] dissassembles \the [src] .", "You start to dissassemble \the [src] .") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) return + to_chat(user, SPAN_NOTICE("You dissasembled \the [src] a!")) + new /obj/item/stack/material/steel(loc, 10) + qdel(src) + /obj/structure/secure_door_assembly/wrench_floor_bolts(mob/user, delay = 40) . = ..() diff --git a/code/game/objects/structures/stool_bed_chair_nest/couches.dm b/code/game/objects/structures/stool_bed_chair_nest/couches.dm index 98fe070e404..8622f36b28b 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/couches.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/couches.dm @@ -20,23 +20,23 @@ to_chat(user, SPAN("notice", "\The [src] doesn't look like it can be disassembled. Breaking it up is the only way to get rid of it.")) else if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - return if(health == max_health) to_chat(user, SPAN("notice", "\The [src] is undamaged.")) return - if(!WT.remove_fuel(0,user)) - to_chat(user, SPAN("notice", "You need more welding fuel to complete this task.")) - return + user.visible_message(SPAN("notice", "[user] is repairing the damage to \the [src]..."), \ - SPAN("notice", "You start repairing the damage to \the [src]...")) - playsound(src, 'sound/items/Welder.ogg', 100, 1) - if(!do_after(user, max(5, health / 3), src) && WT && WT.isOn()) + SPAN("notice", "You start repairing the damage to \the [src]...")) + if(!WT.use_tool(src, user, delay = max(5, health / 3), amount = 5)) return + + if(QDELETED(src) || !user) + return + health = max_health user.visible_message(SPAN("notice", "[user] repairs \the [src]."), \ SPAN("notice", "You repair \the [src].")) update_icon() + else if(istype(W, /obj/item/grab)) var/obj/item/grab/G = W var/mob/living/affecting = G.affecting diff --git a/code/game/objects/structures/windoor_assembly.dm b/code/game/objects/structures/windoor_assembly.dm index a0d8fb0523a..63308efeef2 100644 --- a/code/game/objects/structures/windoor_assembly.dm +++ b/code/game/objects/structures/windoor_assembly.dm @@ -72,24 +72,22 @@ if("01") if(isWelder(W) && !anchored ) var/obj/item/weldingtool/WT = W - if (WT.remove_fuel(0,user)) - user.visible_message("[user] dissassembles the windoor assembly.", "You start to dissassemble the windoor assembly.") - playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) - - if(do_after(user, 40,src)) - if(!src || !WT.isOn()) return - to_chat(user, "You dissasembled the windoor assembly!") - if(material_used == MATERIAL_REINFORCED_PLASS) - new /obj/item/stack/material/glass/rplass(get_turf(src), 5) - else - new /obj/item/stack/material/glass/reinforced(get_turf(src), 5) - if(secure) - new /obj/item/stack/rods(get_turf(src), 4) - qdel(src) - else - to_chat(user, "You need more welding fuel to dissassemble the windoor assembly.") + user.visible_message("[user] dissassembles the windoor assembly.", "You start to dissassemble the windoor assembly.") + if(!WT.use_tool(src, user, delay = 4 SECONDS, amount = 5)) + return + + if(QDELETED(src)|| !user) return + to_chat(user, SPAN_NOTICE("You dissasembled the windoor assembly!")) + if(material_used == MATERIAL_REINFORCED_PLASS) + new /obj/item/stack/material/glass/rplass(get_turf(src), 5) + else + new /obj/item/stack/material/glass/reinforced(get_turf(src), 5) + if(secure) + new /obj/item/stack/rods(get_turf(src), 4) + qdel(src) + //Wrenching an unsecure assembly anchors it in place. Step 4 complete if(isWrench(W) && !anchored) playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1) diff --git a/code/game/turfs/simulated/floor_attackby.dm b/code/game/turfs/simulated/floor_attackby.dm index 8335cf32b3b..3c817beb0a5 100644 --- a/code/game/turfs/simulated/floor_attackby.dm +++ b/code/game/turfs/simulated/floor_attackby.dm @@ -130,30 +130,26 @@ else if(isWelder(C)) var/obj/item/weldingtool/welder = C - if(welder.isOn() && (is_plating())) + if((is_plating())) if(broken || burnt) - if(welder.isOn()) + if(welder.use_tool(src, user, amount = 1)) to_chat(user, "You fix some dents on the broken plating.") playsound(src, 'sound/items/Welder.ogg', 80, 1) icon_state = base_icon_state burnt = null broken = null - else - to_chat(user, "You need more welding fuel to complete this task.") - return else - if(welder.isOn()) - playsound(src, 'sound/items/Welder.ogg', 80, 1) - visible_message("[user] has started melting the plating's reinforcements!") - if(do_after(user, 5 SECONDS) && welder.isOn()) - visible_message("[user] has melted the plating's reinforcements! It should be possible to pry it off.") - playsound(src, 'sound/items/Welder.ogg', 80, 1) - burnt = 1 - remove_decals() - update_icon() - else - to_chat(user, "You need more welding fuel to complete this task.") - return + visible_message("[user] has started melting the plating's reinforcements!") + if(!welder.use_tool(src, user, delay = 5 SECONDS, amount = 5)) + return + + if(QDELETED(src) || !user) + return + + visible_message("[user] has melted the plating's reinforcements! It should be possible to pry it off.") + burnt = 1 + remove_decals() + update_icon() return ..() diff --git a/code/game/turfs/simulated/wall_attacks.dm b/code/game/turfs/simulated/wall_attacks.dm index 48b72b5134f..37166b1b748 100644 --- a/code/game/turfs/simulated/wall_attacks.dm +++ b/code/game/turfs/simulated/wall_attacks.dm @@ -139,12 +139,14 @@ if(locate(/obj/effect/overlay/wallrot) in src) if(isWelder(W)) var/obj/item/weldingtool/WT = W - if( WT.remove_fuel(0,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/effect/overlay/wallrot/WR in src) - qdel(WR) + if(!WT.use_tool(src, user, amount = 1)) return + + to_chat(user, SPAN("notice","You burn away the fungi with \the [WT].")) + playsound(src, 'sound/items/Welder.ogg', 10, 1) + for(var/obj/effect/overlay/wallrot/WR in src) + qdel(WR) + return 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].")) src.dismantle_wall(1) @@ -154,10 +156,12 @@ if(thermite) if(isWelder(W)) var/obj/item/weldingtool/WT = W - if( WT.remove_fuel(0,user) ) - thermitemelt(user) + if(!WT.use_tool(src, user, amount = 1)) return + thermitemelt(user) + return + else if(istype(W, /obj/item/gun/energy/plasmacutter)) thermitemelt(user) return @@ -179,18 +183,15 @@ var/obj/item/weldingtool/WT = W - if(!WT.isOn()) + to_chat(user, SPAN("notice","You start repairing the damage to [src].")) + if(!WT.use_tool(src, user, delay = max(5, damage / 5), amount = 5)) return - if(WT.remove_fuel(0,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) && WT && WT.isOn()) - to_chat(user, SPAN("notice","You finish repairing the damage to [src].")) - take_damage(-damage) - else - to_chat(user, SPAN("notice","You need more welding fuel to complete this task.")) + if(QDELETED(src) || !user) return + + to_chat(user, SPAN("notice","You finish repairing the damage to [src].")) + take_damage(-damage) return // Basic dismantling. @@ -202,14 +203,19 @@ if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) + to_chat(user, SPAN("notice", "You begin cutting through the outer plating.")) + + if(!WT.use_tool(src, user, cut_delay * 0.7, 5)) return - if(!WT.remove_fuel(0,user)) - to_chat(user, SPAN("notice","You need more welding fuel to complete this task.")) + + if(QDELETED(src) || !user) return - dismantle_verb = "cutting" - dismantle_sound = 'sound/items/Welder.ogg' - cut_delay *= 0.7 + + to_chat(user, SPAN("notice","You remove the outer plating.")) + dismantle_wall() + user.visible_message(SPAN("warning","\The [src] was torn open by [user]!")) + return + else if(istype(W,/obj/item/melee/energy/blade)) dismantle_sound = "spark" dismantle_verb = "slicing" @@ -229,7 +235,7 @@ if(cut_delay<0) cut_delay = 0 - if(!do_after(user,cut_delay,src)) + if(!do_after(user, cut_delay, src)) return to_chat(user, SPAN("notice","You remove the outer plating.")) @@ -270,13 +276,12 @@ var/cut_cover if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - return - if(WT.remove_fuel(0,user)) - cut_cover=1 - else - to_chat(user, SPAN("notice", "You need more welding fuel to complete this task.")) + if(!WT.use_tool(src, user, amount = 1)) return + + cut_cover = 1 + to_chat(user, SPAN("notice", "You need more welding fuel to complete this task.")) + return else if (istype(W, /obj/item/gun/energy/plasmacutter)) cut_cover = 1 if(cut_cover) @@ -312,11 +317,10 @@ var/cut_cover if(isWelder(W)) var/obj/item/weldingtool/WT = W - if( WT.remove_fuel(0,user) ) - cut_cover=1 - else - to_chat(user, SPAN("notice","You need more welding fuel to complete this task.")) + if(!WT.use_tool(src, user, amount = 1)) return + + cut_cover = 1 else if(istype(W, /obj/item/gun/energy/plasmacutter)) cut_cover = 1 if(cut_cover) diff --git a/code/modules/atmospherics/components/unary/vent_pump.dm b/code/modules/atmospherics/components/unary/vent_pump.dm index b589ec1e73d..9adbf415326 100644 --- a/code/modules/atmospherics/components/unary/vent_pump.dm +++ b/code/modules/atmospherics/components/unary/vent_pump.dm @@ -350,13 +350,11 @@ var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - to_chat(user, "The welding tool needs to be on to start this task.") - return 1 + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 5)) + return - if(!WT.remove_fuel(0,user)) - to_chat(user, "You need more welding fuel to complete this task.") - return 1 + if(QDELETED(src) || !user) + return if(broken) playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) @@ -364,13 +362,6 @@ SPAN_NOTICE("Now repairing \the [src]."), \ "You hear welding.") - if(!do_after(user, 10, src)) - to_chat(user, SPAN_NOTICE("You must remain still to finish this task!")) - return 1 - if(!WT.isOn()) - to_chat(user, SPAN_NOTICE("The welding tool needs to be on to finish this task.")) - return 1 - switch(broken) if(VENT_DAMAGED_STAGE_ONE) broken=VENT_UNDAMAGED @@ -386,18 +377,12 @@ return to_chat(user, "Now welding \the [src].") - playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) - if(!do_after(user, 20, src)) - to_chat(user, "You must remain close to finish this task.") - return 1 - - if(!src) - return 1 + if(!W.use_tool(src, user, delay = 2 SECONDS, amount = 5)) + return - if(!WT.isOn()) - to_chat(user, "The welding tool needs to be on to finish this task.") - return 1 + if(QDELETED(src) || !user) + return welded = !welded update_icon() diff --git a/code/modules/atmospherics/components/unary/vent_scrubber.dm b/code/modules/atmospherics/components/unary/vent_scrubber.dm index 8bd8972da3d..35ac1fbec7f 100644 --- a/code/modules/atmospherics/components/unary/vent_scrubber.dm +++ b/code/modules/atmospherics/components/unary/vent_scrubber.dm @@ -303,27 +303,17 @@ var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - to_chat(user, "The welding tool needs to be on to start this task.") - return 1 + if(broken) + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 5)) + return - if(!WT.remove_fuel(0,user)) - to_chat(user, "You need more welding fuel to complete this task.") - return 1 + if(QDELETED(src) || !user) + return - if(broken) - playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) user.visible_message(SPAN_NOTICE("\The [user] repairing \the [src]."), \ SPAN_NOTICE("Now repairing \the [src]."), \ "You hear welding.") - if(!do_after(user, 10, src)) - to_chat(user, SPAN_NOTICE("You must remain still to finish this task!")) - return 1 - if(!WT.isOn()) - to_chat(user, SPAN_NOTICE("The welding tool needs to be on to finish this task.")) - return 1 - switch(broken) if(VENT_DAMAGED_STAGE_ONE) broken=VENT_UNDAMAGED @@ -333,31 +323,24 @@ broken=VENT_DAMAGED_STAGE_TWO if(VENT_BROKEN) to_chat(user, SPAN_NOTICE("\The [src] is ruined! You can't repair it!")) - return 1 + return update_icon() return - to_chat(user, "Now welding \the [src].") - playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) - - if(!do_after(user, 20, src)) - to_chat(user, "You must remain close to finish this task.") - return 1 - - if(!src) - return 1 + else + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 5)) + return - if(!WT.isOn()) - to_chat(user, "The welding tool needs to be on to finish this task.") - return 1 + if(QDELETED(src) || !user) + return - welded = !welded - update_icon() - user.visible_message("\The [user] [welded ? "welds \the [src] shut" : "unwelds \the [src]"].", \ - "You [welded ? "weld \the [src] shut" : "unweld \the [src]"].", \ - "You hear welding.") - return 1 + welded = !welded + update_icon() + user.visible_message("\The [user] [welded ? "welds \the [src] shut" : "unwelds \the [src]"].", \ + "You [welded ? "weld \the [src] shut" : "unweld \the [src]"].", \ + "You hear welding.") + return return ..() diff --git a/code/modules/clothing/spacesuits/breaches.dm b/code/modules/clothing/spacesuits/breaches.dm index b5562c3f655..009eacaad72 100644 --- a/code/modules/clothing/spacesuits/breaches.dm +++ b/code/modules/clothing/spacesuits/breaches.dm @@ -203,18 +203,16 @@ return else if(isWelder(W)) - if(istype(src.loc,/mob/living)) to_chat(user, "How do you intend to patch a powersuit while someone is wearing it?") return - if (brute_damage <= 0) + if(brute_damage <= 0) to_chat(user, "There is no structural damage on \the [src] to repair.") return var/obj/item/weldingtool/WT = W - if(!WT.remove_fuel(5)) - to_chat(user, "You need more welding fuel to repair this suit.") + if(!WT.use_tool(src, user, amount = 5)) return repair_breaches(BRUTE, 3, user) diff --git a/code/modules/integrated_electronics/core/assemblies.dm b/code/modules/integrated_electronics/core/assemblies.dm index c3e425e1ce4..2fc01015f1c 100644 --- a/code/modules/integrated_electronics/core/assemblies.dm +++ b/code/modules/integrated_electronics/core/assemblies.dm @@ -650,9 +650,6 @@ /obj/item/device/electronic_assembly/proc/welder_act(mob/living/user, obj/item/weldingtool/I) var/type_to_use - if(!I.isOn()) - return - if(!sealed) type_to_use = input("What would you like to do?","[src] type setting") as null|anything in list("repair", "seal") else @@ -670,10 +667,12 @@ if("seal") if(!opened) - if(I.remove_fuel(3,user)) - sealed = TRUE - to_chat(user,SPAN_NOTICE("You seal the assembly, making it impossible to be opened.")) - return TRUE + if(!I.use_tool(src, user, amount = 3)) + return + + sealed = TRUE + to_chat(user,SPAN_NOTICE("You seal the assembly, making it impossible to be opened.")) + return TRUE else to_chat(user,SPAN_NOTICE("You need to close the assembly first before sealing it indefinitely!")) @@ -681,14 +680,16 @@ if("unseal") to_chat(user,SPAN_NOTICE("You start unsealing the assembly carefully...")) - if(I.remove_fuel(3,user)) - for(var/obj/item/integrated_circuit/IC in assembly_components) - if(prob(50)) - IC.disconnect_all() + if(!I.use_tool(src, user, amount = 3)) + return - to_chat(user,SPAN_NOTICE("You unsealed the assembly.")) - sealed = FALSE - return TRUE + for(var/obj/item/integrated_circuit/IC in assembly_components) + if(prob(50)) + IC.disconnect_all() + + to_chat(user,SPAN_NOTICE("You unsealed the assembly.")) + sealed = FALSE + return TRUE /obj/item/device/electronic_assembly/proc/default_unfasten_wrench(mob/user, obj/item/I, time = 20) if(isWrench(I) && istype(loc, /turf) && can_anchor) diff --git a/code/modules/mob/living/bot/ed209bot.dm b/code/modules/mob/living/bot/ed209bot.dm index aea1241c37a..86ad573cd81 100644 --- a/code/modules/mob/living/bot/ed209bot.dm +++ b/code/modules/mob/living/bot/ed209bot.dm @@ -121,10 +121,12 @@ if(3) if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) - build_step++ - SetName("shielded frame assembly") - to_chat(user, "You welded the vest to [src].") + if(!WT.use_tool(src, user, amount = 1)) + return + + build_step++ + SetName("shielded frame assembly") + to_chat(user, "You welded the vest to [src].") if(4) if(istype(W, /obj/item/clothing/head/helmet)) if(!user.drop(W)) diff --git a/code/modules/mob/living/bot/secbot.dm b/code/modules/mob/living/bot/secbot.dm index 49638c3bcc7..05c245d1541 100644 --- a/code/modules/mob/living/bot/secbot.dm +++ b/code/modules/mob/living/bot/secbot.dm @@ -372,10 +372,12 @@ ..() if(isWelder(O) && !build_step) var/obj/item/weldingtool/WT = O - if(WT.remove_fuel(0, user)) - build_step = 1 - AddOverlays(image('icons/obj/aibots.dmi', "hs_hole")) - to_chat(user, "You weld a hole in \the [src].") + if(!WT.use_tool(src, user, amount = 1)) + return + + build_step = 1 + AddOverlays(image('icons/obj/aibots.dmi', "hs_hole")) + to_chat(user, "You weld a hole in \the [src].") else if(isprox(O) && (build_step == 1)) if(!user.drop(O)) diff --git a/code/modules/mob/living/carbon/xenobiological/crossbreeding/_misc.dm b/code/modules/mob/living/carbon/xenobiological/crossbreeding/_misc.dm index ed0439ff9e9..57c6a4ab457 100644 --- a/code/modules/mob/living/carbon/xenobiological/crossbreeding/_misc.dm +++ b/code/modules/mob/living/carbon/xenobiological/crossbreeding/_misc.dm @@ -85,9 +85,8 @@ if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) + if(WT.use_tool(src, user, amount = 1)) damage = 15 - playsound(loc, 'sound/items/Welder.ogg', 100, 1) health -= damage if(health <= 0) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 06a315379b6..9d4b3f397f9 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -578,20 +578,19 @@ to_chat(user, "Nothing to fix here!") return var/obj/item/weldingtool/WT = W - if (src == user && !do_after(user, 30, src)) - to_chat(user, "You must stand still to repair yourself!") + if(!WT.use_tool(src, user, delay = 3 SECONDS, amount = 5)) return - if (WT.remove_fuel(0)) - user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) - adjustBruteLoss(-30) - updatehealth() - add_fingerprint(user) - for(var/mob/O in viewers(user, null)) - O.show_message(text("[user] has fixed some of the dents on [src]!"), 1) - else - to_chat(user, "Need more welding fuel!") + + if(QDELETED(src) || !user) return + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) + adjustBruteLoss(-30) + updatehealth() + add_fingerprint(user) + for(var/mob/O in viewers(user, null)) + O.show_message(text("[user] has fixed some of the dents on [src]!"), 1) + else if(isCoil(W) && (wiresexposed || istype(src,/mob/living/silicon/robot/drone))) if (!getFireLoss()) to_chat(user, "Nothing to fix here!") diff --git a/code/modules/mob/living/simple_animal/friendly/spiderbot.dm b/code/modules/mob/living/simple_animal/friendly/spiderbot.dm index 026d4a85e71..cd6b17a4c17 100644 --- a/code/modules/mob/living/simple_animal/friendly/spiderbot.dm +++ b/code/modules/mob/living/simple_animal/friendly/spiderbot.dm @@ -98,18 +98,17 @@ if(isWelder(O)) var/obj/item/weldingtool/WT = O - if (WT.remove_fuel(0)) - if(health < maxHealth) - health += pick(1,1,1,2,2,3) - if(health > maxHealth) - health = maxHealth - add_fingerprint(user) - src.visible_message("\The [user] has spot-welded some of the damage to \the [src]!") - else - to_chat(user, "\The [src] is undamaged!") - else - to_chat(user, "You need more welding fuel for this task!") + if(!WT.use_tool(src, user, amount = 1)) return + + if(health < maxHealth) + health += pick(1,1,1,2,2,3) + if(health > maxHealth) + health = maxHealth + add_fingerprint(user) + src.visible_message("\The [user] has spot-welded some of the damage to \the [src]!") + else + to_chat(user, "\The [src] is undamaged!") else if(istype(O, /obj/item/card/id)||istype(O, /obj/item/device/pda)) if (!mmi) to_chat(user, "There's no reason to swipe your ID - \the [src] has no brain to remove.") diff --git a/code/modules/modular_computers/computers/modular_computer/interaction.dm b/code/modules/modular_computers/computers/modular_computer/interaction.dm index 440cdcc9eab..7d972a023c9 100644 --- a/code/modules/modular_computers/computers/modular_computer/interaction.dm +++ b/code/modules/modular_computers/computers/modular_computer/interaction.dm @@ -196,18 +196,15 @@ return if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - to_chat(user, "\The [W] is off.") - return - if(!damage) to_chat(user, "\The [src] does not require repairs.") return - to_chat(user, "You begin repairing damage to \the [src]...") - if(WT.remove_fuel(round(damage/75)) && do_after(usr, damage/10)) - damage = 0 - to_chat(user, "You repair \the [src].") + if(!WT.use_tool(src, user, delay = round(damage /10), amount = round(damage/75))) + return + + damage = 0 + to_chat(user, "You repair \the [src].") return if(isScrewdriver(W)) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index f5a828be687..b334f67d98a 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -559,27 +559,27 @@ return else if(isWelder(W) && opened && has_electronics==0 && !terminal) var/obj/item/weldingtool/WT = W - if (WT.get_fuel() < 3) - to_chat(user, "You need more welding fuel to complete this task.") - return user.visible_message("[user.name] welds [src].", \ "You start welding the APC frame...", \ "You hear welding.") - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) - if(do_after(user, 50, src)) - if(!src || !WT.remove_fuel(3, user)) return - if (emagged || (stat & BROKEN) || opened==2) - new /obj/item/stack/material/steel(loc) - user.visible_message(\ - "[src] has been cut apart by [user.name] with the weldingtool.",\ - "You disassembled the broken APC frame.",\ - "You hear welding.") - else - new /obj/item/frame/apc(loc) - user.visible_message(\ - "[src] has been cut from the wall by [user.name] with the weldingtool.",\ - "You cut the APC frame from the wall.",\ - "You hear welding.") + if(!WT.use_tool(src, user, delay = 5 SECONDS, amount = 5)) + return + + if(QDELETED(src) || !user) + return + + if(emagged || (stat & BROKEN) || opened==2) + new /obj/item/stack/material/steel(loc) + user.visible_message(\ + "[src] has been cut apart by [user.name] with the weldingtool.",\ + "You disassembled the broken APC frame.",\ + "You hear welding.") + else + new /obj/item/frame/apc(loc) + user.visible_message(\ + "[src] has been cut from the wall by [user.name] with the weldingtool.",\ + "You cut the APC frame from the wall.",\ + "You hear welding.") qdel(src) return else if (istype(W, /obj/item/frame/apc) && opened && emagged) diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index bec13278ffb..5444d9fac63 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -249,8 +249,12 @@ GLOBAL_VAR(station_gravity_generator) playsound(loc, 'sound/items/Welder2.ogg', 50, 1) var/obj/item/weldingtool/WT = I - if(!do_after(user, 15 SECONDS, middle) || !WT.remove_fuel(1, user) || broken_state != GRAV_NEEDS_WELDING) + if(!WT.use_tool(src, user, delay = 15 SECONDS, amount = 5)) return + + if(QDELETED(src) || !user || broken_state != GRAV_NEEDS_WELDING) + return + health += 250 user.visible_message(SPAN_NOTICE("[user] fixed the damaged parts."), SPAN_NOTICE("You fixed the damaged parts.")) diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index e7a079ac48c..dab541e0eb5 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -193,31 +193,27 @@ if(0) to_chat(user, "\The [src] needs to be wrenched to the floor.") if(1) - if(WT.remove_fuel(0,user)) - playsound(loc, 'sound/items/Welder2.ogg', 50, 1) - user.visible_message("[user.name] starts to weld [src] to the floor.", \ + user.visible_message("[user.name] starts to weld [src] to the floor.", \ "You start to weld [src] to the floor.", \ "You hear welding") - if(do_after(user,20,src)) - if(!src || !WT.isOn()) return - state = 2 - to_chat(user, "You weld [src] to the floor.") - connect_to_network() - else - to_chat(user, "You need more welding fuel to complete this task.") + if(WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) + if(QDELETED(src) || !user) + return + + state = 2 + to_chat(user, "You weld [src] to the floor.") + connect_to_network() if(2) - if(WT.remove_fuel(0,user)) - playsound(loc, 'sound/items/Welder2.ogg', 50, 1) - user.visible_message("[user.name] starts to cut [src] free from the floor.", \ + user.visible_message("[user.name] starts to cut [src] free from the floor.", \ "You start to cut [src] free from the floor.", \ "You hear welding") - if(do_after(user,20,src)) - if(!src || !WT.isOn()) return - state = 1 - to_chat(user, "You cut [src] free from the floor.") - disconnect_from_network() - else - to_chat(user, "You need more welding fuel to complete this task.") + if(WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) + if(QDELETED(src) || !user) + return + + state = 1 + to_chat(user, "You cut [src] free from the floor.") + disconnect_from_network() return if(istype(W, /obj/item/card/id) || istype(W, /obj/item/device/pda)) diff --git a/code/modules/power/singularity/field_generator.dm b/code/modules/power/singularity/field_generator.dm index 468db24da4b..b10922eae47 100644 --- a/code/modules/power/singularity/field_generator.dm +++ b/code/modules/power/singularity/field_generator.dm @@ -126,29 +126,31 @@ field_generator power level display to_chat(user, "The [src.name] needs to be wrenched to the floor.") return if(1) - if (WT.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) - user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \ - "You start to weld the [src] to the floor.", \ - "You hear welding") - if (do_after(user,20,src)) - if(!src || !WT.isOn()) return - state = 2 - to_chat(user, "You weld the field generator to the floor.") - else + user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \ + "You start to weld the [src] to the floor.", \ + "You hear welding") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) return + + if(QDELETED(src) || !user) + return + + state = 2 + to_chat(user, "You weld the field generator to the floor.") + return if(2) - if (WT.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1) - user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \ - "You start to cut the [src] free from the floor.", \ - "You hear welding") - if (do_after(user,20,src)) - if(!src || !WT.isOn()) return - state = 1 - to_chat(user, "You cut the [src] free from the floor.") - else + user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \ + "You start to cut the [src] free from the floor.", \ + "You hear welding") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) return + + if(QDELETED(src) || !user) + return + + state = 1 + to_chat(user, "You cut the [src] free from the floor.") + return else ..() return diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index 11797bea5fc..fd2099ecc41 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -335,16 +335,20 @@ if(isWelder(W)) var/obj/item/weldingtool/WT = W - if(!WT.isOn()) - to_chat(user, "Turn on \the [WT] first!") - return 0 if(!damage) to_chat(user, "\The [src] is already fully repaired.") - return 0 - if(WT.remove_fuel(0,user) && do_after(user, damage, src)) - to_chat(user, "You repair all structural damage to \the [src]") - damage = 0 - return 0 + return + + if(!WT.use_tool(src, user, delay = damage, amount = 5)) + return + + if(QDELETED(src) || !user) + return + + to_chat(user, "You repair all structural damage to \the [src]") + damage = 0 + return + else if(isWirecutter(W) && !building_terminal) building_terminal = 1 var/obj/machinery/power/terminal/term diff --git a/code/modules/projectiles/guns/launcher/crossbow.dm b/code/modules/projectiles/guns/launcher/crossbow.dm index 44d2fba10d0..2a7f13b8934 100644 --- a/code/modules/projectiles/guns/launcher/crossbow.dm +++ b/code/modules/projectiles/guns/launcher/crossbow.dm @@ -269,11 +269,11 @@ return else if(isWelder(W)) if(buildstate == 1) - var/obj/item/weldingtool/T = W - if(T.remove_fuel(0,user)) - if(!src || !T.isOn()) return - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - to_chat(user, "You weld the rods into place.") + var/obj/item/weldingtool/WT = W + if(!WT.use_tool(src, user, amount = 1)) + return + + to_chat(user, "You weld the rods into place.") buildstate++ update_icon() return diff --git a/code/modules/projectiles/guns/launcher/pneumatic.dm b/code/modules/projectiles/guns/launcher/pneumatic.dm index 4f7316b67df..c1c7898d3e5 100644 --- a/code/modules/projectiles/guns/launcher/pneumatic.dm +++ b/code/modules/projectiles/guns/launcher/pneumatic.dm @@ -188,29 +188,29 @@ return else if(isWelder(W)) if(buildstate == 1) - var/obj/item/weldingtool/T = W - if(T.remove_fuel(0,user)) - if(!src || !T.isOn()) return - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - to_chat(user, "You weld the pipe into place.") - buildstate++ - update_icon() + var/obj/item/weldingtool/WT = W + if(!WT.use_tool(src, user, amount = 1)) + return + + to_chat(user, "You weld the pipe into place.") + buildstate++ + update_icon() if(buildstate == 3) - var/obj/item/weldingtool/T = W - if(T.remove_fuel(0,user)) - if(!src || !T.isOn()) return - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - to_chat(user, "You weld the metal chassis together.") - buildstate++ - update_icon() + var/obj/item/weldingtool/WT = W + if(!WT.use_tool(src, user, amount = 1)) + return + + to_chat(user, "You weld the metal chassis together.") + buildstate++ + update_icon() if(buildstate == 5) - var/obj/item/weldingtool/T = W - if(T.remove_fuel(0,user)) - if(!src || !T.isOn()) return - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - to_chat(user, "You weld the valve into place.") - new /obj/item/gun/launcher/pneumatic(get_turf(src)) - qdel(src) + var/obj/item/weldingtool/WT = W + if(!WT.use_tool(src, user, amount = 1)) + return + + to_chat(user, "You weld the valve into place.") + new /obj/item/gun/launcher/pneumatic(get_turf(src)) + qdel(src) return else ..() diff --git a/code/modules/projectiles/guns/magnetic/magnetic_construction.dm b/code/modules/projectiles/guns/magnetic/magnetic_construction.dm index 5c7cc985988..67a30988123 100644 --- a/code/modules/projectiles/guns/magnetic/magnetic_construction.dm +++ b/code/modules/projectiles/guns/magnetic/magnetic_construction.dm @@ -33,18 +33,11 @@ return if(isWelder(thing) && construction_stage == 4) - var/obj/item/weldingtool/welder = thing - - if(!welder.isOn()) - to_chat(user, "Turn it on first!") - return - - if(!welder.remove_fuel(0,user)) - to_chat(user, "You need more fuel!") + var/obj/item/weldingtool/WT = thing + if(!WT.use_tool(src, user, amount = 1)) return user.visible_message("\The [user] welds the barrel of \the [src] into place.") - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) increment_construction_stage() return diff --git a/code/modules/projectiles/guns/projectile/shotgun.dm b/code/modules/projectiles/guns/projectile/shotgun.dm index de673150697..494b7fa281f 100644 --- a/code/modules/projectiles/guns/projectile/shotgun.dm +++ b/code/modules/projectiles/guns/projectile/shotgun.dm @@ -109,11 +109,13 @@ /obj/item/boomstickframe/attackby(obj/item/W, mob/user) if(isWelder(W) && buildstate == 0) var/obj/item/weldingtool/WT = W - if(WT.remove_fuel(0, user)) - user.visible_message("\The [user] secures \the [src]'s barrel.") - add_fingerprint(user) - buildstate++ - update_icon() + if(!WT.use_tool(src, user, amount = 1)) + return + + user.visible_message("\The [user] secures \the [src]'s barrel.") + add_fingerprint(user) + buildstate++ + update_icon() return else if(istype(W,/obj/item/stack/rods) && buildstate == 1) var/obj/item/stack/rods/R = W diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index 9642c445f82..56c5dd346c5 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -283,58 +283,57 @@ else if(isWelder(I)) if(anchored) - var/obj/item/weldingtool/W = I - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - to_chat(user, "Welding the [nicetype] in place.") - if(do_after(user, 20, src)) - if(!src || !W.isOn()) return - to_chat(user, "The [nicetype] has been welded in place!") - update() // TODO: Make this neat - if(ispipe) // Pipe - - var/pipetype = dpipetype() - var/obj/structure/disposalpipe/P = new pipetype(src.loc) - src.transfer_fingerprints_to(P) - P.base_icon_state = base_state - P.set_dir(dir) - P.dpdir = dpdir - P.update_icon() - - //Needs some special treatment ;) - if(ptype == 5) - var/obj/structure/disposalpipe/trunk/TrunkP = P - TrunkP.getlinked() - else if(ptype == 9 || ptype == 10) - var/obj/structure/disposalpipe/sortjunction/SortP = P - SortP.sortType = sortType - SortP.updatedir() - SortP.updatedesc() - SortP.updatename() - - else if(ptype==6) // Disposal bin - var/obj/machinery/disposal/P = new /obj/machinery/disposal(src.loc) - src.transfer_fingerprints_to(P) - - else if(ptype==7) // Disposal outlet - - var/obj/structure/disposaloutlet/P = new /obj/structure/disposaloutlet(src.loc) - src.transfer_fingerprints_to(P) - P.set_dir(dir) - var/obj/structure/disposalpipe/trunk/Trunk = CP - Trunk.linked = P - - else if(ptype==8) // Disposal outlet - - var/obj/machinery/disposal/deliveryChute/P = new /obj/machinery/disposal/deliveryChute(src.loc) - src.transfer_fingerprints_to(P) - P.set_dir(dir) - - qdel(src) - return - else - to_chat(user, "You need more welding fuel to complete this task.") + var/obj/item/weldingtool/WT = I + to_chat(user, "Welding the [nicetype] in place.") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) + return + + if(QDELETED(src) || !user) return + + to_chat(user, "The [nicetype] has been welded in place!") + update() // TODO: Make this neat + if(ispipe) // Pipe + var/pipetype = dpipetype() + var/obj/structure/disposalpipe/P = new pipetype(src.loc) + src.transfer_fingerprints_to(P) + P.base_icon_state = base_state + P.set_dir(dir) + P.dpdir = dpdir + P.update_icon() + + //Needs some special treatment ;) + if(ptype == 5) + var/obj/structure/disposalpipe/trunk/TrunkP = P + TrunkP.getlinked() + else if(ptype == 9 || ptype == 10) + var/obj/structure/disposalpipe/sortjunction/SortP = P + SortP.sortType = sortType + SortP.updatedir() + SortP.updatedesc() + SortP.updatename() + + else if(ptype==6) // Disposal bin + var/obj/machinery/disposal/P = new /obj/machinery/disposal(src.loc) + src.transfer_fingerprints_to(P) + + else if(ptype==7) // Disposal outlet + + var/obj/structure/disposaloutlet/P = new /obj/structure/disposaloutlet(src.loc) + src.transfer_fingerprints_to(P) + P.set_dir(dir) + var/obj/structure/disposalpipe/trunk/Trunk = CP + Trunk.linked = P + + else if(ptype==8) // Disposal outlet + + var/obj/machinery/disposal/deliveryChute/P = new /obj/machinery/disposal/deliveryChute(src.loc) + src.transfer_fingerprints_to(P) + P.set_dir(dir) + + qdel(src) + return + else to_chat(user, "You need to attach it to the plating first!") return diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index b92a1798ebb..c5ebed3745e 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -76,30 +76,25 @@ if(!panel_open) to_chat(user, "You cannot work on the delivery chute if it is not turned off with its power connection exposed.") - var/obj/item/weldingtool/W = I - if(W.remove_fuel(0, user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - to_chat(user, "You start slicing the floorweld off the disposal unit.") - - if(do_after(user, 20, src)) - if(!src || !W.isOn()) - return - - eject() // In case if something's got inside while we were slicin' and the GC got fucked due to lag - to_chat(user, "You sliced the floorweld off the disposal unit.") - var/obj/structure/disposalconstruct/C = new (src.loc) - transfer_fingerprints_to(C) - C.ptype = 6 // 6 = disposal unit - C.anchored = 1 - C.set_density(1) - C.update() - qdel_self() + var/obj/item/weldingtool/WT = I + to_chat(user, "You start slicing the floorweld off the disposal unit.") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) return - else - to_chat(user, "You need more welding fuel to complete this task.") + if(QDELETED(src) || !user) return + eject() // In case if something's got inside while we were slicin' and the GC got fucked due to lag + to_chat(user, "You sliced the floorweld off the disposal unit.") + var/obj/structure/disposalconstruct/C = new (src.loc) + transfer_fingerprints_to(C) + C.ptype = 6 // 6 = disposal unit + C.anchored = 1 + C.set_density(1) + C.update() + qdel_self() + return + if(istype(I, /obj/item/storage/bag/trash)) var/obj/item/storage/bag/trash/T = I to_chat(user, "You empty the bag.") @@ -858,24 +853,16 @@ return // prevent interaction with T-scanner revealed pipes src.add_fingerprint(user, 0, I) if(isWelder(I)) - var/obj/item/weldingtool/W = I - - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - // check if anything changed over 2 seconds - var/turf/uloc = user.loc - var/atom/wloc = W.loc - to_chat(user, "Slicing the disposal pipe.") - sleep(30) - if(!W.isOn()) return - if(user.loc == uloc && wloc == W.loc) - welded() - else - to_chat(user, "You must stay still while welding the pipe.") - else - to_chat(user, "You need more welding fuel to cut the pipe.") + var/obj/item/weldingtool/WT = I + to_chat(user, "Slicing the disposal pipe.") + if(!WT.use_tool(src, user, delay = 3 SECONDS, amount = 1)) return + if(QDELETED(src) || !user) + return + + welded() + // called when pipe is cut with welder proc/welded() @@ -1512,24 +1499,16 @@ return // prevent interaction with T-scanner revealed pipes src.add_fingerprint(user, 0, I) if(isWelder(I)) - var/obj/item/weldingtool/W = I + var/obj/item/weldingtool/WT = I + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) + return - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - // check if anything changed over 2 seconds - var/turf/uloc = user.loc - var/atom/wloc = W.loc - to_chat(user, "Slicing the disposal pipe.") - sleep(30) - if(!W.isOn()) return - if(user.loc == uloc && wloc == W.loc) - welded() - else - to_chat(user, "You must stay still while welding the pipe.") - else - to_chat(user, "You need more welding fuel to cut the pipe.") + if(QDELETED(src) || !user) return + welded() + return + // would transfer to next pipe segment, but we are in a trunk // if not entering from disposal bin, // transfer to linked object (outlet or bin) @@ -1644,25 +1623,25 @@ to_chat(user, "You attach the screws around the power connection.") return else if(isWelder(I) && mode==1) - var/obj/item/weldingtool/W = I - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - to_chat(user, "You start slicing the floorweld off the disposal outlet.") - if(do_after(user,20, src)) - if(!src || !W.isOn()) return - to_chat(user, "You sliced the floorweld off the disposal outlet.") - var/obj/structure/disposalconstruct/C = new (src.loc) - src.transfer_fingerprints_to(C) - C.ptype = 7 // 7 = outlet - C.update() - C.anchored = 1 - C.set_density(1) - qdel(src) + var/obj/item/weldingtool/WT = I + to_chat(user, "You start slicing the floorweld off the disposal outlet.") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) return - else - to_chat(user, "You need more welding fuel to complete this task.") + + if(QDELETED(src) || !user) return + to_chat(user, "You sliced the floorweld off the disposal outlet.") + var/obj/structure/disposalconstruct/C = new (src.loc) + src.transfer_fingerprints_to(C) + C.ptype = 7 // 7 = outlet + C.update() + C.anchored = TRUE + C.set_density(TRUE) + qdel(src) + return + + // called when movable is expelled from a disposal pipe or outlet // by default does nothing, override for special behaviour diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index 529538d6986..d5c20451b78 100755 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -510,25 +510,24 @@ playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) to_chat(user, "You attach the screws around the power connection.") return - else if(isWelder(I) && c_mode==1) - var/obj/item/weldingtool/W = I - if(W.remove_fuel(1,user)) - to_chat(user, "You start slicing the floorweld off the delivery chute.") - if(do_after(user,20, src)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - if(!src || !W.isOn()) return - to_chat(user, "You sliced the floorweld off the delivery chute.") - var/obj/structure/disposalconstruct/C = new (src.loc) - C.ptype = 8 // 8 = Delivery chute - C.update() - C.anchored = 1 - C.set_density(1) - qdel(src) + else if(isWelder(I) && c_mode == 1) + var/obj/item/weldingtool/WT = I + to_chat(user, "You start slicing the floorweld off the delivery chute.") + if(!WT.use_tool(src, user, delay = 2 SECONDS, amount = 1)) return - else - to_chat(user, "You need more welding fuel to complete this task.") + + if(QDELETED(src) || !user) return + to_chat(user, "You sliced the floorweld off the delivery chute.") + var/obj/structure/disposalconstruct/C = new (src.loc) + C.ptype = 8 // 8 = Delivery chute + C.update() + C.anchored = TRUE + C.set_density(TRUE) + qdel(src) + return + /obj/machinery/disposal/deliveryChute/Destroy() if(trunk) trunk.linked = null diff --git a/code/modules/research/stock_parts_replacer.dm b/code/modules/research/stock_parts_replacer.dm index 33fff67d257..2e6dfc1eda3 100644 --- a/code/modules/research/stock_parts_replacer.dm +++ b/code/modules/research/stock_parts_replacer.dm @@ -53,12 +53,13 @@ /obj/item/storage/part_replacer/mini/attackby(obj/item/I, mob/user) if(isWelder(I)) var/obj/item/weldingtool/WT = I - if(WT.remove_fuel(0, user)) - salvage() - new /obj/item/stack/material/steel(get_turf(src)) - playsound(loc, 'sound/items/Welder.ogg', 100, 1) - qdel(src) - return + if(!WT.use_tool(src, user, amount = 1)) + return FALSE + + salvage() + new /obj/item/stack/material/steel(get_turf(src)) + qdel(src) + return if(isCrowbar(I)) if(wasted) diff --git a/code/modules/tables/tables.dm b/code/modules/tables/tables.dm index be9ac7e99a1..a88a0517b65 100644 --- a/code/modules/tables/tables.dm +++ b/code/modules/tables/tables.dm @@ -154,15 +154,17 @@ if(health < maxhealth && isWelder(W)) var/obj/item/weldingtool/F = W - if(F.welding) - to_chat(user, "You begin reparing damage to \the [src].") - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) - if(!do_after(user, 20, src) || !F.remove_fuel(1, user)) - return - user.visible_message("\The [user] repairs some damage to \the [src].", - "You repair some damage to \the [src].") - health = max(health+(maxhealth/5), maxhealth) // 20% repair per application - return 1 + to_chat(user, SPAN_NOTICE("You begin reparing damage to \the [src].")) + if(!F.use_tool(src, user, delay = 2 SECONDS, amount = 1)) + return FALSE + + if(QDELETED(src) || !user) + return + + user.visible_message(SPAN_NOTICE("\The [user] repairs some damage to \the [src]"), + SPAN_NOTICE("You repair some damage to \the [src].")) + health = max(health + (maxhealth / 5), maxhealth) // 20% repair per application + return TRUE if(!material && can_plate && istype(W, /obj/item/stack/material)) material = common_material_add(W, user, "plat") diff --git a/code/modules/xenoarcheaology/finds/finds.dm b/code/modules/xenoarcheaology/finds/finds.dm index 4d9367276fc..18ad5919d98 100644 --- a/code/modules/xenoarcheaology/finds/finds.dm +++ b/code/modules/xenoarcheaology/finds/finds.dm @@ -40,21 +40,18 @@ return if(isWelder(I)) - var/obj/item/weldingtool/W = I - if(W.isOn()) - if(W.get_fuel() >= 2) - var/obj/item/inside = locate() in src - if(inside) - inside.forceMove(get_turf(src)) - visible_message("\The [src] burns away revealing \the [inside].") - else - visible_message("\The [src] burns away into nothing.") - qdel(src) - W.remove_fuel(2) - else - visible_message("A few sparks fly off \the [src], but nothing else happens.") - W.remove_fuel(1) - return + var/obj/item/weldingtool/WT = I + if(!WT.use_tool(src, user, amount = 2)) + return FALSE + + var/obj/item/inside = locate() in src + if(inside) + inside.forceMove(get_turf(src)) + visible_message(SPAN_INFO("\The [src] burns away revealing \the [inside].")) + else + visible_message(SPAN_INFO("\The [src] burns away into nothing.")) + qdel(src) + return else if(istype(I, /obj/item/device/core_sampler)) var/obj/item/device/core_sampler/S = I diff --git a/icons/effects/effects.dmi b/icons/effects/effects.dmi index e673155c726..8b8376533ea 100644 Binary files a/icons/effects/effects.dmi and b/icons/effects/effects.dmi differ diff --git a/sound/effects/welderactivate.ogg b/sound/effects/welderactivate.ogg new file mode 100644 index 00000000000..b1b5dece26c Binary files /dev/null and b/sound/effects/welderactivate.ogg differ diff --git a/sound/effects/welderdeactivate.ogg b/sound/effects/welderdeactivate.ogg new file mode 100644 index 00000000000..152e89f9157 Binary files /dev/null and b/sound/effects/welderdeactivate.ogg differ