Files
CHOMPStation2/code/game/machinery/flasher.dm
elly1989@rocketmail.com 6e274cd395 New lighting, it's essentially just the old DAL system with a queue.
Comments for lighting:
	Like sd_DAL (what we used to use), it changes the shading overlays of areas by splitting each type of area into sub-areas
	by using the var/tag variable and moving turfs into the contents list of the correct sub-area.

	Unlike sd_DAL however it uses a queueing system. Everytime we  call a change to opacity or luminosity
	(through SetOpacity() or SetLuminosity()) we are  simply updating variables and scheduling certain lights/turfs for an
	update. Actual updates are handled periodically by the lighting_controller. This carries additional overheads, however it
	means that each thing is changed only once per lighting_controller.processing_interval ticks. Allowing for greater control
	over how much priority we'd like lighting updates to have. It also makes it possible for us to simply delay updates by
	setting lighting_controller.processing = 0 at say, the start of a large explosion, waiting for it to finish, and then
	turning it back on with lighting_controller.processing = 1.

	Unlike our old system there is a hardcoded maximum luminosity. This is to discourage coders using large luminosity values
	for dynamic lighting, as the cost of lighting grows rapidly at large luminosity levels (especially when changing opacity
	at runtime)

	Also, in order for the queueing system to work, each light remembers the effect it casts on each turf. This is going to
	have larger memory requirements than our previous system but hopefully it's worth the hassle for the greater control we
	gain. Besides, there are far far worse uses of needless lists in the game, it'd be worth pruning some of them to offset
	costs.

	Known Issues/TODO:
		admin-spawned turfs will have broken lumcounts. Not willing to fix it at this moment
		mob luminosity will be lower than expected when one of multiple light sources is dropped after exceeding the maximum luminosity
		Shuttles still do not have support for dynamic lighting (I hope to fix this at some point)
		No directional lighting support. Fairly easy to add this and the code is ready.
		When opening airlocks etc, lighting does not always update to account for the change in opacity.

Explosions now cause lighting to cease processing temporarily.

Moved controller datums to the code/controllers directory. I plan on standardising them.
"Master","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply Shuttle","Emergency Shuttle","Configuration","pAI" controller datums can be accessed via the debug controller verb (used to be the debug master controller verb)
Supply shuttle now uses a controller datum. Shuttles tend to arrive up to 30 seconds late, this is not a bug.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4537 316c924e-a436-60f5-8080-3fe189b3f50e
2012-08-25 16:06:57 +00:00

144 lines
3.9 KiB
Plaintext

// It is a gizmo that flashes a small area
/obj/machinery/flasher
name = "Mounted flash"
desc = "A wall-mounted flashbulb device."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "mflash1"
var/id = null
var/range = 2 //this is roughly the size of brig cell
var/disable = 0
var/last_flash = 0 //Don't want it getting spammed like regular flashes
var/strength = 10 //How weakened targets are when flashed.
var/base_state = "mflash"
anchored = 1
/obj/machinery/flasher/portable //Portable version of the flasher. Only flashes when anchored
name = "portable flasher"
desc = "A portable flashing device. Wrench to activate and deactivate. Cannot detect slow movements."
icon_state = "pflash1"
strength = 8
anchored = 0
base_state = "pflash"
density = 1
/*
/obj/machinery/flasher/New()
sleep(4) //<--- What the fuck are you doing? D=
src.sd_SetLuminosity(2)
*/
/obj/machinery/flasher/power_change()
if ( powered() )
stat &= ~NOPOWER
icon_state = "[base_state]1"
// src.sd_SetLuminosity(2)
else
stat |= ~NOPOWER
icon_state = "[base_state]1-p"
// src.sd_SetLuminosity(0)
//Don't want to render prison breaks impossible
/obj/machinery/flasher/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/wirecutters))
add_fingerprint(user)
src.disable = !src.disable
if (src.disable)
user.visible_message("\red [user] has disconnected the [src]'s flashbulb!", "\red You disconnect the [src]'s flashbulb!")
if (!src.disable)
user.visible_message("\red [user] has connected the [src]'s flashbulb!", "\red You connect the [src]'s flashbulb!")
//Let the AI trigger them directly.
/obj/machinery/flasher/attack_ai()
if (src.anchored)
return src.flash()
else
return
/obj/machinery/flasher/proc/flash()
if (!(powered()))
return
if ((src.disable) || (src.last_flash && world.time < src.last_flash + 150))
return
playsound(src.loc, 'sound/weapons/flash.ogg', 100, 1)
flick("[base_state]_flash", src)
src.last_flash = world.time
use_power(1000)
for (var/mob/O in viewers(src, null))
if (get_dist(src, O) > src.range)
continue
if (istype(O, /mob/living/carbon/human))
var/mob/living/carbon/human/H = O
if(!H.eyecheck() <= 0)
continue
if (istype(O, /mob/living/carbon/alien))//So aliens don't get flashed (they have no external eyes)/N
continue
O.Weaken(strength)
if ((O.eye_stat > 15 && prob(O.eye_stat + 50)))
flick("e_flash", O:flash)
O.eye_stat += rand(1, 2)
else
if(!O.blinded)
flick("flash", O:flash)
O.eye_stat += rand(0, 2)
/obj/machinery/flasher/portable/HasProximity(atom/movable/AM as mob|obj)
if ((src.disable) || (src.last_flash && world.time < src.last_flash + 150))
return
if(istype(AM, /mob/living/carbon))
var/mob/living/carbon/M = AM
if ((M.m_intent != "walk") && (src.anchored))
src.flash()
/obj/machinery/flasher/portable/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/wrench))
add_fingerprint(user)
src.anchored = !src.anchored
if (!src.anchored)
user.show_message(text("\red [src] can now be moved."))
src.overlays = null
else if (src.anchored)
user.show_message(text("\red [src] is now secured."))
src.overlays += "[base_state]-s"
/obj/machinery/flasher_button/attack_ai(mob/user as mob)
return src.attack_hand(user)
/obj/machinery/flasher_button/attack_paw(mob/user as mob)
return src.attack_hand(user)
/obj/machinery/flasher_button/attackby(obj/item/weapon/W, mob/user as mob)
return src.attack_hand(user)
/obj/machinery/flasher_button/attack_hand(mob/user as mob)
if(stat & (NOPOWER|BROKEN))
return
if(active)
return
use_power(5)
active = 1
icon_state = "launcheract"
for(var/obj/machinery/flasher/M in world)
if(M.id == src.id)
spawn()
M.flash()
sleep(50)
icon_state = "launcherbtt"
active = 0
return