From f6411bce2343acb1d09aa3f11c664fd5f7dd9192 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sun, 3 Nov 2024 08:25:48 -0500 Subject: [PATCH] fix potion mimics breaking game if you pick them up, dont allow you to pickup player potion mimics(literally 1984) --- quant.ew/files/system/enemy_sync.lua | 1 - quant.ew/files/system/item_sync.lua | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/quant.ew/files/system/enemy_sync.lua b/quant.ew/files/system/enemy_sync.lua index 0eb1088b..7729a8d6 100644 --- a/quant.ew/files/system/enemy_sync.lua +++ b/quant.ew/files/system/enemy_sync.lua @@ -168,7 +168,6 @@ local function get_sync_entities(return_all) return not EntityHasTag(ent, "ew_no_enemy_sync") and not EntityHasTag(ent, "wand_ghost") end) table_extend(entities, EntityGetWithTag("ew_enemy_sync_extra")) - table_extend(entities, EntityGetWithTag("mimic_potion")) table_extend(entities, EntityGetWithTag("plague_rat")) table_extend(entities, EntityGetWithTag("perk_fungus_tiny")) table_extend(entities, EntityGetWithTag("helpless_animal")) diff --git a/quant.ew/files/system/item_sync.lua b/quant.ew/files/system/item_sync.lua index 7ad80c8b..5037504e 100644 --- a/quant.ew/files/system/item_sync.lua +++ b/quant.ew/files/system/item_sync.lua @@ -252,6 +252,19 @@ local function is_safe_to_remove() return not ctx.is_wand_pickup end +rpc.opts_everywhere() +function rpc.mimic_potion(ent, gid) + ent = ctx.entity_by_remote_id[ent] or ent + if not EntityHasTag(ent, "ew_global_item") then + item_sync.ensure_notify_component(ent) + EntityAddTag(ent, "ew_global_item") + EntityAddComponent2(ent, "VariableStorageComponent", { + _tags = "enabled_in_world,enabled_in_hand,enabled_in_inventory,ew_global_item_id", + value_string = gid, + }) + end +end + function item_sync.on_world_update() -- TODO check that we not removing item we are going to pick now, instead of checking if picker gui is open. if is_safe_to_remove() then @@ -263,6 +276,18 @@ function item_sync.on_world_update() if GameGetFrameNum() % 60 == 31 then send_item_positions() end + if GameGetFrameNum() % 5 == 2 then + for _, ent in ipairs(EntityGetWithTag("mimic_potion")) do + if ctx.is_host then + if not EntityHasTag(ent, "ew_global_item") then + item_sync.make_item_global(ent) + end + end + if EntityHasTag(ent, "polymorphed_player") then + EntityRemoveComponent(ent, EntityGetFirstComponentIncludingDisabled(ent, "ItemComponent")) + end + end + end end function item_sync.on_should_send_updates() @@ -272,7 +297,7 @@ function item_sync.on_should_send_updates() local global_items = EntityGetWithTag("ew_global_item") local item_list = {} for _, item in ipairs(global_items) do - if is_item_on_ground(item) then + if is_item_on_ground(item) and not EntityHasTag(item, "mimic_potion") then local item_data = inventory_helper.serialize_single_item(item) local gid = item_sync.get_global_item_id(item) item_data.gid = gid