From 7e67345b481b444bbc977da797dcae26fb9e97f1 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sun, 20 Oct 2024 06:27:38 -0400 Subject: [PATCH] fix poly deleting your entity --- quant.ew/files/system/enemy_sync.lua | 6 ++++-- quant.ew/files/system/local_health/local_health.lua | 11 ++++++----- quant.ew/files/system/player_sync.lua | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/quant.ew/files/system/enemy_sync.lua b/quant.ew/files/system/enemy_sync.lua index 2e6f1cf1..d796e8da 100644 --- a/quant.ew/files/system/enemy_sync.lua +++ b/quant.ew/files/system/enemy_sync.lua @@ -172,14 +172,16 @@ local function get_sync_entities(return_all) local entities2 = {} if return_all then - entities2 = entities + table_extend_filtered(entities2, entities, function(ent) + return not EntityHasTag(ent, "ew_no_enemy_sync") + end) else table_extend_filtered(entities2, entities, function(ent) local x, y = EntityGetTransform(ent) local has_anyone = EntityHasTag(ent, "worm") or EntityGetFirstComponent(ent, "BossHealthBarComponent") ~= nil or #EntityGetInRadiusWithTag(x, y, DISTANCE_LIMIT, "ew_peer") ~= 0 - return has_anyone + return has_anyone and not EntityHasTag(ent, "ew_no_enemy_sync") 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 97390006..d0d897cd 100644 --- a/quant.ew/files/system/local_health/local_health.lua +++ b/quant.ew/files/system/local_health/local_health.lua @@ -145,7 +145,7 @@ local function player_died() -- This may look like a hack, but it allows to use existing poly machinery to change player entity AND to store the original player for later, -- Which is, like, perfect. local ent = LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/local_health/notplayer/poly_effect.xml") - polymorph.switch_entity(ent + 1) + ctx.my_player.entity = ent + 1 GameAddFlagRun("ew_flag_notplayer_active") do_switch_effect(false) EntitySetName(ctx.my_player.entity, ctx.my_id.."?") @@ -154,6 +154,7 @@ local function player_died() EntityAddTag(iron, "kill_on_revive") LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/spectate/no_tinker.xml") set_cosmetics_locally(ctx.my_id) + polymorph.switch_entity(ent + 1) remove_healthbar_locally() for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do @@ -304,8 +305,7 @@ ctx.cap.health = { local item_data = inventory_helper.get_item_data(ctx.my_player) remove_inventory() GameRemoveFlagRun("ew_flag_notplayer_active") - local ent = end_poly_effect(ctx.my_player.entity) - polymorph.switch_entity(ent) + ctx.my_player.entity = end_poly_effect(ctx.my_player.entity) for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do if not EntityHasTag(child, "perk_entity") then local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent") @@ -339,6 +339,7 @@ ctx.cap.health = { end if GameHasFlagRun("ew_kill_player") then GameRemoveFlagRun("ew_kill_player") + polymorph.switch_entity(ctx.my_player.entity) async(function() wait(1) if GameHasFlagRun("ending_game_completed") then @@ -349,10 +350,10 @@ ctx.cap.health = { end) else do_switch_effect(true) + polymorph.switch_entity(ctx.my_player.entity) end else - local ent = end_poly_effect(ctx.my_player.entity) - polymorph.switch_entity(ent) + polymorph.switch_entity(end_poly_effect(ctx.my_player.entity)) async(function() wait(1) player_died() diff --git a/quant.ew/files/system/player_sync.lua b/quant.ew/files/system/player_sync.lua index c987b1c8..252f31bf 100644 --- a/quant.ew/files/system/player_sync.lua +++ b/quant.ew/files/system/player_sync.lua @@ -14,7 +14,7 @@ function rpc.player_update(input_data, pos_data, current_slot, team) end local player_data = player_fns.peer_get_player_data(peer_id) - if team ~= nil and not GameHasFlagRun("ending_game_completed") and not EntityHasTag(player_data.entity, "ew_notplayer") and ctx.proxy_opt.friendly_fire_team ~= nil then + if team ~= nil and not GameHasFlagRun("ending_game_completed") and not EntityHasTag(player_data.entity, "polymorphed") and ctx.proxy_opt.friendly_fire_team ~= nil then local my_team = ctx.proxy_opt.friendly_fire_team - 1 if my_team ~= -1 and team ~= -1 and (team == 0 or my_team == 0 or team ~= my_team) then GenomeSetHerdId(player_data.entity, "player_pvp")