Ejemplo n.º 1
0
 public static void SendMoveToPacketToSingleClient <T>(IRealmClient client, Unit movingUnit, uint moveTime,
                                                       MonsterMoveFlags moveFlags, IEnumerable <T> waypoints) where T : IPathVertex
 {
     using (RealmPacketOut packet =
                MovementHandler.ConstructMultiWaypointMovePacket <T>(movingUnit, moveTime, moveFlags, waypoints))
         client.Send(packet, false);
 }
Ejemplo n.º 2
0
 public static void SendMoveToPacket(Unit movingUnit, ref Vector3 pos, float orientation, uint moveTime,
                                     MonsterMoveFlags moveFlags)
 {
     if (movingUnit.IsAreaActive)
     {
         return;
     }
     Character characterMaster = movingUnit.CharacterMaster;
 }
Ejemplo n.º 3
0
 public static void SendMoveToPacketToSingleClient <T>(IRealmClient client, Unit movingUnit, uint moveTime,
                                                       MonsterMoveFlags moveFlags, IEnumerable <T> waypoints)
     where T : IPathVertex
 {
     using (var packet = ConstructMultiWaypointMovePacket(movingUnit, moveTime, moveFlags, waypoints))
     {
         client.Send(packet, addEnd: false);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructs a waypoint packet, starting with the given firstNode (until the end of the LinkedList).
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="unit"></param>
        /// <param name="speed">The speed that the Unit should move with in yards/second</param>
        /// <param name="moveFlags"></param>
        /// <param name="firstNode"></param>
        /// <returns></returns>
        public static RealmPacketOut ConstructMultiWaypointMovePacket <T>(Unit unit, int speed,
                                                                          MonsterMoveFlags moveFlags, LinkedListNode <T> firstNode) where T : IPathVertex
        {
            RealmPacketOut writer = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_MONSTER_MOVE,
                                                       39 + firstNode.List.Count * 4 * 3);

            unit.EntityId.WritePacked((BinaryWriter)writer);
            writer.Write(false);
            writer.Write(unit.Position);
            writer.Write(Utility.GetSystemTime());
            writer.Write((byte)0);
            writer.Write((uint)moveFlags);
            if (moveFlags.HasFlag((Enum)MonsterMoveFlags.Flag_0x200000))
            {
                writer.Write((byte)0);
                writer.Write(0);
            }

            long position1 = writer.Position;

            writer.Position += 4L;
            if (moveFlags.HasFlag((Enum)MonsterMoveFlags.Flag_0x800))
            {
                writer.Write(0.0f);
                writer.Write(0);
            }

            long position2 = writer.Position;

            writer.Position += 4L;
            int num1 = (int)(1000.0 * (double)unit.Position.GetDistance(firstNode.Value.Position) / (double)speed);
            int num2 = 0;
            LinkedListNode <T> linkedListNode = firstNode;

            while (true)
            {
                ++num2;
                writer.Write(linkedListNode.Value.Position);
                LinkedListNode <T> next = linkedListNode.Next;
                if (next != null)
                {
                    num1          += (int)(1000.0 * (double)linkedListNode.Value.GetDistanceToNext() / (double)speed);
                    linkedListNode = next;
                }
                else
                {
                    break;
                }
            }

            writer.Position = position1;
            writer.Write(num1);
            writer.Position = position2;
            writer.Write(num2);
            return(writer);
        }
Ejemplo n.º 5
0
 public static void SendMoveToPacket <T>(Unit movingUnit, int speed, MonsterMoveFlags moveFlags,
                                         LinkedListNode <T> firstNode) where T : IPathVertex
 {
     if (!movingUnit.IsAreaActive)
     {
         return;
     }
     using (RealmPacketOut packet =
                MovementHandler.ConstructMultiWaypointMovePacket <T>(movingUnit, speed, moveFlags, firstNode))
         movingUnit.SendPacketToArea(packet, true, false, Locale.Any, new float?());
 }
Ejemplo n.º 6
0
 public static void SendMoveToPacket <T>(Unit movingUnit, uint moveTime, MonsterMoveFlags moveFlags,
                                         IEnumerable <T> waypoints) where T : IPathVertex
 {
     if (!movingUnit.IsAreaActive)
     {
         return;
     }
     using (RealmPacketOut packet =
                MovementHandler.ConstructMultiWaypointMovePacket <T>(movingUnit, moveTime, moveFlags, waypoints))
         movingUnit.SendPacketToArea(packet, true, false, Locale.Any, new float?());
 }
Ejemplo n.º 7
0
 public static void SendMoveToPacket <T>(Unit movingUnit, int speed,
                                         MonsterMoveFlags moveFlags, LinkedListNode <T> firstNode)
     where T : IPathVertex
 {
     if (!movingUnit.IsAreaActive)
     {
         return;
     }
     using (var packet = ConstructMultiWaypointMovePacket(movingUnit, speed, moveFlags, firstNode))
     {
         movingUnit.SendPacketToArea(packet, true, false);
     }
 }
Ejemplo n.º 8
0
 public static void SendMoveToPacket <T>(Unit movingUnit, uint moveTime,
                                         MonsterMoveFlags moveFlags, IEnumerable <T> waypoints)
     where T : IPathVertex
 {
     if (!movingUnit.IsAreaActive)
     {
         return;
     }
     using (var packet = ConstructMultiWaypointMovePacket(movingUnit, moveTime, moveFlags, waypoints))
     {
         movingUnit.SendPacketToArea(packet, true, false);
     }
 }
Ejemplo n.º 9
0
        public static RealmPacketOut ConstructMultiWaypointMovePacket <T>(Unit movingUnit, uint moveTime,
                                                                          MonsterMoveFlags moveFlags, IEnumerable <T> waypoints) where T : IPathVertex
        {
            int            num    = waypoints.Count <T>();
            RealmPacketOut writer =
                new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_MONSTER_MOVE, 38 + num * 4 * 3);

            movingUnit.EntityId.WritePacked((BinaryWriter)writer);
            writer.Write(false);
            writer.Write(movingUnit.Position);
            writer.Write(Utility.GetSystemTime());
            writer.Write((byte)0);
            writer.Write((uint)moveFlags);
            if (moveFlags.HasFlag((Enum)MonsterMoveFlags.Flag_0x200000))
            {
                writer.Write((byte)0);
                writer.Write(0);
            }

            writer.Write(moveTime);
            if (moveFlags.HasFlag((Enum)MonsterMoveFlags.Flag_0x800))
            {
                writer.Write(0.0f);
                writer.Write(0);
            }

            writer.Write(num);
            if (moveFlags.HasAnyFlag(MonsterMoveFlags.Flag_0x2000_FullPoints_1 |
                                     MonsterMoveFlags.Flag_0x40000_FullPoints_2))
            {
                foreach (T waypoint in waypoints)
                {
                    IPathVertex pathVertex = (IPathVertex)waypoint;
                    writer.Write(pathVertex.Position);
                }
            }
            else
            {
                foreach (T waypoint in waypoints)
                {
                    IPathVertex pathVertex = (IPathVertex)waypoint;
                    writer.Write(pathVertex.Position.ToDeltaPacked(movingUnit.Position, waypoints.First <T>().Position));
                }
            }

            return(writer);
        }
