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 DoProtect() { // Do we have instant debuff set? If not dont bother trying to protect (for now) if (profile.GetString("Necro.DebuffQ") == "" || profile.GetString("Necro.DebuffKey") == "") { return; } try { // Retrieve a list of objects near enough to be attacking our group int myX = _ak.gPlayerXCoord; int myY = _ak.gPlayerYCoord; AKServer.DLL.DAoCServer.Group groupMembers = _ak.GroupMemberInfo; // In a group? If not just return if (groupMembers.GroupMemberTable.Count == 0) { return; } ArrayList pets = new ArrayList(); if (petID > 0) { pets.Add(petID); } int spawnID = _ak.SearchArea((int)profile.GetFloat("SearchDistance"), AKServer.DLL.DAoCServer.DAOCObjectClass.ocMob, pets); while (spawnID != -1) { int mobTarget = _ak.get_MobTarget(spawnID); foreach (AKServer.DLL.DAoCServer.GroupMember grpMember in groupMembers.GroupMemberTable.Values) { //Is this group member being attacked? if (grpMember.ID == mobTarget) { //Yes, use instant debuff to get aggro! if (_ak.isPlayerSitting) { PlayerKeys.SitStand(KeyDirection.KeyUpDown); Thread.Sleep(500); } _ak.SetTarget(spawnID); Thread.Sleep(150); PlayerKeys.Face(KeyDirection.KeyUpDown); UseQbar(profile.GetString("Necro.DebuffQ"), profile.GetString("Necro.DebuffKey")); AddMessage("Protected " + _ak.get_MobName(mobTarget) + " by attacking " + _ak.get_MobName(spawnID)); } } spawnID = _ak.SearchAreaNext((int)profile.GetFloat("SearchDistance"), AKServer.DLL.DAoCServer.DAOCObjectClass.ocMob, pets); } } catch (Exception e) { AddMessage("caught exception " + e.Message); } finally { // Check if we have a next action if (ActionQueue.Count == 0) { throw new Exception("No action in ActionQueue"); } // Next Action Action = ActionQueue.Dequeue(); } }
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 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 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; } }