Merge pull request #12485 from xxalpha/ultrarange

Added ultra_range() proc.
This commit is contained in:
Razharas
2015-10-20 00:17:09 +03:00
35 changed files with 108 additions and 49 deletions
+58
View File
@@ -1416,3 +1416,61 @@ B --><-- A
I.pixel_y = y_offset
return I
//similar function to range(), but with no limitations on the distance; will search spiralling outwards from the center
/proc/ultra_range(dist=0, center=usr, orange=0)
if(!dist)
if(!orange)
return list(center)
else
return list()
var/turf/t_center = get_turf(center)
if(!t_center)
return list()
var/list/L = list()
var/turf/T
var/y
var/x
var/c_dist = 1
if(!orange)
L += t_center
L += t_center.contents
while( c_dist <= dist )
y = t_center.y + c_dist
x = t_center.x - c_dist + 1
for(x in x to t_center.x+c_dist)
T = locate(x,y,t_center.z)
if(T)
L += T
L += T.contents
y = t_center.y + c_dist - 1
x = t_center.x + c_dist
for(y in t_center.y-c_dist to y)
T = locate(x,y,t_center.z)
if(T)
L += T
L += T.contents
y = t_center.y - c_dist
x = t_center.x + c_dist - 1
for(x in t_center.x-c_dist to x)
T = locate(x,y,t_center.z)
if(T)
L += T
L += T.contents
y = t_center.y - c_dist + 1
x = t_center.x - c_dist
for(y in y to t_center.y+c_dist)
T = locate(x,y,t_center.z)
if(T)
L += T
L += T.contents
c_dist++
return L
+1 -1
View File
@@ -88,7 +88,7 @@ STI KALY - blind
/datum/disease/wizarditis/proc/teleport()
var/list/theareas = new/list()
for(var/area/AR in orange(80, affected_mob))
for(var/area/AR in ultra_range(80, affected_mob, 1))
if(theareas.Find(AR) || istype(AR,/area/space)) continue
theareas += AR
+2 -2
View File
@@ -172,7 +172,7 @@ its easier to just keep the beam vertical.
dir=get_dir(src,BeamTarget) //Causes the source of the beam to rotate to continuosly face the BeamTarget.
for(var/obj/effect/overlay/beam/O in orange(10,src)) //This section erases the previously drawn beam because I found it was easier to
for(var/obj/effect/overlay/beam/O in ultra_range(10,src,1)) //This section erases the previously drawn beam because I found it was easier to
if(O.BeamSource==src) //just draw another instance of the beam instead of trying to manipulate all the
qdel(O) //pieces to a new orientation.
var/Angle=round(Get_Angle(src,BeamTarget))
@@ -215,7 +215,7 @@ its easier to just keep the beam vertical.
X.pixel_y=Pixel_y
sleep(3) //Changing this to a lower value will cause the beam to follow more smoothly with movement, but it will also be more laggy.
//I've found that 3 ticks provided a nice balance for my use.
for(var/obj/effect/overlay/beam/O in orange(10,src)) if(O.BeamSource==src) qdel(O)
for(var/obj/effect/overlay/beam/O in ultra_range(10,src,1)) if(O.BeamSource==src) qdel(O)
/atom/proc/examine(mob/user)
//This reformat names to get a/an properly working on item descriptions when they are bloody
@@ -206,7 +206,7 @@
AI_mind.current.verbs -= /datum/game_mode/malfunction/proc/takeover
var/mob/living/silicon/ai/AI = usr
for(var/turf/simulated/floor/bluegrid/T in orange(AI, 5))
for(var/turf/simulated/floor/bluegrid/T in orange(5, AI))
T.icon_state = "rcircuitanim" //Causes blue tiles near the AI to change to flashing red
/datum/game_mode/malfunction/proc/ai_win()
@@ -66,7 +66,7 @@ var/list/possibleShadowlingNames = list("U'ruan", "Y`shej", "Nex", "Hel-uae", "N
H.SetStunned(0)
H << "<i><b><font size=3>YOU LIVE!!!</i></b></font>"
for(var/obj/structure/alien/resin/wall/shadowling/W in orange(H, 1))
for(var/obj/structure/alien/resin/wall/shadowling/W in orange(1, H))
playsound(W, 'sound/effects/splat.ogg', 50, 1)
qdel(W)
for(var/obj/structure/alien/weeds/node/N in shadowturf)
+1 -1
View File
@@ -542,7 +542,7 @@ var/global/list/multiverse = list()
if("r_arm","l_arm")
//use active hand on random nearby mob
var/list/nearby_mobs = list()
for(var/mob/living/L in range(target,1))
for(var/mob/living/L in range(1, target))
if(L!=target)
nearby_mobs |= L
if(nearby_mobs.len)
@@ -113,7 +113,7 @@
connectedscrubbers = new()
var/found = 0
for(var/obj/machinery/portable_atmospherics/scrubber/huge/scrubber in range(range, src.loc))
for(var/obj/machinery/portable_atmospherics/scrubber/huge/scrubber in ultra_range(range, src.loc))
if(istype(scrubber))
found = 1
connectedscrubbers += scrubber
@@ -165,7 +165,7 @@
if(target)
loadProgram(target)
active = 0
for(var/mob/M in range(10,src))
for(var/mob/M in ultra_range(10,src))
M.show_message("The holodeck overloads!")
+2 -2
View File
@@ -228,8 +228,8 @@ var/global/datum/crewmonitor/crewmonitor = new
var/obj/machinery/camera/C = locate(/obj/machinery/camera) in range(5, tile)
if (!C) C = locate(/obj/machinery/camera) in range(10, tile)
if (!C) C = locate(/obj/machinery/camera) in range(15, tile)
if (!C) C = locate(/obj/machinery/camera) in ultra_range(10, tile)
if (!C) C = locate(/obj/machinery/camera) in ultra_range(15, tile)
if (C)
var/turf/current_loc = AI.eyeobj.loc
@@ -141,7 +141,7 @@ var/list/possible_uplinker_IDs = list("Alfa","Bravo","Charlie","Delta","Echo","F
transferlog += ("<b>[worldtime2text()]</b> [logmessage]")
/obj/machinery/computer/telecrystals/boss/proc/scanUplinkers()
for(var/obj/machinery/computer/telecrystals/uplinker/A in range(scanrange, src.loc))
for(var/obj/machinery/computer/telecrystals/uplinker/A in ultra_range(scanrange, src.loc))
if(!A.linkedboss)
TCstations += A
A.linkedboss = src
+3 -3
View File
@@ -39,15 +39,15 @@
Radio.listening = 0
spawn(20)
for(var/obj/machinery/door/window/brigdoor/M in range(20, src))
for(var/obj/machinery/door/window/brigdoor/M in ultra_range(20, src))
if (M.id == src.id)
targets += M
for(var/obj/machinery/flasher/F in range(20, src))
for(var/obj/machinery/flasher/F in ultra_range(20, src))
if(F.id == src.id)
targets += F
for(var/obj/structure/closet/secure_closet/brig/C in range(20, src))
for(var/obj/structure/closet/secure_closet/brig/C in ultra_range(20, src))
if(C.id == src.id)
targets += C
+1 -1
View File
@@ -289,7 +289,7 @@
amount = dispense(amount, cointype, null, 0)
else
var/mob/living/target = locate() in range(src, 2)
var/mob/living/target = locate() in range(2, src)
amount = dispense(amount, cointype, target, 1)
@@ -173,7 +173,7 @@
temp = "<font color = #D70B00>- FAILED: CANNOT PROBE WHEN BUFFER FULL -</font color>"
else
for(var/obj/machinery/telecomms/server/T in range(25, src))
for(var/obj/machinery/telecomms/server/T in ultra_range(25, src))
if(T.network == network)
servers.Add(T)
@@ -94,7 +94,7 @@
temp = "<font color = #D70B00>- FAILED: CANNOT PROBE WHEN BUFFER FULL -</font color>"
else
for(var/obj/machinery/telecomms/T in range(25, src))
for(var/obj/machinery/telecomms/T in ultra_range(25, src))
if(T.network == network)
machinelist.Add(T)
@@ -146,7 +146,7 @@ var/global/list/obj/machinery/telecomms/telecomms_list = list()
if(autolinkers.len)
// Links nearby machines
if(!long_range_link)
for(var/obj/machinery/telecomms/T in orange(20, src))
for(var/obj/machinery/telecomms/T in ultra_range(20, src, 1))
add_link(T)
else
for(var/obj/machinery/telecomms/T in telecomms_list)
@@ -39,18 +39,18 @@
if(locate(/obj/item/mecha_parts/mecha_equipment/hydraulic_clamp) in chassis.equipment)
var/obj/structure/ore_box/ore_box = locate(/obj/structure/ore_box) in chassis:cargo
if(ore_box)
for(var/obj/item/weapon/ore/ore in range(chassis,1))
for(var/obj/item/weapon/ore/ore in range(1, chassis))
if(get_dir(chassis,ore)&chassis.dir)
ore.Move(ore_box)
else if(istype(target, /turf/simulated/floor/plating/asteroid))
for(var/turf/simulated/floor/plating/asteroid/M in range(chassis,1))
for(var/turf/simulated/floor/plating/asteroid/M in range(1, chassis))
if(get_dir(chassis,M)&chassis.dir)
M.gets_dug()
log_message("Drilled through [target]")
if(locate(/obj/item/mecha_parts/mecha_equipment/hydraulic_clamp) in chassis.equipment)
var/obj/structure/ore_box/ore_box = locate(/obj/structure/ore_box) in chassis:cargo
if(ore_box)
for(var/obj/item/weapon/ore/ore in range(chassis,1))
for(var/obj/item/weapon/ore/ore in range(1, chassis))
if(get_dir(chassis,ore)&chassis.dir)
ore.Move(ore_box)
else
@@ -37,7 +37,7 @@
/obj/item/mecha_parts/mecha_equipment/wormhole_generator/action(atom/target)
if(!action_checks(target) || src.loc.z == ZLEVEL_CENTCOM) return
var/list/theareas = list()
for(var/area/AR in orange(100, chassis))
for(var/area/AR in ultra_range(100, chassis, 1))
if(AR in theareas) continue
theareas += AR
if(!theareas.len)
@@ -113,9 +113,9 @@
if(2)
var/list/atoms = list()
if(isturf(target))
atoms = range(target,3)
atoms = range(3, target)
else
atoms = orange(target,3)
atoms = orange(3, target)
for(var/atom/movable/A in atoms)
if(A.anchored) continue
spawn(0)
@@ -39,7 +39,7 @@ effective or pretty fucking useless.
add_logs(user, null, "knocked down people in the area", src)
for(var/mob/living/carbon/human/M in orange(10, user))
for(var/mob/living/carbon/human/M in ultra_range(10, user, 1))
spawn()
if(prob(50))
+2 -2
View File
@@ -1107,7 +1107,7 @@
/obj/item/toy/minimeteor/throw_impact(atom/hit_atom)
if(!..())
playsound(src, 'sound/effects/meteorimpact.ogg', 40, 1)
for(var/mob/M in range(10, src))
for(var/mob/M in ultra_range(10, src))
if(!M.stat && !istype(M, /mob/living/silicon/ai))\
shake_camera(M, 3, 1)
qdel(src)
@@ -1153,7 +1153,7 @@
cooldown = (world.time + 300) // Sets cooldown at 30 seconds
user.visible_message("<span class='warning'>[user] presses the big red button.</span>", "<span class='notice'>You press the button, it plays a loud noise!</span>", "<span class='italics'>The button clicks loudly.</span>")
playsound(src, 'sound/effects/explosionfar.ogg', 50, 0, surround = 0)
for(var/mob/M in range(10, src)) // Checks range
for(var/mob/M in ultra_range(10, src)) // Checks range
if(!M.stat && !istype(M, /mob/living/silicon/ai)) // Checks to make sure whoever's getting shaken is alive/not the AI
sleep(8) // Short delay to match up with the explosion sound
shake_camera(M, 2, 1) // Shakes player camera 2 squares for 1 second.
@@ -149,7 +149,7 @@ Frequency:
else
L["[com.id] (Inactive)"] = com.target
var/list/turfs = list( )
for(var/turf/T in orange(10))
for(var/turf/T in ultra_range(10, orange=1))
if(T.x>world.maxx-8 || T.x<8) continue //putting them at the edge is dumb
if(T.y>world.maxy-8 || T.y<8) continue
turfs += T
+1 -1
View File
@@ -177,7 +177,7 @@ Code:
return 0
if(signal.encryption != code)
return 0
for(var/obj/effect/anomaly/A in orange(0, src))
for(var/obj/effect/anomaly/A in get_turf(src))
A.anomalyNeutralize()
/obj/item/device/assembly/signaler/anomaly/attack_self()
+1 -1
View File
@@ -49,7 +49,7 @@
var/y_distance = TO.y - FROM.y
var/x_distance = TO.x - FROM.x
for (var/atom/movable/A in range(12, FROM )) // iterate thru list of mobs in the area
for (var/atom/movable/A in ultra_range(12, FROM )) // iterate thru list of mobs in the area
if(istype(A, /obj/item/device/radio/beacon)) continue // don't teleport beacons because that's just insanely stupid
if(A.anchored) continue
+1 -1
View File
@@ -31,5 +31,5 @@
return
for(var/obj/effect/landmark/epicentre in epicentreList)
for(var/obj/machinery/power/apc/apc in range(epicentre,lightsoutRange))
for(var/obj/machinery/power/apc/apc in ultra_range(lightsoutRange, epicentre))
apc.overload_lighting()
+1 -1
View File
@@ -361,7 +361,7 @@
return
if(istype(W, /obj/item/weapon/scythe))
for(var/obj/effect/spacevine/B in orange(src,1))
for(var/obj/effect/spacevine/B in orange(1,src))
if(prob(80))
qdel(B)
qdel(src)
+1 -1
View File
@@ -483,7 +483,7 @@ var/list/non_fakeattack_weapons = list(/obj/item/weapon/gun/projectile, /obj/ite
target = T
var/image/I = null
var/count = 0
for(var/obj/machinery/door/airlock/A in range(target,7))
for(var/obj/machinery/door/airlock/A in range(7, target))
if(count>door_number && door_number>0)
break
count++
+1 -1
View File
@@ -267,7 +267,7 @@
lighting_object = locate() in src
init_lighting()
for(var/turf/space/S in orange(src,1))
for(var/turf/space/S in orange(1,src))
S.update_starlight()
+1 -1
View File
@@ -399,7 +399,7 @@ var/global/list/rockTurfEdgeCache
if(prob(30))
if(istype(loc, /area/mine/explored))
return
for(var/atom/A in range(15,T))//Lowers chance of mob clumps
for(var/atom/A in ultra_range(15,T))//Lowers chance of mob clumps
if(istype(A, /mob/living/simple_animal/hostile/asteroid))
return
var/randumb = pickweight(mob_spawn_list)
+4 -4
View File
@@ -395,17 +395,17 @@
doing |= TRAVEL
if(nearby.len > 4)
//i'm crowded, time to leave
TARGET = pick(target_filter(orange(MAX_RANGE_FIND,src)))
TARGET = pick(target_filter(ultra_range(MAX_RANGE_FIND,src,1)))
else if(prob((FUZZY_CHANCE_LOW+FUZZY_CHANCE_HIGH)/2))
//chance to chase an item
TARGET = locate(/obj/item) in orange(MIN_RANGE_FIND,src)
TARGET = locate(/obj/item) in ultra_range(MIN_RANGE_FIND,src,1)
else if(prob((FUZZY_CHANCE_LOW+FUZZY_CHANCE_HIGH)/2))
//chance to leave
TARGET = locate(/obj/machinery/door) in orange(MIN_RANGE_FIND,src) // this is a sort of fix for the current pathing.
TARGET = locate(/obj/machinery/door) in ultra_range(MIN_RANGE_FIND,src,1) // this is a sort of fix for the current pathing.
else
//else, target whatever, or go to our department
if(prob((FUZZY_CHANCE_LOW+FUZZY_CHANCE_HIGH)/2))
TARGET = pick(target_filter(orange(MIN_RANGE_FIND,src)))
TARGET = pick(target_filter(ultra_range(MIN_RANGE_FIND,src,1)))
else
TARGET = pick(get_area_turfs(job2area(myjob)))
tryWalk(TARGET)
+2 -2
View File
@@ -86,7 +86,7 @@ Sorry Giacom. Please don't be mad :(
//BubbleWrap: Should stop you pushing a restrained person out of the way
if(istype(M, /mob/living))
for(var/mob/MM in range(M, 1))
for(var/mob/MM in range(1,M))
if( ((MM.pulling == M && ( M.restrained() && !( MM.restrained() ) && MM.stat == CONSCIOUS)) || locate(/obj/item/weapon/grab, M.grabbed_by.len)) )
if ( !(world.time % 5) )
src << "<span class='warning'>[M] is restrained, you cannot push past.</span>"
@@ -517,7 +517,7 @@ Sorry Giacom. Please don't be mad :(
var/cuff_dragged = 0
if (restrained())
for(var/mob/living/M in range(src, 1))
for(var/mob/living/M in range(1, src))
if (M.pulling == src && !M.incapacitated())
cuff_dragged = 1
if (!cuff_dragged && pulling && !throwing && (get_dist(src, pulling) <= 1 || pulling.loc == loc))
@@ -140,7 +140,7 @@
src.y = y
src.z = z
for(var/obj/machinery/camera/c in range(CHUNK_SIZE, locate(x + (CHUNK_SIZE / 2), y + (CHUNK_SIZE / 2), z)))
for(var/obj/machinery/camera/c in ultra_range(CHUNK_SIZE, locate(x + (CHUNK_SIZE / 2), y + (CHUNK_SIZE / 2), z)))
if(c.can_use())
cameras += c
@@ -83,7 +83,7 @@
//1% chance to skitter madly away
if(!busy && prob(1))
stop_automated_movement = 1
Goto(pick(orange(20, src)), move_to_delay)
Goto(pick(ultra_range(20, src, 1)), move_to_delay)
spawn(50)
stop_automated_movement = 0
walk(src,0)
+1 -1
View File
@@ -147,7 +147,7 @@
move_delay += T.slowdown
if(mob.restrained()) //Why being pulled while cuffed prevents you from moving
for(var/mob/M in range(mob, 1))
for(var/mob/M in range(1, mob))
if(M.pulling == mob)
if(!M.incapacitated() && mob.Adjacent(M))
src << "<span class='warning'>You're restrained! You can't move!</span>"
+1 -1
View File
@@ -139,7 +139,7 @@
set background = BACKGROUND_ENABLED
// if(defer_powernet_rebuild != 2)
// defer_powernet_rebuild = 1
for(var/atom/X in orange(consume_range,src))
for(var/atom/X in ultra_range(consume_range,src,1))
if(isturf(X) || istype(X, /atom/movable))
consume(X)
// if(defer_powernet_rebuild != 2)
@@ -112,7 +112,7 @@
/obj/singularity/proc/admin_investigate_setup()
last_warning = world.time
var/count = locate(/obj/machinery/field/containment) in orange(30, src)
var/count = locate(/obj/machinery/field/containment) in ultra_range(30, src, 1)
if(!count) message_admins("A singulo has been created without containment fields active ([x],[y],[z])",1)
investigate_log("was created. [count?"":"<font color='red'>No containment fields were active</font>"]","singulo")
@@ -233,7 +233,8 @@
/obj/singularity/proc/eat()
set background = BACKGROUND_ENABLED
for(var/atom/X in orange(grav_pull,src))
var/list/L = grav_pull > 8 ? ultra_range(grav_pull, src, 1) : orange(grav_pull, src)
for(var/atom/X in L)
var/dist = get_dist(X, src)
var/obj/singularity/S = src
if(dist > consume_range)
@@ -368,7 +369,7 @@
/obj/singularity/proc/combust_mobs()
for(var/mob/living/carbon/C in orange(20, src))
for(var/mob/living/carbon/C in ultra_range(20, src, 1))
C.visible_message("<span class='warning'>[C]'s skin bursts into flame!</span>", \
"<span class='userdanger'>You feel an inner fire as your skin bursts into flames!</span>")
C.adjust_fire_stacks(5)
@@ -80,7 +80,7 @@
return
A.ex_act(2)
playsound(src.loc, 'sound/effects/meteorimpact.ogg', 40, 1)
for(var/mob/M in range(10, src))
for(var/mob/M in ultra_range(10, src))
if(!M.stat)
shake_camera(M, 3, 1)
qdel(src)