mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
use new ephemerial for enemys and players, fix polymorphing enemys looking weird
This commit is contained in:
parent
005c1b29c1
commit
5cc4ff01c5
6 changed files with 37 additions and 37 deletions
|
@ -491,6 +491,9 @@ function player_fns.spawn_player_for(peer_id, x, y, existing_playerdata)
|
||||||
end
|
end
|
||||||
print("Spawning player for "..peer_id)
|
print("Spawning player for "..peer_id)
|
||||||
local new = EntityLoad("mods/quant.ew/files/system/player/tmp/" .. peer_id .. "_base.xml", x, y)
|
local new = EntityLoad("mods/quant.ew/files/system/player/tmp/" .. peer_id .. "_base.xml", x, y)
|
||||||
|
if new ~= nil then
|
||||||
|
ewext.make_ephemerial(new)
|
||||||
|
end
|
||||||
local inv_full = EntityCreateNew("inventory_full")
|
local inv_full = EntityCreateNew("inventory_full")
|
||||||
EntityAddChild(new, inv_full)
|
EntityAddChild(new, inv_full)
|
||||||
LoadGameEffectEntityTo(new, "mods/quant.ew/files/system/spectate/no_tinker.xml")
|
LoadGameEffectEntityTo(new, "mods/quant.ew/files/system/spectate/no_tinker.xml")
|
||||||
|
@ -539,6 +542,9 @@ function player_fns.spawn_player_for(peer_id, x, y, existing_playerdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
function player_fns.replace_player_entity(new_entity, player_data)
|
function player_fns.replace_player_entity(new_entity, player_data)
|
||||||
|
if new_entity ~= nil then
|
||||||
|
ewext.make_ephemerial(new_entity)
|
||||||
|
end
|
||||||
if new_entity ~= nil then
|
if new_entity ~= nil then
|
||||||
local old_entity = player_data.entity
|
local old_entity = player_data.entity
|
||||||
player_data.entity = new_entity
|
player_data.entity = new_entity
|
||||||
|
|
|
@ -183,11 +183,14 @@ end)
|
||||||
|
|
||||||
-- Load an entity that doesn't get saved.
|
-- Load an entity that doesn't get saved.
|
||||||
function util.load_ephemerial(path, x, y)
|
function util.load_ephemerial(path, x, y)
|
||||||
local entity = EntityCreateNew()
|
--local entity = EntityCreateNew()
|
||||||
EntityAddTag(entity, "ew_synced_entity")
|
--EntityAddTag(entity, "ew_synced_entity")
|
||||||
EntitySetTransform(entity, x, y)
|
--EntitySetTransform(entity, x, y)
|
||||||
local ent_2 = EntityLoad(path, x, y)
|
local ent_2 = EntityLoad(path, x, y)
|
||||||
EntityAddChild(entity, ent_2)
|
--EntityAddChild(entity, ent_2)
|
||||||
|
if ent_2 ~= nil then
|
||||||
|
ewext.make_ephemerial(ent_2)
|
||||||
|
end
|
||||||
return ent_2
|
return ent_2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,5 @@ local orig = GetUpdatedEntityID
|
||||||
|
|
||||||
function GetUpdatedEntityID()
|
function GetUpdatedEntityID()
|
||||||
local ent = EntityGetRootEntity(orig())
|
local ent = EntityGetRootEntity(orig())
|
||||||
if EntityHasTag(ent, "ew_synced_entity") then
|
|
||||||
ent = (EntityGetAllChildren(ent) or {0})[1]
|
|
||||||
end
|
|
||||||
return ent
|
return ent
|
||||||
end
|
end
|
|
@ -63,6 +63,8 @@ local PhysDataNoMotion = util.make_type({
|
||||||
u8 = {"r"}
|
u8 = {"r"}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local frame = 0
|
||||||
|
|
||||||
local enemy_sync = {}
|
local enemy_sync = {}
|
||||||
|
|
||||||
local unsynced_enemys = {}
|
local unsynced_enemys = {}
|
||||||
|
@ -96,10 +98,10 @@ np.CrossCallAdd("ew_es_death_notify", function(enemy_id, responsible_id)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function kill(entity)
|
local function kill(entity)
|
||||||
local parent = EntityGetParent(entity)
|
--local parent = EntityGetParent(entity)
|
||||||
if parent ~= nil then
|
--if parent ~= nil then
|
||||||
EntityKill(parent)
|
-- EntityKill(parent)
|
||||||
end
|
--end
|
||||||
EntityKill(entity)
|
EntityKill(entity)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -401,26 +403,15 @@ function enemy_sync.client_cleanup()
|
||||||
local filename = EntityGetFilename(enemy_id)
|
local filename = EntityGetFilename(enemy_id)
|
||||||
print("Despawning persisted "..enemy_id.." "..filename)
|
print("Despawning persisted "..enemy_id.." "..filename)
|
||||||
kill(enemy_id)
|
kill(enemy_id)
|
||||||
else
|
|
||||||
local cull = EntityGetFirstComponentIncludingDisabled(enemy_id, "VariableStorageComponent", "ew_cull")
|
|
||||||
if cull ~= nil and ComponentGetValue2(cull, "value_int") + 120 < GameGetFrameNum() then
|
|
||||||
kill(enemy_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local frame = GameGetFrameNum()
|
|
||||||
for remote_id, enemy_data in pairs(ctx.entity_by_remote_id) do
|
for remote_id, enemy_data in pairs(ctx.entity_by_remote_id) do
|
||||||
if frame - enemy_data.frame > 60*2 then
|
if frame > enemy_data.frame then
|
||||||
--print("Despawning stale "..remote_id.." "..enemy_data.id)
|
--print("Despawning stale "..remote_id.." "..enemy_data.id)
|
||||||
kill(enemy_data.id)
|
kill(enemy_data.id)
|
||||||
ctx.entity_by_remote_id[remote_id] = nil
|
ctx.entity_by_remote_id[remote_id] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _, ent in ipairs(EntityGetWithTag("ew_synced_entity") or {}) do
|
|
||||||
if #(EntityGetAllChildren(ent) or {}) == 0 then
|
|
||||||
EntityKill(ent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function enemy_sync.on_world_update_host()
|
function enemy_sync.on_world_update_host()
|
||||||
|
@ -440,7 +431,7 @@ function enemy_sync.on_world_update_host()
|
||||||
end
|
end
|
||||||
|
|
||||||
function enemy_sync.on_world_update_client()
|
function enemy_sync.on_world_update_client()
|
||||||
if GameGetFrameNum() % 20 == 1 then
|
if GameGetFrameNum() % 10 == 1 then
|
||||||
enemy_sync.client_cleanup()
|
enemy_sync.client_cleanup()
|
||||||
end
|
end
|
||||||
if GameGetFrameNum() % (60*60) == 1 then
|
if GameGetFrameNum() % (60*60) == 1 then
|
||||||
|
@ -527,9 +518,6 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
||||||
EntityRemoveComponent(enemy_id, com)
|
EntityRemoveComponent(enemy_id, com)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not dont_cull then
|
|
||||||
EntityAddComponent2(enemy_id, "VariableStorageComponent", {_tags="ew_cull", value_int = GameGetFrameNum()})
|
|
||||||
end
|
|
||||||
EntityAddComponent2(enemy_id, "LuaComponent", {_tags="ew_immortal", script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"})
|
EntityAddComponent2(enemy_id, "LuaComponent", {_tags="ew_immortal", script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"})
|
||||||
local damage_component = EntityGetFirstComponentIncludingDisabled(enemy_id, "DamageModelComponent")
|
local damage_component = EntityGetFirstComponentIncludingDisabled(enemy_id, "DamageModelComponent")
|
||||||
if damage_component and damage_component ~= 0 then
|
if damage_component and damage_component ~= 0 then
|
||||||
|
@ -570,10 +558,6 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
||||||
enemy_data_new.frame = frame
|
enemy_data_new.frame = frame
|
||||||
local enemy_id = enemy_data_new.id
|
local enemy_id = enemy_data_new.id
|
||||||
|
|
||||||
if not dont_cull then
|
|
||||||
ComponentSetValue2(EntityGetFirstComponentIncludingDisabled(enemy_id, "VariableStorageComponent", "ew_cull"), "value_int", GameGetFrameNum())
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, phys_component in ipairs(EntityGetComponent(enemy_id, "PhysicsBodyComponent") or {}) do
|
for i, phys_component in ipairs(EntityGetComponent(enemy_id, "PhysicsBodyComponent") or {}) do
|
||||||
local phys_info = phys_infos[i]
|
local phys_info = phys_infos[i]
|
||||||
if phys_component ~= nil and phys_component ~= 0 and phys_info ~= nil then
|
if phys_component ~= nil and phys_component ~= 0 and phys_info ~= nil then
|
||||||
|
@ -605,10 +589,6 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
||||||
else
|
else
|
||||||
EntitySetTransform(enemy_id, x, y)
|
EntitySetTransform(enemy_id, x, y)
|
||||||
end
|
end
|
||||||
local root = EntityGetRootEntity(enemy_id)
|
|
||||||
if root ~= nil and EntityHasTag(root, "ew_synced_entity") then
|
|
||||||
EntitySetTransform(root, x, y)
|
|
||||||
end
|
|
||||||
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
||||||
or EntityGetFirstComponentIncludingDisabled(enemy_id, "BossDragonComponent")
|
or EntityGetFirstComponentIncludingDisabled(enemy_id, "BossDragonComponent")
|
||||||
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
|
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
|
||||||
|
@ -768,6 +748,7 @@ function rpc.handle_death_data(death_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
function rpc.handle_enemy_data(enemy_data)
|
function rpc.handle_enemy_data(enemy_data)
|
||||||
|
frame = GameGetFrameNum()
|
||||||
for _, enemy_info_raw in ipairs(enemy_data) do
|
for _, enemy_info_raw in ipairs(enemy_data) do
|
||||||
sync_enemy(enemy_info_raw, false)
|
sync_enemy(enemy_info_raw, false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,9 @@ local function oh_another_world_state(entity)
|
||||||
print("Another world state: "..entity)
|
print("Another world state: "..entity)
|
||||||
GamePrint("Another World State Entity detected")
|
GamePrint("Another World State Entity detected")
|
||||||
GamePrint("Do a 'mods > restart with enabled mods' to avoid a crash")
|
GamePrint("Do a 'mods > restart with enabled mods' to avoid a crash")
|
||||||
ewext.make_ephemerial(entity)
|
if entity ~= nil then
|
||||||
|
ewext.make_ephemerial(entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.on_local_player_spawn()
|
function module.on_local_player_spawn()
|
||||||
|
@ -44,4 +46,4 @@ function module.on_world_update()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return module
|
return module
|
|
@ -12,6 +12,13 @@ local IGNORE_EFFECTS = {
|
||||||
NO_WAND_EDITING = true,
|
NO_WAND_EDITING = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local REMOVE_EFFECTS = {
|
||||||
|
POLYMORPH = true,
|
||||||
|
POLYMORPH_RANDOM = true,
|
||||||
|
POLYMORPH_CESSATION = true,
|
||||||
|
POLYMORPH_UNSTABLE = true,
|
||||||
|
}
|
||||||
|
|
||||||
function effect_sync.get_ent_effects(entity, perks)
|
function effect_sync.get_ent_effects(entity, perks)
|
||||||
local filename = EntityGetFilename(entity)
|
local filename = EntityGetFilename(entity)
|
||||||
local list = {}
|
local list = {}
|
||||||
|
@ -25,6 +32,10 @@ function effect_sync.get_ent_effects(entity, perks)
|
||||||
local name = ComponentGetValue2(com, "effect")
|
local name = ComponentGetValue2(com, "effect")
|
||||||
if not IGNORE_EFFECTS[name] and filename ~= EntityGetFilename(ent) and (not EntityHasTag(ent, "perk_entity") or perks) then
|
if not IGNORE_EFFECTS[name] and filename ~= EntityGetFilename(ent) and (not EntityHasTag(ent, "perk_entity") or perks) then
|
||||||
table.insert(list, ent)
|
table.insert(list, ent)
|
||||||
|
elseif REMOVE_EFFECTS[name]
|
||||||
|
and ctx.my_player.entity ~= entity
|
||||||
|
and (ctx.my_id ~= ctx.host_id or player_fns.get_player_data_by_local_entity_id(entity) ~= nil) then
|
||||||
|
EntityKill(ent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue