mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 11:43:31 +00:00
Merge pull request #13671 from Cameron653/light_overlay
More light updates!
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
var/emagged = 0
|
var/emagged = 0
|
||||||
var/failmsg = ""
|
var/failmsg = ""
|
||||||
var/charge = 0
|
var/charge = 0
|
||||||
|
var/selected_color = LIGHT_COLOR_INCANDESCENT_TUBE //Default color!
|
||||||
|
|
||||||
// Eating used bulbs gives us bulb shards
|
// Eating used bulbs gives us bulb shards
|
||||||
var/bulb_shards = 0
|
var/bulb_shards = 0
|
||||||
@@ -141,6 +142,10 @@
|
|||||||
return
|
return
|
||||||
*/
|
*/
|
||||||
to_chat(usr, "It has [uses] lights remaining.")
|
to_chat(usr, "It has [uses] lights remaining.")
|
||||||
|
var/new_color = input(usr, "Choose a color to set the light to! (Default is [LIGHT_COLOR_INCANDESCENT_TUBE])", "", selected_color) as color|null
|
||||||
|
if(new_color)
|
||||||
|
selected_color = new_color
|
||||||
|
to_chat(usr, "The light color has been changed.")
|
||||||
|
|
||||||
/obj/item/device/lightreplacer/update_icon()
|
/obj/item/device/lightreplacer/update_icon()
|
||||||
icon_state = "lightreplacer[emagged]"
|
icon_state = "lightreplacer[emagged]"
|
||||||
@@ -184,19 +189,13 @@
|
|||||||
to_chat(U, "<span class='notice'>\The [src] has fabricated a new bulb from the broken bulbs it has stored. It now has [uses] uses.</span>")
|
to_chat(U, "<span class='notice'>\The [src] has fabricated a new bulb from the broken bulbs it has stored. It now has [uses] uses.</span>")
|
||||||
playsound(src, 'sound/machines/ding.ogg', 50, 1)
|
playsound(src, 'sound/machines/ding.ogg', 50, 1)
|
||||||
target.status = LIGHT_EMPTY
|
target.status = LIGHT_EMPTY
|
||||||
|
target.installed_light = null //Remove the light!
|
||||||
target.update()
|
target.update()
|
||||||
|
|
||||||
var/obj/item/weapon/light/L2 = new target.light_type()
|
var/obj/item/weapon/light/L2 = new target.light_type()
|
||||||
|
L2.brightness_color = selected_color
|
||||||
target.status = L2.status
|
target.insert_bulb(L2) //Call the insertion proc.
|
||||||
target.switchcount = L2.switchcount
|
|
||||||
target.rigged = emagged
|
|
||||||
target.brightness_range = L2.brightness_range
|
|
||||||
target.brightness_power = L2.brightness_power
|
|
||||||
target.brightness_color = L2.brightness_color
|
|
||||||
target.on = target.has_power()
|
|
||||||
target.update()
|
target.update()
|
||||||
qdel(L2)
|
|
||||||
|
|
||||||
if(target.on && target.rigged)
|
if(target.on && target.rigged)
|
||||||
target.explode()
|
target.explode()
|
||||||
|
|||||||
@@ -409,24 +409,33 @@
|
|||||||
var/datum/matter_synth/glass = null
|
var/datum/matter_synth/glass = null
|
||||||
|
|
||||||
/obj/item/device/lightreplacer/dogborg/attack_self(mob/user)//Recharger refill is so last season. Now we recycle without magic!
|
/obj/item/device/lightreplacer/dogborg/attack_self(mob/user)//Recharger refill is so last season. Now we recycle without magic!
|
||||||
if(uses >= max_uses)
|
|
||||||
to_chat(user, "<span class='warning'>[src.name] is full.</span>")
|
var/choice = tgui_alert(user, "Do you wish to check the reserves or change the color?", "Selection List", list("Reserves", "Color"))
|
||||||
|
if(choice == "Color")
|
||||||
|
var/new_color = input(usr, "Choose a color to set the light to! (Default is [LIGHT_COLOR_INCANDESCENT_TUBE])", "", selected_color) as color|null
|
||||||
|
if(new_color)
|
||||||
|
selected_color = new_color
|
||||||
|
to_chat(user, "The light color has been changed.")
|
||||||
return
|
return
|
||||||
if(uses < max_uses && cooldown == 0)
|
|
||||||
if(glass.energy < 125)
|
|
||||||
to_chat(user, "<span class='warning'>Insufficient material reserves.</span>")
|
|
||||||
return
|
|
||||||
to_chat(user, "It has [uses] lights remaining. Attempting to fabricate a replacement. Please stand still.")
|
|
||||||
cooldown = 1
|
|
||||||
if(do_after(user, 50))
|
|
||||||
glass.use_charge(125)
|
|
||||||
add_uses(1)
|
|
||||||
cooldown = 0
|
|
||||||
else
|
|
||||||
cooldown = 0
|
|
||||||
else
|
else
|
||||||
to_chat(user, "It has [uses] lights remaining.")
|
if(uses >= max_uses)
|
||||||
return
|
to_chat(user, "<span class='warning'>[src.name] is full.</span>")
|
||||||
|
return
|
||||||
|
if(uses < max_uses && cooldown == 0)
|
||||||
|
if(glass.energy < 125)
|
||||||
|
to_chat(user, "<span class='warning'>Insufficient material reserves.</span>")
|
||||||
|
return
|
||||||
|
to_chat(user, "It has [uses] lights remaining. Attempting to fabricate a replacement. Please stand still.")
|
||||||
|
cooldown = 1
|
||||||
|
if(do_after(user, 50))
|
||||||
|
glass.use_charge(125)
|
||||||
|
add_uses(1)
|
||||||
|
cooldown = 0
|
||||||
|
else
|
||||||
|
cooldown = 0
|
||||||
|
else
|
||||||
|
to_chat(user, "It has [uses] lights remaining.")
|
||||||
|
return
|
||||||
|
|
||||||
//Pounce stuff for K-9
|
//Pounce stuff for K-9
|
||||||
/obj/item/weapon/dogborg/pounce
|
/obj/item/weapon/dogborg/pounce
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ GLOBAL_LIST_EMPTY(apcs)
|
|||||||
var/updating_icon = 0
|
var/updating_icon = 0
|
||||||
var/global/list/status_overlays_environ
|
var/global/list/status_overlays_environ
|
||||||
var/alarms_hidden = FALSE //If power alarms from this APC are visible on consoles
|
var/alarms_hidden = FALSE //If power alarms from this APC are visible on consoles
|
||||||
|
|
||||||
var/nightshift_lights = FALSE
|
var/nightshift_lights = FALSE
|
||||||
var/nightshift_setting = NIGHTSHIFT_AUTO
|
var/nightshift_setting = NIGHTSHIFT_AUTO
|
||||||
var/last_nightshift_switch = 0
|
var/last_nightshift_switch = 0
|
||||||
@@ -198,7 +198,7 @@ GLOBAL_LIST_EMPTY(apcs)
|
|||||||
|
|
||||||
if(!pixel_x && !pixel_y)
|
if(!pixel_x && !pixel_y)
|
||||||
offset_apc()
|
offset_apc()
|
||||||
|
|
||||||
if(building)
|
if(building)
|
||||||
area = get_area(src)
|
area = get_area(src)
|
||||||
area.apc = src
|
area.apc = src
|
||||||
@@ -1360,6 +1360,7 @@ GLOBAL_LIST_EMPTY(apcs)
|
|||||||
|
|
||||||
for(var/obj/machinery/light/L in area)
|
for(var/obj/machinery/light/L in area)
|
||||||
L.nightshift_mode(new_state)
|
L.nightshift_mode(new_state)
|
||||||
|
L.update() //For some reason it gets hung up on updating the overlay for the light fixture somewhere down the line. This fixes it.
|
||||||
CHECK_TICK
|
CHECK_TICK
|
||||||
|
|
||||||
#undef APC_UPDATE_ICON_COOLDOWN
|
#undef APC_UPDATE_ICON_COOLDOWN
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ var/global/list/light_type_cache = list()
|
|||||||
idle_power_usage = 2
|
idle_power_usage = 2
|
||||||
active_power_usage = 10
|
active_power_usage = 10
|
||||||
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
|
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
|
||||||
|
var/obj/item/weapon/light/installed_light //What light is currently in the socket! Updated in new()
|
||||||
var/on = 0 // 1 if on, 0 if off
|
var/on = 0 // 1 if on, 0 if off
|
||||||
var/brightness_range
|
var/brightness_range
|
||||||
var/brightness_power
|
var/brightness_power
|
||||||
@@ -346,7 +347,7 @@ var/global/list/light_type_cache = list()
|
|||||||
else
|
else
|
||||||
if(start_with_cell && !no_emergency)
|
if(start_with_cell && !no_emergency)
|
||||||
cell = new/obj/item/weapon/cell/emergency_light(src)
|
cell = new/obj/item/weapon/cell/emergency_light(src)
|
||||||
var/obj/item/weapon/light/L = get_light_type_instance(light_type)
|
var/obj/item/weapon/light/L = get_light_type_instance(light_type) //This is fine, but old code.
|
||||||
update_from_bulb(L)
|
update_from_bulb(L)
|
||||||
if(prob(L.broken_chance))
|
if(prob(L.broken_chance))
|
||||||
broken(1)
|
broken(1)
|
||||||
@@ -439,7 +440,7 @@ var/global/list/light_type_cache = list()
|
|||||||
return
|
return
|
||||||
|
|
||||||
current_alert = null
|
current_alert = null
|
||||||
var/obj/item/weapon/light/L = get_light_type_instance(light_type)
|
var/obj/item/weapon/light/L = installed_light //This ensures any special bulbs will stay special!
|
||||||
|
|
||||||
if(L)
|
if(L)
|
||||||
update_from_bulb(L)
|
update_from_bulb(L)
|
||||||
@@ -464,11 +465,12 @@ var/global/list/light_type_cache = list()
|
|||||||
var/correct_range = nightshift_enabled ? brightness_range_ns : brightness_range
|
var/correct_range = nightshift_enabled ? brightness_range_ns : brightness_range
|
||||||
var/correct_power = nightshift_enabled ? brightness_power_ns : brightness_power
|
var/correct_power = nightshift_enabled ? brightness_power_ns : brightness_power
|
||||||
var/correct_color = nightshift_enabled ? brightness_color_ns : brightness_color
|
var/correct_color = nightshift_enabled ? brightness_color_ns : brightness_color
|
||||||
|
var/correct_overlay = nightshift_enabled ? brightness_color_ns : brightness_color //Gives lights the correct overlay if NS is enabled.
|
||||||
if(current_alert) //Oh no, we're on fire! Or the atmos is bad! Let's change the color
|
if(current_alert) //Oh no, we're on fire! Or the atmos is bad! Let's change the color
|
||||||
correct_range = brightness_range
|
correct_range = brightness_range
|
||||||
correct_power = brightness_power
|
correct_power = brightness_power
|
||||||
correct_color = brightness_color
|
correct_color = brightness_color
|
||||||
if(light_range != correct_range || light_power != correct_power || light_color != correct_color)
|
if(light_range != correct_range || light_power != correct_power || light_color != correct_color || overlay_color != correct_overlay)
|
||||||
if(!auto_flicker)
|
if(!auto_flicker)
|
||||||
switchcount++
|
switchcount++
|
||||||
if(rigged)
|
if(rigged)
|
||||||
@@ -487,6 +489,7 @@ var/global/list/light_type_cache = list()
|
|||||||
else
|
else
|
||||||
update_use_power(USE_POWER_ACTIVE)
|
update_use_power(USE_POWER_ACTIVE)
|
||||||
set_light(correct_range, correct_power, correct_color)
|
set_light(correct_range, correct_power, correct_color)
|
||||||
|
overlay_color = correct_overlay
|
||||||
if(cell?.charge < cell?.maxcharge)
|
if(cell?.charge < cell?.maxcharge)
|
||||||
START_PROCESSING(SSobj, src)
|
START_PROCESSING(SSobj, src)
|
||||||
else if(has_emergency_power(LIGHT_EMERGENCY_POWER_USE) && !turned_off())
|
else if(has_emergency_power(LIGHT_EMERGENCY_POWER_USE) && !turned_off())
|
||||||
@@ -571,6 +574,7 @@ var/global/list/light_type_cache = list()
|
|||||||
brightness_range = L.brightness_range
|
brightness_range = L.brightness_range
|
||||||
brightness_power = L.brightness_power
|
brightness_power = L.brightness_power
|
||||||
brightness_color = L.brightness_color
|
brightness_color = L.brightness_color
|
||||||
|
overlay_color = L.brightness_color
|
||||||
|
|
||||||
brightness_range_ns = L.nightshift_range
|
brightness_range_ns = L.nightshift_range
|
||||||
brightness_power_ns = L.nightshift_power
|
brightness_power_ns = L.nightshift_power
|
||||||
@@ -580,7 +584,8 @@ var/global/list/light_type_cache = list()
|
|||||||
|
|
||||||
/obj/machinery/light/proc/insert_bulb(obj/item/weapon/light/L)
|
/obj/machinery/light/proc/insert_bulb(obj/item/weapon/light/L)
|
||||||
update_from_bulb(L)
|
update_from_bulb(L)
|
||||||
qdel(L)
|
installed_light = L
|
||||||
|
L.loc = src //Move it into the socket!
|
||||||
|
|
||||||
on = powered()
|
on = powered()
|
||||||
update()
|
update()
|
||||||
@@ -593,16 +598,17 @@ var/global/list/light_type_cache = list()
|
|||||||
explode()
|
explode()
|
||||||
|
|
||||||
/obj/machinery/light/proc/remove_bulb()
|
/obj/machinery/light/proc/remove_bulb()
|
||||||
. = new light_type(src.loc, src)
|
//. = new light_type(src.loc, src)
|
||||||
|
|
||||||
switchcount = 0
|
switchcount = 0
|
||||||
|
installed_light = null
|
||||||
status = LIGHT_EMPTY
|
status = LIGHT_EMPTY
|
||||||
update()
|
update()
|
||||||
|
|
||||||
/obj/machinery/light/attackby(obj/item/W, mob/user)
|
/obj/machinery/light/attackby(obj/item/W, mob/user)
|
||||||
|
|
||||||
//Light replacer code
|
//Light replacer code
|
||||||
if(istype(W, /obj/item/device/lightreplacer))
|
if(istype(W, /obj/item/device/lightreplacer)) //These will never be modified, so it's fine to use old code.
|
||||||
var/obj/item/device/lightreplacer/LR = W
|
var/obj/item/device/lightreplacer/LR = W
|
||||||
if(isliving(user))
|
if(isliving(user))
|
||||||
var/mob/living/U = user
|
var/mob/living/U = user
|
||||||
@@ -619,7 +625,9 @@ var/global/list/light_type_cache = list()
|
|||||||
return
|
return
|
||||||
|
|
||||||
to_chat(user, "You insert [W].")
|
to_chat(user, "You insert [W].")
|
||||||
|
user.drop_item()
|
||||||
insert_bulb(W)
|
insert_bulb(W)
|
||||||
|
update() //Like other places, this is done later down the line but this is essential to updating the overlay when nightmode is involved. Again, I have no idea WHY.
|
||||||
src.add_fingerprint(user)
|
src.add_fingerprint(user)
|
||||||
|
|
||||||
// attempt to break the light
|
// attempt to break the light
|
||||||
@@ -724,6 +732,7 @@ var/global/list/light_type_cache = list()
|
|||||||
if(cell.charge > 300) //it's meant to handle 120 W, ya doofus
|
if(cell.charge > 300) //it's meant to handle 120 W, ya doofus
|
||||||
visible_message("<span class='warning'>[src] short-circuits from too powerful of a power cell!</span>")
|
visible_message("<span class='warning'>[src] short-circuits from too powerful of a power cell!</span>")
|
||||||
status = LIGHT_BURNED
|
status = LIGHT_BURNED
|
||||||
|
installed_light.status = status
|
||||||
return FALSE
|
return FALSE
|
||||||
cell.use(pwr)
|
cell.use(pwr)
|
||||||
set_light(brightness_range * bulb_emergency_brightness_mul, max(bulb_emergency_pow_min, bulb_emergency_pow_mul * (cell.charge / cell.maxcharge)), bulb_emergency_colour)
|
set_light(brightness_range * bulb_emergency_brightness_mul, max(bulb_emergency_pow_min, bulb_emergency_pow_mul * (cell.charge / cell.maxcharge)), bulb_emergency_colour)
|
||||||
@@ -805,8 +814,11 @@ var/global/list/light_type_cache = list()
|
|||||||
else
|
else
|
||||||
to_chat(user, "You remove the light [get_fitting_name()].")
|
to_chat(user, "You remove the light [get_fitting_name()].")
|
||||||
|
|
||||||
// create a light tube/bulb item and put it in the user's hand
|
//Let's actually put the real bulb in their hand.
|
||||||
user.put_in_active_hand(remove_bulb()) //puts it in our active hand
|
installed_light.status = status //Update the bulb they're being given. If it's broken, the bulb should be as well!
|
||||||
|
user.put_in_active_hand(installed_light) //puts it in our active hand
|
||||||
|
installed_light.update_icon()
|
||||||
|
remove_bulb()
|
||||||
|
|
||||||
/obj/machinery/light/flamp/attack_hand(mob/user)
|
/obj/machinery/light/flamp/attack_hand(mob/user)
|
||||||
if(lamp_shade)
|
if(lamp_shade)
|
||||||
@@ -845,13 +857,16 @@ var/global/list/light_type_cache = list()
|
|||||||
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
||||||
s.set_up(3, 1, src)
|
s.set_up(3, 1, src)
|
||||||
s.start()
|
s.start()
|
||||||
status = LIGHT_BROKEN
|
status = LIGHT_BROKEN //This occasionally runtimes when it occurs midround after build mode spawns a broken light. No idea why.
|
||||||
|
installed_light.status = status
|
||||||
update()
|
update()
|
||||||
|
|
||||||
/obj/machinery/light/proc/fix()
|
/obj/machinery/light/proc/fix()
|
||||||
if(status == LIGHT_OK)
|
if(status == LIGHT_OK)
|
||||||
return
|
return
|
||||||
status = LIGHT_OK
|
status = LIGHT_OK
|
||||||
|
if(installed_light)
|
||||||
|
installed_light.status = LIGHT_OK
|
||||||
on = 1
|
on = 1
|
||||||
update()
|
update()
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
// create a new lighting fixture
|
// create a new lighting fixture
|
||||||
/obj/machinery/light/New()
|
/obj/machinery/light/New()
|
||||||
..()
|
..()
|
||||||
|
installed_light = new light_type
|
||||||
|
installed_light.status = status //This is just in case RNG decides to break the light at round start!
|
||||||
|
installed_light.update_icon() //Give it the proper sprite!
|
||||||
//Vorestation addition, so large mobs stop looking stupid in front of lights.
|
//Vorestation addition, so large mobs stop looking stupid in front of lights.
|
||||||
if (dir == SOUTH) // Lights are backwards, SOUTH lights face north (they are on south wall)
|
if (dir == SOUTH) // Lights are backwards, SOUTH lights face north (they are on south wall)
|
||||||
layer = ABOVE_MOB_LAYER
|
layer = ABOVE_MOB_LAYER
|
||||||
|
|||||||
Reference in New Issue
Block a user