make so healing doesn't show as damage on peers side, dont double up player melee damage

This commit is contained in:
bgkillas 2024-10-31 09:03:12 -04:00
parent 8b84a05584
commit f698f1356e
6 changed files with 32 additions and 16 deletions

View file

@ -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;
}
}
}

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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