mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
disable the lua components that where meant to be disabled
This commit is contained in:
parent
0cb69e9091
commit
d49fca4cba
5 changed files with 42 additions and 61 deletions
|
@ -13,7 +13,7 @@ use noita_api::raw::game_get_frame_num;
|
|||
use noita_api::serialize::serialize_entity;
|
||||
use noita_api::{
|
||||
DamageModelComponent, EntityID, ItemCostComponent, LuaComponent, PositionSeedComponent,
|
||||
ProjectileComponent, VariableStorageComponent, VelocityComponent,
|
||||
ProjectileComponent, VariableStorageComponent, VelocityComponent, game_print,
|
||||
};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use shared::des::DesToProxy::UpdatePositions;
|
||||
|
|
|
@ -1505,7 +1505,6 @@ impl RemoteDiffModel {
|
|||
)
|
||||
})?;
|
||||
}
|
||||
entity.set_components_with_tag_enabled("ew_enable_on_pickup".into(), true)?;
|
||||
return Ok(Some(*lid));
|
||||
}
|
||||
for (name, s, i, f, b) in &entity_info.synced_var {
|
||||
|
@ -2079,20 +2078,18 @@ pub fn init_remote_entity(
|
|||
}
|
||||
|
||||
for lua in entity.iter_all_components_of_type_including_disabled::<LuaComponent>(None)? {
|
||||
if !drops_gold
|
||||
&& lua.script_death().ok() == Some("data/scripts/items/drop_money.lua".into())
|
||||
{
|
||||
entity.remove_component(*lua)?;
|
||||
} else if [
|
||||
"data/scripts/animals/leader_damage.lua",
|
||||
"data/scripts/animals/giantshooter_death.lua",
|
||||
"data/scripts/animals/blob_damage.lua",
|
||||
"data/scripts/items/die_roll.lua",
|
||||
"data/scripts/animals/iceskull_damage.lua",
|
||||
"data/scripts/buildings/lukki_eggs.lua",
|
||||
"data/scripts/props/physics_vase_damage.lua",
|
||||
]
|
||||
.contains(&&*lua.script_damage_received()?)
|
||||
if (!drops_gold
|
||||
&& lua.script_death().ok() == Some("data/scripts/items/drop_money.lua".into()))
|
||||
|| [
|
||||
"data/scripts/animals/leader_damage.lua",
|
||||
"data/scripts/animals/giantshooter_death.lua",
|
||||
"data/scripts/animals/blob_damage.lua",
|
||||
"data/scripts/items/die_roll.lua",
|
||||
"data/scripts/animals/iceskull_damage.lua",
|
||||
"data/scripts/buildings/lukki_eggs.lua",
|
||||
"data/scripts/props/physics_vase_damage.lua",
|
||||
]
|
||||
.contains(&&*lua.script_damage_received()?)
|
||||
|| [
|
||||
"data/scripts/buildings/firebugnest.lua",
|
||||
"data/scripts/buildings/flynest.lua",
|
||||
|
@ -2109,12 +2106,7 @@ pub fn init_remote_entity(
|
|||
"data/scripts/props/suspended_container_physics_objects.lua",
|
||||
]
|
||||
.contains(&&*lua.script_source_file()?)
|
||||
|| ["data/scripts/items/die_roll.lua"].contains(&&*lua.script_enabled_changed()?)
|
||||
|| [
|
||||
"data/scripts/items/die_roll.lua",
|
||||
"data/scripts/buildings/statue_hand_modified.lua",
|
||||
]
|
||||
.contains(&&*lua.script_kick()?)
|
||||
|| ["data/scripts/buildings/statue_hand_modified.lua"].contains(&&*lua.script_kick()?)
|
||||
|| [
|
||||
"data/scripts/items/utility_box.lua",
|
||||
"data/scripts/items/chest_random.lua",
|
||||
|
@ -2127,10 +2119,8 @@ pub fn init_remote_entity(
|
|||
.contains(&&*lua.script_physics_body_modified()?)
|
||||
|| ["data/scripts/animals/failed_alchemist_b_death.lua"]
|
||||
.contains(&&*lua.script_death()?)
|
||||
|| ["data/scripts/items/broken_wand_throw.lua"].contains(&&*lua.script_throw_item()?)
|
||||
{
|
||||
entity.set_component_enabled(*lua, false)?;
|
||||
lua.add_tag("ew_enable_on_pickup")?;
|
||||
entity.remove_component(*lua)?;
|
||||
}
|
||||
}
|
||||
let immortal = entity.add_component::<LuaComponent>()?;
|
||||
|
|
|
@ -76,7 +76,7 @@ function inventory_helper.serialize_single_item(item)
|
|||
return item_data
|
||||
end
|
||||
|
||||
function inventory_helper.deserialize_single_item(item_data)
|
||||
function inventory_helper.deserialize_single_item(item_data, local_ent)
|
||||
local x, y = item_data[2], item_data[3]
|
||||
local item = util.deserialize_entity(item_data[1], x, y)
|
||||
local ability = EntityGetFirstComponentIncludingDisabled(item, "AbilityComponent")
|
||||
|
@ -85,40 +85,13 @@ function inventory_helper.deserialize_single_item(item_data)
|
|||
ComponentSetValue2(ability, "mCastDelayStartFrame", 0)
|
||||
ComponentSetValue2(ability, "mReloadNextFrameUsable", 0)
|
||||
end
|
||||
|
||||
if item_data.shop_info ~= nil then
|
||||
local item_cost_component = util.get_or_create_component(item, "ItemCostComponent")
|
||||
ComponentAddTag(item_cost_component, "enabled_in_world")
|
||||
ComponentAddTag(item_cost_component, "shop_cost")
|
||||
ComponentSetValue2(item_cost_component, "cost", item_data.shop_info[1])
|
||||
if item_data.gid == nil then
|
||||
ComponentSetValue2(item_cost_component, "stealable", false)
|
||||
print("ERROR: why is " .. tostring(item) .. " gid nil")
|
||||
elseif string.sub(item_data.gid, 1, 16) ~= ctx.my_id then
|
||||
ComponentSetValue2(item_cost_component, "stealable", false)
|
||||
else
|
||||
local mx, my = GameGetCameraPos()
|
||||
if math.abs(mx - x) > 1024 or math.abs(my - y) > 1024 then
|
||||
if ComponentGetValue2(item_cost_component, "stealable") then
|
||||
EntityAddComponent2(item, "VariableStorageComponent", { _tags = "ew_try_stealable" })
|
||||
ComponentSetValue2(item_cost_component, "stealable", false)
|
||||
else
|
||||
EntityAddComponent2(eid, "VariableStorageComponent", { _tags = "ew_try_float" })
|
||||
end
|
||||
local vel = EntityGetFirstComponentIncludingDisabled(item, "VelocityComponent")
|
||||
ComponentSetValue2(vel, "gravity_y", 0)
|
||||
if not local_ent then
|
||||
for _, v in ipairs(EntityGetComponentIncludingDisabled(item, "VariableStorageComponent") or {}) do
|
||||
if ComponentGetValue2(v, "name") == "ew_gid_lid" then
|
||||
ComponentSetValue2(v, "value_bool", false)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
util.ensure_component_present(item, "SpriteComponent", "shop_cost", {
|
||||
image_file = "data/fonts/font_pixel_white.xml",
|
||||
is_text_sprite = true,
|
||||
offset_x = 7,
|
||||
offset_y = 25,
|
||||
alpha = 1,
|
||||
z_index = -1,
|
||||
update_transform_rotation = false,
|
||||
}, "shop_cost,enabled_in_world")
|
||||
end
|
||||
|
||||
return item
|
||||
|
@ -274,13 +247,13 @@ local function get_item(itemInfo, inv, player, local_ent)
|
|||
end
|
||||
end
|
||||
elseif itemInfo.is_wand then
|
||||
item = inventory_helper.deserialize_single_item(itemInfo.data)
|
||||
item = inventory_helper.deserialize_single_item(itemInfo.data, local_ent)
|
||||
remove_non_send(item)
|
||||
item = EZWand(item)
|
||||
elseif itemInfo.peer_id ~= nil then
|
||||
item = ctx.players[itemInfo.peer_id].entity
|
||||
else
|
||||
item = inventory_helper.deserialize_single_item(itemInfo.data)
|
||||
item = inventory_helper.deserialize_single_item(itemInfo.data, local_ent)
|
||||
remove_non_send(item)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
local mod = {}
|
||||
function mod.do_i_own(ent)
|
||||
if ent == nil or not EntityGetIsAlive(ent) then
|
||||
return false
|
||||
end
|
||||
local gid
|
||||
for _, v in ipairs(EntityGetComponent(ent, "VariableStorageComponent") or {}) do
|
||||
for _, v in ipairs(EntityGetComponentIncludingDisabled(ent, "VariableStorageComponent") or {}) do
|
||||
if ComponentGetValue2(v, "name") == "ew_gid_lid" then
|
||||
gid = v
|
||||
break
|
||||
|
|
|
@ -25,4 +25,19 @@ util.prepend(
|
|||
s
|
||||
)
|
||||
util.prepend("data/scripts/items/die_status.lua", "SetRandomSeed( GameGetFrameNum(), pos_x + pos_y + entity_id )", s)
|
||||
|
||||
s = "GetUpdatedEntityID()\n"
|
||||
.. 'local util = dofile_once("mods/quant.ew/files/resource/util_min.lua")\n'
|
||||
.. "if not util.do_i_own(entity_id) then\n"
|
||||
.. "return\n"
|
||||
.. "end"
|
||||
local lst = {
|
||||
"data/scripts/items/broken_wand_spells.lua",
|
||||
"data/scripts/items/die_roll.lua",
|
||||
"data/scripts/buildings/sun/spot_2.lua",
|
||||
"data/scripts/items/broken_wand_throw.lua",
|
||||
}
|
||||
for _, f in ipairs(lst) do
|
||||
util.prepend(f, "GetUpdatedEntityID()", s)
|
||||
end
|
||||
return {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue