Esempio n. 1
0
        /// <summary>
        /// Send information about an external dependency call in the application, such as a web-service call
        /// </summary>
        /// <param name="dependencyTypeName">External dependency type.</param>
        /// <param name="target">External dependency target.</param>
        /// <param name="dependencyName">External dependency name.</param>
        /// <param name="data">Dependency call command name.</param>
        /// <param name="startTime">The time when the dependency was called.</param>
        /// <param name="duration">The time taken by the external dependency to handle the call.</param>
        /// <param name="resultCode">Result code of dependency call execution.</param>
        /// <param name="wasSuccessfull">True if the dependency call was handled successfully.</param>
        /// <param name="properties">Named string values you can use to search and classify events.</param>
        public virtual void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool wasSuccessfull, IDictionary <string, string> properties = null)
        {
            var dependencyTelemetry = new DependencyTelemetry(dependencyTypeName, target, dependencyName, data, startTime, duration, resultCode, wasSuccessfull);

            if (properties != null)
            {
                foreach (KeyValuePair <string, string> pair in properties)
                {
                    dependencyTelemetry.Properties.Add(pair);
                }
            }
            string correlationId = SetCorrelationId(dependencyTelemetry.Properties);

            if (EnableThreadedOperations)
            {
                ActionQueue.Enqueue(() =>
                {
                    TelemetryClient.Context.Operation.Id = correlationId;
                    ActionQueue.Enqueue(() => TelemetryClient.TrackDependency(dependencyTelemetry));
                });
            }
            else
            {
                TelemetryClient.TrackDependency(dependencyTelemetry);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Send information about an external dependency call in the application, such as a call to a database.
        /// </summary>
        /// <param name="dependencyName">External dependency name.</param>
        /// <param name="commandName">Dependency call command name.</param>
        /// <param name="startTime">The time when the dependency was called.</param>
        /// <param name="duration">The time taken by the external dependency to handle the call.</param>
        /// <param name="wasSuccessfull">True if the dependency call was handled successfully.</param>
        /// <param name="properties">Named string values you can use to search and classify events.</param>
        public virtual void TrackDependency(string dependencyName, string commandName, DateTimeOffset startTime, TimeSpan duration, bool wasSuccessfull, IDictionary <string, string> properties = null)
        {
#pragma warning disable 618
            var dependencyTelemetry = new DependencyTelemetry(dependencyName, commandName, startTime, duration, wasSuccessfull);
#pragma warning restore 618
            if (properties != null)
            {
                foreach (KeyValuePair <string, string> pair in properties)
                {
                    dependencyTelemetry.Properties.Add(pair);
                }
            }
            string correlationId = SetCorrelationId(dependencyTelemetry.Properties);
            if (EnableThreadedOperations)
            {
                ActionQueue.Enqueue(() =>
                {
                    TelemetryClient.Context.Operation.Id = correlationId;
                    ActionQueue.Enqueue(() => TelemetryClient.TrackDependency(dependencyName, commandName, startTime, duration, wasSuccessfull));
                });
            }
            else
            {
                TelemetryClient.TrackDependency(dependencyName, commandName, startTime, duration, wasSuccessfull);
            }
        }
Esempio n. 3
0
 protected virtual void OnRemoveAssetClick(int id)
 {
     ActionQueue.Enqueue(() => {
         GetDatabaseInstance().Remove(id);
         EditorGUI.FocusTextInControl(string.Empty);
     });
 }
Esempio n. 4
0
        private void MainLoop()
        {
            //启动循环,this.LoopActions数组在启动之后就不再更改,所以EventManager模块应最后启动
            var _loopActions = new List <PtiLoopEvent>();

            _loopActions.AddRange(this.LoopActions);
            DateTime now = DateTime.Now;

            while (!StopLoopMark)
            {
                #region 全局Loop模块任务
                now = DateTime.Now;
                foreach (var loopAction in _loopActions)
                {
                    if (now >= loopAction.NextRunDate)
                    {
                        ActionQueue.Enqueue(loopAction.Action);
                        loopAction.NextRunDate = now.Add(loopAction.Interval);
                    }
                }
                #endregion

                PtiEventer act;
                while (ActionQueue.TryDequeue(out act))
                {
                    act.RunAndWait(this);
                }
                Thread.Sleep(100);
            }
            StopLoopMark = false;
            this.WriteInfo("Loop Thread Stopped");
        }
Esempio n. 5
0
        public void BasicWithLimitTest()
        {
            var accu = new IntAccumlator()
            {
                Value = 0
            };
            var queue = new ActionQueue <IntAccumlator>(accu);

            Assert.DoesNotThrow(() => Parallel.For(1, 101, x =>
            {
                var index = x;

                queue.Enqueue((acc, args) =>
                {
                    acc.Value += index;
                    Assert.AreEqual((int)args, 42);
                }, 42);
            }));

            var completed = queue.Perform(50);

            Assert.AreEqual(completed, 50);
            // There is no guarantee for the enqueue order

            completed = queue.Perform();

            Assert.AreEqual(completed, 50);
            Assert.AreEqual(accu.Value, 5050);
        }
        void chatHost_UserLeft(object sender, SessionEventArgs e)
        {
            if (e.SessionID != Id)
            {
                return;
            }

            eventQueue.Enqueue(() => OnUserLeft(e));
        }
        public void ExecuteService()
        {
            foreach (var profile in Profiles)
            {
                Thread           thread;
                ExpressionParser profileParser;
                if (profile.Enabled)
                {
                    profileParser = ExpressionParser.CreateParser();
                    profile.ActionToExecute.Parser = profileParser;
                    if (profile.EventTrigger == null)
                    {
                        profile.EventTrigger = new DefaultTrigger();
                    }

                    profile.EventTrigger.Parser = profileParser;
                    profile.EventTrigger.SetParameters();
                    if (profile.EventTrigger is IWindowsMessageTrigger)
                    {
                        IWindowsMessageTrigger wmt = (IWindowsMessageTrigger)profile.EventTrigger;
                        wmt.FormHandle = FormHandle;
                        RegisteredWinMessage.Add(wmt);
                    }

                    var prof = profile;
                    prof.EventTrigger.OnTriggerEvent += () =>
                    {
                        if (prof.StateTriggers.Count == 0 || prof.StateTriggers.All(st => st.IsStateActive))
                        {
                            prof.IsAllStateActive = true;
                            ActionQueue.Enqueue(prof.ActionToExecute);
                        }
                        else if (prof.EventTrigger is DefaultTrigger)
                        {
                            //executa ação de término do estado
                            if (prof.IsAllStateActive && prof.ActionOnExitState != null)
                            {
                                ActionQueue.Enqueue(prof.ActionOnExitState);
                            }
                            prof.IsAllStateActive = false;
                        }
                    };

                    profile.EventTrigger.Setup();

                    foreach (var trigger in profile.StateTriggers)
                    {
                        trigger.Parser = profileParser;
                        trigger.SetParameters();
                        thread = new Thread(trigger.ExecuteMonitor);
                        thread.Start();
                    }
                }
            }
            serviceThread = new Thread(ProcessActionQueue);
            serviceThread.ApartmentState = ApartmentState.STA;
            serviceThread.Start();
            IsServiceExecuting = true;
        }
Esempio n. 8
0
 public void Enqueue()
 {
     foreach (var action in _scratchActions)
     {
         ActionQueue.Enqueue(action);
     }
     _scratchActions.Clear();
 }
 void Update()
 {
     if (MiddleVRInput.GetButtonDown(0))
     {
         //FirePitch();
         ActionQueue.Enqueue(FirePitch);
     }
 }
Esempio n. 10
0
        public override void DoCheckFlee()
        {
            int numAttackers = GetAttackerCount();

            // Less then specified hp or mana plus 10%, and more then 1 attacker?
            if ((_ak.get_MobHealth(petID) < profile.GetInteger("FleeBelowHealth") + 10 ||
                 _ak.PlayerMana < profile.GetInteger("FleeBelowMana") + 10) &&
                numAttackers > 1)
            {
                // Yes? RUN FOREST RUN !
                // Should we leave the pet behind to die?
                if (profile.GetBool("Necro.FleeLeavePet"))
                {
                    AddMessage("Leave pet to die as we flee");
                    //switch quickbar and cast
                    UseQbar(profile.GetString("Necro.PetHereQ"), profile.GetString("Necro.PetHereKey"));
                }

                Action = BotAction.Flee;

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Rest);
                return;
            }

            //Just one attacker, and below health at which we should run away?
            if (_ak.get_MobHealth(petID) < profile.GetInteger("FleeBelowHealth") ||
                _ak.PlayerMana < profile.GetInteger("FleeBelowMana"))
            {
                // Our attacker has more HP then us?
                if (_ak.TargetIndex > 0 && _ak.get_MobHealth(petID) < _ak.TargetObject.Health)
                {
                    // Yes? RUN FOREST RUN !
                    // Should we leave the pet behind to die?
                    if (profile.GetBool("Necro.FleeLeavePet"))
                    {
                        AddMessage("Leave pet to die as we flee");
                        //switch quickbar and cast
                        UseQbar(profile.GetString("Necro.PetHereQ"), profile.GetString("Necro.PetHereKey"));
                    }

                    Action = BotAction.Flee;

                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.Rest);
                    return;
                }
            }

            // Check if we have a next action
            if (ActionQueue.Count == 0)
            {
                throw new Exception("No action in ActionQueue");
            }

            // Next Action
            Action = ActionQueue.Dequeue();
        }
