#define Clamp(x, y, z) (x <= y ? y : (x >= z ? z : x)) #define CLAMP01(x) (Clamp(x, 0, 1)) #define get_turf(A) get_step(A,0) #define isAI(A) istype(A, /mob/living/silicon/ai) #define isalien(A) istype(A, /mob/living/carbon/alien) #define isanimal(A) istype(A, /mob/living/simple_animal) #define isairlock(A) istype(A, /obj/machinery/door/airlock) #define isbrain(A) istype(A, /mob/living/carbon/brain) #define iscarbon(A) istype(A, /mob/living/carbon) #define iscorgi(A) istype(A, /mob/living/simple_animal/corgi) #define isEye(A) istype(A, /mob/observer/eye) #define ishuman(A) istype(A, /mob/living/carbon/human) #define isliving(A) istype(A, /mob/living) #define ismouse(A) istype(A, /mob/living/simple_animal/mouse) #define isnewplayer(A) istype(A, /mob/new_player) #define isobserver(A) istype(A, /mob/observer/dead) #define isorgan(A) istype(A, /obj/item/organ/external) #define ispAI(A) istype(A, /mob/living/silicon/pai) #define isrobot(A) istype(A, /mob/living/silicon/robot) #define issilicon(A) istype(A, /mob/living/silicon) #define isvoice(A) istype(A, /mob/living/voice) #define isslime(A) istype(A, /mob/living/simple_animal/slime) #define isbot(A) istype(A, /mob/living/bot) #define isxeno(A) istype(A, /mob/living/simple_animal/xeno) #define isopenspace(A) istype(A, /turf/simulated/open) #define isweakref(A) istype(A, /weakref) #define RANDOM_BLOOD_TYPE pick(4;"O-", 36;"O+", 3;"A-", 28;"A+", 1;"B-", 20;"B+", 1;"AB-", 5;"AB+") #define to_chat(target, message) target << message #define to_world(message) world << message #define to_world_log(message) world.log << message // TODO - Baystation has this log to crazy places. For now lets just world.log, but maybe look into it later. #define log_world(message) world.log << message #define CanInteract(user, state) (CanUseTopic(user, state) == STATUS_INTERACTIVE) #define qdel_null_list(x) if(x) { for(var/y in x) { qdel(y) } ; x = null } #define qdel_null(x) if(x) { qdel(x) ; x = null } #define ARGS_DEBUG log_debug("[__FILE__] - [__LINE__]") ; for(var/arg in args) { log_debug("\t[log_info_line(arg)]") } // Helper macros to aid in optimizing lazy instantiation of lists. // All of these are null-safe, you can use them without knowing if the list var is initialized yet //Picks from the list, with some safeties, and returns the "default" arg if it fails #define DEFAULTPICK(L, default) ((istype(L, /list) && L:len) ? pick(L) : default) // Ensures L is initailized after this point #define LAZYINITLIST(L) if (!L) L = list() // Sets a L back to null iff it is empty #define UNSETEMPTY(L) if (L && !L.len) L = null // Removes I from list L, and sets I to null if it is now empty #define LAZYREMOVE(L, I) if(L) { L -= I; if(!L.len) { L = null; } } // Adds I to L, initalizing I if necessary #define LAZYADD(L, I) if(!L) { L = list(); } L += I; // Reads I from L safely - Works with both associative and traditional lists. #define LAZYACCESS(L, I) (L ? (isnum(I) ? (I > 0 && I <= L.len ? L[I] : null) : L[I]) : null) // Reads the length of L, returning 0 if null #define LAZYLEN(L) length(L) // Null-safe L.Cut() #define LAZYCLEARLIST(L) if(L) L.Cut() // Reads L or an empty list if L is not a list. Note: Does NOT assign, L may be an expression. #define SANITIZE_LIST(L) ( islist(L) ? L : list() )