private RunStatus GotoPool(WoWGameObject pool) { if (_lastPoolGuid != pool.Guid) { MoveToPoolSW.Reset(); MoveToPoolSW.Start(); _lastPoolGuid = pool.Guid; if (!FindPoolPoint(pool) || PoolPoints.Count == 0) { Utils.BlacklistPool(pool, TimeSpan.FromDays(1), "Found no landing spots"); return(RunStatus.Success);// return sucess so Behavior stops and starts at begining on next tick. } } // should never be true.. but being safe.. if (PoolPoints.Count == 0) { Utils.BlacklistPool(pool, TimeSpan.FromDays(1), "Pool landing points mysteriously disapear..."); return(RunStatus.Success);// return sucess so Behavior stops and starts at begining on next tick. } TreeRoot.StatusText = "Moving to " + pool.Name; if (_me.Location.Distance(PoolPoints[0]) > 3) { _movetoConcludingSW.Reset(); if (!MoveToPoolSW.IsRunning) { MoveToPoolSW.Start(); } if (_me.IsSwimming) { if (_me.GetMirrorTimerInfo(MirrorTimerType.Breath).CurrentTime > 0) { WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend); } else if (_me.MovementInfo.IsAscending || _me.MovementInfo.JumpingOrShortFalling) { WoWMovement.MoveStop(WoWMovement.MovementDirection.JumpAscend); } } if (AutoAngler.Instance.MySettings.Fly) { // don't bother mounting up if we can use navigator to walk over if it's less than 25 units away if (_me.Location.Distance(PoolPoints[0]) < 25 && !_me.Mounted) { MoveResult moveResult = Navigator.MoveTo(PoolPoints[0]); if (moveResult == MoveResult.Failed || moveResult == MoveResult.PathGenerationFailed) { Flightor.MountHelper.MountUp(); } else { return(RunStatus.Success); } } else if (!_me.Mounted && !SpellManager.GlobalCooldown) { Flightor.MountHelper.MountUp(); } Flightor.MoveTo(WoWMathHelper.CalculatePointFrom(_me.Location, PoolPoints[0], -1f)); } else { if (!StyxWoW.Me.Mounted && Mount.ShouldMount(PoolPoints[0]) && Mount.CanMount()) { Mount.MountUp(() => PoolPoints[0]); } MoveResult moveResult = Navigator.MoveTo(PoolPoints[0]); if (moveResult == MoveResult.UnstuckAttempt || moveResult == MoveResult.PathGenerationFailed || moveResult == MoveResult.Failed) { if (!RemovePointAtTop(pool)) { return(RunStatus.Success); } AutoAngler.Instance.Debug("Unable to path to pool point, switching to a new point"); PoolPoints.Sort((a, b) => a.Distance(_me.Location).CompareTo(b.Distance(_me.Location))); } } // if it takes more than 25 seconds to get to a point remove that point and try another. if (MoveToPoolSW.ElapsedMilliseconds > 25000) { if (!RemovePointAtTop(pool)) { return(RunStatus.Failure); } MoveToPoolSW.Reset(); MoveToPoolSW.Start(); } return(RunStatus.Success); } // allow small delay so clickToMove can run its course before dismounting. better landing precision.. if (!_movetoConcludingSW.IsRunning) { _movetoConcludingSW.Start(); } if (_movetoConcludingSW.ElapsedMilliseconds < 1500) { if (_me.Location.Distance2D(PoolPoints[0]) > 0.5) { WoWMovement.ClickToMove(PoolPoints[0]); } return(RunStatus.Success); } if (_me.Mounted) { if (_me.Class == WoWClass.Druid && (_me.Shapeshift == ShapeshiftForm.FlightForm || _me.Shapeshift == ShapeshiftForm.EpicFlightForm)) { Lua.DoString("CancelShapeshiftForm()"); } else { Lua.DoString("Dismount()"); } } // can't fish while swimming.. if (_me.IsSwimming && !WaterWalking.CanCast) { AutoAngler.Instance.Debug("Moving to new PoolPoint since I'm swimming at current PoolPoint"); RemovePointAtTop(pool); return(RunStatus.Success); } return(RunStatus.Failure); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Decorator(c => Npc != null, new Action(c => { if (!Npc.Attackable) { Blacklist.Add(Npc.Guid, new TimeSpan(0, 5, 0)); } if ((Me.Combat && (Me.GotTarget && Me.CurrentTarget != Npc && !MobIds.Contains((int)Me.CurrentTarget.Entry)) || Me.HealthPercent < HealthPercent) || IsDone) { return RunStatus.Success; } WoWUnit lootable = ObjectManager.GetObjectsOfType <WoWUnit>().OrderBy(u => u.Distance). FirstOrDefault(u => u.Lootable); if (lootable != null) { if (!lootable.WithinInteractRange) { if (Npc.Distance < 30 && SpellManager.CanCast("Death Grip")) { SpellManager.Cast("Death Grip"); WoWMovement.MoveStop(); } else { Navigator.MoveTo(lootable.Location); } } else { lootable.Interact(); } if (Logic.Inventory.Frames.LootFrame.LootFrame.Instance != null && Logic.Inventory.Frames.LootFrame.LootFrame.Instance.IsVisible) { Logic.Inventory.Frames.LootFrame.LootFrame.Instance.LootAll(); if (Me.GotTarget) { Blacklist.Add(Me.CurrentTarget, new TimeSpan(1, 0, 0)); } Me.ClearTarget(); } return RunStatus.Running; } if (!Me.GotTarget || Me.CurrentTarget != Npc) { Npc.Target(); } if (!Npc.WithinInteractRange) { TreeRoot.GoalText = string.Format("Moving to {0}", Npc.Name); Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, Npc.Location, 3)); } else { if (Me.IsMoving) { WoWMovement.MoveStop(); } if (!Me.IsAutoAttacking || !Me.IsSafelyFacing(ObjectManager.Me.CurrentTarget)) { TreeRoot.GoalText = string.Format("Bullying {0}", Npc.Name); Npc.Interact(); } } return RunStatus.Running; })), new Action(c => Navigator.MoveTo(Location)) ))); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Decorator(ret => Counter > NumOfTimes && QuestId == 0, new Action(ret => _isBehaviorDone = true)), new Decorator( ret => UseType == QBType.Current, new PrioritySelector( new Decorator( new Sequence( new Action(ret => TreeRoot.StatusText = "Using Pet Ability:" + " " + Counter + " Out of " + NumOfTimes + " Times"), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Counter++), new Action(ret => Thread.Sleep(WaitTime))) ))), new Decorator( ret => UseType == QBType.Location, new PrioritySelector( new Decorator( ret => Me.Location.Distance(MoveToLocation) > 3, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving To Use Ability at Location, Distance: " + MoveToLocation.Distance(Me.Location)), new Action(ret => Navigator.MoveTo(MoveToLocation)))), new Sequence( new Action(ret => TreeRoot.StatusText = "Using Pet Ability At Location:" + " " + Counter + " Out of " + NumOfTimes + " Times"), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Counter++), new Action(ret => Thread.Sleep(WaitTime))) )), new Decorator( ret => UseType == QBType.ToObject, new PrioritySelector( new Decorator( ret => UseObject == null && Me.Location.DistanceSqr(MoveToLocation) >= 2 * 2, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving To Use Ability around Location. Distance: " + MoveToLocation.Distance(Me.Location)), new Action(ret => Navigator.MoveTo(MoveToLocation)))), new Decorator( ret => UseObject != null, new PrioritySelector( new Decorator( ret => UseObject.DistanceSqr >= Range * Range, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving closer to the Target, Distance: " + MoveToLocation.Distance(Me.Location)), new Action(ret => Navigator.MoveTo(UseObject.Location)))), new Decorator( ret => UseObject.DistanceSqr < MinRange * MinRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Too Close, Backing Up"), new Action(ret => Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, UseObject.Location, (float)MinRange + 2f))) )), new Sequence( new Action(ret => TreeRoot.StatusText = "Using Pet Ability On Target : " + UseObject.Name + " " + Counter + " Out of " + NumOfTimes + " Times"), new Action(ret => UseObject.Target()), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => UseObject.Face()), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)), new Action(ret => Counter++), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => _npcBlacklist.Add(UseObject.Guid)), new Action(ret => Thread.Sleep(WaitTime))))), new Action(ret => TreeRoot.StatusText = "No objects around. Waiting") )) ))); }
public Composite CreateFrostMageCombat() { WantedPet = "Water Elemental"; return(new PrioritySelector( CreateEnsureTarget(), //Move away from frozen targets new Decorator( ret => (Me.CurrentTarget.HasAura("Frost Nova") || Me.CurrentTarget.HasAura("Freeze")) && Me.CurrentTarget.DistanceSqr < 5 * 5, new Action( ret => { Logger.Write("Getting away from frozen target"); WoWPoint moveTo = WoWMathHelper.CalculatePointFrom(Me.Location, Me.CurrentTarget.Location, 10f); if (Navigator.CanNavigateFully(Me.Location, moveTo)) { Navigator.MoveTo(moveTo); } })), CreateMoveToAndFace(34f, ret => Me.CurrentTarget), CreateWaitForCast(true), CreateCastPetActionOnLocation("Freeze", ret => !Me.CurrentTarget.HasAura("Frost Nova")), CreateSpellBuff("Frost Nova", ret => NearbyUnfriendlyUnits.Any(u => u.DistanceSqr <= 8 * 8)), CreateMagePolymorphOnAddBehavior(), new Decorator( ret => !Me.GotAlivePet, new Action(ret => PetManager.CallPet(WantedPet))), CreateSpellCast("Evocation", ret => Me.ManaPercent < 20), CreateSpellCast("Counterspell", ret => Me.CurrentTarget.IsCasting), CreateSpellCast("Mirror Image"), CreateSpellCast("Time Warp"), new Decorator( ret => Me.CurrentTarget.HealthPercent > 50, new Sequence( new Action(ctx => Me.CurrentTarget.Face()), new Action(ctx => StyxWoW.SleepForLagDuration()), new PrioritySelector(CreateSpellCast("Flame Orb")) )), CreateSpellBuffOnSelf("Ice Barrier", ret => !Me.Auras.ContainsKey("Mana Shield")), CreateSpellBuffOnSelf("Mana Shield", ret => !Me.Auras.ContainsKey("Ice Barrier") && Me.HealthPercent <= 50), CreateSpellCast( "Deep Freeze", ret => (Me.ActiveAuras.ContainsKey("Fingers of Frost") || Me.CurrentTarget.HasAura("Frost Nova") || Me.CurrentTarget.HasAura("Freeze"))), CreateSpellCast( "Ice Lance", ret => (Me.ActiveAuras.ContainsKey("Fingers of Frost") || Me.CurrentTarget.ActiveAuras.ContainsKey("Frost Nova") || Me.CurrentTarget.ActiveAuras.ContainsKey("Freeze"))), //CreateSpellCast("Fireball", Me.ActiveAuras.ContainsKey("Brain Freeze")), CreateSpellCast("Arcane Missiles", ret => Me.ActiveAuras.ContainsKey("Arcane Missiles!")), new Decorator( ret => Me.ActiveAuras.ContainsKey("Brain Freeze"), new PrioritySelector( CreateSpellCast("Frostfire Bolt"), CreateSpellCast("Fireball") )), CreateSpellBuff("Fire Blast", ret => Me.CurrentTarget.HealthPercent < 10), CreateSpellCast("Frostbolt") )); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( // if not in a turret than move to one and interact with it new Decorator(ret => !InVehicle, new Sequence(ctx => GetMustang(), // set Turret as context new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr > 5 * 5, new Action(ctx => { Navigator.MoveTo(((WoWUnit)ctx).Location); TreeRoot.StatusText = "Moving To Mustang"; })), new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr <= 5 * 5, new Action(ctx => { Logging.Write("Interacting with Mustang"); if (Me.Mounted) { Mount.Dismount(); } ((WoWUnit)ctx).Interact(); })))), // Find the nearest spider new PrioritySelector(ctx => ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.IsAlive && !_blackList.Contains(u.Guid) && u.Entry == 44284).OrderBy(u => u.DistanceSqr).FirstOrDefault(), new Decorator(ctx => ctx == null, new Action(ctx => Navigator.MoveTo(_spiderLocation))), new Decorator(ctx => ctx != null, new Sequence( new Action(ctx => TreeRoot.StatusText = "Scaring spider towards lumber mill"), new Action(ctx => { var unit = ctx as WoWUnit; if (unit != null && unit.IsValid && unit.IsAlive) { // move to a point that places the spider between player and lumber mill var movetoPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation, unit.Location, -5); // blacklist spider if its not moving if (DateTime.Now - _stuckTimeStamp > TimeSpan.FromSeconds(6)) { _stuckTimeStamp = DateTime.Now; if (movetoPoint.DistanceSqr(_lastMovetoPoint) < 2 * 2) { Logging.Write("Blacklisting spider"); _blackList.Add(unit.Guid); return RunStatus.Failure; } _lastMovetoPoint = movetoPoint; } if (movetoPoint.DistanceSqr(Me.Location) > 6 * 6) { Navigator.MoveTo(movetoPoint); } else { using (new FrameLock()) { //WoWMovement.MoveStop(); //Me.SetFacing(_lumberMillLocation); Lua.DoString("CastSpellByID(83605)"); } } return RunStatus.Running; } return RunStatus.Failure; }))))))); }
protected override RunStatus Run(object context) { if (!IsDone) { if (!TimeoutSW.IsRunning) { TimeoutSW.Start(); } if (TimeoutSW.ElapsedMilliseconds > 300000) { IsDone = true; } WoWPoint movetoPoint = loc; if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox) .OrderBy(o => o.Distance).FirstOrDefault(); } else { mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(loc) < 10) .OrderBy(o => o.Distance).FirstOrDefault(); } if (mailbox != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(me.Location, mailbox.Location, 3); } if (movetoPoint == WoWPoint.Zero) { return(RunStatus.Failure); } if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5) { Util.MoveTo(movetoPoint); } else if (mailbox != null) { mailbox.Interact(); } return(RunStatus.Running); } else { if (_idList == null) { _idList = BuildItemList(); } if (!_refreshInboxSW.IsRunning) { _refreshInboxSW.Start(); } if (!WaitForContentToShowSW.IsRunning) { WaitForContentToShowSW.Start(); } if (WaitForContentToShowSW.ElapsedMilliseconds < 3000) { return(RunStatus.Running); } uint freeslots = ObjectManager.Me.FreeNormalBagSlots; if (!ConcludingSW.IsRunning) { if (_refreshInboxSW.ElapsedMilliseconds < 61000) { if (GetMailType == GetMailActionType.AllItems) { string lua = string.Format("local totalItems,numItems = GetInboxNumItems() local foundMail=0 for index=1,numItems do local _,_,sender,subj,gold,cod,_,itemCnt,_,_,hasText=GetInboxHeaderInfo(index) if sender ~= nil and cod == 0 and itemCnt == nil and gold == 0 and hasText == nil then DeleteInboxItem(index) end if cod == 0 and ((itemCnt and itemCnt >0) or (gold and gold > 0)) then AutoLootMailItem(index) foundMail = foundMail + 1 break end end local beans = BeanCounterMail and BeanCounterMail:IsVisible() if foundMail == 0 {0}and totalItems == numItems and beans ~= 1 then return 1 else return 0 end ", CheckNewMail ? "and HasNewMail() == nil " : ""); //freeslots / 2 >= MinFreeBagSlots ? (freeslots - MinFreeBagSlots) / 2 : 1); if (Lua.GetReturnValues(lua)[0] == "1" || ObjectManager.Me.FreeNormalBagSlots <= MinFreeBagSlots) { ConcludingSW.Start(); } } else { for (int i = 0; i < _idList.Count; i++) { string lua = string.Format("local totalItems,numItems = GetInboxNumItems() local foundMail=0 for index=1,numItems do local _,_,sender,subj,gold,cod,_,itemCnt,_,_,hasText=GetInboxHeaderInfo(index) if sender ~= nil and cod == 0 and itemCnt == nil and gold == 0 and hasText == nil then DeleteInboxItem(index) end if cod == 0 and itemCnt and itemCnt >0 then for i2=1,itemCnt do local itemlink = GetInboxItemLink(index, i2) if string.find(itemlink,'{0}') then foundMail = foundMail + 1 TakeInboxItem(index, i2) break end end end end if (foundMail == 0 {1}) or (foundMail == 0 and (numItems == 50 and totalItems >= 50)) then return 1 else return 0 end ", //, Entry, freeslots / 2 >= MinFreeBagSlots ? (freeslots - MinFreeBagSlots) / 2 : 1); _idList[i], CheckNewMail ? "and HasNewMail() == nil " : ""); if (Lua.GetReturnValues(lua)[0] == "1" || ObjectManager.Me.FreeNormalBagSlots <= MinFreeBagSlots) { _idList.RemoveAt(i); } } if (_idList.Count == 0) { ConcludingSW.Start(); } } } else { _refreshInboxSW.Reset(); MailFrame.Instance.Close(); } } if (ConcludingSW.ElapsedMilliseconds > 2000) { IsDone = true; } if (IsDone) { Professionbuddy.Log("Mail retrieval of items:{0} finished", GetMailType); } else { return(RunStatus.Running); } } } return(RunStatus.Failure); }
protected Composite CreateCombatBehavior() { // NB: This behavior is hooked in at a 'higher priority' than Combat_Main. We need this // because it is sometimes more important to avoid things than fight. // NB: We might be in combat with nothing to fight immediately after initiating the event. // Be aware of this when altering this behavior. bool shadowFogActive = false; // WoWUnit prophet = null; WoWUnit crowStorm = null; return(new PrioritySelector( ctx => { shadowFogActive = ObjectManager.GetObjectsOfType <WoWUnit>().Any(u => u.Entry == InvisibleManId && u.HasAura("Shadow Fog")); return ProphetKharzul; }, new Decorator <WoWUnit>( prophet => prophet != null && prophet.ThreatInfo.ThreatValue > 0, new PrioritySelector( new Decorator( ctx => shadowFogActive, new PrioritySelector( // check if we need to move to platform during Shadow Fog. Ignore Shadow Fog if the prophet is not within melee range of the platform and I'm a melee. new Decorator <WoWUnit>( prophet => Me.Location.Distance(_platformPoint) > 2 || Me.Z < 33, new PrioritySelector( new Decorator(ctx => _platformPoint.Distance(Me.Location) > 20, new Action(ctx => Navigator.MoveTo(_prophetLocation))), new Decorator( ctx => _platformPoint.Distance(Me.Location) <= 20, new Action <WoWUnit>(prophet => { if (Query.IsMeleeSpec(Me.Specialization) && prophet.Location.Distance(_platformPoint) >= MeleeRange(prophet)) { QBCLog.Info("I am melee and Prophet K is not within melee range of platform so I will ignore shadow fog"); return RunStatus.Failure; } TreeRoot.StatusText = "Moving to platform"; Navigator.PlayerMover.MoveTowards(_platformPoint); // we need to jump to get up on the platform if (!Me.MovementInfo.IsAscending && _platformPoint.Distance(Me.Location) <= 9 && Me.Z < 33) { WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend); } return RunStatus.Success; })))), // stop jumping after we're on top of platform. new Decorator(ctx => Me.MovementInfo.IsAscending, new Action(ctx => WoWMovement.MoveStop(WoWMovement.MovementDirection.JumpAscend))))), // Handle Crow Storm. Assume the crow storm is placed on top of platform... new Decorator( ctx => (crowStorm = ObjectManager.GetObjectsOfType <WoWUnit>().FirstOrDefault(u => u.Entry == CrowStormId && u.Distance < 6.5f)) != null, new PrioritySelector( new ActionSetActivity("Moving out of Crow Storm"), new Action <WoWUnit>(prophet => Navigator.PlayerMover.MoveTowards(WoWMathHelper.CalculatePointFrom(prophet.Location, crowStorm.Location, 7.5f))))))))); }
private async Task <bool> ScareSpiders() { // if not in a turret than move to one and interact with it if (!Query.IsInVehicle()) { var mustang = GetMustang(); if (mustang == null) { QBCLog.Warning("No mustang was found nearby"); return(false); } TreeRoot.StatusText = "Moving To Mustang"; if (mustang.DistanceSqr > 5 * 5) { return((await CommonCoroutines.MoveTo(mustang.Location)).IsSuccessful()); } await CommonCoroutines.LandAndDismount(); QBCLog.Info("Interacting with Mustang"); mustang.Interact(); return(true); } // Find the nearest spider and if none exist then move to the spawn location if (!Query.IsViable(_currentTarget) || !_currentTarget.IsAlive) { _currentTarget = ObjectManager.GetObjectsOfType <WoWUnit>() .Where(u => u.IsAlive && u.Entry == 44284 && !Blacklist.Contains(u, BlacklistFlags.Interact)) .OrderBy(u => u.DistanceSqr).FirstOrDefault(); if (_currentTarget == null) { if (!Navigator.AtLocation(_spiderSpawnLocation)) { return((await CommonCoroutines.MoveTo(_spiderSpawnLocation)).IsSuccessful()); } TreeRoot.StatusText = "Waiting for spiders to spawn"; return(true); } _noMoveBlacklistTimer.Reset(); _blacklistTimer.Reset(); QBCLog.Info("Locked on a new target. Distance {0}", _currentTarget.Distance); } TreeRoot.StatusText = "Scaring spider towards lumber mill"; var moveToPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation, _currentTarget.Location, -6); if (moveToPoint.DistanceSquared((WoWMovement.ActiveMover ?? StyxWoW.Me).Location) > 4 * 4) { return((await CommonCoroutines.MoveTo(moveToPoint)).IsSuccessful()); } // spider not moving? blacklist and find a new target. if (_noMoveBlacklistTimer.ElapsedMilliseconds > 20000 && _currentTarget.Location.DistanceSquared(_spiderScareLoc) < 10 * 10) { Blacklist.Add(_currentTarget, BlacklistFlags.Interact, TimeSpan.FromMinutes(3), "Spider is not moving"); _currentTarget = null; } else if (_blacklistTimer.IsFinished) { Blacklist.Add(_currentTarget, BlacklistFlags.Interact, TimeSpan.FromMinutes(3), "Took too long"); _currentTarget = null; } else if (!_currentTarget.HasAura("Fear")) { await CommonCoroutines.StopMoving(); Me.SetFacing(_lumberMillLocation); await CommonCoroutines.SleepForLagDuration(); await Coroutine.Sleep(200); if (!_noMoveBlacklistTimer.IsRunning || _currentTarget.Location.DistanceSquared(_spiderScareLoc) >= 10 * 10) { _noMoveBlacklistTimer.Restart(); _spiderScareLoc = _currentTarget.Location; } Lua.DoString("CastSpellByID(83605)"); await Coroutine.Wait(3000, () => Query.IsViable(_currentTarget) && _currentTarget.HasAura("Fear")); } return(true); }
Stopwatch _concludingSw = new Stopwatch();// add pause at the end to give objectmanager a chance to update. protected override RunStatus Run(object context) { if (!IsDone) { if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible) { WoWPoint movetoPoint = loc; WoWUnit unit = null; unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry). OrderBy(o => o.Distance).FirstOrDefault(); if (unit != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(me.Location, unit.Location, 3); } else if (movetoPoint == WoWPoint.Zero) { movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry); } if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5) { Util.MoveTo(movetoPoint); } else if (unit != null) { unit.Target(); unit.Interact(); } if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible && GossipFrame.Instance.GossipOptionEntries != null) { foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries) { if (ge.Type == GossipEntry.GossipEntryType.Vendor) { GossipFrame.Instance.SelectGossipOption(ge.Index); break; } } } } else { if (!_concludingSw.IsRunning) { if (BuyItemType == BuyItemActionType.SpecificItem) { List <uint> idList = new List <uint>(); string[] entries = ItemID.Split(','); if (entries != null && entries.Length > 0) { foreach (var entry in entries) { uint temp = 0; uint.TryParse(entry.Trim(), out temp); idList.Add(temp); } } else { Professionbuddy.Err("No ItemIDs are specified"); IsDone = true; return(RunStatus.Failure); } foreach (uint id in idList) { buyItem(id, !BuyAdditively ? Count - Util.GetCarriedItemCount(id) : Count); } } else if (BuyItemType == BuyItemActionType.Material) { foreach (var kv in Pb.MaterialList) { // only buy items if we don't have enough in bags... int amount = kv.Value - (int)Ingredient.GetInBagItemCount(kv.Key); if (amount > 0) { buyItem(kv.Key, (uint)amount); } } } _concludingSw.Start(); } if (_concludingSw.ElapsedMilliseconds >= 2000) { Professionbuddy.Log("BuyItemAction Completed "); IsDone = true; } } if (!IsDone) { return(RunStatus.Running); } } return(RunStatus.Failure); }
public static Composite CreateHolyHealOnlyBehavior(bool selfOnly, bool moveInRange) { HealerManager.NeedHealTargeting = true; WoWUnit healTarget = null; return(new PrioritySelector( ret => healTarget = selfOnly ? StyxWoW.Me : HealerManager.Instance.FirstUnit, new Decorator( ret => healTarget != null && (moveInRange || healTarget.InLineOfSpellSight && healTarget.DistanceSqr < 40 * 40), new PrioritySelector( Spell.WaitForCast(), new Decorator( ret => moveInRange, Movement.CreateMoveToLosBehavior(ret => healTarget)), // use fade to drop aggro. Spell.Cast("Fade", ret => (StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid) && StyxWoW.Me.CurrentMap.IsInstance && Targeting.GetAggroOnMeWithin(StyxWoW.Me.Location, 30) > 0), Spell.Cast("Mindbender", ret => StyxWoW.Me.ManaPercent <= 80 && StyxWoW.Me.GotTarget), Spell.Cast("Shadowfiend", ret => StyxWoW.Me.ManaPercent <= 80 && StyxWoW.Me.GotTarget), Spell.BuffSelf("Desperate Prayer", ret => StyxWoW.Me.GetPredictedHealthPercent() <= 50), Spell.BuffSelf("Hymn of Hope", ret => StyxWoW.Me.ManaPercent <= 15 && (!SpellManager.HasSpell("Shadowfiend") || SpellManager.Spells["Shadowfiend"].Cooldown)), Spell.BuffSelf("Divine Hymn", ret => Unit.NearbyFriendlyPlayers.Count(p => p.GetPredictedHealthPercent() <= SingularSettings.Instance.Priest.DivineHymnHealth) >= SingularSettings.Instance.Priest.DivineHymnCount), Spell.BuffSelf("Chakra: Sanctuary"), // all 3 are avail with a cd in holy - add them to the UI manager for holy priest - default Sanctuary Spell.Cast( "Prayer of Mending", ret => healTarget, ret => ret is WoWPlayer && Group.Tanks.Contains((WoWPlayer)ret) && !((WoWUnit)ret).HasMyAura("Prayer of Mending", 3) && Group.Tanks.Where(t => t != healTarget).All(p => !p.HasMyAura("Prayer of Mending"))), Spell.Heal( "Renew", ret => healTarget, ret => healTarget is WoWPlayer && Group.Tanks.Contains(healTarget) && !healTarget.HasMyAura("Renew")), Spell.Heal("Prayer of Healing", ret => healTarget, ret => StyxWoW.Me.HasAura("Serendipity", 2) && Unit.NearbyFriendlyPlayers.Count(p => p.GetPredictedHealthPercent() <= SingularSettings.Instance.Priest.PrayerOfHealingSerendipityHealth) >= SingularSettings.Instance.Priest.PrayerOfHealingSerendipityCount), Spell.Heal("Circle of Healing", ret => healTarget, ret => Unit.NearbyFriendlyPlayers.Count(p => p.GetPredictedHealthPercent() <= SingularSettings.Instance.Priest.CircleOfHealingHealth) >= SingularSettings.Instance.Priest.CircleOfHealingCount), Spell.CastOnGround( "Holy Word: Sanctuary", ret => Clusters.GetBestUnitForCluster(Unit.NearbyFriendlyPlayers.Select(p => p.ToUnit()), ClusterType.Radius, 10f).Location, ret => Clusters.GetClusterCount(healTarget, Unit.NearbyFriendlyPlayers.Select(p => p.ToUnit()), ClusterType.Radius, 10f) >= 4), Spell.Heal( "Holy Word: Serenity", ret => healTarget, ret => ret is WoWPlayer && Group.Tanks.Contains(healTarget)), Spell.Buff("Guardian Spirit", ret => healTarget, ret => healTarget.GetPredictedHealthPercent() <= 10), Spell.CastOnGround("Lightwell", ret => WoWMathHelper.CalculatePointFrom(StyxWoW.Me.Location, healTarget.Location, 5f)), Spell.Cast("Power Infusion", ret => healTarget.GetPredictedHealthPercent() < 40 || StyxWoW.Me.ManaPercent <= 20), Spell.Heal( "Flash Heal", ret => healTarget, ret => StyxWoW.Me.HasAura("Surge of Light") && healTarget.GetPredictedHealthPercent() <= 90), Spell.Heal( "Flash Heal", ret => healTarget, ret => healTarget.GetPredictedHealthPercent() < SingularSettings.Instance.Priest.HolyFlashHeal), Spell.Heal( "Greater Heal", ret => healTarget, ret => healTarget.GetPredictedHealthPercent() < SingularSettings.Instance.Priest.HolyGreaterHeal), Spell.Heal( "Heal", ret => healTarget, ret => healTarget.GetPredictedHealthPercent() < SingularSettings.Instance.Priest.HolyHeal), new Decorator( ret => StyxWoW.Me.Combat && StyxWoW.Me.GotTarget && Unit.NearbyFriendlyPlayers.Count(u => u.IsInMyPartyOrRaid) == 0, new PrioritySelector( Movement.CreateMoveToLosBehavior(), Movement.CreateFaceTargetBehavior(), Helpers.Common.CreateInterruptSpellCast(ret => StyxWoW.Me.CurrentTarget), Spell.Cast("Shadow Word: Death", ret => StyxWoW.Me.CurrentTarget.GetPredictedHealthPercent() <= 20), Spell.Buff("Shadow Word: Pain", true, ret => SpellManager.HasSpell("Power Word: Solace")), Spell.Cast("Holy Word: Chastise"), Spell.Cast("Mindbender"), Spell.Cast("Holy Fire"), Spell.Cast("Power Word: Solace"), Spell.Cast("Smite", ret => !SpellManager.HasSpell("Power Word: Solace")), Spell.Cast("Mind Spike", ret => !SpellManager.HasSpell("Power Word: Solace")), Movement.CreateMoveToTargetBehavior(true, 35f) )), new Decorator( ret => moveInRange, Movement.CreateMoveToTargetBehavior(true, 35f, ret => healTarget)) // Divine Hymn // Desperate Prayer // Prayer of Mending // Prayer of Healing // Power Word: Barrier // TODO: Add smite healing. Only if Atonement is talented. (Its useless otherwise) )))); }
protected override RunStatus Run(object context) { if (!IsDone) { if (TrainerFrame.Instance == null || !TrainerFrame.Instance.IsVisible || !ObjectManager.Me.GotTarget || (ObjectManager.Me.GotTarget && ObjectManager.Me.CurrentTarget.Entry != NpcEntry)) { WoWPoint movetoPoint = _loc; WoWUnit unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry). OrderBy(o => o.Distance).FirstOrDefault(); if (unit != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, unit.Location, 3); } else if (movetoPoint == WoWPoint.Zero) { movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry); } if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5) { Util.MoveTo(movetoPoint); } else if (unit != null) { if (Me.IsMoving) { WoWMovement.MoveStop(); } unit.Target(); unit.Interact(); } if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible && GossipFrame.Instance.GossipOptionEntries != null) { foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries) { if (ge.Type == GossipEntry.GossipEntryType.Trainer) { GossipFrame.Instance.SelectGossipOption(ge.Index); return(RunStatus.Success); } } } return(RunStatus.Success); } if (_trainWaitTimer.IsFinished) { using (new FrameLock()) { Lua.DoString("SetTrainerServiceTypeFilter('available', 1)"); // check if there is any abilities to that need training. var numOfAvailableAbilities = Lua.GetReturnVal <int>( "local a=0 for n=GetNumTrainerServices(),1,-1 do if select(3,GetTrainerServiceInfo(n)) == 'available' then a=a+1 end end return a ", 0); if (numOfAvailableAbilities == 0) { IsDone = true; Professionbuddy.Log("Done training"); return(RunStatus.Failure); } Lua.DoString("BuyTrainerService(0) "); _trainWaitTimer.Reset(); } } return(RunStatus.Success); } return(RunStatus.Failure); }
public static bool InteractAndSell(uint unitID, SellItemActionType SellItemType, uint OptionalItemEntry, uint Count) // Count - for "SellItemActionType.Specific" { // while (!Me.Combat && ) // Thread.Sleep(100); if (!IsDone) { if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible) { WoWPoint movetoPoint = Me.Location; WoWUnit unit = null; unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == unitID). OrderBy(o => o.Distance).FirstOrDefault(); if (unit != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, unit.Location, 3); } else if (movetoPoint == WoWPoint.Zero) { movetoPoint = GetLocationFromDB(MoveToType.NpcByID, unitID); } if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5) { Navigator.MoveTo(movetoPoint); // Util.MoveTo(movetoPoint); } else if (unit != null) { // open selling interface: unit.Target(); unit.Interact(); } if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible) { foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries) { if (ge.Type == GossipEntry.GossipEntryType.Vendor) { GossipFrame.Instance.SelectGossipOption(ge.Index); break; } } } } else { if (SellItemType == SellItemActionType.Specific) { List <WoWItem> itemList = ObjectManager.Me.BagItems.Where(u => u.Entry == OptionalItemEntry).Take((int)Count).ToList(); if (itemList != null) { using (new FrameLock()) { foreach (WoWItem item in itemList) { item.UseContainerItem(); } } } } else { List <WoWItem> itemList = null; IEnumerable <WoWItem> itemQuery = from item in Me.BagItems where !ProtectedItems.Contains(item.Entry) select item; switch (SellItemType) { case SellItemActionType.Greys: itemList = itemQuery.Where(i => i != null && i.IsValid && (i.Quality == WoWItemQuality.Poor)).ToList(); break; case SellItemActionType.Whites: itemList = itemQuery.Where(i => i != null && i.IsValid && (i.Quality == WoWItemQuality.Common || i.Quality == WoWItemQuality.Poor)).ToList(); break; case SellItemActionType.Greens: itemList = itemQuery.Where(i => i != null && i.IsValid && (i.Quality == WoWItemQuality.Uncommon || i.Quality == WoWItemQuality.Common || i.Quality == WoWItemQuality.Poor)).ToList(); break; } if (itemList != null) { using (new FrameLock()) { foreach (WoWItem item in itemList) { item.UseContainerItem(); } } } } Logging.Write("SellItemAction Completed "); IsDone = true; return(true); } if (IsDone) { Lua.DoString("CloseMerchant()"); } else { return(false); } } return(false); }
protected override RunStatus Run(object context) { if (!IsDone) { WoWObject obj = null; if (InteractType == InteractActionType.NPC) { if (Entry != 0) { obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.Entry == Entry).OrderBy( u => u.Distance).FirstOrDefault(); } else if (ObjectManager.Me.GotTarget) { obj = ObjectManager.Me.CurrentTarget; } } else if (InteractType == InteractActionType.GameObject) { obj = ObjectManager.GetObjectsOfType <WoWGameObject>().OrderBy(u => u.Distance).FirstOrDefault( u => (Entry > 0 && u.Entry == Entry) || (u.SubType == GameObjectType && (GameObjectType != WoWGameObjectType.SpellFocus || (GameObjectType == WoWGameObjectType.SpellFocus && u.SpellFocus == SpellFocus)))); } if (obj != null) { if (!obj.WithinInteractRange) { Util.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, obj.Location, 3)); } else { if (InteractDelay > 0 && (!_interactSw.IsRunning || _interactSw.ElapsedMilliseconds < InteractDelay)) { _interactSw.Start(); } else { _interactSw.Reset(); if (InteractType == InteractActionType.NPC) { Lua.DoString("InteractUnit({0})", obj.Entry); } else { obj.Interact(); } IsDone = true; } } } if (!IsDone) { return(RunStatus.Success); } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { if (!_timeoutSW.IsRunning) { _timeoutSW.Start(); } if (_timeoutSW.ElapsedMilliseconds > 300000) { IsDone = true; } WoWPoint movetoPoint = _loc; if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox) .OrderBy(o => o.Distance).FirstOrDefault(); } else { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(_loc) < 10) .OrderBy(o => o.Distance).FirstOrDefault(); } if (_mailbox != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, _mailbox.Location, 3); } if (movetoPoint == WoWPoint.Zero) { Professionbuddy.Err(Pb.Strings["Error_UnableToFindMailbox"]); return(RunStatus.Failure); } if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5) { Util.MoveTo(movetoPoint); } else if (_mailbox != null) { _mailbox.Interact(); } return(RunStatus.Success); } // mail frame is open. if (_idList == null) { _idList = BuildItemList(); } if (!_refreshInboxSW.IsRunning) { _refreshInboxSW.Start(); } if (!_waitForContentToShowSW.IsRunning) { _waitForContentToShowSW.Start(); } if (_waitForContentToShowSW.ElapsedMilliseconds < 3000) { return(RunStatus.Success); } if (!_concludingSW.IsRunning) { if (_refreshInboxSW.ElapsedMilliseconds < 64000) { if (MinFreeBagSlots > 0 && Me.FreeNormalBagSlots - MinFreeBagSlots <= 4) { if (!_throttleSW.IsRunning) { _throttleSW.Start(); } if (_throttleSW.ElapsedMilliseconds < 4000 - (Me.FreeNormalBagSlots - MinFreeBagSlots) * 1000) { return(RunStatus.Success); } _throttleSW.Reset(); _throttleSW.Start(); } if (GetMailType == GetMailActionType.AllItems) { string lua = string.Format(MailFormat, CheckNewMail ? 1 : 0); if (Me.FreeNormalBagSlots <= MinFreeBagSlots || Lua.GetReturnValues(lua)[0] == "1") { _concludingSW.Start(); } } else { if (_idList.Count > 0 && Me.FreeNormalBagSlots > MinFreeBagSlots) { string lua = string.Format(MailByIdFormat, _idList[0], CheckNewMail ? 1 : 0); if (Lua.GetReturnValues(lua)[0] == "1") { _idList.RemoveAt(0); } } else { _concludingSW.Start(); } } } else { _refreshInboxSW.Reset(); MailFrame.Instance.Close(); } } if (_concludingSW.ElapsedMilliseconds > 2000) { IsDone = true; } if (IsDone) { Professionbuddy.Log("Mail retrieval of items:{0} finished", GetMailType); } else { return(RunStatus.Success); } } return(RunStatus.Failure); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Decorator( ret => Item == null, new ActionAlwaysSucceed()), new Decorator(ret => Counter > NumOfTimes && QuestId == 0, new Action(ret => _isBehaviorDone = true)), new Decorator( ret => UseType == QBType.PointToPoint, new PrioritySelector( new Decorator( ret => Me.Location.Distance(MoveToLocation) > 3, new Sequence( new Action(ret => TreeRoot.StatusText = "Using Item: " + UseObject.Name + " " + Counter + " Out of " + NumOfTimes + " Times"), new Action(ret => Navigator.MoveTo(MoveToLocation)))), new Sequence( new Action(ret => TreeRoot.StatusText = "Using Item"), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => Me.SetFacing(ClickToLocation)), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Item.UseContainerItem()), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Counter++), new Action(ret => LegacySpellManager.ClickRemoteLocation(ClickToLocation)), new Action(ret => Thread.Sleep(WaitTime))) )), new Decorator( ret => UseType == QBType.PointToObject, new PrioritySelector( new Decorator( ret => UseObject == null && Me.Location.DistanceSqr(MoveToLocation) >= 2 * 2, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving to location"), new Action(ret => Navigator.MoveTo(MoveToLocation)))), new Decorator( ret => UseObject != null, new PrioritySelector( new Decorator( ret => UseObject.DistanceSqr >= Range * Range, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving closer to the object"), new Action(ret => Navigator.MoveTo(UseObject.Location)))), new Decorator( ret => UseObject.DistanceSqr < MinRange * MinRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Too Close, Backing Up"), new Action(ret => Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, UseObject.Location, (float)MinRange + 2f))) )), new Sequence( new Action(ret => TreeRoot.StatusText = "Using Item: " + UseObject.Name + " " + Counter + " Out of " + NumOfTimes + " Times"), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => Me.SetFacing(UseObject.Location)), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Item.UseContainerItem()), new Action(ret => Counter++), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => LegacySpellManager.ClickRemoteLocation(UseObject.Location)), new Action(ret => _npcBlacklist.Add(UseObject.Guid)), new Action(ret => Thread.Sleep(WaitTime))))), new Action(ret => TreeRoot.StatusText = "No objects around. Waiting") )), new Decorator( ret => UseType == QBType.ToObject, new PrioritySelector( new Decorator( ret => UseObject != null, new PrioritySelector( new Decorator( ret => UseObject.DistanceSqr >= Range * Range, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving to object's range"), new Action(ret => Navigator.MoveTo(UseObject.Location)))), new Decorator( ret => UseObject.DistanceSqr < MinRange * MinRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Too Close, Backing Up"), new Action(ret => Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, UseObject.Location, (float)MinRange + 2f))) )), new Sequence( new Action(ret => TreeRoot.StatusText = "Using Item: " + UseObject.Name + " " + Counter + " Out of " + NumOfTimes + " Times"), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => Me.SetFacing(UseObject.Location)), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => Item.UseContainerItem()), new Action(ret => Counter++), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => LegacySpellManager.ClickRemoteLocation(UseObject.Location)), new Action(ret => _npcBlacklist.Add(UseObject.Guid)), new Action(ret => Thread.Sleep(WaitTime))))), new Decorator( ret => Me.Location.DistanceSqr(MoveToLocation) > 2 * 2, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving to location"), new Action(ret => Navigator.MoveTo(MoveToLocation)))) )) ))); }
protected override RunStatus Run(object context) { WoWPoint mboxLoc = BotPoi.Current.Location; WoWGameObject mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>(). FirstOrDefault(m => m.SubType == WoWGameObjectType.Mailbox && m.Location.Distance(mboxLoc) < 10); WoWPoint loc = mailbox != null ? mailbox.Location : mboxLoc; if (_me.Location.Distance(loc) > 4) { if (AutoAngler.Instance.MySettings.Fly) { Flightor.MoveTo(WoWMathHelper.CalculatePointFrom(_me.Location, loc, 3)); } else { if (!StyxWoW.Me.Mounted && Mount.ShouldMount(loc) && Mount.CanMount()) { Mount.MountUp(() => loc); } Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(_me.Location, loc, 4)); } } else { if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (mailbox == null) { AutoAngler.Instance.Log("No Mailbox found at location {0}. Vendoring instead", loc); Vendor ven = ProfileManager.CurrentOuterProfile.VendorManager.GetClosestVendor(); if (ven != null) { BotPoi.Current = new BotPoi(ven, PoiType.Repair); } else { BotPoi.Current = new BotPoi(PoiType.InnKeeper); } return(RunStatus.Failure); } mailbox.Interact(); } else { Vendor ven = ProfileManager.CurrentOuterProfile.VendorManager.GetClosestVendor(); if (ven != null) { // mail all except grey items which we will vendor. MailFrame.Instance.SendMailWithManyAttachments(CharacterSettings.Instance.MailRecipient, 0, _me.BagItems.Where( i => !i.IsSoulbound && !i.IsConjured && i.Quality != WoWItemQuality.Poor && !ProtectedItemsManager.Contains(i.Entry)) . ToArray()); BotPoi.Current = new BotPoi(ven, PoiType.Repair); } else { // mail all since no vender is in profile MailFrame.Instance.SendMailWithManyAttachments(CharacterSettings.Instance.MailRecipient, 0, _me.BagItems.Where( i => !i.IsSoulbound && !i.IsConjured && !ProtectedItemsManager.Contains(i.Entry)) . ToArray()); BotPoi.Current = new BotPoi(PoiType.None); } } } return(RunStatus.Success); }
protected override async Task Run() { if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible) { WoWPoint movetoPoint = _loc; WoWUnit unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry). OrderBy(o => o.Distance).FirstOrDefault(); if (unit != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, unit.Location, 3); } else if (movetoPoint == WoWPoint.Zero) { movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry); } if (movetoPoint != WoWPoint.Zero && StyxWoW.Me.Location.Distance(movetoPoint) > 4.5) { Util.MoveTo(movetoPoint); } else if (unit != null) { unit.Target(); unit.Interact(); } if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible && GossipFrame.Instance.GossipOptionEntries != null) { foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries) { if (ge.Type == GossipEntry.GossipEntryType.Vendor) { GossipFrame.Instance.SelectGossipOption(ge.Index); break; } } } } else { // check if we have merchant frame open at correct NPC if (NpcEntry > 0 && Me.GotTarget && Me.CurrentTarget.Entry != NpcEntry) { MerchantFrame.Instance.Close(); return; } if (!_concludingSw.IsRunning) { if (BuyItemType == BuyItemActionType.SpecificItem) { var idList = new List <uint>(); string[] entries = ItemID.Split(','); if (entries.Length > 0) { foreach (string entry in entries) { uint itemID; if (!uint.TryParse(entry.Trim(), out itemID)) { PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim()); continue; } idList.Add(itemID); } } else { PBLog.Warn(Strings["Error_NoItemEntries"]); IsDone = true; return; } foreach (uint id in idList) { int count = !BuyAdditively?Math.Max(Count - Util.GetCarriedItemCount(id), 0) : Count; if (count > 0) { BuyItem(id, (uint)count); } } } else if (BuyItemType == BuyItemActionType.Material) { foreach (var kv in ProfessionbuddyBot.Instance.MaterialList) { // only buy items if we don't have enough in bags... int amount = kv.Value - (int)Ingredient.GetInBagItemCount(kv.Key); if (amount > 0) { BuyItem(kv.Key, (uint)amount); } } } _concludingSw.Start(); } if (_concludingSw.ElapsedMilliseconds >= 2000) { PBLog.Log("BuyItemAction Completed"); IsDone = true; } } }
protected override Composite CreateMainBehavior() { return(_root ?? (_root = new PrioritySelector( // don't drop down while wait timer is running new Decorator(ctx => !_waitTimer.IsFinished, new ActionAlwaysSucceed()), new Decorator(ret => Counter > NumOfTimes, new Action(ret => BehaviorDone(string.Format("Used the item {0} times", NumOfTimes)))), // If item is not in our backpack, behavior is done... new Decorator(context => Item == null, new Action(context => { QBCLog.Error("ItemId({0}) is not in our backpack", ItemId); TreeRoot.Stop(); BehaviorDone("Item is not in our backpack"); })), // Wait for item to come off of cooldown... new Decorator(context => Item.CooldownTimeLeft > TimeSpan.Zero, new Action(context => QBCLog.Info("Waiting for {0} to leave cooldown (time remaining: {1})", Item.SafeName, Item.CooldownTimeLeft))), new Decorator( ret => UseType == QBType.PointToPoint, new PrioritySelector( new Decorator( ret => Me.Location.Distance(MoveToLocation) > 3, new ActionRunCoroutine(context => UtilityCoroutine.MoveTo(MoveToLocation, "Destination", MovementBy))), new Sequence( new Action(ret => TreeRoot.StatusText = string.Format("Using Quest Item: {0} Out of {1} Times", Counter, NumOfTimes)), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => Me.SetFacing(ClickToLocation)), new SleepForLagDuration(), new Action(ret => Item.UseContainerItem()), new SleepForLagDuration(), new Action(ret => Counter++), new Action(ret => SpellManager.ClickRemoteLocation(ClickToLocation)), new Action(ctx => _waitTimer.Reset()) ))), new Decorator( ret => UseType == QBType.PointToObject, new PrioritySelector( new Decorator( ret => UseObject == null && Me.Location.DistanceSqr(MoveToLocation) >= 2 * 2, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving to location"), new ActionRunCoroutine(context => UtilityCoroutine.MoveTo(MoveToLocation, "Destination", MovementBy)))), new Decorator( ret => UseObject != null, new PrioritySelector( new Decorator( ret => UseObject.DistanceSqr >= Range * Range, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving closer to the object"), new ActionRunCoroutine(context => UtilityCoroutine.MoveTo(UseObject.Location, "UseObject location", MovementBy)))), new Decorator( ret => UseObject.DistanceSqr < MinRange * MinRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Too Close, Backing Up"), new ActionRunCoroutine(context => UtilityCoroutine.MoveTo( WoWMathHelper.CalculatePointFrom(Me.Location, UseObject.Location, (float)MinRange + 2f), "Backing up", MovementBy)) )), new Sequence( new Action(ret => TreeRoot.StatusText = string.Format("Using Item: {0} {1} Out of {2} Times", UseObject.SafeName, Counter, NumOfTimes)), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => Me.SetFacing(UseObject.Location)), new SleepForLagDuration(), new Action(ret => Item.UseContainerItem()), new Action(ret => Counter++), new SleepForLagDuration(), new Action(ret => SpellManager.ClickRemoteLocation(UseObject.Location)), new Action(ret => _npcBlacklist.Add(UseObject.Guid)), new Action(ctx => _waitTimer.Reset())))), new Action(ret => TreeRoot.StatusText = "No objects around. Waiting") )), new Decorator( ret => UseType == QBType.ToObject, new PrioritySelector( new Decorator( ret => UseObject != null, new PrioritySelector( new Decorator( ret => UseObject.DistanceSqr >= Range * Range, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving to object's range"), new ActionRunCoroutine(context => UtilityCoroutine.MoveTo(UseObject.Location, "UseObject location", MovementBy)))), new Decorator( ret => UseObject.DistanceSqr < MinRange * MinRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Too Close, Backing Up"), new ActionRunCoroutine( context => UtilityCoroutine.MoveTo( WoWMathHelper.CalculatePointFrom(Me.Location, UseObject.Location, (float)MinRange + 2f), "Backing up", MovementBy)) )), new Sequence( new Action(ret => TreeRoot.StatusText = string.Format("Using Item: {0} {1} Out of {2} Times", UseObject.SafeName, Counter, NumOfTimes)), new Action(ret => Navigator.PlayerMover.MoveStop()), new Action(ret => Me.SetFacing(UseObject.Location)), new SleepForLagDuration(), new Action(ret => Item.UseContainerItem()), new Action(ret => Counter++), new SleepForLagDuration(), new Action(ret => SpellManager.ClickRemoteLocation(UseObject.Location)), new Action(ret => _npcBlacklist.Add(UseObject.Guid)), new Action(ctx => _waitTimer.Reset())))), new Decorator( ret => Me.Location.DistanceSqr(MoveToLocation) > 2 * 2, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving to location"), new ActionRunCoroutine(context => UtilityCoroutine.MoveTo(MoveToLocation, "Destination", MovementBy)))) )) ))); }
//private static WoWUnit _moveToHealTarget = null; //private static WoWUnit _lastMoveToTarget = null; public static Composite CreateHolyHealOnlyBehavior(bool selfOnly, bool moveInRange) { if (SingularRoutine.CurrentWoWContext == WoWContext.Normal) { return(new ActionAlwaysFail()); } HealerManager.NeedHealTargeting = true; PrioritizedBehaviorList behavs = new PrioritizedBehaviorList(); int cancelHeal = Math.Max(SingularSettings.Instance.IgnoreHealTargetsAboveHealth, Math.Max(PriestSettings.HolyHeal.Heal, PriestSettings.HolyHeal.Renew)); Logger.WriteDebugInBehaviorCreate("Priest Healing: will cancel cast of direct heal if health reaches {0:F1}%", cancelHeal); if (SingularSettings.Instance.DispelDebuffs != RelativePriority.None) { int dispelPriority = (SingularSettings.Instance.DispelDebuffs == RelativePriority.HighPriority) ? 999 : -999; behavs.AddBehavior(dispelPriority, "Dispel", null, Common.CreatePriestDispelBehavior()); } #region Save the Group if (PriestSettings.HolyHeal.DivineHymn != 0) { behavs.AddBehavior(HealthToPriority(PriestSettings.HolyHeal.DivineHymn) + 300, "Divine Hymn @ " + PriestSettings.HolyHeal.DivineHymn + "% MinCount: " + PriestSettings.HolyHeal.CountDivineHymn, "Divine Hymn", new Decorator( ret => StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid, new PrioritySelector( context => HealerManager.GetBestCoverageTarget("Divine Hymn", PriestSettings.HolyHeal.DivineHymn, 0, 40, PriestSettings.HolyHeal.CountDivineHymn), new Decorator( ret => ret != null, Spell.Cast("Divine Hymn", mov => false, on => (WoWUnit)on, req => true, cancel => false) ) ) ) ); } if (PriestSettings.HolyHeal.GuardianSpirit != 0) { behavs.AddBehavior(HealthToPriority(PriestSettings.HolyHeal.GuardianSpirit) + 300, "Guardian Spirit @ " + PriestSettings.HolyHeal.GuardianSpirit + "%", "Guardian Spirit", Spell.Cast("Guardian Spirit", mov => false, on => (WoWUnit)on, req => ((WoWUnit)req).HealthPercent < PriestSettings.HolyHeal.GuardianSpirit ) ); } if (PriestSettings.LightOfTuure != 0) { behavs.AddBehavior(HealthToPriority(PriestSettings.LightOfTuure) + 300, "Light of T'uure @ " + PriestSettings.LightOfTuure + "%", "Light of T'uure", Spell.Cast("Light of T'uure", mov => false, on => (WoWUnit)on, req => ((WoWUnit)req).HealthPercent < PriestSettings.LightOfTuure && !((WoWUnit)req).HasAura("Light of T'uure") && Group.Tanks.Contains(((WoWUnit)req)) ) ); } #endregion #region AoE Heals int maxDirectHeal = Math.Max(PriestSettings.HolyHeal.FlashHeal, PriestSettings.HolyHeal.Heal); // instant, so cast this first ALWAYS if (PriestSettings.HolyHeal.HolyWordSanctify != 0) { behavs.AddBehavior(398, "Holy Word: Sanctify @ " + PriestSettings.HolyHeal.HolyWordSanctify + "% MinCount: " + PriestSettings.HolyHeal.CountHolyWordSanctify, "Holy Word: Sanctify", new Decorator( ret => true, new PrioritySelector( context => HealerManager.GetBestCoverageTarget("Holy Word: Sanctify", PriestSettings.HolyHeal.HolyWordSanctify, 40, 10, PriestSettings.HolyHeal.CountHolyWordSanctify), new Decorator( ret => ret != null, Spell.CastOnGround("Holy Word: Sanctify", on => (WoWUnit)on, req => true, false) ) ) ) ); } if (PriestSettings.HolyHeal.PrayerOfMending != 0) { behavs.AddBehavior(397, "Prayer of Mending @ " + PriestSettings.HolyHeal.PrayerOfMending + "%", "Prayer of Mending", Spell.Cast("Prayer of Mending", mov => true, on => (WoWUnit)on, req => !((WoWUnit)req).IsMe && ((WoWUnit)req).HealthPercent <PriestSettings.HolyHeal.PrayerOfMending, cancel => ((WoWUnit)cancel).HealthPercent> cancelHeal ) ); } /* * behavs.AddBehavior(HealthToPriority(PriestSettings.HolyHeal.HolyLevel90Talent) + 200, "Divine Star", * "Divine Star", * new Decorator( * ret => StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid, * new Decorator( * ret => * Clusters.GetClusterCount(Me, * HealerManager.Instance.TargetList.Where( * u => u.HealthPercent < PriestSettings.HolyHeal.CountLevel90Talent).ToList(), * ClusterType.PathToUnit, 4) >= PriestSettings.HolyHeal.CountLevel90Talent, * Spell.Cast("Divine Star", on => (WoWUnit)on, req => true) * ) * ) * ); */ if (PriestSettings.HolyHeal.HolyLevel90Talent != 0) { behavs.AddBehavior(397, "Halo @ " + PriestSettings.HolyHeal.HolyLevel90Talent + "% MinCount: " + PriestSettings.HolyHeal.CountLevel90Talent, "Halo", new Decorator( ret => StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid, new Decorator( ret => ret != null && HealerManager.Instance.TargetList.Count( u => u.IsAlive && u.HealthPercent < PriestSettings.HolyHeal.HolyLevel90Talent && u.Distance < 30) >= PriestSettings.HolyHeal.CountLevel90Talent && Unit.UnfriendlyUnits(30).Any(u => u.Combat && !u.IsCrowdControlled()), Spell.Cast("Halo", req => true) ) ) ); } if (PriestSettings.HolyHeal.BindingHeal != 0) { behavs.AddBehavior(396, "Binding Heal @ " + PriestSettings.HolyHeal.BindingHeal + "% MinCount: 2", "Binding Heal", Spell.Cast("Binding Heal", mov => true, on => (WoWUnit)on, req => !((WoWUnit)req).IsMe && ((WoWUnit)req).HealthPercent < PriestSettings.HolyHeal.BindingHeal && Me.HealthPercent <PriestSettings.HolyHeal.BindingHeal, cancel => ((WoWUnit)cancel).HealthPercent> cancelHeal ) ); } if (PriestSettings.HolyHeal.CircleOfHealing != 0) { behavs.AddBehavior(395, "Circle of Healing @ " + PriestSettings.HolyHeal.CircleOfHealing + "% MinCount: " + PriestSettings.HolyHeal.CountCircleOfHealing, "Circle of Healing", new Decorator( ret => StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid, new PrioritySelector( context => HealerManager.GetBestCoverageTarget("Circle of Healing", PriestSettings.HolyHeal.CircleOfHealing, 40, 30, PriestSettings.HolyHeal.CountCircleOfHealing), Spell.Cast("Circle of Healing", on => (WoWUnit)on) ) ) ); } if (PriestSettings.HolyHeal.PrayerOfHealing != 0) { behavs.AddBehavior(394, "Prayer of Healing @ " + PriestSettings.HolyHeal.PrayerOfHealing + "% MinCount: " + PriestSettings.HolyHeal.CountPrayerOfHealing, "Prayer of Healing", new Decorator( ret => StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid, new PrioritySelector( context => HealerManager.GetBestCoverageTarget("Prayer of Healing", PriestSettings.HolyHeal.PrayerOfHealing, 40, 20, PriestSettings.HolyHeal.CountPrayerOfHealing), Spell.Cast("Prayer of Healing", on => (WoWUnit)on) ) ) ); } #endregion /* * HolyWordSanctify Holy Word: Sanctify * HolyWordSerenity Holy Word: Serenity * CircleOfHealing Circle of Healing * PrayerOfHealing Prayer of Healing * DivineHymn Divine Hymn * GuardianSpirit Guardian Spirit * VoidShift Void Shift */ #region Direct Heals if (maxDirectHeal != 0) // Nuke a Flash Heal { behavs.AddBehavior(400, "Surge of Light @ " + maxDirectHeal + "%", "Flash Heal", Spell.Cast("Flash Heal", mov => false, on => (WoWUnit)on, req => Me.HasActiveAura("Surge of Light") && ((WoWUnit)req).HealthPercent < 85 ) ); } if (PriestSettings.HolyHeal.HolyWordSerenity != 0) { behavs.AddBehavior(HealthToPriority(1) + 4, "Holy Word: Serenity @ " + PriestSettings.HolyHeal.HolyWordSerenity + "%", "Holy Word: Serenity", Spell.CastHack("Holy Word: Serenity", on => (WoWUnit)on, req => ((WoWUnit)req).HealthPercent < PriestSettings.HolyHeal.HolyWordSerenity ) ); } var cmt = ""; var flashHealHealth = PriestSettings.HolyHeal.FlashHeal; if (!SpellManager.HasSpell("Heal")) { flashHealHealth = Math.Max(flashHealHealth, PriestSettings.HolyHeal.Heal); cmt = "(Adjusted for Heal)"; } if (flashHealHealth != 0) { behavs.AddBehavior(HealthToPriority(PriestSettings.HolyHeal.FlashHeal), "Flash Heal @ " + flashHealHealth + "% " + cmt, "Flash Heal", Spell.Cast("Flash Heal", mov => true, on => (WoWUnit)on, req => ((WoWUnit)req).HealthPercent <flashHealHealth, cancel => ((WoWUnit)cancel).HealthPercent> cancelHeal ) ); } if (PriestSettings.HolyHeal.Heal != 0) { behavs.AddBehavior(HealthToPriority(PriestSettings.HolyHeal.Heal), "Heal @ " + PriestSettings.HolyHeal.Heal + "%", "Heal", Spell.Cast("Heal", mov => true, on => (WoWUnit)on, req => ((WoWUnit)req).HealthPercent <PriestSettings.HolyHeal.Heal, cancel => ((WoWUnit)cancel).HealthPercent> cancelHeal ) ); } #endregion #region Tank - Low Priority Buffs if (PriestSettings.HolyHeal.Renew != 0) { behavs.AddBehavior(HealthToPriority(102), "Tank - Buff Renew @ " + PriestSettings.HolyHeal.Renew + "%", "Renew", // roll Renew on Tanks Spell.Cast("Renew", on => { WoWUnit unit = HealerManager.GetBestTankTargetForHOT("Renew", PriestSettings.HolyHeal.Renew); if (unit != null && Spell.CanCastHack("Renew", unit, skipWowCheck: true)) { Logger.WriteDebug("Buffing RENEW ON TANK: {0}", unit.SafeName()); return(unit); } return(null); }) ); } #endregion #region Lowest Priority Healer Tasks if (SingularRoutine.CurrentWoWContext == WoWContext.Instances) { behavs.AddBehavior(HealthToPriority(103), "Lightwell", "Lightwell", new Throttle(TimeSpan.FromSeconds(20), new Sequence( new Action(r => { _lightwellTarget = Group.Tanks.FirstOrDefault(t => { if (t.IsAlive && t.Combat && t.GotTarget() && t.CurrentTarget.IsBoss()) { if (t.Distance < 40 && t.SpellDistance(t.CurrentTarget) < 15) { Logger.WriteDiagnostic("Lightwell: found target {0}", t.SafeName()); return(true); } } return(false); }); return(_lightwellTarget == null ? RunStatus.Failure : RunStatus.Success); }), Spell.CastOnGround("Lightwell", location => WoWMathHelper.CalculatePointFrom(Me.Location, _lightwellTarget.Location, (float)Math.Min(10.0, _lightwellTarget.Distance / 2)), req => _lightwellTarget != null, false, desc => string.Format("10 yds from {0}", _lightwellTarget.SafeName()) ) ) ) ); } #endregion behavs.OrderBehaviors(); if (selfOnly == false && CompositeBuilder.CurrentBehaviorType == BehaviorType.Combat) { behavs.ListBehaviors(); } return(new PrioritySelector( ctx => selfOnly ? StyxWoW.Me : HealerManager.FindLowestHealthTarget(), // HealerManager.Instance.FirstUnit, Spell.WaitForCastOrChannel(), new Decorator( ret => !Spell.IsGlobalCooldown() && ret != null, behavs.GenerateBehaviorTree() ), new Decorator( ret => moveInRange, Movement.CreateMoveToUnitBehavior( ret => Battlegrounds.IsInsideBattleground ? (WoWUnit)ret : Group.Tanks.Where(a => a.IsAlive).OrderBy(a => a.Distance).FirstOrDefault(), 35f ) ) )); }
protected override RunStatus Run(object context) { if (!IsDone) { WoWPoint movetoPoint = _loc; if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox) .OrderBy(o => o.Distance).FirstOrDefault(); } else { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(_loc) < 10) .OrderBy(o => o.Distance).FirstOrDefault(); } if (_mailbox != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, _mailbox.Location, 3); } if (movetoPoint == WoWPoint.Zero) { Professionbuddy.Err(Pb.Strings["Error_UnableToFindMailbox"]); return(RunStatus.Failure); } if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5) { Util.MoveTo(movetoPoint); } else if (_mailbox != null) { _mailbox.Interact(); } return(RunStatus.Success); } // Mail Frame is open.. // item split in proceess if (_itemSplitSW.IsRunning && _itemSplitSW.ElapsedMilliseconds <= 2000) { return(RunStatus.Success); } if (_itemList == null) { _itemList = BuildItemList(); } if (_itemList.Count == 0) { //Professionbuddy.Debug("Sending any remaining items already in SendMail item slots. Mail subject will be: {0} ",_mailSubject); Lua.DoString( "for i=1,ATTACHMENTS_MAX_SEND do if GetSendMailItem(i) ~= nil then SendMail (\"{0}\",\"{1}\",'') end end ", CharacterSettings.Instance.MailRecipient.ToFormatedUTF8(), _mailSubject != null ? _mailSubject.ToFormatedUTF8() : " "); //Professionbuddy.Debug("Done sending mail"); IsDone = true; return(RunStatus.Failure); } MailFrame.Instance.SwitchToSendMailTab(); uint itemID = _itemList.Keys.FirstOrDefault(); WoWItem item = Me.BagItems.FirstOrDefault(i => i.Entry == itemID); _mailSubject = item != null ? item.Name : " "; if (string.IsNullOrEmpty(_mailSubject)) { _mailSubject = " "; } Professionbuddy.Debug("MailItem: sending {0}", itemID); int ret = MailItem(itemID, _itemList[itemID]); // we need to wait for item split to finish if ret == 0 // format indexs are MailRecipient=0, Mail subject=1 string mailToLua = string.Format(MailItemsFormat, CharacterSettings.Instance.MailRecipient.ToFormatedUTF8(), _mailSubject.ToFormatedUTF8()); var mailItemsRet = Lua.GetReturnVal <int>(mailToLua, 0); if (ret == 0 || mailItemsRet == 1) { _itemSplitSW.Reset(); _itemSplitSW.Start(); return(RunStatus.Success); } _itemList[itemID] = ret < 0 ? 0 : _itemList[itemID] - ret; bool done = _itemList[itemID] <= 0; if (done) { _itemList.Remove(itemID); } if (IsDone) { Professionbuddy.Log("Done sending {0} via mail", UseCategory ? string.Format("Items that belong to category {0} and subcategory {1}", Category, SubCategory) : string.Format("Items that match Id of {0}", ItemID)); } else { return(RunStatus.Success); } } return(RunStatus.Failure); }
public async static Task <bool> MoveToPool(WoWGameObject pool) { if (!AutoAnglerSettings.Instance.Poolfishing || AutoAnglerBot.Instance.Profile.FishAtHotspot) { return(false); } if (pool == null || !pool.IsValid) { return(false); } if (_lastPoolGuid != pool.Guid) { MoveToPoolTimer.Reset(); _lastPoolGuid = pool.Guid; if (!FindPoolPoint(pool, out _poolPoints) || !_poolPoints.Any()) { Utility.BlacklistPool(pool, TimeSpan.FromDays(1), "Found no landing spots"); return(false); } } // should never be true.. but being safe.. if (!_poolPoints.Any()) { Utility.BlacklistPool(pool, TimeSpan.FromDays(1), "Pool landing points mysteriously disapear..."); return(false); } var myLoc = Me.Location; var moveto = _poolPoints[0]; TreeRoot.StatusText = "Moving to " + pool.Name; if (myLoc.DistanceSqr(moveto) > 4 * 4) { MoveResult moveResult; if (AutoAnglerSettings.Instance.Fly) { // don't bother mounting up if we can use navigator to walk over if it's less than 25 units away if (myLoc.DistanceSqr(moveto) < 25 * 25 && !Me.Mounted) { moveResult = Navigator.MoveTo(moveto); if (moveResult != MoveResult.Failed && moveResult != MoveResult.PathGenerationFailed) { return(true); } } //if (!Me.Mounted && !SpellManager.GlobalCooldown) //{ // Flightor.MountHelper.MountUp(); // return true; //} Flightor.MoveTo(WoWMathHelper.CalculatePointFrom(myLoc, moveto, -1f)); return(true); } moveResult = Navigator.MoveTo(moveto); if (moveResult == MoveResult.UnstuckAttempt || moveResult == MoveResult.PathGenerationFailed || moveResult == MoveResult.Failed) { if (!RemovePointAtTop(pool)) { return(true); } AutoAnglerBot.Debug("Unable to path to pool point, switching to a new point"); _poolPoints.Sort((a, b) => a.DistanceSqr(myLoc).CompareTo(b.DistanceSqr(myLoc))); } // if it takes more than 25 seconds to get to a point remove that point and try another. if (MoveToPoolTimer.IsFinished) { if (!RemovePointAtTop(pool)) { return(false); } } return(true); } // wait for bot to reach destination before dismounting await Coroutine.Wait(2000, () => !Me.IsMoving); if (Me.Mounted) { await CommonCoroutines.Dismount("Fishing"); } // can't fish while swimming.. if (Me.IsSwimming && !WaterWalking.IsActive && !WaterWalking.CanCast) { AutoAnglerBot.Debug("Moving to new PoolPoint since I'm swimming at current PoolPoint"); if (!RemovePointAtTop(pool)) { return(false); } return(true); } return(false); }