|
13 | 13 |
|
14 | 14 | var/area/holodeck/linkedholodeck = null |
15 | 15 | var/linkedholodeck_area |
16 | | - var/active = 0 |
| 16 | + var/active = FALSE |
17 | 17 | var/list/holographic_objs = list() |
18 | 18 | var/list/holographic_mobs = list() |
19 | | - var/damaged = 0 |
20 | | - var/safety_disabled = 0 |
| 19 | + var/list/obj_buffer = list() |
| 20 | + var/damaged = FALSE |
| 21 | + var/safety_disabled = FALSE |
21 | 22 | var/mob/last_to_emag = null |
22 | 23 | var/last_change = 0 |
23 | 24 | var/last_gravity_change = 0 |
24 | 25 | var/list/supported_programs |
25 | 26 | var/list/restricted_programs |
| 27 | + var/lastprogram = "turnoff" |
26 | 28 |
|
27 | 29 | /obj/machinery/computer/HolodeckControl/New() |
28 | 30 | ..() |
|
31 | 33 | supported_programs = list() |
32 | 34 | restricted_programs = list() |
33 | 35 |
|
34 | | -/obj/machinery/computer/HolodeckControl/attack_hand(var/mob/user as mob) |
| 36 | +/obj/machinery/computer/HolodeckControl/attack_hand(mob/user as mob) |
35 | 37 | if(..()) |
36 | 38 | return 1 |
37 | 39 | user.set_machine(src) |
|
56 | 58 | dat += "<A href='?src=\ref[src];program=[supported_programs[prog]]'>([prog])</A><BR>" |
57 | 59 |
|
58 | 60 | dat += "<BR>" |
59 | | - dat += "<A href='?src=\ref[src];program=turnoff'>(Turn Off)</A><BR>" |
| 61 | + var/togglething = !active |
| 62 | + dat += "<A href='?src=\ref[src];toggle=[togglething]'>(Turn [active ? "Off" : "On"])</A><BR>" |
60 | 63 |
|
61 | 64 | dat += "<BR>" |
62 | 65 | dat += "Please ensure that only holographic weapons are used in the holodeck if a combat simulation has been loaded.<BR>" |
|
97 | 100 |
|
98 | 101 | usr.set_machine(src) |
99 | 102 |
|
100 | | - if(href_list["program"]) |
| 103 | + if(!isnull(href_list["toggle"])) |
| 104 | + togglePower(text2num(href_list["toggle"])) |
| 105 | + |
| 106 | + else if(href_list["program"]) |
101 | 107 | var/prog = href_list["program"] |
102 | 108 | if(prog in holodeck_programs) |
103 | | - loadProgram(holodeck_programs[prog]) |
| 109 | + loadProgram(prog) |
104 | 110 |
|
105 | 111 | else if(href_list["AIoverride"]) |
106 | 112 | if(!issilicon(usr)) |
|
124 | 130 | src.updateUsrDialog() |
125 | 131 | return |
126 | 132 |
|
127 | | -/obj/machinery/computer/HolodeckControl/emag_act(var/remaining_charges, var/mob/user as mob) |
| 133 | +/obj/machinery/computer/HolodeckControl/emag_act(remaining_charges, mob/user as mob) |
128 | 134 | playsound(src.loc, 'sound/effects/sparks4.ogg', 75, 1) |
129 | 135 | last_to_emag = user //emag again to change the owner |
130 | 136 | if (!emagged) |
131 | | - emagged = 1 |
132 | | - safety_disabled = 1 |
| 137 | + emagged = TRUE |
| 138 | + safety_disabled = TRUE |
133 | 139 | update_projections() |
134 | 140 | to_chat(user, SPAN_NOTICE("You vastly increase projector power and override the safety and security protocols.")) |
135 | 141 | to_chat(user, "Warning. Automatic shutoff and derezing protocols have been corrupted. Please call [company_name] maintenance and do not use the simulator.") |
|
157 | 163 | //This could all be done better, but it works for now. |
158 | 164 | /obj/machinery/computer/HolodeckControl/Destroy() |
159 | 165 | emergencyShutdown() |
| 166 | + clearbuffer() |
160 | 167 | . = ..() |
161 | 168 |
|
162 | 169 | /obj/machinery/computer/HolodeckControl/explosion_act(target_power, explosion_handler/handler) |
163 | 170 | emergencyShutdown() |
| 171 | + clearbuffer() |
164 | 172 | . = ..() |
165 | 173 |
|
166 | 174 | /obj/machinery/computer/HolodeckControl/power_change() |
|
172 | 180 | /obj/machinery/computer/HolodeckControl/Process() |
173 | 181 | for(var/item in holographic_objs) // do this first, to make sure people don't take items out when power is down. |
174 | 182 | if(!(get_turf(item) in linkedholodeck)) |
175 | | - derez(item, 0) |
| 183 | + derez(item, FALSE) |
176 | 184 |
|
177 | 185 | if (!safety_disabled) |
178 | 186 | for(var/mob/living/simple_animal/hostile/carp/holodeck/C in holographic_mobs) |
|
185 | 193 | if(active) |
186 | 194 | use_power(item_power_usage * (holographic_objs.len + holographic_mobs.len)) |
187 | 195 | if(!checkInteg(linkedholodeck)) |
188 | | - damaged = 1 |
189 | | - loadProgram(holodeck_programs["turnoff"], 0) |
190 | | - active = 0 |
| 196 | + damaged = TRUE |
| 197 | + loadProgram("turnoff", 0) |
| 198 | + clearbuffer() |
| 199 | + active = FALSE |
191 | 200 | set_power_use(IDLE_POWER_USE) |
192 | 201 | for(var/mob/M in range(10,src)) |
193 | 202 | M.show_message("The holodeck overloads!") |
|
201 | 210 | T.explosion_act(100, null) |
202 | 211 | T.hotspot_expose(1000,500,1) |
203 | 212 |
|
204 | | -/obj/machinery/computer/HolodeckControl/proc/derez(var/obj/obj , var/silent = 1) |
205 | | - holographic_objs.Remove(obj) |
206 | 213 |
|
207 | | - if(obj == null) |
| 214 | +/datum/holoposition |
| 215 | + var/holx |
| 216 | + var/holy |
| 217 | + var/holz |
| 218 | + var/holotype |
| 219 | + var/datum/weakref/trueobj |
| 220 | + |
| 221 | +/datum/holoposition/proc/setup(obj/refobj) |
| 222 | + holx = refobj.x |
| 223 | + holy = refobj.y |
| 224 | + holz = refobj.z |
| 225 | + holotype = refobj.type |
| 226 | + trueobj = WEAKREF(refobj) |
| 227 | + |
| 228 | +// clears the off-state buffer |
| 229 | +/obj/machinery/computer/HolodeckControl/proc/clearbuffer() |
| 230 | + for(var/datum/holoposition/toclear in obj_buffer) |
| 231 | + var/obj/resolved = toclear.trueobj.resolve() |
| 232 | + if(resolved) |
| 233 | + qdel(resolved) |
| 234 | + QDEL_LIST(obj_buffer) |
| 235 | + |
| 236 | +/obj/machinery/computer/HolodeckControl/proc/derez(obj/gone , silent = TRUE, buffer = FALSE) |
| 237 | + if(gone == null) |
| 238 | + to_chat(world, "nullobj") |
208 | 239 | return |
209 | 240 |
|
210 | | - if(isobj(obj)) |
211 | | - var/mob/M = obj.loc |
| 241 | + holographic_objs.Remove(gone) |
| 242 | + to_chat(world, "gone") |
| 243 | + if(isobj(gone)) |
| 244 | + if(buffer) |
| 245 | + var/datum/holoposition/holofile = new() |
| 246 | + holofile.setup(gone) |
| 247 | + obj_buffer.Add(holofile) |
| 248 | + var/mob/M = gone.loc |
212 | 249 | if(ismob(M)) |
213 | | - M.remove_from_mob(obj) |
| 250 | + M.remove_from_mob(gone) |
214 | 251 | M.update_icons() //so their overlays update |
215 | 252 |
|
216 | 253 | if(!silent) |
217 | | - var/obj/oldobj = obj |
| 254 | + var/obj/oldobj = gone |
218 | 255 | visible_message("The [oldobj.name] fades away!") |
219 | | - qdel(obj) |
220 | 256 |
|
221 | | -/obj/machinery/computer/HolodeckControl/proc/checkInteg(var/area/A) |
| 257 | + if(buffer) |
| 258 | + gone.forceMove(src) // hide in computer |
| 259 | + else |
| 260 | + qdel(gone) |
| 261 | + |
| 262 | +/obj/machinery/computer/HolodeckControl/proc/checkInteg(area/A) |
222 | 263 | for(var/turf/T in A) |
223 | 264 | if(istype(T, /turf/space)) |
224 | 265 | return 0 |
225 | 266 |
|
226 | 267 | return 1 |
227 | 268 |
|
228 | | -//Why is it called toggle if it doesn't toggle? |
229 | | -/obj/machinery/computer/HolodeckControl/proc/togglePower(var/toggleOn = 0) |
| 269 | +// why wouldn't toggle toggle? |
| 270 | +/obj/machinery/computer/HolodeckControl/proc/togglePower(toggleOn) |
230 | 271 | if(toggleOn) |
231 | | - loadProgram(holodeck_programs["emptycourt"], 0) |
| 272 | + loadProgram(lastprogram, TRUE, TRUE) |
232 | 273 | else |
233 | | - loadProgram(holodeck_programs["turnoff"], 0) |
234 | | - |
| 274 | + loadProgram("turnoff", FALSE) |
235 | 275 |
|
236 | 276 |
|
237 | 277 | if(!linkedholodeck.has_gravity) |
238 | 278 | linkedholodeck.has_gravity = TRUE |
239 | 279 | linkedholodeck.update_gravity() |
240 | 280 |
|
241 | | - active = 0 |
| 281 | + active = FALSE |
242 | 282 | set_power_use(IDLE_POWER_USE) |
243 | 283 |
|
244 | 284 |
|
245 | | -/obj/machinery/computer/HolodeckControl/proc/loadProgram(var/datum/holodeck_program/HP, var/check_delay = 1) |
| 285 | +/obj/machinery/computer/HolodeckControl/proc/loadProgram(programName, check_delay = TRUE, buffered = FALSE) |
| 286 | + var/datum/holodeck_program/HP = holodeck_programs[programName] |
246 | 287 | if(!HP) |
247 | 288 | return |
248 | 289 | var/area/A = locate(HP.target) |
|
253 | 294 | if(world.time < (last_change + 25)) |
254 | 295 | if(world.time < (last_change + 15))//To prevent super-spam clicking, reduced process size and annoyance -Sieve |
255 | 296 | return |
256 | | - for(var/mob/M in range(3,src)) |
257 | | - M.show_message("\b ERROR. Recalibrating projection apparatus.") |
258 | | - last_change = world.time |
259 | | - return |
| 297 | + visible_message(SPAN_DANGER("[src] flashes 'ERROR. Recalibrating projection apparatus.'"), SPAN_WARNING("[src] buzzes."), 3) |
| 298 | + last_change = world.time |
| 299 | + return |
260 | 300 |
|
261 | 301 | last_change = world.time |
262 | | - active = 1 |
| 302 | + active = TRUE |
263 | 303 | set_power_use(ACTIVE_POWER_USE) |
264 | 304 |
|
| 305 | + |
265 | 306 | for(var/item in holographic_objs) |
266 | | - derez(item) |
| 307 | + derez(item, TRUE, !buffered) |
| 308 | + if(programName != "turnoff" && !buffered) |
| 309 | + clearbuffer() |
267 | 310 |
|
268 | 311 | for(var/mob/living/simple_animal/hostile/carp/holodeck/C in holographic_mobs) |
269 | 312 | holographic_mobs -= C |
|
272 | 315 | for(var/obj/effect/decal/cleanable/blood/B in linkedholodeck) |
273 | 316 | qdel(B) |
274 | 317 |
|
275 | | - holographic_objs = A.copy_contents_to(linkedholodeck , 0) |
| 318 | + holographic_objs = A.copy_contents_to(linkedholodeck , FALSE, buffered) |
276 | 319 | for(var/obj/holo_obj in holographic_objs) |
277 | 320 | holo_obj.alpha *= 0.9 //give holodeck objs a slight transparency |
278 | | - holo_obj.plane = 63 //This makes all objects load on the plane that Eris's 3rd z-level uses for objects. This is not dynamic. |
279 | | - |
| 321 | + holo_obj.update_plane() |
| 322 | + |
| 323 | + if(buffered) |
| 324 | + for(var/datum/holoposition/toreturn in obj_buffer) |
| 325 | + var/turf/toplace = locate(toreturn.holx, toreturn.holy, toreturn.holz) |
| 326 | + var/obj/replaced = toreturn.trueobj.resolve() |
| 327 | + if(!toplace) |
| 328 | + toplace = get_turf(src) |
| 329 | + if(!replaced) |
| 330 | + replaced = new toreturn.holotype(toplace) |
| 331 | + replaced.alpha *= 0.9 //give holodeck objs a slight transparency |
| 332 | + else |
| 333 | + replaced.forceMove(toplace) |
| 334 | + holographic_objs.Add(replaced) // we do this after the transparency because we assume it already has it |
| 335 | + QDEL_LIST(obj_buffer) // we just used the entire list, it is no longer necessary |
| 336 | + |
280 | 337 | if(HP.ambience) |
281 | 338 | linkedholodeck.forced_ambience = HP.ambience |
282 | 339 | else |
|
285 | 342 | for(var/mob/living/M in mobs_in_area(linkedholodeck)) |
286 | 343 | if(M.mind) |
287 | 344 | linkedholodeck.play_ambience(M) |
| 345 | + if(programName != "turnoff") |
| 346 | + lastprogram = programName |
288 | 347 |
|
289 | 348 | spawn(30) |
290 | 349 | for(var/obj/landmark/L in linkedholodeck) |
|
307 | 366 | update_projections() |
308 | 367 |
|
309 | 368 |
|
310 | | -/obj/machinery/computer/HolodeckControl/proc/toggleGravity(var/area/A) |
| 369 | +/obj/machinery/computer/HolodeckControl/proc/toggleGravity(area/A) |
311 | 370 | if(world.time < (last_gravity_change + 25)) |
312 | 371 | if(world.time < (last_gravity_change + 15))//To prevent super-spam clicking |
313 | 372 | return |
314 | | - for(var/mob/M in range(3,src)) |
315 | | - M.show_message("\b ERROR. Recalibrating gravity field.") |
316 | | - last_change = world.time |
317 | | - return |
| 373 | + |
| 374 | + visible_message(SPAN_DANGER("[src] flashes 'ERROR. Recalibrating gravity field.'"), SPAN_WARNING("[src] buzzes."), 3) |
| 375 | + last_change = world.time |
| 376 | + return |
318 | 377 |
|
319 | 378 | last_gravity_change = world.time |
320 | | - active = 1 |
| 379 | + active = TRUE |
321 | 380 | set_power_use(ACTIVE_POWER_USE) |
322 | 381 |
|
323 | 382 |
|
|
329 | 388 |
|
330 | 389 | /obj/machinery/computer/HolodeckControl/proc/emergencyShutdown() |
331 | 390 | //Turn it back to the regular non-holographic room |
332 | | - loadProgram(holodeck_programs["turnoff"], 0) |
| 391 | + loadProgram("turnoff", FALSE) |
333 | 392 |
|
334 | 393 |
|
335 | 394 | linkedholodeck.has_gravity = TRUE |
336 | 395 |
|
337 | | - active = 0 |
| 396 | + active = FALSE |
338 | 397 | set_power_use(IDLE_POWER_USE) |
339 | 398 |
|
340 | 399 | /obj/machinery/computer/HolodeckControl/Exodus |
|
0 commit comments