public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddOutfit(Default);

            msg.AddByte((byte)OutfitList.Count);

            foreach (AvalibleOutfit i in OutfitList)
            {
                msg.AddUInt16(i.Id);
                msg.AddString(i.Name);
                msg.AddByte(i.Addons);
            }

            if (Client.VersionNumber >= 870)
            {
                msg.AddByte((byte)MountList.Count);

                foreach (MountDescription i in MountList)
                {
                    msg.AddUInt16(i.Id);
                    msg.AddString(i.Name);
                }
            }
        }
Пример #2
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);

            msg.AddOutfit(Default);

            msg.AddByte((byte)OutfitList.Count);

            foreach (AvalibleOutfit i in OutfitList)
            {
                msg.AddUInt16(i.Id);
                msg.AddString(i.Name);
                msg.AddByte(i.Addons);
            }

            if (Client.VersionNumber >= 870)
            {
                msg.AddByte((byte)MountList.Count);

                foreach (MountDescription i in MountList)
                {
                    msg.AddUInt16(i.Id);
                    msg.AddString(i.Name);
                }
            }
        }
Пример #3
0
 /// <summary>
 ///     Adds the outfits.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="outfits">The outfits.</param>
 private static void AddOutfits(NetworkMessage message, ICollection <IOutfit> outfits)
 {
     message.AddByte((byte)outfits.Count);
     foreach (IOutfit skin in outfits)
     {
         message.AddOutfit(skin);
     }
 }
Пример #4
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);
                }
            }
        }
Пример #5
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);
            msg.AddOutfit(Default);
            msg.AddByte((byte)OutfitList.Count);

            foreach (AvalibleOutfit i in OutfitList)
            {
                msg.AddUInt16(i.Id);
                msg.AddString(i.Name);
                msg.AddByte(i.Addons);
            }
        }
Пример #6
0
        public override void ToNetworkMessage(NetworkMessage msg)
        {
            msg.AddByte((byte)Type);
            msg.AddOutfit(Default);
            msg.AddByte((byte)OutfitList.Count);

            foreach (AvalibleOutfit i in OutfitList)
            {
                msg.AddUInt16(i.Id);
                msg.AddString(i.Name);
                msg.AddByte(i.Addons);
            }
        }
Пример #7
0
        public static void Add(NetworkMessage message, Player player, IEnumerable <Outfit> outfits)
        {
            message.AddByte((byte)ServerPacketType.OutfitWindow);
            message.AddOutfit(player.Outfit);

            message.AddByte((byte)outfits.Count());

            foreach (Outfit outfit in outfits)
            {
                message.AddUInt16((ushort)outfit.LookType);
                message.AddString(outfit.Name);
                message.AddByte(outfit.Addons);
            }
        }
Пример #8
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);
            }
        }
Пример #9
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddOutfit(Outfit);
 }
Пример #10
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);
                    }
                }
            }
        }
