/
storage.dm
365 lines (317 loc) · 12.5 KB
/
storage.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
/obj/item/borg/apparatus
name = "unknown storage apparatus"
desc = "This device seems nonfunctional."
icon = 'icons/mob/silicon/robot_items.dmi'
icon_state = "hugmodule"
/// The item stored inside of this apparatus
var/obj/item/stored
/// Whitelist of types allowed in this apparatus
var/list/storable = list()
/obj/item/borg/apparatus/Initialize(mapload)
RegisterSignal(loc.loc, COMSIG_BORG_SAFE_DECONSTRUCT, PROC_REF(safedecon))
return ..()
/obj/item/borg/apparatus/Destroy()
QDEL_NULL(stored)
return ..()
///If we're safely deconstructed, we put the item neatly onto the ground, rather than deleting it.
/obj/item/borg/apparatus/proc/safedecon()
SIGNAL_HANDLER
if(stored)
stored.forceMove(get_turf(src))
stored = null
/obj/item/borg/apparatus/Exited(atom/movable/gone, direction)
if(gone == stored) //sanity check
UnregisterSignal(stored, COMSIG_ATOM_UPDATED_ICON)
stored = null
update_appearance()
return ..()
///A right-click verb, for those not using hotkey mode.
/obj/item/borg/apparatus/verb/verb_dropHeld()
set category = "Object"
set name = "Drop"
if(usr != loc || !stored)
return
stored.forceMove(get_turf(usr))
return
/**
* Attack_self will pass for the stored item.
*/
/obj/item/borg/apparatus/attack_self(mob/living/silicon/robot/user)
if(!stored || !issilicon(user))
return ..()
stored.attack_self(user)
//Alt click drops the stored item.
/obj/item/borg/apparatus/click_alt(mob/living/silicon/robot/user)
if(!stored || !issilicon(user))
return CLICK_ACTION_BLOCKING
stored.forceMove(user.drop_location())
return CLICK_ACTION_SUCCESS
/obj/item/borg/apparatus/pre_attack(atom/atom, mob/living/user, params)
if(stored)
stored.melee_attack_chain(user, atom, params)
return TRUE
if(istype(atom.loc, /mob/living/silicon/robot) || istype(atom.loc, /obj/item/robot_model) || HAS_TRAIT(atom, TRAIT_NODROP))
return ..() // Borgs should not be grabbing their own modules
var/itemcheck = FALSE
for(var/storable_type in storable)
if(istype(atom, storable_type))
itemcheck = TRUE
break
if(itemcheck)
var/obj/item/item = atom
item.forceMove(src)
stored = item
RegisterSignal(stored, COMSIG_ATOM_UPDATED_ICON, PROC_REF(on_stored_updated_icon))
update_appearance()
return TRUE
return ..()
/**
* Updates the appearance of the apparatus when the stored object's icon gets updated.
*
* Returns NONE as we have not done anything to the stored object itself,
* which is where this signal that this handler intercepts is sent from.
*/
/obj/item/borg/apparatus/proc/on_stored_updated_icon(datum/source, updates)
SIGNAL_HANDLER
update_appearance()
return NONE
/obj/item/borg/apparatus/attackby(obj/item/item, mob/user, params)
if(stored)
item.melee_attack_chain(user, stored, params)
return
return ..()
/obj/item/borg/apparatus/beaker
name = "beaker storage apparatus"
desc = "A special apparatus for carrying beakers, bottles, and test tubes without spilling their contents."
icon_state = "borg_beaker_apparatus"
storable = list(
/obj/item/reagent_containers/cup/beaker,
/obj/item/reagent_containers/cup/bottle,
/obj/item/reagent_containers/cup/tube,
)
/obj/item/borg/apparatus/beaker/Initialize(mapload)
add_glass()
RegisterSignal(stored, COMSIG_ATOM_UPDATED_ICON, PROC_REF(on_stored_updated_icon))
update_appearance()
return ..()
/obj/item/borg/apparatus/beaker/proc/add_glass()
stored = new /obj/item/reagent_containers/cup/beaker/large(src)
/obj/item/borg/apparatus/beaker/Destroy()
if(stored)
var/obj/item/reagent_containers/reagent_container = stored
reagent_container.SplashReagents(get_turf(src))
QDEL_NULL(stored)
return ..()
/obj/item/borg/apparatus/beaker/examine()
. = ..()
if(stored)
var/obj/item/reagent_containers/reagent_container = stored
. += "The apparatus currently has [reagent_container] secured, which contains:"
if(length(reagent_container.reagents.reagent_list))
for(var/datum/reagent/reagent in reagent_container.reagents.reagent_list)
. += "[reagent.volume] units of [reagent.name]"
else
. += "Nothing."
. += span_notice(" <i>Right-clicking</i> will splash the beaker on the ground.")
. += span_notice(" <i>Alt-click</i> will drop the currently stored beaker. ")
/obj/item/borg/apparatus/beaker/update_overlays()
. = ..()
var/mutable_appearance/arm = mutable_appearance(icon = icon, icon_state = "borg_beaker_apparatus_arm")
if(stored)
stored.pixel_x = 0
stored.pixel_y = 0
var/mutable_appearance/stored_copy = new /mutable_appearance(stored)
if(istype(stored, /obj/item/reagent_containers/cup/beaker))
arm.pixel_y = arm.pixel_y - 3
stored_copy.layer = FLOAT_LAYER
stored_copy.plane = FLOAT_PLANE
. += stored_copy
else
arm.pixel_y = arm.pixel_y - 5
. += arm
/// Secondary attack spills the content of the beaker.
/obj/item/borg/apparatus/beaker/pre_attack_secondary(atom/target, mob/living/silicon/robot/user)
var/obj/item/reagent_containers/stored_beaker = stored
if(!stored_beaker)
return ..()
stored_beaker.SplashReagents(drop_location(user))
loc.visible_message(span_notice("[user] spills the contents of [stored_beaker] all over the ground."))
return ..()
/obj/item/borg/apparatus/beaker/extra
name = "secondary beaker storage apparatus"
desc = "A supplementary beaker storage apparatus."
/obj/item/borg/apparatus/beaker/service
name = "beverage storage apparatus"
desc = "A special apparatus for carrying drinks and condiment packets without spilling their contents. Will resynthesize any drinks (or other nutritional liquids) you pour out of glasses!"
icon_state = "borg_beaker_apparatus"
storable = list(
/obj/item/reagent_containers/cup/glass,
/obj/item/reagent_containers/condiment,
/obj/item/reagent_containers/cup/coffeepot,
/obj/item/reagent_containers/cup/bottle/syrup_bottle,
)
/obj/item/borg/apparatus/beaker/service/add_glass()
stored = new /obj/item/reagent_containers/cup/glass/drinkingglass(src)
handle_reflling(stored, loc.loc, force = TRUE)
/obj/item/borg/apparatus/beaker/service/proc/handle_reflling(obj/item/reagent_containers/cup/glass, mob/living/silicon/robot/bro, force = FALSE)
if (isnull(bro))
bro = loc
if (!iscyborg(bro))
return
if (!stored || force)
glass.AddComponent(/datum/component/reagent_refiller, power_draw_callback = CALLBACK(bro, TYPE_PROC_REF(/mob/living/silicon/robot, draw_power)))
/obj/item/borg/apparatus/beaker/service/Entered(atom/movable/arrived, atom/old_loc, list/atom/old_locs)
if (!istype(arrived, /obj/item/reagent_containers/cup/glass))
return
handle_reflling(arrived)
return ..()
///Used by the service borg drink apparatus upgrade, holds drink-related items
/obj/item/borg/apparatus/beaker/drink
name = "secondary beverage storage apparatus"
desc = "A special apparatus for carrying drinks and condiment packets without spilling their contents. Will NOT resynthesize drinks unlike your standard apparatus."
icon_state = "borg_beaker_apparatus"
storable = list(
/obj/item/reagent_containers/cup/glass,
/obj/item/reagent_containers/condiment,
/obj/item/reagent_containers/cup/coffeepot,
/obj/item/reagent_containers/cup/bottle/syrup_bottle,
)
/obj/item/borg/apparatus/beaker/service2/add_glass()
stored = new /obj/item/reagent_containers/cup/glass/drinkingglass(src)
/// allows medical cyborgs to manipulate organs without hands
/obj/item/borg/apparatus/organ_storage
name = "organ storage bag"
desc = "A container for holding body parts."
icon = 'icons/obj/storage/storage.dmi'
icon_state = "evidenceobj"
item_flags = SURGICAL_TOOL
storable = list(/obj/item/organ,
/obj/item/bodypart)
/obj/item/borg/apparatus/organ_storage/examine()
. = ..()
. += "The organ bag currently contains:"
if(stored)
var/obj/item/organ = stored
. += organ.name
else
. += "Nothing."
. += span_notice(" <i>Alt-click</i> will drop the currently stored organ. ")
/obj/item/borg/apparatus/organ_storage/update_overlays()
. = ..()
icon_state = null // hides the original icon (otherwise it's drawn underneath)
var/mutable_appearance/bag
if(stored)
var/mutable_appearance/stored_organ = new /mutable_appearance(stored)
stored_organ.layer = FLOAT_LAYER
stored_organ.plane = FLOAT_PLANE
stored_organ.pixel_x = 0
stored_organ.pixel_y = 0
. += stored_organ
bag = mutable_appearance(icon, icon_state = "evidence") // full bag
else
bag = mutable_appearance(icon, icon_state = "evidenceobj") // empty bag
. += bag
/obj/item/borg/apparatus/organ_storage/click_alt(mob/living/silicon/robot/user)
if(!stored)
to_chat(user, span_notice("[src] is empty."))
return CLICK_ACTION_BLOCKING
var/obj/item/organ = stored
user.visible_message(span_notice("[user] dumps [organ] from [src]."), span_notice("You dump [organ] from [src]."))
cut_overlays()
organ.forceMove(get_turf(src))
return CLICK_ACTION_SUCCESS
///Apparatus to allow Engineering/Sabo borgs to manipulate any material sheets.
/obj/item/borg/apparatus/sheet_manipulator
name = "material manipulation apparatus"
desc = "An apparatus for carrying, deploying, and manipulating sheets of material. The device can also carry custom floor tiles."
icon_state = "borg_stack_apparatus"
storable = list(/obj/item/stack/sheet,
/obj/item/stack/tile)
/obj/item/borg/apparatus/sheet_manipulator/Initialize(mapload)
update_appearance()
return ..()
/obj/item/borg/apparatus/sheet_manipulator/update_overlays()
. = ..()
var/mutable_appearance/arm = mutable_appearance(icon, "borg_stack_apparatus_arm1")
if(stored)
stored.pixel_x = 0
stored.pixel_y = 0
arm.icon_state = "borg_stack_apparatus_arm2"
var/mutable_appearance/stored_copy = new /mutable_appearance(stored)
var/underscore = findtext(stored_copy.icon_state, "_")
if(underscore)
stored_copy.icon_state = initial(stored.icon_state) //how we use the icon_state of single sheets, even with full stacks
stored_copy.layer = FLOAT_LAYER
stored_copy.plane = FLOAT_PLANE
. += stored_copy
. += arm
/obj/item/borg/apparatus/sheet_manipulator/examine()
. = ..()
if(stored)
. += "The apparatus currently has [stored] secured."
. += span_notice(" <i>Alt-click</i> will drop the currently stored sheets. ")
///Apparatus allowing Engineer/Sabo borgs to manipulate Machine and Computer circuit boards
/obj/item/borg/apparatus/circuit
name = "circuit manipulation apparatus"
desc = "A special apparatus for carrying and manipulating circuit boards."
icon_state = "borg_hardware_apparatus"
storable = list(/obj/item/circuitboard,
/obj/item/electronics)
/obj/item/borg/apparatus/circuit/Initialize(mapload)
update_appearance()
return ..()
/obj/item/borg/apparatus/circuit/update_overlays()
. = ..()
var/mutable_appearance/arm = mutable_appearance(icon, "borg_hardware_apparatus_arm1")
if(stored)
stored.pixel_x = -3
stored.pixel_y = 0
if(!istype(stored, /obj/item/circuitboard))
arm.icon_state = "borg_hardware_apparatus_arm2"
var/mutable_appearance/stored_copy = new /mutable_appearance(stored)
stored_copy.layer = FLOAT_LAYER
stored_copy.plane = FLOAT_PLANE
. += stored_copy
. += arm
/obj/item/borg/apparatus/circuit/examine()
. = ..()
if(stored)
. += "The apparatus currently has [stored] secured."
. += span_notice(" <i>Alt-click</i> will drop the currently stored circuit. ")
/obj/item/borg/apparatus/circuit/pre_attack(atom/atom, mob/living/user, params)
if(istype(atom, /obj/item/ai_module) && !stored) //If an admin wants a borg to upload laws, who am I to stop them? Otherwise, we can hint that it fails
to_chat(user, span_warning("This circuit board doesn't seem to have standard robot apparatus pin holes. You're unable to pick it up."))
return ..()
/obj/item/borg/apparatus/service
name = "service apparatus"
desc = "A special apparatus for carrying food, bowls, plates, oven trays, soup pots and paper."
icon_state = "borg_service_apparatus"
storable = list(
/obj/item/food,
/obj/item/paper,
/obj/item/plate,
/obj/item/plate/oven_tray,
/obj/item/reagent_containers/cup/bowl,
/obj/item/reagent_containers/cup/soup_pot,
)
/obj/item/borg/apparatus/service/Initialize(mapload)
update_appearance()
return ..()
/obj/item/borg/apparatus/service/update_overlays()
. = ..()
var/mutable_appearance/arm = mutable_appearance(icon, "borg_hardware_apparatus_arm1")
if(stored)
stored.pixel_x = -3
stored.pixel_y = 0
if((!istype(stored, /obj/item/plate/oven_tray)) || (!istype(stored, /obj/item/food)))
arm.icon_state = "borg_hardware_apparatus_arm2"
var/mutable_appearance/stored_copy = new /mutable_appearance(stored)
stored_copy.layer = FLOAT_LAYER
stored_copy.plane = FLOAT_PLANE
. += stored_copy
. += arm
/obj/item/borg/apparatus/service/examine()
. = ..()
if(stored)
. += "The apparatus currently has [stored] secured."
. += span_notice("<i>Alt-click</i> will drop the currently secured item.")