예제 #1
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromPosition);
     msg.AddLocation(ToPosition);
     msg.AddByte((byte)Effect);
 }
예제 #2
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromPosition);
     msg.AddLocation(ToPosition);
     msg.AddByte((byte)Effect);
 }
예제 #3
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromLocation);
     msg.AddByte(FromStackPosition);
     msg.AddLocation(ToLocation);
 }
예제 #4
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromLocation);
     msg.AddByte(FromStackPosition);
     msg.AddLocation(ToLocation);
 }
예제 #5
0
 public static void Add(NetworkMessage message, Location fromLocation, Location toLocation, ProjectileType projectile)
 {
     message.AddByte((byte)ServerPacketType.Projectile);
     message.AddLocation(fromLocation);
     message.AddLocation(toLocation);
     message.AddByte((byte)projectile);
 }
예제 #6
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);

            message.AddLocation(FromLocation);
            message.AddLocation(ToLocation);
            message.AddByte((byte)ShootType);
        }
예제 #7
0
        public static void Add
        (
            NetworkMessage message,
            Location fromLocation,
            byte fromStackPosition,
            Location toLocation
        )
        {
            message.AddByte((byte)ServerPacketType.CreatureMove);

            message.AddLocation(fromLocation);
            message.AddByte(fromStackPosition);
            message.AddLocation(toLocation);
        }
예제 #8
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);
            message.AddLocation(Origin);

            message.AddBytes(DescriptionBytes); // TODO: change this?
        }
예제 #9
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);
            message.AddUInt32(0);
            message.AddString(SenderName);
            message.AddByte((byte)SpeechType);

            switch (SpeechType)
            {
            case SpeechType.Say:
            case SpeechType.Whisper:
            case SpeechType.Yell:
            case SpeechType.MonsterSay:
                // case SpeechType.MonsterYell:
                message.AddLocation(Location);
                break;

            // case SpeechType.ChannelRed:
            // case SpeechType.ChannelRedAnonymous:
            // case SpeechType.ChannelOrange:
            case SpeechType.ChannelYellow:
                // case SpeechType.ChannelWhite:
                message.AddUInt16((ushort)ChannelId);
                break;

            case SpeechType.RuleViolationReport:
                message.AddUInt32(Time);
                break;

            default:
                break;
            }

            message.AddString(Text);
        }
예제 #10
0
        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg)
        {
            if (msg.GetByte() != (byte)IncomingPacketType.TileUpdate)
            {
                return(false);
            }

            Destination = destination;
            Type        = IncomingPacketType.TileUpdate;
            outMsg.AddByte((byte)Type);

            Objects.Location pos = msg.GetLocation();
            outMsg.AddLocation(pos);

            ushort thingId = msg.PeekUInt16();

            if (thingId == 0xFF01)
            {
                outMsg.AddUInt16(msg.GetUInt16());
            }
            else
            {
                ParseTileDescription(msg, pos, outMsg);
                outMsg.AddUInt16(msg.GetUInt16());
            }

            return(true);
        }
예제 #11
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(Location);
     msg.AddByte((byte)Color);
     msg.AddString(Message);
 }
예제 #12
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);

            message.AddLocation(Location);
            message.AddItem(Item);
        }
예제 #13
0
        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg)
        {
            if (msg.GetByte() != (byte)IncomingPacketType.TileUpdate)
                return false;

            Destination = destination;
            Type = IncomingPacketType.TileUpdate;
            outMsg.AddByte((byte)Type);

            Objects.Location pos = msg.GetLocation();
            outMsg.AddLocation(pos);

            ushort thingId = msg.PeekUInt16();

            if (thingId == 0xFF01)
            {
                outMsg.AddUInt16(msg.GetUInt16());
            }
            else
            {
                ParseTileDescription(msg, pos, outMsg);
                outMsg.AddUInt16(msg.GetUInt16());
            }

            return true;
        }
예제 #14
0
 public static void Add(NetworkMessage message, Location location, TextColor color, string text)
 {
     message.AddByte((byte)ServerPacketType.AnimatedText);
     message.AddLocation(location);
     message.AddByte((byte)color);
     message.AddString(text);
 }
