/
mineral_doors.dm
350 lines (281 loc) · 10.5 KB
/
mineral_doors.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
//NOT using the existing /obj/machinery/door type, since that has some complications on its own, mainly based on its
//machineryness
/obj/structure/mineral_door
name = "metal door"
density = TRUE
anchored = TRUE
opacity = TRUE
layer = CLOSED_DOOR_LAYER
icon = 'icons/obj/doors/mineral_doors.dmi'
icon_state = "metal"
max_integrity = 200
armor = list("melee" = 10, "bullet" = 0, "laser" = 0, "energy" = 100, "bomb" = 10, "bio" = 100, "rad" = 100, "fire" = 50, "acid" = 50)
CanAtmosPass = ATMOS_PASS_DENSITY
flags_1 = RAD_PROTECT_CONTENTS_1 | RAD_NO_CONTAMINATE_1
rad_insulation = RAD_MEDIUM_INSULATION
var/door_opened = FALSE //if it's open or not.
var/isSwitchingStates = FALSE //don't try to change stats if we're already opening
var/close_delay = -1 //-1 if does not auto close.
var/openSound = 'sound/effects/stonedoor_openclose.ogg'
var/closeSound = 'sound/effects/stonedoor_openclose.ogg'
var/sheetType = /obj/item/stack/sheet/metal //what we're made of
var/sheetAmount = 7 //how much we drop when deconstructed
/obj/structure/mineral_door/Initialize()
. = ..()
air_update_turf(TRUE)
/obj/structure/mineral_door/Move()
var/turf/T = loc
. = ..()
move_update_air(T)
/obj/structure/mineral_door/Bumped(atom/movable/AM)
..()
if(!door_opened)
return TryToSwitchState(AM)
/obj/structure/mineral_door/attack_ai(mob/user) //those aren't machinery, they're just big fucking slabs of a mineral
if(isAI(user)) //so the AI can't open it
return
else if(iscyborg(user)) //but cyborgs can
if(get_dist(user,src) <= 1) //not remotely though
return TryToSwitchState(user)
/obj/structure/mineral_door/attack_paw(mob/user)
return attack_hand(user)
/obj/structure/mineral_door/attack_hand(mob/user)
. = ..()
if(.)
return
return TryToSwitchState(user)
/obj/structure/mineral_door/CanAllowThrough(atom/movable/mover, turf/target)
. = ..()
if(istype(mover, /obj/effect/beam))
return !opacity
/obj/structure/mineral_door/proc/TryToSwitchState(atom/user)
if(isSwitchingStates || !anchored)
return
if(isliving(user))
var/mob/living/M = user
if(world.time - M.last_bumped <= 60)
return //NOTE do we really need that?
if(M.client)
if(iscarbon(M))
var/mob/living/carbon/C = M
if(!C.handcuffed)
SwitchState()
else
SwitchState()
else if(ismecha(user))
SwitchState()
/obj/structure/mineral_door/proc/SwitchState()
if(door_opened)
Close()
else
Open()
/obj/structure/mineral_door/proc/Open()
isSwitchingStates = TRUE
playsound(src, openSound, 100, TRUE)
set_opacity(FALSE)
flick("[initial(icon_state)]opening",src)
sleep(10)
density = FALSE
door_opened = TRUE
layer = OPEN_DOOR_LAYER
air_update_turf(1)
update_icon()
isSwitchingStates = FALSE
if(close_delay != -1)
addtimer(CALLBACK(src, .proc/Close), close_delay)
/obj/structure/mineral_door/proc/Close()
if(isSwitchingStates || !door_opened)
return
var/turf/T = get_turf(src)
for(var/mob/living/L in T)
return
isSwitchingStates = TRUE
playsound(src, closeSound, 100, TRUE)
flick("[initial(icon_state)]closing",src)
sleep(10)
density = TRUE
set_opacity(TRUE)
door_opened = FALSE
layer = initial(layer)
air_update_turf(1)
update_icon()
isSwitchingStates = FALSE
/obj/structure/mineral_door/update_icon_state()
icon_state = "[initial(icon_state)][door_opened ? "open":""]"
/obj/structure/mineral_door/attackby(obj/item/I, mob/user)
if(pickaxe_door(user, I))
return
else if(user.a_intent != INTENT_HARM)
return attack_hand(user)
else
return ..()
/obj/structure/mineral_door/set_anchored(anchorvalue) //called in default_unfasten_wrench() chain
. = ..()
set_opacity(anchored ? !door_opened : FALSE)
air_update_turf(TRUE)
/obj/structure/mineral_door/wrench_act(mob/living/user, obj/item/I)
..()
default_unfasten_wrench(user, I, 40)
return TRUE
/////////////////////// TOOL OVERRIDES ///////////////////////
/obj/structure/mineral_door/proc/pickaxe_door(mob/living/user, obj/item/I) //override if the door isn't supposed to be a minable mineral.
if(!istype(user))
return
if(I.tool_behaviour != TOOL_MINING)
return
. = TRUE
to_chat(user, "<span class='notice'>You start digging [src]...</span>")
if(I.use_tool(src, user, 40, volume=50))
to_chat(user, "<span class='notice'>You finish digging.</span>")
deconstruct(TRUE)
/obj/structure/mineral_door/welder_act(mob/living/user, obj/item/I) //override if the door is supposed to be flammable.
..()
. = TRUE
if(anchored)
to_chat(user, "<span class='warning'>[src] is still firmly secured to the ground!</span>")
return
user.visible_message("<span class='notice'>[user] starts to weld apart [src]!</span>", "<span class='notice'>You start welding apart [src].</span>")
if(!I.use_tool(src, user, 60, 5, 50))
to_chat(user, "<span class='warning'>You failed to weld apart [src]!</span>")
return
user.visible_message("<span class='notice'>[user] welded [src] into pieces!</span>", "<span class='notice'>You welded apart [src]!</span>")
deconstruct(TRUE)
/obj/structure/mineral_door/proc/crowbar_door(mob/living/user, obj/item/I) //if the door is flammable, call this in crowbar_act() so we can still decon it
. = TRUE
if(anchored)
to_chat(user, "<span class='warning'>[src] is still firmly secured to the ground!</span>")
return
user.visible_message("<span class='notice'>[user] starts to pry apart [src]!</span>", "<span class='notice'>You start prying apart [src].</span>")
if(!I.use_tool(src, user, 60, volume = 50))
to_chat(user, "<span class='warning'>You failed to pry apart [src]!</span>")
return
user.visible_message("<span class='notice'>[user] pried [src] into pieces!</span>", "<span class='notice'>You pried apart [src]!</span>")
deconstruct(TRUE)
/////////////////////// END TOOL OVERRIDES ///////////////////////
/obj/structure/mineral_door/deconstruct(disassembled = TRUE)
var/turf/T = get_turf(src)
if(disassembled)
new sheetType(T, sheetAmount)
else
new sheetType(T, max(sheetAmount - 2, 1))
qdel(src)
/obj/structure/mineral_door/iron
name = "iron door"
max_integrity = 300
/obj/structure/mineral_door/silver
name = "silver door"
icon_state = "silver"
sheetType = /obj/item/stack/sheet/mineral/silver
max_integrity = 300
rad_insulation = RAD_HEAVY_INSULATION
/obj/structure/mineral_door/gold
name = "gold door"
icon_state = "gold"
sheetType = /obj/item/stack/sheet/mineral/gold
rad_insulation = RAD_HEAVY_INSULATION
/obj/structure/mineral_door/uranium
name = "uranium door"
icon_state = "uranium"
sheetType = /obj/item/stack/sheet/mineral/uranium
max_integrity = 300
light_range = 2
/obj/structure/mineral_door/uranium/ComponentInitialize()
return
/obj/structure/mineral_door/sandstone
name = "sandstone door"
icon_state = "sandstone"
sheetType = /obj/item/stack/sheet/mineral/sandstone
max_integrity = 100
/obj/structure/mineral_door/transparent
opacity = FALSE
rad_insulation = RAD_VERY_LIGHT_INSULATION
/obj/structure/mineral_door/transparent/Close()
..()
set_opacity(FALSE)
/obj/structure/mineral_door/transparent/plasma
name = "plasma door"
icon_state = "plasma"
sheetType = /obj/item/stack/sheet/mineral/plasma
/obj/structure/mineral_door/transparent/plasma/ComponentInitialize()
return
/obj/structure/mineral_door/transparent/plasma/welder_act(mob/living/user, obj/item/I)
return
/obj/structure/mineral_door/transparent/plasma/attackby(obj/item/W, mob/user, params)
if(W.get_temperature())
var/turf/T = get_turf(src)
message_admins("Plasma mineral door ignited by [ADMIN_LOOKUPFLW(user)] in [ADMIN_VERBOSEJMP(T)]")
log_game("Plasma mineral door ignited by [key_name(user)] in [AREACOORD(T)]")
TemperatureAct()
else
return ..()
/obj/structure/mineral_door/transparent/plasma/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(exposed_temperature > 300)
TemperatureAct()
/obj/structure/mineral_door/transparent/plasma/proc/TemperatureAct()
atmos_spawn_air("plasma=500;TEMP=1000")
deconstruct(FALSE)
/obj/structure/mineral_door/transparent/diamond
name = "diamond door"
icon_state = "diamond"
sheetType = /obj/item/stack/sheet/mineral/diamond
max_integrity = 1000
rad_insulation = RAD_EXTREME_INSULATION
/obj/structure/mineral_door/wood
name = "wood door"
icon_state = "wood"
openSound = 'sound/effects/doorcreaky.ogg'
closeSound = 'sound/effects/doorcreaky.ogg'
sheetType = /obj/item/stack/sheet/mineral/wood
resistance_flags = FLAMMABLE
max_integrity = 200
rad_insulation = RAD_VERY_LIGHT_INSULATION
/obj/structure/mineral_door/wood/pickaxe_door(mob/living/user, obj/item/I)
return
/obj/structure/mineral_door/wood/welder_act(mob/living/user, obj/item/I)
return
/obj/structure/mineral_door/wood/crowbar_act(mob/living/user, obj/item/I)
return crowbar_door(user, I)
/obj/structure/mineral_door/wood/attackby(obj/item/I, mob/living/user)
if(I.get_temperature())
fire_act(I.get_temperature())
return
return ..()
/obj/structure/mineral_door/paperframe
name = "paper frame door"
icon_state = "paperframe"
openSound = 'sound/effects/doorcreaky.ogg'
closeSound = 'sound/effects/doorcreaky.ogg'
sheetType = /obj/item/stack/sheet/paperframes
sheetAmount = 3
resistance_flags = FLAMMABLE
max_integrity = 20
/obj/structure/mineral_door/paperframe/Initialize()
. = ..()
QUEUE_SMOOTH_NEIGHBORS(src)
/obj/structure/mineral_door/paperframe/examine(mob/user)
. = ..()
if(obj_integrity < max_integrity)
. += "<span class='info'>It looks a bit damaged, you may be able to fix it with some <b>paper</b>.</span>"
/obj/structure/mineral_door/paperframe/pickaxe_door(mob/living/user, obj/item/I)
return
/obj/structure/mineral_door/paperframe/welder_act(mob/living/user, obj/item/I)
return
/obj/structure/mineral_door/paperframe/crowbar_act(mob/living/user, obj/item/I)
return crowbar_door(user, I)
/obj/structure/mineral_door/paperframe/attackby(obj/item/I, mob/living/user)
if(I.get_temperature()) //BURN IT ALL DOWN JIM
fire_act(I.get_temperature())
return
if((user.a_intent != INTENT_HARM) && istype(I, /obj/item/paper) && (obj_integrity < max_integrity))
user.visible_message("<span class='notice'>[user] starts to patch the holes in [src].</span>", "<span class='notice'>You start patching some of the holes in [src]!</span>")
if(do_after(user, 20, TRUE, src))
obj_integrity = min(obj_integrity+4,max_integrity)
qdel(I)
user.visible_message("<span class='notice'>[user] patches some of the holes in [src].</span>", "<span class='notice'>You patch some of the holes in [src]!</span>")
return TRUE
return ..()
/obj/structure/mineral_door/paperframe/ComponentInitialize()
return
/obj/structure/mineral_door/paperframe/Destroy()
QUEUE_SMOOTH_NEIGHBORS(src)
return ..()