-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy path_flame.dm
233 lines (189 loc) · 6.2 KB
/
_flame.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
//For anything that can light stuff on fire
/obj/item/flame
abstract_type = /obj/item/flame
icon_state = ICON_STATE_WORLD
w_class = ITEM_SIZE_TINY
origin_tech = @'{"materials":1}'
material = /decl/material/solid/organic/wood/oak
/// Parameters for lighting when lit.
var/lit_light_range = 1
var/lit_light_power = 0.5
var/lit_light_color = "#e09d37"
/// Does this flame source smell of anything when burning?
var/decl/scent_type/scent
/// Is this item extinguished by being dropped?
var/extinguish_on_dropped = TRUE
/// How hot does this burn?
var/lit_heat = 1000
/// Can this item be extinguished by water?
var/waterproof = FALSE
/// Is this item currently lit?
var/lit = FALSE
/// How many SSobj ticks can this burn for?
var/_fuel = 0
/// How much fuel does this spend in a tick?
var/_fuel_spend_amt = 1
/// Can you put this item out with your hand?
var/can_manually_extinguish = TRUE
/// Can you light this item with your hand?
var/can_manually_light = FALSE
/// Can this item be put into a sconce?
var/sconce_can_hold = FALSE
/// Can this item go in a bag or storage slot while lit?
var/can_store_lit = FALSE
/obj/item/flame/Initialize(var/ml, var/material_key)
var/list/available_scents = get_available_scents()
if(LAZYLEN(available_scents))
scent = pick(available_scents)
scent = GET_DECL(scent)
if(istype(scent))
if(scent.color)
set_color(scent.color)
desc += " This one smells of [scent.scent]."
else
scent = null
. = ..()
set_extension(src, /datum/extension/tool, list(TOOL_CAUTERY = TOOL_QUALITY_BAD))
update_icon()
if(istype(loc, /obj/structure/wall_sconce))
loc.update_icon()
/obj/item/flame/Destroy()
snuff_out(null, TRUE)
return ..()
/obj/item/flame/proc/get_available_scents()
return null
/obj/item/flame/proc/get_sconce_overlay()
return null
/obj/item/flame/get_tool_quality(archetype)
return (!lit && archetype == TOOL_CAUTERY) ? TOOL_QUALITY_NONE : ..()
/obj/item/flame/proc/has_fuel(amount)
return get_fuel() >= amount
/obj/item/flame/proc/light(mob/user, no_message)
// TODO: check for oxidizer
if(lit || !has_fuel(_fuel_spend_amt))
return FALSE
lit = TRUE
if(!can_store_lit)
obj_flags |= OBJ_FLAG_NO_STORAGE
atom_damage_type = BURN
update_attack_force()
update_icon()
if(istype(loc, /obj/structure/wall_sconce))
loc.update_icon()
if(!no_message && user)
user.visible_message(
SPAN_NOTICE("\The [user] lights \the [src]."),
SPAN_NOTICE("You light \the [src].")
)
if(!is_processing)
START_PROCESSING(SSobj, src)
if(scent)
set_extension(src, scent.scent_datum)
if(lit_light_range && lit_light_power)
set_light(lit_light_range, lit_light_power, lit_light_color)
return TRUE
/obj/item/flame/use_on_mob(mob/living/target, mob/living/user, animate = TRUE)
if(!istype(target) || user.check_intent(I_FLAG_HARM) || !lit || user.get_target_zone() != BP_MOUTH)
return ..()
var/obj/item/clothing/mask/smokable/cigarette/cig = target.get_equipped_item(slot_wear_mask_str)
if(istype(cig))
if(target == user)
cig.attackby(src, user)
else
cig.light(SPAN_NOTICE("\The [user] holds \the [src] out for \the [target], and lights \the [cig]."))
return TRUE
return ..()
/obj/item/flame/proc/snuff_out(mob/user, no_message = FALSE)
if(!lit)
return FALSE
lit = FALSE
if(!can_store_lit && !(initial(obj_flags) & OBJ_FLAG_NO_STORAGE)) // only disable it if it wasn't already set
obj_flags &= ~OBJ_FLAG_NO_STORAGE
atom_damage_type = BRUTE
update_attack_force()
update_icon()
if(ismob(loc)) // not very robust for things like accessories...
update_held_icon()
update_clothing_icon()
if(istype(loc, /obj/structure/wall_sconce))
loc.update_icon()
set_light(0)
if(scent)
remove_extension(src, /datum/extension/scent)
if(is_processing)
STOP_PROCESSING(SSobj, src)
if(!no_message)
visible_message(SPAN_NOTICE("\The [src] goes out."))
return TRUE
/obj/item/flame/attack_self(mob/user)
if(!lit && can_manually_light)
if(has_fuel(_fuel_spend_amt))
light(user)
else
to_chat(user, SPAN_WARNING("\The [src] won't ignite. It must be out of fuel."))
return TRUE
if(lit && can_manually_extinguish)
snuff_out(user)
return TRUE
return ..()
/obj/item/flame/fluid_act(var/datum/reagents/fluids)
..()
if(QDELETED(src) || !fluids?.total_volume || !lit)
return
var/turf/location = get_turf(src)
if(location)
location.hotspot_expose(700, 5) // Potentially set fire to fuel etc.
if(QDELETED(src) || !fluids?.total_volume)
return
if(waterproof)
return
if(fluids.total_volume >= FLUID_PUDDLE)
snuff_out(no_message = TRUE)
/obj/item/flame/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
. = ..()
if(!QDELETED(src) && !can_manually_light)
light(null, TRUE)
/obj/item/flame/get_heat()
return max(..(), lit ? lit_heat : 0)
/obj/item/flame/can_puncture()
return lit
/obj/item/flame/isflamesource()
return lit
/obj/item/flame/proc/get_fuel()
return _fuel
/obj/item/flame/proc/expend_fuel(amount)
_fuel = max(0, get_fuel()-amount)
return has_fuel(_fuel_spend_amt)
/obj/item/flame/resolve_attackby(var/atom/A, mob/user)
. = ..()
if(istype(A, /obj/item/flame) && lit)
var/obj/item/flame/other = A
if(!other.can_manually_light)
other.light(user)
/obj/item/flame/attackby(obj/item/used_item, mob/user)
if(!user.check_intent(I_FLAG_HARM) && !can_manually_light && (used_item.isflamesource() || used_item.get_heat() > T100C))
light(user)
return TRUE
return ..()
/obj/item/flame/Process()
if((!waterproof && submerged()) || !expend_fuel(_fuel_spend_amt))
snuff_out()
return PROCESS_KILL
update_icon()
if(loc)
loc.ignite_fire()
var/turf/my_turf = get_turf(src)
if(my_turf)
my_turf.hotspot_expose(get_heat(), w_class)
/obj/item/flame/dropped(var/mob/user)
//If dropped, put ourselves out
//not before lighting up the turf we land on, though.
if(lit && extinguish_on_dropped)
var/turf/location = loc
if(istype(location))
location.hotspot_expose(700, 5)
snuff_out()
return ..()
/obj/item/flame/spark_act(obj/effect/sparks/sparks)
if(!can_manually_light)
light(null, no_message = TRUE)