Coloured lighting & related stuff (#3555)

Makes all light tubes & bulbs have colour according to the light they emit. There are 6 preset colours: RGB CMY. Any other color is possible by simply changing the already present brightness_color variable. This PR makes it so it actually changes the color of the item and wall object too.
    Added two new colour defines used only along with preset coloured lights.
    Coloured lights are only obtainable by random maintenace loot, cargo spawn or trader.
    Added box of randomly mixed light colours and box for every preset light colour.
    Removed two sets of redundant defines.
    Converted light item New() to Initialize() (hopefully correctly).
    Made couple tiny tweaks to the lights code.

EDIT, 7. Oct 2017:

    When you hit light machinery or item with paint, it will change it's brightness_color var, instead of the color var.
    Paint buckets can now paint items and people again.
    You can now wash paint off by spraying yourself with fire extinguisher or otherwise covering yourself in water.

EDIT, 8. Oct 2017:

    Removed one apparently unused global list.
    Converted pain bucket New to Initialize and changed it's pathing style.
    Shower can now wash paint too.
    Fixed paint bucket sprites to be bit more dynamic and fixed the in hand sprite. Also added bucket lid.
This commit is contained in:
TheGreatJorge
2017-10-10 18:46:24 +02:00
committed by Werner
parent a3b0a30890
commit 0aff2d8785
17 changed files with 343 additions and 122 deletions
+11 -1
View File
@@ -543,7 +543,17 @@ var/list/global/random_stock_large = list(
if (prob(50))
new /obj/item/weapon/storage/box/lights/mixed(L)
if (prob(25))
new /obj/item/weapon/storage/box/lights/mixed(L)
new /obj/item/weapon/storage/box/lights/coloredmixed(L)
if (prob(15))
var/type = pick(list(
/obj/item/weapon/storage/box/lights/colored/red,
/obj/item/weapon/storage/box/lights/colored/green,
/obj/item/weapon/storage/box/lights/colored/blue,
/obj/item/weapon/storage/box/lights/colored/cyan,
/obj/item/weapon/storage/box/lights/colored/yellow,
/obj/item/weapon/storage/box/lights/colored/magenta
))
new type(L)
if("aid")
new /obj/random/firstaid(L)
if("flame")
+2
View File
@@ -670,6 +670,8 @@ var/list/worths = list(
/obj/item/target = 15,
/obj/item/inflatable = 30,
/obj/item/roller = 80,
/obj/item/weapon/light/tube/colored = 20,
/obj/item/weapon/light/bulb/colored = 15,
/obj/item/rig_module/grenade_launcher = 1500,
/obj/item/rig_module/mounted/energy_blade = 5000,
/obj/item/rig_module/mounted/thermalldrill = 2500,
+121 -52
View File
@@ -3,12 +3,6 @@
// consists of light fixtures (/obj/machinery/light) and light tube/bulb items (/obj/item/weapon/light)
#define LIGHTING_POWER_FACTOR 40 //20W per unit luminosity
// status values shared between lighting fixtures and items
#define LIGHT_OK 0
#define LIGHT_EMPTY 1
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3
#define LIGHT_BULB_TEMPERATURE 400 //K - used value for a 60W bulb
/obj/machinery/light_construct
@@ -95,10 +89,10 @@
if(isscrewdriver(W))
if (src.stage == 2)
switch(fixture_type)
if ("tube")
src.icon_state = "tube-empty"
if("tube")
src.icon_state = "tube_empty"
if("bulb")
src.icon_state = "bulb-empty"
src.icon_state = "bulb_empty"
src.stage = 3
user.visible_message("[user.name] closes [src]'s casing.", \
"You close [src]'s casing.", "You hear a noise.")
@@ -108,7 +102,7 @@
if("tube")
newlight = new /obj/machinery/light/built(src.loc)
if ("bulb")
if("bulb")
newlight = new /obj/machinery/light/small/built(src.loc)
newlight.dir = src.dir
@@ -133,7 +127,7 @@
name = "light fixture"
icon = 'icons/obj/lighting.dmi'
var/base_state = "tube" // base description and icon_state
icon_state = "tube1"
icon_state = "tube_empty"
desc = "A lighting fixture."
anchored = 1
layer = 5 // They were appearing under mobs which is a little weird - Ostaf
@@ -154,6 +148,7 @@
var/status = LIGHT_OK // LIGHT_OK, _EMPTY, _BURNED or _BROKEN
var/flickering = 0
var/light_type = /obj/item/weapon/light/tube // the type of light item
var/obj/item/weapon/light/inserted_light = /obj/item/weapon/light/tube
var/fitting = "tube"
var/switchcount = 0 // count of number of times switched on/off
// this is used to calc the probability the light burns out
@@ -171,6 +166,7 @@
brightness_color = LIGHT_COLOR_TUNGSTEN
desc = "A small lighting fixture."
light_type = /obj/item/weapon/light/bulb
inserted_light = /obj/item/weapon/light/bulb
supports_nightmode = FALSE
/obj/machinery/light/small/emergency
@@ -187,6 +183,7 @@
name = "spotlight"
fitting = "large tube"
light_type = /obj/item/weapon/light/tube/large
inserted_light = /obj/item/weapon/light/tube/large
brightness_range = 12
brightness_power = 4
supports_nightmode = FALSE
@@ -223,22 +220,29 @@
return ..()
/obj/machinery/light/update_icon()
cut_overlays()
icon_state = "[base_state]_empty"
switch(status) // set icon_states
if(LIGHT_OK)
icon_state = "[base_state][on]"
var/image/I = image(icon, "[base_state][on]")
I.color = brightness_color
add_overlay(I)
if (supports_nightmode && nightmode && on)
color = "#d2d2d2"
else
color = null
if(LIGHT_EMPTY)
icon_state = "[base_state]-empty"
on = 0
if(LIGHT_BURNED)
icon_state = "[base_state]-burned"
var/image/I = image(icon, "[base_state]_burned")
I.color = brightness_color
add_overlay(I)
on = 0
if(LIGHT_BROKEN)
icon_state = "[base_state]-broken"
var/image/I = image(icon, "[base_state]_broken")
I.color = brightness_color
add_overlay(I)
on = 0
if (!on)
@@ -260,7 +264,10 @@
else if( prob( min(60, switchcount*switchcount*0.01) ) )
if(status == LIGHT_OK && trigger)
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
cut_overlays()
var/image/I = image(icon, "[base_state]_burned")
I.color = brightness_color
add_overlay(I)
on = 0
set_light(0)
else
@@ -345,9 +352,10 @@
brightness_range = L.brightness_range
brightness_power = L.brightness_power
brightness_color = L.brightness_color
inserted_light = L.type
on = has_power()
update()
user.drop_item() //drop the item to update overlays and such
qdel(L)
@@ -497,7 +505,7 @@
user << "You remove the light [fitting]."
// create a light tube/bulb item and put it in the user's hand
var/obj/item/weapon/light/L = new light_type()
var/obj/item/weapon/light/L = new inserted_light()
L.status = status
L.rigged = rigged
L.brightness_range = brightness_range
@@ -513,6 +521,8 @@
user.put_in_active_hand(L) //puts it in our active hand
inserted_light = null
status = LIGHT_EMPTY
update()
@@ -524,7 +534,7 @@
user << "You telekinetically remove the light [fitting]."
// create a light tube/bulb item and put it in the user's hand
var/obj/item/weapon/light/L = new light_type()
var/obj/item/weapon/light/L = new inserted_light()
L.status = status
L.rigged = rigged
L.brightness_range = brightness_range
@@ -539,6 +549,8 @@
L.add_fingerprint(user)
L.loc = loc
inserted_light = null
status = LIGHT_EMPTY
update()
@@ -637,41 +649,90 @@
force = 2
throwforce = 5
w_class = 1
var/status = 0 // LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN
var/base_state
var/switchcount = 0 // number of times switched
matter = list(DEFAULT_WALL_MATERIAL = 60)
var/status = 0 // LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN
var/switchcount = 0 // number of times switched
var/rigged = 0 // true if rigged to explode
var/brightness_range = 2 //how much light it gives off
var/brightness_power = 1
var/brightness_color = null
var/brightness_color = LIGHT_COLOR_HALOGEN
var/lighttype = null
var/randomize_range = TRUE
/obj/item/weapon/light/tube
name = "light tube"
desc = "A replacement light tube."
icon_state = "ltube"
base_state = "ltube"
icon_state = "ltube_preset"//preset state for mapping
item_state = "c_tube"
matter = list("glass" = 100)
brightness_range = 8
brightness_power = 0.8
lighttype = "tube"
/obj/item/weapon/light/tube/colored/red
name = "red light tube"
brightness_color = LIGHT_COLOR_SCARLET
/obj/item/weapon/light/tube/colored/green
name = "green light tube"
brightness_color = LIGHT_COLOR_GREEN
/obj/item/weapon/light/tube/colored/blue
name = "blue light tube"
brightness_color = LIGHT_COLOR_BLUE
/obj/item/weapon/light/tube/colored/magenta
name = "magenta light tube"
brightness_color = LIGHT_COLOR_VIOLET
/obj/item/weapon/light/tube/colored/yellow
name = "yellow light tube"
brightness_color = LIGHT_COLOR_YELLOW
/obj/item/weapon/light/tube/colored/cyan
name = "cyan light tube"
brightness_color = LIGHT_COLOR_CYAN
/obj/item/weapon/light/tube/large
w_class = 2
name = "large light tube"
brightness_range = 15
brightness_power = 6
randomize_range = FALSE
/obj/item/weapon/light/bulb
name = "light bulb"
desc = "A replacement light bulb."
icon_state = "lbulb"
base_state = "lbulb"
icon_state = "lbulb_preset"//preset state for mapping
item_state = "contvapour"
matter = list("glass" = 100)
brightness_range = 5
brightness_power = 0.75
brightness_color = "#a0a080"
lighttype = "bulb"
/obj/item/weapon/light/bulb/colored/red
name = "red light bulb"
brightness_color = LIGHT_COLOR_SCARLET
/obj/item/weapon/light/bulb/colored/green
name = "green light bulb"
brightness_color = LIGHT_COLOR_GREEN
/obj/item/weapon/light/bulb/colored/blue
name = "blue light bulb"
brightness_color = LIGHT_COLOR_BLUE
/obj/item/weapon/light/bulb/colored/magenta
name = "magenta light bulb"
brightness_color = LIGHT_COLOR_VIOLET
/obj/item/weapon/light/bulb/colored/yellow
name = "yellow light bulb"
brightness_color = LIGHT_COLOR_YELLOW
/obj/item/weapon/light/bulb/colored/cyan
name = "cyan light bulb"
brightness_color = LIGHT_COLOR_CYAN
/obj/item/weapon/light/throw_impact(atom/hit_atom)
..()
@@ -680,37 +741,45 @@
/obj/item/weapon/light/bulb/fire
name = "fire bulb"
desc = "A replacement fire bulb."
icon_state = "fbulb"
base_state = "fbulb"
icon_state = "flight"
item_state = "egg4"
matter = list("glass" = 100)
brightness_range = 8
brightness_power = 0.8
randomize_range = FALSE
// update the icon state and description of the light
/obj/item/weapon/light/proc/update()
switch(status)
if(LIGHT_OK)
icon_state = base_state
desc = "A replacement [name]."
if(LIGHT_BURNED)
icon_state = "[base_state]-burned"
desc = "A burnt-out [name]."
if(LIGHT_BROKEN)
icon_state = "[base_state]-broken"
desc = "A broken [name]."
/obj/item/weapon/light/New()
..()
switch(name)
if("light tube")
brightness_range = rand(6,9)
if("light bulb")
brightness_range = rand(4,6)
/obj/item/weapon/light/Initialize()
. = ..()
if(randomize_range)
switch(lighttype)
if("tube")
brightness_range = rand(6,9)
if("bulb")
brightness_range = rand(4,6)
update()
// update the icon state and description of the light
/obj/item/weapon/light/proc/update()
cut_overlays()
switch(status)
if(LIGHT_OK)
icon_state = "l[lighttype]_attachment"
var/image/I = image(icon, "l[lighttype]")
I.color = brightness_color
add_overlay(I)
desc = "A replacement [name]."
if(LIGHT_BURNED)
icon_state = "l[lighttype]_attachment"
var/image/I = image(icon, "l[lighttype]_burned")
I.color = brightness_color
add_overlay(I)
desc = "A burnt-out [name]."
if(LIGHT_BROKEN)
icon_state = "l[lighttype]_attachment_broken"
var/image/I = image(icon, "l[lighttype]_broken")
I.color = brightness_color
add_overlay(I)
desc = "A broken [name]."
// attack bulb/tube with object
// if a syringe, can inject phoron to make it explode
@@ -161,6 +161,7 @@
if(!istype(T))
return
T.color = initial(T.color)
var/datum/gas_mixture/environment = T.return_air()
var/min_temperature = T0C + 100 // 100C, the boiling point of water
@@ -182,13 +183,24 @@
T.wet_floor(1)
/datum/reagent/water/touch_obj(var/obj/O)
if(istype(O, /obj/item/weapon/reagent_containers/food/snacks/monkeycube))
var/obj/item/weapon/reagent_containers/food/snacks/monkeycube/cube = O
if(!cube.wrapped)
cube.Expand()
if(istype(O))
O.color = initial(O.color)
if(istype(O, /obj/item/weapon/light))
var/obj/item/weapon/light/L = O
L.brightness_color = initial(L.brightness_color)
L.update()
else if(istype(O, /obj/machinery/light))
var/obj/machinery/light/L = O
L.brightness_color = initial(L.brightness_color)
L.update()
else if(istype(O, /obj/item/weapon/reagent_containers/food/snacks/monkeycube))
var/obj/item/weapon/reagent_containers/food/snacks/monkeycube/cube = O
if(!cube.wrapped)
cube.Expand()
/datum/reagent/water/touch_mob(var/mob/living/L, var/amount)
if(istype(L))
/datum/reagent/water/touch_mob(var/mob/M, var/amount)
if(istype(M) && isliving(M))
var/mob/living/L = M
var/needed = L.fire_stacks * 10
if(amount > needed)
L.fire_stacks = 0
@@ -198,6 +210,9 @@
L.adjust_fire_stacks(-(amount / 10))
remove_self(amount)
if(istype(M) && !istype(M, /mob/dead))
M.color = initial(M.color)
/datum/reagent/water/affect_touch(var/mob/living/carbon/M, var/alien, var/removed)
if(istype(M, /mob/living/carbon/slime))
var/mob/living/carbon/slime/S = M
@@ -64,7 +64,21 @@
T.color = color
/datum/reagent/paint/touch_obj(var/obj/O)
if(istype(O))
//special checks for special items
if(istype(O, /obj/item/weapon/reagent_containers))
return
else if(istype(O, /obj/item/weapon/light))
var/obj/item/weapon/light/L = O
L.brightness_color = color
L.update()
else if(istype(O, /obj/machinery/light))
var/obj/machinery/light/L = O
L.brightness_color = color
L.update()
else if(istype(O, /obj/item/clothing/suit/storage/det_trench/technicolor) || istype(O, /obj/item/clothing/head/det/technicolor))
return
else if(istype(O))
O.color = color
/datum/reagent/paint/touch_mob(var/mob/M)