Esempio n. 11
0
 /// <summary>
 /// Flushes the in-memory buffer, if one exists
 /// </summary>
 public virtual void Flush()
 {
     if (EnableThreadedOperations)
     {
         ActionQueue.Enqueue(() => TelemetryClient.Flush());
     }
     else
     {
         TelemetryClient.Flush();
     }
 }
Esempio n. 12
0
    public void MoveTo(Vector3 WorldLocation)
    {
        destination = WorldLocation;

        var da = new DAction();

        da.OnBegin += (d) => {
            directionUnit = (destination - transform.position).normalized;
            currentSpeed  = 0f;
            distance      = MathUtil.CrowFliesDistance(destination - transform.position);
//			Debug.Log ("walk>?");
            GetComponentInChildren <Animation>().Play("walk");
        };

        da.OnUpdate += (d) => {
            directionUnit = (destination - transform.position).normalized;
            lastDistance  = distance;
            distance      = MathUtil.CrowFliesDistance(destination - transform.position);
            currentSpeed  = speed * Time.deltaTime;

            if (distance < 0.5f)
            {
                //Debug.Log("last: " + lastDistance + " dist: " + distance);
                d.state = ActionState.Done;
                GetComponentInChildren <Animation>().Play("idle");
                return;
            }
            ;

            controller.SimpleMove(directionUnit * currentSpeed);
            pos = transform.position;

            currentFacing = Vector3.Slerp(pos + transform.forward, destination, rotateSpeed * Time.deltaTime);
            transform.LookAt(new Vector3(currentFacing.x, pos.y, currentFacing.z));
        };

//da.OnEnd += (d) => {Debug.Log("Ended Moveto");};

        queue.Enqueue(da);
    }