Пример #11
0
        protected void GetTileDescription(Tile tile, NetworkMessage msg)
        {
            if (tile != null)
            {
                List<TileObject> objects = tile.Objects;
                objects.Insert(0, new TileObject(tile.Ground.Id, tile.Ground.Count, 0));

                foreach (TileObject o in objects)
                {
                    if (o.Id <= 0)
                    {
                        return;
                    }
                    else if (o.Id == 0x0061 || o.Id == 0x0062 || 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 if (o.Id <= 9999)
                    {
                        // Add an item
                        Item item = new Item(Client, (uint)o.Id, (byte)o.Data, "",
                            ItemLocation.FromLocation(tile.Location, (byte)o.StackOrder));

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

                        try
                        {
                            if (item.HasExtraByte)
                            {
                                msg.AddByte(item.Count);
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Пример #12
0
        protected void GetTileDescription(Tile tile, NetworkMessage msg)
        {
            if (tile != null)
            {
                List <TileObject> objects = tile.Objects;
                objects.Insert(0, new TileObject(tile.Ground.Id, tile.Ground.Count, 0));

                foreach (TileObject o in objects)
                {
                    if (o.Id <= 0)
                    {
                        return;
                    }
                    else if (o.Id == 0x0061 || o.Id == 0x0062 || 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 if (o.Id <= 9999)
                    {
                        // Add an item
                        Item item = new Item(Client, (uint)o.Id, (byte)o.Data, "",
                                             ItemLocation.FromLocation(tile.Location, (byte)o.StackOrder));

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

                        try
                        {
                            if (item.HasExtraByte)
                            {
                                msg.AddByte(item.Count);
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Пример #13
0
        protected bool ParseThing(NetworkMessage msg, Location pos, Tile tile, int n, NetworkMessage outMsg)
        {
            //get thing type
            ushort thingId = msg.GetUInt16();

            outMsg.AddUInt16(thingId);

            PacketCreature c;

            if (thingId == 0x0061 || thingId == 0x0062)
            {
                c          = new PacketCreature(Client);
                c.Location = pos;

                //creatures
                if (thingId == 0x0062) //creature is known
                {
                    c.Type = PacketCreatureType.Known;
                    c.Id   = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id); //creatureid
                }
                else if (thingId == 0x0061)
                { //creature is not known
                    //perhaps we have to remove a known creature
                    c.RemoveId = msg.GetUInt32();
                    outMsg.AddUInt32(c.RemoveId);

                    //add a new creature
                    c.Type = PacketCreatureType.Unknown;
                    c.Id   = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id);

                    c.Name = msg.GetString();
                    outMsg.AddString(c.Name);
                }

                //read creature properties
                c.Health = msg.GetByte();
                outMsg.AddByte(c.Health);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                c.Outfit = msg.GetOutfit();
                outMsg.AddOutfit(c.Outfit);

                c.LightLevel = msg.GetByte();
                outMsg.AddByte(c.LightLevel);

                c.LightColor = msg.GetByte();
                outMsg.AddByte(c.LightColor);

                c.Speed = msg.GetUInt16();
                outMsg.AddUInt16(c.Speed);

                c.Skull = (Constants.Skull)msg.GetByte();
                outMsg.AddByte((byte)c.Skull);

                c.PartyShield = (Constants.PartyShield)msg.GetByte();
                outMsg.AddByte((byte)c.PartyShield);

                creatures.Add(c);

                return(true);
            }
            else if (thingId == 0x0063)
            {
                //creature turn
                c          = new PacketCreature(Client);
                c.Location = pos;
                c.Type     = PacketCreatureType.Turn;
                c.Id       = msg.GetUInt32();
                outMsg.AddUInt32(c.Id);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                creatures.Add(c);

                return(true);
            }
            else
            {
                //item
                UInt16 itemId;
                if (thingId == UInt16.MaxValue)
                {
                    itemId = msg.GetUInt16();
                    outMsg.AddUInt16(itemId);
                }
                else
                {
                    itemId = thingId;
                }

                Item item = new Item(Client, itemId, 0, "", ItemLocation.FromLocation(pos, (byte)n));

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

                if (n == 0)
                {
                    tile.Ground = item;
                }
                else
                {
                    tile.Items.Add(item);
                }

                return(true);
            }
        }
Пример #14
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);
                    }
                }
            }

        }
Пример #15
0
        protected bool ParseThing(NetworkMessage msg, Location pos, Tile tile, int n, NetworkMessage outMsg)
        {
            //get thing type
            ushort thingId = msg.GetUInt16();
            outMsg.AddUInt16(thingId);

            PacketCreature c;

            if (thingId == 0x0061 || thingId == 0x0062)
            {

                c = new PacketCreature(Client);
                c.Location = pos;

                //creatures
                if (thingId == 0x0062) //creature is known
                {
                    c.Type = PacketCreatureType.Known;
                    c.Id = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id); //creatureid
                }
                else if (thingId == 0x0061)
                { //creature is not known
                    //perhaps we have to remove a known creature
                    c.RemoveId = msg.GetUInt32();
                    outMsg.AddUInt32(c.RemoveId);

                    //add a new creature
                    c.Type = PacketCreatureType.Unknown;
                    c.Id = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id);

                    c.Name = msg.GetString();
                    outMsg.AddString(c.Name);
                }

                //read creature properties
                c.Health = msg.GetByte();
                outMsg.AddByte(c.Health);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                c.Outfit = msg.GetOutfit();
                outMsg.AddOutfit(c.Outfit);

                c.LightLevel = msg.GetByte();
                outMsg.AddByte(c.LightLevel);

                c.LightColor = msg.GetByte();
                outMsg.AddByte(c.LightColor);

                c.Speed = msg.GetUInt16();
                outMsg.AddUInt16(c.Speed);

                c.Skull = (Constants.Skull)msg.GetByte();
                outMsg.AddByte((byte)c.Skull);

                c.PartyShield = (Constants.PartyShield)msg.GetByte();
                outMsg.AddByte((byte)c.PartyShield);

                creatures.Add(c);

                return true;
            }
            else if (thingId == 0x0063)
            {
                //creature turn
                c = new PacketCreature(Client);
                c.Location = pos;
                c.Type = PacketCreatureType.Turn;
                c.Id = msg.GetUInt32();
                outMsg.AddUInt32(c.Id);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                creatures.Add(c);

                return true;
            }
            else
            {
                //item
                UInt16 itemId;
                if (thingId == UInt16.MaxValue)
                {
                    itemId = msg.GetUInt16();
                    outMsg.AddUInt16(itemId);
                }
                else
                    itemId = thingId;

                Item item = new Item(Client, itemId, 0, "", ItemLocation.FromLocation(pos, (byte)n));

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

                if (n == 0)
                    tile.Ground = item;
                else
                    tile.Items.Add(item);

                return true;
            }
        }
Пример #16
0
 public override void ToNetworkMessage(NetworkMessage msg)
 {
     msg.AddByte((byte)Type);
     msg.AddUInt32(CreatureId);
     msg.AddOutfit(Outfit);
 }
Пример #17
0
 public static void Add(NetworkMessage message, Creature creature)
 {
     message.AddByte((byte)ServerPacketType.CreatureOutfit);
     message.AddUInt32(creature.Id);
     message.AddOutfit(creature.Outfit);
 }