forked from ParadiseSS13/Paradise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
poolcontroller.dm
136 lines (115 loc) · 5.43 KB
/
poolcontroller.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
/obj/machinery/poolcontroller
name = "Pool Controller"
desc = "A controller for the nearby pool."
icon = 'icons/obj/airlock_machines.dmi'
icon_state = "airlock_control_standby"
var/list/linkedturfs = list() //List contains all of the linked pool turfs to this controller, assignment happens on New()
var/temperature = "normal" //The temperature of the pool, starts off on normal, which has no effects.
var/temperaturecolor = "" //used for nanoUI fancyness
var/srange = 5 //The range of the search for pool turfs, change this for bigger or smaller pools.
var/linkedmist = list() //Used to keep track of created mist
var/misted = 0 //Used to check for mist.
/obj/machinery/poolcontroller/New() //This proc automatically happens on world start
for(var/turf/simulated/floor/beach/water/W in range(srange,src)) //Search for /turf/simulated/floor/beach/water in the range of var/srange
src.linkedturfs += W //Add found pool turfs to the central list.
..() //Changed to call parent as per MarkvA's recommendation
/obj/machinery/poolcontroller/emag_act(user as mob) //Emag_act, this is called when it is hit with a cryptographic sequencer.
if(!emagged) //If it is not already emagged, emag it.
user << "\red You disable \the [src]'s temperature safeguards." //Inform the mob of what emagging does.
emagged = 1 //Set the emag var to true.
/obj/machinery/poolcontroller/attackby(obj/item/P as obj, mob/user as mob, params) //Proc is called when a user hits the pool controller with something.
if(istype(P,/obj/item/device/multitool)) //If the mob hits the pool controller with a multitool, reset the emagged status
if(emagged) //Check the emag status
user << "\red You re-enable \the [src]'s temperature safeguards." //Inform the user that they have just fixed the safeguards.
emagged = 0 //Set the emagged var to false.
return
else
user << "\red Nothing happens." //If not emagged, don't do anything, and don't tell the user that it can be emagged.
return //Return, nothing else needs to be done.
else //If it's not a multitool, defer to /obj/machinery/attackby
..()
/obj/machinery/poolcontroller/attack_hand(mob/user as mob)
ui_interact(user)
/obj/machinery/poolcontroller/process()
updateMobs() //Call the mob affecting proc
/obj/machinery/poolcontroller/proc/updateMobs()
for(var/turf/simulated/floor/beach/water/W in linkedturfs) //Check for pool-turfs linked to the controller.
for(var/mob/M in W) //Check for mobs in the linked pool-turfs.
//Sanity checks, don't affect robuts, AI eyes, and observers
if(isAIEye(M))
return
if(issilicon(M))
return
if(isobserver(M))
return
//End sanity checks, go on
switch(temperature) //Apply different effects based on what the temperature is set to.
if("scalding") //Burn the mob.
M.bodytemperature = min(500, M.bodytemperature + 35) //heat mob at 35k(elvin) per cycle
M << "<span class='danger'>The water is searing hot!</span>"
return
if("frigid") //Freeze the mob.
M.bodytemperature = max(80, M.bodytemperature - 35) //cool mob at -35k per cycle
M << "<span class='danger'>The water is freezing!</span>"
return
if("normal") //Normal temp does nothing, because it's just room temperature water.
return
if("warm") //Gently warm the mob.
M.bodytemperature = min(330, M.bodytemperature + 10) //Heats up mobs to just over normal, not enough to burn
if(prob(50)) //inform the mob of warm water half the time
M << "<span class='warning'>The water is quite warm.</span>" //Inform the mob it's warm water.
return
if("cool") //Gently cool the mob.
M.bodytemperature = max(290, M.bodytemperature - 10) //Cools mobs to just below normal, not enough to burn
if(prob(50)) //inform the mob of cold water half the time
M << "<span class='warning'>The water is chilly.</span>" //Inform the mob it's chilly water.
return
/obj/machinery/poolcontroller/proc/miston() //Spawn /obj/effect/mist (from the shower) on all linked pool tiles
for(var/turf/simulated/floor/beach/water/W in linkedturfs)
var/M = new /obj/effect/mist(W)
if(misted)
return
linkedmist += M
misted = 1 //var just to keep track of when the mist on proc has been called.
/obj/machinery/poolcontroller/proc/mistoff() //Delete all /obj/effect/mist from all linked pool tiles.
for(var/obj/effect/mist/M in linkedmist)
del(M)
misted = 0 //no mist left, turn off the tracking var
/obj/machinery/poolcontroller/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
var/data[0]
data["currentTemp"] = capitalize(src.temperature)
data["emagged"] = emagged
data["TempColor"] = temperaturecolor
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "poolcontroller.tmpl", "Pool Controller Interface", 520, 410)
ui.set_initial_data(data)
ui.open()
/obj/machinery/poolcontroller/Topic(href, href_list)
if(..()) return 1
switch(href_list["temp"])
if("Scalding")
if(!src.emagged)
return 0
src.temperature = "scalding"
src.temperaturecolor = "#FF0000"
miston()
if("Frigid")
if(!src.emagged)
return 0
src.temperature = "frigid"
src.temperaturecolor = "#00CCCC"
mistoff()
if("Warm")
src.temperature = "warm"
src.temperaturecolor = "#990000"
mistoff()
if("Cool")
src.temperature = "cool"
src.temperaturecolor = "#009999"
mistoff()
if("Normal")
src.temperature = "normal"
src.temperaturecolor = ""
mistoff()
return 1