forked from Baystation12/Baystation12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmobs.dm
278 lines (222 loc) · 7.31 KB
/
mobs.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
276
277
278
/atom/movable/proc/get_mob()
return
/obj/mecha/get_mob()
return occupant
/obj/vehicle/train/get_mob()
return buckled_mob
/mob/get_mob()
return src
/mob/living/bot/mulebot/get_mob()
if(load && istype(load, /mob/living))
return list(src, load)
return src
//helper for inverting armor blocked values into a multiplier
#define blocked_mult(blocked) max(1 - (blocked/100), 0)
/proc/mobs_in_view(var/range, var/source)
var/list/mobs = list()
for(var/atom/movable/AM in view(range, source))
var/M = AM.get_mob()
if(M)
mobs += M
return mobs
proc/random_hair_style(gender, species = SPECIES_HUMAN)
var/h_style = "Bald"
var/list/valid_hairstyles = list()
for(var/hairstyle in hair_styles_list)
var/datum/sprite_accessory/S = hair_styles_list[hairstyle]
if(gender != NEUTER && gender != PLURAL)
if(gender == MALE && S.gender == FEMALE)
continue
if(gender == FEMALE && S.gender == MALE)
continue
if( !(species in S.species_allowed))
continue
valid_hairstyles[hairstyle] = hair_styles_list[hairstyle]
if(valid_hairstyles.len)
h_style = pick(valid_hairstyles)
return h_style
proc/random_facial_hair_style(gender, species = SPECIES_HUMAN)
var/f_style = "Shaved"
var/list/valid_facialhairstyles = list()
for(var/facialhairstyle in facial_hair_styles_list)
var/datum/sprite_accessory/S = facial_hair_styles_list[facialhairstyle]
if(gender != NEUTER && gender != PLURAL)
if(gender == MALE && S.gender == FEMALE)
continue
if(gender == FEMALE && S.gender == MALE)
continue
if( !(species in S.species_allowed))
continue
valid_facialhairstyles[facialhairstyle] = facial_hair_styles_list[facialhairstyle]
if(valid_facialhairstyles.len)
f_style = pick(valid_facialhairstyles)
return f_style
proc/sanitize_name(name, species = SPECIES_HUMAN)
var/datum/species/current_species
if(species)
current_species = all_species[species]
return current_species ? current_species.sanitize_name(name) : sanitizeName(name)
proc/random_name(gender, species = SPECIES_HUMAN)
var/datum/species/current_species
if(species)
current_species = all_species[species]
if(!current_species)
if(gender==FEMALE)
return capitalize(pick(first_names_female)) + " " + capitalize(pick(last_names))
else
return capitalize(pick(first_names_male)) + " " + capitalize(pick(last_names))
else
return current_species.get_random_name(gender)
proc/random_skin_tone()
switch(pick(60;"caucasian", 15;"afroamerican", 10;"african", 10;"latino", 5;"albino"))
if("caucasian") . = -10
if("afroamerican") . = -115
if("african") . = -165
if("latino") . = -55
if("albino") . = 34
else . = rand(-185,34)
return min(max( .+rand(-25, 25), -185),34)
proc/skintone2racedescription(tone)
switch (tone)
if(30 to INFINITY) return "albino"
if(20 to 30) return "pale"
if(5 to 15) return "light skinned"
if(-10 to 5) return "white"
if(-25 to -10) return "tan"
if(-45 to -25) return "darker skinned"
if(-65 to -45) return "brown"
if(-INFINITY to -65) return "black"
else return "unknown"
proc/age2agedescription(age)
switch(age)
if(0 to 1) return "infant"
if(1 to 3) return "toddler"
if(3 to 13) return "child"
if(13 to 19) return "teenager"
if(19 to 30) return "young adult"
if(30 to 45) return "adult"
if(45 to 60) return "middle-aged"
if(60 to 70) return "aging"
if(70 to INFINITY) return "elderly"
else return "unknown"
/proc/RoundHealth(health)
var/list/icon_states = icon_states('icons/mob/hud_med.dmi')
for(var/icon_state in icon_states)
if(health >= text2num(icon_state))
return icon_state
return icon_states[icon_states.len] // If we had no match, return the last element
//checks whether this item is a module of the robot it is located in.
/proc/is_robot_module(var/obj/item/thing)
if (!thing || !istype(thing.loc, /mob/living/silicon/robot))
return 0
var/mob/living/silicon/robot/R = thing.loc
return (thing in R.module.modules)
/proc/get_exposed_defense_zone(var/atom/movable/target)
var/obj/item/weapon/grab/G = locate() in target
if(G && G.state >= GRAB_NECK) //works because mobs are currently not allowed to upgrade to NECK if they are grabbing two people.
return pick(BP_HEAD, BP_L_HAND, BP_R_HAND, BP_L_FOOT, BP_R_FOOT, BP_L_ARM, BP_R_ARM, BP_L_LEG, BP_R_LEG)
else
return pick(BP_CHEST, BP_GROIN)
/proc/do_mob(mob/user , mob/target, time = 30, target_zone = 0, uninterruptible = 0, progress = 1)
if(!user || !target)
return 0
var/user_loc = user.loc
var/target_loc = target.loc
var/holding = user.get_active_hand()
var/datum/progressbar/progbar
if (progress)
progbar = new(user, time, target)
var/endtime = world.time+time
var/starttime = world.time
. = 1
while (world.time < endtime)
sleep(1)
if (progress)
progbar.update(world.time - starttime)
if(!user || !target)
. = 0
break
if(uninterruptible)
continue
if(!user || user.incapacitated() || user.loc != user_loc)
. = 0
break
if(target.loc != target_loc)
. = 0
break
if(user.get_active_hand() != holding)
. = 0
break
if(target_zone && user.zone_sel.selecting != target_zone)
. = 0
break
if (progbar)
qdel(progbar)
/proc/do_after(mob/user, delay, atom/target = null, needhand = 1, progress = 1, var/incapacitation_flags = INCAPACITATION_DEFAULT)
if(!user)
return 0
var/atom/target_loc = null
var/target_type = null
if(target)
target_loc = target.loc
target_type = target.type
var/atom/original_loc = user.loc
var/holding = user.get_active_hand()
var/datum/progressbar/progbar
if (progress)
progbar = new(user, delay, target)
var/endtime = world.time + delay
var/starttime = world.time
. = 1
while (world.time < endtime)
sleep(1)
if (progress)
progbar.update(world.time - starttime)
if(!user || user.incapacitated(incapacitation_flags) || user.loc != original_loc)
. = 0
break
if(target_loc && (!target || deleted(target) || target_loc != target.loc || target_type != target.type))
. = 0
break
if(needhand)
if(user.get_active_hand() != holding)
. = 0
break
if (progbar)
qdel(progbar)
/proc/able_mobs_in_oview(var/origin)
var/list/mobs = list()
for(var/mob/living/M in oview(origin)) // Only living mobs are considered able.
if(!M.is_physically_disabled())
mobs += M
return mobs
// Returns true if M was not already in the dead mob list
/mob/proc/switch_from_living_to_dead_mob_list()
remove_from_living_mob_list()
. = add_to_dead_mob_list()
// Returns true if M was not already in the living mob list
/mob/proc/switch_from_dead_to_living_mob_list()
remove_from_dead_mob_list()
. = add_to_living_mob_list()
// Returns true if the mob was in neither the dead or living list
/mob/proc/add_to_living_mob_list()
return FALSE
/mob/living/add_to_living_mob_list()
if((src in living_mob_list_) || (src in dead_mob_list_))
return FALSE
living_mob_list_ += src
return TRUE
// Returns true if the mob was removed from the living list
/mob/proc/remove_from_living_mob_list()
return living_mob_list_.Remove(src)
// Returns true if the mob was in neither the dead or living list
/mob/proc/add_to_dead_mob_list()
return FALSE
/mob/living/add_to_dead_mob_list()
if((src in living_mob_list_) || (src in dead_mob_list_))
return FALSE
dead_mob_list_ += src
return TRUE
// Returns true if the mob was removed form the dead list
/mob/proc/remove_from_dead_mob_list()
return dead_mob_list_.Remove(src)