Ejemplo n.º 10
0
 public static bool HasAnyFlag(this MonsterMoveFlags flags, MonsterMoveFlags otherFlags)
 {
     return((flags & otherFlags) != MonsterMoveFlags.None);
 }
Ejemplo n.º 11
0
		public static bool HasAnyFlag(this MonsterMoveFlags flags, MonsterMoveFlags otherFlags)
		{
			return (flags & otherFlags) != 0;
		}
Ejemplo n.º 12
0
        /// <summary>
        /// Constructs a waypoint packet, starting with the given firstNode (until the end of the LinkedList).
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="unit"></param>
        /// <param name="speed">The speed that the Unit should move with in yards/second</param>
        /// <param name="moveFlags"></param>
        /// <param name="firstNode"></param>
        /// <returns></returns>
        public static RealmPacketOut ConstructMultiWaypointMovePacket <T>(Unit unit,
                                                                          int speed,
                                                                          MonsterMoveFlags moveFlags,
                                                                          LinkedListNode <T> firstNode)

            where T : IPathVertex
        {
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MONSTER_MOVE,
                                            (9 + 1 + 12 + 4 + 1 + 4 + 4 + 4 + (firstNode.List.Count * 4 * 3)));

            unit.EntityId.WritePacked(packet); // 8

            packet.Write(false);               // unknown flag

            packet.Write(unit.Position);
            packet.Write(Utility.GetSystemTime());
            packet.Write((byte)MonsterMoveType.Normal);
            packet.Write((uint)moveFlags);

            if (moveFlags.HasFlag(MonsterMoveFlags.Flag_0x200000))
            {
                packet.Write((byte)0);
                packet.Write(0);
            }

            var timePos = packet.Position;

            packet.Position += 4;

            if (moveFlags.HasFlag(MonsterMoveFlags.Flag_0x800))
            {
                packet.Write(0.0f);
                packet.Write(0);
            }

            var countPos = packet.Position;

            packet.Position += 4;

            var moveTime = (int)(1000 * unit.Position.GetDistance(firstNode.Value.Position) / speed);
            var count    = 0;
            var current  = firstNode;

            while (true)
            {
                count++;
                packet.Write(current.Value.Position);                // + 12*numWaypoints
                var next = current.Next;
                if (next != null)
                {
                    moveTime += (int)(1000 * current.Value.GetDistanceToNext() / speed);
                    current   = next;
                }
                else
                {
                    break;
                }
            }

            packet.Position = timePos;
            packet.Write(moveTime);
            packet.Position = countPos;
            packet.Write(count);
            return(packet);
        }
Ejemplo n.º 13
0
        public static RealmPacketOut ConstructMultiWaypointMovePacket <T>(Unit movingUnit, uint moveTime,
                                                                          MonsterMoveFlags moveFlags, IEnumerable <T> waypoints)
            where T : IPathVertex
        {
            var numWaypoints = waypoints.Count();
            var packet       = new RealmPacketOut(RealmServerOpCode.SMSG_MONSTER_MOVE,
                                                  (9 + 12 + 4 + 1 + 4 + 4 + 4 + (numWaypoints * 4 * 3)));


            movingUnit.EntityId.WritePacked(packet);
            //if (movingUnit.IsOnTransport)
            //{
            //  packet.OpCode = RealmServerOpCode.SMSG_MONSTER_MOVE_TRANSPORT;
            //  movingUnit.Transport.EntityId.WritePacked(packet);
            //  packet.Write((byte)movingUnit.TransportSeat);
            //}
            packet.Write(false);               // some boolean flag

            packet.Write(movingUnit.Position); // OnMonsterMove_serverLoc
            packet.Write(Utility.GetSystemTime());

            const MonsterMoveType moveType = MonsterMoveType.Normal;

            packet.Write((byte)moveType);
            switch (moveType)
            {
            case MonsterMoveType.Normal:
                break;
                // TODO: implement other cases
                //case MonsterMoveType.Stop:
                //    {
                //        return packet;
                //    }
                //case MonsterMoveType.FinalFacingPoint:
                //    {
                //        // OnMonsterMove_final_facingSpot
                //        packet.Write(0.0f);
                //        packet.Write(0.0f);
                //        packet.Write(0.0f);
                //    }
                //case MonsterMoveType.FinalFacingGuid:
                //    {
                //        packet.Write(0ul);
                //    }
                //case MonsterMoveType.FinalFacingAngle:
                //    {
                //        // OnMonsterMove_final_facingAngle
                //        packet.Write(movingUnit.Orientation);
                //    }
            }

            packet.Write((uint)moveFlags);
            if (moveFlags.HasFlag(MonsterMoveFlags.Flag_0x200000))
            {
                // TODO: what does this flag mean?
                packet.Write((byte)0);
                packet.Write(0);
            }

            packet.Write(moveTime);

            if (moveFlags.HasFlag(MonsterMoveFlags.Flag_0x800))
            {
                // TODO: what does this flag mean?
                packet.Write(0.0f);
                packet.Write(0);
            }

            packet.Write(numWaypoints);

            if (moveFlags.HasAnyFlag(MonsterMoveFlags.Flag_0x2000_FullPoints_1 | MonsterMoveFlags.Flag_0x40000_FullPoints_2))
            {
                foreach (IPathVertex waypoint in waypoints)
                {
                    packet.Write(waypoint.Position);                     // + 12*numWaypoints
                }
            }
            else
            {
                // OnMonsterMove_pathPoints_compressed
                foreach (IPathVertex waypoint in waypoints)
                {
                    packet.Write(waypoint.Position.ToDeltaPacked(movingUnit.Position, waypoints.First().Position));                     // + 12*numWaypoints
                }
            }

            return(packet);
        }
Ejemplo n.º 14
0
        public static void SendMoveToPacket(Unit movingUnit, ref Vector3 pos, float orientation, uint moveTime, MonsterMoveFlags moveFlags)
        {
            if (!movingUnit.IsAreaActive && movingUnit.CharacterMaster == null)
            {
                return;
            }

            /*//log.Debug("Monster Move: O={0}, Time={1}, Flags={2}, Pos={3}", orientation, moveTime, moveFlags, pos);
             * using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MONSTER_MOVE, 53))
             * {
             *      movingUnit.EntityId.WritePacked(packet);			// 8
             *      packet.Write((byte)0);
             *      packet.Write(movingUnit.Position);	// + 12 = 20
             *      packet.Write(Utility.GetSystemTime());			// + 4 = 24
             *      if (orientation != 0.0f)
             *      {
             *              packet.Write((byte)MonsterMoveType.FinalFacingAngle);							// + 1 = 25
             *              packet.Write(orientation);					// + 4 = 29
             *      }
             *      else
             *      {
             *              packet.Write((byte)MonsterMoveType.Normal);							// + 1 = 25
             *      }
             *
             *      packet.Write((uint)moveFlags);					// + 4 = 33
             *      packet.Write(moveTime);							// + 4 = 37
             *      packet.Write(1);								// + 4 = 41
             *      packet.Write(pos);							// + 12 = 53
             *
             *      movingUnit.SendPacketToArea(packet, true);
             * }*/
        }
Ejemplo n.º 15
0
 public static bool Has(this MonsterMoveFlags flags, MonsterMoveFlags toCheck)
 {
     return (flags & toCheck) != 0;
 }