diff --git a/code/datums/wires/explosive.dm b/code/datums/wires/explosive.dm index 52b0150b66..234f75a9e8 100644 --- a/code/datums/wires/explosive.dm +++ b/code/datums/wires/explosive.dm @@ -31,4 +31,5 @@ /datum/wires/explosive/c4/explode() var/obj/item/weapon/plastique/P = holder - P.explode(get_turf(P)) + P.set_target(get_turf(P)) + P.detonate() diff --git a/code/game/objects/items/weapons/explosives.dm b/code/game/objects/items/weapons/explosives.dm index 8cbd953a6b..4ecf203424 100644 --- a/code/game/objects/items/weapons/explosives.dm +++ b/code/game/objects/items/weapons/explosives.dm @@ -11,6 +11,7 @@ var/datum/wires/explosive/c4/wires = null var/timer = 10 var/atom/target = null + var/list/location = list() var/open_panel = 0 var/image_overlay = null var/blast_dev = -1 @@ -53,9 +54,9 @@ to_chat(user, "Planting explosives...") user.do_attack_animation(target) - if(do_after(user, 50) && in_range(user, target)) + if(do_after(user, 5 SECONDS) && in_range(user, target)) user.drop_item() - src.target = target + set_target(target) // Saving coordinates in case the reference becomes invalid loc = null if (ismob(target)) @@ -67,16 +68,25 @@ target.overlays += image_overlay to_chat(user, "Bomb has been planted. Timer counting down from [timer].") - spawn(timer*10) - explode(get_turf(target)) + addtimer(CALLBACK(src, .proc/detonate), timer SECONDS) -/obj/item/weapon/plastique/proc/explode(var/location) +/obj/item/weapon/plastique/proc/set_target(var/atom/T) + if(!isatom(T)) + return + target = T + location = list(T.x, T.y, T.z) + +/obj/item/weapon/plastique/proc/detonate() if(!target) target = get_atom_on_turf(src) if(!target) target = src - if(location) - explosion(location, blast_dev, blast_heavy, blast_light, blast_flash) + + var/turf/T = get_turf(target) + if (!T && length(location)) + T = locate(location[1], location[2], location[3]) + if (T) + explosion(T, blast_dev, blast_heavy, blast_light, blast_flash) if(target) if (istype(target, /turf/simulated/wall)) diff --git a/code/modules/power/cells/esoteric_cells.dm b/code/modules/power/cells/esoteric_cells.dm index b9bb06bf68..346d3b3ad1 100644 --- a/code/modules/power/cells/esoteric_cells.dm +++ b/code/modules/power/cells/esoteric_cells.dm @@ -69,6 +69,7 @@ C4.visible_message("The current fries \the [C4]!") if(prob(10)) - C4.explode(get_turf(src)) + C4.set_target(src) + C4.detonate() else qdel(C4)