public static Composite CreateBrewmasterMonkInstanceCombat() { var powerStrikeTimer = new WaitTimer(TimeSpan.FromSeconds(20)); return new PrioritySelector( Safers.EnsureTarget(), Movement.CreateMoveToLosBehavior(), Movement.CreateFaceTargetBehavior(), Helpers.Common.CreateAutoAttack(true), Helpers.Common.CreateInterruptSpellCast(ret => StyxWoW.Me.CurrentTarget), // make sure I have aggro. Spell.Cast("Provoke", ret => TankManager.Instance.NeedToTaunt.FirstOrDefault(), ret => SingularSettings.Instance.EnableTaunting), // apply the Weakened Blows debuff. Keg Smash also generates allot of threat Spell.Cast("Keg Smash", ctx => StyxWoW.Me.MaxChi - StyxWoW.Me.CurrentChi >= 2 && Clusters.GetCluster(StyxWoW.Me, Unit.NearbyUnfriendlyUnits, ClusterType.Radius, 8).Any(u => !u.HasAura("Weakened Blows"))), Spell.CastOnGround("Dizzying Haze", ctx => TankManager.Instance.NeedToTaunt.FirstOrDefault().Location, ctx => TankManager.Instance.NeedToTaunt.Any(), false), // AOE new Decorator(ctx => Unit.NearbyUnfriendlyUnits.Count(u => u.DistanceSqr <= 8 * 8) >= 3, new PrioritySelector( // cast breath of fire to apply the dot. Spell.Cast("Breath of Fire",ctx => Clusters.GetCluster(StyxWoW.Me, Unit.NearbyUnfriendlyUnits, ClusterType.Cone, 8).Count(u =>u.HasAura("Dizzying Haze") && !u.HasAura("Breath of Fire")) >= 3), Spell.Cast("Zen Sphere", ctx => TalentManager.IsSelected((int)Common.Talents.ZenSphere) && StyxWoW.Me.HealthPercent < 90 && StyxWoW.Me.HasAura("Zen Sphere") && StyxWoW.Me.CurrentChi >= 4), // aoe stuns Spell.Cast("Charging Ox Wave", ctx => TalentManager.IsSelected((int)Common.Talents.ChargingOxWave) && Clusters.GetClusterCount(StyxWoW.Me, Unit.NearbyUnfriendlyUnits, ClusterType.Cone, 30) >= 3), Spell.Cast("Leg Sweep", ctx => TalentManager.IsSelected((int)Common.Talents.LegSweep)) )), // ***** Spend Chi ***** Spell.Cast("Rushing Jade Wind", ctx => TalentManager.IsSelected((int)Common.Talents.RushingJadeWind) &&(!StyxWoW.Me.HasAura("Shuffle") || StyxWoW.Me.Auras["Shuffle"].TimeLeft <= TimeSpan.FromSeconds(1))), Spell.Cast("Blackout Kick", ctx => !StyxWoW.Me.HasAura("Shuffle") || StyxWoW.Me.Auras["Shuffle"].TimeLeft <= TimeSpan.FromSeconds(1)), Spell.Cast("Tiger Palm", ret => StyxWoW.Me.CurrentChi >= 2 && SpellManager.HasSpell("Guard") && (!StyxWoW.Me.HasAura("Power Guard") || StyxWoW.Me.Auras["Power Guard"].StackCount < 3)), //Spell.Cast("Tiger Palm", ret => StyxWoW.Me.CurrentChi >= 2 && SpellManager.HasSpell("Blackout Kick") && (!StyxWoW.Me.HasAura("Tiger Power") || StyxWoW.Me.Auras["Tiger Power"].StackCount < 3)), Spell.BuffSelf("Purifying Brew", ctx => StyxWoW.Me.HasAura("Stagger") && StyxWoW.Me.CurrentChi >= 3), // ***** Generate Chi ***** Spell.Cast("Keg Smash", ctx => StyxWoW.Me.MaxChi - StyxWoW.Me.CurrentChi >= 2 && Unit.NearbyUnfriendlyUnits.Any(u => u.DistanceSqr <= 8 * 8)), Spell.Cast("Spinning Crane Kick", ctx => StyxWoW.Me.MaxChi - StyxWoW.Me.CurrentChi >= 1 && Unit.NearbyUnfriendlyUnits.Count(u => u.DistanceSqr <= 8 * 8) >= 3), // jab with power strike talent is > expel Harm if off CD. new Decorator(ctx => TalentManager.IsSelected((int)Common.Talents.PowerStrikes) && StyxWoW.Me.MaxChi - StyxWoW.Me.CurrentChi >= 2 && SpellManager.CanCast("Jab") && powerStrikeTimer.IsFinished, new Sequence( new Action(ctx => powerStrikeTimer.Reset()), Spell.Cast("Jab") )), Spell.Cast("Expel Harm", ctx => StyxWoW.Me.HealthPercent < 90 && StyxWoW.Me.MaxChi - StyxWoW.Me.CurrentChi >= 1 && Unit.NearbyUnfriendlyUnits.Any(u => u.DistanceSqr <= 10 * 10)), Spell.Cast("Jab", ctx => StyxWoW.Me.MaxChi - StyxWoW.Me.CurrentChi >= 1), // filler Spell.Cast("Tiger Palm", ret => !SpellManager.HasSpell("Blackout Kick") || SpellManager.HasSpell("Brewmaster Training")), TryCastClashBehavior(), //Only roll to get to the mob quicker. Spell.Cast("Roll", ret => SingularSettings.Instance.IsCombatRoutineMovementAllowed() && StyxWoW.Me.CurrentTarget.Distance.Between(10, 40)), Movement.CreateMoveToMeleeBehavior(true)); }
private Sequencer() { _timer = new WaitTimer(TimeSpan.FromMilliseconds(100)); _toDelete = new List<Molecule>(); // Activate buildings ???????? // Creating a new list for the actions _actions = new SortedSet<Molecule>(); _actions.Add(new Molecule(new UseGarrisonHearthstoneIfNeeded(), 0)); if (GarrisonButler.IsIceVersion()) _actions.Add(new Molecule(new GetMails(), 100)); _actions.Add(new Molecule(new ActivateBuildings(), 150)); _actions.Add(new Molecule(new CleanMine(), 202)); _actions.Add(new Molecule(new PickUpOrderMine(), 203)); _actions.Add(new Molecule(new StartOrdersMine(), 204)); _actions.Add(new Molecule(new CleanGarden(), 300)); _actions.Add(new Molecule(new PickUpOrderGarden(), 301)); _actions.Add(new Molecule(new StartOrderGarden(), 302)); if (GarrisonButler.IsIceVersion()) _actions.Add(new Molecule(new DisenchantItems(), 400)); _actions.Add(new Molecule(new CraftAllDailies(), 500)); int priority = 1000; foreach (var building in ButlerCoroutine._buildings) { _actions.Add(new Molecule(new PickUpWorkOrders(building), priority)); priority += 1; _actions.Add(new Molecule(new StartWorkOrders(building), priority)); priority += 1; } if (GarrisonButler.IsIceVersion()) { _actions.Add(new Molecule(new UseGearArmorToken(), 2000)); _actions.Add(new Molecule(new UseGearWeaponToken(), 2100)); } _actions.Add(new Molecule(new HarvestCache(), 2150)); _actions.Add(new Molecule(new TurnInMissions(), 2200)); _actions.Add(new Molecule(new StartMissions(), 2300)); _actions.Add(new Molecule(new SalvageCrates(), 2400)); _actions.Add(new Molecule(new SellJunk(), 2500)); if (GarrisonButler.IsIceVersion()) _actions.Add(new Molecule(new DisenchantItems(), 2550)); if (GarrisonButler.IsIceVersion()) _actions.Add(new Molecule(new MailItems(), 2600)); _actions.Add(new Molecule(new LastRound(), 2700)); _actions.Add(new Molecule(new Waiting(), 2800)); }
private static void HandlePlayerDead(object sender, LuaEventArgs args) { // Since we hooked this in ctor, make sure we are the selected CC if (RoutineManager.Current.Name != SingularRoutine.Instance.Name) return; if (StyxWoW.Me.IsAlive || StyxWoW.Me.IsGhost) return; List<string> hasSoulstone = Lua.GetReturnValues("return HasSoulstone()", "hawker.lua"); if (hasSoulstone != null && hasSoulstone.Count > 0 && !String.IsNullOrEmpty(hasSoulstone[0]) && hasSoulstone[0].ToLower() != "nil") { if (MovementManager.IsMovementDisabled ) { Logger.Write(Color.Aquamarine, "Suppressing {0} behavior since movement disabled...", hasSoulstone[0]); return; } const int RezMaxMobsNear = 0; const int RezWaitTime = 10; const int RezWaitDist = 20; WaitTimer waitClearArea = new WaitTimer(TimeSpan.FromSeconds(RezWaitTime )); waitClearArea.Reset(); Logger.Write(Color.Aquamarine, "Waiting up to {0} seconds for clear area to use {1}...", RezWaitTime , hasSoulstone[0]); int countMobs; do { countMobs = (from u in Unit.NearbyUnfriendlyUnits where u.Distance < RezWaitDist select u).Count(); } while (countMobs > RezMaxMobsNear && !waitClearArea.IsFinished && !StyxWoW.Me.IsAlive && !StyxWoW.Me.IsGhost); if (StyxWoW.Me.IsGhost) { Logger.Write(Color.Aquamarine, "Insignia taken or something else released the corpse"); return; } if (StyxWoW.Me.IsAlive) { Logger.Write(Color.Aquamarine, "Ressurected by something other than Singular..."); return; } if (countMobs > RezMaxMobsNear ) { Logger.Write(Color.Aquamarine, "Still {0} enemies within {1} yds, skipping {2}", countMobs, RezWaitDist, hasSoulstone[0]); return; } Lua.DoString("UseSoulstone()"); StyxWoW.SleepForLagDuration(); } else { } }
public async Task<bool> GetCoroutine() { SafeZerg.Instance.DisableZerg(); if (_waitTimer == null) { _waitTimer = new WaitTimer(_waitTime); _waitTimer.Reset(); Logger.Debug("[Wait] Waiting for {0} seconds", _waitTime.TotalSeconds); } if (!_waitTimer.IsFinished) return false; _isDone = true; return true; }
private async Task <bool> NotStarted() { if (_returningToTownWaitTimer == null) { _returningToTownWaitTimer = new WaitTimer(TimeSpan.FromSeconds(5)); _returningToTownWaitTimer.Reset(); } if (!_returningToTownWaitTimer.IsFinished) { return(false); } _returningToTownWaitTimer = null; //if (!IsAvailable) //{ // _isDone = true; // return true; //} Stats = BountyStatistic.GetInstance(QuestId); if (Stats.StartTime == default(DateTime)) { Stats.StartTime = DateTime.UtcNow; } if (Stats.EndTime == default(DateTime)) { Stats.EndTime = DateTime.UtcNow; } Logger.Log(LogLevel.Overlay, "[Bounty] Starting {0} ({1})", QuestData.Name, QuestId); if (IsInZone) { State = States.InZone; } else { Logger.Debug("[Bounty] Using waypoint to reach one of the bounty LevelAreaSnoIdIds: {0}", string.Join(", ", BountyData.LevelAreaIds)); State = States.TakingWaypoint; } return(false); }
private async Task <bool> Completed() { if (_completedWaitTimer == null) { _completedWaitTimer = QuestId == 359927 ? new WaitTimer(TimeSpan.FromSeconds(15)) : new WaitTimer(TimeSpan.FromSeconds(3)); } if (!_completedWaitTimer.IsFinished) { return(false); } _completedWaitTimer = null; _isDone = true; if (Stats != null) { Stats.EndTime = DateTime.UtcNow; Stats.IsCompleted = true; Logger.Log(LogLevel.Overlay, "[Bounty] Completed {0} ({1}) Time {2:hh\\:mm\\:ss}", QuestData.Name, QuestId, Stats.EndTime - Stats.StartTime); } return(true); }
private async Task <bool> EnterPortal() { var portalEntryTimer = new WaitTimer(MaxTimeToPortalEntry); portalEntryTimer.Reset(); QBCLog.DeveloperInfo("Portal Entry Timer Started"); while (true) { if (TookPortal) { return(true); } // If portal entry timer expired, deal with it... if (portalEntryTimer.IsFinished) { QBCLog.Warning( "Unable to enter portal within allotted time of {0}", Utility.PrettyTime(MaxTimeToPortalEntry)); break; } // If we are within 2 yards of calculated end point we should never reach... if (Me.Location.Distance(MovePoint) < 2) { QBCLog.Warning("Seems we missed the portal. Is Portal activated? Profile needs to pick better alignment?"); break; } // If we're not moving toward portal, get busy... if (!StyxWoW.Me.IsMoving || Navigator.AtLocation(StartingPoint)) { QBCLog.DeveloperInfo("Entering portal via {0}", MovePoint); WoWMovement.ClickToMove(MovePoint); } await Coroutine.Yield(); } return(false); }
public override async Task <bool> Run() { var itemId = ItemIdDelegate(); CachedWoWItem = Me.CarriedItems.FirstOrDefault(i => (i.Entry == itemId)); if (Query.IsViable(CachedWoWItem)) { // Squelch the timer, so it will be available if the item disappears from our bags... WatchdogTimer_WaitForItemArrival = null; return(false); } // If timer is not spinning, create & start it... if (WatchdogTimer_WaitForItemArrival == null) { WatchdogTimer_WaitForItemArrival = new WaitTimer(TimeSpan.FromMilliseconds(MaxWaitTimeInMillisecondsDelegate())); WatchdogTimer_WaitForItemArrival.Reset(); } // If timer completes, time to call it quits... if (WatchdogTimer_WaitForItemArrival.IsFinished) { QBCLog.ProfileError( "{0} has not arrived in our bag within {1}.", Utility.GetItemNameFromId(itemId), Utility.PrettyTime(WatchdogTimer_WaitForItemArrival.WaitTime)); ActionOnExpiredTimerDelegate(); } else { TreeRoot.StatusText = String.Format( "Waiting {0} for {1} to arrive in our bags.", Utility.PrettyTime(WatchdogTimer_WaitForItemArrival.WaitTime), Utility.GetItemNameFromId(itemId)); } return(true); }
//发送上线 public void Login() { foreach (IPAddress broadcastAddr in this.BroadcastAddress) { //先发送一个空操作,以防失败 SendEmptyPacket(broadcastAddr); Thread.Sleep(100); UdpPacket packet = new UdpPacket(); packet.Address = broadcastAddr; packet.Port = this.Port; packet.ToMAC = string.Empty; packet.Command = UdpPacket.CMD_ENTRY | UdpPacket.CMD_OPTION_STATE_NICKNAME | //UdpPacket.CMD_OPTION_STATE_PROFILE_PHOTO | //TODO 应该更新所有的,但是跨网的时候好像发送的byte太长,不能正常发送暂且去掉头像 UdpPacket.CMD_OPTION_STATE_PUBKEY | UdpPacket.CMD_OPTION_STATE_STATUS; packet.FromMAC = this.MAC; UdpPacketStateExtend extend = new UdpPacketStateExtend(); extend.PublicKey = _client.SecurityKeys.Public;//送公钥出去 extend.NickName = this.NickName; extend.ProfilePhoto = ProfilePhotoPool.GetPhoto(this.ID, false); extend.Status = this.Status; packet.Extend = extend; _client.Send(packet); Thread.Sleep(100); } //10分钟以后更新头像 WaitTimer.Start(1 * 60 * 10 * 1000, new TimerCallback((obj) => { UpdateState(LanIM.UpdateState.Photo); } ), null); }
public void ShowCollection() { // JSONや画像の読み込みでViewの生成が遅れることがあるのでStart()を待つ const float WAIT_INTERVAL_SECOND = 0.5f; System.Action SetTimer = null; System.Func <bool> IsAllStarted = () => { foreach (var banner in m_banners) { if (!banner.isStarted) { return(false); } } return(true); }; SetTimer = () => { if (m_banners.Count == 0 || !IsAllStarted()) { m_waitTimer = new WaitTimer(WAIT_INTERVAL_SECOND, SetTimer); return; } foreach (var banner in m_banners) { banner.Appear(); } m_waitTimer = null; }; SetTimer(); }
public override void Update(DwarfTime time) { WaitTimer.Update(time); animation.Update(time); if (WaitTimer.HasTriggered) { if (AnnouncementViews.Count > 0) { AnnouncementView view = AnnouncementViews.ElementAt(AnnouncementViews.Count - 1); RemoveChild(view); AnnouncementViews.RemoveAt(AnnouncementViews.Count - 1); if (AnnouncementViews.Count > 0) { WaitTimer.Reset(); } else { Talker.TweenOut(Drawer2D.Alignment.Bottom); } } } if (AnnouncementViews.Count > 0 && !Talker.IsVisible) { Talker.TweenIn(Drawer2D.Alignment.Bottom); } SpeechBubble.IsVisible = AnnouncementViews.Count > 0; if (SpeechBubble.IsVisible || Talker.IsVisible) { UpdateLayout(); } base.Update(time); }
private async Task<bool> NotStarted() { if (_returningToTownWaitTimer == null) { _returningToTownWaitTimer = new WaitTimer(TimeSpan.FromSeconds(5)); _returningToTownWaitTimer.Reset(); } if (!_returningToTownWaitTimer.IsFinished) return false; _returningToTownWaitTimer = null; //if (!IsAvailable) //{ // _isDone = true; // return true; //} Stats = BountyStatistic.GetInstance(QuestId); if (Stats.StartTime == default(DateTime)) Stats.StartTime = DateTime.UtcNow; if (Stats.EndTime == default(DateTime)) Stats.EndTime = DateTime.UtcNow; Logger.Log(LogLevel.Overlay, "[Bounty] Starting {0} ({1})", QuestData.Name, QuestId); if (IsInZone) { State = States.InZone; } else { Logger.Debug("[Bounty] Using waypoint to reach one of the bounty LevelAreaIds: {0}", string.Join(", ", BountyData.LevelAreaIds)); State = States.TakingWaypoint; } return false; }
public Atom() { Status = new Result(ActionResult.Init, "Initialized"); Dependencies = new List<Atom>(); timer = new WaitTimer(TimeSpan.FromMilliseconds(5000)); }
void OnWaitTimerTick(object sender, EventArgs e) { WaitTimer.Stop(); this.HideWaitForm(); }
/// <summary> /// Load event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WatchdogWindow_Load(object sender, EventArgs e) { WaitTimer.Start(); StatusLabel.Text = "Waiting for EVEMon to close."; }
public void MakeTimerForInsertReceipt() { waitTimer = new WaitTimer( 50, RequestInsertReceipt, "Re Rquest Insert Receipt"); Debug.Log( "timer insert Receipt"); }
public void Reset() { _isDone = false; _waitTimer = null; }
public LocalBlacklist(TimeSpan maxSweepTime) { _sweepTimer = new WaitTimer(maxSweepTime); _sweepTimer.WaitTime = maxSweepTime; }
public async override Task Action() { // If check interval is 65s, we must wait for the wow server to allow another refresh if ((MailboxCheckTimer.IsRunning) && (_mailCheckInterval == CheckIntervalWhileStillWaiting)) { // Need to keep waiting for timer if (MailboxCheckTimer.Elapsed.TotalSeconds < (_mailCheckInterval)) { Status = new Result(ActionResult.Running, "Waiting for timer."); return; } GarrisonButler.Diagnostic("[Mail] " + _mailCheckInterval + "s mailbox timer finished inside GetMails()"); MailboxCheckTimer.Reset(); MailboxCheckTimer.Stop(); } if (!_init) { // Wait for server to load mails after opening mailbox GarrisonButler.Diagnostic("[Mail] Waiting 5s for WoW to load mail."); await Buddy.Coroutines.Coroutine.Sleep(5000); _init = true; } var mailFrame = MailFrame.Instance; var numMail = InterfaceLua.GetInboxMailCountInPlayerInbox(); var totalMail = InterfaceLua.GetInboxMailCountOnServer(); GarrisonButler.Diagnostic("[Mail] LUA returned VisibleMail=" + numMail); GarrisonButler.Diagnostic("[Mail] LUA returned server TotalMail=" + totalMail); await Buddy.Coroutines.Coroutine.Sleep(1000); //WorkAroundHBMailLoggingBugStart(); var hbMailLoggingBugOriginalLogLevel = GarrisonButler.CurrentHonorbuddyLog.LoggingLevel; var hbMailLoggingBugOriginalFileLogLevel = GarrisonButler.CurrentHonorbuddyLog.LogFileLevel; var hbMailLoggingBugOriginalFileLoggingFlag = GarrisonButler.CurrentHonorbuddyLog.FileLogging; GarrisonButler.CurrentHonorbuddyLog.LoggingLevel = LogLevel.None; GarrisonButler.CurrentHonorbuddyLog.LogFileLevel = LogLevel.None; GarrisonButler.CurrentHonorbuddyLog.FileLogging = false; bool openAllMailCoroutineResult = false; var timeout = new WaitTimer(TimeSpan.FromMilliseconds(90000)); openAllMailCoroutineResult = await mailFrame.OpenAllMailCoroutine(); while (mailFrame.GetAllMails().Any(m => !m.WasRead || ((m.ItemCount > 0 || m.Copper > 0) && m.CODAmount <= 0)) && !timeout.IsFinished) { openAllMailCoroutineResult = await mailFrame.OpenAllMailCoroutine(); await Buddy.Coroutines.Coroutine.Yield(); } _checkedMailbox = true; GarrisonButler.CurrentHonorbuddyLog.LoggingLevel = hbMailLoggingBugOriginalLogLevel; GarrisonButler.CurrentHonorbuddyLog.LogFileLevel = hbMailLoggingBugOriginalFileLogLevel; GarrisonButler.CurrentHonorbuddyLog.FileLogging = hbMailLoggingBugOriginalFileLoggingFlag; //WorkAroundHBMailLoggingBugEnd(); // Wait for logging changes to take effect / mail icon await Buddy.Coroutines.Coroutine.Sleep(1000); GarrisonButler.Diagnostic("[Mail] OpenAllMailCoroutine() returned " + openAllMailCoroutineResult); // "Read" all mails, even ones with only text in them // This turns the mail "grey" to get rid of the mail icon // OpenAllMailCoroutine() from the Honorbuddy base does NOT turn the mail // to "grey" when checking mail with ONLY text in it. using (var myLock = Styx.StyxWoW.Memory.AcquireFrame()) { mailFrame.GetAllMails().GetEmptyIfNull().ForEach(m => InterfaceLua.MarkMailAsRead(m.Index)); } // Allow for a 2nd check if the server returned more mails than were shown in the inbox // AND // We reduced the number of total mail (on the server) from the last check // If total mail didn't change between checks, that means the user's inbox is // stuck possibly due to "read" messages that contain only text or their inventory // is full GarrisonButler.Diagnostic("[Mail] numMailsOnLastCheck=" + _numMailsOnLastCheck); var condition1 = (numMail >= 50) && (_numMailsOnLastCheck != totalMail); GarrisonButler.Diagnostic("[Mail] condition1=" + condition1); // Allow for a 2nd check when fresh bot run or after a 5min timer refresh var condition2 = (numMail >= 50) && (_allowMailTimerStart); GarrisonButler.Diagnostic("[Mail] condition2=" + condition2); if (condition1 || condition2) { GarrisonButler.Log("[Mail] More mail to check, waiting 65 seconds"); _allowMailTimerStart = false; _numMailsOnLastCheck = totalMail; if (mailFrame.IsVisible) { mailFrame.Close(); // Wait for mail icon to update after closing mail frame await Buddy.Coroutines.Coroutine.Sleep(1000); } _mailCheckInterval = 65; MailboxCheckTimer.Reset(); MailboxCheckTimer.Start(); Status = new Result(ActionResult.Running, "Waiting for mails to refresh."); return; } GarrisonButler.Log("[Mail] Waiting 5 minutes to check mail again."); _numMailsOnLastCheck = 0; _allowMailTimerStart = true; if (mailFrame.IsVisible) { mailFrame.Close(); // Wait for mail icon to update after closing mail frame await Buddy.Coroutines.Coroutine.Sleep(1000); } _mailCheckInterval = 60 * 5; // 5 minutes MailboxCheckTimer.Reset(); MailboxCheckTimer.Start(); _init = false; }
/// <summary> /// Technically this is not a clean solution. We need to hook up the plugin regardless to override routine /// selection. Therefore the HandleRoutineSelection method needs to evaluate whether the plugin is enabled /// or not... /// </summary> public override void OnInitialize() { _pulseTimer = new WaitTimer(new TimeSpan(0, 0, 0, 1)); HandleInit(); }
public static Composite CreateBrewmasterMonkInstanceCombat() { var powerStrikeTimer = new WaitTimer(TimeSpan.FromSeconds(20)); return new PrioritySelector( Helpers.Common.EnsureReadyToAttackFromMelee(), CreateCloseDistanceBehavior(), Helpers.Common.CreateAutoAttack(true), Spell.WaitForCastOrChannel(), new Decorator( req => !Spell.IsGlobalCooldown(), new PrioritySelector( Helpers.Common.CreateInterruptBehavior(), // Execute if we can Spell.Cast("Touch of Death", ret => Me.CurrentChi >= 3 && Me.HasAura("Death Note")), // make sure I have aggro. Spell.Cast("Provoke", ret => TankManager.Instance.NeedToTaunt.FirstOrDefault(), ret => SingularSettings.Instance.EnableTaunting), // highest priority -- Keg Smash for threat and debuff Spell.Cast("Keg Smash", req => Me.MaxChi - Me.CurrentChi >= 2 && Clusters.GetCluster(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Radius, 8).Any(u => !u.HasAura("Weakened Blows"))), // taunt if needed Spell.CastOnGround("Dizzying Haze", on => TankManager.Instance.NeedToTaunt.FirstOrDefault(), req => TankManager.Instance.NeedToTaunt.Any(), false), // AOE new Decorator( req => Spell.UseAOE && Unit.NearbyUnfriendlyUnits.Count(u => u.DistanceSqr <= 8 * 8) >= 3, new PrioritySelector( // cast breath of fire to apply the dot. Spell.Cast("Breath of Fire", ctx => Clusters.GetCluster(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Cone, 8).Count(u => u.HasAura("Dizzying Haze") && !u.HasAura("Breath of Fire")) >= 3), Spell.Cast("Zen Sphere", ctx => TalentManager.IsSelected((int)MonkTalents.ZenSphere) && Me.HealthPercent < 90 && Me.HasAura("Zen Sphere") && Me.CurrentChi >= 4), // aoe stuns Spell.Cast("Charging Ox Wave", ctx => TalentManager.IsSelected((int)MonkTalents.ChargingOxWave) && Clusters.GetClusterCount(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Cone, 30) >= 3), Spell.Cast("Leg Sweep", ctx => TalentManager.IsSelected((int)MonkTalents.LegSweep)) ) ), // ***** Spend Chi ***** Spell.Cast("Rushing Jade Wind", ctx => TalentManager.IsSelected((int)MonkTalents.RushingJadeWind) && (!Me.HasAura("Shuffle") || Me.Auras["Shuffle"].TimeLeft <= TimeSpan.FromSeconds(1))), Spell.Cast("Blackout Kick", ctx => !SpellManager.HasSpell("Brewmaster Training") || Me.HasKnownAuraExpired("Shuffle", 1)), Spell.Cast("Tiger Palm", ret => Me.HasKnownAuraExpired("Tiger Power", 1) || (SpellManager.HasSpell("Brewmaster Training") && Me.HasKnownAuraExpired("Power Guard", 1))), Spell.BuffSelf("Purifying Brew", ctx => Me.HasAura("Stagger") && Me.CurrentChi >= 3), // ***** Generate Chi ***** new Decorator( req => Me.CurrentChi < Me.MaxChi, new PrioritySelector( Spell.Cast("Keg Smash", ctx => Me.MaxChi - Me.CurrentChi >= 2), Spell.Cast("Spinning Crane Kick", ctx => Unit.NearbyUnfriendlyUnits.Count(u => u.DistanceSqr <= 8 * 8) >= 3), // jab with power strike talent is > expel Harm if off CD. new Decorator(ctx => TalentManager.IsSelected((int)MonkTalents.PowerStrikes) && Me.MaxChi - Me.CurrentChi >= 2 && Spell.CanCastHack("Jab") && powerStrikeTimer.IsFinished, new Sequence( new Action(ctx => powerStrikeTimer.Reset()), Spell.Cast("Jab") ) ), Spell.Cast("Expel Harm", req => Me.HealthPercent < 90 && Unit.NearbyUnfriendlyUnits.Any(u => u.DistanceSqr <= 10 * 10)), Spell.Cast("Jab") ) ), // filler: // cast on cooldown when Level < 26 (Guard) or Level >= 34 (Brewmaster Training), otherwise try to save some Chi for Guard if available Spell.Cast("Tiger Palm", ret => SpellManager.HasSpell("Brewmaster Training") || Me.CurrentChi > 2 || !SpellManager.HasSpell("Guard") || Spell.GetSpellCooldown("Guard").TotalSeconds > 4) ) ) ); }
public void MakeTimerForGetPKey( EndTimerDelegate _eventDelegate) { waitTimer = new WaitTimer( 60, _eventDelegate, "GetPKey"); Debug.Log( "Get P Key");}
// =========================================================== // Inner and Anonymous Classes // =========================================================== private static void FormatAndShowTimer(string pTimerStringName) { // Create a new timer if last one has expired or we didn't have one if(!WaitTimerCreated) { foreach(var t in UIRefresher.ThrottleTimers.Where(t => t.TimerName == pTimerStringName)) { WaitTimerCreated = true; // Set up a new timer based on the amount of milliseconds in our current timer WaitTimer = new WaitTimer(new TimeSpan(0, 0, 0, 0, t.Time)); // Build the string with the proper format WaitTimerAsString = BuildTimeAsString(WaitTimer.WaitTime); WaitTimer.Reset(); } } OutputMessage(pTimerStringName); }
public void MakeTimerForGetCashItemRequest(){ waitTimer = new WaitTimer( 50, RequestGetCashItem , "Re Request Get Cash Item"); Debug.Log( "timer GetItemRequest"); }
private async Task<bool> GoingToAct1Hub() { DisablePulse(); if (_goingToAct1HubWaitTimer == null) { _goingToAct1HubWaitTimer = new WaitTimer(TimeSpan.FromSeconds(5)); _goingToAct1HubWaitTimer.Reset(); } if (!_goingToAct1HubWaitTimer.IsFinished) return false; if (!await WaypointCoroutine.UseWaypoint(WaypointFactory.ActHubs[Act.A1])) return false; _goingToAct1HubWaitTimer = null; State = States.InTown; return false; }
private static Composite CreateFeignDeath(SimpleBooleanDelegate req, WaitGetTimeSpanTimeoutDelegate timeOut, SimpleBooleanDelegate cancel) { return new Sequence( Spell.BuffSelf("Feign Death", req), new Action(ret => waitToCancelFeignDeath = new WaitTimer(timeOut())), new Action(ret => Logger.Write("... wait at most {0} seconds before cancelling Feign Death", (waitToCancelFeignDeath.EndTime - waitToCancelFeignDeath.StartTime).TotalSeconds)), new Action(ret => waitToCancelFeignDeath.Reset()), new WaitContinue(TimeSpan.FromMilliseconds(500), ret => Me.HasAura("Feign Death"), new ActionAlwaysSucceed()), new WaitContinue(360, ret => cancel(ret) || waitToCancelFeignDeath.IsFinished || !Me.HasAura("Feign Death"), new ActionAlwaysSucceed()), new DecoratorContinue( ret => Me.HasAura( "Feign Death"), new Sequence( new Action(ret => Logger.Write("/cancel Feign Death after {0} seconds", (DateTime.Now - waitToCancelFeignDeath.StartTime).TotalSeconds)), new Action(ret => Me.CancelAura("Feign Death")) ) ), new Action(ret => waitToCancelFeignDeath = null) ); }
public override bool IsFulfilled() { if (!GaBSettings.Get().StartMissions) { GarrisonButler.Diagnostic("[Missions] Deactivated in user settings."); return true; } var numberMissionAvailable = MissionLua.GetNumberAvailableMissions(); // Is there mission available to start if (numberMissionAvailable == 0) { GarrisonButler.Diagnostic("[Missions] No missions available to start."); return true; } var garrisonRessources = BuildingsLua.GetGarrisonRessources(); IEnumerable<Mission> missions = _missions.Where(m => m.Cost < garrisonRessources).ToList(); if (!missions.Any()) { GarrisonButler.Diagnostic("[Missions] Not enough ressources to start a mission."); return true; } if (_timeOut == null || _timeOut.IsFinished) { _timeOut = new WaitTimer(TimeSpan.FromSeconds(30)); _timeOut.Reset(); GarrisonButler.Diagnostic("Checking for missions."); _followers = FollowersLua.GetAllFollowers(); _missions = MissionLua.GetAllAvailableMissions(); // Enhanced Mission Logic if (GarrisonButler.IsIceVersion()) { toStart = NewMissionStubCode(_followers.ToList()); } else { toStart = new List<Tuple<Mission, Follower[]>>(); var followersTemp = _followers.ToList(); foreach (var mission in missions) { // Make sure that status is Idle or In Party var match = mission.FindMatch(followersTemp.Where(f => f.IsCollected && f.Status.ToInt32() <= 1).ToList()); if (match == null) continue; toStart.Add(new Tuple<Mission, Follower[]>(mission, match)); followersTemp.RemoveAll(match.Contains); } } var mess = "Found available missions to complete. " + "Can successfully complete: " + toStart.Count + " missions."; if (toStart.Count > 0) GarrisonButler.Log(mess); else { GarrisonButler.Diagnostic(mess); } return !toStart.Any(); } return !toStart.Any(); }
public override void Initialize() { Delay = new WaitTimer(TimeSpan.FromSeconds(1)); Delay.Stop(); base.Initialize(); }
public LocalBlacklist(TimeSpan maxSweepTime) { _SweepTimer = new WaitTimer(maxSweepTime) { WaitTime = maxSweepTime }; }
internal static async Task <bool> UsePomander(Pomander number, uint auraId = 0) { if (Core.Me.HasAura(Auras.ItemPenalty) && number != Pomander.Serenity) { return(false); } //cannot use pomander while under the auras of rage / lust if (Core.Me.HasAnyAura(Auras.Lust, Auras.Rage)) { return(false); } var data = DeepDungeonManager.GetInventoryItem(number); if (data.Count == 0) { return(false); } if (data.HasAura) { return(false); } if (Core.Me.HasAura(auraId) && Core.Me.GetAuraById(auraId).TimespanLeft > TimeSpan.FromMinutes(1)) { return(false); } var lockoutTimer = PomanderLockoutTimers[number]; if (!lockoutTimer.IsFinished) { return(false); } await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting); var cnt = data.Count; await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting); var wt = new WaitTimer(TimeSpan.FromSeconds(30)); wt.Reset(); while (cnt == data.Count && !wt.IsFinished) { Logger.Verbose($"Using Pomander: {number}"); DeepDungeonManager.UsePomander(number); await Coroutine.Sleep(150); await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting); DeepDungeonManager.PomanderChange(); data = DeepDungeonManager.GetInventoryItem(number); } //Wait a little so we don't trigger the anti-stuck await Coroutine.Sleep(1000); //TODO this is probabbly stored somewhere in the client... switch (number) { case Pomander.Rage: PomanderState = ItemState.Rage; break; case Pomander.Lust: PomanderState = ItemState.Lust; break; case Pomander.Resolution: PomanderState = ItemState.Resolution; break; } lockoutTimer.Reset(); return(true); }
private void StatusTimerFinished(object sender, WaitTimer.WaitTimerEventArgs e) { if (!Config.Instance.HourlyStatus) return; Debug (String.Format ("HourlyTimer Finished : {0} Started : {1} : WaitTime : {2}", e.TimeFinished, e.TimeStarted, ExtendedTimeFormat(e.WaitTime))); if (Config.Instance.HourlyStatus && _statusTimer.IsFinished) { _hList = new List<string>(); try { _hList.Add(String.Format("Class: {0}", StyxWoW.Me.Class)); _hList.Add(String.Format("We are running {0}!", BotManager.Current.Name)); _hList.Add (String.Format ("I'm at {0} in {1}", Lua.GetReturnVal<string>("return GetMinimapZoneText()", 0), Lua.GetReturnVal<string>("return GetZoneText()", 0))); _hList.Add(String.Format("Money : {0}g", StyxWoW.Me.Gold)); _hList.Add(TreeRoot.StatusText); _hList.Add(TreeRoot.GoalText); if (StyxWoW.Me.Level < 85) { _hList.Add(String.Format("EXP/h: {0}", GameStats.XPPerHour)); _hList.Add(String.Format("Time to Level: {0}", ExtendedTimeFormat(GameStats.TimeToLevel))); } if (BotManager.Current.Name == BotManager.Instance.Bots["Grind Bot"].Name) { _hList.Add(String.Format("Loots: {0}, Per/hr: {1}", GameStats.Loots, GameStats.LootsPerHour)); _hList.Add(String.Format("Kills: {0}", GameStats.MobsKilled)); _hList.Add(String.Format("Kills per hour: {0}", GameStats.MobsPerHour)); _hList.Add(String.Format("Deaths: {0}", GameStats.Deaths)); } else if (BotManager.Current.Name == BotManager.Instance.Bots["Questing"].Name) { _hList.Add(String.Format("Loots: {0}, Per/hr: {1}", GameStats.Loots, GameStats.LootsPerHour)); _hList.Add(String.Format("Kills: {0}", GameStats.MobsKilled)); _hList.Add(String.Format("Deaths: {0}", GameStats.Deaths)); //_hList.Add(String.Format("Poi {0}", BotPoi.Current)); } else if (BotManager.Current.Name == BotManager.Instance.Bots["BGBuddy"].Name) { _hList.Add (String.Format ("BGs: {0} (Won:{1}, Lost:{2})", GameStats.BGsCompleted, GameStats.BGsWon, GameStats.BGsLost)); _hList.Add (String.Format ("BGs/hour: {0} Lost/hr:{1} Won/hr:{2}", GameStats.BGsPerHour, GameStats.BGsLostPerHour, GameStats.BGsWonPerHour)); _hList.Add (String.Format ("Honor Gained: {0}, Honor/hour : {1}", GameStats.HonorGained, GameStats.HonorPerHour)); } else if (BotManager.Current.Name == BotManager.Instance.Bots["Gatherbuddy2"].Name) { int i = GatherbuddyBot.NodeCollectionCount.Values.Sum(value => value); try { _hList.Add(TimeFormat(GatherbuddyBot.runningTime)); _hList.Add(String.Format("Nodes per hour {0}", PerHour(i))); _hList.Add(String.Format("Total Nodes: {0}", i)); _hList.AddRange (GatherbuddyBot.NodeCollectionCount.Select (value => String.Format("{0} : {1}", value.Key, value.Value))); } catch (Exception x) { Log(x.Message); } } else if (BotManager.Current.Name == BotManager.Instance.Bots["AutoAngler"].Name) { var fishList = new List<string> { "Striped Lurker", "Highland Guppy", "Deepsea Sagefish", "Algaefin Rockfish", "Blackbelly Mudfish" }; var itemList = new List<string>(); foreach (var bagItem in StyxWoW.Me.BagItems.Where(bagItem => !itemList.Contains(bagItem.Name)).Where (bagItem => bagItem.Name.ContainsAny(fishList))) itemList.Add(bagItem.Name); foreach (var item in itemList) { try { var count = Lua.GetReturnVal<int> (String.Format("return GetItemCount(\"{0}\")", item), 0); _hList.Add(string.Format("{0} Count : {1}", item, count)); } catch { } } } } catch (Exception listEx) { Logging.Write(String.Format("{0}", listEx)); } finally { SendMail(_hList, string.Format("{0}", e.TimeFinished), "Hourly Status"); } } }
private void CountdownThread_DoWork(object sender, DoWorkEventArgs e) { #region Variables string FROM; string TO; string Compression; decimal MAX; string MAX1; #endregion while (CountdownThread.CancellationPending == false) { FROM = XmlReader.GetWorld(); TO = XmlReader.GetBackupTo(); Compression = XmlReader.UseCompression(); MAX1 = XmlReader.GetBackupTime(); MAX = Convert.ToDecimal(MAX1); #region Do if variables not set if (FROM == "" || TO == "" || MAX == 0 || MAX1 == "") { while (CountdownThread.CancellationPending == false) { WaitTimer.Stop(); Log.MakeLog(null, "required things are blank: FROM: " + FROM + " TO: " + TO + " COMPRESSION:" + Compression + "TIMER: " + MAX.ToString()); this.Invoke((MethodInvoker) delegate() { StartButton.Enabled = true; }); this.Invoke((MethodInvoker) delegate() { StopButton.Enabled = false; }); CountdownThread.CancelAsync(); this.Invoke((MethodInvoker) delegate() { HelpLabel.Visible = true; }); e.Cancel = true; return; } } #endregion if (dec != 0.00M && !CountdownThread.CancellationPending) //reset value when thread runs// { dec = 0.00M; } #region Assign variables DirFrom = FROM; DirTo = TO; if (!DirFrom.EndsWith("\\") && DirFrom != "FTP") { DirFrom = DirFrom + "\\"; } if (!DirTo.EndsWith("\\") && DirTo != "FTP") { DirTo = DirTo + "\\"; } #endregion while (dec < MAX && !CountdownThread.CancellationPending) //Checks the time left is less than the total time { //do nothing// } DateNTime = DateTime.Now.ToString("MM.dd.yyyy hh-mm-ss"); #region Create directory and copy world if (Directory.Exists(DirTo) && DirTo != "FTP") { if (!Directory.Exists(DirTo + DateNTime)) //create the directory for the current time if it does not exist { Directory.CreateDirectory(DirTo + DateNTime); } if (DirFrom == "FTP") //if the from directory is FTP, start FTP downloading { Ftp_Download FTP = new Ftp_Download(); FTP.main(DateNTime); if (Compression == "yes") { CompressionBackground.RunWorkerAsync(); } } else if (DirTo == "FTP") { Ftp_Upload upload = new Ftp_Upload(); upload.Upload(DateNTime); } else if (DirFrom != "FTP") //if the from directory is not FTP, copy the directory. { #region create directories foreach (string dirPath in Directory.GetDirectories(DirFrom, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(DirFrom, DirTo + DateNTime + "\\")); } foreach (string newPath in Directory.GetFiles(DirFrom, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(DirFrom, DirTo + DateNTime + "\\")); } #endregion if (Compression == "yes") { CompressionBackground.RunWorkerAsync(); } } else { //error } } else if (!Directory.Exists(DirTo) && DirTo != "FTP") { Directory.CreateDirectory(DirTo); if (DirFrom == "FTP") { Ftp_Download FTP = new Ftp_Download(); FTP.main(DateNTime); if (Compression == "yes") { CompressionBackground.RunWorkerAsync(); } } else { foreach (string CreateDir in Directory.GetDirectories(DirFrom, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(CreateDir.Replace(DirFrom, DirTo + DateNTime + "\\")); //create each sub directory } foreach (string file in Directory.GetFiles(DirFrom, "*", SearchOption.AllDirectories)) { File.Copy(file, file.Replace(DirFrom, DirTo + DateNTime + "\\")); //copy each file in sub directories, and in main directory } if (Compression == "yes") { CompressionBackground.RunWorkerAsync(); } } } else if (DirTo == "FTP") { Ftp_Upload Upload = new Ftp_Upload(); Upload.Upload(DateNTime); } else { //Error// MessageBox.Show("ERROR"); } #endregion } }
private void ShortTimerFinished(object sender, WaitTimer.WaitTimerEventArgs e) { Debug (String.Format ("Timer Finished : {0} Started : {1} : WaitTime : {2}", e.TimeFinished, e.TimeStarted, ExtendedTimeFormat(e.WaitTime))); try { if (Config.Instance.UseSendTime) Debug (String.Format ("{0} has passed! Checking if we should send email...", ExtendedTimeFormat(_shortTimer.WaitTime))); if (Config.Instance.UseLinesBeforeSend) { Debug (String.Format ("Chatlist contains {0} rows, minimum is set to {1}, {2}", ChatList.Count, Config.Instance.LinesBeforeSend, (ChatList.Count >= Config.Instance.LinesBeforeSend ? "Sending Email" : " return"))); } if (ChatList.Count < 1) { _shortTimer.Reset(); return; } // Send email if the List count is above the value setting if (Config.Instance.UseLinesBeforeSend && ChatList.Count < Config.Instance.LinesBeforeSend) return; try { SendMail(ChatList, string.Format("{0}", e.TimeFinished), "Chat/Events List"); } catch (Exception ex) { Debug("{0}", ex); } finally { // Clear list when we have sent it. ChatList.Clear(); } } catch (Exception ex) { Debug(ex.Message); } }
override public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera) { var body = Parent as Body; System.Diagnostics.Debug.Assert(body != null); Vector3 targetVelocity = TargetPosition - body.GlobalTransform.Translation; if (targetVelocity.LengthSquared() > 0.0001f) { targetVelocity.Normalize(); targetVelocity *= MaxVelocity; } Matrix m = body.LocalTransform; m.Translation += targetVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; body.LocalTransform = m; body.HasMoved = true; switch (State) { case BalloonState.DeliveringGoods: { var voxel = new VoxelHandle(chunks.ChunkData, GlobalVoxelCoordinate.FromVector3(body.GlobalTransform.Translation)); if (voxel.IsValid) { var surfaceVoxel = VoxelHelpers.FindFirstVoxelBelow(voxel); var height = surfaceVoxel.Coordinate.Y + 1; TargetPosition = new Vector3(body.GlobalTransform.Translation.X, height + 5, body.GlobalTransform.Translation.Z); Vector3 diff = body.GlobalTransform.Translation - TargetPosition; if (diff.LengthSquared() < 2) { State = BalloonState.Waiting; } } else { State = BalloonState.Leaving; } } break; case BalloonState.Leaving: TargetPosition = Vector3.UnitY * 100 + body.GlobalTransform.Translation; if (body.GlobalTransform.Translation.Y > VoxelConstants.ChunkSizeY + 2) { Die(); } break; case BalloonState.Waiting: TargetPosition = body.GlobalTransform.Translation; if (!WaitTimer.HasTriggered) { var voxel = new VoxelHandle(chunks.ChunkData, GlobalVoxelCoordinate.FromVector3(body.GlobalTransform.Translation)); if (voxel.IsValid) { var surfaceVoxel = VoxelHelpers.FindFirstVoxelBelow(voxel); var height = surfaceVoxel.Coordinate.Y + 6; TargetPosition = new Vector3(body.GlobalTransform.Translation.X, height + 0.5f * (float)Math.Sin(DwarfTime.LastTime.TotalGameTime.TotalSeconds), body.GlobalTransform.Translation.Z); } WaitTimer.Update(DwarfTime.LastTime); break; } if (!shipmentGiven) { shipmentGiven = true; } else { State = BalloonState.Leaving; } break; } }
public override async Task Action() { if (IsCreateAllOrders()) { if (!await CapacitiveDisplayFrame.StartAllOrder(_building)) { Status = new Result(ActionResult.Failed); return; } GarrisonButler.Log("Successfully started all work orders at {0}.", _building.Name); Status = new Result(ActionResult.Done); return; } // Otherwise we create them one by one var maxSettings = GaBSettings.Get().GetBuildingSettings(_building.Id).MaxCanStartOrder; var maxInProgress = maxSettings == 0 ? _building.ShipmentCapacity : Math.Min(_building.ShipmentCapacity, maxSettings); var maxToStart = maxInProgress - _building.ShipmentsTotal; var maxCanComplete = _building.maxCanComplete(); maxToStart = Math.Min(maxCanComplete, maxToStart); for (var i = 0; i < maxToStart; i++) { if (!await CapacitiveDisplayFrame.ClickStartOrderButton(_building)) { GarrisonButler.Diagnostic( "[ShipmentStart,{0}] Max number of tries ({1}) reached to start shipment at {2}", _building.Id, Building.StartWorkOrderMaxTries, _building.Name); Status = new Result(ActionResult.Failed); return; } await Coroutine.Yield(); } //} var timeout = new WaitTimer(TimeSpan.FromMilliseconds(10000)); timeout.Reset(); while (!timeout.IsFinished) { _building.Refresh(); maxSettings = GaBSettings.Get().GetBuildingSettings(_building.Id).MaxCanStartOrder; maxInProgress = maxSettings == 0 ? _building.ShipmentCapacity : Math.Min(_building.ShipmentCapacity, maxSettings); maxToStart = maxInProgress - _building.ShipmentsTotal; maxCanComplete = _building.maxCanComplete(); var max = Math.Min(maxCanComplete, maxToStart); if (max == 0) { GarrisonButler.Log("[ShipmentStart{1}] Finished starting work orders at {0}.", _building.Name, _building.Id); Status = new Result(ActionResult.Done); return; } GarrisonButler.Diagnostic("[ShipmentStart,{0}] Waiting for shipment to update.", _building.Id); await CommonCoroutines.SleepForRandomReactionTime(); await Coroutine.Yield(); } }
static async Task JumpOnWaterSurface() { if (!Me.IsSwimming) { return; } AutoAnglerBot.Log("Jumping up on water surface since I'm swimming but have water walking"); var sw = Stopwatch.StartNew(); while (StyxWoW.Me.IsSwimming) { if (StyxWoW.Me.IsBeingAttacked) { return; } if (sw.ElapsedMilliseconds > 15000) { var pool = BotPoi.Current.AsObject as WoWGameObject; if (pool != null) { AutoAnglerBot.Log("Moving to another spot since couldn't jump on top."); RemovePointAtTop(pool); } break; } try { // Make sure the player's pitch is not pointing down causing player to not being able to // water walk Lua.DoString("VehicleAimIncrement(1)"); WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend); await Coroutine.Wait(15000, () => Me.IsFalling || !Me.IsSwimming); if (SpellManager.HasSpell("Zen Flight") && AutoAnglerSettings.Instance.UseWaterWalking) { var timer = new WaitTimer(TimeSpan.FromSeconds(3)); timer.Reset(); while (!Me.IsSwimming && !Me.HasAura("Zen Flight") && !timer.IsFinished) { SpellManager.Cast("Zen Flight"); await Coroutine.Yield(); } if (Me.HasAura("Zen Flight")) { await Coroutine.Sleep(200); } } } finally { WoWMovement.MoveStop(WoWMovement.MovementDirection.JumpAscend); } if (await Coroutine.Wait(2000, () => !StyxWoW.Me.IsSwimming && !StyxWoW.Me.IsFalling)) { AutoAnglerBot.Log("Successfuly landed on water surface."); return; } } }
//tests public void StopwatchTest(MainForm frm) { Stopwatch timer = new Stopwatch(); WaitTimer wait = new WaitTimer(); long loopMax = 1000000000; long loopModulus = 100000000; long modNum = -1; try { _msg.Length = 0; _msg.Append("StopwatchTest started ...\r\n"); WriteMessageToLog(_msg.ToString()); timer.Start(); _msg.Length = 0; _msg.Append("\r\nTimed wait ... \r\n"); WriteMessageToLog(_msg.ToString()); wait.Wait((long)2); _msg.Length = 0; _msg.Append("Elapsed Time: "); _msg.Append(timer.FormattedElapsedTime); _msg.Append(Environment.NewLine); _msg.Append("Elapsed milliseconds: "); _msg.Append(timer.ElapsedMilliseconds.ToString("#,##0")); _msg.Append(Environment.NewLine); WriteMessageToLog(_msg.ToString()); _msg.Length = 0; _msg.Append("\r\nLooping "); _msg.Append(loopMax.ToString("#,##0")); _msg.Append(" times... \r\n"); WriteMessageToLog(_msg.ToString()); for (long num = 1; num <= loopMax; num++) { modNum = (num % loopModulus); if (modNum == 0) { _msg.Length = 0; _msg.Append("Loop count = "); _msg.Append(num.ToString("#,##0")); _msg.Append(" Elapsed time to this point: "); _msg.Append(timer.FormattedElapsedTime); WriteMessageToLog(_msg.ToString()); } } _msg.Length = 0; _msg.Append("Elapsed Time: "); _msg.Append(timer.FormattedElapsedTime); _msg.Append(Environment.NewLine); _msg.Append("Elapsed milliseconds: "); _msg.Append(timer.ElapsedMilliseconds.ToString("#,##0")); _msg.Append(Environment.NewLine); WriteMessageToLog(_msg.ToString()); timer.Stop(); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); WriteMessageToLog(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... StopwatchTest finished."); WriteMessageToLog(_msg.ToString()); } }
public override async Task Action() { using (var myLock = StyxWoW.Memory.AcquireFrame()) { // Record number of items in bags if first execution if (_oldEntriesCount == null) { _oldEntriesCount = new List<int>(); foreach (var entry in _entries) { _oldEntriesCount.Add((int) HbApi.GetNumberItemInBags(entry)); } } // take a stack of size 5 or more and mill var stackToMill = StyxWoW.Me.BagItems.GetEmptyIfNull() .FirstOrDefault(i => _entries.Contains(i.Entry) && i.StackCount >= 5); if (stackToMill == default(WoWItem)) { Status = new Result(ActionResult.Failed, "Couldn't find a proper stack to mill in bags."); return; } var itemId = stackToMill.Entry; var itemName = stackToMill.Name; var bagIndex = stackToMill.BagIndex; var bagSlot = stackToMill.BagSlot; var stackSize = stackToMill.StackCount; WoWMovement.MoveStop(); await CommonCoroutines.SleepForLagDuration(); if (_craftMortar != null) { var millingItem = HbApi.GetItemInBags(114942).FirstOrDefault(); if (millingItem == default(WoWItem)) { Status = new Result(ActionResult.Failed, "[Mill] no draenic mortar item in bags found. operation failed."); return; } millingItem.Use(); await CommonCoroutines.SleepForLagDuration(); } else { // Search for milling spell var millingSpell = WoWSpell.FromId(51005); await HbApi.CastSpell(millingSpell); } stackToMill.UseContainerItem(); await CommonCoroutines.SleepForLagDuration(); // Verification process // Refresh of the current state var bagWithMilledItem = default(WoWContainer); var itemMilled = default(WoWItem); var waitTimer = new WaitTimer(TimeSpan.FromMilliseconds(1500)); // cast time supposed to be 1000s waitTimer.Reset(); while (!waitTimer.IsFinished) { await Coroutine.Yield(); //If casting if (StyxWoW.Me.IsCasting) continue; ObjectManager.Update(); try { bagWithMilledItem = StyxWoW.Me.GetBagAtIndex((uint) bagIndex); if (bagWithMilledItem != null) { itemMilled = bagWithMilledItem.GetItemBySlot((uint) bagSlot); if (itemMilled != null) GarrisonButler.Diagnostic( "[Milling] In bags after milling at (bagIndex={0},bagSlot={1}): stackSize={2}, itemName={3}", bagIndex, bagSlot, itemMilled.StackCount, itemMilled.Name); if (itemMilled == null || itemMilled.Entry != itemId || itemMilled.StackCount < stackSize) { GarrisonButler.Diagnostic("[Milling] Confirmed milled, break."); break; } } } catch (Exception) { break; } } await CommonCoroutines.SleepForLagDuration(); if (bagWithMilledItem == null) { Status = new Result(ActionResult.Failed, string.Format("[Milling] wrong bag index. index={0}, slot={1}, itemId={2}", bagIndex, bagSlot, itemId)); return; } if (itemMilled != null && itemMilled.Entry == itemId && itemMilled.StackCount >= stackSize) { Status = new Result(ActionResult.Failed, string.Format( "[Milling] itemMilled not null, and stackCount didn't change. index={0}, slot={1}, itemId={2}, oldSize={3}, newSize={4}", bagIndex, bagSlot, itemId, stackSize, itemMilled.StackCount)); return; } GarrisonButler.Log("[Milling] Succesfully milled {0}.", itemName); } }
// =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public static void SweepTimer() { var maxSweepTime = TimeSpan.FromSeconds(30); _sweepTimer = new WaitTimer(maxSweepTime) {WaitTime = maxSweepTime}; }
private async Task<bool> Completed() { if (_completedWaitTimer == null) _completedWaitTimer = QuestId == 359927 ? new WaitTimer(TimeSpan.FromSeconds(15)) : new WaitTimer(TimeSpan.FromSeconds(3)); if (!_completedWaitTimer.IsFinished) return false; _completedWaitTimer = null; _isDone = true; if (Stats != null) { Stats.EndTime = DateTime.UtcNow; Stats.IsCompleted = true; Logger.Log(LogLevel.Overlay, "[Bounty] Completed {0} ({1}) Time {2:hh\\:mm\\:ss}", QuestData.Name, QuestId, Stats.EndTime - Stats.StartTime); } return true; }
public static Composite CreateBrewmasterMonkInstanceCombat() { TankManager.NeedTankTargeting = (SingularRoutine.CurrentWoWContext == WoWContext.Instances); var powerStrikeTimer = new WaitTimer(TimeSpan.FromSeconds(20)); return new PrioritySelector( Helpers.Common.EnsureReadyToAttackFromMelee(), CreateCloseDistanceBehavior(), Spell.WaitForCastOrChannel(), new Decorator( req => !Spell.IsGlobalCooldown(), new PrioritySelector( SingularRoutine.MoveBehaviorInlineToCombat(BehaviorType.Heal), SingularRoutine.MoveBehaviorInlineToCombat(BehaviorType.CombatBuffs), Helpers.Common.CreateInterruptBehavior(), Movement.WaitForFacing(), Movement.WaitForLineOfSpellSight(), // Execute if we can Common.CastTouchOfDeath(), // make sure I have aggro. new Decorator( req => SingularSettings.Instance.EnableTaunting, new Decorator( req => TankManager.Instance.NeedToTaunt.FirstOrDefault() != null, new PrioritySelector( new Decorator( req => TankManager.Instance.NeedToTaunt.Count() > 1, new PrioritySelector( new Sequence( CreateSummonBlackOxStatueBehavior( on => TankManager.Instance.NeedToTaunt.FirstOrDefault()), new Wait(1, until => FindStatue() != null, new ActionAlwaysSucceed()), Spell.Cast("Provoke", ret => FindStatue()) ), Spell.Cast("Provoke", ret => TankManager.Instance.NeedToTaunt.FirstOrDefault()), CastDizzyingHaze() ) ) ) ) ), // highest priority -- Keg Smash for threat and debuff Spell.Cast("Keg Smash", req => Me.MaxChi - Me.CurrentChi >= 2 && Clusters.GetCluster(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Radius, 8).Any(u => !u.HasAura("Weakened Blows"))), // taunt if needed new Throttle( TimeSpan.FromMilliseconds(1500), Spell.CastOnGround("Dizzying Haze", on => TankManager.Instance.NeedToTaunt.FirstOrDefault(), req => TankManager.Instance.NeedToTaunt.Any(), false) ), // AOE new Decorator( req => Spell.UseAOE && Unit.UnfriendlyUnits(8).Count() >= 3, new PrioritySelector( // cast breath of fire to apply the dot. Spell.Cast("Breath of Fire", ctx => Clusters.GetCluster(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Cone, 8).Count(u => u.HasAura("Dizzying Haze") && !u.HasAura("Breath of Fire")) >= 3), Spell.BuffSelf("Zen Sphere", ctx => HasTalent( MonkTalents.ZenSphere) && Me.HealthPercent < 90), // aoe stuns Spell.Cast("Charging Ox Wave", ctx => TalentManager.IsSelected((int)MonkTalents.ChargingOxWave) && Clusters.GetClusterCount(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Cone, 30) >= 3), Spell.Cast("Leg Sweep", ctx => TalentManager.IsSelected((int)MonkTalents.LegSweep)), Spell.Cast("Spinning Crane Kick", req => Unit.NearbyUnfriendlyUnits.Count(u => u.DistanceSqr <= 8 * 8) >= MonkSettings.SpinningCraneKickCnt), Spell.Cast("Rushing Jade Wind", req => HasTalent(MonkTalents.RushingJadeWind) && Unit.NearbyUnfriendlyUnits.Count(u => u.DistanceSqr <= 8 * 8) >= 3) ) ), Spell.BuffSelf("Purifying Brew", ctx => Me.HasAura("Stagger") && Me.CurrentChi >= 3), new Decorator( req => Me.CurrentChi <= (Me.MaxChi - 2), new PrioritySelector( Spell.Cast("Keg Smash"), Spell.Cast("Expel Harm"), Spell.Cast("Jab") ) ), // use dizzying only if target not in range of keg smash or running away and doesnt have debuff CastDizzyingHaze(), new Decorator( req => Me.CurrentChi > 2, new PrioritySelector( Spell.BuffSelf("Elusive Brew", ctx => MonkSettings.UseElusiveBrew && Me.HasAura("Elusive Brew", MonkSettings.ElusiveBrewMinumumCount)), Spell.BuffSelf("Purifying Brew", ctx => Me.HasAnyAura("Moderate Stagger", "Heavy Stagger") && Me.CurrentChi >= 3), Spell.Cast("Blackout Kick", ctx => SpellManager.HasSpell("Brewmaster Training") && Me.HasKnownAuraExpired("Shuffle", 1)), Spell.Cast("Guard"), Spell.Cast("Blackout Kick", req => Me.CurrentChi >= 4), Spell.Cast("Tiger Palm", ret => Me.HasKnownAuraExpired("Tiger Power", 2)) ) ), // filler: // cast on cooldown when Level < 26 (Guard) or Level >= 34 (Brewmaster Training), otherwise try to save some Chi for Guard if available Spell.Cast("Tiger Palm", ret => SpellManager.HasSpell("Brewmaster Training") || Me.CurrentChi > 2 || !SpellManager.HasSpell("Guard") || Spell.GetSpellCooldown("Guard").TotalSeconds > 4) ) ) ); }
private async Task<bool> ReturningToTown() { DisablePulse(); if (_returningToTownbWaitTimer == null) { _returningToTownbWaitTimer = new WaitTimer(TimeSpan.FromSeconds(5)); _returningToTownbWaitTimer.Reset(); } if (!_returningToTownbWaitTimer.IsFinished) return false; if (!await TownPortalCoroutine.UseWaypoint()) return false; _returningToTownbWaitTimer = null; State = States.InTown; return false; }
private void WaitTimer_Tick(object sender, EventArgs e) { tbCommunication.AppendText(string.Format("WaitTimer active for: {0}{1}", WaitTimer.Interval.ToString(), "\r\n")); WaitTimer.Stop(); }
public BehaviorSleep(int milliseconds) { _sleeptimer = new WaitTimer(new TimeSpan(0, 0, 0, 0, milliseconds)); }
/// <summary> /// Find and mill one of a stack of ItemId in bags. Uses milling spell or draenic mortar. /// </summary> /// <param name="itemId"></param> /// <returns></returns> internal static async Task<ActionResult> MillHerbFromBags(uint itemId) { // Conditions to check using (var myLock = Styx.StyxWoW.Memory.AcquireFrame()) { // Search for a stack in bags var stackToMill = Me.BagItems.GetEmptyIfNull().FirstOrDefault(i => i.Entry == itemId); if (stackToMill == default(WoWItem)) { GarrisonButler.Diagnostic("[Milling] No item found in bags, id={0}", itemId); return ActionResult.Failed; } // Must have inscription or item var inscription = Me.GetSkill(SkillLine.Inscription); if (inscription == null) { GarrisonButler.Diagnostic("[Milling] Inscription == null. operation failed."); return ActionResult.Failed; } if (!inscription.IsValid) { GarrisonButler.Diagnostic("[Milling] Inscription is not valid. operation failed."); return ActionResult.Failed; } WoWSpell millingSpell = default(WoWSpell); var millingItem = default(WoWItem); if (inscription.CurrentValue <= 0) { millingItem = GetItemInBags(114942).FirstOrDefault(); if (millingItem == default(WoWItem) || millingItem.StackCount <= 0) { GarrisonButler.Diagnostic( "[Milling] Inscription value <= 0 and no milling item in bags found. operation failed."); return ActionResult.Failed; } if (!millingItem.Usable) { GarrisonButler.Diagnostic( "[Milling] Milling item unusable. operation failed."); return ActionResult.Failed; } } else { // We use spell to mill // Search for milling spell millingSpell = WoWSpell.FromId(51005); if (millingSpell == null) { GarrisonButler.Diagnostic("[Milling] Milling spell not found(==null)."); return ActionResult.Failed; } if (!millingSpell.IsValid) { GarrisonButler.Diagnostic("[Milling] Milling spell not valid."); return ActionResult.Failed; } if (!millingSpell.CanCast) { GarrisonButler.Diagnostic("[Milling] Can't cast milling spell."); return ActionResult.Failed; } } var bagIndex = stackToMill.BagIndex; var bagSlot = stackToMill.BagSlot; var stackSize = stackToMill.StackCount; var itemName = stackToMill.SafeName; GarrisonButler.Diagnostic( "[Milling] In bags before milling at (bagIndex={0},bagSlot={1}): stackSize={2}, itemName={3}", bagIndex, bagSlot, stackSize, itemName); // Mill once using spell if (millingSpell != default(WoWSpell)) await CastSpell(millingSpell); else { millingItem.Use(); await CommonCoroutines.SleepForLagDuration(); } stackToMill.UseContainerItem(); await CommonCoroutines.SleepForLagDuration(); //// Wait for Cast //await Buddy.Coroutines.Coroutine.Wait(10000, () => !Me.IsCasting); // Verification process // Refresh of the current state var bagWithMilledItem = default(WoWContainer); var itemMilled = default(WoWItem); var waitTimer = new WaitTimer(TimeSpan.FromMilliseconds(1500)); // cast time supposed to be 1000s waitTimer.Reset(); while (!waitTimer.IsFinished) { await Buddy.Coroutines.Coroutine.Yield(); //If casting if (Me.IsCasting) continue; ObjectManager.Update(); try { bagWithMilledItem = Me.GetBagAtIndex((uint) bagIndex); if (bagWithMilledItem != null) { itemMilled = bagWithMilledItem.GetItemBySlot((uint) bagSlot); if (itemMilled != null) GarrisonButler.Diagnostic( "[Milling] In bags after milling at (bagIndex={0},bagSlot={1}): stackSize={2}, itemName={3}", bagIndex, bagSlot, itemMilled.StackCount, itemMilled.Name); if (itemMilled == null || itemMilled.Entry != itemId || itemMilled.StackCount < stackSize) { GarrisonButler.Diagnostic("[Milling] Confirmed milled, break."); break; } } } catch (Exception) { break; } } await CommonCoroutines.SleepForLagDuration(); if (bagWithMilledItem == null) { GarrisonButler.Diagnostic("[Milling] wrong bag index. index={0}, slot={1}, itemId={2}", bagIndex, bagSlot, itemId); return ActionResult.Failed; } if (itemMilled != null && itemMilled.Entry == itemId && itemMilled.StackCount >= stackSize) { GarrisonButler.Diagnostic( "[Milling] itemMilled not null, and stackCount didn't change. index={0}, slot={1}, itemId={2}, oldSize={3}, newSize={4}", bagIndex, bagSlot, itemId, stackSize, itemMilled.StackCount); return ActionResult.Failed; } GarrisonButler.Log("[Milling] Succesfully milled {0}.", itemName); } return ActionResult.Done; }
protected override Composite CreateBehavior_CombatMain() { return(new PrioritySelector( new Decorator(context => !IsDone && !Me.IsActuallyInCombat, new PrioritySelector( // Update Location if relative coord is used... // N.B. Relative locations are only used while on transports and because // transports are usually moving around 'Location' needs to be updated on every frame. new Decorator(context => UseRelativeLocation, new Action(context => Destination = CalculateRelativeLocation(OrigDestination))), // Initialize the timer... new Decorator(context => _runTimer == null, new Action(context => { _runTimer = new WaitTimer(Destination.MaximumTraversalTime(2.5, TimeSpan.FromSeconds(20), UpperLimitOnMovementTime)); QBCLog.DeveloperInfo("Maximum allowed time to reach destination: {0} seconds", _runTimer.WaitTime.TotalSeconds); _runTimer.Reset(); return RunStatus.Failure; })), // Stop HB if _runTimer finishes... new Decorator(context => _runTimer.IsFinished, new Action(context => { WoWMovement.MoveStop(); // N.B. set the runtimer to null so if player manually correct // problem and starts bot up it restarts the timer. _runTimer = null; QBCLog.Fatal("MyCTM is not able to reach {0} from {1}", DestinationName, WoWMovement.ActiveMover.Location); })), // Run stuckhandler CreateBehavior_Antistuck(), // Default anti-stuck has issues. // new Decorator(context => Navigator.NavigationProvider.StuckHandler.IsStuck(), // new Action(context => Navigator.NavigationProvider.StuckHandler.Unstick())), // check if bot has reached the destination. new Decorator(context => Destination.DistanceSqr(Me.Location) <= (3 * 3), new Action(context => { BehaviorDone(string.Format("Finished moving to {0}", DestinationName)); // Drop down to 'CreateBehavior_PerformCTM' to ensure ctm is performed // at least once if start and destination locations are very close on start return RunStatus.Failure; })), CreateBehavior_PerformCTM() )), // _runTimer needs to be recalculated after combat is over and stuck timer needs to rest. new Decorator(context => Me.IsActuallyInCombat, new Action(context => { _runTimer = null; _stuckTimer.Reset(); return RunStatus.Failure; })) )); }
// 11Apr2013-04:41UTC chinajade public static bool IsInCompetition(WoWObject wowObject, double nonCompeteDistance) { if (!IsViable(wowObject)) { return(false); } // Shared world resources are never in competition... if (IsSharedWorldResource(wowObject)) { return(false); } // If unit is tagged by someone else and in combat, it is in competition... // N.B. There are some cases where NPCs are shown as tagged by - // someone else yet nobody is actively engaged with said unit. // If unit is not in combat with anyone and it is tagged and nobody else is around it can not be in competition. // On the other hand if we choose to ignore the tagged unit and it's the only NPC that exists in the world then bot will be stuck var wowUnit = wowObject as WoWUnit; var isTaggedByOther = ((wowUnit != null) && !wowUnit.IsUntagged() && wowUnit.Combat); if (isTaggedByOther) { return(true); } ProvideBoolDelegate excludeGroupMembers = (potentialGroupMember => { var asWoWPlayer = potentialGroupMember as WoWPlayer; return((asWoWPlayer != null) && !asWoWPlayer.IsInMyParty); }); var isPlayersNearby = FindPlayersNearby(wowObject.Location, nonCompeteDistance, excludeGroupMembers).Any(); var isCompetitionTimerRunning = s_inCompetitionTimers.ContainsKey(wowObject.Guid); // If players are clear, and competition timer is running... // We no longer need the competition timer. if (!isPlayersNearby && isCompetitionTimerRunning) { s_inCompetitionTimers.Remove(wowObject.Guid); } // If players are nearby, and we haven't established competition timer... // We need to record time at which we start the wait. if (isPlayersNearby && !isCompetitionTimerRunning) { // Add new entry... s_inCompetitionTimers.Add(wowObject.Guid, DateTime.Now); // Time to sweep away old 'in competition' entries? if ((s_inCompetitionSweepTimer == null) || s_inCompetitionSweepTimer.IsFinished) { // Remove expired 'in competition' entries... var now = DateTime.Now; var keysToRemove = (from kvp in s_inCompetitionTimers where now > (kvp.Value + s_inCompetitionSweepTime) select kvp.Key) .ToArray(); foreach (var key in keysToRemove) { s_inCompetitionTimers.Remove(key); } // Reset sweep timer (creating it, if necessary)... if (s_inCompetitionSweepTimer == null) { s_inCompetitionSweepTimer = new WaitTimer(s_inCompetitionSweepTime); } s_inCompetitionSweepTimer.Reset(); } } // If we've been waiting on object too long, it is no longer 'in competition'... // NB: Since group membership affects 'nearby players', we must make this test // after the competition timers have been updated due to nearby players. DateTime waitStart; if (s_inCompetitionTimers.TryGetValue(wowObject.Guid, out waitStart)) { if (DateTime.Now > (waitStart + s_inCompetitionMaxWaitTime)) { return(false); } // Fall through, if we haven't been waiting too long... } return(isPlayersNearby); }
public async Task GatherWeatherNodes() { if (WorldManager.RawZoneId != 901) { await EnterDiadem(); Log($"Waiting for instance time"); await Coroutine.Wait(5000, () => TimeLeftInDiadem.TotalMinutes > 1); Log($"Time left {TimeLeftInDiadem:hh\\:mm\\:ss}"); } lastChange = new WaitTimer(new TimeSpan(0, 7, 0)); Log($"Current Weather: {WorldManager.CurrentWeather} {WorldManager.CurrentWeatherId}"); Random time = new Random(); int minutes = time.Next(10, 20); int sec = time.Next(0, 59); standBy = afkSpots[time.Next(0, afkSpots.Length)]; while (TimeLeftInDiadem > new TimeSpan(0, minutes, sec)) { switch (WorldManager.CurrentWeatherId) { case 133: if (lastWeather == 133) { break; } //await FlyTo(new Vector3(-295.9257f, 268.4518f, -370.327f)); await MineWeather(ClassJobType.Miner, umbralFlareAbove, umbralFlare); standBy = afkSpots[time.Next(0, afkSpots.Length)]; await StandBy(); break; case 135: if (lastWeather == 135) { break; } await MineWeather(ClassJobType.Miner, umbralLevinAbove, umbralLevin); standBy = afkSpots[time.Next(0, afkSpots.Length)]; await StandBy(); break; case 134: if (lastWeather == 134) { break; } await MineWeather(ClassJobType.Botanist, umbralDuststormAbove, umbralDuststorm); standBy = afkSpots[time.Next(0, afkSpots.Length)]; await StandBy(); break; case 136: if (lastWeather == 136) { break; } await MineWeather(ClassJobType.Botanist, umbralTempestAbove, umbralTempest); standBy = afkSpots[time.Next(0, afkSpots.Length)]; await StandBy(); break; default: await Coroutine.Sleep(1000); if (lastChange.IsFinished) { lastChange.Reset(); lastWeather = 0; } await StandBy(); break; } await Coroutine.Sleep(1000); } if (DutyManager.InInstance) { Log($"Out of time: {TimeLeftInDiadem:hh\\:mm\\:ss} Left"); DutyManager.LeaveActiveDuty(); if (await Coroutine.Wait(30000, () => CommonBehaviors.IsLoading)) { await Coroutine.Yield(); await Coroutine.Wait(Timeout.Infinite, () => !CommonBehaviors.IsLoading); await Coroutine.Sleep(10000); } } }
private void WaitTimer_Tick(object sender, EventArgs e) { WaitTimer.Stop(); }
public void Reset() { _isDone = false; _waitTimer = null; }
protected override Composite CreateBehavior() { return _root ?? (_root = new PrioritySelector( new Decorator(ret => IsDone, new Action(c => { TreeRoot.StatusText = "Demon banishing complete!"; })), new Decorator(ret => null == NearestUnit, new PrioritySelector( new Decorator(ret => waypoints.Peek() != _nextWaypoint, new Action(c => { _nextWaypoint = waypoints.Peek(); TreeRoot.StatusText = "No mobs nearby, moving to next waypoint: " + _nextWaypoint; })), new Decorator(ret => _nextWaypoint.DistanceSqr(Me.Location) > DistanceCheckSqr, new Action(c => { Navigator.MoveTo(_nextWaypoint); })), new Action(c => { waypoints.Dequeue(); }) )), new Decorator(ret => null == DroppedPortal, new PrioritySelector( new Decorator(ret => Me.Auras.ContainsKey(DruidSwiftFlightForm) || Me.Auras.ContainsKey(DruidFlightForm), new Action(c => { TreeRoot.StatusText = "Cancelling flight form."; Lua.DoString("CancelShapeshiftForm()"); })), new Decorator(ret => Me.Mounted, new Action(c => { TreeRoot.StatusText = "Dismounting."; Lua.DoString("Dismount()"); })), new Decorator(ret => Item.Cooldown > 0f, new Action(c => { TreeRoot.StatusText = "Waiting on banishing crystal cooldown."; })), new Action(c => { TreeRoot.StatusText = "Dropping banishing portal."; Item.UseContainerItem(); }) )), new Decorator(ret => null != _nearestUnit && (null != DroppedPortal || _nearestUnit.IsTargetingMeOrPet), new PrioritySelector( new Decorator(ret => !_nearestUnit.IsAlive, new Action(c => { TreeRoot.StatusText = "Current target is dead."; _nearestUnit = NearestUnit; })), new Decorator(ret => Me.Auras.ContainsKey(DruidSwiftFlightForm) || Me.Auras.ContainsKey(DruidFlightForm), new Action(c => { TreeRoot.StatusText = "Cancelling flight form."; Lua.DoString("CancelShapeshiftForm()"); })), new Decorator(ret => Me.Mounted, new Action(c => { TreeRoot.StatusText = "Dismounting."; Lua.DoString("Dismount()"); })), new Action(c => { // not supposed to have to use loops and sleep but I don't know how to prevent CC combat otherwise if (null != Me.Pet) { Lua.DoString("PetPassiveMode()"); } TreeRoot.StatusText = "Agroing target."; while (_nearestUnit.IsAlive && !_nearestUnit.IsTargetingMeOrPet) { Navigator.MoveTo(_nearestUnit.Location); Thread.Sleep(100); } if (_nearestUnit.IsDemon) { TreeRoot.StatusText = "Moving back to portal."; while (null != DroppedPortal && _nearestUnit.IsAlive && _nearestUnit.IsTargetingMeOrPet && DroppedPortal.Location.DistanceSqr(_nearestUnit.Location) > AttackRangeSqr) { Navigator.MoveTo(DroppedPortal.Location); Thread.Sleep(100); } WaitTimer banishTimer = new WaitTimer(TimeSpan.FromSeconds(20)); TreeRoot.StatusText = "Waiting for target to get banishment."; while (null != DroppedPortal && _nearestUnit.IsAlive && _nearestUnit.IsTargetingMeOrPet && null == _nearestUnit.GetAuraById(BanishmentId)) { Thread.Sleep(100); if (banishTimer.IsFinished) break; } } bool doBackUp = false; while (_nearestUnit.IsAlive && _nearestUnit.IsTargetingMeOrPet) { while (!Me.IsSafelyFacing(_nearestUnit)) { _nearestUnit.Face(); doBackUp = true; } if (doBackUp) { WoWMovement.Move(WoWMovement.MovementDirection.Backwards); Thread.Sleep(500); WoWMovement.MoveStop(WoWMovement.MovementDirection.Backwards); doBackUp = false; } if (Me.CurrentTargetGuid != _nearestUnit.Guid) { _nearestUnit.Target(); } if (!Me.IsAutoAttacking) { Lua.DoString("AttackTarget()"); } Thread.Sleep(100); } Blacklist.Add(_nearestUnit, BlacklistTime); _nearestUnit = null; }) ))//, //new Action(c => { TreeRoot.StatusText = "ASSERT: Shouldn't get here"; }) )); }
public LocalBlacklist(TimeSpan maxSweepTime) { _sweepTimer = new WaitTimer(maxSweepTime); _sweepTimer.WaitTime = maxSweepTime; }
public void MakeTimerForCheckReceipt() { waitTimer = new WaitTimer( 50, SendCheckReceipt , "Re Send Check Receipt"); Debug.Log( "timer check Receipt"); }