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()