From 56a8fd834e7fb525c56e2a09cbc98b8754aad727 Mon Sep 17 00:00:00 2001 From: atermonera Date: Sat, 2 Apr 2022 19:13:04 -0800 Subject: [PATCH 1/3] 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) From 4368e990557348b6550d04026ec32030e755b576 Mon Sep 17 00:00:00 2001 From: atermonera Date: Mon, 4 Apr 2022 23:02:21 -0800 Subject: [PATCH 2/3] fiddlybits --- code/datums/wires/explosive.dm | 3 ++- code/game/objects/items/weapons/explosives.dm | 21 +++++++++++++------ code/modules/power/cells/esoteric_cells.dm | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/code/datums/wires/explosive.dm b/code/datums/wires/explosive.dm index f523a0ee99..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.detonate(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 07743ddff5..a5e647547e 100644 --- a/code/game/objects/items/weapons/explosives.dm +++ b/code/game/objects/items/weapons/explosives.dm @@ -57,9 +57,7 @@ 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 + set_target(target) // Saving coordinates in case the reference becomes invalid loc = null if (ismob(target)) @@ -73,16 +71,27 @@ to_chat(user, "Bomb has been planted. Timer counting down from [timer].") addtimer(CALLBACK(src, .proc/detonate), timer SECONDS) +/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 - var/turf/T = get_turf(src) - if(!istype(T) && location.len == 3) + + var/turf/T = null + if(isturf(get_turf(target)) + T = get_turf(target) + if(LAZYLEN(location) == 3) T = locate(location[1], location[2], location[3]) + else + T = get_turf(target) - if(istype(T)) + if(isturf(T)) explosion(T, blast_dev, blast_heavy, blast_light, blast_flash) if(target) diff --git a/code/modules/power/cells/esoteric_cells.dm b/code/modules/power/cells/esoteric_cells.dm index 830c964b6b..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.set_target(src) C4.detonate() else qdel(C4) From f63d33eafdde3cd7a8f7ad7f753d493f9e11d715 Mon Sep 17 00:00:00 2001 From: Atermonera Date: Wed, 6 Apr 2022 16:35:22 -0800 Subject: [PATCH 3/3] Update code/game/objects/items/weapons/explosives.dm Co-authored-by: Spookerton --- code/game/objects/items/weapons/explosives.dm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/code/game/objects/items/weapons/explosives.dm b/code/game/objects/items/weapons/explosives.dm index a5e647547e..bd24c3c366 100644 --- a/code/game/objects/items/weapons/explosives.dm +++ b/code/game/objects/items/weapons/explosives.dm @@ -83,15 +83,10 @@ if(!target) target = src - var/turf/T = null - if(isturf(get_turf(target)) - T = get_turf(target) - if(LAZYLEN(location) == 3) + var/turf/T = get_turf(target) + if (!T && length(location)) T = locate(location[1], location[2], location[3]) - else - T = get_turf(target) - - if(isturf(T)) + if (T) explosion(T, blast_dev, blast_heavy, blast_light, blast_flash) if(target)