private void ErrorHandling() { if (ErrorDialog.IsVisible) { // Check if Demonbuddy found errordialog if (!handlederror) { Send("CheckConnection", pause: true); handlederror = true; } else { handlederror = false; ErrorDialog.Click(); bootTo(); } } else if (UIElementTester.isValid(_UIElement.errordialog_okbutton)) { // Demonbuddy failed to find error dialog use static hash to find the OK button Send("CheckConnection", pause: true); UIElement.FromHash(_UIElement.errordialog_okbutton).Click(); bootTo(); } else { handlederror = false; if (UIElementTester.isValid(_UIElement.loginscreen_username)) { // We are at loginscreen Send("CheckConnection", pause: true); } } }
/// <summary> /// UIElement validation check /// </summary> /// <param name="hash">UIElement hash to check</param> /// <param name="isEnabled">should be enabled</param> /// <param name="isVisible">should be visible</param> /// <param name="bisValid">should be a valid UIElement</param> /// <returns>true if all requirements are valid</returns> public static bool isValid(ulong hash, bool isEnabled = true, bool isVisible = true, bool bisValid = true) { try { if (!UIElement.IsValidElement(hash)) { return(false); } else { var element = UIElement.FromHash(hash); if ((isEnabled && !element.IsEnabled) || (!isEnabled && element.IsEnabled)) { return(false); } if ((isVisible && !element.IsVisible) || (!isVisible && element.IsVisible)) { return(false); } if ((bisValid && !element.IsValid) || (!bisValid && element.IsValid)) { return(false); } } } catch { return(false); } return(true); }
void CheckNotificationUI() { try { Zeta.Internals.UIElement ui = null; if (Zeta.Internals.UIElement.IsValidElement(0x4CC93A73A58BAFFF) && (ui = Zeta.Internals.UIElement.FromHash(0x4CC93A73A58BAFFF)) != null) { if (ui.IsVisible) { Log(String.Format("Detect UI = {0}, Visible = {1}", ui.Name, ui.IsVisible)); Zeta.Internals.UIElement Button = null; if (Zeta.Internals.UIElement.IsValidElement(0xB4433DA3F648A992) && (Button = Zeta.Internals.UIElement.FromHash(0xB4433DA3F648A992)) != null) { if (Button.IsVisible) { Log("Notification OK clicked"); Button.Click(); // Case for click OK when Disconnect popups in Start/Resume menu if (Zeta.Internals.UIElement.IsValidElement(0x51A3923949DC80B7) && (Button = Zeta.Internals.UIElement.FromHash(0x51A3923949DC80B7)) != null) { if (Button.IsVisible && Button.IsEnabled) { Log("Resume/Start Button clicked"); Button.Click(); } } } } } } else if (Zeta.Internals.UIElement.IsValidElement(0x7355E17C5FE4B253) && (ui = Zeta.Internals.UIElement.FromHash(0x7355E17C5FE4B253)) != null) { // Party notification if (ui.IsVisible) { Log(String.Format("Detect UI = {0}, Visible = {1}", ui.Name, ui.IsVisible)); Zeta.Internals.UIElement Button = null; if (Zeta.Internals.UIElement.IsValidElement(0xB4433DA3F648A992) && (Button = Zeta.Internals.UIElement.FromHash(0xB4433DA3F648A992)) != null) { if (Button.IsVisible) { Log("Party Notification click"); Button.Click(); } } } } } catch (Exception) { } }
protected override Composite CreateBehavior() { try { Zeta.Internals.UIElement okBtn = Zeta.Internals.UIElements.ConfirmationDialogOkButton; healthCheck(); return(new PrioritySelector( new Decorator(ret => isBusy(), new Zeta.TreeSharp.Action(delegate { if (isBusy()) { return RunStatus.Running; } else { return RunStatus.Success; } } ) ), new Decorator(ret => okBtn != null && okBtn.IsValid && okBtn.IsVisible, new Zeta.TreeSharp.Action(delegate { Logging.WriteDiagnostic("[ConfirmOK] Clicking OK"); okBtn.Click(); return RunStatus.Success; } ) ), new Zeta.TreeSharp.Action(delegate { Logging.WriteDiagnostic("[ConfirmOK] Finished"); m_IsDone = true; } ) )); } catch (Exception ex) { Logging.WriteException(ex); return(new Zeta.TreeSharp.Action(delegate { m_IsDone = true; })); } }
/// <summary> /// Checks to see if the Confirmation OK Dialog box is visible /// </summary> /// <returns></returns> private bool ConfirmationDialogVisible() { try { Zeta.Internals.UIElement okBtn = Zeta.Internals.UIElements.ConfirmationDialogOkButton; if (okBtn != null && okBtn.IsValid && okBtn.IsVisible) { return(true); } else { return(false); } } catch { return(false); } }
/* This method checks to see if the leader is in a different Level Area than the follower. If it is, then we need to see if there is a portal nearby, and if so use it. -- do not use portal if we are near a boss portal or in a boss area */ private void leaderLevelAreaChangeCheck(int levelAreaID) { if (nearBossPortal()) { Log("leaderLevelAreaChangeCheck() - WARNING! We are near a Boss portal!"); } // if we don't find a portal then we need to TP and banner bool portalFound = false; // check if the leader's Level Area ID is different to the follower's // We can't be fighting a boss or near a boss portal... if either of these are true, then it's best to // TP to town if it turns out that we have lost the leader if (ZetaDia.CurrentLevelAreaId != levelAreaID && !BossEncounter && !nearBossPortal()) { // Is there a portal nearby // if so, locate portal and use it foreach (Actor worldActor in ZetaDia.Actors.RActorList) { // in order to be able to use the object's data we need to convert it to a DiaObject DiaObject worldObject = (DiaObject)worldActor; Log("leaderLevelAreaChangeCheck() - looking for a portal"); // is the object a portal, within 30 feet and NOT a BossPortal ? if(worldObject is Zeta.Internals.Actors.Gizmos.GizmoPortal && worldObject.Distance < 50) { // portal found portalFound = true; Log("leaderLevelAreaChangeCheck() - There is portal nearby!"); // move to the portal Log("leaderLevelAreaChangeCheck() - Moving to the portal"); while (ZetaDia.Me.Position.Distance(worldObject.Position) > 10) { ZetaDia.Me.UsePower(SNOPower.Walk, worldObject.Position, ZetaDia.Me.WorldDynamicId, -1); } BotMain.PauseFor(System.TimeSpan.FromSeconds(randomNumber.Next(2, 3))); // store the followers current coordinates Vector3 prePortalCoordinates = ZetaDia.Me.Position; // get me through that portal // repeat until our world position has changed while(prePortalCoordinates.Distance(ZetaDia.Me.Position) < 5) { Log("leaderLevelAreaChangeCheck() - Use dat portal, mon"); ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, worldObject.Position, ZetaDia.Me.WorldDynamicId, worldObject.ACDGuid); // pause bot for a bit BotMain.PauseFor(System.TimeSpan.FromSeconds(randomNumber.Next(1, 2))); // Portal stone OK button // this pops up for a number of reasons: // - Portal Stone use if (Zeta.Internals.UIElement.IsValidElement(0x891D21408238D18E) && (Button = Zeta.Internals.UIElement.FromHash(0x891D21408238D18E)) != null) { if (Button.IsVisible) { // grab world ID int previousWorldID = ZetaDia.CurrentWorldId; Log("Clicking on OK button"); // click on the ACCEPT button Button.Click(); pauseForABit(2, 3); // wait till we get to the destination while(ZetaDia.CurrentWorldId == previousWorldID) { // do nothing Log("leaderLevelAreaChangeCheck() - we are transitioning out of this world, via the portal stone"); } } } } // Set this follower's DudeState file to Running, so that the leader knows that // all the followers are through the portal and ready to continue the run again // dudeRadio.updateDudeState("Running"); pauseForABit(1,2); // set the time portal was last used to the current time timeLastPortalWasUsed = DateTime.Now; break; } } // No portal // nothing more to check on, we may be out of range, so let that code deal with that possibility } if (!portalFound) { // no portal was found, so we need to head back to town Log("No portal found, let's TP back to town and find the leader's banner"); catchUpWithTheParty(); } }
/* this mothod looks for and invite to a party, accepts it, and acquires an ID for the dude updates the PartyState file, signifying this dude is in the part */ private void checkForPartyInvite() { Log("checkForPartyInvite() - We are in Party Creation mode"); // Wait for invite if (Zeta.Internals.UIElement.IsValidElement(0x9EFA05648195042D) && (Button = Zeta.Internals.UIElement.FromHash(0x9EFA05648195042D)) != null) { // is the invite graphic visible if (Button.IsVisible) { Log("checkForPartyInvite() - Invite incoming!"); // invite has shown up, accept it pauseForABit(1, 3); Button.Click(); // Confirm joining party (click OK) if (Zeta.Internals.UIElement.IsValidElement(0xB4433DA3F648A992) && (Button = Zeta.Internals.UIElement.FromHash(0xB4433DA3F648A992)) != null) { // is the joining party confirmation button visible if (Button.IsVisible) { // invite has shown up, accept it pauseForABit(1, 3); Log("checkForPartyInvite() - Accepting the invite to the party"); // click ok Button.Click(); // we are now in a party } } // retrieve this dude's party member ID // required for inter-party communication partyID = dudeRadio.retrievePartyMemberID(); // update PartyState file saying this char is present // need to make sure that the PartyState for this characters is set to Present while (dudeRadio.thisDudeIsPresent(partyID) == false) { dudeRadio.updatePartyState("Present"); } } } // Follower leaving message // need to OKAY this in order to get rid of it if (Zeta.Internals.UIElement.IsValidElement(0xF85A00117F5902E9) && (Button = Zeta.Internals.UIElement.FromHash(0xF85A00117F5902E9)) != null) { if (Button.IsVisible) { Log("Follower is leaving message has popped up"); // click on the OK button Button.Click(); } } // Follower is joining up again - if you are the only one in the party, then might as well have the follower rejoin // need to OKAY this in order to get rid of it if (Zeta.Internals.UIElement.IsValidElement(0x161745BBCE22A8BA) && (Button = Zeta.Internals.UIElement.FromHash(0x161745BBCE22A8BA)) != null) { if (Button.IsVisible) { Log("Follower is joining message has popped up"); // click on the YES button Button.Click(); } } // Follower is joining up again - if you are the only one in the party, then might as well have the follower rejoin // need to OKAY this in order to get rid of it if (Zeta.Internals.UIElement.IsValidElement(0x161745BBCE22A8BA) && (Button = Zeta.Internals.UIElement.FromHash(0x161745BBCE22A8BA)) != null) { if (Button.IsVisible) { Log("Follower is joining message has popped up"); // click on the YES button Button.Click(); } } }
public void OnPulse() { // Plugin Will Crash D3 if not in game world // do not do anything IF // - we are not in the game // - we are still loading the world // - comms directory exists if (ZetaDia.IsInGame && !ZetaDia.IsLoadingWorld && Directory.Exists(commsDirectory)) { Zeta.CommonBot.LootTargeting.Instance.Pulse(); // get the current GameState currentGameState = dudeRadio.getGameState(); // keep on checking if the leader has finished with the boss and moved on if (BossEncounter && currentGameState != "BossEncounter") { Log("Boss fight is over, now where is the leader?"); BossEncounter = false; } // are we creating the party - start of a game if (currentGameState == "CreateParty") { // TP back to town while(!ZetaDia.Me.IsInTown) { // make sure there aren't any baddies about! Zeta.CommonBot.CombatTargeting.Instance.Pulse(); // To town, baby! ZetaDia.Me.UseTownPortal(); pauseForABit(1, 2); } checkForPartyInvite(); } else { // Are we on the run if (!inCombat() && !isLooting() && !isStashing() && (currentGameState == "Running" || currentGameState == "BossEncounter")) onTheRun(); // grab Dude's current state // PartyID will be = Dude1, Dude2, or Dude3 // string currentDudeState = dudeRadio.getDudeState(); // ready for when we add code that requires the Dude's state } // Portal stone OK button // this pops up for a number of reasons: // - Portal Stone use if (Zeta.Internals.UIElement.IsValidElement(0x891D21408238D18E) && (Button = Zeta.Internals.UIElement.FromHash(0x891D21408238D18E)) != null) { if (Button.IsVisible) { // grab world ID int previousWorldID = ZetaDia.CurrentWorldId; Log("Clicking on OK button"); // click on the ACCEPT button Button.Click(); pauseForABit(2, 3); // wait till we get to the destination while(ZetaDia.CurrentWorldId == previousWorldID) { // do nothing Log("we are transitioning out of this world, via the portal stone"); } } } // Boss Encounter // This clicks on the ACCEPT button of the boss encounter // found to be the same hash for all bosses // Skeleton King - The Butcher - Zultan Kull - Belial - Ghom - Azmodan - Diablo if (Zeta.Internals.UIElement.IsValidElement(0x69B3F61C0F8490B0) && (Button = Zeta.Internals.UIElement.FromHash(0x69B3F61C0F8490B0)) != null) { if (Button.IsVisible) { pauseForABit(1, 3); // click on the ACCEPT button Button.Click(); // set the boss encounter to true, so that we don't test for out of Range of the Leader BossEncounter = true; // Allow time to enter boss area while (!inBossArea()) { Log("We are transitioning to boss area"); pauseForABit(3, 4); } } } if (Zeta.Internals.UIElement.IsValidElement(0xF495983BA9BE450F) && (Button = Zeta.Internals.UIElement.FromHash(0xF495983BA9BE450F)) != null) { if (Button.IsVisible) { pauseForABit(1, 3); // click on the ACCEPT button Button.Click(); // set the boss encounter to true, so that we don't test for out of Range of the Leader BossEncounter = true; // Allow time to enter boss area while (!inBossArea()) { Log("We are transitioning to boss area"); pauseForABit(3, 4); } } } // Follower leaving message // need to OKAY this in order to get rid of it if (Zeta.Internals.UIElement.IsValidElement(0xF85A00117F5902E9) && (Button = Zeta.Internals.UIElement.FromHash(0xF85A00117F5902E9)) != null) { if (Button.IsVisible) { Log("Follower is leaving message has popped up"); // click on the OK button Button.Click(); } } // Follower is joining up again - if you are the only one in the party, then might as well have the follower rejoin // need to OKAY this in order to get rid of it if (Zeta.Internals.UIElement.IsValidElement(0x161745BBCE22A8BA) && (Button = Zeta.Internals.UIElement.FromHash(0x161745BBCE22A8BA)) != null) { if (Button.IsVisible) { Log("Follower is joining message has popped up"); // click on the YES button Button.Click(); } } // Follower is joining up again - if you are the only one in the party, then might as well have the follower rejoin // need to OKAY this in order to get rid of it if (Zeta.Internals.UIElement.IsValidElement(0x161745BBCE22A8BA) && (Button = Zeta.Internals.UIElement.FromHash(0x161745BBCE22A8BA)) != null) { if (Button.IsVisible) { Log("Follower is joining message has popped up"); // click on the YES button Button.Click(); } } Zeta.CommonBot.CombatTargeting.Instance.Pulse(); } // Dude died? // If the Revive at last checkpoint BUTTON pops up, then click on it if (Zeta.Internals.UIElement.IsValidElement(0xBFAAF48BA9316742) && (Button = Zeta.Internals.UIElement.FromHash(0xBFAAF48BA9316742)) != null) { if (Button.IsVisible) { Log("Revive at last checkpoint BUTTON has popped up"); // wait for a second or 2 pauseForABit(1, 2); Log("Clicking on the Revive at last checkpoint BUTTON"); // click on the Revive at last checkpoint BUTTON Button.Click(); // wait for a second or 2 pauseForABit(1, 2); } } }