mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 03:57:13 +01:00
Boo! Rework (#14543)
* Boo Refactor * Boo-Refactor Review Items Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com> * Vending Machines Flicker * Dave's Fire PR Review Mixtape Ft. SteelSlayer Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com> Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>
This commit is contained in:
@@ -419,18 +419,27 @@
|
||||
update_icon()
|
||||
updating_icon = 0
|
||||
|
||||
/obj/machinery/power/apc/get_spooked(second_pass = FALSE)
|
||||
/obj/machinery/power/apc/flicker(second_pass = FALSE)
|
||||
if(opened || panel_open)
|
||||
return
|
||||
return FALSE
|
||||
if(stat & (NOPOWER | BROKEN))
|
||||
return
|
||||
return FALSE
|
||||
if(!second_pass) //The first time, we just cut overlays
|
||||
addtimer(CALLBACK(src, /obj/machinery/power/apc/proc.get_spooked, TRUE), 1)
|
||||
addtimer(CALLBACK(src, /obj/machinery/power/apc/proc.flicker, TRUE), 1)
|
||||
cut_overlays()
|
||||
// APC power distruptions have a chance to propogate to other machines on its network
|
||||
for(var/obj/machinery/M in area)
|
||||
// Please don't cascade, thanks
|
||||
if(M == src)
|
||||
continue
|
||||
if(prob(10))
|
||||
M.flicker()
|
||||
else
|
||||
flick("apcemag", src) //Second time we cause the APC to update its icon, then add a timer to update icon later
|
||||
addtimer(CALLBACK(src, /obj/machinery/power/apc/proc.update_icon, TRUE), 10)
|
||||
|
||||
return TRUE
|
||||
|
||||
//attack with an item - open/close cover, insert cell, or (un)lock interface
|
||||
/obj/machinery/power/apc/attackby(obj/item/W, mob/living/user, params)
|
||||
|
||||
@@ -1231,6 +1240,21 @@
|
||||
else if(last_ch != charging)
|
||||
queue_icon_update()
|
||||
|
||||
if(prob(MACHINE_FLICKER_CHANCE))
|
||||
flicker()
|
||||
|
||||
// lights don't have their own processing loop, so APCs will be the father they never had. 3x as likely to cause a light flicker in a particular area, pick a light to flicker at random
|
||||
if(prob(MACHINE_FLICKER_CHANCE) * 3)
|
||||
var/list/lights = list()
|
||||
for(var/obj/machinery/light/L in area)
|
||||
lights += L
|
||||
|
||||
if(lights.len > 0)
|
||||
var/obj/machinery/light/picked_light = pick(lights)
|
||||
ASSERT(istype(picked_light))
|
||||
picked_light.flicker()
|
||||
|
||||
|
||||
/obj/machinery/power/apc/proc/autoset(var/val, var/on)
|
||||
if(on==0)
|
||||
if(val==2) // if on, return off
|
||||
|
||||
@@ -289,9 +289,6 @@
|
||||
on = FALSE
|
||||
return
|
||||
|
||||
/obj/machinery/light/get_spooked()
|
||||
flicker()
|
||||
|
||||
/**
|
||||
* Updates the light's properties
|
||||
*
|
||||
@@ -519,32 +516,38 @@
|
||||
var/area/A = get_area(src)
|
||||
return A.lightswitch && A.power_light
|
||||
|
||||
/obj/machinery/light/proc/flicker(amount = rand(10, 20))
|
||||
/obj/machinery/light/flicker(amount = rand(20, 30))
|
||||
if(flickering)
|
||||
return
|
||||
return FALSE
|
||||
|
||||
if(!on)
|
||||
return
|
||||
if(!on || status != LIGHT_OK)
|
||||
return FALSE
|
||||
|
||||
flickering = TRUE
|
||||
INVOKE_ASYNC(src, /obj/machinery/light/.proc/flicker_event, amount)
|
||||
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* Flicker routine for the light.
|
||||
* Called by invoke_async so the parent proc can return immediately.
|
||||
*/
|
||||
/obj/machinery/light/proc/flicker_event(amount)
|
||||
for(var/i in 1 to amount)
|
||||
if(status != LIGHT_OK)
|
||||
break
|
||||
on = !on
|
||||
update() // No param means that ghosts can burn out lights
|
||||
sleep(rand(5, 15))
|
||||
if(status == LIGHT_OK)
|
||||
on = TRUE
|
||||
/obj/machinery/light/proc/flicker_event(var/amount)
|
||||
if(on && status == LIGHT_OK)
|
||||
for(var/i = 0; i < amount; i++)
|
||||
if(status != LIGHT_OK)
|
||||
break
|
||||
on = FALSE
|
||||
update(FALSE)
|
||||
sleep(rand(1, 3))
|
||||
on = (status == LIGHT_OK)
|
||||
update(FALSE)
|
||||
sleep(rand(1, 10))
|
||||
on = (status == LIGHT_OK)
|
||||
update(FALSE)
|
||||
flickering = FALSE
|
||||
|
||||
|
||||
// ai attack - make lights flicker, because why not
|
||||
/obj/machinery/light/attack_ai(mob/user)
|
||||
flicker(1)
|
||||
|
||||
Reference in New Issue
Block a user