Skip to content

Commit

Permalink
light floors emit colored lights (#51097)
Browse files Browse the repository at this point in the history
* 1

* 2

* debines

* knojbhgfxychgvjbkn

* better emp (test later)

* alt

* | || || |_

* scewact
  • Loading branch information
Tlaltecuhtli committed Jun 3, 2020
1 parent 386b507 commit 3ca1913
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 48 deletions.
11 changes: 0 additions & 11 deletions code/game/objects/items/stacks/tiles/light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
turf_type = /turf/open/floor/light
var/state = 0

/obj/item/stack/tile/light/Initialize(mapload, new_amount, merge = TRUE)
. = ..()
if(prob(5))
state = 3 //broken
else if(prob(5))
state = 2 //breaking
else if(prob(10))
state = 1 //flickering occasionally
else
state = 0 //fine

/obj/item/stack/tile/light/attackby(obj/item/O, mob/user, params)
if(O.tool_behaviour == TOOL_CROWBAR)
new/obj/item/stack/sheet/metal(user.loc)
Expand Down
118 changes: 81 additions & 37 deletions code/game/turfs/open/floor/light_floor.dm
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
#define LIGHTFLOOR_FINE 0
#define LIGHTFLOOR_FLICKER 1
#define LIGHTFLOOR_BREAKING 2
#define LIGHTFLOOR_BROKEN 3

/turf/open/floor/light
name = "light floor"
desc = "A wired glass tile embedded into the floor. Modify the color with a Multitool."
light_range = 5
icon_state = "light_on"
icon_state = "light_on-1"
floor_tile = /obj/item/stack/tile/light
broken_states = list("light_broken")
///var to see if its on or off
var/on = TRUE
var/state = 0//0 = fine, 1 = flickering, 2 = breaking, 3 = broken
var/static/list/coloredlights = list("r", "o", "y", "g", "b", "i", "v", "w", "s", "z")
var/currentcolor = "b"
///defines on top
var/state = LIGHTFLOOR_FINE
///list of colours to choose
var/static/list/coloredlights = list(LIGHT_COLOR_CYAN, LIGHT_COLOR_RED, LIGHT_COLOR_ORANGE, LIGHT_COLOR_GREEN, LIGHT_COLOR_YELLOW, LIGHT_COLOR_DARK_BLUE, LIGHT_COLOR_LAVENDER, LIGHT_COLOR_WHITE, LIGHT_COLOR_SLIME_LAMP, LIGHT_COLOR_FIRE)
///current light color
var/currentcolor = LIGHT_COLOR_CYAN
///var to prevent changing color on certain admin spawn only tiles
var/can_modify_colour = TRUE
tiled_dirt = FALSE
///icons for radial menu
var/static/list/lighttile_designs

/turf/open/floor/light/examine(mob/user)
. = ..()
. += "<span class='notice'>There's a <b>small crack</b> on the edge of it.</span>"
. += "<span class='notice'>Use a multitool on it to change colors.</span>"
. += "<span class='notice'>Use a screwdriver to turn it off or on.</span>"
if(state) ///check if broken
. += "<span class='danger'>The light bulb seems fried!</span>"

///create radial menu
/turf/open/floor/light/proc/populate_lighttile_designs()
lighttile_designs = list(
"r" = image(icon = src.icon, icon_state = "light_on-r"),
"o" = image(icon = src.icon, icon_state = "light_on-o"),
"y" = image(icon = src.icon, icon_state = "light_on-y"),
"g" = image(icon = src.icon, icon_state = "light_on-g"),
"b" = image(icon = src.icon, icon_state = "light_on-b"),
"i" = image(icon = src.icon, icon_state = "light_on-i"),
"v" = image(icon = src.icon, icon_state = "light_on-v"),
"w" = image(icon = src.icon, icon_state = "light_on-w"),
"blk" = image(icon = src.icon, icon_state = "light_on-blk"),
"s" = image(icon = src.icon, icon_state = "light_on-s"),
"z" = image(icon = src.icon, icon_state = "light_on-z")
LIGHT_COLOR_CYAN = image(icon = src.icon, icon_state = "light_on-1"),
LIGHT_COLOR_RED = image(icon = src.icon, icon_state = "light_on-2"),
LIGHT_COLOR_ORANGE = image(icon = src.icon, icon_state = "light_on-3"),
LIGHT_COLOR_GREEN = image(icon = src.icon, icon_state = "light_on-4"),
LIGHT_COLOR_YELLOW = image(icon = src.icon, icon_state = "light_on-5"),
LIGHT_COLOR_DARK_BLUE = image(icon = src.icon, icon_state = "light_on-6"),
LIGHT_COLOR_LAVENDER = image(icon = src.icon, icon_state = "light_on-7"),
LIGHT_COLOR_WHITE = image(icon = src.icon, icon_state = "light_on-8"),
LIGHT_COLOR_SLIME_LAMP = image(icon = src.icon, icon_state = "light_on-9"),
LIGHT_COLOR_FIRE = image(icon = src.icon, icon_state = "light_on-10")
)

/turf/open/floor/light/Initialize()
Expand All @@ -40,81 +55,105 @@

/turf/open/floor/light/break_tile()
..()
light_range = 0
update_light()
state = pick(LIGHTFLOOR_FLICKER, LIGHTFLOOR_BREAKING, LIGHTFLOOR_BROKEN)/// pick a broken state
update_icon()

/turf/open/floor/light/update_icon()
..()
if(on)
switch(state)
if(0)
icon_state = "light_on-[currentcolor]"
set_light(1)
if(1)
var/num = pick("1","2","3","4")
icon_state = "light_on_flicker[num]"
set_light(1)
if(2)
if(LIGHTFLOOR_FINE)
icon_state = "light_on-[LAZYFIND(coloredlights, currentcolor)]"
light_color = currentcolor
set_light(5)
light_range = 3
if(LIGHTFLOOR_FLICKER)
icon_state = "light_on_flicker-[LAZYFIND(coloredlights, currentcolor)]"
light_color = currentcolor
set_light(3)
light_range = 2
if(LIGHTFLOOR_BREAKING)
icon_state = "light_on_broken"
set_light(1)
if(3)
if(LIGHTFLOOR_BROKEN)
icon_state = "light_off"
set_light(0)
else
set_light(0)
icon_state = "light_off"


/turf/open/floor/light/ChangeTurf(path, new_baseturf, flags)
set_light(0)
return ..()

/turf/open/floor/light/screwdriver_act(mob/living/user, obj/item/I)
. = ..()
if(!can_modify_colour)
return
on = !on
update_icon()

/turf/open/floor/light/multitool_act(mob/living/user, obj/item/I)
. = ..()
if(.)
return
if(!can_modify_colour)
return
return FALSE
var/choice = show_radial_menu(user,src, lighttile_designs, custom_check = CALLBACK(src, .proc/check_menu, user, I), radius = 36, require_near = TRUE)
if(!choice)
return FALSE
currentcolor = choice
update_icon()

/turf/open/floor/light/attack_ai(mob/user)
return attack_hand(user)

/turf/open/floor/light/attackby(obj/item/C, mob/user, params)
if(..())
return
if(istype(C, /obj/item/light/bulb)) //only for light tiles
var/obj/item/light/bulb/B = C
if(B.status)/// check if broken
to_chat(user, "<span class='danger'>The light bulb is broken!</span>")
return
if(state && user.temporarilyRemoveItemFromInventory(C))
qdel(C)
state = 0 //fixing it by bashing it with a light bulb, fun eh?
state = LIGHTFLOOR_FINE //fixing it by bashing it with a light bulb, fun eh?
update_icon()
to_chat(user, "<span class='notice'>You replace the light bulb.</span>")
else
to_chat(user, "<span class='notice'>The light bulb seems fine, no need to replace it.</span>")

/turf/open/floor/light/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
currentcolor = pick(coloredlights)
if(state == LIGHTFLOOR_BROKEN) /// he's dead, jim
return
if(prob(50))
state++
currentcolor = pick(coloredlights)
update_icon()

//Cycles through all of the colours
/turf/open/floor/light/colour_cycle
currentcolor = "cycle_all"
icon_state = "cycle_all"
light_color = LIGHT_COLOR_SLIME_LAMP
can_modify_colour = FALSE



//Two different "dancefloor" types so that you can have a checkered pattern
// (also has a longer delay than colour_cycle between cycling colours)
/turf/open/floor/light/colour_cycle/dancefloor_a
name = "dancefloor"
desc = "Funky floor."
currentcolor = "dancefloor_A"
icon_state = "light_on-dancefloor_A"
light_color =LIGHT_COLOR_SLIME_LAMP
can_modify_colour = FALSE

/turf/open/floor/light/colour_cycle/dancefloor_b
name = "dancefloor"
desc = "Funky floor."
currentcolor = "dancefloor_A"
icon_state = "light_on-dancefloor_B"
light_color = LIGHT_COLOR_SLIME_LAMP
can_modify_colour = FALSE

/**
* check_menu: Checks if we are allowed to interact with a radial menu
Expand All @@ -131,3 +170,8 @@
if(!multitool || !user.is_holding(multitool))
return FALSE
return TRUE

#undef LIGHTFLOOR_FINE
#undef LIGHTFLOOR_FLICKER
#undef LIGHTFLOOR_BREAKING
#undef LIGHTFLOOR_BROKEN
Binary file modified icons/turf/floors.dmi
Binary file not shown.

0 comments on commit 3ca1913

Please sign in to comment.