//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 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); }
private static MissionSimulatorResults SimulatorResults(Mission mission, GarrisonFollower[] followers, MissionSimulatorOptions options) { var _options = options ?? SuccessOnlyOptions; var result = GarrisonMissionSimulator.Simulate(mission.refGarrisonMission, followers, _options); string followernames = result.Followers.Aggregate(String.Empty, (current, f) => current + f.Name + "\t"); GarrisonBase.Log("Result: Success {0}%, Followers {1}", result.SuccessChance, followernames); return(result); }
private static async Task <bool> CheckLootFrame() { // loot everything. if (!LuaEvents.LootOpened) { return(false); } var lootSlotInfos = new List <LootSlotInfo>(); for (int i = 0; i < LootFrame.Instance.LootItems; i++) { lootSlotInfos.Add(LootFrame.Instance.LootInfo(i)); } if (await Coroutine.Wait(2000, () => { LootFrame.Instance.LootAll(); return(!LuaEvents.LootOpened); })) { GarrisonBase.Log("Succesfully looted: "); foreach (LootSlotInfo lootinfo in lootSlotInfos) { try { string lootQuanity = lootinfo.LootQuantity.ToString(); string lootName = lootinfo.LootName; GarrisonBase.Log(lootQuanity + "x " + lootName); } catch { GarrisonBase.Log("exception occured"); } } } else { GarrisonBase.Err("Failed to loot from Frame."); } await CommonCoroutines.SleepForLagDuration(); return(true); }
public PlayerInventory() { EquipmentManagerItemGuids.Clear(); ItemDisenchantingBlacklistedGuids.Clear(); RefreshEquipmentManagerItemGuids(); ItemDisenchantingBlacklistedGuids.AddRange(EquipmentManagerItemGuids); RefreshBackpackContainerInfo(); UpdateBagItems(); UpdateBankItems(); UpdateBankReagentItems(); RefreshLowestDurabilityPercent(); LuaEvents.OnBagUpdate += () => ShouldUpdateBagItems = true; LuaEvents.OnPlayerBankSlotsChanged += () => ShouldUpdateBankItems = true; LuaEvents.OnPlayerReagentsBankSlotsChanged += () => ShouldUpdateBankReagentItems = true; GarrisonBase.Log(DebugString); }
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); }
private async Task <bool> Interaction() { if (InteractionObject != null && InteractionObject.IsValid) { if (entryId == 0) { entryId = InteractionObject.Entry; } GarrisonBase.Log("Activating " + InteractionObject.Name + ", waiting..."); InteractionObject.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Wait(5000, () => !StyxWoW.Me.IsCasting && !InteractionObject.IsValid); await Coroutine.Sleep(StyxWoW.Random.Next(1999, 3001)); return(true); } Building.CanActivate = false; if (Building.Type == BuildingType.HerbGarden || Building.Type == BuildingType.Mines) {//Since activating herb/mine building resets the nodes, we should reset our last checked so we can redo it.. if (Building.Type == BuildingType.HerbGarden) { BaseSettings.CurrentSettings.LastCheckedHerbString = "0001-01-01T00:00:00"; } else { BaseSettings.CurrentSettings.LastCheckedMineString = "0001-01-01T00:00:00"; } BaseSettings.SerializeToXML(BaseSettings.CurrentSettings); } return(false); }
private async Task <bool> Interaction() { if (_questActionFinished) { return(false); } if (!QuestFrame.Instance.IsVisible) { return(true); } switch (QuestHelper.QuestFrameType) { case QuestHelper.QuestFrameTypes.Progress: QuestFrame.Instance.ClickContinue(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Sleep(5000); break; case QuestHelper.QuestFrameTypes.Complete: GarrisonBase.Log("Completing Quest.."); if (RewardIndex > -1) { GarrisonBase.Log("Selecting Reward Index {0}", RewardIndex); QuestFrame.Instance.SelectQuestReward(RewardIndex); await CommonCoroutines.SleepForRandomUiInteractionTime(); } if (!BaseSettings.CurrentSettings.DEBUG_FAKEFINISHQUEST) { var successTurnedIn = await CommonCoroutines.WaitForLuaEvent( "QUEST_FINISHED", 7500, null, QuestFrame.Instance.CompleteQuest); await CommonCoroutines.SleepForRandomUiInteractionTime(); await CommonCoroutines.SleepForLagDuration(); if (successTurnedIn) { _questActionFinished = true; if (buildingType != BuildingType.Unknown && GarrisonManager.Buildings.ContainsKey(buildingType)) { GarrisonManager.Buildings[buildingType].FirstQuestCompleted = true; } if (_specialMovement != null) { _specialMovement.UseDeqeuedPoints(true); } return(false); } return(true); } if (_specialMovement != null) { _specialMovement.UseDeqeuedPoints(true); } _questActionFinished = true; return(false); } return(true); }
private async Task <bool> Interaction() { if (Building.CheckedWorkOrderPickUp) { return(false); } if (WorkOrderObject == null || !WorkOrderObject.IsValid) { //Error Cannot find object! GarrisonBase.Debug("Workorder Pickup object null!"); Building.CheckedWorkOrderPickUp = true; await Coroutine.Sleep(StyxWoW.Random.Next(755, 1449)); await Coroutine.Yield(); Building.WorkOrder.Refresh(); //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true); return(false); } if (WorkOrderObject.WithinInteractRange) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } if (BaseSettings.CurrentSettings.DEBUG_FAKEPICKUPWORKORDER) { Building.CheckedWorkOrderPickUp = true; //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true); return(false); } if (WorkOrderObject.GetCursor == WoWCursorType.PointCursor) { //Nothing to pickup! GarrisonBase.Debug("Workorder Pickup Object Non-loot Cursor!"); Building.CheckedWorkOrderPickUp = true; await Coroutine.Sleep(StyxWoW.Random.Next(755, 1449)); await Coroutine.Yield(); //Building.WorkOrder.Refresh(); Building.WorkOrder.Pending -= Building.WorkOrder.Pickup; Building.WorkOrder.Pickup = 0; //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true); return(false); } WorkOrderObject.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); if (StyxWoW.LastRedErrorMessage.Contains("Inventory is full.")) { GarrisonBase.Log("Stopping Work Order Pickup due to inventory full!"); return(false); } return(true); } //if (_specialMovement != null) //{//Special Movement for navigating inside buildings using Click To Move // if (_specialMovement.CurrentMovementQueue.Count > 0) // { // //find the nearest point to the npc in our special movement queue // var nearestPoint = Coroutines.Movement.FindNearestPoint(WorkOrderObject.Location, _specialMovement.CurrentMovementQueue.ToList()); // //click to move.. but don't dequeue // var result = await _specialMovement.ClickToMove_Result(false); // if (!nearestPoint.Equals(_specialMovement.CurrentMovementQueue.Peek())) // { // //force dequeue now since its not nearest point // if (result == MoveResult.ReachedDestination) // _specialMovement.ForceDequeue(true); // return true; // } // //Last position was nearest and we reached our destination.. so lets finish special movement! // if (result == MoveResult.ReachedDestination) // { // _specialMovement.ForceDequeue(true); // _specialMovement.DequeueAll(false); // } // } //} //Move to the interaction object if (_movement == null) { _movement = new Movement(WorkOrderObject, WorkOrderObject.InteractRange - 0.25f, name: "WorkOrderPickup " + WorkOrderObject.Name); } await _movement.MoveTo(false); return(true); }
private async Task <bool> Interaction() { if (_questActionFinished || !QuestFrame.Instance.IsVisible) { return(false); } if (_completeQuest) { if (QuestHelper.QuestFrameType == QuestHelper.QuestFrameTypes.Complete) { if (_rewardIndex > -1) { GarrisonBase.Log("Selecting Reward Index {0}", _rewardIndex); QuestFrame.Instance.SelectQuestReward(_rewardIndex); await CommonCoroutines.SleepForRandomUiInteractionTime(); } if (BaseSettings.CurrentSettings.DEBUG_FAKEFINISHQUEST) { if (_specialMovement != null) { _specialMovement.UseDeqeuedPoints(true); } _questActionFinished = true; return(false); } var successTurnedIn = await CommonCoroutines.WaitForLuaEvent( "QUEST_TURNED_IN", 7500, null, QuestFrame.Instance.CompleteQuest); if (successTurnedIn) { if (_specialMovement != null) { _specialMovement.UseDeqeuedPoints(true); } _questActionFinished = true; return(false); } return(true); } if (QuestHelper.QuestFrameType == QuestHelper.QuestFrameTypes.Progress) { QuestFrame.Instance.ClickContinue(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); return(true); } GarrisonBase.Err("QuestPickup attempted to complete quest but was not on correct frame!"); _questActionFinished = true; return(false); } var successAccepted = await CommonCoroutines.WaitForLuaEvent( "QUEST_ACCEPTED", 7500, null, QuestFrame.Instance.AcceptQuest); // if (successAccepted) { await CommonCoroutines.SleepForRandomUiInteractionTime(); await CommonCoroutines.SleepForLagDuration(); await Coroutine.Sleep(1250); _questActionFinished = true; return(false); } return(true); }
internal static Behavior[] GetGarrisonBehaviors() { var retBehaviorList = new List <Behavior> { new BehaviorGetMail(), new BehaviorMissionComplete(), new BehaviorCache() }; //Finalize Plots foreach (var b in Buildings.Values.Where(b => b.CanActivate)) { retBehaviorList.Add(new BehaviorFinalizePlots(b)); } #region Building First Quest Behaviors foreach (var b in Buildings.Values.Where(b => !b.FirstQuestCompleted && !b.IsBuilding && b.FirstQuestNpcId > -1 && b.FirstQuestId > -1)) { retBehaviorList.Add(QuestHelper.GetGarrisonBuildingFirstQuestArray(b, Player.IsAlliance)); } #endregion #region Herbing and Mining if (Buildings.Values.Any(b => b.Type == BuildingType.Mines)) { var miningMoveTo = new BehaviorMove(MovementCache.MinePlot59SafePoint); miningMoveTo.Criteria += () => !GarrisonMineZoneIds.Contains(Player.ZoneId.Value); var miningArray = new BehaviorArray(new Behavior[] { new BehaviorCustomAction(() => { TargetManager.LootType = TargetManager.LootFlags.Units | TargetManager.LootFlags.Ore; }), miningMoveTo, new BehaviorMine() }); miningArray.Criteria += () => (!Buildings[BuildingType.Mines].IsBuilding && !Buildings[BuildingType.Mines].CanActivate && Buildings[BuildingType.Mines].FirstQuestCompleted && LuaCommands.CheckForDailyReset(BaseSettings.CurrentSettings.LastCheckedMine) && BaseSettings.CurrentSettings.BehaviorMineGather); miningArray.DisposalAction = () => { TargetManager.LootType = TargetManager.LootFlags.None; }; retBehaviorList.Add(miningArray); retBehaviorList.Add(new BehaviorWorkOrderPickUp(Buildings[BuildingType.Mines])); retBehaviorList.Add(new BehaviorWorkOrderStartUp(Buildings[BuildingType.Mines])); } if (Buildings.Values.Any(b => b.Type == BuildingType.HerbGarden)) { var herbingArray = new BehaviorArray(new Behavior[] { new BehaviorCustomAction(() => { TargetManager.LootType = TargetManager.LootFlags.Units | TargetManager.LootFlags.Herbs; }), new BehaviorMove(MovementCache.GardenPlot63SafePoint), new BehaviorHerb() }); herbingArray.Criteria += () => (!Buildings[BuildingType.HerbGarden].IsBuilding && !Buildings[BuildingType.HerbGarden].CanActivate && Buildings[BuildingType.HerbGarden].FirstQuestCompleted && LuaCommands.CheckForDailyReset(BaseSettings.CurrentSettings.LastCheckedHerb) && BaseSettings.CurrentSettings.BehaviorHerbGather); herbingArray.DisposalAction = () => { TargetManager.LootType = TargetManager.LootFlags.None; }; retBehaviorList.Add(herbingArray); retBehaviorList.Add(new BehaviorWorkOrderPickUp(Buildings[BuildingType.HerbGarden])); retBehaviorList.Add(new BehaviorWorkOrderStartUp(Buildings[BuildingType.HerbGarden])); } #endregion #region Professions foreach (var profession in Player.Professions.ProfessionSkills.Values.Where(p => p.DailyCooldownSpellIds != null)) { if (profession.Skill == SkillLine.Inscription) { retBehaviorList.Add(new BehaviorMilling()); } int[] spellIds = profession.DailyCooldownSpellIds; retBehaviorList.Add(new BehaviorCraftingProfession(profession.Skill, spellIds[1])); retBehaviorList.Add(new BehaviorCraftingProfession(profession.Skill, spellIds[0])); } #endregion #region Salvaging if (Buildings.Values.Any(b => b.Type == BuildingType.SalvageYard)) { retBehaviorList.Add(new BehaviorSalvage()); } #endregion #region Work Order Pickup && Startup foreach (var b in Buildings.Values.Where(b => b.FirstQuestId <= 0 || b.FirstQuestCompleted).OrderBy(b => b.Plot)) { if (b.Type != BuildingType.Mines || b.Type != BuildingType.HerbGarden) { if (b.WorkOrder != null) { retBehaviorList.Add(new BehaviorWorkOrderPickUp(b)); if (b.Type == BuildingType.EnchantersStudy) { retBehaviorList.Add(new BehaviorDisenchant()); //Disenchanting! } else if (b.Type == BuildingType.ScribesQuarters) { retBehaviorList.Add(new BehaviorMilling()); //Milling! } else if (b.Type == BuildingType.Barn) { if (Player.Inventory.Trap != null) { GarrisonBase.Log("Adding Trapping Behavior"); if (Player.Inventory.Trap.TrapRank > 1) { retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Elites_Nagrand.Clone()); } if (Player.IsAlliance) { retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Leather_ShadowmoonVally.Clone()); retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Fur_ShadowmoonValley.Clone()); } else { retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Leather_FrostfireRidge.Clone()); retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Fur_Nagrand_Horde.Clone()); } retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Boars_Gorgond.Clone()); } } retBehaviorList.Add(new BehaviorWorkOrderStartUp(b)); if (b.Type == BuildingType.WarMillDwarvenBunker && b.Level == 3) { var questid = Player.IsAlliance ? 38175 : 38188; retBehaviorList.Add(QuestHelper.GetDailyQuestArray(Convert.ToUInt32(questid), Player.IsAlliance)); } else if (b.Type == BuildingType.AlchemyLab && b.HasFollowerWorking) { retBehaviorList.Add(QuestHelper.GetDailyQuestArray(Convert.ToUInt32(37270), Player.IsAlliance)); } } } } #endregion //Primal Spirit Exchange retBehaviorList.Add(new BehaviorPrimalTrader()); var forceBagCheck = new BehaviorCustomAction(() => { Common.ForceBagCheck = true; }); retBehaviorList.Add(forceBagCheck); //Finally, start some new missions! retBehaviorList.Add(new BehaviorMissionStartup()); //Optional follower behaviors (to unlock) retBehaviorList.Add(BehaviorArrayFollowers.Clone()); return(retBehaviorList.ToArray()); }
public override async Task <bool> BehaviorRoutine() { if (await base.BehaviorRoutine()) { return(true); } if (IsDone) { return(false); } if (!QuestHelper.QuestContainedInQuestLog(QuestID) || QuestHelper.GetQuestFromQuestLog(QuestID).IsCompleted) { return(false); } if (Building.WorkOrder == null || Building.WorkOrder.TotalWorkorderStartups() == 0) { return(false); } if (await StartMovement.MoveTo()) { return(true); } if (GossipHelper.IsOpen) { GossipFrame.Instance.SelectGossipOption(0); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } if (LuaCommands.IsGarrisonCapacitiveDisplayFrame()) { if (!LuaCommands.ClickStartOrderButtonEnabled()) { Building.CheckedWorkOrderStartUp = true; GarrisonBase.Log("Order Button Disabled!"); return(false); } LuaCommands.ClickStartOrderButton(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await CommonCoroutines.SleepForLagDuration(); return(true); } if (InteractionObject != null && InteractionObject.IsValid) { if (InteractionObject.WithinInteractRange) { TreeRoot.StatusText = String.Format("Behavior {0} Quest NPC Interact", Type.ToString()); InteractionObject.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } if (_npcMovement == null) { _npcMovement = new Movement(InteractionObject.Location, InteractionObject.InteractRange - 0.25f); } await _npcMovement.ClickToMove(false); return(true); } return(false); }
private async Task <bool> Movement() { if (Building.CheckedWorkOrderStartUp) { return(false); } if (WorkOrderObject == null) { GarrisonBase.Err("Could not find Work Order Npc Id {0}", Building.WorkOrderNpcEntryId); //Error Cannot find object! Building.CheckedWorkOrderStartUp = true; return(false); } if (WorkOrderObject.WithinInteractRange) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForLagDuration(); if (_interactionAttempts > 3) { GarrisonBase.Log("Interaction Attempts for {0} has exceeded 3! Preforming movement..", WorkOrderObject.Name); StartMovement.Reset(); _interactionAttempts = 0; return(true); } if (LuaUI.WorkOrder.IsVisible()) { //Workorder frame is displayed! _interactionAttempts = 0; return(false); } if (Building.Type == BuildingType.Barn && GossipHelper.IsOpen) { //var entries = GossipHelper.GossipOptions.Where( // entry => entry.Text.ToLower().Contains(BarnWorkOrderGossipString)).ToList(); var entries = GossipHelper.GossipOptions.Where( entry => entry.Index == BarnGossipIndex).ToList(); if (entries.Count > 0) { int index = entries[0].Index; QuestManager.GossipFrame.SelectGossipOption(index); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } else { GarrisonBase.Err("Could not find gossip index for barn currency {0}", CurrentBarnCurrceny[0].Item1.ToString()); } } _interactionAttempts++; WorkOrderObject.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } //Setup the NPC movement! if (_movement == null || _movement.CurrentMovementQueue.Count == 0) { _movement = new Movement(WorkOrderObject, WorkOrderObject.InteractRange - 0.50f, WorkOrderObject.Name); } await _movement.MoveTo(); return(true); }
private async Task <bool> Interaction() { /* * Check Cursor Spell ID * Click Interaction * Await for event CURRENT_SPELL_CAST_CHANGED * -If event did not fire then check for confirmation popup * * Item Interaction * * */ if (Player.CurrentPendingCursorSpellId == 160201) { //Item Interaction! GarrisonBase.Log("Disenchant Cursor!"); if (Player.Inventory.DisenchantItems.Count > 0) { var item = Player.Inventory.DisenchantItems[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); } bool cursorChanged = await CommonCoroutines.WaitForLuaEvent( "CURRENT_SPELL_CAST_CHANGED", StyxWoW.Random.Next(555, 2002), null, DisenchantingObject.Interact); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); await Coroutine.Sleep(StyxWoW.Random.Next(1222, 2222)); if (!cursorChanged) { if (LuaCommands.IsStaticPopupVisible()) { LuaCommands.ClickStaticPopupButton(1); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } GarrisonBase.Err("Could not find static popup confirmation frame!"); } return(true); }
private async Task <bool> Interaction() { if (!_commandtableCompletemissionsWaittimer.IsFinished) { return(true); } _commandtableCompletemissionsWaittimer.Reset(); if (GarrisonManager.AvailableMissionIds.Count == 0) { await Coroutine.Yield(); return(false); } if (LuaUI.MissionFrame.IsMissionCompleteDialogVisible) { //Complete Dialog is visible.. //We need to add complete missions to coroutines //Add it again.. //Finish this behavior GarrisonBase.Log("Garrison Mission Complete Is Visible!"); BehaviorManager.Behaviors.Insert(1, new BehaviorMissionComplete()); BehaviorManager.Behaviors.Insert(2, new BehaviorMissionStartup()); LuaUI.MissionFrame.Close.Click(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); return(false); } //Find our next mission.. if any. double _successChance = 0; if (_currentMission == null) { int[] followerIds; var removalList = new List <int>(); for (int i = 0; i < GarrisonManager.AvailableMissions.Count; i++) { var mission = GarrisonManager.AvailableMissions[i]; if (mission.Level >= mission.MinimumLevel && mission.Priority > 0 && mission.Cost <= Character.Player.AvailableGarrisonResource) { _successChance = LuaCommands.GetMissionBestSuccessAttempt(mission.Id, out followerIds); if (_successChance < mission.SuccessRate) { removalList.Add(i); continue; } _currentMission = mission; break; } removalList.Add(i); } if (removalList.Count > 0) { foreach (var mission in removalList.OrderByDescending(k => k).Select(k => GarrisonManager.AvailableMissions[k])) { GarrisonManager.AvailableMissionIds.Remove(mission.Id); GarrisonManager.AvailableMissions.Remove(mission); } } } if (_currentMission != null) { GarrisonBase.Log("Starting Mission {0} Rewards {1} Priority {2} Success {3}", _currentMission.Name, _currentMission.RewardTypes, _currentMission.Priority, _successChance); //GARRISON_FOLLOWER_LIST_UPDATE await CommonCoroutines.WaitForLuaEvent("GARRISON_FOLLOWER_LIST_UPDATE", 7500, null, Action); await Coroutine.Sleep(2218); await CommonCoroutines.WaitForLuaEvent("GARRISON_MISSION_STARTED", 7500, null, LuaUI.MissionFrame.StartMissionButton.Click); await Coroutine.Sleep(2500); //LuaCommands.CloseMission(); //await Coroutine.Sleep(1500); GarrisonManager.AvailableMissionIds.Remove(_currentMission.Id); GarrisonManager.AvailableMissions.Remove(_currentMission); _currentMission = null; await Coroutine.Yield(); return(true); } _currentMission = null; GarrisonManager.AvailableMissions.Clear(); GarrisonManager.AvailableMissionIds.Clear(); return(false); }
private static async Task <bool> SendMail(string recipient, List <C_WoWItem> items) { int count = 0; foreach (var cWoWItem in items) { if (!MailHelper.IsOpen) { GarrisonBase.Debug("Send Mail Failed due to mailbox not open!"); return(false); } if (count > 11) { break; } if (BaseSettings.CurrentSettings.MailSendItems.Any(i => i.EntryId == cWoWItem.Entry && i.OnCount > 0)) { var mailItemInfo = BaseSettings.CurrentSettings.MailSendItems.FirstOrDefault(i => i.EntryId == cWoWItem.Entry); if (mailItemInfo != null) { int excessCount = (int)cWoWItem.StackCount - mailItemInfo.OnCount; if (excessCount > 0) { GarrisonBase.Log("Send Mail Spliting Item {0} to send count {1}", cWoWItem.Name, excessCount); int freeBagIndex, freeBagSlot; bool foundFreeSpot = Character.Player.Inventory.FindFreeBagSlot(out freeBagIndex, out freeBagSlot); if (foundFreeSpot) { GarrisonBase.Log("Send Mail Split Item Moving to Bag Index {0} Slot {1}", freeBagIndex, freeBagSlot); bool success = await SplitItem(cWoWItem, excessCount, freeBagIndex, freeBagSlot); if (success) { GarrisonBase.Log("Attaching item {0} to mail", cWoWItem.Name); LuaCommands.UseContainerItem(freeBagIndex, freeBagSlot + 1); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Sleep(StyxWoW.Random.Next(1250, 2223)); count++; } LuaCommands.ClearCursor(); continue; } } } } GarrisonBase.Log("Attaching item {0} to mail", cWoWItem.Name); LuaCommands.UseContainerItem(cWoWItem.BagIndex + 1, cWoWItem.BagSlot + 1); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Sleep(StyxWoW.Random.Next(1250, 2223)); count++; } if (!_mailingSetRecipient) { if (!MailHelper.IsOpen) { GarrisonBase.Debug("Send Mail Failed due to mailbox not open!"); return(false); } LuaCommands.SetSendMailRecipient(recipient); _mailingSetRecipient = true; await CommonCoroutines.SleepForRandomUiInteractionTime(); } if (!MailHelper.IsOpen) { GarrisonBase.Debug("Send Mail Failed due to mailbox not open!"); _mailingSetRecipient = false; return(false); } LuaCommands.ClickSendMailButton(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Sleep(StyxWoW.Random.Next(1250, 2223)); _mailingSetRecipient = false; return(true); }
private async Task <bool> CheckHearthStone() { if (await Common.CheckCommonCoroutines()) { return(true); } if (FlightPathBehavior != null && !FlightPathBehavior.IsDone && await FlightPathBehavior.BehaviorRoutine()) { return(true); } if (MovementBehavior != null && MovementBehavior.CurrentMovementQueue.Count > 0 && await MovementBehavior.MoveTo()) { return(true); } if (!StyxWoW.Me.IsCasting) { var hearthstone = Player.Inventory.GarrisonHearthstone; if (hearthstone != null) { bool oncooldown = false; var cooldownTimeLeft = hearthstone.ref_WoWItem.CooldownTimeLeft; if (cooldownTimeLeft.TotalSeconds > 0) { oncooldown = true; GarrisonBase.Log("Garrison Hearthstone on cooldown! {0} seconds left", cooldownTimeLeft.TotalSeconds); if (cooldownTimeLeft.TotalSeconds < 60) { await Coroutine.Sleep((int)cooldownTimeLeft.TotalMilliseconds); return(true); } } if (!oncooldown && hearthstone.ref_WoWItem.Usable) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } hearthstone.Use(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Wait(10000, () => StyxWoW.Me.IsCasting); await Coroutine.Yield(); if (!await Coroutine.Wait(25000, () => StyxWoW.Me.CurrentMap.IsGarrison)) { GarrisonBase.Err("Used garrison hearthstone but not in garrison yet."); return(false); } //If we are using taxi.. finish it! if (BehaviorManager.CurrentBehavior.Type == BehaviorType.Taxi) { BehaviorManager.CurrentBehavior.IsDone = true; } } else { if (Player.MapExpansionId != 5) { //Not in draenor! GarrisonBase.Err("Garrison Hearthstone is on cooldown and not currently in draenor!"); return(false); } if (!attemptedFlightPath) { GarrisonBase.Debug("Attempting flight path to garrison"); FlightPathBehavior = new BehaviorUseFlightPath(MovementCache.GarrisonEntrance); attemptedFlightPath = true; } else { GarrisonBase.Debug("Attempting movement to garrison"); if (MovementBehavior == null) { MovementBehavior = new Movement(MovementCache.GarrisonEntrance, 50f, name: "GarrisonMovement"); } } return(true); } } } await Coroutine.Sleep(StyxWoW.Random.Next(1232, 3323)); return(true); }
private static async Task <bool> DisenchantForgeInteraction(C_WoWGameObject disenchantobject, List <C_WoWItem> items) { if (disenchantobject.GetCursor != WoWCursorType.InteractCursor) { GarrisonBase.Debug("Disenchant Interaction failed -- Cursor was not InteractCursor!"); return(false); } if (Player.CurrentPendingCursorSpellId == 160201) { //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); } bool cursorChanged = await CommonCoroutines.WaitForLuaEvent( "CURRENT_SPELL_CAST_CHANGED", StyxWoW.Random.Next(555, 2002), null, disenchantobject.Interact); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); await Coroutine.Sleep(StyxWoW.Random.Next(1222, 2222)); if (!cursorChanged) { if (LuaCommands.IsStaticPopupVisible()) { LuaCommands.ClickStaticPopupButton(1); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } } return(true); }
internal static void SimulateMission(Mission mission) { GarrisonBase.Log("Simulating Mission {0}", mission.Name); RefreshFollowers(); var firstFollowers = Followers.Values.Where(follower => (follower.Status == GarrisonFollowerStatus.Idle || follower.Status == GarrisonFollowerStatus.InParty) && follower.Level >= mission.Level && follower.ItemLevel >= mission.ItemLevel).ToList(); var firstFollowerIds = firstFollowers.Select(f => f.ID).ToList(); var idleFollowers = Followers.Values.Where(follower => !firstFollowerIds.Contains(follower.ID) && (follower.Status == GarrisonFollowerStatus.Idle || follower.Status == GarrisonFollowerStatus.InParty)).OrderByDescending(f => f.ItemLevel).ThenByDescending(f => f.Level).ToList(); int followerCount = idleFollowers.Count; int missionSlots = mission.Followers; MissionSimulatorOptions options = new MissionSimulatorOptions(true, false, false, false, true, true, false, false, false); //mission.RewardTypes.HasFlag(RewardTypes.XP), var results = new List <MissionSimulatorResults>(); foreach (var follower in firstFollowers) { //int followerIndex1 = idleFollowers.IndexOf(follower); //if (followerIndex1 > followerCount - missionSlots) // break; GarrisonFollower follower1 = follower._refFollower; GarrisonFollower follower2, follower3; if (missionSlots > 1) { for (int i = 0; i < (missionSlots > 2?followerCount - 1:followerCount); i++) { follower2 = idleFollowers[i]._refFollower; if (missionSlots > 2) { for (int j = i + 1; j < followerCount; j++) { follower3 = idleFollowers[j]._refFollower; results.Add(SimulatorResults(mission, new[] { follower1, follower2, follower3 }, null)); //break; } } else { results.Add(SimulatorResults(mission, new[] { follower1, follower2 }, null)); } //break; } } else { results.Add(SimulatorResults(mission, new[] { follower1 }, null)); } //break; } //foreach (var result in results) //{ // string followernames = result.Followers.Aggregate(string.Empty, (current, f) => current + f.Name + "\t"); // GarrisonBase.Log("Result: Success {0}%, Followers {1}", result.SuccessChance, followernames); //} }
public static async Task <bool> RootLogic() { if (!CacheStaticLookUp.InitalizedCache) { CacheStaticLookUp.Update(); ObjectCacheManager.Initalize(); TargetManager.Initalize(); Movement.IgnoreTaxiCheck = false; //Simple Check if garrison can be accessed! if (Player.Level < 90 || Player.Inventory.GarrisonHearthstone == null) { GarrisonBase.Log("No access to garrison!"); TreeRoot.Stop("No Access to Garrison"); return(false); } } if (await Common.CheckCommonCoroutines()) { return(true); } //Do we need to hearth or fly to our garrison? if (await Common.PreChecks.BehaviorRoutine()) { return(true); } //Disable and reload UI if master plan is enabled.. //if (await Common.PreChecks.CheckAddons()) return true; //We need "open" the garrison up and initalize it.. (so we don't get errors trying to inject!) if (await Common.PreChecks.InitalizeGarrisonManager()) { return(true); } ////Inject our lua addon code for mission success function //if (!LuaEvents.LuaAddonInjected) //{ // if (LuaCommands.TestLuaInjectionCode()) // {//Prevent multiple injections by checking simple function return! // LuaEvents.LuaAddonInjected = true; // } // else // { // await LuaEvents.InjectLuaAddon(); // return true; // } //} if (!InitalizedBehaviorList) { InitalizeBehaviorsList(); } //Check for next behavior if (CurrentBehavior == null) { while (Behaviors.Count > 0) { if (!Behaviors[0].CheckCriteria()) { Behaviors.RemoveAt(0); } else { CurrentBehavior = Behaviors[0]; CurrentBehavior.Initalize(); break; } } } if (CurrentBehavior != null) { //Check for any switch behaviors.. (override current behavior temporarly) if (SwitchBehaviors.Count > 0 && SwitchBehavior == null) { while (SwitchBehaviors.Count > 0) { if (!SwitchBehaviors[0].CheckCriteria()) { SwitchBehaviors.RemoveAt(0); } else { SwitchBehavior = SwitchBehaviors[0]; break; } } } if (SwitchBehavior != null && CurrentBehavior != SwitchBehavior) { GarrisonBase.Debug("Switching behaviors to {0}", SwitchBehavior.Type); CurrentBehavior = SwitchBehavior; CurrentBehavior.Initalize(); } bool x = await CurrentBehavior.BehaviorRoutine(); if (x && !CurrentBehavior.IsDone) { return(true); } GarrisonBase.Debug( !x ? "Finishing Behavior {0} because it returned false!" : "Finishing Behavior {0} because IsDone is true", CurrentBehavior.Type); if (!CurrentBehavior.Disposed) { CurrentBehavior.Dispose(); } if (SwitchBehavior != null && CurrentBehavior.Equals(SwitchBehavior)) { CurrentBehavior = Behaviors[0]; CurrentBehavior.Initalize(); SwitchBehaviors.RemoveAt(0); SwitchBehavior = null; } else { Behaviors.RemoveAt(0); CurrentBehavior = null; } return(true); } //if (Common.PreChecks.DisabledMasterPlanAddon) //{ // Common.PreChecks.ShouldCheckAddons = false; // LuaCommands.EnableAddon("MasterPlan"); // LuaCommands.ReloadUI(); // Common.PreChecks.DisabledMasterPlanAddon = false; // await Coroutine.Wait(6000, () => StyxWoW.IsInGame); // return true; //} TreeRoot.StatusText = "GarrisonBase is finished!"; TreeRoot.Stop(); return(false); }