Skip to content

Commit

Permalink
make alpha of player ping non linear, have karl yellow trail copy you…
Browse files Browse the repository at this point in the history
…r player color
  • Loading branch information
bgkillas committed Dec 1, 2024
1 parent 047a459 commit 9901132
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion noita-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions noita-proxy/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
20 changes: 12 additions & 8 deletions quant.ew/files/system/karl/karl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion quant.ew/files/system/player_ping/player_ping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9901132

Please sign in to comment.