Example #1
0
        public Packet Serialize(ObjectId itemId, ObjectId containerId, Location3D location)
        {
            ItemId      = itemId;
            ContainerId = containerId;
            Location    = location;

            byte[] payload = new byte[packetLength];

            var writer = new ArrayPacketWriter(payload);

            writer.WriteByte((byte)PacketDefinitions.DropItem.Id);
            writer.WriteId(ItemId);
            writer.WriteUShort((ushort)Location.X);
            writer.WriteUShort((ushort)Location.Y);
            writer.WriteSByte((sbyte)Location.Z);

            if (useGridIndex)
            {
                writer.WriteByte(0);
            }

            writer.WriteId(ContainerId);

            rawPacket = new Packet(PacketDefinitions.DropItem.Id, payload);
            return(rawPacket);
        }
Example #2
0
        public UpdatePlayerPacket(ObjectId id, ModelId type, Location3D location,
                                  Direction direction, Color color)
        {
            PlayerId     = id;
            Type         = type;
            Location     = location;
            Direction    = direction;
            MovementType = MovementType.Walk;
            Color        = color;
            Flags        = 0;

            byte[] payload = new byte[17];

            var writer = new ArrayPacketWriter(payload);

            writer.WriteByte((byte)PacketDefinitions.UpdatePlayer.Id);
            writer.WriteId(id);
            writer.WriteModelId(type);
            writer.WriteUShort((ushort)location.X);
            writer.WriteUShort((ushort)location.Y);
            writer.WriteSByte((sbyte)location.Z);
            writer.WriteMovement(direction, MovementType.Walk);
            writer.WriteColor(color);
            writer.WriteByte(0);
            writer.WriteByte(0);

            rawPacket = new Packet(PacketDefinitions.UpdateCurrentStamina.Id, payload);
        }
Example #3
0
 public TargetInfo(Location3D location, TargetType type, ModelId modelId, ObjectId?id)
 {
     Location = location;
     Type     = type;
     ModelId  = modelId;
     Id       = id;
 }
Example #4
0
        public ObjectInfoPacket(ObjectId id, ModelId type, Location3D location, Color?color)
        {
            Id       = id;
            Type     = type;
            Location = location;

            ushort packetLength = (ushort)(color.HasValue ? 17 : 15);
            var    payload      = new byte[packetLength];
            var    writer       = new ArrayPacketWriter(payload);

            writer.WriteByte((byte)PacketDefinitions.ObjectInfo.Id);
            writer.WriteUShort(packetLength);
            writer.WriteId(id);
            writer.WriteModelId(type);
            writer.WriteUShort((ushort)location.X);
            ushort y = (ushort)(color.HasValue ? location.Y | 0x8000 : location.Y);

            writer.WriteUShort(y);
            writer.WriteSByte((sbyte)location.Z);

            if (color.HasValue)
            {
                writer.WriteColor(color.Value);
            }

            rawPacket = new Packet(PacketDefinitions.ObjectInfo.Id, payload);
        }
Example #5
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            PlayerId = reader.ReadObjectId();
            uint unknown1 = reader.ReadUInt();

            BodyType = reader.ReadModelId();
            ushort xloc     = reader.ReadUShort();
            ushort yloc     = reader.ReadUShort();
            byte   unknown2 = reader.ReadByte();
            sbyte  zloc     = reader.ReadSByte();

            Location = new Location3D(xloc, yloc, zloc);
            (Direction, MovementType) = reader.ReadDirection();

            //reader.Skip(5);

            //var minX = reader.ReadUShort();
            //var minY = reader.ReadUShort();
            //var maxX = reader.ReadUShort();
            //var maxY = reader.ReadUShort();
            //MapBoundary = new MapBoundary(minX, minY, maxX, maxY);
        }
Example #6
0
 public Item(ObjectId id, ModelId type, ushort amount, Location3D location, Color?color, ObjectId?containerId, Layer?layer)
     : base(id, type, location)
 {
     Amount      = amount;
     Color       = color;
     ContainerId = containerId;
     Layer       = layer;
 }
Example #7
0
        private DropItemRequest(ObjectId itemId, ObjectId containerId, Location3D location)
        {
            ItemId      = itemId;
            ContainerId = containerId;
            Location    = location;

            RawPacket = Serialize();
        }
