Пример #1
0
        /// <summary>
        /// If we're in a different world to the leader, teleport to him.
        /// </summary>
        public static async Task <bool> TeleportWhenInDifferentWorld(Message player)
        {
            if (player.WorldSnoId <= 0 || Player.CurrentWorldSnoId <= 0)
            {
                return(false);
            }

            if (Player.IsInTown && BrainBehavior.IsVendoring)
            {
                return(false);
            }

            if ((RiftHelper.IsInRift || player.IsInRift) && RiftHelper.IsGreaterRiftStarted)
            {
                return(false);
            }

            if (Player.IsFollower && player.WorldSnoId != Player.CurrentMessage.WorldSnoId && player.IsInSameGame && !player.IsInCombat)
            {
                await Coordination.TeleportToPlayer(player);

                return(true);
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Run adventurer Gem Upgrade coroutine
        /// </summary>
        public static async Task <bool> UpgradeGems()
        {
            if (DateTime.UtcNow.Subtract(LastRequestedGemUpgrade).TotalSeconds < 10)
            {
                return(false);
            }

            if (RiftHelper.IsInRift && RiftHelper.RiftQuest.Step == RiftQuest.RiftStep.UrshiSpawned && RiftHelper.IsCompleted)
            {
                if (AutoFollow.CurrentLeader.Distance > 150f)
                {
                    await Coordination.TeleportToPlayer(AutoFollow.CurrentLeader);
                }

                Log.Warn("Rift is Completed.");

                while (await _gemUpgrader.GetCoroutine() == false && !Player.IsDead)
                {
                    await Coroutine.Yield();
                }

                _gemUpgrader.Reset();

                await Coroutine.Sleep(5000);

                LastRequestedGemUpgrade = DateTime.UtcNow;
                return(true);
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Check if we're in the same game as the leader, and leave if they're different.
        /// </summary>
        public static async Task <bool> LeaveWhenInWrongGame()
        {
            if (ZetaDia.IsLoadingWorld || DateTime.UtcNow.Subtract(ChangeMonitor.LastGameJoinedTime).Seconds < 5)
            {
                return(false);
            }

            // Leaves party when out of game the d3-party leader and not the bot-leader.
            // Disbands party if leader leaves it.
            if (Player.IsFollower && Player.IsInParty && ZetaDia.Service.Party.IsPartyLeader && !ZetaDia.IsInGame &&
                GameUI.ElementIsVisible(GameUI.OutOfGameLeavePartyButton) && ZetaDia.Service.Party.CurrentPartyLockReasonFlags == PartyLockReasonFlag.None &&
                DateTime.UtcNow.Subtract(_lastAttemptQuickJoin) > TimeSpan.FromSeconds(10))
            {
                Log.Info("We are a follower but leader of party - leaving party");
                GameUI.OutOfGameLeavePartyButton.Click();
                Coordination.WaitFor(TimeSpan.FromSeconds(5));
                return(true);
            }

            if (ZetaDia.IsInGame && Player.IsFollower && !AutoFollow.CurrentLeader.IsMe && !AutoFollow.CurrentLeader.IsInSameGame && !AutoFollow.CurrentLeader.IsLoadingWorld)
            {
                Log.Warn("Leader is in a different game, Leave Game!", AutoFollow.CurrentLeader.IsInSameGame);
                await LeaveGame();

                Coordination.WaitFor(TimeSpan.FromSeconds(5));
                return(true);
            }

            return(false);
        }
Пример #4
0
        /// <summary>
        /// Send out a request to all plugins for someone to handle gem upgrading for us.
        /// </summary>
        public static async Task <bool> UpgradeGems()
        {
            if (DateTime.UtcNow.Subtract(LastRequestedGemUpgrade).TotalSeconds < 15)
            {
                return(false);
            }

            if (RiftHelper.IsInRift && RiftHelper.RiftQuest.Step == RiftQuest.RiftStep.UrshiSpawned && RiftHelper.CurrentRift.IsCompleted)
            {
                if (AutoFollow.CurrentLeader.Distance > 30f)
                {
                    Log.Warn("Rift is Completed; telport to the leader");
                    await Coordination.TeleportToPlayer(AutoFollow.CurrentLeader, false);

                    await Coroutine.Sleep(3000);
                }

                Log.Warn("Rift is Completed; requesting gem upgrade from other plugins.");
                PluginCommunicator.BroadcastGemUpgradRequest();
                await Coroutine.Sleep(5000);

                LastRequestedGemUpgrade = DateTime.UtcNow;
                return(true);
            }

            return(false);
        }
Пример #5
0
        /// <summary>
        /// Tell other bots to leave their game and wait for them to do so.
        /// </summary>
        public static async Task <bool> WaitForPlayersToLeaveGame()
        {
            if (Player.IsInParty && !Player.IsInGame && (AutoFollow.CurrentParty.Any(m => m.IsInGame) || !GameUI.ChangeQuestButton.IsEnabled))
            {
                Log.Info("Waiting for party members to leave game");
                EventManager.FireEvent(new EventData(EventType.LeavingGame, null, null, true));
                Coordination.WaitFor(TimeSpan.FromSeconds(5));
                return(true);
            }

            return(false);
        }
Пример #6
0
 /// <summary>
 /// Leave the party if there are strange people in it.
 /// </summary>
 public static async Task <bool> LeavePartyUnknownPlayersInGame()
 {
     if (AutoFollow.NumberOfConnectedBots == 0 && !GameUI.ChangeQuestButton.IsEnabled &&
         Settings.Misc.AvoidUnknownPlayers)
     {
         Log.Info("Unknown players in the party and no connected bots, leaving party.");
         GameUI.OutOfGameLeavePartyButton.Click();
         Coordination.WaitFor(TimeSpan.FromSeconds(5));
         return(true);
     }
     return(false);
 }
Пример #7
0
 /// <summary>
 /// Clicks the start game button once all players have left the game.
 /// </summary>
 public static async Task <bool> StartGameWhenPartyReady()
 {
     if (ZetaDia.Service.Party.IsPartyLeader && Player.NumPlayersInParty > 1 &&
         Player.NumPlayersInParty == AutoFollow.NumberOfConnectedBots + 1 && GameUI.PlayGameButton.IsEnabled &&
         Player.NumPlayersInParty == AutoFollow.CurrentParty.Count(p => !p.IsInGame))
     {
         Log.Warn("We're all here, starting game");
         GameUI.PlayGameButton.Click();
         Coordination.WaitFor(TimeSpan.FromSeconds(2));
         return(true);
     }
     return(false);
 }
Пример #8
0
        /// <summary>
        /// If we're too far away from the leader, teleport to him.
        /// </summary>
        public static async Task <bool> TeleportWhenTooFarAway(Message playerMessage)
        {
            if (RiftHelper.IsInGreaterRift || Player.IsInBossEncounter || playerMessage.IsInBossEncounter)
            {
                return(false);
            }

            if (Player.IsFollower && playerMessage.WorldSnoId == Player.CurrentMessage.WorldSnoId && playerMessage.IsInSameGame &&
                !playerMessage.IsInCombat && playerMessage.Distance > Settings.Coordination.TeleportDistance)
            {
                Log.Info("{0} is getting quite far away... attempting teleport!", playerMessage.HeroName);
                await Coordination.TeleportToPlayer(playerMessage);

                return(true);
            }

            return(false);
        }
Пример #9
0
 /// <summary>
 /// Handle being in a party lobby.
 /// </summary>
 public static async Task <bool> JoinGameOrLeaveParty()
 {
     if (!ZetaDia.Service.Party.IsPartyLeader && Player.IsInParty && !ZetaDia.IsInGame)
     {
         if (!IsLeaderInParty())
         {
             Log.Info("Leaving party, leader is not in this group!");
             GameUI.OutOfGameLeavePartyButton.Click();
             Coordination.WaitFor(TimeSpan.FromSeconds(2));
         }
         else if (GameUI.PlayGameButton.IsEnabled && AutoFollow.CurrentLeader.IsInGame)
         {
             Log.Info("We're in party, leader already in game, joining game!");
             GameUI.PlayGameButton.Click();
             Coordination.WaitFor(TimeSpan.FromSeconds(2));
             return(true);
         }
     }
     return(false);
 }