-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathpool.dm
344 lines (303 loc) · 14.2 KB
/
pool.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
//Simple pool behaviour. Sprites by Cdey!
/**
How to pool!
Place pool turfs on the inside of your pool. This is where you swim. Pool end caps to cap it off on the north face
Place pool border decals around the pool so it doesn't look weird
Place a pool ladder at the top of the pool so that it leads to a normal tile (or else it'll be hard to get out of the pool.)
Place a pool filter somewhere in the pool if you want people to be able to modify the pool's settings (Temperature) or dump reagents into the pool (which'll change the pool's colour)
*/
/obj/effect/overlay/poolwater
name = "pool water"
icon = 'icons/obj/pool.dmi'
icon_state = "water"
anchored = TRUE
layer = ABOVE_ALL_MOB_LAYER
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/turf/open/indestructible/sound/pool
name = "swimming pool"
desc = "A fun place where you go to swim! <b>Drag and drop yourself onto it to climb in...</b>"
icon = 'icons/obj/pool.dmi'
icon_state = "pool"
flags_1 = RAD_CONTAIN_CONTENTS // contains most of the rads on the tile within that tile
var/id = null //Set me if you don't want the pool and the pump to be in the same area, or you have multiple pools per area.
var/obj/effect/water_overlay = null
/turf/open/indestructible/sound/pool/end
icon_state = "poolwall"
/turf/open/indestructible/sound/pool/Initialize(mapload)
. = ..()
water_overlay = new /obj/effect/overlay/poolwater(get_turf(src))
/turf/open/indestructible/sound/pool/Destroy()
if(water_overlay)
qdel(water_overlay)
return ..()
/turf/open/indestructible/sound/pool/examine(mob/user)
. = ..() // This is a list
if(!HAS_TRAIT(user,TRAIT_CLUMSY) && calculate_zap(user))
. += span_warning("It's probably not the best idea to jump in...")
/turf/open/indestructible/sound/pool/proc/set_colour(colour)
water_overlay.color = colour
/turf/open/CanPass(atom/movable/mover, turf/target)
var/datum/component/swimming/S = mover.GetComponent(/datum/component/swimming) //If you're swimming around, you don't really want to stop swimming just like that do you?
if(S)
return FALSE //If you're swimming, you can't swim into a regular turf, y'dig?
. = ..()
/turf/open/indestructible/sound/pool/CanPass(atom/movable/mover, turf/target)
if(mover.throwing)
return TRUE
var/datum/component/swimming/S = mover.GetComponent(/datum/component/swimming) //You can't get in the pool unless you're swimming.
return (isliving(mover)) ? S : ..() //So you can do stuff like throw beach balls around the pool!
/turf/open/indestructible/sound/pool/Entered(atom/movable/AM)
. = ..()
if(AM.throwing) //they haven't fallen in the pool until they stop being thrown
if(!AM._listen_lookup?[COMSIG_MOVABLE_THROW_LANDED]) //if they don't already have a throw_landed signal, add one
RegisterSignal(AM, COMSIG_MOVABLE_THROW_LANDED, PROC_REF(land_in_pool))
return
SEND_SIGNAL(AM, COMSIG_COMPONENT_CLEAN_ACT, 2)
playsound(src,'sound/effects/splash.ogg',50,TRUE)
if(isliving(AM))
var/datum/component/swimming/S = AM.GetComponent(/datum/component/swimming) //You can't get in the pool unless you're swimming.
if(!S)
var/mob/living/carbon/C = AM
var/component_type = /datum/component/swimming
if(istype(C) && C?.dna?.species)
component_type = C.dna.species.swimming_component
AM.AddComponent(component_type)
/turf/open/indestructible/sound/pool/Exited(atom/movable/Obj, atom/newloc)
. = ..()
if(!istype(newloc, /turf/open/indestructible/sound/pool))
var/datum/component/swimming/S = Obj.GetComponent(/datum/component/swimming) //Handling admin TPs here.
if(S)
qdel(S)
/turf/open/indestructible/sound/pool/proc/land_in_pool(atom/movable/thrown)
UnregisterSignal(thrown, COMSIG_MOVABLE_THROW_LANDED)
var/turf/open/indestructible/sound/pool/end = get_turf(thrown) //if the place they've ended is a pool, splash them in the pool
if(end && istype(end) && isliving(thrown))
end.splash(thrown)
var/datum/component/swimming/S = thrown.GetComponent(/datum/component/swimming) //You can't get in the pool unless you're swimming.
if(!S)
var/mob/living/carbon/C = thrown
var/component_type = /datum/component/swimming
if(istype(C) && C?.dna?.species)
component_type = C.dna.species.swimming_component
thrown.AddComponent(component_type)
/turf/open/MouseDrop_T(atom/dropping, mob/user)
. = ..()
if(!isliving(user) || !isliving(dropping)) //No I don't want ghosts to be able to dunk people into the pool.
return
var/atom/movable/AM = dropping
var/datum/component/swimming/S = dropping.GetComponent(/datum/component/swimming)
if(!S)
return
if(!do_after(user, 1 SECONDS, src))
return
qdel(S)
visible_message("<span class='notice'>[dropping] climbs out of the pool.</span>")
AM.forceMove(src)
/turf/open/indestructible/sound/pool/MouseDrop_T(atom/dropping, mob/user)
if(!isliving(user) || !isliving(dropping)) //No I don't want ghosts to be able to dunk people into the pool.
return
var/datum/component/swimming/S = dropping.GetComponent(/datum/component/swimming) //If they're already swimming, don't let them start swimming again.
if(S)
return FALSE
. = ..()
if(user != dropping)
dropping.visible_message("<span class='notice'>[user] starts to lower [dropping] down into [src].</span>", \
"<span class='notice'>You start to lower [dropping] down into [src].</span>")
else
to_chat(user, "<span class='notice'>You start climbing down into [src]...")
if(do_after(user, 4 SECONDS, dropping))
splash(dropping)
/datum/mood_event/poolparty
description = "<span class='nicegreen'>I love swimming!</span>\n"
mood_change = 2
timeout = 2 MINUTES
/datum/mood_event/robotpool
description = "<span class='warning'>I really wasn't built with water resistance in mind...</span>\n"
mood_change = -3
timeout = 2 MINUTES
/datum/mood_event/poolwet
description = "<span class='warning'>Eugh! My clothes are soaking wet from that swim.</span>\n"
mood_change = -4
timeout = 4 MINUTES
//Used to determine how zappy to be to a perhaps-electronic user entering this pool.
/turf/open/indestructible/sound/pool/proc/calculate_zap(mob/user)
var/zap = 0
if(issilicon(user)) //Do not throw brick in a pool. Brick begs.
zap = 10 //Sorry borgs! Swimming will come at a cost.
if(ishuman(user))
var/mob/living/carbon/human/F = user
var/datum/species/SS = F.dna.species
if(SS.inherent_biotypes & MOB_ROBOTIC) //ZAP goes preternis and IPC
zap = 10 * F.get_permeability(null, TRUE) //You can protect yourself from water damage with low permeability clothing
return zap
/turf/open/indestructible/sound/pool/proc/splash(mob/user)
user.forceMove(src)
playsound(src, 'sound/effects/splosh.ogg', 100, 1) //Credit to hippiestation for this sound file!
user.visible_message("<span class='boldwarning'>SPLASH!</span>")
var/zap = calculate_zap(user)
if(zap > 0)
user.emp_act(zap)
user.emote("scream") //Chad coders use M.say("*scream")
do_sparks(zap, TRUE, user)
to_chat(user, "<span class='userdanger'>WARNING: WATER DAMAGE DETECTED!</span>")
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "robotpool", /datum/mood_event/robotpool)
else
if(!check_clothes(user))
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "pool", /datum/mood_event/poolparty)
return
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "pool", /datum/mood_event/poolwet)
//Largely a copypaste from shower.dm. Checks if the mob was stupid enough to enter a pool fully clothed. We allow masks as to not discriminate against clown and mime players.
/turf/open/indestructible/sound/pool/proc/check_clothes(mob/living/carbon/human/H)
if(!istype(H) || iscatperson(H)) //Don't care about non humans.
return FALSE
if(H.wear_suit && (H.wear_suit.clothing_flags & SHOWEROKAY))
// Do not check underclothing if the over-suit is suitable.
// This stops people feeling dumb if they're showering
// with a radiation suit on.
return FALSE
. = FALSE
if(H.wear_suit && !(H.wear_suit.clothing_flags & SHOWEROKAY))
return TRUE
if(H.w_uniform && !(H.w_uniform.clothing_flags & SHOWEROKAY))
return TRUE
if(H.head && !(H.head.clothing_flags & SHOWEROKAY))
return TRUE
/turf/open/indestructible/sound/pool/singularity_act() // Pool's closed
playsound(src, 'sound/effects/splosh.ogg', 100, 1) // Slourmping up all the pool water is very sploshy.
visible_message(span_warning("The pool's water is sucked into the singularity!"))
for(var/turf/open/indestructible/sound/pool/water in get_area_turfs(get_area(src))) // Basically, we can just turn into plating or something.
if(water != src)
if(isnull(id) || id == water.id) // To make sure this is the same pool being drained
water.ChangeTurf(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
ChangeTurf(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
/obj/effect/turf_decal/pool
name = "Pool siding"
icon = 'icons/obj/pool.dmi'
icon_state = "poolborder"
/obj/effect/turf_decal/pool/corner
icon_state = "bordercorner"
/obj/effect/turf_decal/pool/innercorner
icon_state = "innercorner"
//Pool machinery
/obj/structure/pool_ladder
name = "Pool ladder"
desc = "Click this to get out of a pool quickly."
icon = 'icons/obj/pool.dmi'
icon_state = "ladder"
pixel_y = 12
var/reversed = FALSE
anchored = TRUE
/obj/structure/pool_ladder/reversed
reversed = TRUE
GLOBAL_LIST_EMPTY(pool_filters)
/obj/machinery/pool_filter
name = "Pool filter"
desc = "A device which can help you regulate conditions in a pool. Use a <b>wrench</b> to change its operating temperature, or hit it with a reagent container to load in new liquid to add to the pool."
icon = 'icons/obj/pool.dmi'
icon_state = "poolfilter"
pixel_y = 12 //So it sits above the water
idle_power_usage = IDLE_POWER_USE
var/id = null //change this if youre an annoying mapper who wants multiple pools per area.
var/list/pool = list()
var/desired_temperature = 300 //Room temperature
var/current_temperature = 300 //current temp
var/preset_reagent_type = null //Set this if you want your pump to start filled with a given reagent. SKEWIUM POOL SKEWIUM POOL!
var/temp_rate = 0.5
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
/obj/machinery/pool_filter/examine(mob/user)
. = ..()
. += "<span class='boldnotice'>The thermostat on it reads [current_temperature].</span>"
/obj/machinery/pool_filter/Initialize(mapload)
. = ..()
create_reagents(100, OPENCONTAINER) //If you're a terrible terrible clown and want to dump reagents into the pool.
if(preset_reagent_type)
reagents.add_reagent(preset_reagent_type, 100)
var/area/AR = get_area(src)
for(var/turf/open/indestructible/sound/pool/water in get_area_turfs(AR))
if(id && water.id != id)
continue //Not the same id. Fine. Ignore that one then!
pool += water
GLOB.pool_filters += src
//Brick can set the pool to low temperatures remotely. This will probably be hell on malf!
/obj/machinery/pool_filter/attack_robot(mob/user)
. = ..()
wrench_act(user, null)
/obj/machinery/pool_filter/attack_ai(mob/user)
. = ..()
wrench_act(user, null)
/obj/machinery/pool_filter/wrench_act(mob/living/user, obj/item/I)
. = ..()
var/newTemp = input(user, "Set a new temperature for [src] (Kelvin).", "[src]", null) as num
if(!newTemp)
return
newTemp = clamp(newTemp, T0C, 320)
desired_temperature = newTemp
return FALSE
/obj/machinery/pool_filter/process()
if(!LAZYLEN(pool) || !is_operational())
return //No use having one of these processing for no reason is there?
use_power(idle_power_usage)
if (current_temperature > desired_temperature)
current_temperature -= temp_rate
current_temperature = max(desired_temperature, current_temperature)
else if (current_temperature < desired_temperature)
current_temperature += temp_rate
current_temperature = min(desired_temperature, current_temperature)
var/trans_amount = reagents.total_volume / pool.len //Split up the reagents equally.
for(var/turf/open/indestructible/sound/pool/water as() in pool)
if(reagents.reagent_list.len)
water.set_colour(mix_color_from_reagents(reagents.reagent_list))
else
water.set_colour("#009999")
if(water.contents.len && reagents.total_volume > 0)
for(var/mob/living/M in water)
if(!istype(M))
continue
var/datum/reagents/splash_holder = new/datum/reagents(trans_amount) //Take some of our reagents out, react them with the pool denizens.
splash_holder.my_atom = water
reagents.trans_to(splash_holder, trans_amount, transfered_by = src)
splash_holder.chem_temp = current_temperature
if(prob(80))
splash_holder.reaction(M, TOUCH)
else //Sometimes the water penetrates a lil deeper than just a splosh.
splash_holder.reaction(M, INGEST)
splash_holder.trans_to(M, trans_amount, transfered_by = src) //Actually put reagents in the mob
qdel(splash_holder)
var/mob/living/carbon/C = M
if(current_temperature <= 283.5) //Colder than 10 degrees is going to make you very cold
if(iscarbon(M))
C.adjust_bodytemperature(-80, current_temperature)
to_chat(M, "<span class='warning'>The water is freezing cold!</span>")
else if(current_temperature >= 308.5) //Hotter than 35 celsius is going to make you burn up
if(iscarbon(M))
C.adjust_bodytemperature(35, 0, current_temperature)
if(!HAS_TRAIT(C, TRAIT_RESISTHEAT))
C.adjustFireLoss(5)
to_chat(M, "<span class='danger'>The water is searing hot!</span>")
else
if(iscarbon(M)) //if temperature is comfy, can be used to warm up or cool down
var/body_temperature_difference = current_temperature - C.bodytemperature
C.adjust_bodytemperature(min(100, body_temperature_difference))
/obj/structure/pool_ladder/attack_hand(mob/user)
var/datum/component/swimming/S = user.GetComponent(/datum/component/swimming)
if(S)
to_chat(user, "<span class='notice'>You start to climb out of the pool...</span>")
if(do_after(user, 1 SECONDS, src))
qdel(S)
visible_message("<span class='notice'>[user] climbs out of the pool.</span>")
if(!reversed)
user.forceMove(get_turf(get_step(src, NORTH))) //Ladders shouldn't adjoin another pool section. Ever.
else
user.forceMove(get_turf(get_step(src, SOUTH)))
else
to_chat(user, "<span class='notice'>You start to climb into the pool...</span>")
var/turf/T = get_turf(src)
if(do_after(user, 1 SECONDS, src))
if(!istype(T, /turf/open/indestructible/sound/pool)) //Ugh, fine. Whatever.
user.forceMove(get_turf(src))
else
var/turf/open/indestructible/sound/pool/P = T
P.splash(user)
/obj/structure/pool_ladder/attack_robot(mob/user)
. = ..()
attack_hand(user)