Esempio n. 13
0
    protected virtual void CheckStayingAmount()
    {
        leaveTimer += Time.deltaTime;
        if (leaveTimer >= maxTime)
        {
            // dont call this method again
            leaving = true;

            // save score and catch NaN
            if (!float.IsNaN(needs.CalculateMood()))
            {
                ScoreManager.instance.Score += needs.CalculateMood() * 10;
                Debug.Log("<color=red>I am getting out of here!</color>: " + gameObject.name + ":::" + ScoreManager.instance.Score);

                // queue leaving action
                actionQueue.Enqueue(new TimedAction(
                                        npcSpawnpoint,
                                        "Getting outta here",
                                        null,
                                        null,
                                        () => { Destroy(gameObject); }, //onend
                                        () => { },                      //onstart
                                        3f));
            }

            else
            {
                // queue leaving action
                actionQueue.Enqueue(new TimedAction(
                                        npcSpawnpoint,
                                        "Getting outta here",
                                        null,
                                        null,
                                        () => { Destroy(gameObject); }, //onend
                                        () => { },                      //onstart
                                        3f));
            }
        }
    }
Esempio n. 14
0
        private void ProcessDestinationDirectoryForPossibleDelete(DirectoryInfo di)
        {
            //Get the source directory
            string srcDirectory = SourceDirectory + di.FullName.Substring(DestinationDirectory.Length);
            var    srcDir       = new DirectoryInfo(srcDirectory);

            try
            {
                //Delete the destination directory if it doesn't exist at the source
                // or if the directory is in the ignore list but is present at the destination
                if (!Directory.Exists(srcDirectory) ||
                    ExcludedDirectories.Contains(srcDirectory))
                {
                    try
                    {
                        ActionQueue.Enqueue(new DeleteFolderAction(di.FullName));
                        OnActionAddedToQueue(new EventArgs());
                    }
                    catch (Exception ex)
                    {
                        _log.ErrorFormat("ProcessDestinationDirectoryForPossibleDelete: {0} {1}", di.FullName, ex.Message);
                    }
                }
                else
                {
                    foreach (FileInfo fi in di.GetFiles("*.*", SearchOption.TopDirectoryOnly))
                    {
                        string srcPath = srcDir + "\\" + fi.Name;
                        try
                        {
                            Debug.WriteLine(di.FullName);

                            //Delete the destination file if it doesn't exist at the source
                            if (!File.Exists(srcPath))
                            {
                                ActionQueue.Enqueue(new DeleteFileAction(fi.FullName));
                                OnActionAddedToQueue(new EventArgs());
                            }
                        }
                        catch (Exception ex)
                        {
                            _log.ErrorFormat("ProcessDestinationDirectoryForPossibleDelete: {0} {1}", di.FullName, ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("ProcessDestinationDirectoryForPossibleDelete: {0} {1}", di.FullName, ex.Message);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Send a metric.
        /// </summary>
        /// <param name="name">Metric name.</param>
        /// <param name="value">Metric value.</param>
        /// <param name="properties">Named string values you can use to search and classify events.</param>
        public virtual void TrackMetric(string name, double value, IDictionary <string, string> properties = null)
        {
            IDictionary <string, string> telemetryProperties = (properties ?? new Dictionary <string, string>());
            string correlationId = SetCorrelationId(telemetryProperties);

            if (EnableThreadedOperations)
            {
                ActionQueue.Enqueue(() =>
                {
                    TelemetryClient.Context.Operation.Id = correlationId;
                    TelemetryClient.TrackMetric(name, value, telemetryProperties);
                });
            }
            else
            {
                TelemetryClient.TrackMetric(name, value, telemetryProperties);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Send an Exception
        /// </summary>
        /// <param name="exception">The exception to log.</param>
        /// <param name="metrics">Additional values associated with this exception.</param>
        /// <param name="properties">Named string values you can use to search and classify events.</param>
        public virtual void TrackException(Exception exception, IDictionary <string, double> metrics = null, IDictionary <string, string> properties = null)
        {
            IDictionary <string, string> telemetryProperties = (properties ?? new Dictionary <string, string>());
            string correlationId = SetCorrelationId(telemetryProperties);

            if (EnableThreadedOperations)
            {
                ActionQueue.Enqueue(() =>
                {
                    TelemetryClient.Context.Operation.Id = correlationId;
                    ActionQueue.Enqueue(() => TelemetryClient.TrackException(exception, telemetryProperties, metrics));
                });
            }
            else
            {
                TelemetryClient.TrackException(exception, telemetryProperties, metrics);
            }
        }
Esempio n. 17
0
        public override void DoCheckFlee()
        {
            int numAttackers = GetAttackerCount();

            // Less then specified hp or mana plus 10%, and more then 1 attacker?
            if (_ak.PlayerHealth < profile.GetInteger("FleeBelowHealth") + 10 &&
                numAttackers > 1)
            {
                // Yes? RUN FOREST RUN !
                AddMessage("Run away!");
                Action = BotAction.Flee;
                PlayerKeys.Sprint(KeyDirection.KeyUpDown);

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Rest);
                return;
            }

            //Just one attacker, and below health at which we should run away?
            if (_ak.PlayerHealth < profile.GetInteger("FleeBelowHealth"))
            {
                // Our attacker has more HP then us?
                if (_ak.TargetIndex > 0 && _ak.PlayerHealth < _ak.TargetObject.Health)
                {
                    // Yes? RUN FOREST RUN !
                    AddMessage("Run away!");
                    Action = BotAction.Flee;
                    PlayerKeys.Sprint(KeyDirection.KeyUpDown);

                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.Rest);
                    return;
                }
            }

            // Check if we have a next action
            if (ActionQueue.Count == 0)
            {
                throw new Exception("No action in ActionQueue");
            }

            // Next Action
            Action = ActionQueue.Dequeue();
        }
Esempio n. 18
0
 public void Enqueue_PerformActionAndDispose()
 {
     var actionQueue = new ActionQueue<string>(s => Debug.WriteLine(s));
     Task[] tasks = new Task[10]; 
     for (int i = 0; i < tasks.Length; ++i)
     {
         int taskIndex = i;
         tasks[i] = Task.Run(() =>
         {
             
             for (int j = 0; j < 10; ++j)
             {
                 actionQueue.Enqueue(string.Format("task {0}; item #{1}", taskIndex, j));
               }
         });
     }
     Task.WaitAll(tasks);
     
     actionQueue.Dispose();
 }
        private void setupOperation(ClientContext context)
        {
            LogDebug($"Setting default timeout to: {Context.RequestTimeout}");
            DefaultTimeout = Context.RequestTimeout;

            LastSite = Context.Site;
            LastWeb  = RootWeb = Context.Web;

            LogDebug("Loading initial data");

            LoadWebWithDefaultRetrievals(LastWeb);
            LoadSiteWithDefaultRetrievals(LastSite);

            ActionQueue.Enqueue(new DeferredAction {
                ClientObject = LastSite, Action = DeferredActions.Load
            });
            ActionQueue.Enqueue(new DeferredAction {
                ClientObject = LastWeb, Action = DeferredActions.Load
            });
        }
Esempio n. 20
0
        /// <summary>
        /// Send information about a request handled by the application.
        /// </summary>
        /// <param name="name">The request name.</param>
        /// <param name="url"></param>
        /// <param name="userId">The ID of user accessing the application.</param>
        /// <param name="startTime">The time when the page was requested.</param>
        /// <param name="duration">The time taken by the application to handle the request.</param>
        /// <param name="responseCode">The response status code.</param>
        /// <param name="wasSuccessfull">True if the request was handled successfully by the application.</param>
        /// <param name="properties">Named string values you can use to search and classify events.</param>
        /// <param name="sessionId">The application-defined session ID.</param>
        public virtual void TrackRequest(string name, Uri url, string userId, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool wasSuccessfull, IDictionary <string, string> properties = null, string sessionId = null)
        {
            var requestTelemetry = new RequestTelemetry(name, startTime, duration, responseCode, wasSuccessfull)
            {
                Url = url
            };

            if (properties != null)
            {
                foreach (KeyValuePair <string, string> pair in properties)
                {
                    requestTelemetry.Properties.Add(pair);
                }
            }
            string correlationId = SetCorrelationId(requestTelemetry.Properties);

            TelemetryClient.Context.Operation.Name = name;
            requestTelemetry.Context.Operation.Id  = correlationId;
            if (!string.IsNullOrWhiteSpace(userId))
            {
                requestTelemetry.Context.User.Id = userId;
            }
            if (!string.IsNullOrWhiteSpace(sessionId))
            {
                requestTelemetry.Context.Session.Id = sessionId;
            }

            if (EnableThreadedOperations)
            {
                ActionQueue.Enqueue(() =>
                {
                    TelemetryClient.Context.Operation.Id = correlationId;
                    ActionQueue.Enqueue(() => TelemetryClient.TrackRequest(requestTelemetry));
                });
            }
            else
            {
                TelemetryClient.TrackRequest(requestTelemetry);
            }
        }
Esempio n. 21
0
    public GuiObject BuildBenchUpgradeWindow(Table t, Knowledge k)
    {
        GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Upgrade Bench");

        var playerPosition = Static.Man.transform.position;

        window.Draw += (g) => {
            GUI.Box(g.rect, g.text);
            int boxY = 30, inc = 0;
            Debug.Log(Vector3.Distance(playerPosition, Static.Man.transform.position));
            if (Vector3.Distance(playerPosition, Static.Man.transform.position) > 2)
            {
                NewWindowTask = CloseWindow;
                NewWindow     = window;
                return;
            }

            foreach (Bench b_ in k.benches)
            {
                var b = b_;
                inc = 0;
                int[] inv  = man.GetComponent <Inventory>().GetAmounts(b.buildcost);
                int   boxH = 30 + inv.Length * 25;
                GUI.Box(new Rect(5, boxY, 290, boxH), "");
                GUI.Label(new Rect(10, 5 + boxY, 200, 25), b.customname);
                GUI.Label(new Rect(10, boxY + boxH - 25, 150, boxH - 30), b.description);

                int  i        = 0;
                bool canbuild = true;
                foreach (ItemCount rc in b.buildcost)
                {
                    SetColor(() => { return(inv[i] >= rc.amount); });
                    if (inv[i] < rc.amount)
                    {
                        canbuild = false;
                    }

                    GUI.Label(new Rect(210, 5 + boxY + inc, 150, 25), inv[i] + "/" + rc.amount + " " + rc.item.GetName());
                    inc += 20;
                    i++;
                }

                SetColor();
                GUI.enabled = canbuild;

                if (GUI.Button(new Rect(240, boxY + boxH - 30, 45, 25), "Build"))
                {
                    queue.Enqueue(control.SimpleAction(
                                      (d) => {
                        t.bench = b;
                        foreach (var rc in b.buildcost)
                        {
                            man.GetComponent <Inventory>().AddToInventory(rc.item, -rc.amount);
                        }
                        OpenWindow(BuildBenchWindow(b));
                        d.state = ActionState.Done;
                    }));
                }
                GUI.enabled = true;
                boxY       += boxH + 5;
            }
        };
        return(window);
    }
Esempio n. 22
0
        public override void DoMeleeFight()
        {
            //just in case
            _ak.StopRunning();

            Action = BotAction.CheckFlee;
            ActionQueue.Clear();
            ActionQueue.Enqueue(BotAction.Protect);
            ActionQueue.Enqueue(BotAction.MeleeFight);

            //nothing to do if still casting last melee spell
            if (_ak.isPlayerCasting || !cooldowns.IsReady("MeleePT"))
            {
                return;
            }

            //did we start with a melee range fight so currentTarget never got set?
            if (currentTarget < 1 && _ak.TargetIndex > 0)
            {
                currentTarget = _ak.TargetIndex;
            }

            // Do we need to heal the pet?
            if (cooldowns.IsReady("Heal") && _ak.get_MobHealth(petID) < profile.GetInteger("Necro.HealHealth") && profile.GetString("Necro.HealPetQ") != "" && profile.GetString("Necro.HealPetKey") != "")
            {
                AddMessage("Healing pet at health " + _ak.get_MobHealth(petID));
                //switch quickbar and cast
                UseQbar(profile.GetString("Necro.HealPetQ"), profile.GetString("Necro.HealPetKey"));

                cooldowns.SetTime("Heal");
                return;
            }

            //if too far away for melee fight
            if (_ak.TargetIndex > 0 && DistanceToPet(_ak.TargetIndex) > profile.GetFloat("MinimumRangedAttackDistance"))
            {
                Action = BotAction.RangedFight;

                //face target
                PlayerKeys.Face(KeyDirection.KeyUpDown);

                return;
            }

            //do repeated melee range spell
            if (_ak.TargetIndex > 0)
            {
                AddMessage("Close Range Spell ");
                //switch quickbar and cast
                UseQbar(profile.GetString("Necro.FightMeleePTQ"), profile.GetString("Necro.FightMeleePTKey"));

                cooldowns.SetTime("MeleePT");

                nCountFight++;
            }


            if (_ak.TargetIndex < 1 || _ak.get_IsMobDead(_ak.TargetIndex))
            {
                AddMessage("Target Dead");
                // Target is lost, check for agro
                Action = BotAction.CheckAgro;

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Protect);
                ActionQueue.Enqueue(BotAction.Loot);
                ActionQueue.Enqueue(BotAction.CheckAgro);

                NumKilled++;
                AddMessage(string.Format("==> Number Killed {0} <==", NumKilled));
                nextSpell     = eRangedFights.First;
                nCountFight   = 0;
                currentTarget = 0;
                Thread.Sleep(500);
                return;
            }
        }
Esempio n. 23
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("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);
        }
Esempio n. 24
0
        public override void DoRangedFight()
        {
            //just in case
            _ak.StopRunning();

            Action = BotAction.CheckFlee;
            ActionQueue.Clear();
            ActionQueue.Enqueue(BotAction.Protect);
            ActionQueue.Enqueue(BotAction.RangedFight);

            //if target close enough to switch to melee fight, do it
            //done before cooldown check since we can cast melee range spells immediately
            if (_ak.TargetIndex > 0 && DistanceToPet(_ak.TargetIndex) < profile.GetFloat("MinimumRangedAttackDistance"))
            {
                //put pet back in defensive mode
                UseQbar(profile.GetString("Necro.PetDefensiveQ"), profile.GetString("Necro.PetDefensiveKey"));

                Action = BotAction.MeleeFight;

                //face target
                PlayerKeys.Face(KeyDirection.KeyUpDown);

                return;
            }

            //nothing to do if cooldowns arent ready
            if (_ak.isPlayerCasting || _ak.get_isMobCasting(petID) || !cooldowns.IsReady("Ranged"))
            {
                return;
            }

            //check if we targeted something in a dungeon we cant get see, "not in line of sight"
            if (bNoLineOfSight)
            {
                if (_ak.TargetIndex > 0)
                {
                    IgnoreThis(_ak.TargetIndex);
                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.FindTarget);
                    //lets clear the stuff we use to test for unfightable targets
                    currentTarget = 0;
                    AddMessage("In Ranged Fight, no LOS, added to bad target list");
                    return;
                }
            }

            //check if this is a new fight, so we can store our mob for the evade test below
            if (currentTarget < 1 && _ak.TargetIndex > 0)
            {
                currentTarget = _ak.TargetIndex;
            }

            //Got out of range somehow?
            if (_ak.TargetIndex > 0 && DistanceToPet(_ak.TargetIndex) > profile.GetFloat("MaximumRangedAttackDistance"))
            {
                AddMessage("Target out of range, moving closer");

                //for some reason we need to break auto face
                //before moveto will work right
                PlayerKeys.TurnLeft(KeyDirection.KeyDown);
                Thread.Sleep(25);
                PlayerKeys.TurnLeft(KeyDirection.KeyUp);

                Action = BotAction.CheckAgro;
                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Protect);
                ActionQueue.Enqueue(BotAction.GetInRange);
                ActionQueue.Enqueue(BotAction.RangedFight);

                return;
            }

            if (nextSpell == eRangedFights.First)
            {
                AddMessage(string.Format("Fight Starting at distance: {0}", DistanceToPet(_ak.TargetIndex)));
            }

            //if this is our first ranged cast we get to cast twice to fill up the queue
            if (_ak.TargetIndex > 0 &&
                nextSpell == eRangedFights.First &&
                cooldowns.IsReady("Global") &&
                !_ak.isPlayerCasting)
            {
                //put pet back in passive mode so it doesnt run to mob
                UseQbar(profile.GetString("Necro.PetPassiveQ"), profile.GetString("Necro.PetPassiveKey"));

                nextSpell = eRangedFights.Power;                  //default

                //do we need health more than power?
                if (_ak.PlayerMana > 75 && _ak.get_MobHealth(petID) < 75)
                {
                    nextSpell = eRangedFights.Health;
                }

                //Now cast the first spell
                if (nextSpell == eRangedFights.Power)
                {
                    AddMessage("Casting Power Tap ");
                    //switch quickbar and cast
                    UseQbar(profile.GetString("Necro.FightRangedPTQ"), profile.GetString("Necro.FightRangedPTKey"));
                }
                else
                {
                    AddMessage("Casting Life Tap ");
                    //switch quickbar and cast
                    UseQbar(profile.GetString("Necro.FightRangedLTQ"), profile.GetString("Necro.FightRangedLTKey"));
                }

                nextSpell = eRangedFights.Debuff;
                //Thread.Sleep(500);
            }

            //Debuff
            if (_ak.TargetIndex > 0 &&                                          //make sure we have a target
                nextSpell == eRangedFights.Debuff &&                            //not pull spell
                cooldowns.IsReady("Ranged") &&                                  //not still casting previous ranged spell
                !_ak.isPlayerCasting)                                           //not casting anything
            {
                // Are the instant debuff keys set?  If so use it
                if (profile.GetString("Necro.DebuffQ") != "" &&
                    profile.GetString("Necro.DebuffKey") != "")
                {
                    AddMessage("Debuffing");
                    UseQbar(profile.GetString("Necro.DebuffQ"), profile.GetString("Necro.DebuffKey"));
                }

//				cooldowns.SetTime("Ranged");
                nextSpell = eRangedFights.Power;

                return;
            }

            //cast subsequent ranged spells
            if (_ak.TargetIndex > 0 &&                            //make sure we have a target
                nextSpell != eRangedFights.First &&               //not pull spell
                cooldowns.IsReady("Ranged") &&                    //not still casting previous ranged spell
                !_ak.isPlayerCasting)                             //not casting anything
            {
                nextSpell = eRangedFights.Power;                  //default

                //do we need health more than power?
                if (_ak.PlayerMana > 75 && _ak.get_MobHealth(petID) < 75)
                {
                    nextSpell = eRangedFights.Health;
                }

                //Now cast the spell
                if (nextSpell == eRangedFights.Power)
                {
                    AddMessage("Casting Power Tap - Range " + DistanceToPet(_ak.TargetIndex).ToString());
                    //switch quickbar and cast
                    UseQbar(profile.GetString("Necro.FightRangedPTQ"), profile.GetString("Necro.FightRangedPTKey"));
                }
                else
                {
                    AddMessage("Casting Life Tap - Range " + DistanceToPet(_ak.TargetIndex).ToString());
                    //switch quickbar and cast
                    UseQbar(profile.GetString("Necro.FightRangedLTQ"), profile.GetString("Necro.FightRangedLTKey"));
                }
                cooldowns.SetTime("Ranged");

                nCountFight++;
            }

            if (_ak.TargetIndex < 1 || _ak.get_IsMobDead(_ak.TargetIndex))
            {
                AddMessage("Target Dead");
                // Target is lost, check for agro
                Action = BotAction.CheckAgro;

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Protect);
                ActionQueue.Enqueue(BotAction.Loot);
                ActionQueue.Enqueue(BotAction.CheckAgro);

                NumKilled++;
                AddMessage(string.Format("==> Number Killed {0} <==", NumKilled));
                nextSpell     = eRangedFights.First;
                nCountFight   = 0;
                currentTarget = 0;
                Thread.Sleep(500);
                return;
            }
        }
Esempio n. 25
0
        private void ProcessDirectoryForActions(DirectoryInfo di)
        {
            //Get the destination directory
            string newFolder = di.FullName.Substring(SourceDirectory.Length);

            if (newFolder.StartsWith(@"\"))
            {
                newFolder = newFolder.Substring(1);
            }
            string destDirectory = Path.Combine(DestinationDirectory, newFolder);
            var    destDir       = new DirectoryInfo(destDirectory);

            //Create the destination directory if it doesn't already exist
            //if (!Directory.Exists(destDirectory))
            if (!destDir.Exists)
            {
                _log.InfoFormat("Add Create Folder Action to Action Queue: {0}", destDir.FullName);
                ActionQueue.Enqueue(new CreateFolderAction(destDir.FullName));
                OnActionAddedToQueue(new EventArgs());
            }

            //Now check each file in the source directory for the following conditions
            //  * In the source directory but not in the destination directory
            //  * file in source and destination directory are different
            try
            {
                foreach (FileInfo fi in di.GetFiles("*.*", SearchOption.TopDirectoryOnly))
                {
                    //FileBeginProcessingEventArgs ea = new FileBeginProcessingEventArgs(fi.FullName);
                    //OnFileBeginProcessing(ea);
                    string destPath = Path.Combine(destDir.FullName, fi.Name);

                    //Check file attributes
                    if ((!IncludeHidden && fi.Attributes.ToString().Contains("Hidden")) ||
                        (!IncludeReadOnly && fi.Attributes.ToString().Contains("ReadOnly")) ||
                        (!IncludeSystem && fi.Attributes.ToString().Contains("System")))
                    {
                        _log.InfoFormat("Add Skip File Action to Action Queue: {0}", fi.FullName);
                        SkipFileActionQueue.Enqueue(new SkipFileAction(fi.FullName));
                        OnActionAddedToQueue(new EventArgs());
                    }
                    else
                    {
                        //Check if the file exists
                        ///TODO: Probably only need copy action
                        if (!File.Exists(destPath))
                        {
                            _log.InfoFormat("Add Copy File Action to Action Queue: {0} {1}", fi.FullName, destPath);
                            ActionQueue.Enqueue(new CopyFileAction(fi.FullName, destPath));
                            OnActionAddedToQueue(new EventArgs());
                        }
                        else //Only copy if it has changed
                        {
                            var fiD = new FileInfo(destPath);
                            if (fi.LastWriteTimeUtc < fiD.LastWriteTimeUtc.AddSeconds(-5) ||
                                fi.Length != fiD.Length)
                            {
                                _log.InfoFormat("Add Overwrite File Action to Action Queue: {0}", fi.FullName, destPath);
                                ActionQueue.Enqueue(new OverwriteFileAction(fi.FullName, destPath));
                                OnActionAddedToQueue(new EventArgs());
                            }
                            else
                            {
                                _log.InfoFormat("Add Skip File Action to Action Queue: {0}", fi.FullName);
                                SkipFileActionQueue.Enqueue(new SkipFileAction(fi.FullName));
                                OnActionAddedToQueue(new EventArgs());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("{0}: {1} {2}", "ProcessDirectoryForActions", di.FullName, ex.Message);
            }
        }
Esempio n. 26
0
        public override void DoGetInRange()
        {
            nextSpell = eRangedFights.First;

            // Do we have a target and is it not fighting someone else?
            if (_ak.TargetIndex < 1 || (_ak.TargetObject != null && _ak.TargetObject.TargetID != 0 && _ak.TargetObject.TargetID != _ak.PlayerID))
            {                   // No? Stop moving
                _ak.StopRunning();

                // Check agro
                Action = BotAction.Protect;

                // If we were in Melee code, maybe it died?
                if (ActionQueue.Count > 0 && ActionQueue.Peek(0) == BotAction.MeleeFight)
                {
                    // Let melee code do whatever it does when something dies
                    return;
                }
                else
                {
                    // Find a new target
                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.CheckAgro);
                    ActionQueue.Enqueue(BotAction.FindTarget);
                }

                return;
            }

            // Get the next action from the queue
            BotAction NextAction = ActionQueue.Dequeue();

            // By default assume a ranged attack distance (move closer then the max, so mobs that run away are caught easier)
            float AttackDistance = profile.GetFloat("MaximumRangedAttackDistance") * 0.95f;

            // Calculate the distance to the target FROM PET
            float TargetDistance = DistanceToPet(_ak.TargetIndex);

            // Check if we're past the minimum distance, go to melee distance else
            if (TargetDistance < profile.GetFloat("MinimumRangedAttackDistance"))
            {
                NextAction = BotAction.MeleeFight;
            }

            // Should we go to melee attack distance?
            if (NextAction == BotAction.MeleeFight || (ActionQueue.Count > 0 && ActionQueue.Peek(0) == BotAction.MeleeFight))
            {
                AttackDistance = 200;                  //200 should be close enough to /stick to the target
            }
            // TODO: Add (extra) stuck checking here

            float distToWalk = TargetDistance - AttackDistance;

//			AddMessage("DEBUG: distToWalk " + distToWalk.ToString() + " target index " + _ak.TargetIndex);

            // Do our final distance move?
            if (_ak.TargetIndex > 0 && distToWalk <= 200)
            {
                // Do our final move
                MoveTo(_ak.TargetIndex, AttackDistance, true);

                // make sure we are facing the target
                PlayerKeys.Face(KeyDirection.KeyUpDown);

                // One final agro check, might be the same monster though
                Action = BotAction.CheckAgro;

                // Make sure we do the appropriate action
                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Protect);
                ActionQueue.Enqueue(NextAction);
            }
            else
            {
                // Walk to our target in small steps
                if (_ak.TargetIndex > 0)
                {
                    MoveTo(_ak.TargetIndex, TargetDistance - (distToWalk / 4), false);
                }

                // Recheck if our target is still the closest once, only if not incombat
                // Use multiple checks because once in a great while GetAttackerCount is 0 and something is hitting us
                if (GetAttackerCount() == 0 || _ak.isPlayerInCombat || (petID > 0 && !_ak.get_isMobInCombat(petID)))
                {
                    // Setup our bot actions
                    Action = BotAction.Protect;
                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.CheckAgro);
                    ActionQueue.Enqueue(BotAction.FindTarget);
                }
                else
                {                       // In combat, just get in range
                                        //for some reason we need to break auto face
                                        //before moveto will work right
                    PlayerKeys.TurnLeft(KeyDirection.KeyDown);
                    Thread.Sleep(25);
                    PlayerKeys.TurnLeft(KeyDirection.KeyUp);

                    Action = BotAction.GetInRange;
                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.Protect);
                    ActionQueue.Enqueue(NextAction);
                }
            }
        }
Esempio n. 27
0
 public static void Enqueue(Action action)
 {
     queue.Enqueue(action);
 }
Esempio n. 28
0
        public override void DoMeleeFight()
        {
            if (_ak.TargetIndex < 1 || _ak.get_IsMobDead(_ak.TargetIndex))
            {
                AddMessage("Target Dead");
                // Target is lost, check for agro
                Action = BotAction.CheckAgro;

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Loot);
                ActionQueue.Enqueue(BotAction.CheckAgro);

                playerShooting = false;
                playerSwinging = false;
                NumKilled++;
                AddMessage(string.Format("==> Number Killed {0} <==", NumKilled));
                nextRanged    = eRangedFights.Crit;
                nCountFight   = 0;
                currentTarget = 0;
                Thread.Sleep(500);

                //select bow
                AddMessage("selecting bow");
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));

                return;
            }

            //just in case
            _ak.StopRunning();

            Action = BotAction.CheckFlee;
            ActionQueue.Clear();
            ActionQueue.Enqueue(BotAction.MeleeFight);

            //are we still doing the last style?
            if (playerSwinging || !cooldowns.IsReady("FightDelay"))
            {
                return;
            }

            //did we start with a melee range fight so currentTarget never got set?
            if (currentTarget < 1 && _ak.TargetIndex > 0)
            {
                //switch to melee weapon
                UseQbar(profile.GetString("Scout.FightMeleeWeaponQ"), profile.GetString("Scout.FightMeleeWeaponKey"));
                currentTarget = _ak.TargetIndex;
//				playerShooting = false;
//				playerSwinging = false;
            }

            //do repeated melee range spell
            if (_ak.TargetIndex > 0)
            {
                AddMessage("Close Range Style " + nextMelee.ToString());

                switch (nextMelee)
                {
                case eMeleeFights.Normal:
                    UseQbar(profile.GetString("Scout.SlashNormalQ"), profile.GetString("Scout.SlashNormalKey"));
                    if (profile.GetString("Scout.SlashNormalChainQ") != "" &&
                        profile.GetString("Scout.SlashNormalChainKey") != "")
                    {
                        nextMelee = eMeleeFights.NormalChain;
                    }
                    break;

                case eMeleeFights.NormalChain:
                    UseQbar(profile.GetString("Scout.SlashNormalChainQ"), profile.GetString("Scout.SlashNormalChainKey"));
                    //done with chain, back to normal fight
                    nextMelee = eMeleeFights.Normal;
                    break;

                case eMeleeFights.Blocked:
                    UseQbar(profile.GetString("Scout.SlashBlockQ"), profile.GetString("Scout.SlashBlockKey"));
                    //if user has set up a chain for blocked styles, do it next time
                    if (profile.GetString("Scout.SlashBlockChainQ") != "" &&
                        profile.GetString("Scout.SlashBlockChainKey") != "")
                    {
                        nextMelee = eMeleeFights.NormalChain;
                    }
                    else
                    {
                        nextMelee = eMeleeFights.Normal;
                    }
                    break;

                case eMeleeFights.BlockedChain:
                    UseQbar(profile.GetString("Scout.SlashBlockChainQ"), profile.GetString("Scout.SlashBlockChainKey"));
                    //done with chain, back to normal fight
                    nextMelee = eMeleeFights.Normal;
                    break;
                }
                //make sure we give the game time to send the chat string "you prepare"
                cooldowns.SetTime("FightDelay");
                playerSwinging = true;

                nCountFight++;
            }
        }
Esempio n. 29
0
        public override void DoRangedFight()
        {
            if (_ak.TargetIndex < 1 || _ak.get_IsMobDead(_ak.TargetIndex))
            {
                AddMessage("Target Dead");
                // Target is lost, check for agro
                Action = BotAction.CheckAgro;

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Loot);
                ActionQueue.Enqueue(BotAction.CheckAgro);

                playerShooting = false;
                playerSwinging = false;
                NumKilled++;
                AddMessage(string.Format("==> Number Killed {0} <==", NumKilled));
                nextRanged    = eRangedFights.Crit;
                nCountFight   = 0;
                currentTarget = 0;
                //in case we have bow drawn, make sure to put it away so we can
                //use crit shot for next kill even if we dont run anywhere
                UseQbar(profile.GetString("Scout.FightMeleeWeaponQ"), profile.GetString("Scout.FightMeleeWeaponKey"));

                return;
            }

            //just in case
            _ak.StopRunning();

            Action = BotAction.CheckFlee;
            ActionQueue.Clear();
            ActionQueue.Enqueue(BotAction.RangedFight);

            //if target close enough to switch to melee fight, do it
            //done before cooldown check since we can cast melee range spells immediately
            if (_ak.TargetIndex > 0 && DistanceToMob(_ak.TargetIndex) < profile.GetFloat("MinimumRangedAttackDistance"))
            {
                Action = BotAction.MeleeFight;

                //face target
                PlayerKeys.Face(KeyDirection.KeyUpDown);

                //switch to melee weapon
                UseQbar(profile.GetString("Scout.FightMeleeWeaponQ"), profile.GetString("Scout.FightMeleeWeaponKey"));

                return;
            }

            //check if we targeted something in a dungeon we cant get see, "not in line of sight"
            if (bNoLineOfSight)
            {
                if (_ak.TargetIndex > 0)
                {
                    IgnoreThis(_ak.TargetIndex);
                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.FindTarget);
                    //lets clear the stuff we use to test for unfightable targets
                    currentTarget = 0;
                    AddMessage("In Ranged Fight, no LOS, added to bad target list");
                    return;
                }
            }

            //check if this is a new fight, so we can store our mob
            if (currentTarget < 1 && _ak.TargetIndex > 0)
            {
                currentTarget = _ak.TargetIndex;
                nextRanged    = eRangedFights.Crit;
//				playerShooting = false;
//				playerSwinging = false;
            }
            //Got out of range somehow?
            if (_ak.TargetIndex > 0 && DistanceToMob(_ak.TargetIndex) > profile.GetFloat("MaximumRangedAttackDistance"))
            {
                AddMessage("Target out of range, moving closer");

                //for some reason we need to break auto face
                //before moveto will work right
                PlayerKeys.TurnLeft(KeyDirection.KeyDown);
                Thread.Sleep(25);
                PlayerKeys.TurnLeft(KeyDirection.KeyUp);

                Action = BotAction.GetInRange;
                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.RangedFight);

                return;
            }

            //nothing more to do if still shooting
            if (playerShooting || !cooldowns.IsReady("FightDelay"))
            {
                return;
            }

            if (_ak.PlayerLeftHand != AutoKillerScript.WeaponSlots.Ranged)
            {
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));
            }

            if (nextRanged == eRangedFights.Crit)
            {
                AddMessage(string.Format("Fight Starting at distance: {0}", DistanceToMob(_ak.TargetIndex)));
            }

            //if this is our first ranged fight, do crit shot
            if (_ak.TargetIndex > 0 &&
                nextRanged == eRangedFights.Crit &&
                !playerShooting)
            {
                // Do the crit shot
                UseQbar(profile.GetString("Scout.FightRangedCritQ"), profile.GetString("Scout.FightRangedCritKey"));

                //release and reload
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));

                playerShooting = true;
                nextRanged     = eRangedFights.Bow;
                cooldowns.SetTime("FightDelay");
                nCountFight++;

                return;
            }

            if (_ak.TargetIndex > 0 &&                                          //make sure we have a target
                nextRanged == eRangedFights.Bow &&                              //not pull spell
                !playerShooting)                                                //not casting anything
            {
                AddMessage("Regular bow shot - Range " + DistanceToMob(_ak.TargetIndex).ToString());

                //release and reload
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));

                playerShooting = true;
                nextRanged     = eRangedFights.Bow;
                cooldowns.SetTime("FightDelay");
                nCountFight++;
            }
        }
Esempio n. 30
0
 public void Enqueue(Action action)
 {
     ActionQueue.Enqueue(action);
     Wait.Set();
 }
Esempio n. 31
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);
        }