示例#1
0
 private bool MoveToCell(int cellId)
 {
     if (cellId != Fighter.CellId)
     {
         if (!(IsCellWalkable(cellId)))
         {
             int      num       = -1;
             int      num2      = 5000;
             MapPoint point     = new MapPoint(Fighter.CellId);
             MapPoint point2    = new MapPoint(cellId);
             int      direction = 1;
             while (true)
             {
                 MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1);
                 if (IsCellWalkable(nearestCellInDirection.CellId))
                 {
                     int num4 = point.DistanceToCell(nearestCellInDirection);
                     if (num4 < num2)
                     {
                         num2 = num4;
                         num  = nearestCellInDirection.CellId;
                     }
                 }
                 direction = (direction + 2);
                 if (direction > 7)
                 {
                     if (num == -1)
                     {
                         return(false);
                     }
                     cellId = num;
                     break;
                 }
             }
         }
         SimplePathfinder pathfinder = new SimplePathfinder((BlueSheep.Data.D2p.Map)m_Account.Map.Data);
         pathfinder.SetFight(Fighters, Fighter.MovementPoints);
         MovementPath path = pathfinder.FindPath(Fighter.CellId, cellId);
         if (path != null)
         {
             List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
             //Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.ToList().Select<uint, short>(ui => (short)ui).ToArray(), Account.Game.Map.Id));
             using (BigEndianWriter writer = new BigEndianWriter())
             {
                 GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.ToList().Select <uint, short>(ui => (short)ui).ToArray(), m_Account.Map.Id);
                 msg.Serialize(writer);
                 writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                 MessagePackaging pack = new MessagePackaging(writer);
                 pack.Pack((int)msg.ProtocolID);
                 m_Account.SocketManager.Send(pack.Writer.Content);
                 if (m_Account.DebugMode.Checked)
                 {
                     m_Account.Log(new BotTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                 }
             }
             return(true);
         }
     }
     return(false);
 }
示例#2
0
        public bool MoveToCellWithDistance(int cellId, int maxDistance, bool bool1)
        {
            m_Account.SetStatus(Status.Moving);
            MovementPath path           = null;
            int          savDistance    = -1;
            MapPoint     characterPoint = new MapPoint(Character.CellId);
            MapPoint     targetPoint    = new MapPoint(cellId);

            foreach (MapPoint point in GetListPointAtGoodDistance(characterPoint, targetPoint, maxDistance))
            {
                Pathfinder pathFinding = null;
                if ((targetPoint.DistanceToCell(point) > maxDistance) || ((targetPoint.X != point.X) && (targetPoint.Y != point.Y)))
                {
                    continue;
                }
                int distance = characterPoint.DistanceTo(point);
                if ((savDistance != -1) && (distance >= savDistance))
                {
                    continue;
                }
                if (bool1)
                {
                    if (Data.IsWalkable(point.CellId))
                    {
                        goto Label_00A8;
                    }
                    continue;
                }
                if (!(NothingOnCell(point.CellId)))
                {
                    continue;
                }
Label_00A8:
                pathFinding = new Pathfinder(m_Account.Map.Data, m_Account.Map);
                MovementPath path2 = pathFinding.FindPath(Character.CellId, point.CellId);
                if (path2 != null)
                {
                    path        = path2;
                    savDistance = distance;
                }
            }
            if (path == null)
            {
                return(false);
            }
            //if (AutoTimeout)
            //    m_Account.Game.Character.State.SetTimeout(StateEnum.Moving, false, TimeoutMin, TimeoutMax);
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
            int           timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 500;
            }
            else
            {
                timetowait = serverMovement.Count() * 300;
            }
            //m_Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.Select<uint, short>(ui => (short)ui).ToArray(), Id));
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select <uint, short>(ui => (short)ui).ToArray(), Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.ProtocolID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new BotTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }
            m_Account.Wait(timetowait, timetowait + 100);
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
                newmsg.Serialize(writer);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)newmsg.ProtocolID);
                if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup() && m_Account.Fight.followinggroup.m_cellId == cellId)
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                    m_Account.Fight.LaunchFight(m_Account.Fight.followinggroup.m_contextualId);
                    //m_Account.Wait(3000, 4000);
                    //if (m_Account.StatusLb.Text != "Combat")
                    //{
                    //    m_Account.Fight.SearchFight();
                    //}
                }
                else if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup())
                {
                    m_Account.Fight.SearchFight();
                }
                else if (m_Account.Gather.Id != -1)
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                    UseElement(m_Account.Gather.Id, m_Account.Gather.SkillInstanceUid);
                }
                else
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                }
                m_Account.SetStatus(Status.None);
            }
            return(true);
        }
