From 699788c035dc668566ee1a9d43d3fe6751e12e4d Mon Sep 17 00:00:00 2001 From: BiancaWilkson <42818125+BiancaWilkson@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:41:17 -0500 Subject: [PATCH] [PTBF] Wavy Vision (#27674) * Initial commit * Finished it up * adds a define for clarity * actually adds it to hallucinating --------- Signed-off-by: Luc <89928798+lewcc@users.noreply.github.com> Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com> --- .../effects/waves_hallucination.dm | 58 +++++++++++++++++++ code/modules/hallucinations/hallucinations.dm | 3 +- paradise.dme | 1 + 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 code/modules/hallucinations/effects/waves_hallucination.dm diff --git a/code/modules/hallucinations/effects/waves_hallucination.dm b/code/modules/hallucinations/effects/waves_hallucination.dm new file mode 100644 index 00000000000..478f107eaf6 --- /dev/null +++ b/code/modules/hallucinations/effects/waves_hallucination.dm @@ -0,0 +1,58 @@ +/** + * Hallucination - Waves + * + * Makes the owner's screen all funky and wavy. +*/ +#define WAVES_HALLUCINATION_FILTER "ripple_hallucination" +#define WAVE_VERTICAL 0 + +/obj/effect/hallucination/no_delete/waves + +/datum/hallucination_manager/waves + initial_hallucination = /obj/effect/hallucination/no_delete/waves + trigger_time = 20 SECONDS + /// How many wave filters the hallucination spawns. + var/amount_spawned + // Maximum distortion size in pixels + var/size + /// Phase of wave, in periods + var/phase_offset + /// How many pixels each wave will be off in the y direction + var/x_offset + /// How many pixels each wave will be off in the y direction + var/y_offset + /// If the filter will be sideways or vertical + var/orientation + var/atom/movable/plane_master_controller/game_plane_master_controller + +/datum/hallucination_manager/waves/spawn_hallucination() + game_plane_master_controller = owner.hud_used?.plane_master_controllers[PLANE_MASTERS_GAME] + if(!game_plane_master_controller) + log_debug("No plane master controller found for [owner], ending hallucination.") + return + hallucination_list |= initial_hallucination + trigger_timer = addtimer(CALLBACK(src, PROC_REF(on_trigger)), trigger_time, TIMER_DELETE_ME) // Put the timer first so in case something goes wrong the filters still get deleted + on_spawn() + +/datum/hallucination_manager/waves/on_spawn() + amount_spawned = roll("4d3-3") // Results in a normal distribution from 1-9. 5 is the most likely result at ~23% + for(var/i in 1 to amount_spawned) + randomize_pulse() + game_plane_master_controller.add_filter(WAVES_HALLUCINATION_FILTER, 1, wave_filter(x_offset, y_offset, size, phase_offset, orientation)) + game_plane_master_controller.transition_filter(WAVES_HALLUCINATION_FILTER, 20 SECONDS, list("x" = x_offset + 15, "y" = y_offset - 15, "offset" = phase_offset + 1), BOUNCE_EASING|EASE_IN|EASE_OUT) + +/datum/hallucination_manager/waves/proc/randomize_pulse() + size = rand() * 2.5 + 0.5 //between .05 and 3 pixels + phase_offset = rand() + var/x_sign = pick(-1, 1) + var/y_sign = pick(-1, 1) + orientation = pick(WAVE_SIDEWAYS, WAVE_VERTICAL) + x_offset = roll(5) * x_sign + y_offset = roll(5) * y_sign + +/datum/hallucination_manager/waves/on_trigger() + game_plane_master_controller.remove_filter(WAVES_HALLUCINATION_FILTER) + qdel(src) + +#undef WAVES_HALLUCINATION_FILTER +#undef WAVE_VERTICAL diff --git a/code/modules/hallucinations/hallucinations.dm b/code/modules/hallucinations/hallucinations.dm index bd9f5a9dc62..5bb4e8a5f0a 100644 --- a/code/modules/hallucinations/hallucinations.dm +++ b/code/modules/hallucinations/hallucinations.dm @@ -32,8 +32,9 @@ GLOBAL_LIST_INIT(hallucinations, list( /obj/effect/hallucination/fake_grenade/spawner = 10, /obj/effect/hallucination/terror_infestation = 10, /obj/effect/hallucination/loose_energy_ball = 10, + /datum/hallucination_manager/xeno_pounce = 10, + /datum/hallucination_manager/waves = 2, /obj/effect/hallucination/blob = 10, - /datum/hallucination_manager/xeno_pounce = 10 ) )) diff --git a/paradise.dme b/paradise.dme index 85eadb7a7e3..18d4c596688 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1998,6 +1998,7 @@ #include "code\modules\hallucinations\effects\major.dm" #include "code\modules\hallucinations\effects\minor.dm" #include "code\modules\hallucinations\effects\moderate.dm" +#include "code\modules\hallucinations\effects\waves_hallucination.dm" #include "code\modules\hallucinations\effects\xeno_pounce.dm" #include "code\modules\holiday\christmas.dm" #include "code\modules\holiday\holiday.dm"