Files
Paradise/code/modules/lighting/lighting_atom.dm
Charlie 634f9c72f1 Vampire Rework. (#16476)
* vampire rework

* fixes and tweaks

* cleanup + tweaks

* grug stomp

* TGUI

* TGUI rebuild

* UID fix

* debugging cooldown fix

* first review changes

* subclass refactor

* tweaks + some sprites

* blackbox logging

* tweaks + grammar

* minor UI tweaks

* ability icon sprites.

* placeholder sprite warning fix

* melee mod code comment warning

* nullification rework

* final sprites!

* fixes

* sabre review pt 1

Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com>

* sabre review pt2

* sprites readd

* tgui rebuild

* removes traitor vampires

* fixes

* readds sprites

* runtime fixes

* hotfix

* more runtime fixes

* glare tweak. less confusing when the vampire is stunned.

* gargantua nerf

* minor tweaks.

* hemomancer nerfs

* bugfixes and cleanup

* I did a dumb

* couple of fixes

* confusion and shadow snare fixes

* hemomancer nerfs part 2 electric boogaloo

* TGUI rebuild

* fixes and easier events

* Umbrae tweaks

* gargantua tweak

* umbrae nerf 2 electric boogaloo. also var edit suggestion

* runtime fix

* buffs blood nutrition to be in line with its metabolic rate

* Henk stuff

Co-authored-by: Farie82 <farie82@users.noreply.github.com>

* more review changes

* final tweak

* affected request + runtime fix

* FUCK

* fat fucks

* darkness tweaks

* UMBRAE AAAAAAAAAAAAAHH

* force doors bugfix

* either git or I am drunk

* admin rejuv fix

* I CANNOT SPELL

* shitnt code

* steel review

* tgui rebuild

* mochi review

* vampire ability usage logging

Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com>
Co-authored-by: Farie82 <farie82@users.noreply.github.com>
2021-11-14 15:34:56 +01:00

132 lines
4.6 KiB
Plaintext

/atom
var/light_power = 1 // Intensity of the light.
var/light_range = 0 // Range in tiles of the light.
var/light_color // Hexadecimal RGB string representing the colour of the light.
var/tmp/datum/light_source/light // Our light source. Don't fuck with this directly unless you have a good reason!
var/tmp/list/light_sources // Any light sources that are "inside" of us, for example, if src here was a mob that's carrying a flashlight, that flashlight's light source would be part of this list.
// The proc you should always use to set the light of this atom.
// Nonesensical value for l_color default, so we can detect if it gets set to null.
#define NONSENSICAL_VALUE -99999
/atom/proc/set_light(l_range, l_power, l_color = NONSENSICAL_VALUE)
if(l_range > 0 && l_range < MINIMUM_USEFUL_LIGHT_RANGE)
l_range = MINIMUM_USEFUL_LIGHT_RANGE //Brings the range up to 1.4, which is just barely brighter than the soft lighting that surrounds players.
if(l_power != null)
light_power = l_power
if(l_range != null)
light_range = l_range
if(l_color != NONSENSICAL_VALUE)
light_color = l_color
SEND_SIGNAL(src, COMSIG_ATOM_SET_LIGHT, l_range, l_power, l_color)
update_light()
#undef NONSENSICAL_VALUE
/atom/proc/remove_light()
light_power = 0
light_range = 0
light_color = 0
update_light()
// Will update the light (duh).
// Creates or destroys it if needed, makes it update values, makes sure it's got the correct source turf...
/atom/proc/update_light()
set waitfor = FALSE
if(QDELETED(src))
return
if(!light_power || !light_range) // We won't emit light anyways, destroy the light source.
QDEL_NULL(light)
else
if(!ismovable(loc)) // We choose what atom should be the top atom of the light here.
. = src
else
. = loc
if(light) // Update the light or create it if it does not exist.
light.update(.)
else
light = new/datum/light_source(src, .)
/atom/proc/extinguish_light()
return
// If we have opacity, make sure to tell (potentially) affected light sources.
/atom/movable/Destroy()
var/turf/T = loc
. = ..()
if(opacity && istype(T))
var/old_has_opaque_atom = T.has_opaque_atom
T.recalc_atom_opacity()
if(old_has_opaque_atom != T.has_opaque_atom)
T.reconsider_lights()
// Should always be used to change the opacity of an atom.
// It notifies (potentially) affected light sources so they can update (if needed).
/atom/proc/set_opacity(new_opacity)
if(new_opacity == opacity)
return
opacity = new_opacity
var/turf/T = loc
if(!isturf(T))
return
if(new_opacity == TRUE)
T.has_opaque_atom = TRUE
T.reconsider_lights()
else
var/old_has_opaque_atom = T.has_opaque_atom
T.recalc_atom_opacity()
if(old_has_opaque_atom != T.has_opaque_atom)
T.reconsider_lights()
/atom/vv_edit_var(var_name, var_value)
switch (var_name)
if("light_range")
set_light(l_range=var_value)
return TRUE
if("light_power")
set_light(l_power=var_value)
return TRUE
if("light_color")
set_light(l_color=var_value)
return TRUE
return ..()
/atom/proc/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
return
/turf/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
if(!_duration)
stack_trace("Lighting FX obj created on a turf without a duration")
new /obj/effect/dummy/lighting_obj (src, _color, _range, _power, _duration)
/obj/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
var/temp_color
var/temp_power
var/temp_range
if(!_reset_lighting) //incase the obj already has a lighting color that you don't want cleared out after, ie computer monitors.
temp_color = light_color
temp_power = light_power
temp_range = light_range
set_light(_range, _power, _color)
addtimer(CALLBACK(src, /atom/proc/set_light, _reset_lighting ? initial(light_range) : temp_range, _reset_lighting ? initial(light_power) : temp_power, _reset_lighting ? initial(light_color) : temp_color), _duration, TIMER_OVERRIDE|TIMER_UNIQUE)
/mob/living/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = LIGHT_COLOR_WHITE, _duration = FLASH_LIGHT_DURATION, _reset_lighting = TRUE)
mob_light(_color, _range, _power, _duration)
/mob/living/proc/mob_light(_color, _range, _power, _duration)
var/obj/effect/dummy/lighting_obj/moblight/mob_light_obj = new (src, _color, _range, _power, _duration)
return mob_light_obj