예제 #15
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(Location);
     msg.AddByte((byte)Color);
     msg.AddString(Message);
 }
예제 #16
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);

            message.AddLocation(Location);
            message.AddCreature(Creature, AsKnown, RemoveThisCreatureId);
        }
예제 #17
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddUInt32(Unknown);
            msg.AddString(SenderName);
            msg.AddUInt16(SenderLevel);

            SpeechTypeInfo info = Enums.GetSpeechTypeInfo(Client.GetVersionNumber(), SpeechType);

            msg.AddByte(info.Value);

            switch (info.AdditionalSpeechData)
            {
            case AdditionalSpeechData.Location:
                msg.AddLocation(Position);
                break;

            case AdditionalSpeechData.ChannelId:
                msg.AddUInt16((ushort)ChannelId);
                break;

            case AdditionalSpeechData.Time:
                msg.AddUInt32(Time);
                break;

            default:
                break;
            }

            msg.AddString(Message);
        }
예제 #18
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddLocation(FromLocation);
     msg.AddUInt16(SpriteId);
     msg.AddByte(FromStackPosition);
     msg.AddUInt32(CreatureId);
 }
예제 #19
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);

            message.AddLocation(Location);
            message.AddByte((byte)Color);
            message.AddString(Text);
        }
예제 #20
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddLocation(Location);
            msg.AddUInt16(SpriteId);
            msg.AddByte(StackPosition);
        }
예제 #21
0
 public static void Add(NetworkMessage message, Location fromLocation, byte fromStackPosition)
 {
     if (fromStackPosition < 10)
     {
         message.AddByte((byte)ServerPacketType.TileRemoveThing);
         message.AddLocation(fromLocation);
         message.AddByte(fromStackPosition);
     }
 }
예제 #22
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {

            msg.AddByte((byte)Type);

            msg.AddLocation(Location);
            msg.AddUInt16(ItemId);
            msg.AddByte(StackPosition);
        }
예제 #23
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);

            message.AddLocation(Creature.Location);
            message.AddByte(Creature.GetStackPosition());
            message.AddUInt16(Creature.ThingId);
            message.AddUInt32(Creature.CreatureId);
            message.AddByte((byte)Creature.Direction);
        }
예제 #24
0
        public static void Add
        (
            Connection connection,
            NetworkMessage message,
            Tile tile
        )
        {
            message.AddByte((byte)ServerPacketType.TileUpdate);

            message.AddLocation(tile.Location);
            MapPacket.AddTileDescription(connection, message, tile);
        }
예제 #25
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddLocation(Location);
            msg.AddByte(Stack);
            msg.AddUInt16(ThingId);

            if (ThingId == 0x0061 || ThingId == 0x0062)
            {
                if (ThingId == 0x0062)
                {
                    msg.AddUInt32(Creature.Id);
                }
                else if (ThingId == 0x0061)
                {
                    msg.AddUInt32(Creature.RemoveId);
                    msg.AddUInt32(Creature.Id);
                    msg.AddString(Creature.Name);
                }

                msg.AddByte(Creature.Health);
                msg.AddByte(Creature.Direction);
                msg.AddOutfit(Creature.Outfit);

                msg.AddByte(Creature.LightLevel);
                msg.AddByte(Creature.LightColor);

                msg.AddUInt16(Creature.Speed);
                msg.AddByte((byte)Creature.Skull);
                msg.AddByte((byte)Creature.PartyShield);
                if (Client.VersionNumber >= 853)
                {
                    if (ThingId == 0x0061)
                    {
                        msg.AddByte((byte)Creature.WarIcon);
                    }
                    msg.AddByte(Convert.ToByte(Creature.IsBlocking));
                }
            }
            else if (ThingId == 0x0063)
            {
                msg.AddUInt32(Creature.Id);
                msg.AddByte(Creature.Direction);
            }
            else
            {
                if (Item.HasExtraByte)
                {
                    msg.AddByte(Item.Count);
                }
            }
        }
