mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Removes the approximations cheap_pythag and cheap_hypotenuse, since they're anything *but* cheap
This commit is contained in:
@@ -61,18 +61,6 @@
|
||||
/proc/isNotAdminLevel(var/level)
|
||||
return !isAdminLevel(level)
|
||||
|
||||
//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)
|
||||
|
||||
var/turf/centerturf = get_turf(center)
|
||||
|
||||
@@ -115,7 +115,7 @@ datum/light_source
|
||||
dist = 0
|
||||
else
|
||||
#ifdef LIGHTING_CIRCULAR
|
||||
dist = cheap_hypotenuse(A.x, A.y, __x, __y)
|
||||
dist = sqrt((A.x - __x)**2 + (A.y - __y)**2)
|
||||
#else
|
||||
dist = max(abs(A.x - __x), abs(A.y - __y))
|
||||
#endif
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
//build affected area list
|
||||
for(var/turf/T in view(range, location))
|
||||
//cull turfs to circle
|
||||
if(cheap_pythag(T.x - location.x, T.y - location.y) <= range)
|
||||
if(sqrt((T.x - location.x)**2 + (T.y - location.y)**2) <= range)
|
||||
targetTurfs += T
|
||||
|
||||
//make secondary list for reagents that affect walls
|
||||
@@ -145,7 +145,7 @@
|
||||
if(istype(A, /obj/effect/effect/smoke/chem)) //skip the item if it is chem smoke
|
||||
continue
|
||||
else if(istype(A, /mob))
|
||||
var/dist = cheap_pythag(T.x - location.x, T.y - location.y)
|
||||
var/dist = sqrt((T.x - location.x)**2 + (T.y - location.y)**2)
|
||||
if(!dist)
|
||||
dist = 1
|
||||
R.reaction_mob(A, volume = R.volume / dist)
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
//TODO: Flash range does nothing currently
|
||||
|
||||
//A very crude linear approximatiaon of pythagoras theorem.
|
||||
/proc/cheap_pythag(var/dx, var/dy)
|
||||
dx = abs(dx); dy = abs(dy);
|
||||
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)
|
||||
|
||||
///// Z-Level Stuff
|
||||
proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1, z_transfer = 1)
|
||||
///// Z-Level Stuff
|
||||
@@ -88,7 +82,7 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
|
||||
var/z0 = epicenter.z
|
||||
|
||||
for(var/turf/T in range(epicenter, max_range))
|
||||
var/dist = cheap_pythag(T.x - x0,T.y - y0)
|
||||
var/dist = sqrt((T.x - x0)**2 + (T.y - y0)**2)
|
||||
|
||||
if(dist < devastation_range) dist = 1
|
||||
else if(dist < heavy_impact_range) dist = 2
|
||||
|
||||
Reference in New Issue
Block a user