From b7bd579dee1b60a398d539457126c22fbd4891bb Mon Sep 17 00:00:00 2001 From: Ghilker <42839747+Ghilker@users.noreply.github.com> Date: Sun, 8 May 2022 19:57:30 +0200 Subject: [PATCH] Supermatter zaps now are colored based on the power (#66639) Supermatter zaps will now start with a red color on low power, shifting towards blue for higher powers --- code/datums/beam.dm | 28 +++++++++++++------ code/modules/power/supermatter/supermatter.dm | 8 ++++-- .../power/supermatter/supermatter_process.dm | 5 +++- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/code/datums/beam.dm b/code/datums/beam.dm index f0149edf7ad..bb67f55632d 100644 --- a/code/datums/beam.dm +++ b/code/datums/beam.dm @@ -28,14 +28,17 @@ var/beam_type = /obj/effect/ebeam ///This is used as the visual_contents of beams, so you can apply one effect to this and the whole beam will look like that. never gets deleted on redrawing. var/obj/effect/ebeam/visuals + ///The color of the beam we're drawing. + var/beam_color -/datum/beam/New(beam_origin,beam_target,beam_icon='icons/effects/beam.dmi',beam_icon_state="b_beam",time=INFINITY,maxdistance=INFINITY,btype = /obj/effect/ebeam) - origin = beam_origin - target = beam_target - max_distance = maxdistance - icon = beam_icon - icon_state = beam_icon_state - beam_type = btype +/datum/beam/New(origin, target, icon = 'icons/effects/beam.dmi', icon_state = "b_beam", time = INFINITY, max_distance = INFINITY, beam_type = /obj/effect/ebeam, beam_color = null) + src.origin = origin + src.target = target + src.icon = icon + src.icon_state = icon_state + src.max_distance = max_distance + src.beam_type = beam_type + src.beam_color = beam_color if(time < INFINITY) QDEL_IN(src, time) @@ -46,6 +49,9 @@ visuals = new beam_type() visuals.icon = icon visuals.icon_state = icon_state + visuals.color = beam_color + visuals.layer = ABOVE_ALL_MOB_LAYER + visuals.update_appearance() Draw() RegisterSignal(origin, COMSIG_MOVABLE_MOVED, .proc/redrawing) RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/redrawing) @@ -139,6 +145,10 @@ anchored = TRUE var/datum/beam/owner +/obj/effect/ebeam/update_overlays() + . = ..() + . += emissive_appearance(icon, icon_state) + /obj/effect/ebeam/Destroy() owner = null return ..() @@ -160,7 +170,7 @@ * maxdistance: how far the beam will go before stopping itself. Used mainly for two things: preventing lag if the beam may go in that direction and setting a range to abilities that use beams. * beam_type: The type of your custom beam. This is for adding other wacky stuff for your beam only. Most likely, you won't (and shouldn't) change it. */ -/atom/proc/Beam(atom/BeamTarget,icon_state="b_beam",icon='icons/effects/beam.dmi',time=INFINITY,maxdistance=INFINITY,beam_type=/obj/effect/ebeam) - var/datum/beam/newbeam = new(src,BeamTarget,icon,icon_state,time,maxdistance,beam_type) +/atom/proc/Beam(atom/BeamTarget,icon_state="b_beam",icon='icons/effects/beam.dmi',time=INFINITY,maxdistance=INFINITY,beam_type=/obj/effect/ebeam, beam_color = null) + var/datum/beam/newbeam = new(src,BeamTarget,icon,icon_state,time,maxdistance,beam_type, beam_color) INVOKE_ASYNC(newbeam, /datum/beam/.proc/Start) return newbeam diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index f70c5887bea..29aa61a4ba4 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -256,6 +256,8 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) var/freonbonus = 0 ///Can the crystal trigger the station wide anomaly spawn? var/anomaly_event = TRUE + ///Hue shift of the zaps color based on the power of the crystal + var/hue_angle_shift = 0 ///If an admin wants a sure cascade with the delamination just set this to true (don't be a badmin) var/admin_cascade = FALSE ///Do we have a destabilizing crystal attached? @@ -523,7 +525,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) if(VORTEX_ANOMALY) new /obj/effect/anomaly/bhole(local_turf, 20, FALSE) -/obj/machinery/proc/supermatter_zap(atom/zapstart = src, range = 5, zap_str = 4000, zap_flags = ZAP_SUPERMATTER_FLAGS, list/targets_hit = list(), zap_cutoff = 1500, power_level = 0, zap_icon = DEFAULT_ZAP_ICON_STATE) +/obj/machinery/proc/supermatter_zap(atom/zapstart = src, range = 5, zap_str = 4000, zap_flags = ZAP_SUPERMATTER_FLAGS, list/targets_hit = list(), zap_cutoff = 1500, power_level = 0, zap_icon = DEFAULT_ZAP_ICON_STATE, color = null) if(QDELETED(zapstart)) return . = zapstart.dir @@ -612,7 +614,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) //Do the animation to zap to it from here if(!(zap_flags & ZAP_ALLOW_DUPLICATES)) LAZYSET(targets_hit, target, TRUE) - zapstart.Beam(target, icon_state=zap_icon, time = 0.5 SECONDS) + zapstart.Beam(target, icon_state=zap_icon, time = 0.5 SECONDS, beam_color = color) var/zapdir = get_dir(zapstart, target) if(zapdir) . = zapdir @@ -661,7 +663,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) var/child_targets_hit = targets_hit if(zap_count > 1) child_targets_hit = targets_hit.Copy() //Pass by ref begone - supermatter_zap(target, new_range, zap_str, zap_flags, child_targets_hit, zap_cutoff, power_level, zap_icon) + supermatter_zap(target, new_range, zap_str, zap_flags, child_targets_hit, zap_cutoff, power_level, zap_icon, color) /obj/machinery/power/supermatter_crystal/engine is_main_engine = TRUE diff --git a/code/modules/power/supermatter/supermatter_process.dm b/code/modules/power/supermatter/supermatter_process.dm index e60be796a7a..4c55959031a 100644 --- a/code/modules/power/supermatter/supermatter_process.dm +++ b/code/modules/power/supermatter/supermatter_process.dm @@ -279,13 +279,16 @@ var/power_multiplier = max(0, (1 + (power_transmission_bonus / (10 - (gas_comp[/datum/gas/bz] * BZ_RADIOACTIVITY_MODIFIER)))) * freonbonus)// RadModBZ(500%) var/pressure_multiplier = max((1 / ((env.return_pressure() ** pressure_bonus_curve_angle) + 1) * pressure_bonus_derived_steepness) + pressure_bonus_derived_constant, 1) var/co2_power_increase = max(gas_comp[/datum/gas/carbon_dioxide] * 2, 1) + hue_angle_shift = clamp(903 * log(10, (power + 8000)) - 3590, -50, 240) + var/zap_color = color_matrix_rotate_hue(hue_angle_shift) supermatter_zap( zapstart = src, range = 3, zap_str = 2.5 * power * power_multiplier * pressure_multiplier * co2_power_increase, zap_flags = ZAP_SUPERMATTER_FLAGS, zap_cutoff = 300, - power_level = power + power_level = power, + color = zap_color, ) last_power_zap = world.time