예제 #1
0
        /// <summary>
        ///	Moves to a Waypoint until within distance
        /// </summary>
        /// <param name="distance">stop/return if within distance</param>
        /// <param name="stoprunning">before exiting, stop running</param>
        /// <param name="stopondamage">stop running when the player is damaged</param>
        public void MoveTo(float distance, bool stoprunning, bool stopondamage)
        {
            if (_ak.ZDistance(_ak.gPlayerXCoord, _ak.gPlayerYCoord, _ak.gPlayerZCoord, _mX, _mY, _mZ) > distance)
            {
                _ak.StartRunning();
            }
            int lasthealth = _ak.PlayerHealth;

            while (_ak.ZDistance(_ak.gPlayerXCoord, _ak.gPlayerYCoord, _ak.gPlayerZCoord, _mX, _mY, _mZ) > distance)
            {
                if (stopondamage && _ak.PlayerHealth < lasthealth)
                {
                    _ak.StopRunning();
                    return;
                }
                lasthealth = _ak.PlayerHealth;

                //on slow machines (mine!) turnToHeading this often is bad, so lets only turn if we
                // are really facing the wrong way - more than 15 degrees off of correct heading
                if (Math.Abs(_ak.FindHeading(_ak.gPlayerXCoord, _ak.gPlayerYCoord, _mX, _mY) - _ak.PlayerDir) > 5)
                {
                    _ak.TurnToHeading(_ak.FindHeading(_ak.gPlayerXCoord, _ak.gPlayerYCoord, _mX, _mY));
                }

                //Give the game process a chance at the cpu so it can respond
                System.Threading.Thread.Sleep(150);
            }

            if (stoprunning)
            {
                _ak.StopRunning();
            }
        }
예제 #2
0
파일: fmrMain.cs 프로젝트: dbeattie71/ak
        private void btnStop_Click(object sender, System.EventArgs e)
        {
            btnRest.Enabled          = false;
            btnPatrolArea.Enabled    = false;
            btnTravelPath.Enabled    = false;
            btnTravel.Enabled        = false;
            btnClassSettings.Enabled = false;
            btnFlee.Enabled          = false;
            btnDistances.Enabled     = false;
            btnLoot.Enabled          = false;

            bRunning = false;

            //just in case
            _ak.StopRunning();

            if (_botbase != null)
            {
                //pause the bot
                _botbase.bPaused = true;

                switch (_profile.GetString("Class"))
                {
                case "Necro":
//						_chatlogparser.LogLine -= new LogLineDelegate(((WoW_Rogue)_botbase).OnChatLogLine);
                    break;

                case "Scout":
//						_chatlogparser.LogLine -= new LogLineDelegate(((WoW_Warrior)_botbase).ParseChatLogLine);
                    break;
                }
            }

            // Remove the botbase
            _botbase = null;

            // Unregister Remote Chat
            //moved to dispose
            //_chatlogparser.LogLine -= new LogLineDelegate(_frmRemoteChat.ParseChatLogLine);

            if (_ak.GameProcess > 0)
            {
                _ak.StopInit();
            }

            btnInitialize.Enabled = true;
            btnStart.Enabled      = false;
            btnStop.Enabled       = false;
            btnPause.Enabled      = false;

            notifyIconMenuItem1.Enabled = false;
            notifyIconMenuItem2.Enabled = false;
            notifyIconMenuItem3.Enabled = true;
            notifyIconMenuItem1.Text    = "Start";

            this.notifyIconTimer.Stop();
        }
예제 #3
0
파일: frmTravel.cs 프로젝트: dbeattie71/ak
        /// <summary>
        /// Thread for actual moving
        /// </summary>
        public void Movement()
        {
            MovementDirection bForward = MovementDirection.Forward;

            if (_bKeepRunning)
            {
                //dont let the user change where we are going while we run
                cbxDestinations.Enabled = false;
                cbxPatrolAreas.Enabled  = false;

                PatrolArea patrolarea;
                try
                {
                    patrolarea = _patrolareas.GetPatrolArea(cbxPatrolAreas.SelectedItem.ToString());
                }
                catch (Exception E)
                {
                    MessageBox.Show(E.Message, "Load Area Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                //clear display of last time we ran
                lvwDisplay.Items.Clear();

                //determine direction
                bForward = FindDirection();

                //set patrolareas direction
                patrolarea.Direction = bForward;

                //find closest and set waypoint internal iterator to next waypoint in the correct direction
                //this also sets the waypoint internal direction setting
                Waypoint wpt = patrolarea.FindClosest(bForward);

                //get the next waypoint in the correct direction
                wpt = patrolarea.GetNextWaypoint();

                //run through all the waypoints
                while (wpt != null && _bKeepRunning && _ak.GameProcess != 0)
                {
                    //update the display
                    ListViewItem lvi = new ListViewItem(wpt.Name, 0);
                    lvi.SubItems.Add(wpt.X.ToString() + ", " + wpt.Y.ToString());
                    lvi.SubItems.Add(_ak.ZDistance(_ak.gPlayerXCoord, _ak.gPlayerYCoord, _ak.gPlayerZCoord, wpt.X, wpt.Y, wpt.Z).ToString("N"));
                    lvwDisplay.Items.Add(lvi);
                    lvwDisplay.EnsureVisible(lvwDisplay.Items.Count - 1);

                    wpt.MoveTo(250, false, cbxStopOnDamage.Checked);

                    //have we gotten to the selected destination?
                    if (cbxDestinations.SelectedIndex != -1 && wpt.Name == cbxDestinations.SelectedItem.ToString())
                    {
                        break;
                    }

                    //get the next waypoint in the correct direction
                    wpt = patrolarea.GetNextWaypoint();
                }

                _ak.StopRunning();

                string status = "Reached Destination";
                if (!_bKeepRunning)
                {
                    status = "Stopped";
                }
                ListViewItem doneLVI = new ListViewItem(status, 0);
                lvwDisplay.Items.Add(doneLVI);
                lvwDisplay.EnsureVisible(lvwDisplay.Items.Count - 1);

                _bKeepRunning = false;

                //done running, let them change destinations again
                cbxDestinations.Enabled = true;
                cbxPatrolAreas.Enabled  = true;
            }
        }