mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Clean up procs.
This commit is contained in:
@@ -13,15 +13,11 @@
|
|||||||
|
|
||||||
var/atom/A = O
|
var/atom/A = O
|
||||||
|
|
||||||
for (var/i = 0, ++i <= 20)
|
for (var/i = 0, ++i <= 16)
|
||||||
if (isarea(A))
|
if (isarea(A))
|
||||||
return A
|
return A
|
||||||
|
|
||||||
switch (istype(A))
|
A = A.loc
|
||||||
if (1)
|
|
||||||
A = A.loc
|
|
||||||
if (0)
|
|
||||||
return
|
|
||||||
|
|
||||||
/proc/get_area_master(const/O)
|
/proc/get_area_master(const/O)
|
||||||
var/area/A = get_area(O)
|
var/area/A = get_area(O)
|
||||||
@@ -59,19 +55,6 @@
|
|||||||
return 0
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
//Magic constants obtained by using linear regression on right-angled triangles of sides 0<x<1, 0<y<1
|
|
||||||
//They should approximate pythagoras theorem well enough for our needs.
|
|
||||||
#define k1 0.934
|
|
||||||
#define k2 0.427
|
|
||||||
/proc/cheap_hypotenuse(Ax,Ay,Bx,By) // T is just the second atom to check distance to center with
|
|
||||||
var/dx = abs(Ax - Bx) //sides of right-angled triangle
|
|
||||||
var/dy = abs(Ay - By)
|
|
||||||
if(dx>=dy) return (k1*dx) + (k2*dy) //No sqrt or powers :)
|
|
||||||
else return (k2*dx) + (k1*dy)
|
|
||||||
#undef k1
|
|
||||||
#undef k2
|
|
||||||
|
|
||||||
/proc/circlerange(center=usr,radius=3)
|
/proc/circlerange(center=usr,radius=3)
|
||||||
|
|
||||||
var/turf/centerturf = get_turf(center)
|
var/turf/centerturf = get_turf(center)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// Credits to Nickr5 for the useful procs I've taken from his library resource.
|
/**
|
||||||
|
* Credits to Nickr5 for the useful procs I've taken from his library resource.
|
||||||
|
*/
|
||||||
|
|
||||||
var/const/E = 2.71828183
|
var/const/E = 2.71828183
|
||||||
var/const/Sqrt2 = 1.41421356
|
var/const/Sqrt2 = 1.41421356
|
||||||
@@ -85,12 +87,16 @@ var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
|
|||||||
return sum / values
|
return sum / values
|
||||||
|
|
||||||
|
|
||||||
// Returns the nth root of x.
|
/*
|
||||||
/proc/Root(n, x)
|
* Returns the nth root of x.
|
||||||
|
*/
|
||||||
|
/proc/Root(const/n, const/x)
|
||||||
return x ** (1 / n)
|
return x ** (1 / n)
|
||||||
|
|
||||||
// secant
|
/*
|
||||||
/proc/Sec(x)
|
* Secant.
|
||||||
|
*/
|
||||||
|
/proc/Sec(const/x)
|
||||||
return 1 / cos(x)
|
return 1 / cos(x)
|
||||||
|
|
||||||
// The quadratic formula. Returns a list with the solutions, or an empty list
|
// The quadratic formula. Returns a list with the solutions, or an empty list
|
||||||
@@ -106,20 +112,51 @@ var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
|
|||||||
if(!d) return
|
if(!d) return
|
||||||
. += (-b - root) / bottom
|
. += (-b - root) / bottom
|
||||||
|
|
||||||
// tangent
|
/*
|
||||||
/proc/Tan(x)
|
* Tangent.
|
||||||
|
*/
|
||||||
|
/proc/Tan(const/x)
|
||||||
return sin(x) / cos(x)
|
return sin(x) / cos(x)
|
||||||
|
|
||||||
/proc/ToDegrees(radians)
|
/proc/ToDegrees(const/radians)
|
||||||
// 180 / Pi
|
// 180 / Pi
|
||||||
return radians * 57.2957795
|
return radians * 57.2957795
|
||||||
|
|
||||||
/proc/ToRadians(degrees)
|
/proc/ToRadians(const/degrees)
|
||||||
// Pi / 180
|
// Pi / 180
|
||||||
return degrees * 0.0174532925
|
return degrees * 0.0174532925
|
||||||
|
|
||||||
// min is inclusive, max is exclusive
|
// min is inclusive, max is exclusive
|
||||||
/proc/Wrap(val, min, max)
|
/proc/Wrap(val, min, max)
|
||||||
var/d = max - min
|
var/d = max - min
|
||||||
var/t = Floor((val - min) / d)
|
var/t = Floor((val - min) / d)
|
||||||
return val - (t * d)
|
return val - (t * d)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A very crude linear approximatiaon of pythagoras theorem.
|
||||||
|
*/
|
||||||
|
/proc/cheap_pythag(const/Ax, const/Ay)
|
||||||
|
var/dx = abs(Ax)
|
||||||
|
var/dy = abs(Ay)
|
||||||
|
|
||||||
|
if (dx >= dy)
|
||||||
|
return dx + (0.5 * dy) // The longest side add half the shortest side approximates the hypotenuse.
|
||||||
|
else
|
||||||
|
return dy + (0.5 * dx)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Magic constants obtained by using linear regression on right-angled triangles of sides 0<x<1, 0<y<1
|
||||||
|
* They should approximate pythagoras theorem well enough for our needs.
|
||||||
|
*/
|
||||||
|
#define k1 0.934
|
||||||
|
#define k2 0.427
|
||||||
|
/proc/cheap_hypotenuse(const/Ax, const/Ay, const/Bx, const/By)
|
||||||
|
var/dx = abs(Ax - Bx) // Sides of right-angled triangle.
|
||||||
|
var/dy = abs(Ay - By)
|
||||||
|
|
||||||
|
if (dx >= dy)
|
||||||
|
return (k1*dx) + (k2*dy) // No sqrt or powers :).
|
||||||
|
else
|
||||||
|
return (k2*dx) + (k1*dy)
|
||||||
|
#undef k1
|
||||||
|
#undef k2
|
||||||
|
|||||||
@@ -1252,15 +1252,11 @@ proc/get_mob_with_client_list()
|
|||||||
|
|
||||||
var/atom/A = O
|
var/atom/A = O
|
||||||
|
|
||||||
for (var/i = 0, ++i <= 20)
|
for (var/i = 0, ++i <= 16)
|
||||||
if (isturf(A))
|
if (isturf(A))
|
||||||
return A
|
return A
|
||||||
|
|
||||||
switch (istype(A))
|
A = A.loc
|
||||||
if (1)
|
|
||||||
A = A.loc
|
|
||||||
if (0)
|
|
||||||
return
|
|
||||||
|
|
||||||
/proc/get(atom/loc, type)
|
/proc/get(atom/loc, type)
|
||||||
while(loc)
|
while(loc)
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
//TODO: Flash range does nothing currently
|
//TODO: Flash range does nothing currently
|
||||||
|
|
||||||
//A very crude linear approximatiaon of pythagoras theorem.
|
/proc/trange(var/Dist = 0, var/turf/Center = null)//alternative to range (ONLY processes turfs and thus less intensive)
|
||||||
/proc/cheap_pythag(var/dx, var/dy)
|
if (isnull(Center))
|
||||||
dx = abs(dx); dy = abs(dy);
|
return
|
||||||
if(dx>=dy) return dx + (0.5*dy) //The longest side add half the shortest side approximates the hypotenuse
|
|
||||||
else return dy + (0.5*dx)
|
|
||||||
|
|
||||||
proc/trange(var/Dist=0,var/turf/Center=null)//alternative to range (ONLY processes turfs and thus less intensive)
|
|
||||||
if(Center==null) return
|
|
||||||
|
|
||||||
//var/x1=((Center.x-Dist)<1 ? 1 : Center.x-Dist)
|
//var/x1=((Center.x-Dist)<1 ? 1 : Center.x-Dist)
|
||||||
//var/y1=((Center.y-Dist)<1 ? 1 : Center.y-Dist)
|
//var/y1=((Center.y-Dist)<1 ? 1 : Center.y-Dist)
|
||||||
@@ -16,10 +11,11 @@ proc/trange(var/Dist=0,var/turf/Center=null)//alternative to range (ONLY process
|
|||||||
|
|
||||||
var/turf/x1y1 = locate(((Center.x-Dist)<1 ? 1 : Center.x-Dist),((Center.y-Dist)<1 ? 1 : Center.y-Dist),Center.z)
|
var/turf/x1y1 = locate(((Center.x-Dist)<1 ? 1 : Center.x-Dist),((Center.y-Dist)<1 ? 1 : Center.y-Dist),Center.z)
|
||||||
var/turf/x2y2 = locate(((Center.x+Dist)>world.maxx ? world.maxx : Center.x+Dist),((Center.y+Dist)>world.maxy ? world.maxy : Center.y+Dist),Center.z)
|
var/turf/x2y2 = locate(((Center.x+Dist)>world.maxx ? world.maxx : Center.x+Dist),((Center.y+Dist)>world.maxy ? world.maxy : Center.y+Dist),Center.z)
|
||||||
return block(x1y1,x2y2)
|
return block(x1y1, x2y2)
|
||||||
|
|
||||||
proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1, squelch = 0)
|
/proc/explosion(turf/epicenter, const/devastation_range, const/heavy_impact_range, const/light_impact_range, const/flash_range, adminlog = 1, squelch = 0)
|
||||||
src = null //so we don't abort once src is deleted
|
src = null //so we don't abort once src is deleted
|
||||||
|
|
||||||
spawn(0)
|
spawn(0)
|
||||||
if(config.use_recursive_explosions)
|
if(config.use_recursive_explosions)
|
||||||
var/power = devastation_range * 2 + heavy_impact_range + light_impact_range //The ranges add up, ie light 14 includes both heavy 7 and devestation 3. So this calculation means devestation counts for 4, heavy for 2 and light for 1 power, giving us a cap of 27 power.
|
var/power = devastation_range * 2 + heavy_impact_range + light_impact_range //The ranges add up, ie light 14 includes both heavy 7 and devestation 3. So this calculation means devestation counts for 4, heavy for 2 and light for 1 power, giving us a cap of 27 power.
|
||||||
@@ -42,11 +38,10 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
|
|||||||
// Calculate far explosion sound range. Only allow the sound effect for heavy/devastating explosions.
|
// Calculate far explosion sound range. Only allow the sound effect for heavy/devastating explosions.
|
||||||
|
|
||||||
// 3/7/14 will calculate to 80 + 35
|
// 3/7/14 will calculate to 80 + 35
|
||||||
var/far_dist = 0
|
var/far_dist = (devastation_range * 20) + (heavy_impact_range * 5)
|
||||||
far_dist += heavy_impact_range * 5
|
|
||||||
far_dist += devastation_range * 20
|
|
||||||
var/frequency = get_rand_frequency()
|
var/frequency = get_rand_frequency()
|
||||||
for(var/mob/M in player_list)
|
|
||||||
|
for (var/mob/M in player_list)
|
||||||
// Double check for client
|
// Double check for client
|
||||||
if(M && M.client)
|
if(M && M.client)
|
||||||
var/turf/M_turf = get_turf(M)
|
var/turf/M_turf = get_turf(M)
|
||||||
@@ -88,21 +83,22 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
|
|||||||
var/y0 = epicenter.y
|
var/y0 = epicenter.y
|
||||||
var/z0 = epicenter.z
|
var/z0 = epicenter.z
|
||||||
|
|
||||||
for(var/turf/T in trange(max_range, epicenter))
|
for (var/turf/T in trange(max_range, epicenter))
|
||||||
var/dist = cheap_pythag(T.x - x0,T.y - y0)
|
var/dist = cheap_pythag(T.x - x0, T.y - y0)
|
||||||
|
|
||||||
if(dist < devastation_range) dist = 1
|
if (dist < devastation_range)
|
||||||
else if(dist < heavy_impact_range) dist = 2
|
dist = 1
|
||||||
else if(dist < light_impact_range) dist = 3
|
else if (dist < heavy_impact_range)
|
||||||
else continue
|
dist = 2
|
||||||
|
else if (dist < light_impact_range)
|
||||||
|
dist = 3
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
|
||||||
if(T)
|
for (var/atom/A in T.contents)
|
||||||
//spawn(dist) No need for this anymore with the new garbage man
|
A.ex_act(dist)
|
||||||
T.ex_act(dist)
|
|
||||||
for(var/atom_movable in T.contents) //bypass type checking since only atom/movable can be contained by turfs anyway
|
T.ex_act(dist)
|
||||||
var/atom/movable/AM = atom_movable
|
|
||||||
//spawn(dist) No need for this anymore with the new garbage man
|
|
||||||
if(AM) AM.ex_act(dist)
|
|
||||||
|
|
||||||
var/took = (world.timeofday-start)/10
|
var/took = (world.timeofday-start)/10
|
||||||
//You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare
|
//You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare
|
||||||
|
|||||||
Reference in New Issue
Block a user