private async Task <bool> Movement()
        {
            if (!_questActionFinished && !QuestHelper.QuestFrameOpen)
            {
                if (InteractionObject.WithinInteractRange)
                {
                    InteractionObject.Interact();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }

                #region SpecialMovement
                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(InteractionObject.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);
                        }
                    }
                }
                #endregion

                if (_npcMovement == null)
                {
                    _npcMovement = new Movement(InteractionObject, InteractionObject.InteractRange - 0.25f);
                }

                await _npcMovement.MoveTo(false);

                return(true);
            }

            return(false);
        }
        public override void Process(float elapsed)
        {
            if (interactionObject == null)
            {
                return;
            }

            float interactionDistance = interactionObject.MaximumRange;

            if (interactionDistance == 0)
            {
                interactionDistance = 15;
            }

            float distance = (interactionObject.Position - Owner.Position).Length;

            // if not at destination, then go there and follow
            if (!interactionObject.IsInRange(Owner.Position))
            {
                distance = (interactionObject.Position - Owner.Path.MoveTo).Length;

                // update path only if destination position and own destination are too far away
                if (distance >= interactionDistance - 1)
                {
                    Owner.Path.MoveTo = interactionObject.Position;
                }

                waitForFellowers = 0;
            }
            else
            {
                bool everyOneReached = true;

                // wait until fellows reach destination
                foreach (Character character in Owner.GetGroup())
                {
                    if (!Owner.GetGroup().IsInRange(Owner, character))
                    {
                        everyOneReached = false;
                        break;
                    }
                }

                // everyone reached or waited for 30 seconds
                if (everyOneReached || waitForFellowers >= 30)
                {
                    // do interaction
                    interactionObject.Interact(Owner);

                    // release object
                    interactionObject = null;
                }
                else
                {
                    waitForFellowers += elapsed;
                }
            }
        }
Beispiel #3
0
 private void InteractAction()
 {
     if (target != null)
     {
         if (target.GetComponent <InteractionObject>() != null)
         {
             InteractionObject interactionObject = target.GetComponent <InteractionObject>();
             interactionObject.Interact();
         }
     }
 }
        private void ProcessInteract()
        {
            if (_hoveredInteraction == null)
            {
                return;
            }

            if (_interactedObject == null &&
                InputMgr.Controller.SelectDown)
            {
                _interactedObject = _hoveredInteraction;
                _interactedObject.Interact();
            }
            else if (InputMgr.Controller.SelectDown)
            {
                _interactedObject.StopInteract();
                _interactedObject = null;
            }
        }
        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);
        }
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }

            if (InteractionObject == null)
            {
                if (await StartMovement.MoveTo())
                {
                    return(true);
                }
            }



            if (GossipHelper.IsOpen)
            {
                if (GossipHelper.GossipOptions.All(o => o.Type != GossipEntry.GossipEntryType.Vendor))
                {
                    //Could not find Vendor Option!
                    GarrisonBase.Err("Primal Trader behavior could not find vendoring gossip!");
                    return(false);
                }
                var gossipEntryVendor = GossipHelper.GossipOptions.FirstOrDefault(o => o.Type == GossipEntry.GossipEntryType.Vendor);

                QuestManager.GossipFrame.SelectGossipOption(gossipEntryVendor.Index);
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                return(true);
            }

            if (MerchantHelper.IsOpen)
            {
                await Coroutine.Yield();

                if (ExchangeItemInfo.Cost <= TotalPrimalSpiritCount)
                {
                    if (StyxWoW.Me.IsMoving)
                    {
                        await CommonCoroutines.StopMoving();
                    }

                    await Coroutine.Sleep(StyxWoW.Random.Next(1005, 1666));

                    bool success = false;

                    await CommonCoroutines.WaitForLuaEvent("BAG_UPDATE",
                                                           StyxWoW.Random.Next(1255, 1777),
                                                           null,
                                                           () => success = MerchantHelper.BuyItem(ExchangeItemInfo.ItemId, 1, true));

                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    await Coroutine.Yield();

                    if (success)
                    {
                        return(true);
                    }
                }

                IsDone = true;
                return(false);
            }

            if (InteractionObject != null)
            {
                if (InteractionObject.WithinInteractRange)
                {
                    if (StyxWoW.Me.IsMoving)
                    {
                        await CommonCoroutines.StopMoving();
                    }
                    await CommonCoroutines.SleepForLagDuration();

                    InteractionObject.Interact();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }

                if (_npcMovement == null)
                {
                    _npcMovement = new Movement(InteractionObject, InteractionObject.InteractRange - 0.25f);
                }

                await _npcMovement.MoveTo(false);

                return(true);
            }


            return(false);
        }
        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);
        }