From 580afaf74a5edd43f18f8408250e179118970855 Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Mon, 24 Aug 2020 20:29:25 -0400 Subject: [PATCH 01/16] init first attempt --- code/_globalvars/lists/objects.dm | 1 + code/modules/power/tesla/coil.dm | 8 ++++++++ code/modules/power/tesla/energy_ball.dm | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 4de7c88bf7..2b6a733941 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -13,6 +13,7 @@ GLOBAL_LIST_EMPTY(deliverybeacontags) //list of all tags associated with d GLOBAL_LIST_EMPTY(nuke_list) GLOBAL_LIST_EMPTY(alarmdisplay) //list of all machines or programs that can display station alerts GLOBAL_LIST_EMPTY(singularities) //list of all singularities on the station (actually technically all engines) +GLOBAL_LIST_EMPTY(grounding_rods) //list of all grounding rods on the station GLOBAL_LIST(chemical_reactions_list) //list of all /datum/chemical_reaction datums. Used during chemical reactions GLOBAL_LIST(chemical_reagents_list) //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff diff --git a/code/modules/power/tesla/coil.dm b/code/modules/power/tesla/coil.dm index eb80548441..be24ea0fef 100644 --- a/code/modules/power/tesla/coil.dm +++ b/code/modules/power/tesla/coil.dm @@ -160,6 +160,14 @@ buckle_lying = FALSE buckle_requires_restraints = TRUE +/obj/machinery/power/grounding_rod/Initialize() + GLOB.grounding_rods |= src + return ..() + +/obj/machinery/power/grounding_rod/Destroy() + GLOB.grounding_rods.Remove(src) + return ..() + /obj/machinery/power/grounding_rod/default_unfasten_wrench(mob/user, obj/item/I, time = 20) . = ..() if(. == SUCCESSFUL_UNFASTEN) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 06e5d27f6d..7b247934d6 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -31,6 +31,7 @@ var/produced_power var/energy_to_raise = 32 var/energy_to_lower = -20 + var/rodtarget /obj/singularity/energy_ball/Initialize(mapload, starting_energy = 50, is_miniball = FALSE) miniball = is_miniball @@ -91,8 +92,20 @@ /obj/singularity/energy_ball/proc/move_the_basket_ball(var/move_amount) //we face the last thing we zapped, so this lets us favor that direction a bit var/move_bias = pick(GLOB.alldirs) + var/rods = GLOB.grounding_rods + if(rods) // grounding rods pull the tesla ball, picks the nearest one + for(var/rod in rods) + if(!rodtarget) + rodtarget=rod + + if(get_dist(src,rod) Date: Mon, 24 Aug 2020 20:54:36 -0400 Subject: [PATCH 02/16] it likes moving grounding rod now it actually gets the dir instead of just adding the rod itself to the pick also moved declaration of move_dir because dm was freaking out because i had two declarations --- code/modules/power/tesla/energy_ball.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 7b247934d6..b4ca2062b3 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -92,6 +92,7 @@ /obj/singularity/energy_ball/proc/move_the_basket_ball(var/move_amount) //we face the last thing we zapped, so this lets us favor that direction a bit var/move_bias = pick(GLOB.alldirs) + var/move_dir var/rods = GLOB.grounding_rods if(rods) // grounding rods pull the tesla ball, picks the nearest one for(var/rod in rods) @@ -103,9 +104,9 @@ for(var/i in 0 to move_amount) if(rods) - var/move_dir = pick(GLOB.alldirs + move_bias + rodtarget) + move_dir = pick(GLOB.alldirs + get_dir(src,rodtarget)) else - var/move_dir = pick(GLOB.alldirs + move_bias) //ensures large-ball teslas don't just sit around + move_dir = pick(GLOB.alldirs + move_bias) //ensures large-ball teslas don't just sit around if(target && prob(10)) move_dir = get_dir(src,target) var/turf/T = get_step(src, move_dir) From 9743e5b458384875c61a4380357f46936ca920ae Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Mon, 24 Aug 2020 23:10:44 -0400 Subject: [PATCH 03/16] tesla counterplay?? just put out some grounding rods and it'll eat up the rods at expense of some energy --- code/modules/power/tesla/energy_ball.dm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index b4ca2062b3..2e0b8ad451 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -343,6 +343,12 @@ else power = closest_atom.zap_act(power, zap_flags, shocked_targets) + + var/obj/singularity/energy_ball/tesla = source + if(istype(tesla)) + if(istype(closest_atom,/obj/machinery/power/grounding_rod) && tesla.energy>13) + qdel(closest_atom) + tesla.energy = round(tesla.energy/1.5) if(prob(20))//I know I know tesla_zap(closest_atom, next_range, power * 0.5, zap_flags, shocked_targets) tesla_zap(closest_atom, next_range, power * 0.5, zap_flags, shocked_targets) From 591fc167476e45b8a5cb3539459f47899846fd3f Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Mon, 24 Aug 2020 23:20:28 -0400 Subject: [PATCH 04/16] oops! no grounding rods now it (hopefully) won't delete rods from within containment --- code/modules/power/tesla/energy_ball.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 2e0b8ad451..11bbca3431 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -346,9 +346,9 @@ var/obj/singularity/energy_ball/tesla = source if(istype(tesla)) - if(istype(closest_atom,/obj/machinery/power/grounding_rod) && tesla.energy>13) - qdel(closest_atom) - tesla.energy = round(tesla.energy/1.5) + if(istype(closest_atom,/obj/machinery/power/grounding_rod) && tesla.energy>13 && !tesla.contained) + qdel(closest_atom) // each rod deletes two miniballs, + tesla.energy = round(tesla.energy/1.5625) // if there are no miniballs the rod stays and continues to pull the ball in if(prob(20))//I know I know tesla_zap(closest_atom, next_range, power * 0.5, zap_flags, shocked_targets) tesla_zap(closest_atom, next_range, power * 0.5, zap_flags, shocked_targets) From df30569104364c7c9f080fe6822821659e9e3820 Mon Sep 17 00:00:00 2001 From: raspy-on-osu <47289484+raspy-on-osu@users.noreply.github.com> Date: Mon, 24 Aug 2020 23:32:48 -0400 Subject: [PATCH 05/16] Update code/modules/power/tesla/energy_ball.dm Co-authored-by: Putnam3145 --- code/modules/power/tesla/energy_ball.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 11bbca3431..5bb010d6f4 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -31,7 +31,7 @@ var/produced_power var/energy_to_raise = 32 var/energy_to_lower = -20 - var/rodtarget + var/obj/machinery/power/grounding_rod/rodtarget /obj/singularity/energy_ball/Initialize(mapload, starting_energy = 50, is_miniball = FALSE) miniball = is_miniball From 77015ed16663898a88a68cb6b7d5a8b124de0c00 Mon Sep 17 00:00:00 2001 From: raspy-on-osu <47289484+raspy-on-osu@users.noreply.github.com> Date: Mon, 24 Aug 2020 23:33:27 -0400 Subject: [PATCH 06/16] Update code/modules/power/tesla/energy_ball.dm Co-authored-by: Putnam3145 --- code/modules/power/tesla/energy_ball.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 5bb010d6f4..3aebbc7fce 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -96,7 +96,7 @@ var/rods = GLOB.grounding_rods if(rods) // grounding rods pull the tesla ball, picks the nearest one for(var/rod in rods) - if(!rodtarget) + if(!rodtarget || get_dist(src,rod) Date: Mon, 24 Aug 2020 23:35:17 -0400 Subject: [PATCH 07/16] Update code/modules/power/tesla/energy_ball.dm Co-authored-by: Putnam3145 --- code/modules/power/tesla/energy_ball.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 3aebbc7fce..ef59f0748d 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -103,7 +103,7 @@ rodtarget=rod for(var/i in 0 to move_amount) - if(rods) + if(rodtarget) move_dir = pick(GLOB.alldirs + get_dir(src,rodtarget)) else move_dir = pick(GLOB.alldirs + move_bias) //ensures large-ball teslas don't just sit around From 2e5517b9f32e96da413b5dab82c9fbe517378609 Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Mon, 24 Aug 2020 23:36:37 -0400 Subject: [PATCH 08/16] if committing above suggestion, remove these two lines ok done --- code/modules/power/tesla/energy_ball.dm | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index ef59f0748d..e9ddb288aa 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -98,9 +98,6 @@ for(var/rod in rods) if(!rodtarget || get_dist(src,rod) Date: Mon, 24 Aug 2020 23:46:38 -0400 Subject: [PATCH 09/16] if(rods) literally just eats disk space and nothing more no longer. 300 bytes saved --- code/modules/power/tesla/energy_ball.dm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index e9ddb288aa..38a4e4b0a2 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -93,11 +93,9 @@ //we face the last thing we zapped, so this lets us favor that direction a bit var/move_bias = pick(GLOB.alldirs) var/move_dir - var/rods = GLOB.grounding_rods - if(rods) // grounding rods pull the tesla ball, picks the nearest one - for(var/rod in rods) - if(!rodtarget || get_dist(src,rod) Date: Tue, 25 Aug 2020 00:46:04 -0400 Subject: [PATCH 10/16] tesla can now be contained for whatever reason, the contained variable was unused for teslas, but now it is unintentional side-effect may be that grounding rods for tesla containments with a larger than 1x1 tile space might get eaten (untested but assumed) --- code/modules/power/tesla/energy_ball.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 38a4e4b0a2..ac16941aeb 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -91,6 +91,7 @@ /obj/singularity/energy_ball/proc/move_the_basket_ball(var/move_amount) //we face the last thing we zapped, so this lets us favor that direction a bit + contained=0 var/move_bias = pick(GLOB.alldirs) var/move_dir for(var/rod in GLOB.grounding_rods) // grounding rods pull the tesla ball, picks the nearest one @@ -110,6 +111,8 @@ setDir(move_dir) for(var/mob/living/carbon/C in loc) dust_mobs(C) + else + contained=1 /obj/singularity/energy_ball/proc/handle_energy() From 6fc019ebf8f8adc51a43ce075de51fd07aa40492 Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Wed, 26 Aug 2020 21:20:23 -0400 Subject: [PATCH 11/16] create unique containment check for the tesla it now functions as normal. it only checks for containment in a 10 tile radius (this should work fine for the default setups of Delta and Lambda). --- code/modules/power/tesla/energy_ball.dm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index ac16941aeb..e734493698 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -63,6 +63,7 @@ /obj/singularity/energy_ball/process() + determine_containment() if(!orbiting) handle_energy() @@ -91,7 +92,6 @@ /obj/singularity/energy_ball/proc/move_the_basket_ball(var/move_amount) //we face the last thing we zapped, so this lets us favor that direction a bit - contained=0 var/move_bias = pick(GLOB.alldirs) var/move_dir for(var/rod in GLOB.grounding_rods) // grounding rods pull the tesla ball, picks the nearest one @@ -111,8 +111,24 @@ setDir(move_dir) for(var/mob/living/carbon/C in loc) dust_mobs(C) - else - contained=1 + + +/obj/singularity/energy_ball/proc/determine_containment() + contained=0 + var/found + var/tiletocheck + for(var/direction in GLOB.cardinals) // check a radius of 10 tiles around the ball for a full containment field + tiletocheck=get_step(src,direction) + for(var/tile in 1 to 10) + found=locate(/obj/machinery/field/containment) in tiletocheck + if(found) + continue + else if (!found && tile==10) + return // if one side is lacking a field it doesn't bother checking the others + tiletocheck=get_step(tiletocheck,direction) + contained=1 + + /obj/singularity/energy_ball/proc/handle_energy() From f3990732f3e19dce08be78195d4eb199e6dfa53f Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Wed, 26 Aug 2020 21:25:45 -0400 Subject: [PATCH 12/16] remove excess whitespace title --- code/modules/power/tesla/energy_ball.dm | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index e734493698..ea50015663 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -127,8 +127,6 @@ return // if one side is lacking a field it doesn't bother checking the others tiletocheck=get_step(tiletocheck,direction) contained=1 - - /obj/singularity/energy_ball/proc/handle_energy() From 7840205d4eb9b7ac4b0a157bf4f834320cfaa3df Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Wed, 26 Aug 2020 23:59:15 -0400 Subject: [PATCH 13/16] shuffle containment checking for optimization now it should be checking less (tested, functionally identical to before) --- code/modules/power/tesla/energy_ball.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index ea50015663..f28eadd297 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -62,11 +62,12 @@ ..() -/obj/singularity/energy_ball/process() - determine_containment() +/obj/singularity/energy_ball/process() if(!orbiting) handle_energy() + determine_containment() + move_the_basket_ball(4 + orbiting_balls.len * 1.5) playsound(src.loc, 'sound/magic/lightningbolt.ogg', 100, TRUE, extrarange = 30) From 68cb78ba51119db28f2aefcdbc74359d98d57cdf Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Thu, 27 Aug 2020 00:03:58 -0400 Subject: [PATCH 14/16] why is this here no really how the fuck did this happen --- code/modules/power/tesla/energy_ball.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index f28eadd297..a687ea87a3 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -62,7 +62,7 @@ ..() -/obj/singularity/energy_ball/process() +/obj/singularity/energy_ball/process() if(!orbiting) handle_energy() From 350a99a4ba01a69536f9092cd71346dd0420f92b Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Thu, 27 Aug 2020 02:39:09 -0400 Subject: [PATCH 15/16] teslas now fizzle at 0 energy and adds admin log for fizzles fixing the tesla engine 100% speedrun world record --- code/__DEFINES/logging.dm | 1 + code/modules/power/tesla/energy_ball.dm | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index ecb58f1291..2a8f39766b 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -6,6 +6,7 @@ #define INVESTIGATE_GRAVITY "gravity" #define INVESTIGATE_RECORDS "records" #define INVESTIGATE_SINGULO "singulo" +#define INVESTIGATE_TESLA "tesla" #define INVESTIGATE_SUPERMATTER "supermatter" #define INVESTIGATE_TELESCI "telesci" #define INVESTIGATE_WIRES "wires" diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index a687ea87a3..ce0bc27461 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -148,6 +148,10 @@ else if(orbiting_balls.len) dissipate() //sing code has a much better system. + if(energy<=0) + investigate_log("fizzled.", INVESTIGATE_TESLA) + qdel(src) + /obj/singularity/energy_ball/proc/new_mini_ball() if(!loc) return From 172fe663c3dddac55f001754057b88c799631825 Mon Sep 17 00:00:00 2001 From: raspy-on-osu Date: Thu, 27 Aug 2020 02:46:19 -0400 Subject: [PATCH 16/16] remove redundant separate tesla log and merge it into the singulo log also formatting because i hate inconsistent whitespace --- code/__DEFINES/logging.dm | 1 - code/modules/power/tesla/energy_ball.dm | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index 2a8f39766b..ecb58f1291 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -6,7 +6,6 @@ #define INVESTIGATE_GRAVITY "gravity" #define INVESTIGATE_RECORDS "records" #define INVESTIGATE_SINGULO "singulo" -#define INVESTIGATE_TESLA "tesla" #define INVESTIGATE_SUPERMATTER "supermatter" #define INVESTIGATE_TELESCI "telesci" #define INVESTIGATE_WIRES "wires" diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index ce0bc27461..89c5aa3316 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -61,7 +61,6 @@ return //don't annnounce miniballs ..() - /obj/singularity/energy_ball/process() if(!orbiting) handle_energy() @@ -90,7 +89,6 @@ if(orbiting_balls.len) . += "There are [orbiting_balls.len] mini-balls orbiting it." - /obj/singularity/energy_ball/proc/move_the_basket_ball(var/move_amount) //we face the last thing we zapped, so this lets us favor that direction a bit var/move_bias = pick(GLOB.alldirs) @@ -113,7 +111,6 @@ for(var/mob/living/carbon/C in loc) dust_mobs(C) - /obj/singularity/energy_ball/proc/determine_containment() contained=0 var/found @@ -129,7 +126,6 @@ tiletocheck=get_step(tiletocheck,direction) contained=1 - /obj/singularity/energy_ball/proc/handle_energy() if(energy >= energy_to_raise) energy_to_lower = energy_to_raise - 20 @@ -149,7 +145,7 @@ dissipate() //sing code has a much better system. if(energy<=0) - investigate_log("fizzled.", INVESTIGATE_TESLA) + investigate_log("fizzled.", INVESTIGATE_SINGULO) qdel(src) /obj/singularity/energy_ball/proc/new_mini_ball() @@ -165,7 +161,6 @@ EB.orbit(src, orbitsize, pick(FALSE, TRUE), rand(10, 25), pick(3, 4, 5, 6, 36)) - /obj/singularity/energy_ball/Bump(atom/A) dust_mobs(A) @@ -197,7 +192,6 @@ if (!QDELETED(src)) qdel(src) - /obj/singularity/energy_ball/proc/dust_mobs(atom/A) if(isliving(A)) var/mob/living/L = A