-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
watertank.dm
473 lines (401 loc) · 14.9 KB
/
watertank.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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
//Hydroponics tank and base code
/obj/item/watertank
name = "backpack water tank"
desc = "A S.U.N.S.H.I.N.E. brand watertank backpack with nozzle to water plants."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "waterbackpack"
item_state = "waterbackpack"
w_class = WEIGHT_CLASS_BULKY
slot_flags = ITEM_SLOT_BACK
slowdown = 1
actions_types = list(/datum/action/item_action/toggle_mister)
max_integrity = 200
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 0, RAD = 0, FIRE = 100, ACID = 30)
resistance_flags = FIRE_PROOF
var/obj/item/noz
var/volume = 500
/obj/item/watertank/Initialize(mapload)
. = ..()
create_reagents(volume, OPENCONTAINER)
noz = make_noz()
/obj/item/watertank/ui_action_click(mob/user)
toggle_mister(user)
/obj/item/watertank/item_action_slot_check(slot, mob/user)
if(slot == user.getBackSlot())
return 1
/obj/item/watertank/proc/toggle_mister(mob/living/user)
if(!istype(user))
return
if(user.get_item_by_slot(user.getBackSlot()) != src)
to_chat(user, span_warning("The watertank must be worn properly to use!"))
return
if(user.incapacitated())
return
if(QDELETED(noz))
noz = make_noz()
if(noz in src)
//Detach the nozzle into the user's hands
if(!user.put_in_hands(noz))
to_chat(user, span_warning("You need a free hand to hold the mister!"))
return
else
//Remove from their hands and put back "into" the tank
remove_noz()
/obj/item/watertank/verb/toggle_mister_verb()
set name = "Toggle Mister"
set category = "Object"
toggle_mister(usr)
/obj/item/watertank/proc/make_noz()
return new /obj/item/reagent_containers/spray/mister(src)
/obj/item/watertank/equipped(mob/user, slot)
..()
if(slot != ITEM_SLOT_BACK)
remove_noz()
/obj/item/watertank/proc/remove_noz()
if(!QDELETED(noz))
if(ismob(noz.loc))
var/mob/M = noz.loc
M.temporarilyRemoveItemFromInventory(noz, TRUE)
noz.forceMove(src)
/obj/item/watertank/Destroy()
QDEL_NULL(noz)
return ..()
/obj/item/watertank/attack_hand(mob/user)
if (user.get_item_by_slot(user.getBackSlot()) == src)
toggle_mister(user)
else
return ..()
/obj/item/watertank/MouseDrop(obj/over_object)
var/mob/M = loc
if(istype(M) && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(src, H.held_index)
return ..()
/obj/item/watertank/attackby(obj/item/W, mob/user, params)
if(W == noz)
remove_noz()
return 1
else
return ..()
/obj/item/watertank/dropped(mob/user)
..()
remove_noz()
// This mister item is intended as an extension of the watertank and always attached to it.
// Therefore, it's designed to be "locked" to the player's hands or extended back onto
// the watertank backpack. Allowing it to be placed elsewhere or created without a parent
// watertank object will likely lead to weird behaviour or runtimes.
/obj/item/reagent_containers/spray/mister
name = "water mister"
desc = "A mister nozzle attached to a water tank."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "mister"
item_state = "mister"
lefthand_file = 'icons/mob/inhands/equipment/mister_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/mister_righthand.dmi'
w_class = WEIGHT_CLASS_BULKY
amount_per_transfer_from_this = 50
possible_transfer_amounts = list(25,50,100)
volume = 500
item_flags = NOBLUDGEON | ABSTRACT // don't put in storage
slot_flags = 0
var/obj/item/watertank/tank
/obj/item/reagent_containers/spray/mister/Initialize(mapload)
. = ..()
tank = loc
if(!istype(tank))
return INITIALIZE_HINT_QDEL
reagents = tank.reagents //This mister is really just a proxy for the tank's reagents
/obj/item/reagent_containers/spray/mister/attack_self()
return
/obj/item/reagent_containers/spray/mister/doMove(atom/destination)
if(destination && (destination != tank.loc || !ismob(destination)))
if (loc != tank)
to_chat(tank.loc, span_notice("The mister snaps back onto the watertank."))
destination = tank
..()
/obj/item/reagent_containers/spray/mister/afterattack(obj/target, mob/user, proximity)
if(target.loc == loc) //Safety check so you don't fill your mister with mutagen or something and then blast yourself in the face with it
return
..()
//Janitor tank
/obj/item/watertank/janitor
name = "backpack cleaner tank"
desc = "A janitorial cleaner backpack with nozzle to clean blood and graffiti."
icon_state = "waterbackpackjani"
item_state = "waterbackpackjani"
custom_price = 100
/obj/item/watertank/janitor/Initialize(mapload)
. = ..()
reagents.add_reagent(/datum/reagent/space_cleaner, 500)
/obj/item/reagent_containers/spray/mister/janitor
name = "janitor spray nozzle"
desc = "A janitorial spray nozzle attached to a watertank, designed to clean up large messes."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "misterjani"
item_state = "misterjani"
lefthand_file = 'icons/mob/inhands/equipment/mister_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/mister_righthand.dmi'
amount_per_transfer_from_this = 5
possible_transfer_amounts = list()
/obj/item/watertank/janitor/make_noz()
return new /obj/item/reagent_containers/spray/mister/janitor(src)
/obj/item/reagent_containers/spray/mister/janitor/attack_self(mob/user)
amount_per_transfer_from_this = (amount_per_transfer_from_this == 10 ? 5 : 10)
to_chat(user, span_notice("You [amount_per_transfer_from_this == 10 ? "remove" : "fix"] the nozzle. You'll now use [amount_per_transfer_from_this] units per spray."))
//ATMOS FIRE FIGHTING BACKPACK
#define EXTINGUISHER 0
#define RESIN_LAUNCHER 1
#define RESIN_FOAM 2
/obj/item/watertank/atmos
name = "backpack firefighter tank"
desc = "A refrigerated and pressurized backpack tank with extinguisher nozzle, intended to fight fires. Swaps between extinguisher, resin launcher and a smaller scale resin foamer. The resin launcher costs 50 units of water and regenerates every 5 seconds. The resin foamer starts with 5 charges and regenerates one every 5 seconds."
item_state = "waterbackpackatmos"
icon_state = "waterbackpackatmos"
volume = 300
slowdown = 0
/obj/item/watertank/atmos/Initialize(mapload)
. = ..()
reagents.add_reagent(/datum/reagent/water, volume)
/obj/item/watertank/atmos/make_noz()
return new /obj/item/extinguisher/mini/nozzle(src)
/obj/item/watertank/atmos/dropped(mob/user)
..()
icon_state = "waterbackpackatmos"
if(istype(noz, /obj/item/extinguisher/mini/nozzle))
var/obj/item/extinguisher/mini/nozzle/N = noz
N.nozzle_mode = 0
/obj/item/extinguisher/mini/nozzle
name = "extinguisher nozzle"
desc = "A heavy duty nozzle attached to a firefighter's backpack tank."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "atmos_nozzle"
item_state = "nozzleatmos"
lefthand_file = 'icons/mob/inhands/equipment/mister_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/mister_righthand.dmi'
safety = 0
power = 8
force = 10
precision = 1
w_class = WEIGHT_CLASS_HUGE
item_flags = ABSTRACT // don't put in storage
var/obj/item/watertank/tank
var/nozzle_mode = EXTINGUISHER
var/resin_charges = 5
var/launcher_cost = 50
COOLDOWN_DECLARE(resin_cooldown)
/obj/item/extinguisher/mini/nozzle/Initialize(mapload)
. = ..()
tank = loc
if (!istype(tank))
return INITIALIZE_HINT_QDEL
reagents = tank.reagents
max_water = tank.volume
/obj/item/extinguisher/mini/nozzle/doMove(atom/destination)
if(destination && (destination != tank.loc || !ismob(destination)))
if(loc != tank)
to_chat(tank.loc, span_notice("The nozzle snaps back onto the tank!"))
destination = tank
..()
/obj/item/extinguisher/mini/nozzle/attack_self(mob/user)
switch(nozzle_mode)
if(EXTINGUISHER)
nozzle_mode = RESIN_LAUNCHER
tank.icon_state = "waterbackpackatmos_1"
to_chat(user, "Swapped to resin launcher")
return
if(RESIN_LAUNCHER)
nozzle_mode = RESIN_FOAM
tank.icon_state = "waterbackpackatmos_2"
to_chat(user, "Swapped to resin foamer")
return
if(RESIN_FOAM)
nozzle_mode = EXTINGUISHER
tank.icon_state = "waterbackpackatmos_0"
to_chat(user, "Swapped to water extinguisher")
return
return
/obj/item/extinguisher/mini/nozzle/afterattack(atom/target, mob/user)
if(AttemptRefill(target, user))
return
if(nozzle_mode == EXTINGUISHER)
return ..()
var/Adj = user.Adjacent(target)
if(nozzle_mode == RESIN_LAUNCHER)
if(Adj)
return //Safety check so you don't blast yourself trying to refill your tank
var/datum/reagents/R = reagents
if(R.total_volume < launcher_cost)
to_chat(user, span_warning("You need at least [launcher_cost] units of water to use the resin launcher!"))
return
if(!COOLDOWN_FINISHED(src, resin_cooldown))
to_chat(user, span_warning("Resin launcher is still recharging..."))
return
COOLDOWN_START(src, resin_cooldown, 5 SECONDS)
R.remove_any(launcher_cost)
var/obj/effect/resin_container/resin = new (get_turf(src))
log_game("[key_name(user)] used Resin Launcher at [AREACOORD(user)].")
playsound(src,'sound/items/syringeproj.ogg',40,TRUE)
for(var/a=0, a<5, a++)
step_towards(resin, target)
sleep(0.2 SECONDS)
resin.Smoke()
return
if(nozzle_mode == RESIN_FOAM)
if(!Adj || !isturf(target))
return
for(var/S in target)
if(istype(S, /obj/effect/particle_effect/fluid/foam/metal/resin) || istype(S, /obj/structure/foamedmetal/resin))
to_chat(user, span_warning("There's already resin here!"))
return
if(resin_charges)
var/obj/effect/particle_effect/fluid/foam/metal/resin/foam = new (get_turf(target))
foam.group.target_size = 0
resin_charges--
addtimer(CALLBACK(src, PROC_REF(add_foam_charge)), 5 SECONDS)
else
to_chat(user, span_warning("Resin foam mix is still being synthesized..."))
return
/obj/item/extinguisher/mini/nozzle/proc/add_foam_charge()
resin_charges++
if(resin_charges > initial(resin_charges))
resin_charges = initial(resin_charges)
/obj/effect/resin_container
name = "resin container"
desc = "A compacted ball of expansive resin, used to repair the atmosphere in a room, or seal off breaches."
icon = 'icons/effects/effects.dmi'
icon_state = "frozen_smoke_capsule"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
pass_flags = PASSTABLE
anchored = TRUE
/obj/effect/resin_container/proc/Smoke()
var/datum/effect_system/fluid_spread/foam/metal/resin/foaming = new
foaming.set_up(4, holder = src, location = loc)
foaming.start()
playsound(src,'sound/effects/bamf.ogg',100,TRUE)
qdel(src)
#undef EXTINGUISHER
#undef RESIN_LAUNCHER
#undef RESIN_FOAM
/datum/action/item_action/activate_injector
name = "Activate Injector"
/obj/item/reagent_containers/chemtank
name = "backpack chemical injector"
desc = "A chemical autoinjector that can be carried on your back."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "waterbackpackatmos"
item_state = "waterbackpackatmos"
w_class = WEIGHT_CLASS_BULKY
slot_flags = ITEM_SLOT_BACK
slowdown = 1
actions_types = list(/datum/action/item_action/activate_injector)
var/on = FALSE
volume = 300
var/usage_ratio = 5 //5 unit added per 1 removed
/// How much to inject per second
var/injection_amount = 0.5
amount_per_transfer_from_this = 5
reagent_flags = OPENCONTAINER_NOSPILL
possible_transfer_amounts = list(5,10,15)
/obj/item/reagent_containers/chemtank/ui_action_click()
toggle_injection()
/obj/item/reagent_containers/chemtank/item_action_slot_check(slot, mob/user)
if(slot == ITEM_SLOT_BACK)
return 1
/obj/item/reagent_containers/chemtank/proc/toggle_injection()
var/mob/living/carbon/human/user = usr
if(!istype(user))
return
if (user.get_item_by_slot(ITEM_SLOT_BACK) != src)
to_chat(user, span_warning("The chemtank needs to be on your back before you can activate it!"))
return
if(on)
turn_off()
else
turn_on()
//Todo : cache these.
/obj/item/reagent_containers/chemtank/proc/update_filling()
cut_overlays()
if(reagents.total_volume)
var/mutable_appearance/filling = mutable_appearance('icons/obj/reagentfillings.dmi', "backpack-10")
var/percent = round((reagents.total_volume / volume) * 100)
switch(percent)
if(0 to 15)
filling.icon_state = "backpack-10"
if(16 to 60)
filling.icon_state = "backpack50"
if(61 to INFINITY)
filling.icon_state = "backpack100"
filling.color = mix_color_from_reagents(reagents.reagent_list)
add_overlay(filling)
/obj/item/reagent_containers/chemtank/worn_overlays(mutable_appearance/standing, isinhands = FALSE, icon_file) //apply chemcolor and level
. = ..()
//inhands + reagent_filling
if(!isinhands && reagents.total_volume)
var/mutable_appearance/filling = mutable_appearance('icons/obj/reagentfillings.dmi', "backpackmob-10")
var/percent = round((reagents.total_volume / volume) * 100)
switch(percent)
if(0 to 15)
filling.icon_state = "backpackmob-10"
if(16 to 60)
filling.icon_state = "backpackmob50"
if(61 to INFINITY)
filling.icon_state = "backpackmob100"
filling.color = mix_color_from_reagents(reagents.reagent_list)
. += filling
/obj/item/reagent_containers/chemtank/proc/turn_on()
on = TRUE
START_PROCESSING(SSobj, src)
if(ismob(loc))
to_chat(loc, span_notice("[src] turns on."))
/obj/item/reagent_containers/chemtank/proc/turn_off()
on = FALSE
STOP_PROCESSING(SSobj, src)
if(ismob(loc))
to_chat(loc, span_notice("[src] turns off."))
/obj/item/reagent_containers/chemtank/process(delta_time)
if(!ishuman(loc))
turn_off()
return
if(!reagents.total_volume)
turn_off()
return
var/mob/living/carbon/human/user = loc
if(user.back != src)
turn_off()
return
var/inj_am = injection_amount * delta_time
var/used_amount = inj_am / usage_ratio
reagents.reaction(user, INJECT, used_amount, 0)
reagents.trans_to(user, used_amount, multiplier=usage_ratio)
update_filling()
user.update_inv_back() //for overlays update
//Operator backpack spray
/obj/item/watertank/op
name = "backpack water tank"
desc = "A New Russian backpack spray for systematic cleansing of carbon lifeforms."
icon_state = "waterbackpackjani"
item_state = "waterbackpackjani"
w_class = WEIGHT_CLASS_NORMAL
volume = 2000
slowdown = 0
/obj/item/watertank/op/Initialize(mapload)
. = ..()
reagents.add_reagent(/datum/reagent/toxin/mutagen,350)
reagents.add_reagent(/datum/reagent/napalm,125)
reagents.add_reagent(/datum/reagent/fuel,125)
reagents.add_reagent(/datum/reagent/clf3,300)
reagents.add_reagent(/datum/reagent/cryptobiolin,350)
reagents.add_reagent(/datum/reagent/toxin/plasma,250)
reagents.add_reagent(/datum/reagent/consumable/condensedcapsaicin,500)
/obj/item/reagent_containers/spray/mister/op
desc = "A mister nozzle attached to several extended water tanks. It suspiciously has a compressor in the system and is labelled entirely in New Cyrillic."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "misterjani"
item_state = "misterjani"
lefthand_file = 'icons/mob/inhands/equipment/mister_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/mister_righthand.dmi'
w_class = WEIGHT_CLASS_BULKY
amount_per_transfer_from_this = 100
possible_transfer_amounts = list(75,100,150)
/obj/item/watertank/op/make_noz()
return new /obj/item/reagent_containers/spray/mister/op(src)