예제 #26
0
        public static void Send(Objects.Client client, Objects.Location fromLocation, ushort itemId, byte fromStack, uint creatureId)
        {
            NetworkMessage packet = new NetworkMessage();

            packet.Position = 0;
            packet.AddByte(0x84);
            packet.AddLocation(fromLocation);
            packet.AddUInt16(itemId);
            packet.AddByte(fromStack);
            packet.AddUInt32(creatureId);

            client.HookProxy.SendPacketToServer(packet.Data);
        }
예제 #27
0
        public static void Add
        (
            NetworkMessage message,
            Location location,
            byte stackPosition,
            Item item
        )
        {
            message.AddByte((byte)ServerPacketType.TileAddThing);

            message.AddLocation(location);
            message.AddByte(stackPosition);
            message.AddItem(item);
        }
예제 #28
0
        public static void Add
        (
            NetworkMessage message,
            Creature creature
        )
        {
            message.AddByte((byte)ServerPacketType.TileTransformThing);

            message.AddLocation(creature.Tile.Location);
            message.AddByte(creature.Tile.GetStackPosition(creature));
            message.AddUInt16(0x63);
            message.AddUInt32(creature.Id);
            message.AddByte((byte)creature.Direction);
        }
예제 #29
0
 public static void Add(Connection connection, NetworkMessage message, Location playerLocation)
 {
     message.AddByte((byte)ServerPacketType.MapDescription);
     message.AddLocation(playerLocation);
     AddMapDescription(
         connection,
         message,
         playerLocation.X - 8,
         playerLocation.Y - 6,
         playerLocation.Z,
         18,
         14
         );
 }
예제 #30
0
        public static void Add
        (
            NetworkMessage message,
            string senderName,
            ushort senderLevel,
            SpeechType speechType,
            string text,
            Location location,
            ChatChannel channelId,
            uint time
        )
        {
            message.AddByte((byte)ServerPacketType.CreatureSpeech);

            message.AddUInt32(0x00000000);
            message.AddString(senderName);
            message.AddUInt16(senderLevel);
            message.AddByte((byte)speechType);

            switch (speechType)
            {
            case SpeechType.Say:
            case SpeechType.Whisper:
            case SpeechType.Yell:
            case SpeechType.MonsterSay:
            case SpeechType.MonsterYell:
            case SpeechType.PrivateNPCToPlayer:
                message.AddLocation(location);
                break;

            case SpeechType.ChannelRed:
            case SpeechType.ChannelRedAnonymous:
            case SpeechType.ChannelOrange:
            case SpeechType.ChannelYellow:
            case SpeechType.ChannelWhite:
                message.AddUInt16((ushort)channelId);
                break;

            case SpeechType.RuleViolationReport:
                message.AddUInt32(time);
                break;

            default:
                break;
            }

            message.AddString(text);
        }
예제 #31
0
        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg)
        {
            int msgPosition = msg.Position, outMsgPosition = outMsg.Position;

            if (msg.GetByte() != (byte)IncomingPacketType.MapDescription)
                return false;

            Destination = destination;
            Type = IncomingPacketType.MapDescription;
            outMsg.AddByte((byte)Type);

            Client.playerLocation = msg.GetLocation();
            outMsg.AddLocation(Client.playerLocation);

            return ParseMapDescription(msg, Client.playerLocation.X - 8, Client.playerLocation.Y - 6, Client.playerLocation.Z, 18, 14, outMsg);
        }
예제 #32
0
        public static void Add
        (
            NetworkMessage message,
            Location location,
            byte stackPosition,
            Creature creature,
            bool known,
            uint removeKnown
        )
        {
            message.AddByte((byte)ServerPacketType.TileAddThing);

            message.AddLocation(location);
            message.AddByte(stackPosition);
            message.AddCreature(creature, known, removeKnown);
        }
예제 #33
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);

            message.AddLocation(Location);

            if (DescriptionBytes.Length > 0)
            {
                message.AddBytes(DescriptionBytes);
                message.AddByte(0x00); // skip count
            }
            else
            {
                message.AddByte(0x01); // skip count
            }

            message.AddByte(0xFF);
        }
예제 #34
0
        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg)
        {
            int msgPosition = msg.Position, outMsgPosition = outMsg.Position;

            if (msg.GetByte() != (byte)IncomingPacketType.MapDescription)
            {
                return(false);
            }

            Destination = destination;
            Type        = IncomingPacketType.MapDescription;
            outMsg.AddByte((byte)Type);

            Client.playerLocation = msg.GetLocation();
            outMsg.AddLocation(Client.playerLocation);

            return(ParseMapDescription(msg, Client.playerLocation.X - 8, Client.playerLocation.Y - 6, Client.playerLocation.Z, 18, 14, outMsg));
        }
예제 #35
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddLocation(Position);
            msg.AddByte(StackPosition);
            msg.AddUInt16(ThingId);

            if (ThingId == 0x0061 || ThingId == 0x0062 || ThingId == 0x0063)
            {
                msg.AddUInt32(CreatureId);
                msg.AddByte(CreatureDirection);
            }
            else
            {
                if (Item.HasExtraByte)
                    msg.AddByte(Item.Count);
            }
        }
예제 #36
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddLocation(Location);
            msg.AddByte(Stack);
            msg.AddUInt16(ThingId);

            if (ThingId == 0x0061 || ThingId == 0x0062)
            {
                if (ThingId == 0x0062)
                    msg.AddUInt32(Creature.Id);
                else if (ThingId == 0x0061)
                {
                    msg.AddUInt32(Creature.RemoveId);
                    msg.AddUInt32(Creature.Id);
                    msg.AddString(Creature.Name);
                }

                msg.AddByte(Creature.Health);
                msg.AddByte(Creature.Direction);
                msg.AddOutfit(Creature.Outfit);

                msg.AddByte(Creature.LightLevel);
                msg.AddByte(Creature.LightColor);

                msg.AddUInt16(Creature.Speed);
                msg.AddByte((byte)Creature.Skull);
                msg.AddByte((byte)Creature.PartyShield);
            }
            else if (ThingId == 0x0063)
            {
                msg.AddUInt32(Creature.Id);
                msg.AddByte(Creature.Direction);
            }
            else
            {
                if (Item.HasExtraByte)
                    msg.AddByte(Item.Count);
            }
        }
예제 #37
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddLocation(Position);
            msg.AddByte(StackPosition);
            msg.AddUInt16(ThingId);

            if (ThingId == 0x0061 || ThingId == 0x0062 || ThingId == 0x0063)
            {
                msg.AddUInt32(CreatureId);
                msg.AddByte(CreatureDirection);
            }
            else
            {
                if (Item.HasExtraByte)
                {
                    msg.AddByte(Item.Count);
                }
            }
        }
예제 #38
0
 public static void Add(NetworkMessage message, Location location, Effect effect)
 {
     message.AddByte((byte)ServerPacketType.Effect);
     message.AddLocation(location);
     message.AddByte((byte)effect);
 }
예제 #39
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddUInt32(Unknown);
            msg.AddString(SenderName);
            msg.AddUInt16(SenderLevel);

            SpeechTypeInfo info = Enums.GetSpeechTypeInfo(Client.VersionNumber, SpeechType);

            msg.AddByte(info.Value);

            switch (info.AdditionalSpeechData)
            {
                case AdditionalSpeechData.Location:
                    msg.AddLocation(Position);
                    break;
                case AdditionalSpeechData.ChannelId:
                    msg.AddUInt16((ushort)ChannelId);
                    break;
                case AdditionalSpeechData.Time:
                    msg.AddUInt32(Time);
                    break;
                default:
                    break;
            }

            msg.AddString(Message);
        }
예제 #40
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            Tile playerTile = Client.Map.GetTileWithPlayer();
            msg.AddByte((byte)Type);
            msg.AddLocation(playerTile.Location);

            //GetMapDescription(playerLocation.X - 8, playerLocation.Y - 6, playerLocation.Z, 18, 14, msg);

            int startz, endz, zstep;

            if (playerTile.Location.Z > 7)
            {
                startz = playerTile.Location.Z - 2;
                endz = Math.Min(15, playerTile.Location.Z + 2);
                zstep = 1;
            }
            else
            {
                startz = 7;
                endz = 0;
                zstep = -1;
            }

            uint mapStart = Client.Memory.ReadUInt32(Addresses.Map.MapPointer);

            for (int z = startz; z != endz + zstep; z += zstep)
            {
                for (int x = 0; x < 18; x++)
                {
                    for (int y = 0; y < 14; y++)
                    {
                        Location memLoc = new Location(x, y, z);
                        uint num = memLoc.ToTileNumber();
                        Tile pCurrent = new Tile(Client, mapStart + (Addresses.Map.StepTile * num), num);

                        foreach (TileObject o in pCurrent.Objects)
                        {
                            if (o.Id == 0x0063)
                            {
                                // Add a creature
                                Creature c = Client.BattleList.GetCreatures().FirstOrDefault(cr => cr.Id == o.Data);

                                if (c == null)
                                    throw new Exception("Creature does not exist.");

                                // Add as unknown
                                msg.AddUInt16((ushort)o.Id);

                                // No need to remove a creature
                                msg.AddUInt32(0);

                                // Add the creature id
                                msg.AddUInt32((uint)c.Id);

                                msg.AddString(c.Name);

                                msg.AddByte((byte)c.HPBar);

                                msg.AddByte((byte)c.Direction);

                                msg.AddOutfit(c.Outfit);

                                msg.AddByte((byte)c.Light);

                                msg.AddByte((byte)c.LightColor);

                                msg.AddUInt16((ushort)c.WalkSpeed);

                                msg.AddByte((byte)c.Skull);

                                msg.AddByte((byte)c.PartyShield);
                            }
                            else
                            {
                                Item item = new Item(Client, (uint)o.Id);

                                msg.AddUInt16((ushort)item.Id);

                                if (item.HasExtraByte)
                                    msg.AddByte(item.Count);
                            }
                        }

                        msg.AddByte(0x00);
                        msg.AddByte(0xFF);
                    }
                }
            }

        }
예제 #41
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            Tile playerTile = Client.Map.GetTileWithPlayer();

            msg.AddByte((byte)Type);
            msg.AddLocation(playerTile.Location);

            //GetMapDescription(playerLocation.X - 8, playerLocation.Y - 6, playerLocation.Z, 18, 14, msg);

            int startz, endz, zstep;

            if (playerTile.Location.Z > 7)
            {
                startz = playerTile.Location.Z - 2;
                endz   = Math.Min(15, playerTile.Location.Z + 2);
                zstep  = 1;
            }
            else
            {
                startz = 7;
                endz   = 0;
                zstep  = -1;
            }

            uint mapStart = Client.Memory.ReadUInt32(Addresses.Map.MapPointer);

            for (int z = startz; z != endz + zstep; z += zstep)
            {
                for (int x = 0; x < 18; x++)
                {
                    for (int y = 0; y < 14; y++)
                    {
                        Location memLoc   = new Location(x, y, z);
                        uint     num      = memLoc.ToTileNumber();
                        Tile     pCurrent = new Tile(Client, mapStart + (Addresses.Map.StepTile * num), num);

                        foreach (TileObject o in pCurrent.Objects)
                        {
                            if (o.Id == 0x0063)
                            {
                                // Add a creature
                                Creature c = Client.BattleList.GetCreatures().FirstOrDefault(cr => cr.Id == o.Data);

                                if (c == null)
                                {
                                    throw new Exception("Creature does not exist.");
                                }

                                // Add as unknown
                                msg.AddUInt16((ushort)o.Id);

                                // No need to remove a creature
                                msg.AddUInt32(0);

                                // Add the creature id
                                msg.AddUInt32((uint)c.Id);

                                msg.AddString(c.Name);

                                msg.AddByte((byte)c.HPBar);

                                msg.AddByte((byte)c.Direction);

                                msg.AddOutfit(c.Outfit);

                                msg.AddByte((byte)c.Light);

                                msg.AddByte((byte)c.LightColor);

                                msg.AddUInt16((ushort)c.WalkSpeed);

                                msg.AddByte((byte)c.Skull);

                                msg.AddByte((byte)c.PartyShield);
                            }
                            else
                            {
                                Item item = new Item(Client, (uint)o.Id);

                                msg.AddUInt16((ushort)item.Id);

                                if (item.HasExtraByte)
                                {
                                    msg.AddByte(item.Count);
                                }
                            }
                        }

                        msg.AddByte(0x00);
                        msg.AddByte(0xFF);
                    }
                }
            }
        }