示例#3
0
        public bool MoveToCellWithDistance(int cellId, int maxDistance, bool bool1)
        {
            MovementPath path           = null;
            int          savDistance    = -1;
            MapPoint     characterPoint = new MapPoint(m_Account.MapData.Character.Disposition.CellId);
            MapPoint     targetPoint    = new MapPoint(cellId);

            foreach (MapPoint point in m_Account.MapData.GetListPointAtGoodDistance(characterPoint, targetPoint, maxDistance))
            {
                Pathfinder pathFinding = null;
                if ((targetPoint.DistanceToCell(point) > maxDistance) || ((targetPoint.X != point.X) && (targetPoint.Y != point.Y)))
                {
                    continue;
                }
                int distance = characterPoint.DistanceTo(point);
                if ((savDistance != -1) && (distance >= savDistance))
                {
                    continue;
                }
                if (bool1)
                {
                    if (m_Account.MapData.Data.IsWalkable(point.CellId))
                    {
                        goto Label_00A8;
                    }
                    continue;
                }
                if (!(m_Account.MapData.NothingOnCell(point.CellId)))
                {
                    continue;
                }
Label_00A8:
                pathFinding = new Pathfinder(m_Account.MapData);
                MovementPath path2 = pathFinding.FindPath(m_Account.MapData.Character.Disposition.CellId, point.CellId);
                if (path2 != null)
                {
                    path        = path2;
                    savDistance = distance;
                }
            }
            if (path == null)
            {
                return(false);
            }
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);

            if (serverMovement[serverMovement.Count - 1] == m_Account.MapData.Character.Disposition.CellId)
            {
                Moving = false;
                ConfirmMove();
                return(true);
            }
            int timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 514;
            }
            else
            {
                timetowait = serverMovement.Count() * 320;
            }
            m_time = timetowait;
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select(ui => (short)ui).ToList(), m_Account.MapData.Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.MessageID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                m_Account.SetStatus(Status.Moving);
                Moving = true;
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new DebugTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }
            return(true);
        }
示例#4
0
        public bool MoveToCell(int cellId)
        {
            if (m_Account.state == Engine.Enums.Status.Fighting)
            {
                return(false);
            }
            m_Account.SetStatus(Status.Moving);
            MovementPath path = (new Pathfinder(m_Account.Map.Data, m_Account.Map)).FindPath(Character.CellId, cellId);

            if (path == null)
            {
                return(false);
            }
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
            int           timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 500;
            }
            else
            {
                timetowait = serverMovement.Count() * 300;
            }
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select <uint, short>(ui => (short)ui).ToArray(), Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.ProtocolID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new BotTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }
            m_Account.Wait(timetowait, timetowait + 100);
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
                newmsg.Serialize(writer);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)newmsg.ProtocolID);
                if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup())
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                    m_Account.Fight.LaunchFight(m_Account.Fight.followinggroup.m_contextualId);
                }
                else
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                }
                if (m_Account.Gather != null)
                {
                    m_Account.Gather.Moved = true;
                }
                m_Account.SetStatus(Status.None);
            }

            return(true);
        }
示例#5
0
        public bool MoveToCell(int cellId)
        {
            if (m_Account.state == Engine.Enums.Status.Fighting)
            {
                return(false);
            }
            m_Account.SetStatus(Status.Moving);
            MovementPath path = (new Pathfinder(m_Account.MapData)).FindPath(m_Account.MapData.Character.Disposition.CellId, cellId);

            if (path == null)
            {
                return(false);
            }
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);

            if (serverMovement[serverMovement.Count - 1] == m_Account.MapData.Character.Disposition.CellId)
            {
                Moving = false;
                ConfirmMove();
                return(true);
            }
            int timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 500;
            }
            else
            {
                timetowait = serverMovement.Count() * 300;
            }
            m_time = timetowait;
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select(ui => (short)ui).ToList(), m_Account.MapData.Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.MessageID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                Moving = true;
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new DebugTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }

            //m_Account.Wait(timetowait, timetowait + 100);
            //using (BigEndianWriter writer = new BigEndianWriter())
            //{
            //    GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
            //    newmsg.Serialize(writer);
            //    MessagePackaging pack = new MessagePackaging(writer);
            //    pack.Pack((int)newmsg.ProtocolID);
            //    if (m_Account.Fight != null && m_Account.FightData.IsFollowingGroup && m_Account.FightData.followingGroup.m_cellId == cellId)
            //    {
            //        m_Account.SocketManager.Send(pack.Writer.Content);
            //        if (m_Account.DebugMode.Checked)
            //            m_Account.Log(new DebugTextInformation("[SND] 952 (GameMapMovementConfirmMessage)"), 0);
            //        m_Account.Fight.LaunchFight(m_Account.FightData.followingGroup.m_contextualId);
            //        Thread t = new Thread(new ThreadStart(CheckFight));
            //        t.Start();
            //    }
            //    else if (m_Account.Fight != null && m_Account.FightData.IsFollowingGroup)
            //    {
            //        m_Account.Fight.SearchFight();
            //    }
            //    else if (m_Account.Gather.Id != -1)
            //    {
            //        m_Account.SocketManager.Send(pack.Writer.Content);
            //        if (m_Account.DebugMode.Checked)
            //            m_Account.Log(new DebugTextInformation("[SND] 952 (GameMapMovementConfirmMessage)"), 0);
            //        //UseElement(m_Account.Gather.Id, m_Account.Gather.SkillInstanceUid);
            //        int distance = m_Account.Gather.GetRessourceDistance(m_Account.Gather.Id);
            //        m_Account.Log(new DebugTextInformation("[Gather] New distance from element " + m_Account.Gather.Id + " = " + distance), 0);
            //        if (distance <= m_Account.Inventory.WeaponRange)
            //        {
            //            UseElement(m_Account.Gather.Id, m_Account.Gather.SkillInstanceUid);
            //            m_Account.SetStatus(Status.Gathering);
            //        }
            //        else if (m_Account.Path != null)
            //            m_Account.Path.PerformFlag();
            //        else
            //            m_Account.PerformGather();
            //    }
            //    else
            //    {
            //        m_Account.SocketManager.Send(pack.Writer.Content);
            //        if (m_Account.DebugMode.Checked)
            //            m_Account.Log(new DebugTextInformation("[SND] 952 (GameMapMovementConfirmMessage)"), 0);
            //    }
            //    m_Account.SetStatus(Status.None);
            //}

            return(true);
        }