/
borghypo.dm
309 lines (274 loc) · 11.3 KB
/
borghypo.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
/obj/item/reagent_containers/borghypo
name = "robot hypospray"
desc = "An advanced chemical synthesizer and injection system, designed for heavy-duty medical equipment."
icon = 'icons/obj/tools/syringe.dmi'
item_state = "hypo"
icon_state = "borghypo"
amount_per_transfer_from_this = 5
volume = 30
possible_transfer_amounts = null
canremove = FALSE
/// Numeric index of the synthesizer in use, or 0 if dispensing from an external container
var/mode = 1
var/weakref/dispense = null
var/charge_cost = 50
var/charge_tick = 0
var/recharge_time = 5 //Time it takes for shots to recharge (in seconds)
var/list/reagent_ids = list(/datum/reagent/tricordrazine, /datum/reagent/inaprovaline, /datum/reagent/spaceacillin)
var/list/reagent_volumes = list()
var/list/reagent_names = list()
/obj/item/reagent_containers/borghypo/surgeon
reagent_ids = list(/datum/reagent/inaprovaline, /datum/reagent/bicaridine, /datum/reagent/dexalin, /datum/reagent/tramadol)
/obj/item/reagent_containers/borghypo/crisis
reagent_ids = list(/datum/reagent/inaprovaline, /datum/reagent/dylovene, /datum/reagent/dexalin, /datum/reagent/tramadol, /datum/reagent/adrenaline)
/obj/item/reagent_containers/borghypo/Initialize()
. = ..()
for(var/T in reagent_ids)
reagent_volumes[T] = volume
var/datum/reagent/R = T
reagent_names += initial(R.name)
/obj/item/reagent_containers/borghypo/Initialize()
. = ..()
START_PROCESSING(SSobj, src)
/obj/item/reagent_containers/borghypo/Destroy()
STOP_PROCESSING(SSobj, src)
. = ..()
/obj/item/reagent_containers/borghypo/Process() //Every [recharge_time] seconds, recharge some reagents for the cyborg+
if(++charge_tick < recharge_time)
return 0
charge_tick = 0
if(isrobot(loc))
var/mob/living/silicon/robot/R = loc
if(R && R.cell)
for(var/T in reagent_ids)
if(reagent_volumes[T] < volume)
R.cell.use(charge_cost)
reagent_volumes[T] = min(reagent_volumes[T] + 5, volume)
return 1
/obj/item/reagent_containers/borghypo/use_before(mob/living/M, mob/user)
. = FALSE
if (!istype(M))
return FALSE
if (mode && !reagent_volumes[reagent_ids[mode]])
to_chat(user, SPAN_WARNING("\The [src] is empty."))
return TRUE
var/obj/item/reagent_containers/container = null
if (!mode)
container = dispense.resolve()
if (!valid_container(user, container))
to_chat(user, SPAN_WARNING("Can't find the container to dispense from."))
return TRUE
if (!container.reagents?.total_volume)
to_chat(user, SPAN_WARNING("\The [container] is empty."))
return TRUE
var/target_zone = user.zone_sel.selecting
var/allow = M.can_inject(user, target_zone)
if (allow)
if (allow == INJECTION_PORT)
user.visible_message(SPAN_WARNING("\The [user] begins hunting for an injection port on \the [M]'s suit!"))
if (!user.do_skilled(INJECTION_PORT_DELAY, SKILL_MEDICAL, M, do_flags = DO_MEDICAL))
return TRUE
to_chat(user, SPAN_NOTICE("You inject [M] with the injector."))
if (ishuman(M))
var/mob/living/carbon/human/H = M
H.custom_pain(SPAN_WARNING("You feel a tiny prick!"), 1, TRUE, H.get_organ(user.zone_sel.selecting))
if (M.reagents)
if (mode)
var/datum/reagent/R = reagent_ids[mode]
var/should_admin_log = initial(R.should_admin_log)
var/transferred = min(amount_per_transfer_from_this, reagent_volumes[R])
M.reagents.add_reagent(R, transferred)
reagent_volumes[R] -= transferred
if (should_admin_log)
admin_inject_log(user, M, src, R, transferred)
to_chat(user, SPAN_NOTICE("[transferred] units injected. [reagent_volumes[R]] units remaining."))
return TRUE
else
var/datum/reagents/R = container.reagents
var/should_admin_log = R.should_admin_log()
var/contained = R.get_reagents()
var/transferred = R.trans_to_mob(M, amount_per_transfer_from_this, CHEM_BLOOD)
if (should_admin_log)
admin_inject_log(user, M, src, contained, transferred)
to_chat(user, SPAN_NOTICE("[transferred] units injected. [R.total_volume] units remaining in \the [container]."))
return TRUE
/obj/item/reagent_containers/borghypo/attack_self(mob/user as mob)
ui_interact(user)
/obj/item/reagent_containers/borghypo/examine(mob/user, distance)
. = ..()
if(distance > 2)
return
if (mode)
var/datum/reagent/R = reagent_ids[mode]
to_chat(user, SPAN_NOTICE("It is currently producing [initial(R.name)] and has [reagent_volumes[R]] out of [volume] units left."))
else
var/obj/item/reagent_containers/container = dispense.resolve()
if (istype(container))
var/datum/reagents/R = container.reagents
if (istype(R))
to_chat(user, SPAN_NOTICE("It is currently dispensing from \the [container] which has [R.total_volume] out of [R.maximum_volume] units left."))
return
to_chat(user, SPAN_WARNING("It is currently empty."))
/obj/item/reagent_containers/borghypo/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = TRUE)
var/data = list()
data["selected"] = mode ? reagent_names[mode] : dispense.ref
data["synthReagents"] = reagent_names
data["bottles"] = list()
var/list/bottles = list()
var/mob/living/silicon/robot/robot = loc
if (istype(robot))
var/list/equipment = robot.module.equipment
for (var/obj/item/reagent_containers/glass/container in equipment)
// Will pick up on any containers directly in the loadout, like buckets and legacy robot bottles
bottles += container
for (var/obj/item/robot_rack/bottle/rack in equipment)
// Append contents
bottles += rack.held
for (var/obj/item/gripper/gripper in equipment)
// If the gripper's holding a container, add it in
if (istype(gripper.wrapped, /obj/item/reagent_containers/glass))
bottles += gripper.wrapped
for (var/obj/item/reagent_containers/bottle in bottles)
var/iconPath = "bottle-\ref[bottle].png"
var/icon/flatIcon = getFlatIcon(bottle)
flatIcon.Scale(64, 64) // Scale to avoid blurring in the browser
send_rsc(user, flatIcon, iconPath)
data["bottles"] += list(list( // It's completely ridiculous that this double list thing is necessary
"id" = ref(bottle),
"icon" = iconPath,
"name" = bottle.label_text || bottle.name,
"total_volume" = bottle.reagents ? bottle.reagents.total_volume : 0,
"maximum_volume" = bottle.reagents ? bottle.reagents.maximum_volume : 0
))
ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
var/nbottles = length(bottles)
var/width = max(330, nbottles * 165)
var/height = min(600, 240 + 10 * length(reagent_ids))
ui = new(user, src, ui_key, "borghypo.tmpl", name, width, height)
ui.set_initial_data(data)
ui.open()
ui.auto_update_layout = TRUE
ui.set_auto_update(TRUE)
/obj/item/reagent_containers/borghypo/OnTopic(mob/user, list/href_list, datum/topic_state/state)
var/selection = href_list["selected"]
var/obj/item/reagent_containers/bottle = locate(selection)
if (istype(bottle))
if (valid_container(user, bottle))
mode = 0
dispense = weakref(bottle)
to_chat(user, SPAN_NOTICE("Dispensing from \the [bottle]."))
return TOPIC_REFRESH
var/index = reagent_names.Find(selection)
if (index)
mode = index
dispense = null
to_chat(user, SPAN_NOTICE("Synthesizer is now producing [selection]."))
return TOPIC_REFRESH
return TOPIC_NOACTION
/**
* Check the bottle is still accessible.
* Valid places the bottle could be:
* * in the robot's active modules (loc == user)
* * in the robot's inactive modules (loc == user.module)
* * in a rack or gripper in either of these places
*/
/obj/item/reagent_containers/borghypo/proc/valid_container(mob/user, obj/item/reagent_containers/container)
var/mob/living/silicon/robot/robot = user
return istype(container) && (container.loc == user || container.loc.loc == user || istype(robot) && container.loc.loc == robot.module)
/obj/item/reagent_containers/borghypo/service
name = "cyborg drink synthesizer"
desc = "A portable drink dispencer."
icon = 'icons/obj/food/drinks.dmi'
icon_state = "shaker"
charge_cost = 5
recharge_time = 3
volume = 60
possible_transfer_amounts = "5;10;20;30"
reagent_ids = list(
/datum/reagent/ethanol/beer,
/datum/reagent/ethanol/coffee/kahlua,
/datum/reagent/ethanol/whiskey,
/datum/reagent/ethanol/wine,
/datum/reagent/ethanol/vodka,
/datum/reagent/ethanol/gin,
/datum/reagent/ethanol/rum,
/datum/reagent/ethanol/tequilla,
/datum/reagent/ethanol/vermouth,
/datum/reagent/ethanol/cognac,
/datum/reagent/ethanol/ale,
/datum/reagent/ethanol/mead,
/datum/reagent/water,
/datum/reagent/sugar,
/datum/reagent/drink/ice,
/datum/reagent/drink/tea,
/datum/reagent/drink/tea/icetea,
/datum/reagent/drink/space_cola,
/datum/reagent/drink/spacemountainwind,
/datum/reagent/drink/dr_gibb,
/datum/reagent/drink/space_up,
/datum/reagent/drink/tonic,
/datum/reagent/drink/sodawater,
/datum/reagent/drink/lemon_lime,
/datum/reagent/drink/juice/orange,
/datum/reagent/drink/juice/lime,
/datum/reagent/drink/juice/watermelon,
/datum/reagent/drink/coffee,
/datum/reagent/drink/hot_coco,
/datum/reagent/drink/tea/green,
/datum/reagent/drink/spacemountainwind,
/datum/reagent/ethanol/beer,
/datum/reagent/ethanol/coffee/kahlua
)
/obj/item/reagent_containers/borghypo/service/use_before(mob/M, mob/user)
return FALSE //We don't want the service borg to be able to inject alcohol into blood.
/obj/item/reagent_containers/borghypo/service/use_after(obj/target, mob/living/user, click_parameters)
if (!target.reagents)
return FALSE
if(!target.is_open_container())
to_chat(user, SPAN_WARNING("\The [target] is capped."))
return TRUE
if(!target.reagents.get_free_space())
to_chat(user, SPAN_WARNING("\The [target] is full."))
return TRUE
if (mode)
var/datum/reagent/R = reagent_ids[mode]
if(!reagent_volumes[R])
to_chat(user, SPAN_WARNING("\The [src] is out of this reagent, give it some time to refill."))
return TRUE
var/transferred = min(amount_per_transfer_from_this, reagent_volumes[R])
target.reagents.add_reagent(R, transferred)
reagent_volumes[R] -= transferred
to_chat(user, SPAN_NOTICE("You transfer [transferred] units of the solution to [target]."))
else
var/obj/item/reagent_containers/container = dispense.resolve()
if (!valid_container(user, container))
to_chat(user, SPAN_WARNING("Can't find the container to dispense from."))
return TRUE
var/datum/reagents/R = container.reagents
if (!R || !R.total_volume)
to_chat(user, SPAN_WARNING("\The [container] is empty."))
var/transferred = R.trans_to_holder(target.reagents, amount_per_transfer_from_this)
to_chat(user, "You transfer [transferred] units of the solution to [target].")
return TRUE
/obj/item/robot_rack/bottle
name = "bottle rack"
icon = 'icons/obj/chemical_storage.dmi'
icon_state = "bottle-1"
object_type = /obj/item/reagent_containers/glass/bottle
capacity = 4
attack_self_on_deploy = FALSE // Don't open/close bottles on deploy
// Hint that the hypo can use the bottle rack's contents
/obj/item/robot_rack/bottle/examine(mob/user)
. = ..()
var/mob/living/silicon/robot/R = user
if (istype(R))
var/obj/item/reagent_containers/borghypo/hypo = locate() in R.module.equipment
if (istype(hypo))
to_chat(user, "Its contents are available to \the [hypo].")
// Extra message for if you try to pick up beakers
/obj/item/robot_rack/bottle/resolve_attackby(obj/O, mob/user, click_params)
if (!istype(O, object_type) && istype(O, /obj/item/reagent_containers/glass))
to_chat(user, SPAN_WARNING("\The [O] is the wrong shape for \the [src]."))
return
. = ..()