Beispiel #1
0
 public void MoveTo(short x, short y, short facing = 2)
 {
     Packets.PacketWriter w = new Packets.PacketWriter(0x2A);
     w.WriteUInt32(0x00); // accountid to send to replaced in roommove
     w.WriteUInt32(0x00);
     w.WriteUInt32(this.Body.GameID);
     w.WriteUInt32(this.Body.Location.CurrentRoom.RoomID);
     w.WriteByte(0x00);
     w.WriteShort(x);
     w.WriteShort(y);
     w.WriteByte(0x00);
     w.WriteShort(x);
     w.WriteShort(y); // stop packet no facing
     //w.WriteShort(0x02);
     w.WriteByte(0xFF);
     byte[] move = w.ToArray();
     if (this.Body.Location.CurrentRoom.PlayerCount != 0) // no need to send to a room noone is in.
     {
         this.Body.Location.CurrentRoom.SendMovePacket(move);
     }
 }
Beispiel #2
0
 public virtual byte[] Serialize()
 {
     Packets.PacketWriter w = new Packets.PacketWriter();
     w.WriteByte(0x01);
     w.WriteUShort(this.GraphicID);
     w.WriteUInt32(this.GameID);
     w.WriteUShort(this.Color); // color
     if (string.IsNullOrEmpty(this.Name))
     {
         w.WriteByte(0x00); // 1 here if name follows, then followed by 2 bytes with length of naem
     }
     else
     {
         w.WriteByte(0x01);
         w.WriteString(this.Name); // prefixes the string with a short length
     }
     // right after name, if this item is engraved with a custom name
     // the spell byte is 0x4A
     if (!string.IsNullOrEmpty(this.Name))
     {
         w.WriteByte(0x4A);
     }
     else
     {
         w.WriteByte(0x00);
     }
     // identified, added later ? yes
     // how to handle buffs ?
     if (this.Enchantments.Count == 0)
     {
         w.WriteUShort(0x00);
     }
     else
     {
         foreach (byte b in this.Enchantments)
         {
             w.WriteByte(b);
             //Console.WriteLine("Wrote {0} for {1}.", b.ToString("X2"), this.GameID);
         }
     }
     w.WriteByte(0xFF); // buff end
     w.WriteByte(0x00); // i do not know if this byte holds a value
     // Roomlocation, if in a room
     #region Room and Location bytes
     if (this.Location == null)
     {
         w.WriteByte(0x00);                        // no location
     }
     else
     {
         if (this.Location.CurrentRoom != null)
         {
             if (this.Location.CurrentRoom.RoomID <= 65535)
             {
                 w.WriteByte(0x01);
                 w.WriteUShort((ushort)this.Location.CurrentRoom.RoomID);
             }
             else
             {
                 w.WriteByte(0x02);
                 w.WriteUInt32(this.Location.CurrentRoom.RoomID);
             }
             w.WriteUShort(this.Location.X);
             w.WriteUShort(this.Location.Y);
             w.WriteUShort(this.Location.Facing);
         }
         else
         {
             w.WriteByte(0x00); // we do not know what happened, a locations room should never be null
         }
     }
     // Ok locations done
     #endregion
     int i = this.IsInventoryItem ? 1 : 0;
     w.WriteByte((byte)i); // Not sure most items have this
     int e = this.Equipped ? 1 : 0;
     w.WriteByte((byte)e);
     w.WriteByte(0x00); // Do not know
     // Starts info for containers
     if (this.IsContainer)
     {
         w.WriteShort((short)this.ContainedItems.Count);
         // Followed by items contained
     }
     else
     {
         w.WriteShort(0x00);
     }
     //  w.WriteByte(0x00);
     w.WriteUInt32(0x00);
     return(w.GetRawPacket());
 }
Beispiel #3
0
        public override byte[] Serialize(out uint itemid)
        {
            itemid      = ServerGlobals.GetNextAvailableID();
            this.GameID = itemid;
            Packets.PacketWriter w = new Packets.PacketWriter();
            w.WriteByte(0x01);
            w.WriteUShort(this.GraphicID);
            w.WriteUInt32(this.GameID);
            w.WriteShort(0x73); // color
            if (string.IsNullOrEmpty(this.Name))
            {
                w.WriteByte(0x00); // 1 here if name follows, then followed by 2 bytes with length of naem
            }
            else
            {
                w.WriteByte(0x01);
                w.WriteString(this.Name); // prefixes the string with a short length
            }
            if (this.Enchantments.Count == 0)
            {
                w.WriteShort(0x00);
                w.WriteByte(0x00);
            }
            else
            {
                int totalenchants = this.Enchantments.Count;
                // must be 2 0x00 and 1 buff, if the item only has 1 buff.
                if (totalenchants == 1)
                {
                    w.WriteShort(0x00);
                    w.WriteByte(this.Enchantments[0]);
                }
                else if (totalenchants == 2)
                {
                    w.WriteByte(0x00);
                    w.WriteByte(this.Enchantments[0]);
                    w.WriteByte(this.Enchantments[1]);
                }
                else
                {
                    foreach (byte b in this.Enchantments)
                    {
                        w.WriteByte(b);
                    }
                }
            }
            w.WriteByte(0xFF);
            w.WriteByte(0x00);
            if (this.Location == null)
            {
                w.WriteByte(0x00);
            }                                                 // 0x01 if in a room with loc
            else
            {
                // Add room location
                if (this.Location.RoomNumber < 65534)
                {
                    w.WriteByte(0x01);
                    w.WriteUShort((ushort)this.Location.RoomNumber);
                }
                else
                {
                    w.WriteByte(0x02);
                    w.WriteUInt32(this.Location.RoomNumber);
                }
                w.WriteUShort(this.Location.X);
                w.WriteUShort(this.Location.Y);
                w.WriteUShort(this.Location.Facing);
            }
            w.WriteByte(0x01); // Not sure most items have this
            w.WriteByte((byte)(this.Equipped ? 1:0));
            // Not sure on all this
            w.WriteByte(0x00); // dunno
            w.WriteShort((short)this.ContainedItems.Count);


            w.WriteByte(0x00);
            // w.WriteUShort(0x00);
            w.WriteUInt32(0x00);
            // w.WriteBytes(new byte[3]);
            //w.WriteByte(0x00); // items in backpack just after this ?
            return(w.GetRawPacket());
        }