diff --git a/quant.ew/files/system/enemy_sync.lua b/quant.ew/files/system/enemy_sync.lua index 1c980938..224173b7 100644 --- a/quant.ew/files/system/enemy_sync.lua +++ b/quant.ew/files/system/enemy_sync.lua @@ -21,8 +21,9 @@ local EnemyDataNoMotion = util.make_type({ }) local EnemyDataWorm = util.make_type({ - u32 = {"enemy_id"}, + u32 = {"enemy_id", "target"}, f32 = {"x", "y", "vx", "vy", "tx", "ty"}, + string = {"peer_id"} }) local EnemyDataKolmi = util.make_type({ @@ -285,6 +286,13 @@ function enemy_sync.host_upload_entities() } elseif worm ~= nil then 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 { enemy_id = enemy_id, x = x, @@ -293,6 +301,8 @@ function enemy_sync.host_upload_entities() vy = vy, tx = tx, ty = ty, + target = target, + peer_id = peer_id, } elseif math.abs(vx) < 0.01 and math.abs(vy) < 0.01 then 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 local tx, ty = en_data.tx, en_data.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 if ffi.typeof(en_data) == EnemyDataKolmi and en_data.enabled then local lua_components = EntityGetComponentIncludingDisabled(enemy_id, "LuaComponent") or {} diff --git a/quant.ew/files/system/hamis/hamis.lua b/quant.ew/files/system/hamis/hamis.lua index 9f06c418..d6a168b5 100644 --- a/quant.ew/files/system/hamis/hamis.lua +++ b/quant.ew/files/system/hamis/hamis.lua @@ -60,6 +60,7 @@ np.CrossCallAdd("ew_pet_hamis", function(x, y) for a, b in pairs(ctx.entity_by_remote_id) do if b.id == y then ent = a + break end end rpc.pet(ctx.player_data_by_local_entity[x] or x, ent, frame(), hx, hy)