예제 #1
0
        private void btnGetTarget_Click(object sender, System.EventArgs e)
        {
            if (cbxPatrolAreas.SelectedIndex == -1)
            {
                MessageBox.Show("Please select the Patrol Area first.", "Add Target Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (_ak.TargetObject == null)
            {
                MessageBox.Show("Target something in the game first.", "Add Target Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string targetName = _ak.TargetObject.Name;

            PatrolArea patrolarea = _patrolareas.GetPatrolArea(cbxPatrolAreas.SelectedItem.ToString());

            lbxTargets.Items.Add(targetName);
            patrolarea.AddTarget(targetName);
        }
예제 #2
0
        private void btnTargetDelete_Click(object sender, System.EventArgs e)
        {
            if (cbxPatrolAreas.SelectedIndex == -1)
            {
                MessageBox.Show("Please select the Patrol Area first.", "Add Target Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            PatrolArea patrolarea = _patrolareas.GetPatrolArea(cbxPatrolAreas.SelectedItem.ToString());

            //remove the highlighted items
            while (lbxTargets.SelectedIndices.Count > 0)
            {
                lbxTargets.Items.RemoveAt(lbxTargets.SelectedIndices[0]);
            }

            //rebuild our patrolarea targets array
            patrolarea.ClearTargets();
            foreach (string target in lbxTargets.Items)
            {
                patrolarea.AddTarget(target);
            }
        }
예제 #3
0
        /// <summary>
        /// Saves all PatrolAreas
        /// </summary>
        /// <remarks>
        /// PatrolAreas are stored at:
        /// [ExecutablePath]\PatrolAreas\[PatrolArea].xml
        /// </remarks>
        public void SavePatrolAreas( )
        {
            string directory = Path.GetDirectoryName(Application.ExecutablePath);

            if (!directory.EndsWith("\\"))
            {
                directory += "\\";
            }
            directory += "PatrolAreas";

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            lock (_mPatrolAreas.SyncRoot)
            {
                foreach (string patrolareaname in _mPatrolAreas.Keys)
                {
                    String fileName = directory + "\\" + patrolareaname + ".xml";

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml("<PatrolAreas/>");

                    // Create the element
                    XmlNode patrolareaNode = doc.CreateElement("PatrolArea");

                    //add the PatrolArea name
                    XmlAttribute attr = doc.CreateAttribute("Name");
                    attr.Value = patrolareaname;
                    patrolareaNode.Attributes.Append(attr);

                    // Let the PatrolArea save
                    PatrolArea patrolarea = GetPatrolArea(patrolareaname);
                    patrolarea.SaveYourself(doc, patrolareaNode);

                    //append to the xml doc
                    doc.DocumentElement.AppendChild(patrolareaNode);

                    // Let each Waypoint save
                    ArrayList waypoints = patrolarea.GetAllWaypoints;

                    // Remember to lock on the SyncRoot before enumeration.
                    lock (waypoints.SyncRoot)
                    {
                        foreach (Waypoint wpt in waypoints)
                        {
                            // Create the element
                            XmlNode waypointNode = doc.CreateElement("Waypoint");

                            // Let the Waypoint save
                            wpt.SaveYourself(doc, waypointNode);

                            //append to the xml doc
                            patrolareaNode.AppendChild(waypointNode);
                        }
                    }

                    //save it
                    doc.Save(fileName);
                }
            }
        }
예제 #4
0
        public override void DoInitialize()
        {
            AddMessage("Our thread priority is " + Thread.CurrentThread.Priority.ToString());
            //argh, we need to make sure patrol area has a valid GetCurrentTarget, and if
            //we arent going to use SetClosest then we need to do this the long way
            //sets patrolarea internal iterator so it wont throw an exception
            //the next time we try and move
            PatrolArea patrolarea = GetPatrolArea();

            patrolarea.FindClosest(MovementDirection.Forward);


            //to avoid answering questions too often, lets make sure the user
            //has set things up correctly.
            string msg = "";

            if (profile.GetString("PatrolArea") == "")
            {
                msg += "You do not have a Patrol Area selected.\n";
            }
            if (patrolarea != null && patrolarea.NumWaypoints == 0)
            {
                msg += "You do not have any waypoints in your selected Patrol Area\n";
            }
            if (
                profile.GetString("Scout.FightRangedBowQ") == "" ||
                profile.GetString("Scout.FightRangedBowKey") == "" ||
                profile.GetString("Scout.SlashNormalQ") == "" ||
                profile.GetString("Scout.SlashNormalKey") == "" ||
                profile.GetString("Scout.FightMeleeWeaponQ") == "" ||
                profile.GetString("Scout.FightMeleeWeaponKey") == ""
                )
            {
                msg += "You must set up your fight keys before fighting.\n";
            }

            if (msg != "")
            {
                msg += "\nFix these problems and press Resume";
                MessageBox.Show(msg);
                bPaused = true;
                return;
            }

            Interaction.AppActivate(_ak.GameProcess);


            AddMessage("Starting bot");

            Thread.Sleep(1000);

            //Are we dead?
            if (_ak.IsPlayerDead)
            {
                Action = BotAction.DiedReleaseAndRun;
                return;
            }

            Action = BotAction.CheckAgro;
            ActionQueue.Enqueue(BotAction.Rest);
            ActionQueue.Enqueue(BotAction.FindTarget);
        }
예제 #5
0
파일: DAoCNecro.cs 프로젝트: dbeattie71/ak
        public override void DoInitialize()
        {
            AddMessage("Our thread priority is " + Thread.CurrentThread.Priority.ToString());
            //argh, we need to make sure patrol area has a valid GetCurrentTarget, and if
            //we arent going to use SetClosest then we need to do this the long way
            //sets patrolarea internal iterator so it wont throw an exception
            //the next time we try and move
            PatrolArea patrolarea = GetPatrolArea();

            patrolarea.FindClosest(MovementDirection.Forward);


            //to avoid answering questions too often, lets make sure the user
            //has set things up correctly.
            string msg = "";

            if (profile.GetString("PatrolArea") == "")
            {
                msg += "You do not have a Patrol Area selected.\n";
            }
            if (patrolarea != null && patrolarea.NumWaypoints == 0)
            {
                msg += "You do not have any waypoints in your selected Patrol Area\n";
            }
            if (
                profile.GetString("Necro.FightRangedLTQ") == "" ||
                profile.GetString("Necro.FightRangedLTKey") == "" ||
                profile.GetString("Necro.FightRangedPTQ") == "" ||
                profile.GetString("Necro.FightRangedPTKey") == "" ||
                profile.GetString("Necro.FightMeleePTQ") == "" ||
                profile.GetString("Necro.FightMeleePTKey") == "" ||
                profile.GetString("Necro.FightFPQ") == "" ||
                profile.GetString("Necro.FightFPKey") == ""
                )
            {
                msg += "You must set up your fight spell keys before fighting.\n";
            }

            if (msg != "")
            {
                msg += "\nFix these problems and press Resume";
                MessageBox.Show(msg);
                bPaused = true;
                return;
            }

            Interaction.AppActivate(_ak.GameProcess);


            AddMessage("Starting bot");

            Thread.Sleep(1000);

            //Are we dead?
            if (_ak.IsPlayerDead)
            {
                Action = BotAction.DiedReleaseAndRun;
                return;
            }


            if (petID < 1 || !_ak.get_DoesObjectExist(petID))
            {
                CastPet();
                //we want to do this in a new thread so it can sleep without sleeping
                //the code the delegate that waits for the pet packet.  It didnt work
                //most of the time if it was in the same thread
//				System.Threading.Thread tPet = new Thread(new ThreadStart(CastPet));
//				tPet.Start();				//start the castPet thread
//				tPet.Priority = ThreadPriority.BelowNormal;
//				Thread.Sleep(0);			//yield so the thread really starts
//				tPet.Join();				//wait for that thread to finish
            }
            Action = BotAction.CheckAgro;
            ActionQueue.Enqueue(BotAction.Protect);
            ActionQueue.Enqueue(BotAction.CheckBuffs);
            ActionQueue.Enqueue(BotAction.Rest);
            ActionQueue.Enqueue(BotAction.FindTarget);
        }