コード例 #1
0
        //////////////////////////////////////////////////////////////////////
        // mlteleportto(x, y, walkcallflag)
        // -------------------------------------------------------------------
        // teleports to the given coordinates
        // returns: true on success, false on failure
        // requires mlMapInitializeMap: NO
        //////////////////////////////////////////////////////////////////////
        private int TeleportToXY(System.Drawing.Point c, int Currentpoint)         //current point is used internally
        {
            PC  Me      = new PC();
            int TargetX = c.X;
            int TargetY = c.Y;

            for (int rv = 0; rv < 3; rv++)
            {
                MoverEventArgs mve = new MoverEventArgs(c, Currentpoint, this);

                RaiseMoverCallBackHandler(mve);

                if (mve.Stop)
                {
                    return(-1);
                }

                Mover.CastAtXY(SkillType.Teleport, SkillHand.Right, TargetX, TargetY);
                // Check to see see if we have arrived at our destination
                if ((Math.Abs(Me.X - TargetX) < 6) && (Math.Abs(Me.Y - TargetY) < 6))
                {
                    return(1);
                }
            }


            if ((Math.Abs(Me.X - TargetX) < 6) && (Math.Abs(Me.Y - TargetY) < 6))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
コード例 #2
0
 public void RaiseMoverCallBackHandler(MoverEventArgs e)
 {
     try
     {
         OnMoverCallBack(e);
     }
     catch
     {
     }
 }
コード例 #3
0
        //////////////////////////////////////////////////////////////////////
        // mlwalkto(x, y, walkcallflag)
        // -------------------------------------------------------------------
        // walks to the given coordinates
        // returns: true on success, false on failure
        // requires mlMapInitializeMap: NO
        //////////////////////////////////////////////////////////////////////
        private int WalkToXY(System.Drawing.Point c, int currpoint)         //currentpoint is for internal use only
        {
            PC  Me      = new PC();
            int TargetX = c.X;
            int TargetY = c.Y;

            int startX    = Me.X;
            int startY    = Me.Y;
            int currDestX = TargetX;
            int currDestY = TargetY;

            if (Math.Abs(Me.X - TargetX) <= 2 && Math.Abs(Me.Y - TargetY) <= 2)
            {
                return(1);
            }

            int    trys    = 0;
            int    ntrys   = 12;
            int    thrash  = 0;
            int    nthrash = 3;
            int    door;
            int    directionalmove = 0;
            double direction       = 0;

            while ((Math.Abs(Me.X - TargetX) > 3 || Math.Abs(Me.Y - TargetY) > 3) && trys <= ntrys)
            {
                Me.ClickMap(ClickType.LeftDown, false, currDestX, currDestY);
                Thread.Sleep(100);
                Me.ClickMap(ClickType.LeftUp, false, currDestX, currDestY);

                MoverEventArgs mve = new MoverEventArgs(c, currpoint, this);

                RaiseMoverCallBackHandler(mve);

                if (mve.Stop)
                {
                    return(-1);
                }

                while (Me.Mode != PlayerMode.Neutral && Me.Mode != PlayerMode.TownNeutral)
                {
                    Thread.Sleep(20);
                }
                trys++;
                if ((Math.Abs(Me.X - TargetX) > 1 && Math.Abs(Me.Y - TargetX) > 1))
                {
                    if (thrash >= nthrash)
                    {
                        direction = Math.Abs(Math.Floor((Math.Atan2(TargetX - Me.X, TargetY - Me.Y)) * 180 / 3.1415) - 180);
                        if (direction > 0 && direction < 45)
                        {
                            currDestX = Me.X + 5;
                            currDestY = Me.Y + 1;
                        }
                        else if (direction > 45 && direction < 90)
                        {
                            currDestX = Me.X - 1;
                            currDestY = Me.Y - 5;
                        }
                        else if (direction > 90 && direction < 135)
                        {
                            currDestX = Me.X - 1;
                            currDestY = Me.Y + 5;
                        }
                        else if (direction > 135 && direction < 180)
                        {
                            currDestX = Me.X + 5;
                            currDestY = Me.Y - 1;
                        }
                        else if (direction > 180 && direction < 225)
                        {
                            currDestX = Me.X - 5;
                            currDestY = Me.Y - 1;
                        }
                        else if (direction > 225 && direction < 270)
                        {
                            currDestX = Me.X + 1;
                            currDestY = Me.Y + 5;
                        }
                        else if (direction > 270 && direction < 315)
                        {
                            currDestX = Me.X + 1;
                            currDestY = Me.Y - 5;
                        }
                        else if (direction > 315 && direction < 360)
                        {
                            currDestX = Me.X - 5;
                            currDestY = Me.Y + 1;
                        }
                        else
                        {
                            //make a randome move
                            int    dx = currDestX - startX;
                            int    dy = currDestY - startY;
                            double a  = Math.Atan2(dx, dy);
                            a         = Math.Floor(a * 100) + 157;                       // + pi/2;
                            direction = (new Random()).Next((int)a, (int)a + 314) / 100; // + pi
                            currDestX = Convert.ToInt32(Math.Floor(Math.Sin(direction) * 20) + Me.X);
                            currDestY = Convert.ToInt32(Math.Floor(Math.Cos(direction) * 20) + Me.Y);
                        }
                        directionalmove = 0;

                        //########################################
                        thrash = 0;
                        directionalmove++;
                    }
                    else
                    {
                        thrash++;
                    }
                }
                else
                {
                    startX    = Me.X;
                    startY    = Me.Y;
                    currDestX = TargetX;
                    currDestY = TargetY;
                }
            }
            if (Math.Abs(Me.X - TargetX) > 4 || Math.Abs(Me.Y - TargetY) > 4)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }