Exemplo n.º 1
0
        public static void Action(Client pClient, Packet pPacket)
        {
            int uniqueIdentifier;
            short moveIdentifier;
            bool isUsingAbility;
            byte usingAbility;
            Coordinates projectileTarget;

            if (!pPacket.ReadInt(out uniqueIdentifier) ||
                !pPacket.ReadShort(out moveIdentifier) ||
                !pPacket.ReadBool(out isUsingAbility) ||
                !pPacket.ReadByte(out usingAbility) ||
                !pPacket.ReadCoordinates(out projectileTarget) ||
                !pPacket.ReadSkip(5))
            {
                pClient.Disconnect();
                return;
            }
            Mob mob = pClient.Player.Map.GetMob(uniqueIdentifier);
            if (mob == null || mob.Controller != pClient.Player) return;
            int rewindOffset = pPacket.Cursor;
            Coordinates unknownPosition;
            if (!pPacket.ReadCoordinates(out unknownPosition) ||
                !pClient.Player.Map.ReadMovement(mob, pPacket))
            {
                pClient.Disconnect();
                return;
            }

            Packet packet = new Packet(EOpcode.SMSG_MOB_ACTION_CONFIRM);
            packet.WriteInt(uniqueIdentifier);
            packet.WriteShort(moveIdentifier);
            packet.WriteBool(isUsingAbility);
            packet.WriteUShort((ushort)mob.Mana);
            packet.WriteByte(0x00); // Ability Identifier
            packet.WriteByte(0x00); // Ability Level
            pClient.SendPacket(packet);

            pPacket.Rewind(rewindOffset);

            packet = new Packet(EOpcode.SMSG_MOB_ACTION);
            packet.WriteInt(uniqueIdentifier);
            packet.WriteBool(isUsingAbility);
            packet.WriteByte(usingAbility);
            packet.WriteCoordinates(projectileTarget);
            packet.WriteBytes(pPacket.InnerBuffer, pPacket.Cursor, pPacket.Remaining);
            pClient.Player.Map.SendPacketToAllExcept(packet, pClient.Player);

            pClient.Player.Map.UpdateMobControllers(true);
        }
Exemplo n.º 2
0
 public static void Action(Client pClient, Packet pPacket)
 {
     int firstUnknown;
     short secondUnknown;
     if (!pPacket.ReadInt(out firstUnknown) ||
         !pPacket.ReadShort(out secondUnknown))
     {
         pClient.Disconnect();
         return;
     }
     Packet packet = new Packet(EOpcode.SMSG_NPC_ACTION);
     byte thirdUnknown;
     if (!pPacket.ReadByte(out thirdUnknown))
     {
         packet.WriteInt(firstUnknown);
         packet.WriteShort(secondUnknown);
     }
     else packet.WriteBytes(pPacket.InnerBuffer, pPacket.Cursor, pPacket.Remaining);
     pClient.SendPacket(packet);
 }
 private static void SendWorldStatus(Client pClient)
 {
     int population = Server.Population;
     Packet packet = new Packet(EOpcode.SMSG_WORLD_STATUS);
     if (population >= Config.Instance.Channel.MaxPopulation) packet.WriteByte(0x02);
     else if (population >= (Config.Instance.Channel.MaxPopulation * 0.9)) packet.WriteByte(0x01);
     else packet.WriteByte(0x00);
     packet.WriteByte(0);
     pClient.SendPacket(packet);
 }
        private static void SendWorldList(Client pClient)
        {
            Packet packet = new Packet(EOpcode.SMSG_WORLD_LIST);
            packet.WriteByte(0);
            packet.WriteString("Scania");
            packet.WriteByte(Config.Instance.World.Ribbon);
            packet.WriteString(Config.Instance.World.EventMessage);
            packet.WriteByte(Config.Instance.World.ExperienceModifier);
            packet.WriteByte(0);
            packet.WriteByte(Config.Instance.World.DropModifier);
            packet.WriteByte(0);
            packet.WriteByte(0);

            packet.WriteByte(1);
            packet.WriteString("Scania-1");
            packet.WriteInt(Server.Population);
            packet.WriteByte(0);
            packet.WriteByte(0);
            packet.WriteByte(0);

            packet.WriteShort(0);
            pClient.SendPacket(packet);

            packet = new Packet(EOpcode.SMSG_WORLD_LIST);
            packet.WriteByte(0xFF);
            pClient.SendPacket(packet);
        }
 private static void SendPlayerNameCheck(Client pClient, string pName, bool pUnusable)
 {
     Packet packet = new Packet(EOpcode.SMSG_PLAYER_NAME_CHECK);
     packet.WriteString(pName);
     packet.WriteBool(pUnusable);
     pClient.SendPacket(packet);
 }
 private static void SendPlayerList(Client pClient)
 {
     Packet packet = new Packet(EOpcode.SMSG_PLAYER_LIST);
     packet.WriteByte(0x00);
     byte playerCount = (byte)(long)Database.Scalar("SELECT COUNT(*) FROM player WHERE account_identifier=@account_identifier", new MySqlParameter("@account_identifier", pClient.Account.Identifier));
     packet.WriteByte(playerCount);
     if (playerCount > 0)
     {
         using (DatabaseQuery query = Database.Query("SELECT * FROM player WHERE account_identifier=@account_identifier", new MySqlParameter("@account_identifier", pClient.Account.Identifier)))
         {
             while (query.NextRow()) WritePlayer(packet, query);
         }
     }
     packet.WriteInt(Config.Instance.Login.MaxPlayersPerAccount);
     pClient.SendPacket(packet);
 }
 private static void SendPlayerDelete(Client pClient, int pPlayerIdentifier)
 {
     Packet packet = new Packet(EOpcode.SMSG_PLAYER_DELETE);
     packet.WriteInt(pPlayerIdentifier);
     packet.WriteByte(0x00);
     pClient.SendPacket(packet);
 }
 private static void SendPlayerCreate(Client pClient, DatabaseQuery pQuery)
 {
     Packet packet = new Packet(EOpcode.SMSG_PLAYER_CREATE);
     packet.WriteByte(0x00);
     WritePlayer(packet, pQuery);
     pClient.SendPacket(packet);
 }
 private static void SendPin(Client pClient)
 {
     Packet packet = new Packet(EOpcode.SMSG_PIN);
     packet.WriteByte(0x00);
     pClient.SendPacket(packet);
 }
Exemplo n.º 10
0
 private static void SendChannelConnect(Client pClient, int pPlayerIdentifier)
 {
     Packet packet = new Packet(EOpcode.SMSG_CHANNEL_CONNECT);
     packet.WriteByte(0x00);
     packet.WriteByte(0x00);
     packet.WriteBytes(IPAddress.Parse(Config.Instance.Channel.ExternalAddress).GetAddressBytes());
     packet.WriteUShort(Config.Instance.Channel.Listener.Port);
     packet.WriteInt(pPlayerIdentifier);
     packet.WriteSkip(5);
     pClient.SendPacket(packet);
 }
Exemplo n.º 11
0
 private static void SendAuthentication(Client pClient, EAuthenticationResult pResult)
 {
     Packet packet = new Packet(EOpcode.SMSG_AUTHENTICATION);
     packet.WriteUInt((uint)pResult);
     packet.WriteSkip(2);
     if (pClient.Account != null)
     {
         packet.WriteInt(pClient.Account.Identifier);
         packet.WriteSkip(4);
         packet.WriteString(pClient.Account.Username);
         packet.WriteSkip(22);
     }
     pClient.SendPacket(packet);
 }