Example #8
0
        internal Item Update(ModelId type, ushort amount, Location3D location, Color?color, ObjectId?containerId,
                             Layer?layer)
        {
            var updatedItem = Update(type, amount, location, color, containerId);

            updatedItem.Layer = layer;

            return(updatedItem);
        }
Example #9
0
 public void ShowMobile(ObjectId id, ModelId type, Location3D location, Color color, Direction direction)
 {
     ShowTracked(id, location);
     if (id.IsMobile)
     {
         ultimaClient.UpdatePlayer(id, type, location, direction, color);
     }
     phantomIds.Add(id);
 }
Example #10
0
        public DrawGamePlayerPacket(ObjectId playerId, ModelId bodyType, Location3D location, Direction direction, MovementType movementType, Color color)
        {
            PlayerId = playerId;
            BodyType = bodyType;
            Location = location;
            Color    = color;

            Serialize();
        }
Example #11
0
 // Add an entity to the world
 public void AddEntity(Entity entity, Location3D location)
 {
     // If the target tile will accept the entity,
     if (tiles.At(location).AddEntity(entity))
     {
         // Track the entity globally
         entities.Add(entity);
     }
 }
Example #12
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);
            uint   rawId   = reader.ReadUInt();
            ushort rawType = reader.ReadUShort();

            uint finalId;

            if ((rawId & 0x80000000) != 0)
            {
                finalId = rawId - 0x80000000;
                Amount  = reader.ReadUShort();
            }
            else
            {
                Amount  = 1;
                finalId = rawId;
            }
            Id = new ObjectId(finalId);

            if ((rawType & 0x8000) != 0)
            {
                throw new PacketParsingException(rawPacket, "Not implementated: Type & 0x8000");
            }

            Type = rawType;

            ushort xloc = reader.ReadUShort();
            ushort yloc = reader.ReadUShort();

            if ((xloc & 0x8000) != 0)
            {
                xloc -= 0x8000;

                (Facing, _) = reader.ReadDirection();
            }

            sbyte zloc = reader.ReadSByte();

            if ((yloc & 0x8000) != 0)
            {
                yloc -= 0x8000;
                Dye   = (Color)reader.ReadUShort();
            }

            if ((yloc & 0x4000) != 0)
            {
                yloc -= 0x4000;
                Flags = (ObjectFlag)reader.ReadByte();
            }

            Location = new Location3D(xloc, yloc, zloc);
        }
 internal GraphicalEffectStartedEvent(EffectDirectionType directionType, ObjectId characterId,
                                      ObjectId targetId, ModelId type, Location3D location, Location3D targetLocation)
 {
     DirectionType  = directionType;
     CharacterId    = characterId;
     TargetId       = targetId;
     Type           = type;
     Location       = location;
     TargetLocation = targetLocation;
 }
Example #14
0
        internal Item Update(ModelId type, ushort amount, Location3D location, Color?color, ObjectId?containerId)
        {
            var updatedItem = (Item)Duplicate();

            updatedItem.Location    = location;
            updatedItem.Type        = type;
            updatedItem.Amount      = amount;
            updatedItem.Color       = color;
            updatedItem.ContainerId = containerId;

            return(updatedItem);
        }
Example #15
0
        public void TargetTile(Location3D location, ModelId tileType)
        {
            if (targetInfoRequested)
            {
                lastTargetInfo = new TargetInfo(location, TargetType.Tile, tileType, null);
                receivedTargetInfoEvent.Set();
            }
            else
            {
                server.TargetLocation(lastCursorId, location, tileType, CursorType.Harmful);
            }

            discardNextTargetLocationRequestIfEmpty = true;
            client.TargetLocation(lastCursorId, location, tileType, CursorType.Cancel);
        }
Example #16
0
   public Board()
   {
     person = new Person(this);
     rnd = new Random();
     gameBoard = new Cube[10, 10, 10];
     gameBoard.Initialize();
     int xAxis = rnd.Next(11);
     int yAxis = rnd.Next(11);
     int zAxis = rnd.Next(11);
 
     var location = new Location3D(xAxis, yAxis, zAxis);
     person.Location = location;
 
     GetCubeAt(location).AddContents(person);
   }
Example #17
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(2);
            Id = reader.ReadUShort();
            reader.Skip(2);

            var x = reader.ReadUShort();
            var y = reader.ReadUShort();

            Location = new Location3D(x, y, 0);
        }
