From 5c3a2118389f52e532a69b8fa9c5f9a9495da2bf Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sun, 20 Oct 2024 08:12:12 -0400 Subject: [PATCH] color player pings based on mina color, fix friendly fire settings ui showing up when host doesn't have it enabled, send less data from angry ghost memory sync --- noita-proxy/src/lib.rs | 2 +- noita-proxy/src/player_cosmetics.rs | 23 +++++++++++++----- .../angry_ghost_memory/angry_ghost_memory.lua | 4 ++- .../system/local_health/local_health.lua | 2 ++ .../system/player_arrows/player_arrows.lua | 6 +---- quant.ew/files/system/player_ping/arrow.png | Bin 4253 -> 4505 bytes .../files/system/player_ping/player_ping.lua | 9 ++++--- 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/noita-proxy/src/lib.rs b/noita-proxy/src/lib.rs index 0fae1220..a7fad20c 100644 --- a/noita-proxy/src/lib.rs +++ b/noita-proxy/src/lib.rs @@ -1022,7 +1022,7 @@ impl eframe::App for App { ui.checkbox(&mut self.app_saved_state.show_extra_debug_stuff, tr("Show-debug-info")); ui.add_space(15.0); - if self.app_saved_state.game_settings.friendly_fire || netman.friendly_fire.load(Ordering::Relaxed) { + if netman.friendly_fire.load(Ordering::Relaxed) { let last = self.app_saved_state.game_settings.friendly_fire_team; ui.add(Slider::new(&mut self.app_saved_state.game_settings.friendly_fire_team, -1..=16)); if last != self.app_saved_state.game_settings.friendly_fire_team { diff --git a/noita-proxy/src/player_cosmetics.rs b/noita-proxy/src/player_cosmetics.rs index 857650f9..175e467b 100644 --- a/noita-proxy/src/player_cosmetics.rs +++ b/noita-proxy/src/player_cosmetics.rs @@ -17,13 +17,15 @@ pub fn player_path(path: PathBuf) -> PathBuf { path.join("files/system/player/unmodified.png") } -pub fn arrows_path(path: PathBuf, is_host: bool) -> PathBuf { - let p = path.parent().unwrap().join("player_arrows"); - if is_host { +pub fn arrows_path(path: PathBuf, is_host: bool) -> (PathBuf, PathBuf) { + let parent = path.parent().unwrap(); + let p = parent.join("player_arrows"); + let o = parent.join("player_ping"); + (if is_host { p.join("arrow_host.png") } else { p.join("arrow.png") - } + }, o.join("arrow.png")) } pub fn cursor_path(path: PathBuf) -> PathBuf { @@ -251,7 +253,7 @@ pub fn create_player_png( let cosmetics = rgb.cosmetics; let rgb = rgb.colors; let tmp_path = player_path.parent().unwrap(); - let arrows_path = arrows_path(tmp_path.into(), is_host); + let (arrows_path, ping_path) = arrows_path(tmp_path.into(), is_host); let cursor_path = cursor_path(tmp_path.into()); let mut img = image::open(player_path).unwrap().into_rgba8(); replace_color( @@ -267,6 +269,13 @@ pub fn create_player_png( Rgba::from(rgb.player_alt), Rgba::from(rgb.player_arm), ); + let mut img_ping = image::open(ping_path).unwrap().into_rgba8(); + replace_color( + &mut img_ping, + Rgba::from(rgb.player_main), + Rgba::from(rgb.player_alt), + Rgba::from(rgb.player_arm), + ); let mut img_cursor = image::open(cursor_path).unwrap().into_rgba8(); replace_color( &mut img_cursor, @@ -278,6 +287,8 @@ pub fn create_player_png( img.save(path).unwrap(); let path = tmp_path.join(format!("tmp/{}_arrow.png", id)); img_arrow.save(path).unwrap(); + let path = tmp_path.join(format!("tmp/{}_ping.png", id)); + img_ping.save(path).unwrap(); let path = tmp_path.join(format!("tmp/{}_cursor.png", id)); img_cursor.save(path).unwrap(); let img = create_arm(Rgba::from(rgb.player_forearm)); @@ -400,4 +411,4 @@ fn edit_by_replacing( fn rgb_to_hex(rgb: [u8; 4]) -> String { format!("{:02X}{:02X}{:02X}", rgb[0], rgb[1], rgb[2]) -} +} \ No newline at end of file diff --git a/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua b/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua index 82c8a505..bd74919f 100644 --- a/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua +++ b/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua @@ -17,7 +17,9 @@ function ghost.on_world_update() local memory = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "angry_ghost_projectile_memory") table.insert(ghosts_memory, ComponentGetValue2(memory, "value_string")) end - rpc.send_ghost_data(ghosts_memory) + if #ghosts_memory ~= 0 then + rpc.send_ghost_data(ghosts_memory) + end end return ghost \ No newline at end of file diff --git a/quant.ew/files/system/local_health/local_health.lua b/quant.ew/files/system/local_health/local_health.lua index d0d897cd..077e9189 100644 --- a/quant.ew/files/system/local_health/local_health.lua +++ b/quant.ew/files/system/local_health/local_health.lua @@ -173,6 +173,8 @@ local function set_camera_free(enable) if cam ~= nil then ComponentSetValue2(cam, "center_camera_on_this_entity", not enable) ComponentSetValue2(cam, "move_camera_with_aim", not enable) + else + GameSetCameraFree(true) end end diff --git a/quant.ew/files/system/player_arrows/player_arrows.lua b/quant.ew/files/system/player_arrows/player_arrows.lua index ebd549ec..dcec12d9 100644 --- a/quant.ew/files/system/player_arrows/player_arrows.lua +++ b/quant.ew/files/system/player_arrows/player_arrows.lua @@ -23,10 +23,6 @@ local function world2gui( x, y ) return x, y, vres_scaling_factor end -local function is_suitable_target(entity) - return EntityGetIsAlive(entity) and not EntityHasTag(entity,"ew_notplayer") -end - function module.on_world_update() if EntityHasTag(ctx.my_player.entity, "polymorphed") and not EntityHasTag(ctx.my_player.entity, "ew_notplayer") then return @@ -129,7 +125,7 @@ function module.on_world_update() img_path = "mods/quant.ew/files/system/player/tmp/" .. player_data.peer_id .. "_arrow.png" end end - local scale = math.max(1 / 6, 0.7 - math.atan((math.sqrt(dist_sq) - tch) / 1280) / math.pi) + local scale = math.max(1 / 6, 0.75 - math.atan((math.sqrt(dist_sq) - tch) / 1280) / math.pi) GuiImage(gui, gui_id, x, y, img_path, 1, scale, 0, math.atan2(player_dir_y, player_dir_x) + math.pi/2) gui_id = gui_id + 1 end diff --git a/quant.ew/files/system/player_ping/arrow.png b/quant.ew/files/system/player_ping/arrow.png index e09c2efa8cf24a5ec4d78ed9d782ae7bfcc620a0..7c2a00af6a8404d5e6cfc664f7b59b91dd9af2f4 100644 GIT binary patch delta 639 zcmbQMI8%AT4OK$}D$-FCZ_RAEfQ_sSdUeG=yAjoL2 z%3!sb`f1G{ee0`PepHD+j{NuhpUmH=dr1xsN`0GWWeVpDoX@#sdhYiTC2dWqkCq=> zJjGS&p6q({QTq9!(@f_@&iYi%i%^-?6}zU)P3TAs#W&= z$@>i^nTOR++v!)#;;ECwX{54Z#o`{WoFf^g9vdet``glAf8*=vCqXAe*_4knt-7#q zN8JbeA9vS=&Y1OOk`m{F??(&mjx}7+yO3pZ?)%2aTl^Xx7#F0L{JE-T@Y}O$@nYBh zhQ{0nk9I9yS$*IspTU=qV4tH?n@n1r7%S`-=bvJ1-tJIw_O;g9z5SQj6`W(2<~1}s zC+zXK`P%ONyVvjD-Zy^xua3druV}^x*6*Copv}DH|FYB^wzS8S5IGm>B7r zq*++%CZ(At>sq85nwy&$nkO2kO}1rS!E0$^WNKz^ZUBU4W|Kd$=JJ6fEd&;6lXKY= z(1bS6W)ozbe3C6j*~G}iB+=5+P}d~I6ljT&se!JAQJS%CqH$tsqM2E8l6lf(4|Wfr zeqAF2xRIOZvFCBHR317vZL)xXAupE*52N7Coy;GB=^dj delta 555 zcmbQKJXdkT4OIgRD?>{K5NU2@WX8bAz_@@JNHTyikYXqa$qbwLS5fw;l4xt0K;emi zxo;LJ^=;*HT_KRw8Yb(b_qR!ncd|93ZoSdjSDp;B@@CHr2|DvM{OG>$76C^I=Z=$S zjGn1z^4|Yg+RqUG{*le;|99pmJLpF6aC98uOq*f$k?rG|Ww{0S)cZDVS|c=H*ndWe z<0JQV+H(5~^>*rfIJ08r*)ziKokxSjwPVkmTIOcsD-&!w_fzYf<66&k&qZxLckBBT zeID^I^;1*VU6yg>>W*k)5#)NcVgZ+QVN_|5PD+OT%g6GCe}#666ono*v9UqQNug-kC*Gqfui2i)z4*}Q$iB}Jek?L diff --git a/quant.ew/files/system/player_ping/player_ping.lua b/quant.ew/files/system/player_ping/player_ping.lua index 4e856a5d..642e5d83 100644 --- a/quant.ew/files/system/player_ping/player_ping.lua +++ b/quant.ew/files/system/player_ping/player_ping.lua @@ -68,6 +68,7 @@ function module.on_world_update() while i <= #pings do local pos = pings[i] local frame = pos[3] + local peer_id = pos[4] if frame + 300 < GameGetFrameNum() then table.remove(pings, i) goto continue @@ -106,14 +107,14 @@ function module.on_world_update() outside = true end - local img_path = "mods/quant.ew/files/system/player_ping/arrow.png" + local img_path = "mods/quant.ew/files/system/player/tmp/".. peer_id .."_ping.png" if outside then - local scale = math.max(1 / 6, 0.7 - math.atan((math.sqrt(dist_sq) - tch) / 1280) / math.pi) + local scale = math.max(1 / 6, 0.75 - math.atan((math.sqrt(dist_sq) - tch) / 1280) / math.pi) local x, y = world2gui(ccx+player_dir_x, ccy+player_dir_y) GuiImage(gui, gui_id, x, y, img_path, 1, scale, 0, math.atan2(player_dir_y, player_dir_x) + math.pi/2) else local x, y = world2gui(pos[1], pos[2]) - GuiImage(gui, gui_id, x, y, img_path, 1, 0.7, 0, math.pi) + GuiImage(gui, gui_id, x, y, img_path, 1, 0.75, 0, math.pi) end gui_id = gui_id + 1 i = i + 1 @@ -123,7 +124,7 @@ function module.on_world_update() rpc.opts_everywhere() function rpc.send_ping(x, y) - table.insert(pings, {x, y, GameGetFrameNum()}) + table.insert(pings, {x, y, GameGetFrameNum(), ctx.rpc_peer_id}) end return module \ No newline at end of file