mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
make potion mimic logic more general to any polied item player, dont let polied players have nametags ever
This commit is contained in:
parent
c833c1a1cb
commit
eb897d3816
3 changed files with 14 additions and 11 deletions
|
@ -73,7 +73,9 @@ function nickname.calculate_textwidth(text, font)
|
||||||
end
|
end
|
||||||
|
|
||||||
function nickname.add_label(player_entity, text, font_filename, scale, alpha)
|
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
|
return
|
||||||
end
|
end
|
||||||
local prev_nickname = EntityGetFirstComponentIncludingDisabled(player_entity, "SpriteComponent", "ew_nickname")
|
local prev_nickname = EntityGetFirstComponentIncludingDisabled(player_entity, "SpriteComponent", "ew_nickname")
|
||||||
|
|
|
@ -89,7 +89,7 @@ end
|
||||||
function module.on_world_update_post()
|
function module.on_world_update_post()
|
||||||
local ent = np.GetPlayerEntity()
|
local ent = np.GetPlayerEntity()
|
||||||
if ent ~= nil and ent ~= ctx.my_player.entity then
|
if ent ~= nil and ent ~= ctx.my_player.entity then
|
||||||
if EntityHasTag(ent, "mimic_potion") then
|
if EntityGetFirstComponentIncludingDisabled(ent, "ItemComponent") ~= nil then
|
||||||
local effect
|
local effect
|
||||||
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do
|
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do
|
||||||
local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
|
local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
|
||||||
|
@ -108,9 +108,12 @@ function module.on_world_update_post()
|
||||||
ComponentSetValue2(effect, "frames", 1200)
|
ComponentSetValue2(effect, "frames", 1200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local item = EntityGetFirstComponentIncludingDisabled(ent, "ItemComponent")
|
|
||||||
ComponentRemoveTag(item, "enabled_if_charmed")
|
if EntityHasTag(ent, "mimic_potion") then
|
||||||
EntitySetComponentIsEnabled(ent, item, true)
|
local item = EntityGetFirstComponentIncludingDisabled(ent, "ItemComponent")
|
||||||
|
ComponentRemoveTag(item, "enabled_if_charmed")
|
||||||
|
EntitySetComponentIsEnabled(ent, item, true)
|
||||||
|
end
|
||||||
|
|
||||||
EntityAddComponent2(ent, "LuaComponent", {
|
EntityAddComponent2(ent, "LuaComponent", {
|
||||||
script_item_picked_up = "mods/quant.ew/files/system/potion_mimic/pickup.lua",
|
script_item_picked_up = "mods/quant.ew/files/system/potion_mimic/pickup.lua",
|
||||||
|
|
|
@ -2,11 +2,9 @@ local rpc = net.new_rpc_namespace()
|
||||||
local potion = {}
|
local potion = {}
|
||||||
|
|
||||||
function potion.enable_in_world(item)
|
function potion.enable_in_world(item)
|
||||||
for _, com in ipairs(EntityGetAllComponents(item) or {}) do
|
EntitySetComponentsWithTagEnabled(item, "enabled_in_hand", false)
|
||||||
EntitySetComponentIsEnabled(item, com, true)
|
EntitySetComponentsWithTagEnabled(item, "enabled_in_inventory", false)
|
||||||
end
|
EntitySetComponentsWithTagEnabled(item, "enabled_in_world", true)
|
||||||
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "SpriteComponent", "enabled_in_hand"), false)
|
|
||||||
EntitySetComponentIsEnabled(item, EntityGetFirstComponentIncludingDisabled(item, "ItemChestComponent"), false)
|
|
||||||
if EntityGetParent(item) ~= 0 then
|
if EntityGetParent(item) ~= 0 then
|
||||||
EntityRemoveFromParent(item)
|
EntityRemoveFromParent(item)
|
||||||
end
|
end
|
||||||
|
@ -57,7 +55,7 @@ function rpc.ensure_held(peer_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function potion.on_world_update()
|
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
|
local effect
|
||||||
for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do
|
for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do
|
||||||
local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
|
local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue