Nightshifts & Randomized Station Time

This commit adds the Nightshift lighting mode from /tg/. From 19:00 to
07:00 in station time, the station will go into a reduced-lighting mode,
with dimmed lights across the station.

In conjunction with this, there is a new configuration option to start
the shift time at a random time other than 12:00, so that players are
more likely to experience a night shift (as opposed to having to have a
7 hour round).
This commit is contained in:
tigercat2000
2018-03-25 23:01:04 -07:00
parent 80cef82ebd
commit bc4fb3d79b
68 changed files with 264 additions and 121 deletions
+24
View File
@@ -104,6 +104,10 @@
var/shock_proof = 0 //if set to 1, this APC will not arc bolts of electricity if it's overloaded.
// Nightshift
var/nightshift_lights = FALSE
var/last_nightshift_switch = 0
/obj/machinery/power/apc/worn_out
name = "\improper Worn out APC"
keep_preset_name = 1
@@ -773,6 +777,7 @@
data["siliconUser"] = istype(user, /mob/living/silicon)
data["siliconLock"] = locked
data["malfStatus"] = get_malf_status(user)
data["nightshiftLights"] = nightshift_lights
var/powerChannels[0]
powerChannels[++powerChannels.len] = list(
@@ -904,6 +909,16 @@
toggle_breaker()
else if(href_list["toggle_nightshift"])
if(!is_authenticated(usr))
return
if(last_nightshift_switch < world.time + 100) // don't spam...
to_chat(usr, "<span class='warning'>[src]'s night lighting circuit breaker is still cycling!</span>")
return
last_nightshift_switch = world.time
set_nightshift(!nightshift_lights)
else if(href_list["cmode"])
if(!is_authenticated(usr))
return
@@ -1353,4 +1368,13 @@
else
return 0
/obj/machinery/power/apc/proc/set_nightshift(on)
set waitfor = FALSE
nightshift_lights = on
for(var/obj/machinery/light/L in area)
if(L.nightshift_allowed)
L.nightshift_enabled = nightshift_lights
L.update(FALSE)
CHECK_TICK
#undef APC_UPDATE_ICON_COOLDOWN
+19 -5
View File
@@ -153,6 +153,13 @@
var/rigged = 0 // true if rigged to explode
var/lightmaterials = list(MAT_GLASS=100) //stores the materials the light is made of to stop infinite glass exploit
var/nightshift_enabled = FALSE //Currently in night shift mode?
var/nightshift_allowed = TRUE //Set to FALSE to never let this light get switched to night mode.
var/nightshift_light_range = 8
var/nightshift_light_power = 0.45
var/nightshift_light_color = "#FFDDCC"
// the smaller bulb light fixture
/obj/machinery/light/small
@@ -161,6 +168,7 @@
fitting = "bulb"
brightness_range = 4
brightness_color = "#a0a080"
nightshift_light_range = 4
desc = "A small lighting fixture."
light_type = /obj/item/weapon/light/bulb
@@ -226,18 +234,24 @@
return
// update the icon_state and luminosity of the light depending on its state
/obj/machinery/light/proc/update(var/trigger = 1)
/obj/machinery/light/proc/update(var/trigger = TRUE)
switch(status)
if(LIGHT_BROKEN, LIGHT_BURNED, LIGHT_EMPTY)
on = FALSE
update_icon()
if(on)
if(light_range != brightness_range || light_power != brightness_power || light_color != brightness_color)
var/BR = nightshift_enabled ? nightshift_light_range : brightness_range
var/PO = nightshift_enabled ? nightshift_light_power : brightness_power
var/CO = nightshift_enabled ? nightshift_light_color : brightness_color
var/matching = light_range == BR && light_power == PO && light_color == CO
if(!matching)
switchcount++
if(rigged)
if(status == LIGHT_OK && trigger)
log_admin("LOG: Rigged light explosion, last touched by [fingerprintslast]")
message_admins("LOG: Rigged light explosion, last touched by [fingerprintslast]")
explode()
else if( prob( min(60, switchcount*switchcount*0.01) ) )
else if(prob(min(60, switchcount * switchcount * 0.01)))
if(status == LIGHT_OK && trigger)
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
@@ -245,7 +259,7 @@
set_light(0)
else
use_power = 2
set_light(brightness_range, brightness_power, brightness_color)
set_light(BR, PO, CO)
else
use_power = 1
set_light(0)