-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathinventory.dm
433 lines (396 loc) · 13.5 KB
/
inventory.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
/mob/living/carbon/human/can_equip(obj/item/I, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE)
return dna.species.can_equip(I, slot, disable_warning, src, bypass_equip_delay_self)
// Return the item currently in the slot ID
/mob/living/carbon/human/get_item_by_slot(slot_id)
switch(slot_id)
if(ITEM_SLOT_BELT)
return belt
if(ITEM_SLOT_ID)
return wear_id
if(ITEM_SLOT_EARS)
return ears
if(ITEM_SLOT_EYES)
return glasses
if(ITEM_SLOT_GLOVES)
return gloves
if(ITEM_SLOT_FEET)
return shoes
if(ITEM_SLOT_OCLOTHING)
return wear_suit
if(ITEM_SLOT_ICLOTHING)
return w_uniform
if(ITEM_SLOT_LPOCKET)
return l_store
if(ITEM_SLOT_RPOCKET)
return r_store
if(ITEM_SLOT_SUITSTORE)
return s_store
return ..()
/mob/living/carbon/human/get_slot_by_item(obj/item/looking_for)
if(looking_for == belt)
return ITEM_SLOT_BELT
if(looking_for == wear_id)
return ITEM_SLOT_ID
if(looking_for == ears)
return ITEM_SLOT_EARS
if(looking_for == glasses)
return ITEM_SLOT_EYES
if(looking_for == gloves)
return ITEM_SLOT_GLOVES
if(looking_for == head)
return ITEM_SLOT_HEAD
if(looking_for == shoes)
return ITEM_SLOT_FEET
if(looking_for == wear_suit)
return ITEM_SLOT_OCLOTHING
if(looking_for == w_uniform)
return ITEM_SLOT_ICLOTHING
if(looking_for == r_store)
return ITEM_SLOT_RPOCKET
if(looking_for == l_store)
return ITEM_SLOT_LPOCKET
if(looking_for == s_store)
return ITEM_SLOT_SUITSTORE
return ..()
/mob/living/carbon/human/proc/get_all_slots()
. = get_head_slots() | get_body_slots()
/mob/living/carbon/human/proc/get_body_slots()
return list(
back,
s_store,
handcuffed,
legcuffed,
wear_suit,
gloves,
shoes,
belt,
wear_id,
l_store,
r_store,
w_uniform
)
/mob/living/carbon/human/proc/get_head_slots()
return list(
head,
wear_mask,
wear_neck,
glasses,
ears,
)
/mob/living/carbon/human/proc/get_storage_slots()
return list(
back,
belt,
l_store,
r_store,
s_store,
)
//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()
// Initial is used to indicate whether or not this is the initial equipment (job datums etc) or just a player doing it
/mob/living/carbon/human/equip_to_slot(obj/item/I, slot, initial = FALSE)
if(!..()) //a check failed or the item has already found its slot
return
var/not_handled = FALSE //Added in case we make this type path deeper one day
switch(slot)
if(ITEM_SLOT_BELT)
belt = I
update_inv_belt()
if(ITEM_SLOT_ID)
wear_id = I
sec_hud_set_ID()
update_inv_wear_id()
if(ITEM_SLOT_EARS)
ears = I
update_inv_ears()
if(ITEM_SLOT_EYES)
glasses = I
var/obj/item/clothing/glasses/G = I
if(G.glass_colour_type)
update_glasses_color(G, 1)
if(G.tint)
update_tint()
if(G.vision_correction)
clear_fullscreen("nearsighted")
clear_fullscreen("eye_damage")
if(G.vision_flags || G.invis_override || G.invis_view || !isnull(G.lighting_cutoff))
update_sight()
update_inv_glasses()
if(ITEM_SLOT_GLOVES)
gloves = I
update_inv_gloves()
if(ITEM_SLOT_FEET)
shoes = I
update_inv_shoes()
if(ITEM_SLOT_OCLOTHING)
wear_suit = I
if(I.flags_inv & HIDEJUMPSUIT)
update_inv_w_uniform()
if(wear_suit.breakouttime) //when equipping a straightjacket
stop_pulling() //can't pull if restrained
update_mob_action_buttons() //certain action buttons will no longer be usable.
update_inv_wear_suit()
if(ITEM_SLOT_ICLOTHING)
w_uniform = I
update_suit_sensors()
update_inv_w_uniform()
if(ITEM_SLOT_LPOCKET)
l_store = I
update_inv_pockets()
if(ITEM_SLOT_RPOCKET)
r_store = I
update_inv_pockets()
if(ITEM_SLOT_SUITSTORE)
s_store = I
update_inv_s_store()
else
to_chat(src, span_danger("You are trying to equip this item to an unsupported inventory slot. Report this to a coder!"))
//Item is handled and in slot, valid to call callback, for this proc should always be true
if(!not_handled)
I.equipped(src, slot, initial)
// Send a signal for when we equip an item that used to cover our feet/shoes. Used for bloody feet
if((I.body_parts_covered & FEET) || (I.flags_inv | I.transparent_protection) & HIDESHOES)
SEND_SIGNAL(src, COMSIG_CARBON_EQUIP_SHOECOVER, I, slot, initial)
return not_handled //For future deeper overrides
/mob/living/carbon/human/doUnEquip(obj/item/I, force, newloc, no_move, invdrop = TRUE, silent = FALSE)
var/index = get_held_index_of_item(I)
. = ..() //See mob.dm for an explanation on this and some rage about people copypasting instead of calling ..() like they should.
if(!. || !I)
return
if(index && !QDELETED(src) && dna.species.mutanthands) //hand freed, fill with claws, skip if we're getting deleted.
put_in_hand(new dna.species.mutanthands(), index)
if(I == wear_suit)
if(s_store && invdrop)
dropItemToGround(s_store, TRUE) //It makes no sense for your suit storage to stay on you if you drop your suit.
if(wear_suit.breakouttime) //when unequipping a straightjacket
drop_all_held_items() //suit is restraining
update_mob_action_buttons() //certain action buttons may be usable again.
wear_suit = null
if(!QDELETED(src)) //no need to update we're getting deleted anyway
if(I.flags_inv & HIDEJUMPSUIT)
update_inv_w_uniform()
update_inv_wear_suit()
else if(I == w_uniform)
w_uniform = null
update_suit_sensors()
if(!QDELETED(src))
update_inv_w_uniform()
if(invdrop)
if(r_store && !can_equip(r_store, ITEM_SLOT_RPOCKET, TRUE))
dropItemToGround(r_store, TRUE) //Again, makes sense for pockets to drop.
if(l_store && !can_equip(l_store, ITEM_SLOT_LPOCKET, TRUE))
dropItemToGround(l_store, TRUE)
if(wear_id && !can_equip(wear_id, ITEM_SLOT_ID, TRUE))
dropItemToGround(wear_id)
if(belt && !can_equip(belt, ITEM_SLOT_BELT, TRUE))
dropItemToGround(belt)
else if(I == gloves)
gloves = null
if(!QDELETED(src))
update_inv_gloves()
else if(I == glasses)
glasses = null
var/obj/item/clothing/glasses/G = I
if(G.glass_colour_type)
update_glasses_color(G, 0)
if(G.tint)
update_tint()
if(G.vision_correction)
if(HAS_TRAIT(src, TRAIT_NEARSIGHT))
overlay_fullscreen("nearsighted", /atom/movable/screen/fullscreen/impaired, 1)
if(G.vision_flags || G.invis_override || G.invis_view || !isnull(G.lighting_cutoff))
update_sight()
if(!QDELETED(src))
update_inv_glasses()
else if(I == ears)
ears = null
if(!QDELETED(src))
update_inv_ears()
else if(I == shoes)
shoes = null
if(!QDELETED(src))
update_inv_shoes()
else if(I == belt)
belt = null
if(!QDELETED(src))
update_inv_belt()
else if(I == wear_id)
wear_id = null
sec_hud_set_ID()
if(!QDELETED(src))
update_inv_wear_id()
else if(I == r_store)
r_store = null
if(!QDELETED(src))
update_inv_pockets()
else if(I == l_store)
l_store = null
if(!QDELETED(src))
update_inv_pockets()
else if(I == s_store)
s_store = null
if(!QDELETED(src))
update_inv_s_store()
// Send a signal for when we unequip an item that used to cover our feet/shoes. Used for bloody feet
if((I.body_parts_covered & FEET) || (I.flags_inv | I.transparent_protection) & HIDESHOES)
SEND_SIGNAL(src, COMSIG_CARBON_UNEQUIP_SHOECOVER, I, force, newloc, no_move, invdrop, silent)
/mob/living/carbon/human/toggle_internals(obj/item/tank, is_external = FALSE)
// Just close the tank if it's the one the mob already has open.
var/obj/item/existing_tank = is_external ? external : internal
if(tank == existing_tank)
return toggle_close_internals(is_external)
// Use breathing tube regardless of mask.
if(can_breathe_tube())
return toggle_open_internals(tank, is_external)
// Use mask in absence of tube.
if(isclothing(wear_mask) && ((wear_mask.visor_flags & MASKINTERNALS) || (wear_mask.clothing_flags & MASKINTERNALS)))
// Adjust dishevelled breathing mask back onto face.
if (wear_mask.mask_adjusted)
wear_mask.adjustmask(src)
return toggle_open_internals(tank, is_external)
// Use helmet in absence of tube or valid mask.
if(can_breathe_helmet())
return toggle_open_internals(tank, is_external)
// Notify user of missing valid breathing apparatus.
if (wear_mask)
// Invalid mask
to_chat(src, span_warning("[wear_mask] can't use [tank]!"))
else if (head)
// Invalid headgear
to_chat(src, span_warning("[head] isn't airtight! You need a mask!"))
else
// Not wearing any breathing apparatus.
to_chat(src, span_warning("You need a mask!"))
/// Returns TRUE if the tank successfully toggles open/closed. Opens the tank only if a breathing apparatus is found.
/mob/living/carbon/human/toggle_externals(obj/item/tank)
return toggle_internals(tank, TRUE)
/mob/living/carbon/human/wear_mask_update(obj/item/I, toggle_off = 1)
if((I.flags_inv & (HIDEHAIR|HIDEFACIALHAIR)) || (initial(I.flags_inv) & (HIDEHAIR|HIDEFACIALHAIR)))
update_hair()
// Close internal air tank if mask was the only breathing apparatus.
if(invalid_internals())
cutoff_internals()
if(I.flags_inv & HIDEEYES)
update_inv_glasses()
sec_hud_set_security_status()
..()
/mob/living/carbon/human/head_update(obj/item/I, forced)
if((I.flags_inv & (HIDEHAIR|HIDEFACIALHAIR)) || forced)
update_hair()
else
var/obj/item/clothing/C = I
if(istype(C) && C.dynamic_hair_suffix)
update_hair()
// Close internal air tank if helmet was the only breathing apparatus.
if (invalid_internals())
cutoff_internals()
if(I.flags_inv & HIDEEYES || forced)
update_inv_glasses()
if(I.flags_inv & HIDEEARS || forced)
update_body()
sec_hud_set_security_status()
..()
/mob/living/carbon/human/proc/equipOutfit(outfit, visualsOnly = FALSE)
var/datum/outfit/O = null
if(ispath(outfit))
O = new outfit
else
O = outfit
if(!istype(O))
return FALSE
if(!O)
return FALSE
return O.equip(src, visualsOnly)
//delete all equipment without dropping anything
/mob/living/carbon/human/proc/delete_equipment()
for(var/slot in get_all_slots())//order matters, dependant slots go first
qdel(slot)
for(var/obj/item/I in held_items)
qdel(I)
/mob/living/carbon/human/proc/smart_equipbag() // take most recent item out of bag or place held item in bag
if(incapacitated())
return
var/obj/item/thing = get_active_held_item()
var/obj/item/equipped_back = get_item_by_slot(ITEM_SLOT_BACK)
if(!equipped_back) // We also let you equip a backpack like this
if(!thing)
to_chat(src, "<span class='warning'>You have no backpack to take something out of!</span>")
return
if(equip_to_slot_if_possible(thing, ITEM_SLOT_BACK))
update_inv_hands()
return
if(!SEND_SIGNAL(equipped_back, COMSIG_CONTAINS_STORAGE)) // not a storage item
if(!thing)
equipped_back.attack_hand(src)
else
to_chat(src, "<span class='warning'>You can't fit anything in!</span>")
return
if(thing) // put thing in backpack
if(!SEND_SIGNAL(equipped_back, COMSIG_TRY_STORAGE_INSERT, thing, src))
to_chat(src, "<span class='warning'>You can't fit anything in!</span>")
return
if(!equipped_back.contents.len) // nothing to take out
to_chat(src, "<span class='warning'>There's nothing in your backpack to take out!</span>")
return
var/obj/item/stored = equipped_back.contents[equipped_back.contents.len]
if(!stored || stored.on_found(src))
return
stored.attack_hand(src) // take out thing from backpack
return
/mob/living/carbon/human/proc/smart_equipbelt() // put held thing in belt or take most recent item out of belt
if(incapacitated())
return
var/obj/item/thing = get_active_held_item()
var/obj/item/equipped_belt = get_item_by_slot(ITEM_SLOT_BELT)
if(!equipped_belt) // We also let you equip a belt like this
if(!thing)
to_chat(src, "<span class='warning'>You have no belt to take something out of!</span>")
return
if(equip_to_slot_if_possible(thing, ITEM_SLOT_BELT))
update_inv_hands()
return
if(!SEND_SIGNAL(equipped_belt, COMSIG_CONTAINS_STORAGE)) // not a storage item
if(!thing)
equipped_belt.attack_hand(src)
else
to_chat(src, "<span class='warning'>You can't fit anything in!</span>")
return
if(thing) // put thing in belt
if(!SEND_SIGNAL(equipped_belt, COMSIG_TRY_STORAGE_INSERT, thing, src))
to_chat(src, "<span class='warning'>You can't fit anything in!</span>")
return
if(!equipped_belt.contents.len) // nothing to take out
to_chat(src, "<span class='warning'>There's nothing in your belt to take out!</span>")
return
var/obj/item/stored = equipped_belt.contents[equipped_belt.contents.len]
if(!stored || stored.on_found(src))
return
stored.attack_hand(src) // take out thing from belt
return
/mob/living/carbon/human/proc/smart_equipsuit()
var/obj/item/thing = get_active_held_item()
var/obj/item/equipped_suit = get_item_by_slot(ITEM_SLOT_SUITSTORE)
if(!equipped_suit)
if(!thing)
to_chat(src, span_notice("You have no suit storage to take something out of."))
return
if(equip_to_slot_if_possible(thing, ITEM_SLOT_SUITSTORE))
update_inv_hands()
return
if(!SEND_SIGNAL(equipped_suit, COMSIG_CONTAINS_STORAGE)) // not a storage item
if(!thing)
equipped_suit.attack_hand(src)
else
to_chat(src, span_notice("You can't fit anything in."))
return
if(thing) // put thing in suit storage
if(!SEND_SIGNAL(equipped_suit, COMSIG_TRY_STORAGE_INSERT, thing, src))
to_chat(src, span_notice("You can't fit anything in."))
return
if(!equipped_suit.contents.len) // nothing to take out
to_chat(src, span_notice("There's nothing in your suit storage to take out."))
return
var/obj/item/stored = equipped_suit.contents[equipped_suit.contents.len]
if(!stored || stored.on_found(src))
return
stored.attack_hand(src) // take out thing from suit storage
return