[MIRROR] Lighting object oddities [MDB IGNORE] (#21945)

* Lighting object oddities (#76009)

## About The Pull Request

Fire stacks status effect no longer uses a weakref for the mob light, I
am pretty sure there was no real reason to use a weakref there.
Deleted weird luminescent glow dummy, now it just uses the standard
moblight obj.
Put all /obj/effect/dummy/lighting_obj together in a single file and
added a comment explaining why they exist.

(I severely dislike the /obj/effect/dummy typepath, but I am very much
unsure if just replacing all of them with /obj/effect/abstract would
break shit)

## Why It's Good For The Game

Code organization good

* Lighting object oddities

* Update kindle.dm

---------

Co-authored-by: ChungusGamer666 <82850673+ChungusGamer666@users.noreply.github.com>
Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-06-20 14:06:48 -07:00
committed by GitHub
co-authored by ChungusGamer666 lessthanthree
parent b43e8ed49e
commit 529b8b4464
16 changed files with 108 additions and 131 deletions
+1 -1
View File
@@ -129,7 +129,7 @@
antimagic_color = LIGHT_COLOR_DARK_BLUE
playsound(user, 'sound/magic/magic_block_mind.ogg', 50, TRUE)
user.mob_light(_range = 2, _color = antimagic_color, _duration = 5 SECONDS)
user.mob_light(range = 2, color = antimagic_color, duration = 5 SECONDS)
user.add_overlay(antimagic_effect)
addtimer(CALLBACK(user, TYPE_PROC_REF(/atom, cut_overlay), antimagic_effect), 50)
+15 -15
View File
@@ -230,47 +230,47 @@
quality = POSITIVE
text_gain_indication = "<span class='notice'>Your skin begins to glow softly.</span>"
instability = 5
var/obj/effect/dummy/luminescent_glow/glowth //shamelessly copied from luminescents
var/glow = 2.5
var/range = 2.5
var/glow_color
power_coeff = 1
conflicts = list(/datum/mutation/human/glow/anti)
var/glow_power = 2.5
var/glow_range = 2.5
var/glow_color
var/obj/effect/dummy/lighting_obj/moblight/glow
/datum/mutation/human/glow/on_acquiring(mob/living/carbon/human/owner)
. = ..()
if(.)
return
glow_color = glow_color()
glowth = new(owner)
glow_color = get_glow_color()
glow = owner.mob_light()
modify()
// Override modify here without a parent call, because we don't actually give an action.
/datum/mutation/human/glow/modify()
if(!glowth)
if(!glow)
return
glowth.set_light_range_power_color(range * GET_MUTATION_POWER(src), glow, glow_color)
/// Returns the color for the glow effect
/datum/mutation/human/glow/proc/glow_color()
return pick(COLOR_RED, COLOR_BLUE, COLOR_YELLOW, COLOR_GREEN, COLOR_PURPLE, COLOR_ORANGE)
glow.set_light_range_power_color(glow_range * GET_MUTATION_POWER(src), glow_power, glow_color)
/datum/mutation/human/glow/on_losing(mob/living/carbon/human/owner)
. = ..()
if(.)
return
QDEL_NULL(glowth)
QDEL_NULL(glow)
/// Returns a color for the glow effect
/datum/mutation/human/glow/proc/get_glow_color()
return pick(COLOR_RED, COLOR_BLUE, COLOR_YELLOW, COLOR_GREEN, COLOR_PURPLE, COLOR_ORANGE)
/datum/mutation/human/glow/anti
name = "Anti-Glow"
desc = "Your skin seems to attract and absorb nearby light creating 'darkness' around you."
text_gain_indication = "<span class='notice'>Your light around you seems to disappear.</span>"
text_gain_indication = "<span class='notice'>The light around you seems to disappear.</span>"
glow = -1.5
conflicts = list(/datum/mutation/human/glow)
locked = TRUE
/datum/mutation/human/glow/anti/glow_color()
/datum/mutation/human/glow/anti/get_glow_color()
return COLOR_BLACK
/datum/mutation/human/strong
@@ -152,12 +152,12 @@
/// If we're on fire
var/on_fire = FALSE
/// A weakref to the mob light emitter
var/datum/weakref/firelight_ref
/// Type of mob light emitter we use when on fire
var/firelight_type = /obj/effect/dummy/lighting_obj/moblight/fire
/// Stores current fire overlay icon state, for optimisation purposes
var/last_icon_state
/// Reference to the mob light emitter itself
var/obj/effect/dummy/lighting_obj/moblight
/// Type of mob light emitter we use when on fire
var/moblight_type = /obj/effect/dummy/lighting_obj/moblight/fire
/datum/status_effect/fire_handler/fire_stacks/tick(seconds_per_tick, times_fired)
if(stacks <= 0)
@@ -249,8 +249,10 @@
if(!silent)
owner.visible_message(span_warning("[owner] catches fire!"), span_userdanger("You're set on fire!"))
if(firelight_type)
firelight_ref = WEAKREF(new firelight_type(owner))
if(moblight_type)
if(moblight)
qdel(moblight)
moblight = new moblight_type(owner)
SEND_SIGNAL(owner, COMSIG_LIVING_IGNITED, owner)
cache_stacks()
@@ -263,9 +265,7 @@
*/
/datum/status_effect/fire_handler/fire_stacks/proc/extinguish()
if(firelight_ref)
qdel(firelight_ref)
QDEL_NULL(moblight)
on_fire = FALSE
owner.clear_mood_event("on_fire")
SEND_SIGNAL(owner, COMSIG_LIVING_EXTINGUISHED, owner)
@@ -290,6 +290,11 @@
. = ..()
update_overlay()
/obj/effect/dummy/lighting_obj/moblight/fire
name = "fire"
light_color = LIGHT_COLOR_FIRE
light_range = LIGHT_RANGE_FIRE
/datum/status_effect/fire_handler/wet_stacks
id = "wet_stacks"
+1 -1
View File
@@ -55,7 +55,7 @@
/obj/effect/abstract/singularity_act()
return
/obj/effect/abstract/has_gravity(turf/T)
/obj/effect/abstract/has_gravity(turf/gravity_turf)
return FALSE
/obj/effect/dummy/singularity_pull()
+42
View File
@@ -0,0 +1,42 @@
/**
* Basically, a fake object that emits light.
*
* Why is this used sometimes instead of giving atoms light values directly?
* Because using these, you can have multiple light sources in a single object.
*/
/obj/effect/dummy/lighting_obj
name = "lighting"
desc = "Tell a coder if you're seeing this."
icon_state = "nothing"
light_system = MOVABLE_LIGHT
light_range = MINIMUM_USEFUL_LIGHT_RANGE
light_color = COLOR_WHITE
blocks_emissive = EMISSIVE_BLOCK_NONE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/obj/effect/dummy/lighting_obj/Initialize(mapload, range, power, color, duration)
. = ..()
if(!isnull(range))
set_light_range(range)
if(!isnull(power))
set_light_power(power)
if(!isnull(color))
set_light_color(color)
if(duration)
QDEL_IN(src, duration)
/obj/effect/dummy/lighting_obj/moblight
name = "mob lighting"
/obj/effect/dummy/lighting_obj/moblight/Initialize(mapload, range, power, color, duration)
. = ..()
if(!ismob(loc))
return INITIALIZE_HINT_QDEL
/obj/effect/dummy/lighting_obj/moblight/fire
name = "mob fire lighting"
light_color = LIGHT_COLOR_FIRE
light_range = LIGHT_RANGE_FIRE
/obj/effect/dummy/lighting_obj/moblight/species
name = "species lighting"
-30
View File
@@ -78,33 +78,3 @@
/obj/effect/abstract/marker/intercom
name = "intercom range marker"
color = COLOR_YELLOW
/obj/effect/dummy/lighting_obj
name = "lighting fx obj"
desc = "Tell a coder if you're seeing this."
icon_state = "nothing"
light_system = MOVABLE_LIGHT
light_range = MINIMUM_USEFUL_LIGHT_RANGE
light_color = COLOR_WHITE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
blocks_emissive = EMISSIVE_BLOCK_NONE
/obj/effect/dummy/lighting_obj/Initialize(mapload, _range, _power, _color, _duration)
. = ..()
if(!isnull(_range))
set_light_range(_range)
if(!isnull(_power))
set_light_power(_power)
if(!isnull(_color))
set_light_color(_color)
if(_duration)
QDEL_IN(src, _duration)
/obj/effect/dummy/lighting_obj/moblight
name = "mob lighting fx"
/obj/effect/dummy/lighting_obj/moblight/Initialize(mapload, _color, _range, _power, _duration)
. = ..()
if(!ismob(loc))
return INITIALIZE_HINT_QDEL
+1 -3
View File
@@ -407,9 +407,7 @@
if(IS_CULTIST(user))
user.visible_message(span_warning("[user] holds up [user.p_their()] hand, which explodes in a flash of red light!"), \
span_cultitalic("You attempt to stun [target] with the spell!"))
user.mob_light(_range = 3, _color = LIGHT_COLOR_BLOOD_MAGIC, _duration = 0.2 SECONDS)
user.mob_light(range = 3, color = LIGHT_COLOR_BLOOD_MAGIC, duration = 0.2 SECONDS)
if(IS_HERETIC(target))
to_chat(user, span_warning("Some force greater than you intervenes! [target] is protected by the Forgotten Gods!"))
to_chat(target, span_warning("You are protected by your faith to the Forgotten Gods."))
@@ -310,9 +310,4 @@
/obj/effect/hotspot/singularity_pull()
return
/obj/effect/dummy/lighting_obj/moblight/fire
name = "fire"
light_color = LIGHT_COLOR_FIRE
light_range = LIGHT_RANGE_FIRE
#undef INSUFFICIENT
+9 -23
View File
@@ -42,7 +42,6 @@
else
light = new/datum/light_source(src, .)
/**
* Updates the atom's opacity value.
*
@@ -56,7 +55,6 @@
. = opacity
opacity = new_opacity
/atom/movable/set_opacity(new_opacity)
. = ..()
if(isnull(.) || !isturf(loc))
@@ -67,35 +65,23 @@
else
RemoveElement(/datum/element/light_blocking)
/turf/set_opacity(new_opacity)
. = ..()
if(isnull(.))
return
recalculate_directional_opacity()
/atom/proc/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION)
return
/atom/proc/flash_lighting_fx(range = FLASH_LIGHT_RANGE, power = FLASH_LIGHT_POWER, color = COLOR_WHITE, duration = FLASH_LIGHT_DURATION, light_type = /obj/effect/dummy/lighting_obj)
if(!duration)
stack_trace("Lighting FX obj created on \[[type]\] without a duration")
var/obj/effect/dummy/light_obj = new light_type(get_turf(src), range, power, color, duration)
return light_obj
/mob/living/flash_lighting_fx(range = FLASH_LIGHT_RANGE, power = FLASH_LIGHT_POWER, color = COLOR_WHITE, duration = FLASH_LIGHT_DURATION, light_type = /obj/effect/dummy/lighting_obj/moblight)
return mob_light(range, power, color, duration)
/turf/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION)
if(!_duration)
stack_trace("Lighting FX obj created on a turf without a duration")
new /obj/effect/dummy/lighting_obj (src, _range, _power, _color, _duration)
/obj/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION)
if(!_duration)
stack_trace("Lighting FX obj created on a obj without a duration")
new /obj/effect/dummy/lighting_obj (get_turf(src), _range, _power, _color, _duration)
/mob/living/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION)
mob_light(_range, _power, _color, _duration)
/mob/living/proc/mob_light(_range, _power, _color, _duration)
var/obj/effect/dummy/lighting_obj/moblight/mob_light_obj = new (src, _range, _power, _color, _duration)
/mob/living/proc/mob_light(range, power, color, duration, light_type = /obj/effect/dummy/lighting_obj/moblight)
var/obj/effect/dummy/lighting_obj/moblight/mob_light_obj = new light_type(src, range, power, color, duration)
return mob_light_obj
/// Setter for the light power of this atom.
@@ -61,14 +61,10 @@
var/obj/effect/dummy/lighting_obj/ethereal_light
var/default_color
/datum/species/ethereal/Destroy(force)
if(ethereal_light)
QDEL_NULL(ethereal_light)
QDEL_NULL(ethereal_light)
return ..()
/datum/species/ethereal/on_species_gain(mob/living/carbon/new_ethereal, datum/species/old_species, pref_load)
. = ..()
if(!ishuman(new_ethereal))
@@ -81,7 +77,7 @@
RegisterSignal(ethereal, COMSIG_ATOM_EMAG_ACT, PROC_REF(on_emag_act))
RegisterSignal(ethereal, COMSIG_ATOM_EMP_ACT, PROC_REF(on_emp_act))
RegisterSignal(ethereal, COMSIG_LIGHT_EATER_ACT, PROC_REF(on_light_eater))
ethereal_light = ethereal.mob_light()
ethereal_light = ethereal.mob_light(light_type = /obj/effect/dummy/lighting_obj/moblight/species)
spec_updatehealth(ethereal)
new_ethereal.set_safe_hunger_level()
update_mail_goodies(ethereal)
@@ -497,7 +497,7 @@
/// How strong is our glow
var/glow_intensity = LUMINESCENT_DEFAULT_GLOW
/// Internal dummy used to glow (very cool)
var/obj/effect/dummy/luminescent_glow/glow
var/obj/effect/dummy/lighting_obj/moblight/glow
/// The slime extract we currently have integrated
var/obj/item/slime_extract/current_extract
/// A list of all luminescent related actions we have
@@ -505,25 +505,16 @@
/// The cooldown of us using exteracts
COOLDOWN_DECLARE(extract_cooldown)
//Species datums don't normally implement destroy, but JELLIES SUCK ASS OUT OF A STEEL STRAW
/datum/species/jelly/luminescent/Destroy(force, ...)
//Species datums don't normally implement destroy, but JELLIES SUCK ASS OUT OF A STEEL STRAW and have to i guess
/datum/species/jelly/luminescent/Destroy(force)
current_extract = null
QDEL_NULL(glow)
QDEL_LIST(luminescent_actions)
return ..()
/datum/species/jelly/luminescent/on_species_loss(mob/living/carbon/C)
. = ..()
if(current_extract)
current_extract.forceMove(C.drop_location())
current_extract = null
QDEL_NULL(glow)
QDEL_LIST(luminescent_actions)
/datum/species/jelly/luminescent/on_species_gain(mob/living/carbon/new_jellyperson, datum/species/old_species)
. = ..()
glow = new(new_jellyperson)
glow = new_jellyperson.mob_light(light_type = /obj/effect/dummy/lighting_obj/moblight/species)
update_glow(new_jellyperson)
luminescent_actions = list()
@@ -540,26 +531,19 @@
extract_major.Grant(new_jellyperson)
luminescent_actions += integrate_extract
/// Updates the glow of our internal glow thing.
/datum/species/jelly/luminescent/proc/update_glow(mob/living/carbon/C, intensity)
/datum/species/jelly/luminescent/on_species_loss(mob/living/carbon/C)
. = ..()
if(current_extract)
current_extract.forceMove(C.drop_location())
current_extract = null
QDEL_NULL(glow)
QDEL_LIST(luminescent_actions)
/// Updates the glow of our internal glow object
/datum/species/jelly/luminescent/proc/update_glow(mob/living/carbon/human/glowie, intensity)
if(intensity)
glow_intensity = intensity
glow.set_light_range_power_color(glow_intensity, glow_intensity, C.dna.features["mcolor"])
/obj/effect/dummy/luminescent_glow
name = "luminescent glow"
desc = "Tell a coder if you're seeing this."
icon_state = "nothing"
light_system = MOVABLE_LIGHT
light_range = LUMINESCENT_DEFAULT_GLOW
light_power = 2.5
light_color = COLOR_WHITE
/obj/effect/dummy/luminescent_glow/Initialize(mapload)
. = ..()
if(!isliving(loc))
return INITIALIZE_HINT_QDEL
glow.set_light_range_power_color(glow_intensity, glow_intensity, glowie.dna.features["mcolor"])
/datum/action/innate/integrate_extract
name = "Integrate Extract"
@@ -222,7 +222,7 @@
return ..()
// We are literally a vessel of otherworldly destruction, we bring our own gravity unto this plane
/mob/living/simple_animal/hostile/heretic_summon/armsy/has_gravity(turf/T)
/mob/living/simple_animal/hostile/heretic_summon/armsy/has_gravity(turf/gravity_turf)
return TRUE
/mob/living/simple_animal/hostile/heretic_summon/armsy/can_be_pulled()
+1 -1
View File
@@ -352,7 +352,7 @@
continue
return rebound
/mob/has_gravity()
/mob/has_gravity(turf/gravity_turf)
return mob_negates_gravity() || ..()
/**
@@ -294,7 +294,7 @@
var/range = created_volume/3
if(isatom(holder.my_atom))
var/atom/A = holder.my_atom
A.flash_lighting_fx(_range = (range + 2))
A.flash_lighting_fx(range = (range + 2))
for(var/mob/living/C in get_hearers_in_view(range, location))
if(C.flash_act(affect_silicon = TRUE))
if(get_dist(C, location) < 4)
@@ -314,7 +314,7 @@
var/range = created_volume/10
if(isatom(holder.my_atom))
var/atom/A = holder.my_atom
A.flash_lighting_fx(_range = (range + 2))
A.flash_lighting_fx(range = (range + 2))
for(var/mob/living/C in get_hearers_in_view(range, location))
if(C.flash_act(affect_silicon = TRUE))
if(get_dist(C, location) < 4)
@@ -30,7 +30,7 @@
// Chaplains are understandably 100% immune
if(hit_mob.can_block_magic(MAGIC_RESISTANCE_HOLY))
hit_mob.mob_light(_color = LIGHT_COLOR_HOLY_MAGIC, _range = 2, _duration = 10 SECONDS)
hit_mob.mob_light(color = LIGHT_COLOR_HOLY_MAGIC, range = 2, duration = 10 SECONDS)
var/mutable_appearance/forbearance = mutable_appearance('icons/effects/genetics.dmi', "servitude", -MUTATIONS_LAYER)
hit_mob.add_overlay(forbearance)
@@ -44,7 +44,7 @@
//To make battles more fun, both sides can't bullshit stun hand the other
if(IS_CULTIST(hit_mob))
hit_mob.mob_light(_color = LIGHT_COLOR_BLOOD_MAGIC, _range = 2, _duration = 30 SECONDS)
hit_mob.mob_light(color = LIGHT_COLOR_BLOOD_MAGIC, range = 2, duration = 30 SECONDS)
hit_mob.adjust_stutter(15 SECONDS)
hit_mob.adjust_jitter(15 SECONDS)
@@ -62,7 +62,7 @@
return TRUE
//Successful Invokation
invoker.mob_light(_color = LIGHT_COLOR_CLOCKWORK, _range = 2, _duration = 1 SECONDS)
invoker.mob_light(color = LIGHT_COLOR_CLOCKWORK, range = 2, duration = 1 SECONDS)
if(issilicon(hit_mob))
var/mob/living/silicon/borgo = hit_mob
+1
View File
@@ -1807,6 +1807,7 @@
#include "code\game\objects\effects\glowshroom.dm"
#include "code\game\objects\effects\info.dm"
#include "code\game\objects\effects\landmarks.dm"
#include "code\game\objects\effects\lighting.dm"
#include "code\game\objects\effects\mines.dm"
#include "code\game\objects\effects\misc.dm"
#include "code\game\objects\effects\overlays.dm"