private static async Task <bool> LootMovement() { if (_lootMovement == null) { _lootMovement = new Movement(TargetManager.LootableObject.Location, TargetManager.LootableObject.InteractRange - 0.25f, String.Format("Loot {0}", TargetManager.LootableObject.Name)); } MoveResult result = await _lootMovement.MoveTo_Result(); if (result == MoveResult.Failed) { if (_lootMovement.CanNavigateFailures > 2) { GarrisonBase.Debug("Behavior Looting Movement FAILED 3x Times! for {0}", TargetManager.LootableObject.Name); TargetManager.LootableObject.IgnoredTimer = WaitTimer.TenSeconds; TargetManager.LootableObject.IgnoredTimer.Reset(); ResetLoot(); return(false); } return(true); } if (result != MoveResult.ReachedDestination) { return(true); } ResetLoot(); return(false); }
private static void MerchantFrameOpened() { GarrisonBase.Debug("Updating Merchant Frame Info.."); IsOpen = true; MerchantItems.Clear(); NumMerchantItems.Reset(); }
private static async Task <bool> CombatMovement() { if (_combatMovement == null) { _combatMovement = new Movement(TargetManager.CombatObject, (float)TargetManager.PullDistance, String.Format("Combat {0}", TargetManager.CombatObject.Name)); } TreeRoot.StatusText = "Combat Movement Behavior"; var result = await _combatMovement.MoveTo_Result(false); if (result == MoveResult.Failed) { if (_combatMovement.CanNavigateFailures > 2) { GarrisonBase.Debug("Behavior Combat Movement FAILED for {0}", TargetManager.CombatObject.Name); TargetManager.CombatObject.IgnoredTimer = WaitTimer.TenSeconds; TargetManager.CombatObject = null; _combatMovement = null; return(false); } return(true); } if (result != MoveResult.ReachedDestination) { return(true); } _combatMovement = null; return(false); }
//internal static void RefreshFollowerIds() //{ // GarrisonBase.Debug("Refreshing Follower Ids.."); // FollowerIdsCollected.Clear(); // FollowerIdsNotCollected.Clear(); // BuildingIdsWithFollowerWorking.Clear(); // CurrentActiveFollowers = 0; // FollowerIdsAll = LuaCommands.GetAllFollowerIDs(); // foreach (var id in FollowerIdsAll) // { // if (LuaCommands.IsFollowerCollected(id)) // FollowerIdsCollected.Add(id); // else // FollowerIdsNotCollected.Add(id); // } // GarrisonBase.Log("Found a total of {0} collected followers!", FollowerIdsCollected.Count); //} internal static void RefreshFollowers() { GarrisonBase.Debug("Refreshing Followers.."); BuildingIdsWithFollowerWorking.Clear(); CurrentActiveFollowers = 0; foreach (var follower in GarrisonInfo.Followers) { var followerId = Convert.ToInt32(follower.Id); var f = new Follower(follower); Followers.Add(followerId, f); if (f.Status != GarrisonFollowerStatus.Inactive) { CurrentActiveFollowers++; } if (f.AssignedBuildingId > -1) { BuildingIdsWithFollowerWorking.Add(f.AssignedBuildingId); } } GarrisonBase.Log("Followers Active {0} / {1}", CurrentActiveFollowers, MaxActiveFollowers); }
private static void LuaBuyMerchantItem(int index, int amount) { string lua = String.Format("BuyMerchantItem(\"{0}\"" + ", \"{1}\");", index, amount); GarrisonBase.Debug("LuaCommand: BuyMerchantItem {0} / {1}", index, amount); Lua.DoString(lua); }
public override void Initalize() { Movement.IgnoreTaxiCheck = true; _selectedTaxiNode = null; _taxiMovement = null; _taxiNpc = null; _nonVisiblityCount = 0; GarrisonBase.Debug("UseFlightPath Destination {0}", _destination.ToString()); _destinationFlightPathInfo = TaxiFlightHelper.NearestFlightPathFromLocation(_destination); if (_destinationFlightPathInfo != null) { GarrisonBase.Debug("Destination FlightPathInfo {0}", _destinationFlightPathInfo.ToString()); if (_destinationFlightPathInfo.MasterId == TaxiFlightHelper.FlightPathInfo.FrostwallMasterEntry || _destinationFlightPathInfo.MasterId == TaxiFlightHelper.FlightPathInfo.LunarfallMasterEntry) { GarrisonBase.Debug("Flight path destination is garrison, ignore hearth set to false!"); Common.PreChecks.IgnoreHearthing = false; } } _currentMapId = TaxiFlightHelper.GetMapId(Player.Location); _destinationMapId = TaxiFlightHelper.GetMapId(_destination); GarrisonBase.Debug("Current Map Id {0} -- Destination Map Id {1}", _currentMapId, _destinationMapId); if (_currentMapId != _destinationMapId) { _shouldCheckMapId = true; } Common.CloseOpenFrames(); Initalized = true; }
private async Task <bool> CheckFlightNodes() { //Validate that we have a node we can use.. var validInfoNodes = TaxiFlightHelper.TaxiNodes.Where(n => n.Known && n.Info != null).ToList(); if (validInfoNodes.Count > 0) { var orderedNodes = validInfoNodes.OrderBy(n => n.Info.Location.Distance(_destination)).ToList(); _selectedTaxiNode = orderedNodes[0]; GarrisonBase.Debug("UseFlightPath using closest node {0}!", _selectedTaxiNode.Name); } else { GarrisonBase.Debug("UseFlightPath could not find a valid flight point using location!"); IsDone = true; return(true); } //Garrison FP! if (_selectedTaxiNode.Name.Contains("frostwall garrison") || _selectedTaxiNode.Name.Contains("lunarfall")) { Common.PreChecks.IgnoreHearthing = false; } return(false); }
/// <summary> /// The universal method used by all behaviors for execution. /// </summary> /// <returns></returns> public virtual async Task <bool> BehaviorRoutine() { TreeRoot.StatusText = GetStatusText; if (!Initalized) { GarrisonBase.Debug("Initalizing Behavior {0}", Type); Initalize(); } if (!IsDone) { IsDone = !CheckRunCondition(); } if (IsDone) { if (!Disposed) { GarrisonBase.Debug("Disposing Behavior {0}", Type); Dispose(); } return(false); } //await Coroutine.Yield(); return(await Common.CheckCommonCoroutines()); }
public static bool ShouldTakeFlightPath(WoWPoint destination) { var runTravelTime = Styx.CommonBot.FlightPaths.GetRunPathTime(new[] { Player.Location, destination }, 14.7f); GarrisonBase.Debug("Checking ShouldTakeFlightpath for {0} with mounted time {1} seconds", destination, runTravelTime.TotalSeconds); if (runTravelTime.TotalSeconds < 90) { return(Styx.CommonBot.FlightPaths.ShouldTakeFlightpath(Player.Location, destination, 14.7f)); } else { var playerMapId = !Player.MapIsContinent ? Player.ParentMapId : (int)Player.MapId.Value; //Lets verify that our possible destination var destinationTaxi = NearestFlightPathFromLocation(destination); var currentTaxi = NearestFlightPath; if (destinationTaxi.Name == currentTaxi.Name) { GarrisonBase.Debug("ShouldTakeFlight path return false due to matching names taxi and current taxi"); return(false); } } return(true); }
private static async Task <bool> Looting() { if (StyxWoW.Me.IsMoving && await CommonCoroutines.StopMoving()) { await CommonCoroutines.SleepForLagDuration(); } if (TargetManager.LootableObject.IsValid) { bool success = await CommonCoroutines.WaitForLuaEvent( "LOOT_CLOSED", 4200, null, TargetManager.LootableObject.Interact); if (TargetManager.LootableObject.InteractionAttempts > 1) { GarrisonBase.Debug("LootObject interaction attempts has excedeed max! Ignoring {0}", TargetManager.LootableObject.Name); IgnoreLootableObject(); ResetLoot(); return(false); } if (success) { await CheckLootFrame(); IgnoreLootableObject(); ResetLoot(); } } return(true); }
private static int GetGossipEntryCount() { GarrisonBase.Debug("LuaCommand: GetNumGossipOptions"); string lua = String.Format("return GetNumGossipOptions()"); List <string> retvalues = Lua.GetReturnValues(lua); return(retvalues[0].ToInt32()); }
private static int GetMerchantItemCount() { GarrisonBase.Debug("LuaCommand: GetMerchantNumItems"); string lua = String.Format("return GetMerchantNumItems()"); List <string> retvalues = Lua.GetReturnValues(lua); return(retvalues[0].ToInt32()); }
private static async Task <bool> VendorInteraction(C_WoWObject vendor, List <C_WoWItem> items) { TreeRoot.StatusText = "Vendor Interaction Behavior"; if (GossipHelper.IsOpen) { await Coroutine.Yield(); if (GossipHelper.GossipOptions.All(o => o.Type != GossipEntry.GossipEntryType.Vendor)) { //Could not find Vendor Option! GarrisonBase.Debug("Vendor Gossip Has No Option for Vendoring!"); return(false); } var gossipEntryVendor = GossipHelper.GossipOptions.FirstOrDefault(o => o.Type == GossipEntry.GossipEntryType.Vendor); QuestManager.GossipFrame.SelectGossipOption(gossipEntryVendor.Index); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } if (MerchantHelper.IsOpen) { if (items.Count > 0) { foreach (var item in items) { GarrisonBase.Debug("Vendoring Item {0} ({1}) Quality {2}", item.Name, item.Entry, item.Quality); MerchantFrame.Instance.SellItem(item.ref_WoWItem); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); if (!MerchantHelper.IsOpen) { break; } } return(true); } //No vendor items found.. return(false); } if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForLagDuration(); vendor.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); }
public static async Task <bool> VendoringBehavior() { if (await DisenchantBehavior.Disenchanting()) { return(true); } if (await VendorBehavior.Vendoring()) { return(true); } if (await MailBehavior.Mailing()) { return(true); } if (Player.Inventory.TotalFreeSlots < BaseSettings.CurrentSettings.MinimumBagSlotsFree || ForceBagCheck) { ForceBagCheck = false; if (VendorBehavior.ShouldVendor) { GarrisonBase.Debug("Enabling Vendor behavior!"); VendorBehavior.IsVendoring = true; } if (MailBehavior.ShouldMail) { GarrisonBase.Debug("Enabling Mailing behavior!"); MailBehavior.IsMailing = true; } if (DisenchantBehavior.ShouldDisenchant) { GarrisonBase.Debug("Enabling Disenchanting behavior!"); DisenchantBehavior.IsDisenchanting = true; } if (VendorBehavior.IsVendoring || MailBehavior.ShouldMail || DisenchantBehavior.ShouldDisenchant) { _originalTargetManagerLoot = TargetManager.ShouldLoot; _originalTargetManagerKill = TargetManager.ShouldKill; TargetManager.ShouldKill = false; TargetManager.ShouldLoot = false; _resetTargetManager = true; return(true); } } if (_resetTargetManager) { _resetTargetManager = false; TargetManager.ShouldKill = _originalTargetManagerKill; TargetManager.ShouldLoot = _originalTargetManagerLoot; } return(false); }
/// <summary> /// This occurs only once to initalize any variable only after the Criteria check occurs and passes. /// </summary> public virtual void Initalize() { StartMovement = new Movement(MovementPoints.ToArray(), 2f, name: String.Format("StartMovement({0})", Type.ToString())); EndMovement = new Movement(MovementPoints.ToArray().Reverse().ToArray(), 2f, name: String.Format("EndMovement({0})", Type.ToString())); _interactionObject = null; IsDone = false; Initalized = true; GarrisonBase.Debug("Behavior {0} has been initalized", Type); }
private async Task <bool> Interaction() { if (Building.CheckedWorkOrderStartUp) { return(false); } if ((Building.Type != BuildingType.TradingPost && Building.Type != BuildingType.Barn) && Building.WorkOrder.TotalWorkorderStartups() == 0) { GarrisonBase.Debug("Total Work Order Startup Count is Zero!"); Building.CheckedWorkOrderStartUp = true; return(false); } TreeRoot.StatusText = String.Format("Behavior {0} [{1}] Interaction", Type.ToString(), Building.Type); if (LuaEvents.ShipmentOrderFrameOpen) { if (BaseSettings.CurrentSettings.DEBUG_FAKESTARTWORKORDER || !LuaUI.WorkOrder.StartWorkOrder.IsEnabled()) { if (Building.Type != BuildingType.Barn) { Building.CheckedWorkOrderStartUp = true; } else { CurrentBarnCurrceny = null; BarnWorkOrderCurrencies.RemoveAt(0); } //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true); GarrisonBase.Log("Order Button Disabled!"); Building.WorkOrder.Refresh(); LuaUI.WorkOrder.Close.Click(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); return(Building.Type == BuildingType.Barn); } await CommonCoroutines.SleepForRandomUiInteractionTime(); if (Building.Type == BuildingType.WarMillDwarvenBunker) { LuaUI.WorkOrder.StartWorkOrder.Click(); } else { LuaUI.WorkOrder.CreateAllWorkOrder.Click(); } await Coroutine.Yield(); } return(true); }
private static async Task <bool> DisenchantInteraction(List <C_WoWItem> items) { if (Player.CurrentPendingCursorSpellId == DisenchantSpellId) { //Item Interaction! GarrisonBase.Log("Disenchant Cursor!"); if (items.Count > 0) { var item = items[0]; GarrisonBase.Debug("Disenchanting Item {0} ({1}) Quality {2}", item.Name, item.Entry, item.Quality); bool bagChanged = await CommonCoroutines.WaitForLuaEvent( "BAG_UPDATE", 6200, null, item.Use); PlayerInventory.ItemDisenchantingBlacklistedGuids.Add(item.Guid); //Force update if bag didn't change.. (so we ignore this item now) if (!bagChanged) { Player.Inventory.UpdateBagItems(); } return(true); } return(false); } var spell = DisenchantSpell; if (spell != null) { bool cursorChanged = await CommonCoroutines.WaitForLuaEvent( "CURRENT_SPELL_CAST_CHANGED", StyxWoW.Random.Next(555, 2002), null, spell.Cast); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); await Coroutine.Sleep(StyxWoW.Random.Next(1222, 2222)); } else { GarrisonBase.Err("Disenchanting Spell returned null!"); return(false); } return(true); }
/// <summary> /// This occurs only once after the behavior is considered done. /// </summary> public virtual void Dispose() { IsDone = true; Disposed = true; if (DisposalAction != null) { DisposalAction.Invoke(); } GarrisonBase.Debug("Behavior {0} has been disposed", Type); }
private static void PopulateFlightPaths() { GarrisonBase.Debug("Populating Flight Paths from XML.."); //Populate the known flight paths incase we need it! FlightPaths.Clear(); foreach (var node in Styx.CommonBot.FlightPaths.XmlNodes) { FlightPaths.Add(new FlightPathInfo(node)); } GarrisonBase.Debug("Added a total of {0} Flight Paths!", FlightPaths.Count); }
private static bool buyitem(MItem item, int amount, bool forced = false) { GarrisonBase.Debug("Attempting to buy Merchant item ({0}) at index {1} of quantity {2} (forced={3})", item.Name, item.Index, amount, forced); if (!forced) { return(MerchantFrame.Instance.BuyItem(item.Index, amount)); } LuaBuyMerchantItem(item.Index, amount); return(true); }
private static async Task <bool> ValidateCombatPoi() { if (StyxWoW.Me.CurrentTarget == null || StyxWoW.Me.CurrentTarget.Guid != TargetManager.CombatObject.Guid) { GarrisonBase.Debug("Behavior Combat changing POI to unit {0}", TargetManager.CombatObject.Name); BotPoi.Current = new BotPoi(TargetManager.CombatObject.RefWoWUnit, PoiType.Kill); TargetManager.CombatObject.RefWoWUnit.Target(); ResetCombat(); return(true); } return(false); }
private static async Task <bool> MailMovement() { TreeRoot.StatusText = "Mail Movement Behavior"; var result = await _mailingMovement.MoveTo_Result(); if (result == MoveResult.Failed) { GarrisonBase.Debug("Behavior Mailbox Movement FAILED!"); _mailingMovement = null; return(false); } return(true); }
internal static void InitalizeBehaviorsList() { GarrisonBase.Debug("Initalize Behaviors List.."); //Insert new missions behavior at beginning! Behaviors.Clear(); SwitchBehaviors.Clear(); CurrentBehavior = null; SwitchBehavior = null; //Garrison Related! Behaviors.AddRange(GarrisonManager.GetGarrisonBehaviors()); InitalizedBehaviorList = true; }
private static bool ValidateCombatObject() { if (ObjectCacheManager.ShouldUpdateObjectCollection) { ObjectCacheManager.UpdateCache(); } if (!TargetManager.ShouldKill) { ResetCombat(); return(false); } if (TargetManager.CombatObject == null) { TargetManager.UpdateCombatTarget(); if (TargetManager.CombatObject == null) { ResetCombat(); return(false); } } if (!TargetManager.CombatObject.ValidForCombat) { GarrisonBase.Debug("EngageObject no longer valid for combat!"); TargetManager.UpdateCombatTarget(); //Clear and update lootable object TargetManager.LootableObject = null; LootBehavior.ResetLoot(); TargetManager.UpdateLootableTarget(); ResetCombat(); return(false); } if (TargetManager.CombatObject.IsEvadeRunningBack) { GarrisonBase.Debug("EngageObject is evading!"); TargetManager.CombatObject.IgnoredTimer = WaitTimer.TenSeconds; TargetManager.CombatObject.IgnoredTimer.Reset(); return(false); } return(true); }
public override async Task <bool> BehaviorRoutine() { if (await base.BehaviorRoutine()) { return(true); } if (IsDone) { return(false); } var millingHerbs = Player.Inventory.GetBagItemsMilling(); if (millingHerbs.Count == 0) { IsDone = true; return(false); } if (Player.CurrentPendingCursorSpellId != 51005) { if (!MillingSpell.Cooldown && MillingSpell.CanCast) { await CommonCoroutines.WaitForLuaEvent( "CURRENT_SPELL_CAST_CHANGED", 10000, () => false, MillingSpell.Cast); } await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } GarrisonBase.Debug("Milling Herb {0} stack {1}", millingHerbs[0].Name, millingHerbs[0].StackCount); await CommonCoroutines.WaitForLuaEvent( "BAG_UPDATE", 10000, () => false, millingHerbs[0].Use); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); }
public static void PopulateTaxiNodes() { GarrisonBase.Debug("Populating Taxi Nodes!"); if (!IsOpen) { return; } TaxiNodes.Clear(); foreach (var node in TaxiFrame.Instance.Nodes) { TaxiNodes.Add(new TaxiNodeInfo(node)); } GarrisonBase.Debug("Added a total of {0} Taxi Nodes!", TaxiNodes.Count); }
private void UpdateCurrentHitPoints() { uint currentHealth; try { currentHealth = RefWoWUnit.CurrentHealth; } catch { GarrisonBase.Debug("Failure to get hitpoint current {0}", this.ToString()); //Logger.Write(LogLevel.Cache, "Failure to get hitpoint current {0}", DebugStringSimple); //CurrentHealthPct = null; return; } CurrentHealth = currentHealth; if (!MaxHealth.HasValue) { try { MaxHealth = RefWoWUnit.MaxHealth; } catch { //NeedsRemoved = true; GarrisonBase.Debug("Failure to get max hitpoints {0}", this.ToString()); return; } } var dCurrentHealthPct = CurrentHealth / (float)MaxHealth.Value; CurrentHealthPercent = dCurrentHealthPct; //if (dCurrentHealthPct != CurrentHealthPercent) //{ // LastCurrentHealthPercent = CurrentHealthPercent; // CurrentHealthPercent = dCurrentHealthPct; //} }
private static bool ValidateLootObject() { if (ObjectCacheManager.ShouldUpdateObjectCollection) { ObjectCacheManager.UpdateCache(); } if (!TargetManager.ShouldLoot) { return(false); } if (TargetManager.LootableObject == null || !TargetManager.LootableObject.IsValid) { if (TargetManager.LootableObject != null) { TargetManager.LootableObject.ShouldLoot = false; } TargetManager.UpdateLootableTarget(); if (TargetManager.LootableObject == null) { ResetLoot(); return(false); } } if (!TargetManager.LootableObject.ValidForLooting) { GarrisonBase.Debug("LootObject no longer valid for looting {0}", TargetManager.LootableObject.Name); IgnoreLootableObject(); TargetManager.UpdateLootableTarget(); ResetLoot(); return(false); } return(true); }
public override async Task <bool> BehaviorRoutine() { if (await base.BehaviorRoutine()) { return(true); } if (IsDone) { return(false); } if (_shouldCheckMapId && Player.MapId == _destinationMapId) { GarrisonBase.Debug("UseFlightPath is finished due to matching map ids"); IsDone = true; if (_currentMapId == 1153 || _currentMapId == 1159 || _currentMapId == 1331 || _currentMapId == 1330) { //Reset Cache (Garrison was last location) ObjectCacheManager.ResetCache(); TargetManager.Reset(); } return(false); } if (TaxiFlightHelper.TaxiNodes.Count > 0 && _selectedTaxiNode == null && await CheckFlightNodes()) { return(true); } if (await VerifyFlightNpc()) { return(true); } if (await UseFlightPath()) { return(true); } return(false); }
private static async Task <bool> MailboxInteraction(C_WoWObject mailbox, Dictionary <string, List <C_WoWItem> > items) { if (MailHelper.IsOpen) { //Click Send Mail Tab if (!LuaCommands.IsSendMailFrameVisible()) { LuaCommands.ClickSendMailTab(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } foreach (var keypair in items) { GarrisonBase.Log("Found {0} items to mail", keypair.Value.Count); bool success = await SendMail(keypair.Key, keypair.Value); if (!success) { GarrisonBase.Debug("Sending Mail Failed!"); return(false); } await Coroutine.Yield(); return(true); } } if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForLagDuration(); mailbox.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); }