From 14e347ed43c8de6de243642592e269db3b8b689b Mon Sep 17 00:00:00 2001 From: bgkillas Date: Tue, 19 Nov 2024 16:08:59 -0500 Subject: [PATCH] fix immortal bug --- quant.ew/files/core/inventory_helper.lua | 5 +++++ quant.ew/files/system/damage/damage.lua | 2 +- quant.ew/files/system/local_health/local_health.lua | 2 +- quant.ew/files/system/polymorph/polymorph.lua | 2 +- quant.ew/files/system/potion_mimic/potion_mimic.lua | 5 +++++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/quant.ew/files/core/inventory_helper.lua b/quant.ew/files/core/inventory_helper.lua index 20c2b691..26df80ce 100644 --- a/quant.ew/files/core/inventory_helper.lua +++ b/quant.ew/files/core/inventory_helper.lua @@ -209,6 +209,11 @@ function inventory_helper.get_item_data(player_data, fresh) local slot_x, slot_y = ComponentGetValue2(item_comp, "inventory_slot") local item_x, item_y = EntityGetTransform(item) + local immortal = EntityGetFirstComponentIncludingDisabled(item, "LuaComponent", "ew_immortal") + if immortal ~= 0 then + EntityRemoveComponent(item, immortal) + end + SetRandomSeed(item + slot_x + item_x, slot_y + item_y) if(entity_is_wand(item))then diff --git a/quant.ew/files/system/damage/damage.lua b/quant.ew/files/system/damage/damage.lua index cbd3c97e..92c7cfe2 100644 --- a/quant.ew/files/system/damage/damage.lua +++ b/quant.ew/files/system/damage/damage.lua @@ -114,7 +114,7 @@ function module.on_client_spawned(peer_id, playerdata) 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"}) + EntityAddComponent2(playerdata.entity, "LuaComponent", {_tags="ew_immortal", script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"}) end end diff --git a/quant.ew/files/system/local_health/local_health.lua b/quant.ew/files/system/local_health/local_health.lua index 06846960..df5573db 100644 --- a/quant.ew/files/system/local_health/local_health.lua +++ b/quant.ew/files/system/local_health/local_health.lua @@ -384,7 +384,7 @@ 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"}) + EntityAddComponent2(playerdata.entity, "LuaComponent", {_tags="ew_immortal", 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"}) end diff --git a/quant.ew/files/system/polymorph/polymorph.lua b/quant.ew/files/system/polymorph/polymorph.lua index 56c4a279..4b8bad0a 100644 --- a/quant.ew/files/system/polymorph/polymorph.lua +++ b/quant.ew/files/system/polymorph/polymorph.lua @@ -161,7 +161,7 @@ local function apply_seri_ent(player_data, seri_ent) EntityAddTag(ent, "ew_no_enemy_sync") EntityAddTag(ent, "ew_client") - EntityAddComponent2(ent, "LuaComponent", {script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"}) + EntityAddComponent2(ent, "LuaComponent", {_tags="ew_immortal", script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"}) -- Remove all poly-like effects to prevent spawn of another player character when it runs out remove_all_effects(ent) diff --git a/quant.ew/files/system/potion_mimic/potion_mimic.lua b/quant.ew/files/system/potion_mimic/potion_mimic.lua index bfb33f3f..988a8ade 100644 --- a/quant.ew/files/system/potion_mimic/potion_mimic.lua +++ b/quant.ew/files/system/potion_mimic/potion_mimic.lua @@ -17,6 +17,11 @@ function rpc.got_thrown(peer_id, vx, vy) local phys_component = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "PhysicsBodyComponent") local px, py, pr, pvx, pvy, pvr = np.PhysBodyGetTransform(phys_component) np.PhysBodySetTransform(phys_component, px, py, pr, pvx + vx, pvy + vy, pvr) + else + local immortal = EntityGetFirstComponentIncludingDisabled(item, "LuaComponent", "ew_immortal") + if immortal == 0 then + EntityAddComponent2(item, "LuaComponent", {_tags="ew_immortal", script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"}) + end end end