mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 19:44:09 +01:00
Merge pull request #4381 from Tastyfish/macros-macros-everywhere
Some math, mob helper, etc one-liner optimizations
This commit is contained in:
@@ -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