diff --git a/noita-proxy/src/lib.rs b/noita-proxy/src/lib.rs index ce0e116c..9cbd1a6f 100644 --- a/noita-proxy/src/lib.rs +++ b/noita-proxy/src/lib.rs @@ -822,8 +822,10 @@ impl App { ); }); if ui.button(tr("Reset-colors-to-default")).clicked() { - self.appearance.player_color = PlayerColor::default(); - self.appearance.hue = 0.0 + let old = self.appearance.clone(); + self.appearance = Default::default(); + self.appearance.cosmetics = old.cosmetics; + self.appearance.player_picker = old.player_picker; } } } diff --git a/noita-proxy/src/player_cosmetics.rs b/noita-proxy/src/player_cosmetics.rs index 2ad1463b..07250bfd 100644 --- a/noita-proxy/src/player_cosmetics.rs +++ b/noita-proxy/src/player_cosmetics.rs @@ -119,7 +119,13 @@ pub fn add_cosmetics( } } -fn rgb_to_oklch(color: &mut [f64; 4]) { +pub fn get_lch(color: [f64; 4]) -> (f64, f64, f64) { + let c = (color[1].powi(2) + color[2].powi(2)).sqrt(); + let h = color[2].atan2(color[1]); + (color[0], c, h) +} + +pub fn rgb_to_oklch(color: &mut [f64; 4]) { let mut l = 0.4122214708 * color[0] + 0.5363325363 * color[1] + 0.0514459929 * color[2]; let mut m = 0.2119034982 * color[0] + 0.6806995451 * color[1] + 0.1073969566 * color[2]; let mut s = 0.0883024619 * color[0] + 0.2817188376 * color[1] + 0.6299787005 * color[2]; @@ -150,8 +156,7 @@ fn oklch_to_rgb(color: &mut [f64; 4]) { fn shift_hue_by(color: &mut [f64; 4], diff: f64) { let tau = std::f64::consts::TAU; let diff = tau * diff / 360.0; - let c = (color[1].powi(2) + color[2].powi(2)).sqrt(); - let hue = color[2].atan2(color[1]); + let (_, c, hue) = get_lch(*color); let mut new_hue = (hue + diff) % tau; if new_hue.is_sign_negative() { new_hue += tau; diff --git a/quant.ew/files/resource/cbs/immortal.lua b/quant.ew/files/resource/cbs/immortal.lua index de3652d0..d453f72f 100644 --- a/quant.ew/files/resource/cbs/immortal.lua +++ b/quant.ew/files/resource/cbs/immortal.lua @@ -1,7 +1,17 @@ function damage_about_to_be_received( damage, x, y, entity_thats_responsible, critical_hit_chance ) - if entity_thats_responsible ~= GameGetWorldStateEntity() then - return 2^-128, 0 - end + local dtypes = GetDamageDetails().damage_types + if GameHasFlagRun("ew_flag_this_is_host") and dtypes == 1 + and entity_thats_responsible ~= GameGetWorldStateEntity() then + return damage, 0 + end - return damage, 0 + if entity_thats_responsible ~= GameGetWorldStateEntity() then + return 2^-128, 0 + end + + if damage < 0 then + return -2^-128, 0 + end + + return damage, 0 end \ No newline at end of file diff --git a/quant.ew/files/system/damage/cbs/send_damage_to_client.lua b/quant.ew/files/system/damage/cbs/send_damage_to_client.lua index 6133c9e8..21e9f475 100644 --- a/quant.ew/files/system/damage/cbs/send_damage_to_client.lua +++ b/quant.ew/files/system/damage/cbs/send_damage_to_client.lua @@ -1,8 +1,10 @@ function damage_received(damage, message, entity_thats_responsible, is_fatal, projectile_thats_responsible) - if entity_thats_responsible == GameGetWorldStateEntity() then + if entity_thats_responsible == GameGetWorldStateEntity() + or (projectile_thats_responsible ~= nil and projectile_thats_responsible ~= 0) + or EntityHasTag(entity_thats_responsible, "ew_peer") then return end - + -- Change our health back local entity_id = GetUpdatedEntityID(); @@ -12,4 +14,4 @@ function damage_received(damage, message, entity_thats_responsible, is_fatal, pr -- Damage the client CrossCall("ew_ds_client_damaged", EntityGetName(entity_id), damage, message) end -end +end \ 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 ca9e7c92..a081fcee 100644 --- a/quant.ew/files/system/local_health/local_health.lua +++ b/quant.ew/files/system/local_health/local_health.lua @@ -263,10 +263,9 @@ end function module.on_client_spawned(peer_id, playerdata) playerdata.status = { is_alive = true } + EntityAddComponent2(playerdata.entity, "LuaComponent", {script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"}) if ctx.is_host then EntityAddComponent2(playerdata.entity, "LuaComponent", {script_damage_received = "mods/quant.ew/files/system/damage/cbs/send_damage_to_client.lua"}) - else - EntityAddComponent2(playerdata.entity, "LuaComponent", {script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"}) end local damage_model = EntityGetFirstComponentIncludingDisabled(playerdata.entity, "DamageModelComponent") ComponentSetValue2(damage_model, "wait_for_kill_flag_on_death", true) diff --git a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua index a608afa4..a1acd3ed 100644 --- a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua +++ b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua @@ -786,8 +786,6 @@ local function choose_movement() end end local pdx, pdy = closest[2], closest[3] - GamePrint(pdx) - GamePrint(pdy) if math.abs(pdy) < 60 and math.abs(pdx) < 55 then if pdx < 0 then state.control_d = true