public void CanCancelWithTimestampedConsume() { var arr = new List <Timestamped <int> >(); ActionQueue <int> .Clear(); // Start processing queue at the rate of one item every 11ms. var t = ActionQueue <int> .Consume(x => { arr.Add(x); Thread.Sleep(11); }); // Arrange to stop processing the queue in 0.1 sec ActionQueue <int> .Cancel(95); // Add ten items. Enumerable.Range(0, 10).ToList().ForEach(ActionQueue <int> .Enqueue); // Wait 0.1 sec. Thread.Sleep(100); // Add another hundred items. The consumer should be cancelled before this happens. Enumerable.Range(10, 100).ToList().ForEach(ActionQueue <int> .Enqueue); // Wait 0.1 sec for the extra items to be processed in the event of the cancellation not working. Thread.Sleep(100); Assert.AreEqual(9, arr.Count); }
public void CanDequeueManually() { var random = new Random(); var max = 1000; var dequeuedCount = random.Next(1, max - 1); var value = 0; var remainder = 0; ActionQueue <int> .Clear(); // Add random number of items to queue. Enumerable.Range(1, max).ToList().ForEach(ActionQueue <int> .Enqueue); // Dequeue a (different and smaller) random number of times. for (var i = 0; i < dequeuedCount; i++) { value = ActionQueue <int> .Dequeue(); } // Work out how many items there should be left in the queue. remainder = max - dequeuedCount; // Make sure we dequeued as many items as expected. Assert.AreEqual(value, dequeuedCount); // Make sure there are as many items left in the queue as expected. Assert.AreEqual(ActionQueue <int> .Count, remainder); }
public void CanGetLatency() { var arr = new List <int>(); ActionQueue <int> .Clear(); // Start processing queue at the rate of one item every 11ms. var t = ActionQueue <int> .Consume(x => { arr.Add(x); Thread.Sleep(11); }); // Arrange to stop processing the queue in 0.1 sec ActionQueue <int> .Cancel(95); // Add ten items. Enumerable.Range(0, 10).ToList().ForEach(ActionQueue <int> .Enqueue); // Wait 0.1 sec. Thread.Sleep(100); var latency = ActionQueue <int> .GetLatencyInMilliseconds(); // Wait 0.1 sec for the extra items to be processed in the event of the cancellation not working. Thread.Sleep(100); Assert.IsTrue(latency >= 100, string.Format("Latency was meant to be >= {0}ms but it was {1}ms.", 100, latency)); }
public void Abort(AgentAbortReason why) { CurrentAction = null; ActionQueue.Clear(); Logger.Log <Agent>($"{Owner.Identifier} aborted: {why}"); _behavior?.IaAborted(why); }
/// <summary> /// Handles the cleanup process for a landblock /// This method is called by LandblockManager /// </summary> public void Unload() { var landblockID = Id.Raw | 0xFFFF; //log.Debug($"Landblock.Unload({landblockID:X8})"); ProcessPendingWorldObjectAdditionsAndRemovals(); SaveDB(); // remove all objects foreach (var wo in worldObjects.ToList()) { if (!wo.Value.BiotaOriginatedFromOrHasBeenSavedToDatabase()) { wo.Value.Destroy(false); } else { RemoveWorldObjectInternal(wo.Key); } } ProcessPendingWorldObjectAdditionsAndRemovals(); actionQueue.Clear(); // remove physics landblock LScape.unload_landblock(landblockID); }
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(); }
public void ActionQueuePurge_Test() { var actionQueue = new ActionQueue <BusinessLogicEntity, BusinessLogicEntity>(); actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>()); actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>()); actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>()); actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>()); actionQueue.Add(new ActionQueueEntry <BusinessLogicEntity, BusinessLogicEntity>()); actionQueue.Clear(); Assert.AreEqual(0, actionQueue.Count); }
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(); }
public void CanProcessQueue() { var total = 0; ActionQueue <int> .Clear(); // Start processing queue var task = ActionQueue <int> .Consume(x => total += x); // Arrange to stop processing the queue in 0.1 sec ActionQueue <int> .Cancel(100); // Add items to queue (this is almost instantaneous). Enumerable.Range(1, 10).ToList().ForEach(ActionQueue <int> .Enqueue); // Wait 0.1 sec for the cancellation to take effect. Thread.Sleep(100); Assert.AreEqual(55, total); }
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); } } }
public void reset() { aq.Cancel(); aq.Clear(); moveGroup(outsideY); }
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++; } }
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++; } }
public void Flush() { CurrentAction = null; ActionQueue.Clear(); }
private void BuildActionQueue() { _log.Info("Building Action Queue"); ProcessingStatus = BackupProcessingStatus.BuildingActionQueue; //Clear the action Queues ActionQueue.Clear(); SkipFileActionQueue.Clear(); DeleteActionStack.Clear(); if (_cancelToken.IsCancellationRequested) { _log.Info("Building Action Queue Cancelled"); ProcessingStatus = BackupProcessingStatus.Cancelled; return; } if (CheckDriveExists(SourceDirectory.Substring(0, 1)) && CheckSourceRootExists() && CheckDriveExists(DestinationDirectory.Substring(0, 1))) { if (BackupMode == BackupSetMode.Backup && RemoveDeleted) { List <DirectoryInfo> destDirs = IOHelper.GetDirectoriesPostOrder(DestinationDirectory); if (destDirs != null) { foreach (DirectoryInfo di in destDirs) { if (_cancelToken.IsCancellationRequested) { ProcessingStatus = BackupProcessingStatus.Cancelled; return; } ProcessDestinationDirectoryForPossibleDelete(di); } } } var dirs = IOHelper.GetDirectories(SourceDirectory); if (dirs != null) { foreach (DirectoryInfo di in dirs) { //Check if the directory should be excluded if (ExcludedDirectories == null || !ExcludedDirectories.Contains(di.FullName)) { if (_cancelToken.IsCancellationRequested) { ProcessingStatus = BackupProcessingStatus.Cancelled; return; } ProcessDirectoryForActions(di); } else { IOHelper.GetFiles(di.FullName) .ForEach(fi => SkipFileActionQueue.Enqueue(new SkipFileAction(fi.FullName))); } } } } _log.Info("Finished Building Action Queue"); ProcessingStatus = BackupProcessingStatus.ActionQueueBuilt; }
public void FinishActions() { ActionQueue.Clear(); gc.playerOrder.Remove(this); }
private void CleanAllQueue() { carInOutDetsilsLogQueue?.Clear(); }
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; } }
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; } }
private void OnTouchField() { field.AddPatternToField(currentPoint, pattern, cubesInPattern); actionQueue.Clear(); GameEvent.FieldTouched(this, field.IsGameLost()); }
internal void Clear() { actionQueue.Clear(); }