protected override void TargetFilter_IncludeTargets( List <WoWObject> incomingWowObjects, HashSet <WoWObject> outgoingWowObjects) { // don't add targets while flying because core will dismount before reaching search area. if (Me.IsFlying && !Me.IsActuallyInCombat || !Query.IsViable(SelectedNpc)) { return; } if (!SelectedNpc.HasAura(ImmunityAuraId)) { outgoingWowObjects.Add(SelectedNpc); return; } if (!Me.IsActuallyInCombat) { return; } foreach (var unit in incomingWowObjects.OfType <WoWUnit>()) { if (ImmunityBreakingMobIds.Contains((int)unit.Entry)) { outgoingWowObjects.Add(unit); } } }
public BreakImmunityByKillingMobsInCloseProximity(Dictionary <string, string> args) : base(args) { QBCLog.BehaviorLoggingContext = this; try { // QuestRequirement* attributes are explained here... // http://www.thebuddyforum.com/mediawiki/index.php?title=Honorbuddy_Programming_Cookbook:_QuestId_for_Custom_Behaviors // ...and also used for IsDone processing. // Primary attributes... MobIds = GetNumberedAttributesAsArray <int>("MobId", 0, ConstrainAs.MobId, new[] { "NpcId" }); if (MobIds != null && !MobIds.Any()) { MobIds = GetAttributeAsArray <int>("MobIds", true, ConstrainAs.MobId, new[] { "NpcIds" }, null); } ImmunityBreakingMobIds = GetNumberedAttributesAsArray <int>( "ImmunityBreakingMobId", 0, ConstrainAs.MobId, new[] { "ImmunityBreakingNpcId" }); if (ImmunityBreakingMobIds != null && !ImmunityBreakingMobIds.Any()) { ImmunityBreakingMobIds = GetAttributeAsArray <int>( "ImmunityBreakingMobIds", true, ConstrainAs.MobId, new[] { "ImmunityBreakingNpcIds" }, null); } SearchLocation = GetAttributeAsNullable <Vector3>("", false, ConstrainAs.Vector3NonEmpty, null) ?? Me.Location; ImmunityAuraId = GetAttributeAsNullable <int>("ImmunityAuraId", true, ConstrainAs.AuraId, null) ?? 0; MaxRange = GetAttributeAsNullable <double>("MaxRange", false, new ConstrainTo.Domain <double>(0, 40), null) ?? 8; } catch (Exception except) { // Maintenance problems occur for a number of reasons. The primary two are... // * Changes were made to the behavior, and boundary conditions weren't properly tested. // * The Honorbuddy core was changed, and the behavior wasn't adjusted for the new changes. // In any case, we pinpoint the source of the problem area here, and hopefully it // can be quickly resolved. QBCLog.Exception(except); IsAttributeProblem = true; } }
private async Task <bool> MainCoroutine() { // break if we are done or we are not in combat and targting is not empty, we want the botbase to clear path for us. if (IsDone || (!Me.Combat && Targeting.Instance.FirstUnit != null) || !Me.IsAlive) { return(false); } if (!Query.IsViable(SelectedNpc)) { SelectedNpc = GetNpc(); } if (!Query.IsViable(SelectedNpc) || !Me.IsActuallyInCombat && Targeting.Instance.FirstUnit == null) { // move to search area if (SearchLocation != Vector3.Zero && !Navigator.AtLocation(SearchLocation)) { await UtilityCoroutine.MoveTo(SearchLocation, "Search Area", MovementBy); } // Dismount after reaching search location. else if ((SearchLocation == Vector3.Zero || Navigator.AtLocation(SearchLocation)) && Me.Mounted) { await UtilityCoroutine.ExecuteMountStrategy(MountStrategyType.Dismount); } else { TreeRoot.StatusText = "Waiting for NPC to spawn"; } return(true); } if (SelectedNpc.IsDead && SelectedNpc.TaggedByMe && !VariantQuestIds.Any()) { BehaviorDone(); return(true); } if (SelectedNpc.HasAura(ImmunityAuraId)) { if (BotPoi.Current.AsObject == SelectedNpc) { BotPoi.Clear("Mob is immune"); } var targetedMob = Targeting.Instance.FirstUnit; if (targetedMob != null && ImmunityBreakingMobIds.Contains((int)targetedMob.Entry)) { if (targetedMob.IsTargetingMeOrPet) { // move close enough to shielded NPC so that the exploding mobs will hit it when killed. var myMinDistance = Math.Max(2, MaxRange - targetedMob.MeleeRange); if (SelectedNpc.DistanceSqr > myMinDistance * myMinDistance) { TreeRoot.StatusText = string.Format("Moving closer to {0} before killing {1}", SelectedNpc.SafeName, targetedMob.SafeName); Navigator.MoveTo(SelectedNpc.Location); return(true); } // wait for exploding mob to get within range of shielded mob. if (targetedMob.Location.DistanceSquared(SelectedNpc.Location) > MaxRange * MaxRange) { TreeRoot.StatusText = string.Format( "Waiting for {0} to move withing range of {1}", targetedMob.SafeName, SelectedNpc.SafeName); return(true); } } } } return(false); }