private async Task <bool> Interacting() { if (ZetaDia.Me.IsFullyValid() && (_castWaitStartTime.Subtract(DateTime.UtcNow).TotalSeconds < 10 || _castWaitStartTime == DateTime.MinValue)) { if (ZetaDia.Me.CommonData.AnimationState == AnimationState.Casting) { _castWaitStartTime = DateTime.UtcNow; Core.Logger.Debug("Waiting while AnimationState.Casting"); await Coroutine.Sleep(500); return(false); } if (ZetaDia.Me.CommonData.AnimationState == AnimationState.Channeling) { _castWaitStartTime = DateTime.UtcNow; Core.Logger.Debug("Waiting while AnimationState.Channeling"); await Coroutine.Sleep(500); return(false); } } if (ZetaDia.Globals.IsLoadingWorld) { Core.Logger.Debug("Waiting for world load"); await Coroutine.Sleep(500); return(false); } if (ZetaDia.Globals.WorldSnoId != _startingWorldId) { Core.Logger.Debug("World changed, assuming done!"); await Coroutine.Sleep(2500); State = States.Completed; return(false); } var actor = GetActor(); if (actor == null) { Core.Logger.Debug("Nothing to interact, failing. "); State = States.Failed; return(false); } if (!string.IsNullOrEmpty(_endAnimation)) { var anim = actor.CommonData?.CurrentAnimation.ToString().ToLowerInvariant(); if (!string.IsNullOrEmpty(anim) && anim.Contains(_endAnimation.ToLowerInvariant())) { Core.Logger.Debug($"Specified end animation was detected {_endAnimation}, done!"); State = States.Completed; return(false); } } if (!string.IsNullOrEmpty(_startAnimation)) { var anim = actor.CommonData?.CurrentAnimation.ToString().ToLowerInvariant(); if (!string.IsNullOrEmpty(anim) && !anim.Contains(_startAnimation.ToLowerInvariant())) { Core.Logger.Debug($"Specified start animation was no longer detected {_startAnimation}, done!"); State = States.Completed; return(false); } } var unit = actor as DiaUnit; if (_isQuestGiver && unit != null && !unit.IsQuestGiver) { Core.Logger.Debug($"Unit {actor.Name} is no longer a quest giver, assuming done!"); State = States.Completed; return(false); } //if (actor.Distance > 75f) //{ // Core.Logger.Debug($"Actor is way too far away. {actor.Distance}"); // State = States.Failed; // return false; //} // Assume done if (!_ignoreSanityChecks && !actor.IsInteractableQuestObject()) { State = States.Completed; return(false); } if (_currentInteractAttempt > _interactAttempts) { Core.Logger.Debug($"Max interact attempts reached ({_interactAttempts})"); State = States.Completed; return(true); } if (_currentInteractAttempt > 1 && actor.Position.Distance(ZetaDia.Me.Position) > 5f) { Navigator.PlayerMover.MoveTowards(actor.Position); await Coroutine.Sleep(250 *_currentInteractAttempt); } if (_isPortal || actor.IsFullyValid() && GameData.PortalTypes.Contains(actor.CommonData.GizmoType)) { var worldId = ZetaDia.Globals.WorldSnoId; if (worldId != _startingWorldId) { Core.Logger.Debug($"World changed from {_startingWorldId} to {worldId}, assuming done."); State = States.Completed; return(true); } } if (_timeoutCheckEnabled) { if (_interactionStartedAt == default(DateTime)) { _interactionStartedAt = DateTime.UtcNow; } else { if (DateTime.UtcNow - _interactionStartedAt > _timeOut) { Core.Logger.Debug("Interaction timed out after {0} seconds", (DateTime.UtcNow - _interactionStartedAt).TotalSeconds); State = States.TimedOut; return(false); } } } if (!actor.IsFullyValid()) { Core.Logger.Debug($"Actor is no longer valid, assuming done."); State = States.Completed; return(true); } Core.Logger.Debug($"Attempting to interact with {((SNOActor)actor.ActorSnoId)} at distance {actor.Distance} #{_currentInteractAttempt}"); var interactionResult = await Interact(actor); await Coroutine.Sleep(300); if (ActorFinder.IsDeathGate(actor)) { var nearestGate = ActorFinder.FindNearestDeathGate(); if (nearestGate.CommonData.AnnId != actor.CommonData.AnnId && actor.Distance > 10f) { Core.Logger.Debug("Arrived at Gate Destination (AnnId Check)"); State = States.Completed; return(true); } } //// Sleep time would have to be set to 0/low for this to be checked during gate travel. //if (ZetaDia.Me.IsUsingDeathGate()) //{ // Core.Logger.Debug("Used Death Gate!"); // await Coroutine.Wait(5000, () => !ZetaDia.Me.IsUsingDeathGate()); // Core.Logger.Debug("Arrived at Gate Destination (Travelling Check)"); // State = States.Completed; // return true; //} if (interactionResult) { if (_currentInteractAttempt <= _interactAttempts) { _currentInteractAttempt++; return(false); } if (!_isPortal && !_isNephalemStone && !_isOrek && actor.IsInteractableQuestObject()) { return(false); } if (_isNephalemStone && !UIElements.RiftDialog.IsVisible) { return(false); } if (_isOrek && AdvDia.RiftQuest.State != QuestState.Completed) { return(false); } State = States.Completed; } Core.Logger.Debug($"Interaction Failed"); return(false); }
private async Task <bool> Checking() { _startingWorldId = ZetaDia.Globals.WorldSnoId; var actor = GetActor(); if (actor == null || !actor.IsFullyValid()) { Core.Logger.Debug("Nothing to interact, failing. "); State = States.Failed; return(false); } Core.Logger.Debug($"Interact Actor Found: {actor.Name} ({actor.ActorSnoId}) Distance={actor.Distance}"); if (!_ignoreSanityChecks && !actor.IsInteractableQuestObject()) { Core.Logger.Debug("The object is not valid or not interactable, failing."); State = States.Failed; return(false); } Core.PlayerMover.MoveTowards(actor.Position); if (!Core.Player.IsTakingDamage) { await Coroutine.Sleep(500); Core.PlayerMover.MoveStop(); } // why not eh? if (actor.IsFullyValid() && !ActorFinder.IsDeathGate(actor)) { var gizmo = actor as DiaGizmo; if (gizmo != null && gizmo.IsFullyValid() && gizmo.IsPortal) { _isPortal = true; GameEvents.FireWorldTransferStart(); } actor.Interact(); } var unit = actor as DiaUnit; if (unit != null && unit.IsFullyValid()) { _isQuestGiver = unit.IsQuestGiver; } if (actor.ActorSnoId == 364715) { _isNephalemStone = true; } if (actor.ActorSnoId == 363744) { _isOrek = true; } if (_isNephalemStone && UIElements.RiftDialog.IsVisible) { State = States.Completed; return(false); } if (_isOrek && AdvDia.RiftQuest.State == QuestState.Completed) { State = States.Completed; return(false); } State = States.Interacting; return(false); }