From e923714ae7c74029e39d177f8c40e9ccc49ad4f6 Mon Sep 17 00:00:00 2001 From: CHOMPStation2 <58959929+CHOMPStation2@users.noreply.github.com> Date: Sat, 2 Mar 2024 05:25:19 -0700 Subject: [PATCH] [MIRROR] Adds new mode for mining resonators: Resonance Cascade! (#7868) Co-authored-by: Runa Dacino Co-authored-by: CHOMPStation2 --- code/modules/mining/resonator_vr.dm | 49 +++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/code/modules/mining/resonator_vr.dm b/code/modules/mining/resonator_vr.dm index d3c3246a24..b007a3212f 100644 --- a/code/modules/mining/resonator_vr.dm +++ b/code/modules/mining/resonator_vr.dm @@ -18,6 +18,8 @@ var/fieldsactive = 0 var/burst_time = 50 var/fieldlimit = 3 + var/spreadmode = 0 + var/cascading = 0 /obj/item/resonator/upgraded name = "upgraded resonator" @@ -30,20 +32,28 @@ var/turf/T = get_turf(target) if(locate(/obj/effect/resonance) in T) return - if(fieldsactive < fieldlimit) + + if((!spreadmode && fieldsactive < fieldlimit) || (spreadmode && !cascading) ) playsound(src,'sound/weapons/resonator_fire.ogg',50,1) - new /obj/effect/resonance(T, creator, burst_time) + new /obj/effect/resonance(T, WEAKREF(creator), burst_time, spreadmode, fieldlimit, get_cardinal_dir(src, T)) fieldsactive++ + cascading = TRUE spawn(burst_time) fieldsactive-- + cascading = FALSE /obj/item/resonator/attack_self(mob/user) - if(burst_time == 50) - burst_time = 30 - to_chat(user, "You set the resonator's fields to detonate after 3 seconds.") - else - burst_time = 50 - to_chat(user, "You set the resonator's fields to detonate after 5 seconds.") + switch(tgui_alert(user, "Change Detonation Time or toggle Cascading?","Setting", list("Toggle Cascade", "Resonance Time"))) + if("Resonance Time") + if(burst_time == 50) + burst_time = 30 + to_chat(user, "You set the resonator's fields to detonate after 3 seconds.") + else + burst_time = 50 + to_chat(user, "You set the resonator's fields to detonate after 5 seconds.") + if("Toggle Cascade") + spreadmode = !spreadmode + to_chat(user, span_info("You have [(spreadmode ? "enabled" : "disabled")] the resonance cascade mode.")) /obj/item/resonator/afterattack(atom/target, mob/user, proximity_flag) if(proximity_flag) @@ -61,11 +71,30 @@ mouse_opacity = 0 var/resonance_damage = 20 -/obj/effect/resonance/Initialize(mapload, var/creator = null, var/timetoburst) + +/obj/effect/resonance/Initialize(mapload, var/creator = null, var/timetoburst, var/spread, var/fields, var/origin_dir, var/depth = 0) . = ..() // Start small and grow to big size as we are about to burst transform = matrix()*0.75 animate(src, transform = matrix()*1.5, time = timetoburst) + //Spread if requested + if(spread) + fields-- + var/new_dir = turn(origin_dir, 90) + var/new_fields = fields + for(var/i=0, i<=2, i++) //We place cascade the resonance by 3 entries each time in a "T shape" around the original resonance + if(fields > 0) + switch(i) + if(0) + new_dir = origin_dir + if(1) + new_dir = turn(origin_dir, 90) + if(2) + new_dir = turn(origin_dir, -90) + var/turf/T = get_step(get_turf(src), new_dir) + new_fields = fields - 2 - (i*3) - depth + fields-- + new /obj/effect/resonance(T, WEAKREF(creator), timetoburst, spread, new_fields, get_cardinal_dir(src, T), depth++) // Queue the actual bursting spawn(timetoburst) if(!QDELETED(src)) @@ -90,7 +119,7 @@ if(environment.temperature < 250) name = "strong resonance field" resonance_damage = 50 - + for(var/mob/living/L in src.loc) if(creator) add_attack_logs(creator, L, "used a resonator field on")