internal void SendObeliskBroken(IWorldClient client, Obelisk obelisk) { using var packet = new Packet(PacketType.OBELISK_CHANGE); packet.Write(obelisk.Id); packet.Write((byte)obelisk.ObeliskCountry); client.SendPacket(packet); }
internal void SendUseVehicle(IWorldClient client, bool success, bool status) { using var packet = new Packet(PacketType.USE_VEHICLE); packet.Write(success); packet.Write(status); client.SendPacket(packet); }
internal void SendQuestStarted(IWorldClient client, ushort questId, int npcId) { using var packet = new Packet(PacketType.QUEST_START); packet.Write(npcId); packet.Write(questId); client.SendPacket(packet); }
internal void SendFriendOnline(IWorldClient client, int id, bool isOnline) { using var packet = new Packet(PacketType.FRIEND_ONLINE); packet.Write(id); packet.Write(isOnline); client.SendPacket(packet); }
internal void SendItemDoesNotBelong(IWorldClient client) { using var packet = new Packet(PacketType.ADD_ITEM); packet.WriteByte(0); packet.WriteByte(0); // Item doesn't belong to player. client.SendPacket(packet); }
internal void SendFullInventory(IWorldClient client) { using var packet = new Packet(PacketType.ADD_ITEM); packet.WriteByte(0); packet.WriteByte(1); // Inventory is full. client.SendPacket(packet); }
internal void SendMobRecover(IWorldClient client, IKillable sender) { using var packet = new Packet(PacketType.MOB_RECOVER); packet.Write(sender.Id); packet.Write(sender.CurrentHP); client.SendPacket(packet); }
internal void SendShapeUpdate(IWorldClient client, Character sender) { using var packet = new Packet(PacketType.CHARACTER_SHAPE_UPDATE); packet.Write(sender.Id); packet.Write((byte)sender.Shape); client.SendPacket(packet); }
internal void SendPortalTeleportNotAllowed(IWorldClient client, PortalTeleportNotAllowedReason reason) { using var packet = new Packet(PacketType.CHARACTER_ENTERED_PORTAL); packet.Write(false); // success packet.Write((byte)reason); client.SendPacket(packet); }
internal void SendAddGem(IWorldClient client, bool success, Item gem, Item destinationItem, byte gemSlot, uint gold, Item saveItem, Item hammer) { using var packet = new Packet(PacketType.GEM_ADD); packet.Write(success); packet.Write(gem.Bag); packet.Write(gem.Slot); packet.Write(gem.Count); packet.Write(destinationItem.Bag); packet.Write(destinationItem.Slot); packet.Write(gemSlot); packet.Write(gem.TypeId); packet.WriteByte(0); // unknown, old eps: byBag packet.WriteByte(0); // unknown, old eps: bySlot packet.WriteByte(0); // unknown, old eps: byTypeID; maybe in new ep TypeId is int? packet.Write(gold); if (hammer is null) { packet.WriteByte(0); packet.WriteByte(0); } else { packet.Write(hammer.Bag); packet.Write(hammer.Slot); } client.SendPacket(packet); }
public void OnPlayerMoved(IWorldClient client, PlayerMovedPacket packet) { if (client.Player.IsDead) { _logger.LogError($"Player {client.Player.Object.Name} is dead, he cannot move with keyboard."); return; } // TODO: Check if player is flying client.Player.Follow.Reset(); client.Player.Battle.Reset(); client.Player.Object.Position = packet.BeginPosition + packet.DestinationPosition; client.Player.Object.Angle = packet.Angle; client.Player.Object.MovingFlags = (ObjectState)packet.State; client.Player.Object.MotionFlags = (StateFlags)packet.StateFlag; client.Player.Moves.IsMovingWithKeyboard = client.Player.Object.MovingFlags.HasFlag(ObjectState.OBJSTA_FMOVE) || client.Player.Object.MovingFlags.HasFlag(ObjectState.OBJSTA_BMOVE); client.Player.Moves.DestinationPosition = packet.BeginPosition + packet.DestinationPosition; _moverPacketFactory.SendMoverMoved(client.Player, packet.BeginPosition, packet.DestinationPosition, client.Player.Object.Angle, (uint)client.Player.Object.MovingFlags, (uint)client.Player.Object.MotionFlags, packet.Motion, packet.MotionEx, packet.Loop, packet.MotionOption, packet.TickCount); }
public void OnJoin(IWorldClient client, JoinPacket packet) { DbCharacter character = _database.Characters.Include(x => x.User).FirstOrDefault(x => x.Id == packet.PlayerId); if (character == null) { _logger.LogError($"Invalid player id received from client; cannot find player with id: {packet.PlayerId}"); return; } if (character.IsDeleted) { _logger.LogWarning($"Cannot connect with character '{character.Name}' for user '{character.User.Username}'. Reason: character is deleted."); return; } if (character.User.Authority <= 0) { _logger.LogWarning($"Cannot connect with '{character.Name}'. Reason: User {character.User.Username} is banned."); // TODO: send error to client return; } client.Player = _playerFactory.CreatePlayer(character); client.Player.Connection = client; _worldSpawnPacketFactory.SendPlayerSpawn(client.Player); client.Player.Object.Spawned = true; client.Player.PlayerData.LoggedInAt = DateTime.UtcNow; }
/// <summary> /// Cancels duel. /// </summary> /// <param name="cancelReason">player is too far away; player was attacked etc.</param> private void SendDuelCancel(IWorldClient client, DuelCancelReason cancelReason, int playerId) { using var packet = new Packet(PacketType.DUEL_CANCEL); packet.Write((byte)cancelReason); packet.Write(playerId); client.SendPacket(packet); }
/// <summary> /// Removes item from trade. /// </summary> private void SendRemovedItemFromTrade(IWorldClient client, byte slotInTradeWindow, byte senderType) { using var packet = new Packet(PacketType.DUEL_TRADE_REMOVE_ITEM); packet.Write(senderType); packet.Write(slotInTradeWindow); client.SendPacket(packet); }
/// <summary> /// "Ok" button change in trade window. /// </summary> private void SendDuelApprove(IWorldClient client, byte senderType, bool isDuelDeclined) { using var packet = new Packet(PacketType.DUEL_TRADE_OK); packet.Write(senderType); packet.Write(isDuelDeclined); client.SendPacket(packet); }
internal void SendCharacterMotion(IWorldClient client, int characterId, Motion motion) { using var packet = new Packet(PacketType.CHARACTER_MOTION); packet.Write(characterId); packet.WriteByte((byte)motion); client.SendPacket(packet); }
/// <summary> /// Sends duel response. /// </summary> private void SendDuelResponse(IWorldClient client, DuelResponse response, int characterId) { using var packet = new Packet(PacketType.DUEL_RESPONSE); packet.Write((byte)response); packet.Write(characterId); client.SendPacket(packet); }
private void SendTradeConfirm(byte senderId, bool isDeclined, IWorldClient client) { using var packet = new Packet(PacketType.TRADE_FINISH); packet.WriteByte(senderId); packet.Write(isDeclined); client.SendPacket(packet); }
/// <summary> /// Adds money to trade. /// </summary> private void SendAddedMoneyToTrade(IWorldClient client, byte senderType, uint tradeMoney) { using var packet = new Packet(PacketType.DUEL_TRADE_ADD_MONEY); packet.Write(senderType); packet.Write(tradeMoney); client.SendPacket(packet); }
public void OnProjectileLaunched(IWorldClient client, SfxIdPacket packet) { var projectile = _projectileSystem.GetProjectile <ProjectileInfo>(client.Player, packet.IdSfxHit); if (projectile != null) { bool isProjectileValid = true; if (projectile.Target.Id != packet.TargetId) { _logger.LogError($"Invalid projectile target for '{client.Player}'"); isProjectileValid = false; } if (projectile.Type != (AttackFlags)packet.Type) { _logger.LogError($"Invalid projectile type for '{client.Player}'"); isProjectileValid = false; } if (!isProjectileValid) { _projectileSystem.RemoveProjectile(client.Player, packet.IdSfxHit); } } }
private void SendTradeDecide(byte senderId, bool isDecided, IWorldClient client) { using var packet = new Packet(PacketType.TRADE_DECIDE); packet.WriteByte(senderId); packet.Write(isDecided); client.SendPacket(packet); }
/// <summary> /// Sends duel position, in 5 seconds duel will start. /// </summary> private void SendReady(IWorldClient client, float x, float z) { using var packet = new Packet(PacketType.DUEL_READY); packet.Write(x); packet.Write(z); client.SendPacket(packet); }
public void OnSnapshot(IWorldClient client, INetPacketStream packet) { var snapshotCount = packet.Read <byte>(); while (snapshotCount > 0) { var snapshotHeaderNumber = packet.Read <short>(); try { var snapshotHeader = (SnapshotType)snapshotHeaderNumber; _handlerInvoker.Invoke(snapshotHeader, client, packet); } catch (ArgumentNullException) { if (Enum.IsDefined(typeof(SnapshotType), snapshotHeaderNumber)) { _logger.LogWarning("Received an unimplemented World snapshot {0} (0x{1}) from {2}.", Enum.GetName(typeof(SnapshotType), snapshotHeaderNumber), snapshotHeaderNumber.ToString("X4"), client.Socket.RemoteEndPoint); } else { _logger.LogWarning("[SECURITY] Received an unknown World snapshot 0x{0} from {1}.", snapshotHeaderNumber.ToString("X4"), client.Socket.RemoteEndPoint); } } catch (Exception exception) { _logger.LogError(exception, $"An error occured while handling a world snapshot."); _logger.LogDebug(exception.InnerException?.StackTrace); } snapshotCount--; } }
internal void SendCharacterPartyChanged(IWorldClient client, int characterId, PartyMemberType type) { using var packet = new Packet(PacketType.MAP_PARTY_SET); packet.Write(characterId); packet.Write((byte)type); client.SendPacket(packet); }
private void SendStartTrade(IWorldClient client, int characterId) { using var packet = new Packet(PacketType.DUEL_TRADE); packet.Write(characterId); packet.WriteByte(0); // ? client.SendPacket(packet); }
/// <summary> /// Send duel approval request. /// </summary> private void SendWaitingDuel(IWorldClient client, int duelStarterId, int duelOpponentId) { using var packet = new Packet(PacketType.DUEL_REQUEST); packet.Write(duelStarterId); packet.Write(duelOpponentId); client.SendPacket(packet); }
internal void SendRemoveGem(IWorldClient client, bool success, Item item, byte gemPosition, List <Item> savedGems, uint gold) { using var packet = new Packet(PacketType.GEM_REMOVE); packet.Write(success); packet.Write(item.Bag); packet.Write(item.Slot); packet.Write(gemPosition); for (var i = 0; i < 6; i++) { if (savedGems[i] is null) { packet.WriteByte(0); // bag } else { packet.Write(savedGems[i].Bag); } } for (var i = 0; i < 6; i++) { if (savedGems[i] is null) { packet.WriteByte(0); // slot } else { packet.Write(savedGems[i].Slot); } } for (var i = 0; i < 6; i++) // NB! in old eps this value was byte. { if (savedGems[i] is null) { packet.Write(0); // type id } else { packet.Write((int)savedGems[i].TypeId); } } for (var i = 0; i < 6; i++) { if (savedGems[i] is null) { packet.WriteByte(0); // count } else { packet.Write(savedGems[i].Count); } } packet.Write(gold); client.SendPacket(packet); }
/// <inheritdoc /> public void SendWelcome(IWorldClient client, uint sessionId) { using var packet = new FFPacket(PacketType.WELCOME); packet.Write(sessionId); client.Send(packet); }
internal void SendCharacterKilled(IWorldClient client, Character character, IKiller killer) { using var packet = new Packet(PacketType.CHARACTER_DEATH); packet.Write(character.Id); packet.WriteByte(1); // killer type. 1 - another player. packet.Write(killer.Id); client.SendPacket(packet); }
public void OnSnapshotSetDestPosition(IWorldClient client, SetDestPositionPacket packet) { client.Player.Object.MovingFlags = ObjectState.OBJSTA_FMOVE; client.Player.Moves.DestinationPosition = new Vector3(packet.X, packet.Y, packet.Z); client.Player.Follow.Reset(); _moverPacketFactory.SendDestinationPosition(client.Player); }