From 990113284a4b831c3f3015a9de13aac87b47bc3f Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sat, 30 Nov 2024 22:06:33 -0500 Subject: [PATCH] make alpha of player ping non linear, have karl yellow trail copy your player color --- noita-proxy/src/lib.rs | 2 +- noita-proxy/src/net.rs | 6 ++++++ quant.ew/files/system/karl/karl.lua | 20 +++++++++++-------- .../files/system/player_ping/player_ping.lua | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/noita-proxy/src/lib.rs b/noita-proxy/src/lib.rs index 8949e2c6..5427eb23 100644 --- a/noita-proxy/src/lib.rs +++ b/noita-proxy/src/lib.rs @@ -405,7 +405,7 @@ pub struct UXSettings { impl UXSettings { fn ping_lifetime(&self) -> u32 { - self.ping_lifetime.unwrap_or(5) + self.ping_lifetime.unwrap_or(6) } fn ping_scale(&self) -> f32 { self.ping_scale.unwrap_or(0.0) diff --git a/noita-proxy/src/net.rs b/noita-proxy/src/net.rs index 47f45ee8..8d9f5ef8 100644 --- a/noita-proxy/src/net.rs +++ b/noita-proxy/src/net.rs @@ -609,6 +609,12 @@ impl NetManager { rgb[0] as u32 + ((rgb[1] as u32) << 8) + ((rgb[2] as u32) << 16), ); + let rgb = self.init_settings.player_color.player_alt; + state.try_ws_write_option( + "mina_color_alt", + rgb[0] as u32 + ((rgb[1] as u32) << 8) + ((rgb[2] as u32) << 16), + ); + state.try_ws_write_option( "ping_lifetime", self.init_settings.ux_settings.ping_lifetime(), diff --git a/quant.ew/files/system/karl/karl.lua b/quant.ew/files/system/karl/karl.lua index a5054081..d3cc3073 100644 --- a/quant.ew/files/system/karl/karl.lua +++ b/quant.ew/files/system/karl/karl.lua @@ -18,7 +18,7 @@ function rpc.kill_karl() end end -function rpc.send_karl(x, y, vx, vy, t, jet, rgb) +function rpc.send_karl(x, y, vx, vy, t, jet, rgb1, rgb2) local players_karl for _, entity in ipairs(EntityGetWithTag("racing_cart")) do local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl") @@ -41,9 +41,11 @@ function rpc.send_karl(x, y, vx, vy, t, jet, rgb) EntityRemoveComponent(players_karl, com) end end - local particle = EntityGetFirstComponentIncludingDisabled(players_karl, "ParticleEmitterComponent") - local rgbc = rgb + 128 * 2^24 - ComponentSetValue2(particle, "color", rgbc) + local particle = EntityGetComponentIncludingDisabled(players_karl, "ParticleEmitterComponent") + local rgbc = rgb2 + 128 * 2^24 + ComponentSetValue2(particle[1], "color", rgbc) + rgbc = rgb1 + 128 * 2^24 + ComponentSetValue2(particle[2], "color", rgbc) else EntitySetTransform(players_karl, x, y, t) end @@ -77,9 +79,11 @@ function karl.on_world_update() local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl") if com == nil then my_karl = entity - local particle = EntityGetFirstComponentIncludingDisabled(my_karl, "ParticleEmitterComponent") - local rgbc = ctx.proxy_opt.mina_color + 128 * 2^24 - ComponentSetValue2(particle, "color", rgbc) + local particle = EntityGetComponentIncludingDisabled(my_karl, "ParticleEmitterComponent") + local rgbc = ctx.proxy_opt.mina_color_alt + 128 * 2^24 + ComponentSetValue2(particle[1], "color", rgbc) + rgbc = ctx.proxy_opt.mina_color + 128 * 2^24 + ComponentSetValue2(particle[2], "color", rgbc) break end end @@ -89,7 +93,7 @@ function karl.on_world_update() local vel = EntityGetFirstComponentIncludingDisabled(my_karl, "VelocityComponent") local vx, vy = ComponentGetValue2(vel, "mVelocity") local jet = ComponentGetIsEnabled(EntityGetFirstComponentIncludingDisabled(my_karl, "SpriteParticleEmitterComponent")) - rpc.send_karl(x, y, vx, vy, t, jet, ctx.proxy_opt.mina_color) + rpc.send_karl(x, y, vx, vy, t, jet, ctx.proxy_opt.mina_color, ctx.proxy_opt.mina_color_alt) local stopwatch_best = EntityGetClosestWithTag(x, y, "stopwatch_best_lap") local com = EntityGetFirstComponentIncludingDisabled(stopwatch_best, "VariableStorageComponent") diff --git a/quant.ew/files/system/player_ping/player_ping.lua b/quant.ew/files/system/player_ping/player_ping.lua index 4224329d..f24d2104 100644 --- a/quant.ew/files/system/player_ping/player_ping.lua +++ b/quant.ew/files/system/player_ping/player_ping.lua @@ -70,7 +70,7 @@ function module.on_world_update() local pos = pings[i] local frame = pos[3] local peer_id = pos[4] - local alpha = 1 - ((GameGetFrameNum() - frame) / lifetime) + local alpha = math.sqrt(1 - (GameGetFrameNum() - frame) / lifetime) if frame + lifetime < GameGetFrameNum() then table.remove(pings, i) goto continue