mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 20:16:55 +01:00
Merge pull request #4381 from Tastyfish/macros-macros-everywhere
Some math, mob helper, etc one-liner optimizations
This commit is contained in:
+21
-3
@@ -10,6 +10,24 @@
|
||||
#define T20C 293.15 // 20degC
|
||||
#define TCMB 2.7 // -270.3degC
|
||||
|
||||
#define Clamp(x, y, z) (x <= y ? y : (x >= z ? z : x))
|
||||
|
||||
#define CLAMP01(x) (Clamp(x, 0, 1))
|
||||
#define Clamp(x, y, z) ((x) <= (y) ? (y) : ((x) >= (z) ? (z) : (x)))
|
||||
#define CLAMP01(x) (Clamp((x), 0, 1))
|
||||
#define SIMPLE_SIGN(X) ((X) < 0 ? -1 : 1)
|
||||
#define SIGN(X) ((X) ? SIMPLE_SIGN(X) : 0)
|
||||
#define hypotenuse(Ax, Ay, Bx, By) (sqrt(((Ax) - (Bx))**2 + ((Ay) - (By))**2))
|
||||
#define Ceiling(x) (-round(-(x)))
|
||||
#define Tan(x) (sin(x) / cos(x))
|
||||
#define Cot(x) (1 / Tan(x))
|
||||
#define Csc(x) (1 / sin(x))
|
||||
#define Sec(x) (1 / cos(x))
|
||||
#define Floor(x) (round(x))
|
||||
#define Inverse(x) (1 / (x))
|
||||
#define IsEven(x) ((x) % 2 == 0)
|
||||
#define IsOdd(x) ((x) % 2 == 1)
|
||||
#define IsInRange(val, min, max) ((min) <= (val) && (val) <= (max))
|
||||
#define IsInteger(x) (Floor(x) == (x))
|
||||
#define IsMultiple(x, y) ((x) % (y) == 0)
|
||||
#define Lcm(a, b) (abs(a) / Gcd((a), (b)) * abs(b))
|
||||
#define Root(n, x) ((x) ** (1 / (n)))
|
||||
#define ToDegrees(radians) ((radians) * 57.2957795) // 180 / Pi
|
||||
#define ToRadians(degrees) ((degrees) * 0.0174532925) // Pi / 180
|
||||
@@ -142,6 +142,14 @@
|
||||
#define STAGE_FIVE 9
|
||||
#define STAGE_SIX 11 //From supermatter shard
|
||||
|
||||
#define in_range(source, user) (get_dist(source, user) <= 1)
|
||||
|
||||
#define RANGE_TURFS(RADIUS, CENTER) \
|
||||
block( \
|
||||
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
|
||||
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
|
||||
)
|
||||
|
||||
#define FOR_DVIEW(type, range, center, invis_flags) \
|
||||
dview_mob.loc = center; \
|
||||
dview_mob.see_invisible = invis_flags; \
|
||||
|
||||
+36
-1
@@ -97,4 +97,39 @@
|
||||
|
||||
#define CHEM_MOB_SPAWN_INVALID 0
|
||||
#define CHEM_MOB_SPAWN_HOSTILE 1
|
||||
#define CHEM_MOB_SPAWN_FRIENDLY 2
|
||||
#define CHEM_MOB_SPAWN_FRIENDLY 2
|
||||
|
||||
#define isobserver(A) (istype((A), /mob/dead/observer))
|
||||
#define isliving(A) (istype((A), /mob/living))
|
||||
#define isAutoAnnouncer(A) (istype((A), /mob/living/automatedannouncer))
|
||||
|
||||
#define iscarbon(A) (istype((A), /mob/living/carbon))
|
||||
#define ishuman(A) (istype((A), /mob/living/carbon/human))
|
||||
#define isbrain(A) (istype((A), /mob/living/carbon/brain))
|
||||
#define isalien(A) (istype((A), /mob/living/carbon/alien))
|
||||
#define isalienadult(A) (istype((A), /mob/living/carbon/alien/humanoid))
|
||||
#define islarva(A) (istype((A), /mob/living/carbon/alien/larva))
|
||||
#define isslime(A) (istype((A), /mob/living/carbon/slime))
|
||||
|
||||
#define isanimal(A) (istype((A), /mob/living/simple_animal))
|
||||
#define iscorgi(A) (istype((A), /mob/living/simple_animal/pet/corgi))
|
||||
#define ismouse(A) (istype((A), /mob/living/simple_animal/mouse))
|
||||
#define isbot(A) (istype((A), /mob/living/simple_animal/bot))
|
||||
#define isswarmer(A) (istype((A), /mob/living/simple_animal/hostile/swarmer))
|
||||
#define isguardian(A) (istype((A), /mob/living/simple_animal/hostile/guardian))
|
||||
|
||||
#define issilicon(A) (istype((A), /mob/living/silicon))
|
||||
#define isAI(A) (istype((A), /mob/living/silicon/ai))
|
||||
#define isrobot(A) (istype((A), /mob/living/silicon/robot))
|
||||
#define ispAI(A) (istype((A), /mob/living/silicon/pai))
|
||||
|
||||
#define isAIEye(A) (istype((A), /mob/camera/aiEye))
|
||||
#define isovermind(A) (istype((A), /mob/camera/blob))
|
||||
|
||||
#define isSpirit(A) (istype((A), /mob/spirit))
|
||||
#define ismask(A) (istype((A), /mob/spirit/mask))
|
||||
|
||||
#define isorgan(A) (istype((A), /obj/item/organ/external))
|
||||
#define hasorgans(A) (ishuman(A))
|
||||
|
||||
#define is_admin(user) (check_rights(R_ADMIN, 0, (user)) != 0)
|
||||
+27
-55
@@ -1,10 +1,3 @@
|
||||
//supposedly the fastest way to do this according to https://gist.github.com/Giacom/be635398926bb463b42a
|
||||
#define RANGE_TURFS(RADIUS, CENTER) \
|
||||
block( \
|
||||
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
|
||||
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
|
||||
)
|
||||
|
||||
/proc/dopage(src,target)
|
||||
var/href_list
|
||||
var/href
|
||||
@@ -46,13 +39,6 @@
|
||||
areas |= T.loc
|
||||
return areas
|
||||
|
||||
|
||||
/proc/in_range(source, user)
|
||||
if(get_dist(source, user) <= 1)
|
||||
return 1
|
||||
|
||||
return 0 //not in range and not telekinetic
|
||||
|
||||
// Like view but bypasses luminosity check
|
||||
|
||||
/proc/hear(var/range, var/atom/source)
|
||||
@@ -65,11 +51,6 @@
|
||||
|
||||
return heard
|
||||
|
||||
//We used to use linear regression to approximate the answer, but Mloc realized this was actually faster.
|
||||
//And lo and behold, it is, and it's more accurate to boot.
|
||||
/proc/cheap_hypotenuse(Ax,Ay,Bx,By)
|
||||
return sqrt(abs(Ax - Bx)**2 + abs(Ay - By)**2) //A squared + B squared = C squared
|
||||
|
||||
/proc/circlerange(center=usr,radius=3)
|
||||
|
||||
var/turf/centerturf = get_turf(center)
|
||||
@@ -233,53 +214,44 @@
|
||||
. |= M // Since we're already looping through mobs, why bother using |= ? This only slows things down.
|
||||
return .
|
||||
|
||||
|
||||
#define SIGN(X) ((X<0)?-1:1)
|
||||
|
||||
proc
|
||||
inLineOfSight(X1,Y1,X2,Y2,Z=1,PX1=16.5,PY1=16.5,PX2=16.5,PY2=16.5)
|
||||
var/turf/T
|
||||
if(X1==X2)
|
||||
if(Y1==Y2)
|
||||
return 1 //Light cannot be blocked on same tile
|
||||
else
|
||||
var/s = SIGN(Y2-Y1)
|
||||
Y1+=s
|
||||
while(Y1!=Y2)
|
||||
T=locate(X1,Y1,Z)
|
||||
if(T.opacity)
|
||||
return 0
|
||||
Y1+=s
|
||||
/proc/inLineOfSight(X1,Y1,X2,Y2,Z=1,PX1=16.5,PY1=16.5,PX2=16.5,PY2=16.5)
|
||||
var/turf/T
|
||||
if(X1==X2)
|
||||
if(Y1==Y2)
|
||||
return 1 //Light cannot be blocked on same tile
|
||||
else
|
||||
var/m=(32*(Y2-Y1)+(PY2-PY1))/(32*(X2-X1)+(PX2-PX1))
|
||||
var/b=(Y1+PY1/32-0.015625)-m*(X1+PX1/32-0.015625) //In tiles
|
||||
var/signX = SIGN(X2-X1)
|
||||
var/signY = SIGN(Y2-Y1)
|
||||
if(X1<X2)
|
||||
b+=m
|
||||
while(X1!=X2 || Y1!=Y2)
|
||||
if(round(m*X1+b-Y1))
|
||||
Y1+=signY //Line exits tile vertically
|
||||
else
|
||||
X1+=signX //Line exits tile horizontally
|
||||
var/s = SIMPLE_SIGN(Y2-Y1)
|
||||
Y1+=s
|
||||
while(Y1!=Y2)
|
||||
T=locate(X1,Y1,Z)
|
||||
if(T.opacity)
|
||||
return 0
|
||||
return 1
|
||||
#undef SIGN
|
||||
Y1+=s
|
||||
else
|
||||
var/m=(32*(Y2-Y1)+(PY2-PY1))/(32*(X2-X1)+(PX2-PX1))
|
||||
var/b=(Y1+PY1/32-0.015625)-m*(X1+PX1/32-0.015625) //In tiles
|
||||
var/signX = SIMPLE_SIGN(X2-X1)
|
||||
var/signY = SIMPLE_SIGN(Y2-Y1)
|
||||
if(X1<X2)
|
||||
b+=m
|
||||
while(X1!=X2 || Y1!=Y2)
|
||||
if(round(m*X1+b-Y1))
|
||||
Y1+=signY //Line exits tile vertically
|
||||
else
|
||||
X1+=signX //Line exits tile horizontally
|
||||
T=locate(X1,Y1,Z)
|
||||
if(T.opacity)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
proc/isInSight(var/atom/A, var/atom/B)
|
||||
/proc/isInSight(var/atom/A, var/atom/B)
|
||||
var/turf/Aturf = get_turf(A)
|
||||
var/turf/Bturf = get_turf(B)
|
||||
|
||||
if(!Aturf || !Bturf)
|
||||
return 0
|
||||
|
||||
if(inLineOfSight(Aturf.x,Aturf.y, Bturf.x,Bturf.y,Aturf.z))
|
||||
return 1
|
||||
|
||||
else
|
||||
return 0
|
||||
return inLineOfSight(Aturf.x, Aturf.y, Bturf.x, Bturf.y, Aturf.z)
|
||||
|
||||
/proc/get_cardinal_step_away(atom/start, atom/finish) //returns the position of a step from start away from finish, in one of the cardinal directions
|
||||
//returns only NORTH, SOUTH, EAST, or WEST
|
||||
|
||||
@@ -3,70 +3,18 @@
|
||||
var/const/E = 2.71828183
|
||||
var/const/Sqrt2 = 1.41421356
|
||||
|
||||
// List of square roots for the numbers 1-100.
|
||||
var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10)
|
||||
|
||||
/proc/Atan2(x, y)
|
||||
if(!x && !y) return 0
|
||||
var/a = arccos(x / sqrt(x*x + y*y))
|
||||
return y >= 0 ? a : -a
|
||||
|
||||
/proc/Ceiling(x)
|
||||
return -round(-x)
|
||||
|
||||
//Replaced in /code/__DEFINES/math.dm because holy shit man a define is faster.
|
||||
/*
|
||||
/proc/Clamp(val, min, max)
|
||||
return max(min, min(val, max))
|
||||
*/
|
||||
|
||||
// cotangent
|
||||
/proc/Cot(x)
|
||||
return 1 / Tan(x)
|
||||
|
||||
// cosecant
|
||||
/proc/Csc(x)
|
||||
return 1 / sin(x)
|
||||
|
||||
/proc/Default(a, b)
|
||||
return a ? a : b
|
||||
|
||||
/proc/Floor(x)
|
||||
return round(x)
|
||||
|
||||
// Greatest Common Divisor - Euclid's algorithm
|
||||
/proc/Gcd(a, b)
|
||||
return b ? Gcd(b, a % b) : a
|
||||
|
||||
/proc/Inverse(x)
|
||||
return 1 / x
|
||||
|
||||
/proc/IsAboutEqual(a, b, deviation = 0.1)
|
||||
return abs(a - b) <= deviation
|
||||
|
||||
/proc/IsEven(x)
|
||||
return x % 2 == 0
|
||||
|
||||
// Returns true if val is from min to max, inclusive.
|
||||
/proc/IsInRange(val, min, max)
|
||||
return min <= val && val <= max
|
||||
|
||||
/proc/IsInteger(x)
|
||||
return Floor(x) == x
|
||||
|
||||
/proc/IsOdd(x)
|
||||
return !IsEven(x)
|
||||
|
||||
/proc/IsMultiple(x, y)
|
||||
return x % y == 0
|
||||
|
||||
// Least Common Multiple
|
||||
/proc/Lcm(a, b)
|
||||
return abs(a) / Gcd(a, b) * abs(b)
|
||||
|
||||
// Performs a linear interpolation between a and b.
|
||||
// Note that amount=0 returns a, amount=1 returns b, and
|
||||
// amount=0.5 returns the mean of a and b.
|
||||
@@ -81,15 +29,6 @@ var/list/sqrtTable = list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
|
||||
sum += val
|
||||
return sum / values
|
||||
|
||||
|
||||
// Returns the nth root of x.
|
||||
/proc/Root(n, x)
|
||||
return x ** (1 / n)
|
||||
|
||||
// secant
|
||||
/proc/Sec(x)
|
||||
return 1 / cos(x)
|
||||
|
||||
// The quadratic formula. Returns a list with the solutions, or an empty list
|
||||
// if they are imaginary.
|
||||
/proc/SolveQuadratic(a, b, c)
|
||||
@@ -103,18 +42,6 @@ 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
|
||||
. += (-b - root) / bottom
|
||||
|
||||
// tangent
|
||||
/proc/Tan(x)
|
||||
return sin(x) / cos(x)
|
||||
|
||||
/proc/ToDegrees(radians)
|
||||
// 180 / Pi
|
||||
return radians * 57.2957795
|
||||
|
||||
/proc/ToRadians(degrees)
|
||||
// Pi / 180
|
||||
return degrees * 0.0174532925
|
||||
|
||||
// Will filter out extra rotations and negative rotations
|
||||
// E.g: 540 becomes 180. -180 becomes 180.
|
||||
/proc/SimplifyDegrees(degrees)
|
||||
|
||||
@@ -185,9 +185,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/proc/sign(x)
|
||||
return x!=0?x/abs(x):0
|
||||
|
||||
/proc/getline(atom/M,atom/N)//Ultra-Fast Bresenham Line-Drawing Algorithm
|
||||
var/px=M.x //starting x
|
||||
var/py=M.y
|
||||
@@ -196,8 +193,8 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
var/dy=N.y-py
|
||||
var/dxabs=abs(dx)//Absolute value of x distance
|
||||
var/dyabs=abs(dy)
|
||||
var/sdx=sign(dx) //Sign of x distance (+ or -)
|
||||
var/sdy=sign(dy)
|
||||
var/sdx=SIGN(dx) //Sign of x distance (+ or -)
|
||||
var/sdy=SIGN(dy)
|
||||
var/x=dxabs>>1 //Counters for steps taken, setting to distance/2
|
||||
var/y=dyabs>>1 //Bit-shifting makes me l33t. It also makes getline() unnessecarrily fast.
|
||||
var/j //Generic integer for counting
|
||||
|
||||
@@ -355,16 +355,11 @@ var/global/datum/controller/processScheduler/processScheduler
|
||||
/datum/controller/processScheduler/proc/updateTimeAllowance()
|
||||
// Time allowance goes down linearly with world.cpu.
|
||||
var/tmp/error = cpuAverage - 100
|
||||
var/tmp/timeAllowanceDelta = sign(error) * -0.5 * world.tick_lag * max(0, 0.001 * abs(error))
|
||||
var/tmp/timeAllowanceDelta = SIMPLE_SIGN(error) * -0.5 * world.tick_lag * max(0, 0.001 * abs(error))
|
||||
|
||||
//timeAllowance = world.tick_lag * min(1, 0.5 * ((200/max(1,cpuAverage)) - 1))
|
||||
timeAllowance = min(timeAllowanceMax, max(0, timeAllowance + timeAllowanceDelta))
|
||||
|
||||
/datum/controller/processScheduler/proc/sign(var/x)
|
||||
if (x == 0)
|
||||
return 1
|
||||
return x / abs(x)
|
||||
|
||||
/datum/controller/processScheduler/proc/statProcesses()
|
||||
if(!isRunning)
|
||||
stat("Processes", "Scheduler not running")
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
var/turf/T = A
|
||||
if(!T)
|
||||
continue
|
||||
var/dist = cheap_hypotenuse(T.x, T.y, x0, y0)
|
||||
var/dist = hypotenuse(T.x, T.y, x0, y0)
|
||||
|
||||
if(config.reactionary_explosions)
|
||||
var/turf/Trajectory = T
|
||||
@@ -206,7 +206,7 @@
|
||||
var/list/wipe_colours = list()
|
||||
for(var/turf/T in spiral_range_turfs(max_range, epicenter))
|
||||
wipe_colours += T
|
||||
var/dist = cheap_hypotenuse(T.x, T.y, x0, y0)
|
||||
var/dist = hypotenuse(T.x, T.y, x0, y0)
|
||||
|
||||
if(newmode == "Yes")
|
||||
var/turf/TT = T
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
|
||||
// fun if you want to typecast humans/monkeys/etc without writing long path-filled lines.
|
||||
/proc/ishuman(A)
|
||||
if(istype(A, /mob/living/carbon/human))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/issmall(A)
|
||||
if(A && istype(A, /mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/H = A
|
||||
@@ -12,56 +5,6 @@
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isbrain(A)
|
||||
if(A && istype(A, /mob/living/carbon/brain))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isalien(A)
|
||||
if(istype(A, /mob/living/carbon/alien))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isalienadult(A)
|
||||
if(istype(A, /mob/living/carbon/alien/humanoid))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/islarva(A)
|
||||
if(istype(A, /mob/living/carbon/alien/larva))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
proc/isfacehugger(A)
|
||||
if(istype(A, /obj/item/clothing/mask/facehugger))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
proc/isembryo(A)
|
||||
if(istype(A, /obj/item/organ/internal/body_egg/alien_embryo))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isslime(A)
|
||||
if(istype(A, /mob/living/carbon/slime))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isrobot(A)
|
||||
if(istype(A, /mob/living/silicon/robot))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isanimal(A)
|
||||
if(istype(A, /mob/living/simple_animal))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/iscorgi(A)
|
||||
if(istype(A, /mob/living/simple_animal/pet/corgi))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/ispet(A)
|
||||
if(istype(A, /mob/living/simple_animal))
|
||||
var/mob/living/simple_animal/SA = A
|
||||
@@ -69,46 +12,6 @@ proc/isembryo(A)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/iscrab(A)
|
||||
if(istype(A, /mob/living/simple_animal/crab))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/iscat(A)
|
||||
if(istype(A, /mob/living/simple_animal/pet/cat))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/ismouse(A)
|
||||
if(istype(A, /mob/living/simple_animal/mouse))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isbear(A)
|
||||
if(istype(A, /mob/living/simple_animal/hostile/bear))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/iscarp(A)
|
||||
if(istype(A, /mob/living/simple_animal/hostile/carp))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isbot(A)
|
||||
if(istype(A, /mob/living/simple_animal/bot))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isclown(A)
|
||||
if(istype(A, /mob/living/simple_animal/hostile/retaliate/clown))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isAI(A)
|
||||
if(istype(A, /mob/living/silicon/ai))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/mob/proc/isSynthetic()
|
||||
return 0
|
||||
|
||||
@@ -119,76 +22,6 @@ proc/isembryo(A)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/proc/isAIEye(A)
|
||||
if(istype(A, /mob/camera/aiEye))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/ispAI(A)
|
||||
if(istype(A, /mob/living/silicon/pai))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/iscarbon(A)
|
||||
if(istype(A, /mob/living/carbon))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/issilicon(A)
|
||||
if(istype(A, /mob/living/silicon))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isSilicon(A) // Bay support
|
||||
if(istype(A, /mob/living/silicon))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isliving(A)
|
||||
if(istype(A, /mob/living))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isswarmer(A)
|
||||
if(istype(A, /mob/living/simple_animal/hostile/swarmer))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isguardian(A)
|
||||
if(istype(A, /mob/living/simple_animal/hostile/guardian))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isobserver(A)
|
||||
if(istype(A, /mob/dead/observer))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isSpirit(A)
|
||||
if(istype(A, /mob/spirit))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
proc/isovermind(A)
|
||||
if(istype(A, /mob/camera/blob))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/ismask(A)
|
||||
if(istype(A, /mob/spirit/mask))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isAutoAnnouncer(A)
|
||||
if(istype(A, /mob/living/automatedannouncer))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isorgan(A)
|
||||
if(istype(A, /obj/item/organ/external))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/isloyal(A) //Checks to see if the person contains a loyalty implant, then checks that the implant is actually inside of them
|
||||
for(var/obj/item/weapon/implant/loyalty/L in A)
|
||||
if(L && L.implanted)
|
||||
@@ -220,14 +53,6 @@ proc/isNonCrewAntag(A)
|
||||
|
||||
return 1
|
||||
|
||||
proc/isnewplayer(A)
|
||||
if(istype(A, /mob/new_player))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
proc/hasorgans(A)
|
||||
return ishuman(A)
|
||||
|
||||
proc/iscuffed(A)
|
||||
if(istype(A, /mob/living/carbon))
|
||||
var/mob/living/carbon/C = A
|
||||
@@ -255,10 +80,6 @@ proc/getsensorlevel(A)
|
||||
return U.sensor_mode
|
||||
return SUIT_SENSOR_OFF
|
||||
|
||||
/proc/is_admin(var/mob/user)
|
||||
return check_rights(R_ADMIN, 0, user) != 0
|
||||
|
||||
|
||||
/proc/check_zone(zone)
|
||||
if(!zone) return "chest"
|
||||
switch(zone)
|
||||
@@ -537,8 +358,7 @@ var/list/intents = list(I_HELP,I_DISARM,I_GRAB,I_HARM)
|
||||
return P
|
||||
|
||||
/proc/get_both_hands(mob/living/carbon/M)
|
||||
var/list/hands = list(M.l_hand, M.r_hand)
|
||||
return hands
|
||||
return list(M.l_hand, M.r_hand)
|
||||
|
||||
|
||||
//Direct dead say used both by emote and say
|
||||
|
||||
@@ -199,27 +199,27 @@
|
||||
interpreter.SetProc("tostring", /proc/n_num2str)
|
||||
interpreter.SetProc("sqrt", /proc/n_sqrt)
|
||||
interpreter.SetProc("abs", /proc/n_abs)
|
||||
interpreter.SetProc("floor", /proc/Floor)
|
||||
interpreter.SetProc("ceil", /proc/Ceiling)
|
||||
interpreter.SetProc("floor", /proc/n_floor)
|
||||
interpreter.SetProc("ceil", /proc/n_ceiling)
|
||||
interpreter.SetProc("round", /proc/n_round)
|
||||
interpreter.SetProc("clamp", /proc/n_clamp)
|
||||
interpreter.SetProc("inrange", /proc/IsInRange)
|
||||
interpreter.SetProc("inrange", /proc/n_isInRange)
|
||||
interpreter.SetProc("rand", /proc/rand_chance)
|
||||
interpreter.SetProc("arctan", /proc/Atan2)
|
||||
interpreter.SetProc("lcm", /proc/Lcm)
|
||||
interpreter.SetProc("lcm", /proc/n_lcm)
|
||||
interpreter.SetProc("gcd", /proc/Gcd)
|
||||
interpreter.SetProc("mean", /proc/Mean)
|
||||
interpreter.SetProc("root", /proc/Root)
|
||||
interpreter.SetProc("root", /proc/n_root)
|
||||
interpreter.SetProc("sin", /proc/n_sin)
|
||||
interpreter.SetProc("cos", /proc/n_cos)
|
||||
interpreter.SetProc("arcsin", /proc/n_asin)
|
||||
interpreter.SetProc("arccos", /proc/n_acos)
|
||||
interpreter.SetProc("tan", /proc/Tan)
|
||||
interpreter.SetProc("csc", /proc/Csc)
|
||||
interpreter.SetProc("cot", /proc/Cot)
|
||||
interpreter.SetProc("sec", /proc/Sec)
|
||||
interpreter.SetProc("todegrees", /proc/ToDegrees)
|
||||
interpreter.SetProc("toradians", /proc/ToRadians)
|
||||
interpreter.SetProc("tan", /proc/n_tan)
|
||||
interpreter.SetProc("csc", /proc/n_csc)
|
||||
interpreter.SetProc("cot", /proc/n_cot)
|
||||
interpreter.SetProc("sec", /proc/n_sec)
|
||||
interpreter.SetProc("todegrees", /proc/n_toDegrees)
|
||||
interpreter.SetProc("toradians", /proc/n_toRadians)
|
||||
interpreter.SetProc("lerp", /proc/Lerp)
|
||||
interpreter.SetProc("max", /proc/n_max)
|
||||
interpreter.SetProc("min", /proc/n_min)
|
||||
|
||||
@@ -221,13 +221,13 @@ proc/n_abs(var/num)
|
||||
proc/n_floor(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_floor() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
return round(num)
|
||||
return Floor(num)
|
||||
|
||||
// Round up
|
||||
proc/n_ceil(var/num)
|
||||
proc/n_ceiling(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_ceil() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
return round(num)+1
|
||||
return Ceiling(num)
|
||||
|
||||
// Round to nearest integer
|
||||
proc/n_round(var/num)
|
||||
@@ -235,22 +235,61 @@ proc/n_round(var/num)
|
||||
if(isnum(num))
|
||||
if(num-round(num)<0.5)
|
||||
return round(num)
|
||||
return n_ceil(num)\
|
||||
return Ceiling(num)
|
||||
|
||||
// END OF BY DONKIE :(
|
||||
|
||||
/proc/n_sin(var/const/x)
|
||||
return sin(x)
|
||||
if(isnum(x))
|
||||
return sin(x)
|
||||
|
||||
/proc/n_cos(var/const/x)
|
||||
return cos(x)
|
||||
if(isnum(x))
|
||||
return cos(x)
|
||||
|
||||
/proc/n_tan(var/const/x)
|
||||
if(isnum(x))
|
||||
return Tan(x)
|
||||
|
||||
/proc/n_csc(var/const/x)
|
||||
if(isnum(x))
|
||||
return Csc(x)
|
||||
|
||||
/proc/n_cot(var/const/x)
|
||||
if(isnum(x))
|
||||
return Cot(x)
|
||||
|
||||
/proc/n_sec(var/const/x)
|
||||
if(isnum(x))
|
||||
return Sec(x)
|
||||
|
||||
/proc/n_asin(var/const/x)
|
||||
return arcsin(x)
|
||||
if(isnum(x))
|
||||
return arcsin(x)
|
||||
|
||||
/proc/n_acos(var/const/x)
|
||||
return arccos(x)
|
||||
if(isnum(x))
|
||||
return arccos(x)
|
||||
|
||||
/proc/n_isInRange(var/const/x, var/const/min, var/const/max)
|
||||
if(isnum(x) && isnum(min) && isnum(max))
|
||||
return IsInRange(x, min, max)
|
||||
|
||||
/proc/n_lcm(var/const/a, var/const/b)
|
||||
if(isnum(a) && isnum(b))
|
||||
return Lcm(a, b)
|
||||
|
||||
/proc/n_root(var/const/n, var/const/x)
|
||||
if(isnum(n) && isnum(x))
|
||||
return Root(n, x)
|
||||
|
||||
/proc/n_toDegrees(var/const/x)
|
||||
if(isnum(x))
|
||||
return ToDegrees(x)
|
||||
|
||||
/proc/n_toRadians(var/const/x)
|
||||
if(isnum(x))
|
||||
return ToRadians(x)
|
||||
|
||||
/proc/n_max(...)
|
||||
return max(arglist(args))
|
||||
|
||||
Reference in New Issue
Block a user