mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
sync worms a bit more(pls help quant why no worky)
This commit is contained in:
parent
ae3520f3c4
commit
3ea359f89c
2 changed files with 26 additions and 1 deletions
|
@ -21,8 +21,9 @@ local EnemyDataNoMotion = util.make_type({
|
||||||
})
|
})
|
||||||
|
|
||||||
local EnemyDataWorm = util.make_type({
|
local EnemyDataWorm = util.make_type({
|
||||||
u32 = {"enemy_id"},
|
u32 = {"enemy_id", "target"},
|
||||||
f32 = {"x", "y", "vx", "vy", "tx", "ty"},
|
f32 = {"x", "y", "vx", "vy", "tx", "ty"},
|
||||||
|
string = {"peer_id"}
|
||||||
})
|
})
|
||||||
|
|
||||||
local EnemyDataKolmi = util.make_type({
|
local EnemyDataKolmi = util.make_type({
|
||||||
|
@ -285,6 +286,13 @@ function enemy_sync.host_upload_entities()
|
||||||
}
|
}
|
||||||
elseif worm ~= nil then
|
elseif worm ~= nil then
|
||||||
local tx, ty = ComponentGetValue2(worm, "mRandomTarget")
|
local tx, ty = ComponentGetValue2(worm, "mRandomTarget")
|
||||||
|
local target = ComponentGetValue2(worm, "mTargetEntityId")
|
||||||
|
local peer_id
|
||||||
|
local data = player_fns.get_player_data_by_local_entity_id(target)
|
||||||
|
if data ~= nil then
|
||||||
|
peer_id = data.peer_id
|
||||||
|
target = nil
|
||||||
|
end
|
||||||
en_data = EnemyDataWorm {
|
en_data = EnemyDataWorm {
|
||||||
enemy_id = enemy_id,
|
enemy_id = enemy_id,
|
||||||
x = x,
|
x = x,
|
||||||
|
@ -293,6 +301,8 @@ function enemy_sync.host_upload_entities()
|
||||||
vy = vy,
|
vy = vy,
|
||||||
tx = tx,
|
tx = tx,
|
||||||
ty = ty,
|
ty = ty,
|
||||||
|
target = target,
|
||||||
|
peer_id = peer_id,
|
||||||
}
|
}
|
||||||
elseif math.abs(vx) < 0.01 and math.abs(vy) < 0.01 then
|
elseif math.abs(vx) < 0.01 and math.abs(vy) < 0.01 then
|
||||||
en_data = EnemyDataNoMotion {
|
en_data = EnemyDataNoMotion {
|
||||||
|
@ -601,6 +611,20 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
||||||
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
|
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
|
||||||
local tx, ty = en_data.tx, en_data.ty
|
local tx, ty = en_data.tx, en_data.ty
|
||||||
ComponentSetValue2(worm, "mRandomTarget", tx, ty)
|
ComponentSetValue2(worm, "mRandomTarget", tx, ty)
|
||||||
|
local ent
|
||||||
|
if en_data.peer_id == nil then
|
||||||
|
if ctx.entity_by_remote_id[en_data.target] ~= nil then
|
||||||
|
ent = ctx.entity_by_remote_id[en_data.target].id
|
||||||
|
end
|
||||||
|
else
|
||||||
|
--help quant :( GamePrint(ffi.string(en_data.peer_id))
|
||||||
|
--if ctx.players[ffi.string(en_data.peer_id)] ~= nil then
|
||||||
|
-- ent = ctx.players[ffi.string(en_data.peer_id)].entity
|
||||||
|
--end
|
||||||
|
end
|
||||||
|
if ent ~= nil then
|
||||||
|
ComponentSetValue2(worm, "mTargetEntityId", ent)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if ffi.typeof(en_data) == EnemyDataKolmi and en_data.enabled then
|
if ffi.typeof(en_data) == EnemyDataKolmi and en_data.enabled then
|
||||||
local lua_components = EntityGetComponentIncludingDisabled(enemy_id, "LuaComponent") or {}
|
local lua_components = EntityGetComponentIncludingDisabled(enemy_id, "LuaComponent") or {}
|
||||||
|
|
|
@ -60,6 +60,7 @@ np.CrossCallAdd("ew_pet_hamis", function(x, y)
|
||||||
for a, b in pairs(ctx.entity_by_remote_id) do
|
for a, b in pairs(ctx.entity_by_remote_id) do
|
||||||
if b.id == y then
|
if b.id == y then
|
||||||
ent = a
|
ent = a
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rpc.pet(ctx.player_data_by_local_entity[x] or x, ent, frame(), hx, hy)
|
rpc.pet(ctx.player_data_by_local_entity[x] or x, ent, frame(), hx, hy)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue