make potion mimic logic more general to any polied item player, dont let polied players have nametags ever

This commit is contained in:
bgkillas 2024-11-17 17:59:49 -05:00
parent c833c1a1cb
commit eb897d3816
3 changed files with 14 additions and 11 deletions

View file

@ -73,7 +73,9 @@ function nickname.calculate_textwidth(text, font)
end
function nickname.add_label(player_entity, text, font_filename, scale, alpha)
if not EntityGetIsAlive(player_entity) or EntityHasTag(player_entity, "polymorphed_cessation") then
if not EntityGetIsAlive(player_entity)
or EntityHasTag(player_entity, "polymorphed_cessation")
or EntityHasTag(player_entity, "polymorphed_player") then
return
end
local prev_nickname = EntityGetFirstComponentIncludingDisabled(player_entity, "SpriteComponent", "ew_nickname")

View file

@ -89,7 +89,7 @@ end
function module.on_world_update_post()
local ent = np.GetPlayerEntity()
if ent ~= nil and ent ~= ctx.my_player.entity then
if EntityHasTag(ent, "mimic_potion") then
if EntityGetFirstComponentIncludingDisabled(ent, "ItemComponent") ~= nil then
local effect
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do
local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
@ -108,9 +108,12 @@ function module.on_world_update_post()
ComponentSetValue2(effect, "frames", 1200)
end
end
if EntityHasTag(ent, "mimic_potion") then
local item = EntityGetFirstComponentIncludingDisabled(ent, "ItemComponent")
ComponentRemoveTag(item, "enabled_if_charmed")
EntitySetComponentIsEnabled(ent, item, true)
end
EntityAddComponent2(ent, "LuaComponent", {
script_item_picked_up = "mods/quant.ew/files/system/potion_mimic/pickup.lua",

View file

@ -2,11 +2,9 @@ local rpc = net.new_rpc_namespace()
local potion = {}
function potion.enable_in_world(item)
for _, com in ipairs(EntityGetAllComponents(item) or {}) do
EntitySetComponentIsEnabled(item, com, true)
end
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "SpriteComponent", "enabled_in_hand"), false)
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "ItemChestComponent"), false)
EntitySetComponentsWithTagEnabled(item, "enabled_in_hand", false)
EntitySetComponentsWithTagEnabled(item, "enabled_in_inventory", false)
EntitySetComponentsWithTagEnabled(item, "enabled_in_world", true)
if EntityGetParent(item) ~= 0 then
EntityRemoveFromParent(item)
end
@ -57,7 +55,7 @@ function rpc.ensure_held(peer_id)
end
function potion.on_world_update()
if EntityHasTag(ctx.my_player.entity, "mimic_potion") then
if EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "ItemComponent") ~= nil then
local effect
for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do
local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")