From 56a8fd834e7fb525c56e2a09cbc98b8754aad727 Mon Sep 17 00:00:00 2001 From: atermonera Date: Sat, 2 Apr 2022 19:13:04 -0800 Subject: [PATCH] C4 still explodes if the turf its placed upon changes --- code/datums/wires/explosive.dm | 2 +- code/game/objects/items/weapons/explosives.dm | 18 ++++++++++++------ code/modules/power/cells/esoteric_cells.dm | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/code/datums/wires/explosive.dm b/code/datums/wires/explosive.dm index 52b0150b66..f523a0ee99 100644 --- a/code/datums/wires/explosive.dm +++ b/code/datums/wires/explosive.dm @@ -31,4 +31,4 @@ /datum/wires/explosive/c4/explode() var/obj/item/weapon/plastique/P = holder - P.explode(get_turf(P)) + P.detonate(get_turf(P)) diff --git a/code/game/objects/items/weapons/explosives.dm b/code/game/objects/items/weapons/explosives.dm index 75411925a8..07743ddff5 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 @@ -54,9 +55,11 @@ 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 + var/turf/T = get_turf(target) + location = list(T.x, T.y, T.z) // Saving coordinates in case the reference becomes invalid loc = null if (ismob(target)) @@ -68,16 +71,19 @@ 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/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(src) + if(!istype(T) && location.len == 3) + T = locate(location[1], location[2], location[3]) + + if(istype(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..830c964b6b 100644 --- a/code/modules/power/cells/esoteric_cells.dm +++ b/code/modules/power/cells/esoteric_cells.dm @@ -69,6 +69,6 @@ C4.visible_message("The current fries \the [C4]!") if(prob(10)) - C4.explode(get_turf(src)) + C4.detonate() else qdel(C4)