Example #18
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            PlayerId = reader.ReadObjectId();
            Type     = reader.ReadModelId();
            Location = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte());
            (Direction, MovementType) = reader.ReadDirection();
            Color = reader.ReadColor();
            Flags = reader.ReadByte();
        }
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            SequenceKey = reader.ReadByte();
            ushort xloc = reader.ReadUShort();
            ushort yloc = reader.ReadUShort();

            (Direction, MovementType) = reader.ReadDirection();
            sbyte zloc = reader.ReadSByte();

            Location = new Location3D(xloc, yloc, zloc);
        }
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(4);

            Id     = reader.ReadObjectId();
            Type   = reader.ReadModelId();
            Facing = (Direction)reader.ReadByte();
            Amount = reader.ReadUShort();
            reader.ReadUShort(); // second amount?
            Location = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte());
            Layer    = reader.ReadLayer();
            Color    = reader.ReadColor();

            reader.ReadByte(); // flags
        }
Example #21
0
        private void ShowTracked(ObjectId id, Location3D location)
        {
            byte[] payload = null;

            lock (trackedObjectsLock)
            {
                if (!trackedObjects.TryGetValue(id, out payload) || payload == null)
                {
                    return;
                }
            }

            var packet = packetRegistry.Instantiate <DrawObjectPacket>();

            packet.Deserialize(new Packet(payload[0], payload));
            packet.Location = location;
            ultimaClient.Send(packet.RawPacket);
        }
Example #22
0
        public TargetLocationRequest(CursorId cursorId, Location3D location, ModelId tileType, CursorType cursorType)
        {
            var payload = new byte[19];
            var writer  = new ArrayPacketWriter(payload);

            writer.WriteByte((byte)PacketDefinitions.TargetCursor.Id);
            writer.WriteByte((byte)CursorTarget.Location);
            writer.WriteUInt(cursorId.Value);
            writer.WriteByte((byte)cursorType);
            writer.WriteInt(0); // clicked on item = 0 (using location click)
            writer.WriteUShort((ushort)location.X);
            writer.WriteUShort((ushort)location.Y);
            writer.WriteByte(0); // unknown
            writer.WriteSByte((sbyte)location.Z);
            writer.WriteModelId(tileType);

            RawPacket = new Packet(PacketDefinitions.TargetCursor.Id, payload);
        }
        public CharMoveRejectionPacket(byte sequenceKey, Location3D location, Direction direction)
        {
            SequenceKey = sequenceKey;
            Location    = location;
            Direction   = direction;

            var payload = new byte[8];
            var writer  = new ArrayPacketWriter(payload);

            writer.WriteByte((byte)PacketDefinitions.CharMoveRejection.Id);
            writer.WriteByte(sequenceKey);
            writer.WriteUShort((ushort)location.X);
            writer.WriteUShort((ushort)location.Y);
            writer.WriteByte((byte)direction);
            writer.WriteByte((byte)location.Z);

            rawPacket = new Packet(PacketDefinitions.CharMoveRejection.Id, payload);
        }
Example #24
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            DirectionType = (EffectDirectionType)reader.ReadByte();
            CharacterId   = reader.ReadObjectId();
            TargetId      = reader.ReadObjectId();
            Type          = reader.ReadModelId();

            Location        = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte());
            TargetLocation  = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte());
            AnimationSpeed  = reader.ReadByte();
            AdjustDirection = reader.ReadBool();
            ExplodeOnImpact = reader.ReadBool();
        }
Example #25
0
        private void Target(ObjectId itemId, ModelId type, Location3D location)
        {
            if (targetInfoRequested)
            {
                lastItemIdInfo = itemId;
                lastTypeInfo   = type;
                lastTargetInfo = new TargetInfo(location, TargetType.Object, type, itemId);
                receivedTargetInfoEvent.Set();
            }
            else
            {
                server.TargetItem(lastCursorId, itemId, CursorType.Harmful, location, type);
            }

            discardNextTargetLocationRequestIfEmpty = true;
            client.CancelTarget(lastCursorId, itemId, location, type);

            lock (nextTargetsLock)
                nextTargets.Clear();
        }
Example #26
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            CursorTarget = (CursorTarget)reader.ReadByte();
            CursorId     = new CursorId(reader.ReadUInt());
            CursorType   = (CursorType)reader.ReadByte();
            ClickedOnId  = reader.ReadObjectId();

            ushort xloc    = reader.ReadUShort();
            ushort yloc    = reader.ReadUShort();
            byte   unknown = reader.ReadByte();
            sbyte  zloc    = reader.ReadSByte();

            Location = new Location3D(xloc, yloc, zloc);

            ClickedOnType = reader.ReadModelId();
        }
