/
candle.dm
160 lines (133 loc) · 3.78 KB
/
candle.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
#define TALL_CANDLE 1
#define MID_CANDLE 2
#define SHORT_CANDLE 3
/obj/item/candle
name = "red candle"
desc = "In Greek myth, Prometheus stole fire from the Gods and gave it to humankind. The jewelry he kept for himself."
icon = 'icons/obj/candle.dmi'
icon_state = "candle1"
item_state = "candle1"
w_class = WEIGHT_CLASS_TINY
var/wax = 200
/// Index for the icon state
var/wax_index = TALL_CANDLE
var/lit = FALSE
var/infinite = FALSE
var/start_lit = FALSE
var/flickering = FALSE
light_color = "#E09D37"
/obj/item/candle/New()
..()
if(start_lit)
// No visible message
light(show_message = 0)
/obj/item/candle/Destroy()
STOP_PROCESSING(SSobj, src)
return ..()
/obj/item/candle/update_icon_state()
if(flickering)
icon_state = "candle[wax_index]_flicker"
else
icon_state = "candle[wax_index][lit ? "_lit" : ""]"
/obj/item/candle/can_enter_storage(obj/item/storage/S, mob/user)
if(lit)
to_chat(user, "<span class='warning'>[S] can't hold [src] while it's lit!</span>")
return FALSE
else
return TRUE
/obj/item/candle/attackby(obj/item/W, mob/user, params)
if(W.get_heat())
light("<span class='notice'>[user] lights [src] with [W].</span>")
return
return ..()
/obj/item/candle/welder_act(mob/user, obj/item/I)
. = TRUE
if(I.tool_use_check(user, 0)) //Don't need to flash eyes because you are a badass
light("<span class='notice'>[user] casually lights [src] with [I], what a badass.</span>")
/obj/item/candle/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume, global_overlay = TRUE)
if(!lit)
light() //honk
return ..()
/obj/item/candle/proc/light(show_message)
if(!lit)
lit = TRUE
if(show_message)
usr.visible_message(show_message)
set_light(CANDLE_LUM)
START_PROCESSING(SSobj, src)
update_icon(UPDATE_ICON_STATE)
/obj/item/candle/proc/update_wax_index()
var/new_wax_index
if(wax > 150)
new_wax_index = TALL_CANDLE
else if(wax > 80)
new_wax_index = MID_CANDLE
else
new_wax_index = SHORT_CANDLE
if(wax_index != new_wax_index)
wax_index = new_wax_index
return TRUE
return FALSE
/obj/item/candle/proc/start_flickering()
flickering = TRUE
update_icon(UPDATE_ICON_STATE)
addtimer(CALLBACK(src, PROC_REF(stop_flickering)), 4 SECONDS, TIMER_UNIQUE)
/obj/item/candle/proc/stop_flickering()
flickering = FALSE
update_icon(UPDATE_ICON_STATE)
/obj/item/candle/process()
if(!lit)
return
if(!infinite)
wax--
if(wax_index != SHORT_CANDLE) // It's not at its shortest
if(update_wax_index())
update_icon(UPDATE_ICON_STATE)
if(!wax)
new/obj/item/trash/candle(src.loc)
if(ismob(src.loc))
var/mob/M = src.loc
M.unEquip(src, 1) //src is being deleted anyway
qdel(src)
if(isturf(loc)) //start a fire if possible
var/turf/T = loc
T.hotspot_expose(700, 5)
/obj/item/candle/proc/unlight()
if(lit)
lit = FALSE
update_icon(UPDATE_ICON_STATE)
set_light(0)
/obj/item/candle/attack_self(mob/user)
if(lit)
user.visible_message("<span class='notice'>[user] snuffs out [src].</span>")
unlight()
/obj/item/candle/eternal
desc = "A candle. This one seems to have an odd quality about the wax."
infinite = TRUE
/obj/item/candle/get_spooked()
if(lit)
start_flickering()
playsound(src, 'sound/effects/candle_flicker.ogg', 15, 1)
return TRUE
return FALSE
/obj/item/candle/eternal/wizard
desc = "A candle. It smells like magic, so that would explain why it burns brighter."
start_lit = TRUE
/obj/item/candle/eternal/wizard/attack_self(mob/user)
return
/obj/item/candle/eternal/wizard/process()
return
/obj/item/candle/eternal/wizard/light(show_message)
. = ..()
if(lit)
set_light(CANDLE_LUM * 2)
/obj/item/candle/extinguish_light(force)
if(!force)
return
infinite = FALSE
wax = 1 // next process will burn it out
/obj/item/candle/get_heat()
return lit * 1000
#undef TALL_CANDLE
#undef MID_CANDLE
#undef SHORT_CANDLE