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);
        }
示例#2
0
        internal bool ReadMovement(IMoveable pMoveable, Packet pPacket)
        {
            byte movements;
            Coordinates position = null;
            ushort foothold = 0;
            byte stance = 0;
            if (!pPacket.ReadByte(out movements)) return false;
            while (movements-- > 0)
            {
                byte type;
                if (!pPacket.ReadByte(out type)) return false;
                switch (type)
                {
                    case 0:
                    case 5:
                        if (!pPacket.ReadCoordinates(out position) ||
                            !pPacket.ReadSkip(4) ||
                            !pPacket.ReadUShort(out foothold) ||
                            !pPacket.ReadByte(out stance) ||
                            !pPacket.ReadSkip(2)) return false;
                        break;
                    case 1:
                    case 2:
                    case 6:
                    case 13:
                        if (!pPacket.ReadCoordinates(out position) ||
                            !pPacket.ReadByte(out stance) ||
                            !pPacket.ReadUShort(out foothold)) return false;
                        break;
                    case 3:
                    case 4:
                    case 7:
                    case 8:
                    case 9:
                        if (!pPacket.ReadCoordinates(out position) ||
                            !pPacket.ReadSkip(4) ||
                            !pPacket.ReadByte(out stance)) return false;
                        break;
                    case 10:
                        if (!pPacket.ReadSkip(1)) return false;
                        break;
                    case 11:
                        if (!pPacket.ReadCoordinates(out position) ||
                            !pPacket.ReadUShort(out foothold) ||
                            !pPacket.ReadByte(out stance) ||
                            !pPacket.ReadSkip(2)) return false;
                        break;
                    case 12:
                    case 16:
                        if (!pPacket.ReadSkip(7)) return false;
                        break;
                    case 14:
                        if (!pPacket.ReadSkip(9)) return false;
                        break;
                    case 15:
                        if (!pPacket.ReadCoordinates(out position) ||
                            !pPacket.ReadSkip(6) ||
                            !pPacket.ReadUShort(out foothold) ||
                            !pPacket.ReadByte(out stance) ||
                            !pPacket.ReadSkip(2)) return false;
                        break;
                    case 17:
                        if (!pPacket.ReadCoordinates(out position) ||
                            !pPacket.ReadUShort(out foothold) ||
                            !pPacket.ReadByte(out stance) ||
                            !pPacket.ReadSkip(6)) return false;
                        break;
                    default: return false;
                }
            }

            if (position != null)
            {
                pMoveable.Position = position;
                pMoveable.Foothold = foothold;
                pMoveable.Stance = stance;
            }
            return true;
        }