Example #27
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            Id       = reader.ReadObjectId();
            Type     = reader.ReadModelId();
            Location = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte());
            (Direction, MovementType) = reader.ReadDirection();
            Color     = (Color)reader.ReadUShort();
            Flags     = reader.ReadByte();
            Notoriety = (Notoriety)reader.ReadByte();

            var items  = new List <Item>();
            var itemId = reader.ReadUInt();

            while (itemId != 0x00000000)
            {
                var   type  = reader.ReadUShort();
                var   layer = (Layer)reader.ReadByte();
                Color?color = null;

                if ((type & 0x8000) != 0)
                {
                    type -= 0x8000;
                    color = (Color)reader.ReadUShort();
                }

                var item = new Item(new ObjectId(itemId), new ModelId(type), 1, new Location3D(0, 0, 0), containerId: Id,
                                    layer: layer, color: color);

                items.Add(item);

                itemId = reader.ReadUInt();
            }

            Items = items.ToArray();
        }
Example #28
0
        public GraphicalEffectPacket(ObjectId characterId, ObjectId targetId, ModelId type, Location3D location,
                                     Location3D targetLocation, byte animationSpeed, EffectDirectionType directionType, byte duration, bool adjustDirection, bool explodeOnImpact)
        {
            DirectionType   = directionType;
            CharacterId     = characterId;
            TargetId        = targetId;
            Type            = type;
            Location        = location;
            TargetLocation  = targetLocation;
            AnimationSpeed  = animationSpeed;
            AdjustDirection = adjustDirection;
            ExplodeOnImpact = explodeOnImpact;

            var payload = new byte[28];
            var writer  = new ArrayPacketWriter(payload);

            writer.WriteByte((byte)PacketDefinitions.GraphicalEffect.Id);
            writer.WriteByte((byte)DirectionType);
            writer.WriteId(characterId);
            writer.WriteId(targetId);
            writer.WriteModelId(type);

            writer.WriteUShort((ushort)location.X);
            writer.WriteUShort((ushort)location.Y);
            writer.WriteByte((byte)location.Z);

            writer.WriteUShort((ushort)targetLocation.X);
            writer.WriteUShort((ushort)targetLocation.Y);
            writer.WriteByte((byte)targetLocation.Z);

            writer.WriteByte(animationSpeed);
            writer.WriteByte(duration);
            writer.WriteUShort(0); // unknwon
            writer.WriteByte((byte)(adjustDirection ? 1 : 0));
            writer.WriteByte((byte)(explodeOnImpact ? 1 : 0));

            rawPacket = new Packet(PacketDefinitions.GraphicalEffect.Id, payload);
        }
Example #29
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            PlayerId = reader.ReadObjectId();
            BodyType = reader.ReadModelId();
            reader.Skip(1); // unknown

            Color = reader.ReadColor();
            Flags = reader.ReadByte();

            var xloc = reader.ReadUShort();
            var yloc = reader.ReadUShort();

            reader.Skip(2); // unknown
            (Direction, MovementType) = reader.ReadDirection();
            var zloc = reader.ReadSByte();

            Location = new Location3D(xloc, yloc, zloc);
        }
Example #30
0
        public DrawGamePlayerPacket(ObjectId playerId, ModelId bodyType, Location3D location, Direction direction, MovementType movementType, Color color)
        {
            var payload = new byte[19];
            var writer  = new ArrayPacketWriter(payload);

            PlayerId = playerId;
            BodyType = bodyType;
            Location = location;
            Color    = color;

            writer.WriteByte((byte)PacketDefinitions.DrawGamePlayer.Id);
            writer.WriteId(playerId);
            writer.WriteModelId(bodyType);
            writer.WriteByte(0); // unknown
            writer.WriteColor(color);
            writer.WriteByte(0); // flag, alway 0
            writer.WriteUShort((ushort)location.X);
            writer.WriteUShort((ushort)location.Y);
            writer.WriteUShort(0); // unknown
            writer.WriteMovement(direction, movementType);
            writer.WriteSByte((sbyte)location.Z);

            rawPacket = new Packet(PacketDefinitions.DrawGamePlayer.Id, payload);
        }