forked from Baystation12/Baystation12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_macros.dm
147 lines (92 loc) · 5.81 KB
/
_macros.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#define PUBLIC_GAME_MODE (ticker ? (ticker.hide_mode == 0 ? master_mode : "Secret") : "Unknown")
#define Clamp(value, low, high) (value <= low ? low : (value >= high ? high : value))
#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 isatom(A) istype(A, /atom)
#define isbrain(A) istype(A, /mob/living/carbon/brain)
#define iscarbon(A) istype(A, /mob/living/carbon)
#define iscolorablegloves(A) (istype(A, /obj/item/clothing/gloves/color)||istype(A, /obj/item/clothing/gloves/insulated)||istype(A, /obj/item/clothing/gloves/thick))
#define isclient(A) istype(A, /client)
#define iscorgi(A) istype(A, /mob/living/simple_animal/corgi)
#define is_drone(A) istype(A, /mob/living/silicon/robot/drone)
#define isEye(A) istype(A, /mob/observer/eye)
#define ishuman(A) istype(A, /mob/living/carbon/human)
#define isitem(A) istype(A, /obj/item)
#define islist(A) istype(A, /list)
#define isliving(A) istype(A, /mob/living)
#define ismouse(A) istype(A, /mob/living/simple_animal/mouse)
#define ismovable(A) istype(A, /atom/movable)
#define isnewplayer(A) istype(A, /mob/new_player)
#define isobj(A) istype(A, /obj)
#define isghost(A) istype(A, /mob/observer/ghost)
#define isobserver(A) istype(A, /mob/observer)
#define isorgan(A) istype(A, /obj/item/organ/external)
#define isstack(A) istype(A, /obj/item/stack)
#define isspace(A) istype(A, /area/space)
#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 isslime(A) istype(A, /mob/living/carbon/slime)
#define isunderwear(A) istype(A, /obj/item/underwear)
#define isvirtualmob(A) istype(A, /mob/observer/virtual)
#define isweakref(A) istype(A, /weakref)
#define attack_animation(A) if(istype(A)) A.do_attack_animation(src)
#define isairlock(A) istype(A, /obj/machinery/door/airlock)
#define isopenspace(A) istype(A, /turf/simulated/open)
#define sequential_id(key) uniqueness_repository.Generate(/datum/uniqueness_generator/id_sequential, key)
#define random_id(key,min_id,max_id) uniqueness_repository.Generate(/datum/uniqueness_generator/id_random, key, min_id, max_id)
#define to_chat(target, message) target << message
#define to_world(message) world << message
#define to_world_log(message) world.log << message
#define sound_to(target, sound) target << sound
#define to_file(file_entry, source_var) file_entry << source_var
#define from_file(file_entry, target_var) file_entry >> target_var
#define show_browser(target, browser_content, browser_name) target << browse(browser_content, browser_name)
#define show_image(target, image) target << image
#define send_rsc(target, rsc_content, rsc_name) target << browse_rsc(rsc_content, rsc_name)
#define MAP_IMAGE_PATH "nano/images/[GLOB.using_map.path]/"
#define map_image_file_name(z_level) "[GLOB.using_map.path]-[z_level].png"
#define RANDOM_BLOOD_TYPE pick(4;"O-", 36;"O+", 3;"A-", 28;"A+", 1;"B-", 20;"B+", 1;"AB-", 5;"AB+")
#define any2ref(x) "\ref[x]"
#define CanInteract(user, state) (CanUseTopic(user, state) == STATUS_INTERACTIVE)
#define CanInteractWith(user, target, state) (target.CanUseTopic(user, state) == STATUS_INTERACTIVE)
#define CanPhysicallyInteract(user) CanInteract(user, GLOB.physical_state)
#define CanPhysicallyInteractWith(user, target) CanInteractWith(user, target, GLOB.physical_state)
#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 L if necessary
#define LAZYADD(L, I) if(!L) { L = list(); } L += I;
// Adds I to L, initalizing L if necessary, if I is not already in L
#define LAZYDISTINCTADD(L, I) if(!L) { L = list(); } L |= I;
// Sets L[A] to I, initalizing L if necessary
#define LAZYSET(L, A, I) if(!L) { L = list(); } L[A] = 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)
// Safely checks if I is in L
#define LAZYISIN(L, I) (L ? (I in L) : FALSE)
// 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() )
// Insert an object A into a sorted list using cmp_proc (/code/_helpers/cmp.dm) for comparison.
#define ADD_SORTED(list, A, cmp_proc) if(!list.len) {list.Add(A)} else {list.Insert(FindElementIndex(A, list, cmp_proc), A)}
//Currently used in SDQL2 stuff
#define send_output(target, msg, control) target << output(msg, control)
#define send_link(target, url) target << link(url)