-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathis_helpers.dm
275 lines (171 loc) · 10 KB
/
is_helpers.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
// simple is_type and similar inline helpers
#define in_range(source, user) (get_dist(source, user) <= 1 && (get_step(source, 0)?:z) == (get_step(user, 0)?:z))
/// Within given range, but not counting z-levels
#define IN_GIVEN_RANGE(source, other, given_range) (get_dist(source, other) <= given_range && (get_step(source, 0)?:z) == (get_step(other, 0)?:z))
#define isatom(A) (isloc(A))
#define isweakref(D) (istype(D, /datum/weakref))
#define isdatum(thing) (istype(thing, /datum))
#define isappearance(A) (!isnum(A) && copytext("\ref[A]", 4, 6) == "3a")
#define isnan(x) ( isnum((x)) && ((x) != (x)) )
//#define isinternalorgan(A) (istype(A, /obj/item/organ/internal)) uncomment if we port tg organ code
//Turfs
//#define isturf(A) (istype(A, /turf)) This is actually a byond built-in. Added here for completeness sake.
GLOBAL_LIST_INIT(turfs_without_ground, typecacheof(list(
/turf/open/space,
/turf/open/chasm,
/turf/open/lava,
/turf/open/water,
/turf/open/openspace,
/turf/open/space/openspace
)))
#define isgroundlessturf(A) (is_type_in_typecache(A, GLOB.turfs_without_ground))
#define isopenturf(A) (istype(A, /turf/open))
#define isindestructiblefloor(A) (istype(A, /turf/open/indestructible))
#define isspaceturf(A) (istype(A, /turf/open/space))
#define isfloorturf(A) (istype(A, /turf/open/floor))
#define isclosedturf(A) (istype(A, /turf/closed))
#define isindestructiblewall(A) (istype(A, /turf/closed/indestructible))
#define iswallturf(A) (istype(A, /turf/closed/wall))
#define ismineralturf(A) (istype(A, /turf/closed/mineral))
#define islava(A) (istype(A, /turf/open/lava))
#define ischasm(A) (istype(A, /turf/open/chasm))
#define isplatingturf(A) (istype(A, /turf/open/floor/plating))
#define isaicore(A) (istype(A, /obj/machinery/ai/data_core))
#define isvalidAIloc(A) ((isturf(A) || isaicore(A)))
//Mobs
#define isliving(A) (istype(A, /mob/living))
#define isbrain(A) (istype(A, /mob/living/brain))
//Carbon mobs
#define iscarbon(A) (istype(A, /mob/living/carbon))
#define ishuman(A) (istype(A, /mob/living/carbon/human))
//Human sub-species
#define isabductor(A) (is_species(A, /datum/species/abductor))
#define isgolem(A) (is_species(A, /datum/species/golem))
#define islizard(A) (is_species(A, /datum/species/lizard))
#define isplasmaman(A) (is_species(A, /datum/species/plasmaman))
#define ispolysmorph(A) (is_species(A, /datum/species/polysmorph))
#define ispodperson(A) (is_species(A, /datum/species/pod))
#define isflyperson(A) (is_species(A, /datum/species/fly))
#define isjellyperson(A) (is_species(A, /datum/species/jelly))
#define isslimeperson(A) (is_species(A, /datum/species/jelly/slime))
#define isluminescent(A) (is_species(A, /datum/species/jelly/luminescent))
#define iszombie(A) (is_species(A, /datum/species/zombie))
#define IS_INFECTEDzombie(A) (is_species(A, /datum/species/zombie/infectious/gamemode))
#define isspitter(A) (is_species(A, /datum/species/zombie/infectious/gamemode/spitter))
#define isskeleton(A) (is_species(A, /datum/species/skeleton))
#define ismoth(A) (is_species(A, /datum/species/moth))
#define ishumanbasic(A) (is_species(A, /datum/species/human))
#define iscatperson(A) (is_species(A, /datum/species/human/felinid))
#define isethereal(A) (is_species(A, /datum/species/ethereal))
#define isvampire(A) (is_species(A,/datum/species/vampire))
#define ispreternis(A) (is_species(A,/datum/species/preternis))
#define isszlachta(A) (is_species(A, /datum/species/szlachta))
#define isipc(A) (is_species(A, /datum/species/ipc))
#define isinsurgent(A) (is_species(A, /datum/species/ipc/self/insurgent))
#define issnail(A) (is_species(A, /datum/species/snail))
#define isshadowperson(A) (is_species(A, /datum/species/shadow))
#define is_synth(A) (is_species(A,/datum/species/wy_synth))
#define isdummy(A) (istype(A, /mob/living/carbon/human/dummy))
//more carbon mobs
#define ismonkey(A) (istype(A, /mob/living/carbon/monkey))
#define isalien(A) (istype(A, /mob/living/carbon/alien))
#define islarva(A) (istype(A, /mob/living/carbon/alien/larva))
#define isalienadult(A) (istype(A, /mob/living/carbon/alien/humanoid) || istype(A, /mob/living/simple_animal/hostile/alien))
#define isalienhunter(A) (istype(A, /mob/living/carbon/alien/humanoid/hunter))
#define isaliensentinel(A) (istype(A, /mob/living/carbon/alien/humanoid/sentinel))
#define isalienroyal(A) (istype(A, /mob/living/carbon/alien/humanoid/royal))
#define isalienqueen(A) (istype(A, /mob/living/carbon/alien/humanoid/royal/queen))
#define isdevil(A) (istype(A, /mob/living/carbon/true_devil))
//Silicon mobs
#define issilicon(A) (istype(A, /mob/living/silicon))
#define issiliconoradminghost(A) (istype(A, /mob/living/silicon) || IsAdminGhost(A))
#define iscyborg(A) (istype(A, /mob/living/silicon/robot))
#define isAI(A) (istype(A, /mob/living/silicon/ai))
#define isAIShell(A) (istype(A, /mob/living/silicon/robot/shell))
#define ispAI(A) (istype(A, /mob/living/silicon/pai))
//Simple animals
#define isanimal(A) (istype(A, /mob/living/simple_animal))
#define isrevenant(A) (istype(A, /mob/living/simple_animal/revenant))
#define ishorror(A) (istype(A, /mob/living/simple_animal/horror))
#define isbot(A) (istype(A, /mob/living/simple_animal/bot))
#define isshade(A) (istype(A, /mob/living/simple_animal/shade))
#define ismouse(A) (istype(A, /mob/living/simple_animal/mouse))
#define iscow(A) (istype(A, /mob/living/simple_animal/cow))
#define isslime(A) (istype(A, /mob/living/simple_animal/slime))
#define isdrone(A) (istype(A, /mob/living/simple_animal/drone))
#define iscat(A) (istype(A, /mob/living/simple_animal/pet/cat))
#define iscorgi(A) (istype(A, /mob/living/simple_animal/pet/dog/corgi))
#define ishostile(A) (istype(A, /mob/living/simple_animal/hostile))
#define isswarmer(A) (istype(A, /mob/living/simple_animal/hostile/swarmer))
#define isguardian(A) (istype(A, /mob/living/simple_animal/hostile/guardian))
#define isclockmob(A) (istype(A, /mob/living/simple_animal/hostile/clockwork))
#define isconstruct(A) (istype(A, /mob/living/simple_animal/hostile/construct))
#define isfauna(A) (istype(A, /mob/living/simple_animal/hostile/asteroid))
#define ismegafauna(A) (istype(A, /mob/living/simple_animal/hostile/megafauna))
#define isjunglealpha(A) (istype(A, /mob/living/simple_animal/hostile/megafauna))
#define isclown(A) (istype(A, /mob/living/simple_animal/hostile/retaliate/clown))
#define issupplypod(A) (istype(A, /obj/structure/closet/supplypod))
//Misc mobs
#define isobserver(A) (istype(A, /mob/dead/observer))
#define isdead(A) (istype(A, /mob/dead))
#define isnewplayer(A) (istype(A, /mob/dead/new_player))
#define isovermind(A) (istype(A, /mob/camera/blob))
#define iscameramob(A) (istype(A, /mob/camera))
#define isaicamera(A) (istype(A, /mob/camera/ai_eye))
#define iseminence(A) (istype(A, /mob/camera/eminence))
//Objects
#define isobj(A) istype(A, /obj) //override the byond proc because it returns true on children of /atom/movable that aren't objs
#define isitem(A) (istype(A, /obj/item))
#define isstack(A) (istype(A, /obj/item/stack))
#define isidcard(I) (istype(I, /obj/item/card/id))
#define isstructure(A) (istype(A, /obj/structure))
#define ismachinery(A) (istype(A, /obj/machinery))
#define ismecha(A) (istype(A, /obj/mecha))
#define ismopable(A) (A && (A.layer <= FLOOR_CLEAN_LAYER)) //If something can be cleaned by floor-cleaning devices such as mops or clean bots
#define isorgan(A) (istype(A, /obj/item/organ))
#define isclothing(A) (istype(A, /obj/item/clothing))
#define iscash(A) (istype(A, /obj/item/coin) || istype(A, /obj/item/stack/spacecash) || istype(A, /obj/item/holochip))
#define isbodypart(A) (istype(A, /obj/item/bodypart))
#define isprojectile(A) (istype(A, /obj/projectile))
#define isgun(A) (istype(A, /obj/item/gun))
#define is_reagent_container(O) (istype(O, /obj/item/reagent_containers))
//Assemblies
#define isassembly(O) (istype(O, /obj/item/assembly))
#define isigniter(O) (istype(O, /obj/item/assembly/igniter))
#define isprox(O) (istype(O, /obj/item/assembly/prox_sensor))
#define issignaler(O) (istype(O, /obj/item/assembly/signaler))
GLOBAL_LIST_INIT(glass_sheet_types, typecacheof(list(
/obj/item/stack/sheet/glass,
/obj/item/stack/sheet/rglass,
/obj/item/stack/sheet/plasmaglass,
/obj/item/stack/sheet/plasmarglass,
/obj/item/stack/sheet/titaniumglass,
/obj/item/stack/sheet/plastitaniumglass)))
#define is_glass_sheet(O) (is_type_in_typecache(O, GLOB.glass_sheet_types))
#define iseffect(O) (istype(O, /obj/effect))
#define isholoeffect(O) (istype(O, /obj/effect/holodeck_effect))
#define isblobmonster(O) (istype(O, /mob/living/simple_animal/hostile/blob))
#define isshuttleturf(T) (!isnull(T.depth_to_find_baseturf(/turf/baseturf_skipover/shuttle)))
//Fugitive
#define isfugitive(M) (istype(M) && M.mind?.has_antag_datum(/datum/antagonist/fugitive))
#define isProbablyWallMounted(O) (O.pixel_x > 20 || O.pixel_x < -20 || O.pixel_y > 20 || O.pixel_y < -20)
GLOBAL_LIST_INIT(turfs_openspace, typecacheof(list(
/turf/open/openspace,
/turf/open/space/openspace
)))
#define istransparentturf(A) (HAS_TRAIT(A, TURF_Z_TRANSPARENT_TRAIT))
#define isopenspaceturf(A) (is_type_in_typecache(A, GLOB.turfs_openspace))
// Jobs
#define is_job(job_type) (istype(job_type, /datum/job))
#define is_assistant_job(job_type) (istype(job_type, /datum/job/assistant))
#define is_bartender_job(job_type) (istype(job_type, /datum/job/bartender))
#define is_captain_job(job_type) (istype(job_type, /datum/job/captain))
#define is_chaplain_job(job_type) (istype(job_type, /datum/job/chaplain))
#define is_clown_job(job_type) (istype(job_type, /datum/job/clown))
#define is_detective_job(job_type) (istype(job_type, /datum/job/detective))
#define is_scientist_job(job_type) (istype(job_type, /datum/job/scientist))
#define is_security_officer_job(job_type) (istype(job_type, /datum/job/security_officer))
#define is_research_director_job(job_type) (istype(job_type, /datum/job/research_director))
#define is_unassigned_job(job_type) (istype(job_type, /datum/job/unassigned))
#define isprojectilespell(thing) (istype(thing, /datum/action/cooldown/spell/pointed/projectile))
#define is_multi_tile_object(atom) (atom.bound_width > world.icon_size || atom.bound_height > world.icon_size)