示例#1
0
        public async Task SaveBotStats(BotStats stats)
        {
            var Query = "UPDATE `BotStats` SET `YouTubeAlertCount`=" + stats.YouTubeAlertCount +
                        ",`MixerAlertCount`=" + stats.BeamAlertCount +
                        ",`SmashcastAlertCount`=" + stats.HitboxAlertCount +
                        ",`PicartoAlertCount`=" + stats.PicartoAlertCount +
                        ",`VidMeAlertCount`=" + stats.VidMeAlertCount +
                        ",`UptimeMinutes`=" + stats.UptimeMinutes +
                        ",`HaiBaiCount`=" + stats.HaiBaiCount +
                        ",`FlipCount`=" + stats.FlipCount +
                        ",`UnflipCount`=" + stats.UnflipCount +
                        ",`TwitchAlertCount`=" + stats.TwitchAlertCount +
                        ",`LoggingStartDate`='" + stats.LoggingStartDate +
                        "',`LastRestart`='" + stats.LastRestart.ToString("yyyy-MM-dd HH:mm:ss") + "' WHERE Id = 1";

            MySqlConnection MyConn2    = new MySqlConnection(_botSettings.ConnectionStrings.BotContext);
            MySqlCommand    MyCommand2 = new MySqlCommand(Query, MyConn2);
            MySqlDataReader MyReader2;

            MyConn2.Open();
            MyReader2 = MyCommand2.ExecuteReader();

            while (MyReader2.Read())
            {
            }
            MyConn2.Close();
            await MyConn2.ClearPoolAsync(MyConn2);

            await MyConn2.ClearAllPoolsAsync();
        }
        public static async Task Execute()
        {
            await Inventory.GetCachedInventory(true);

            var pokemonToEvolve = await Inventory.GetPokemonToEvolve(Logic._client.Settings.PrioritizeIVOverCP, Logic._client.Settings.PokemonsToEvolve);

            if (pokemonToEvolve == null || !pokemonToEvolve.Any())
            {
                return;
            }

            Logger.Write($"Found {pokemonToEvolve.Count()} Pokemon for Evolve:", LogLevel.Debug);
            foreach (var pokemon in pokemonToEvolve)
            {
                var evolvePokemonOutProto = await Logic._client.Inventory.EvolvePokemon(pokemon.Id);

                await Inventory.GetCachedInventory(true);

                Logger.Write(evolvePokemonOutProto.Result == EvolvePokemonResponse.Types.Result.Success
                        ? $"{pokemon.PokemonId} [CP: {pokemon.Cp}/{PokemonInfo.CalculateMaxCp(pokemon)} | IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect] | received XP {evolvePokemonOutProto.ExperienceAwarded}"
                        : $"Failed: {pokemon.PokemonId}. EvolvePokemonOutProto.Result was {evolvePokemonOutProto.Result}, stopping evolving {pokemon.PokemonId}"
                             , LogLevel.Evolve);

                if (evolvePokemonOutProto.Result == EvolvePokemonResponse.Types.Result.Success)
                {
                    BotStats.ExperienceThisSession += evolvePokemonOutProto.ExperienceAwarded;
                }
            }
            await BotStats.GetPokeDexCount();

            BotStats.UpdateConsoleTitle();
        }
示例#3
0
        public void OnInitialize()
        {
            Log("YAR Plugin Initialized with PID: {0}", _bs.Pid);
            // Force enable YAR
            foreach (var plugin in PluginManager.Plugins)
            {
                if (!plugin.Enabled && plugin.Plugin.Name == this.Name)
                {
                    plugin.Enabled = true;
                }
            }

            _bs           = new BotStats();
            _bs.LastPulse = DateTime.Now.Ticks;
            //_bs.Pid = Process.GetCurrentProcess().Id;

            lmd = new Logging.LogMessageDelegate(Logging_OnLogMessage);
            Logging.OnLogMessage += lmd;

            Reset();

            _yarThread = new Thread(YarWorker)
            {
                IsBackground = true
            };
            _yarThread.Start();

            Pulsator.OnPulse += Pulsator_OnPulse;

            Send("Initialized");
        }
示例#4
0
        public void OnInitialize()
        {
            Log("YAR Plugin Initialized with PID: {0}", _bs.Pid);

            // Force enable YAR
            var enabledPluginsList = PluginManager.Plugins.Where(p => p.Enabled).Select(p => p.Plugin.Name).ToList();

            if (!enabledPluginsList.Contains(Name))
            {
                enabledPluginsList.Add(Name);
            }
            PluginManager.SetEnabledPlugins(enabledPluginsList.ToArray());

            _bs           = new BotStats();
            _bs.LastPulse = DateTime.UtcNow.Ticks;

            lock (_appenderLock)
            {
                if (!_appenderAdded)
                {
                    Hierarchy loggingHierarchy = (Hierarchy)LogManager.GetRepository();
                    loggingHierarchy.Root.AddAppender(YARAppender);
                    _appenderAdded = true;
                }
            }

            Reset();

            StartYarWorker();

            Pulsator.OnPulse += Pulsator_OnPulse;
            TreeHooks.Instance.OnHooksCleared += Instance_OnHooksCleared;

            Send("Initialized");
        }
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.tag == "Target")
     {
         bStats = other.gameObject.GetComponent <BotStats>();
         bStats.RemoveTeamPlayerBuff();
     }
 }
示例#6
0
 public Logic(ISettings clientSettings)
 {
     _clientSettings = clientSettings;
     _client         = new Client(_clientSettings);
     _inventory      = new Inventory(_client);
     _botStats       = new BotStats();
     _navigation     = new Navigation(_client);
 }
示例#7
0
 public Logic(ISettings clientSettings)
 {
     _clientSettings = clientSettings;
     PositionCheckState.Execute();
     _client     = new Client(_clientSettings);
     _inventory  = new Inventory();
     _stats      = new BotStats();
     _navigation = new Navigation();
 }
示例#8
0
 public Logic(ISettings clientSettings, LogicInfoObservable infoObservable)
 {
     _clientSettings = clientSettings;
     _client         = new Client(_clientSettings);
     _inventory      = new Inventory(_client);
     _botStats       = new BotStats();
     _navigation     = new Navigation(_client);
     _pokevision     = new PokeVisionUtil();
     _infoObservable = infoObservable;
 }
示例#9
0
 public Logic(ISettings clientSettings, LogicInfoObservable infoObservable)
 {
     _clientSettings = clientSettings;
     _client         = new Client(_clientSettings);
     _client.setFailure(new ApiFailureStrat(_client));
     _botStats       = new BotStats();
     _navigation     = new Navigation(_client);
     _pokevision     = new PokeVisionUtil();
     _infoObservable = infoObservable;
 }
示例#10
0
        public Logic(ISettings clientSettings)
        {
            _configsPath = Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), clientSettings.PtcUsername), "Settings");

            _clientSettings = clientSettings;
            _client         = new Client(_clientSettings);
            _inventory      = new Inventory(_client);
            _stats          = new BotStats();
            _navigation     = new Navigation(_client);

            ResetCoords();
        }
 void Start()
 {
     laserLine         = GetComponent <LineRenderer>();
     laserLine.enabled = false;
     gameManager       = GameObject.Find("Persistent Object").GetComponent <GameManager>();
     hubTracker        = GameObject.Find("Persistent Object").GetComponent <HUBTracker>();
     botStats          = GetComponent <BotStats>();
     canvasCaster      = GameObject.Find("RunningUI").GetComponent <GraphicRaycaster>();
     eventSys          = GameObject.Find("EventSystem").GetComponent <EventSystem>();
     displayLog        = GameObject.Find("RunningUI/Text Log/Log Panel/Content").GetComponent <DisplayLog>();
     animator          = GetComponent <Animator>();
     audioS            = GetComponent <AudioSource>();
     hitCanvas         = false;
 }
示例#12
0
        public BotStats GetBotStats()
        {
            var path = Constants.ConfigRootDirectory + Constants.BotStatistics;

            if (!File.Exists(path))
            {
                var stats = new BotStats();
                stats.BeamAlertCount    = 0;
                stats.TwitchAlertCount  = 0;
                stats.UptimeMinutes     = 0;
                stats.YouTubeAlertCount = 0;
                stats.LoggingStartDate  = DateTime.UtcNow;
                File.WriteAllText(path, JsonConvert.SerializeObject(stats));
            }
            return(JsonConvert.DeserializeObject <BotStats>(File.ReadAllText(path)));
        }
示例#13
0
        public void OnInitialize()
        {
            _bs = new BotStats();

            Logging.OnLogMessage += new Logging.LogMessageDelegate(Logging_OnLogMessage);
            _bs.Pid = Process.GetCurrentProcess().Id;

            Reset();

            _yarThread = new Thread(YarWorker)
            {
                IsBackground = true
            };
            _yarThread.Start();
            Send("Initialized");
        }
示例#14
0
        public static async Task Execute()
        {
            await Inventory.GetCachedInventory(true);

            var pokemonToTransfer = await Inventory.GetPokemonToTransfer(Logic._clientSettings.NotTransferPokemonsThatCanEvolve, Logic._clientSettings.PrioritizeIVOverCP, Logic._clientSettings.PokemonsToNotTransfer);

            if (pokemonToTransfer == null || !pokemonToTransfer.Any())
            {
                return;
            }

            Logger.Write($"Found {pokemonToTransfer.Count()} Pokemon for Transfer:", LogLevel.Debug);
            foreach (var pokemon in pokemonToTransfer)
            {
                await Logic._client.Inventory.TransferPokemon(pokemon.Id);

                await Inventory.GetCachedInventory(true);

                var myPokemonSettings = await Inventory.GetPokemonSettings();

                var pokemonSettings   = myPokemonSettings.ToList();
                var myPokemonFamilies = await Inventory.GetPokemonFamilies();

                var pokemonFamilies = myPokemonFamilies.ToArray();
                var settings        = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                var familyCandy     = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
                var familyCandies   = $"{familyCandy.Candy_}";

                BotStats.PokemonTransferedThisSession += 1;

                var bestPokemonOfType = Logic._client.Settings.PrioritizeIVOverCP
                    ? await Inventory.GetHighestPokemonOfTypeByIv(pokemon)
                    : await Inventory.GetHighestPokemonOfTypeByCp(pokemon);

                var bestPokemonInfo = "NONE";
                if (bestPokemonOfType != null)
                {
                    bestPokemonInfo = $"CP: {bestPokemonOfType.Cp}/{PokemonInfo.CalculateMaxCp(bestPokemonOfType)} | IV: {PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType).ToString("0.00")}% perfect";
                }

                Logger.Write($"{pokemon.PokemonId} [CP: {pokemon.Cp}/{PokemonInfo.CalculateMaxCp(pokemon)} | IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}% perfect] | Best: [{bestPokemonInfo}] | Family Candies: {familyCandies}", LogLevel.Transfer);
            }

            await BotStats.GetPokemonCount();

            BotStats.UpdateConsoleTitle();
        }
示例#15
0
        public Logic(ISettings botSettings, LogicInfoObservable infoObservable)
        {
            this.BotSettings = botSettings;
            var clientSettings = new PokemonGo.RocketAPI.Shared.ClientSettings(botSettings.pFHashKey, botSettings.DefaultLatitude, botSettings.DefaultLongitude, botSettings.DefaultAltitude,
                                                                               botSettings.proxySettings.hostName, botSettings.proxySettings.port, botSettings.proxySettings.username, botSettings.proxySettings.password,
                                                                               botSettings.AuthType, botSettings.Username, botSettings.Password, GlobalVars.BotApiSupportedVersion);

            objClient = new Client(clientSettings);
            objClient.setFailure(new ApiFailureStrat(objClient));
            BotStats            = new BotStats();
            navigation          = new Navigation(objClient, botSettings);
            pokevision          = new PokeVisionUtil();
            this.infoObservable = infoObservable;
            Instance            = this;
            sniperLogic         = new  Sniper(objClient, botSettings);
            PokemonGo.RocketAPI.Shared.KeyCollection.Load();
        }
示例#16
0
    void Start()
    {
        foreach (GameObject bot in GameObject.FindGameObjectsWithTag("Target"))
        {
            if (bot.GetComponent <Health>() && bot.GetComponent <AIMachine>())
            {
                friendlyBots.Add(bot);
            }
        }
        friendlyBots.Remove(this.gameObject);
        friendlyBots.Remove(GameObject.Find("PlayerSphere"));

        foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Cap Area")) //if there are any capture areas in the level, add them to the list
        {
            objectives.Add(obj);
        }

        foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Terminal")) //if there are any terminals in the level, add them to the list
        {
            objectives.Add(obj);
        }

        botMachine        = GetComponent <BotStateMachine>();
        thisAgent         = GetComponent <NavMeshAgent>();
        botStats          = GetComponent <BotStats>();
        gameManager       = GameObject.Find("Persistent Object").GetComponent <GameManager>();
        logD              = GameObject.Find("RunningUI/Text Log/Log Panel/Content").GetComponent <DisplayLog>();
        playerObject      = GameObject.Find("PlayerSphere");
        laserLine         = GetComponent <LineRenderer>();
        laserLine.enabled = false;
        audioS            = GetComponent <AudioSource>();
        startingPos       = transform.position;

        if (gameObject.name.Contains("Blue"))
        {
            displayName = "Blue Bot";
        }
        if (gameObject.name.Contains("Green"))
        {
            displayName = "Green Bot";
        }
        if (gameObject.name.Contains("Orange"))
        {
            displayName = "Orange Bot";
        }
    }
示例#17
0
    public static BotStats GetBotStats(int index)
    {
        if (!Topan.Network.HasServerInfo("bS" + index.ToString()))
        {
            return(null);
        }

        BotStats newStats = new BotStats();
        string   botInfo  = Topan.Network.GetServerInfo("bS" + index.ToString()).ToString();

        string[] thisBotInfo = botInfo.Split(new string[] { "," }, StringSplitOptions.None);

        newStats.kills     = int.Parse(thisBotInfo[0]);
        newStats.deaths    = int.Parse(thisBotInfo[1]);
        newStats.headshots = int.Parse(thisBotInfo[2]);
        newStats.score     = int.Parse(thisBotInfo[3]);
        return(newStats);
    }
示例#18
0
        public async Task <BotStats> GetBotStats()
        {
            BotStats stats = null;
            string   query = "SELECT * FROM BotStats where Id = 1";

            MySqlConnection MyConn2    = new MySqlConnection(_botSettings.ConnectionStrings.BotContext);
            MySqlCommand    MyCommand2 = new MySqlCommand(query, MyConn2);
            MySqlDataReader MyReader2;

            MyConn2.Open();
            MyReader2 = MyCommand2.ExecuteReader();

            while (MyReader2.Read())
            {
                stats = new BotStats();

                stats.BeamAlertCount     = int.Parse(MyReader2["MixerAlertCount"].ToString());
                stats.FlipCount          = int.Parse(MyReader2["FlipCount"].ToString());
                stats.HaiBaiCount        = int.Parse(MyReader2["Id"].ToString());
                stats.HitboxAlertCount   = int.Parse(MyReader2["SmashcastAlertCount"].ToString());
                stats.LastRestart        = DateTime.Parse(MyReader2["LastRestart"].ToString());
                stats.LoggingStartDate   = DateTime.Parse(MyReader2["LoggingStartDate"].ToString());
                stats.PicartoAlertCount  = int.Parse(MyReader2["PicartoAlertCount"].ToString());
                stats.TwitchAlertCount   = int.Parse(MyReader2["TwitchAlertCount"].ToString());
                stats.UnflipCount        = int.Parse(MyReader2["UnflipCount"].ToString());
                stats.UptimeMinutes      = int.Parse(MyReader2["UptimeMinutes"].ToString());
                stats.VidMeAlertCount    = int.Parse(MyReader2["VidMeAlertCount"].ToString());
                stats.YouTubeAlertCount  = int.Parse(MyReader2["YouTubeAlertCount"].ToString());
                stats.MobcrushAlertCount = int.Parse(MyReader2["MobcrushAlertCount"].ToString());
            }
            MyConn2.Close();
            await MyConn2.ClearPoolAsync(MyConn2);

            await MyConn2.ClearAllPoolsAsync();

            return(stats);
        }
        public static async Task Execute()
        {
            await Inventory.GetCachedInventory(true);

            var items = await Inventory.GetItemsToRecycle(Logic._clientSettings);

            if (items == null || !items.Any())
            {
                return;
            }

            Logger.Write($"Found {items.Count()} Recyclable {(items.Count() == 1 ? "Item" : "Items")}:", LogLevel.Debug);
            foreach (var item in items)
            {
                await Logic._client.Inventory.RecycleItem(item.ItemId, item.Count);

                Logger.Write($"{item.Count}x {item.ItemId}", LogLevel.Recycling);

                BotStats.ItemsRemovedThisSession += item.Count;
            }

            BotStats.UpdateConsoleTitle();
            _recycleCounter = 0;
        }
示例#20
0
        public async Task PrintPlayerInfos(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            await Inventory.GetCachedInventory();

            _playerProfile = await _client.Player.GetPlayer();

            BotStats.UpdateConsoleTitle();

            var playerStats = (await Inventory.GetPlayerStats()).FirstOrDefault();

            if (playerStats != null)
            {
                BotStats.KmWalkedOnStart = playerStats.KmWalked;
            }

            Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
            if (_clientSettings.AuthType == AuthType.Ptc)
            {
                Logger.Write($"PTC Account: {BotStats.GetUsername(_playerProfile)}\n", LogLevel.None,
                             ConsoleColor.Cyan);
            }
            Logger.Write($"Latitude: {_clientSettings.DefaultLatitude}", LogLevel.None,
                         ConsoleColor.DarkGray);
            Logger.Write($"Longitude: {_clientSettings.DefaultLongitude}", LogLevel.None,
                         ConsoleColor.DarkGray);
            Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
            Logger.Write("Your Account:\n");
            Logger.Write($"Name: {BotStats.GetUsername(_playerProfile)}", LogLevel.None,
                         ConsoleColor.DarkGray);
            Logger.Write($"Team: {_playerProfile.PlayerData.Team}", LogLevel.None, ConsoleColor.DarkGray);
            Logger.Write($"Level: {BotStats.GetCurrentInfo()}", LogLevel.None, ConsoleColor.DarkGray);
            Logger.Write($"Stardust: {_playerProfile.PlayerData.Currencies.ToArray()[1].Amount}",
                         LogLevel.None, ConsoleColor.DarkGray);
            Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
            await DisplayHighests();

            Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);

            var pokemonToNotTransfer = _clientSettings.PokemonToNotTransfer;
            var pokemonsToNotCatch   = _clientSettings.PokemonToNotCatch;
            var pokemonsToEvolve     = _clientSettings.PokemonToEvolve;

            await RecycleItemsTask.Execute();

            if (_client.Settings.UseLuckyEggs)
            {
                await UseLuckyEggTask.Execute();
            }
            if (_client.Settings.EvolvePokemon || _client.Settings.EvolveOnlyPokemonAboveIV)
            {
                await EvolvePokemonTask.Execute();
            }
            if (_client.Settings.TransferPokemon)
            {
                await TransferPokemonTask.Execute();
            }
            if (_client.Settings.UseCSVExport)
            {
                await ExportPokemonToCsv.Execute(_playerProfile.PlayerData);
            }
            if (_clientSettings.HatchEggs)
            {
                await HatchEggsTask.Execute();
            }
        }
示例#21
0
        public async Task PostLoginExecute()
        {
            Logger.Write($"Client logged in", LogLevel.Info);

            while (true)
            {
                if (!_isInitialized)
                {
                    await Inventory.GetCachedInventory();

                    _playerProfile = await _client.Player.GetPlayer();

                    BotStats.UpdateConsoleTitle();

                    var stats = await Inventory.GetPlayerStats();

                    var stat = stats.FirstOrDefault();
                    if (stat != null)
                    {
                        BotStats.KmWalkedOnStart = stat.KmWalked;
                    }

                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
                    if (_clientSettings.AuthType == AuthType.Ptc)
                    {
                        Logger.Write($"PTC Account: {BotStats.GetUsername(_playerProfile)}\n", LogLevel.None, ConsoleColor.Cyan);
                    }
                    Logger.Write($"Latitude: {_clientSettings.DefaultLatitude}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Longitude: {_clientSettings.DefaultLongitude}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
                    Logger.Write("Your Account:\n");
                    Logger.Write($"Name: {BotStats.GetUsername(_playerProfile)}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Team: {_playerProfile.PlayerData.Team}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Level: {BotStats.GetCurrentInfo()}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write($"Stardust: {_playerProfile.PlayerData.Currencies.ToArray()[1].Amount}", LogLevel.None, ConsoleColor.DarkGray);
                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);
                    await DisplayHighests();

                    Logger.Write("----------------------------", LogLevel.None, ConsoleColor.Yellow);

                    var pokemonsToNotTransfer = _clientSettings.PokemonsToNotTransfer;
                    var pokemonsToNotCatch    = _clientSettings.PokemonsToNotCatch;
                    var pokemonsToEvolve      = _clientSettings.PokemonsToEvolve;

                    await RecycleItemsTask.Execute();

                    if (_client.Settings.UseLuckyEggs)
                    {
                        await UseLuckyEggTask.Execute();
                    }
                    if (_client.Settings.EvolvePokemon || _client.Settings.EvolvePokemonAboveIV)
                    {
                        await EvolvePokemonTask.Execute();
                    }
                    if (_client.Settings.TransferPokemon)
                    {
                        await TransferPokemonTask.Execute();
                    }
                    await ExportPokemonToCsv.Execute(_playerProfile.PlayerData);

                    if (_clientSettings.HatchEggs)
                    {
                        await HatchEggsTask.Execute();
                    }
                }
                _isInitialized = true;
                await Main();

                await RefreshTokens();

                /*
                 * Example calls below
                 *
                 * var profile = await _client.GetProfile();
                 * var settings = await _client.GetSettings();
                 * var mapObjects = await _client.GetMapObjects();
                 * var inventory = await _client.GetInventory();
                 * var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0);
                 */

                await Task.Delay(10000);
            }
        }
示例#22
0
 public static string ParseToBotFormat(BotStats bStats)
 {
     return(bStats.kills.ToString() + "," + bStats.deaths.ToString() + "," + bStats.headshots.ToString() + "," + bStats.score.ToString());
 }
示例#23
0
    void Awake()
    {
        countToNextRound        = 10;
        vignetting.intensity    = 0f;
        blackStuff.alpha        = 0f;
        Screen.lockCursor       = false;
        UICamera.selectedObject = null;

        sortedPlayers = new List <NetPlayerInfo>();

        for (int i = 0; i < Topan.Network.connectedPlayers.Length; i++)
        {
            Topan.NetworkPlayer curPlayer = Topan.Network.connectedPlayers[i];

            NetPlayerInfo npi = new NetPlayerInfo();
            npi.realPlayer = curPlayer;
            npi.myKills    = (int)((UInt16)curPlayer.GetPlayerData("k", (UInt16)0));
            npi.myDeaths   = (int)((UInt16)curPlayer.GetPlayerData("d", (UInt16)0));
            npi.myHeads    = (int)((UInt16)curPlayer.GetPlayerData("h", (UInt16)0));
            npi.myScore    = (int)curPlayer.GetPlayerData("sc", 0);
            sortedPlayers.Add(npi);
        }

        if (GeneralVariables.gameModeHasTeams)
        {
            teamBasedRoot.SetActive(true);
            Destroy(individualBasedRoot);

            int redIndex  = 0;
            int blueIndex = 0;

            sortedPlayers = new List <NetPlayerInfo>();
            for (int i = 0; i < Topan.Network.connectedPlayers.Length; i++)
            {
                Topan.NetworkPlayer curPlayer = Topan.Network.connectedPlayers[i];

                NetPlayerInfo npi = new NetPlayerInfo();
                npi.realPlayer = curPlayer;
                npi.myKills    = (int)((UInt16)curPlayer.GetPlayerData("k", (UInt16)0));
                npi.myDeaths   = (int)((UInt16)curPlayer.GetPlayerData("d", (UInt16)0));
                npi.myHeads    = (int)((UInt16)curPlayer.GetPlayerData("h", (UInt16)0));
                npi.myScore    = (int)curPlayer.GetPlayerData("sc", 0);
                sortedPlayers.Add(npi);
            }

            BotPlayer[] redBots = NetworkingGeneral.GetBotParticipants(0);
            for (int i = 0; i < redBots.Length; i++)
            {
                BotStats hisStats = BotManager.GetBotStats(redBots[i].index);

                NetPlayerInfo npi = new NetPlayerInfo();
                npi.botPlayer = redBots[i];
                npi.myKills   = hisStats.kills;
                npi.myDeaths  = hisStats.deaths;
                npi.myHeads   = hisStats.headshots;
                npi.myScore   = hisStats.score;
                sortedPlayers.Add(npi);
            }

            BotPlayer[] blueBots = NetworkingGeneral.GetBotParticipants(1);
            for (int i = 0; i < blueBots.Length; i++)
            {
                BotStats hisStats = BotManager.GetBotStats(blueBots[i].index);

                NetPlayerInfo npi = new NetPlayerInfo();
                npi.botPlayer = blueBots[i];
                npi.myKills   = hisStats.kills;
                npi.myDeaths  = hisStats.deaths;
                npi.myHeads   = hisStats.headshots;
                npi.myScore   = hisStats.score;
                sortedPlayers.Add(npi);
            }

            if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills)
            {
                sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills));
            }
            else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score)
            {
                sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore));
            }

            for (int i = 0; i < sortedPlayers.Count; i++)
            {
                NetPlayerInfo current = sortedPlayers[i];
                if (current.botPlayer == null && current.realPlayer == null)
                {
                    continue;
                }

                if (current.myInfo == null)
                {
                    continue;
                }

                int   kills  = current.myKills;
                int   deaths = current.myDeaths;
                int   score  = current.myScore;
                float kd     = (deaths > 0) ? ((float)kills / (float)deaths) : kills;

                UserStatsGUI usg = null;
                if (current.myTeam == 0)
                {
                    UserStatsGUI instance = (UserStatsGUI)Instantiate(scoreboardPrefab);
                    instance.transform.parent        = redStart;
                    instance.transform.localPosition = Vector3.down * (redIndex * statsSpacing);
                    instance.transform.localScale    = Vector3.one;
                    usg = instance;
                    redIndex++;
                }
                else
                {
                    UserStatsGUI instance = (UserStatsGUI)Instantiate(scoreboardPrefab);
                    instance.transform.parent        = blueStart;
                    instance.transform.localPosition = Vector3.down * (blueIndex * statsSpacing);
                    instance.transform.localScale    = Vector3.one;
                    usg = instance;
                    blueIndex++;
                }

                int thisListIndex = (current.myTeam == 0) ? redIndex : blueIndex;

                string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : "";
                usg.SetInfo(((current.myInfo != null) ? current.myInfo.rank : 1).ToString(),
                            clanNameFinal + current.myInfo.username,
                            kills.ToString(),
                            deaths.ToString(),
                            kd.ToString("F2"),
                            current.myHeads.ToString(),
                            score.ToString(),
                            ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(),
                            (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player),
                            (thisListIndex % 2 == 0));
            }
        }
        else
        {
            Destroy(teamBasedRoot);
            individualBasedRoot.SetActive(true);

            int currentIndex = 0;

            for (int i = 0; i < BotManager.allBotPlayers.Length && i < GeneralVariables.Networking.botCount; i++)
            {
                BotStats hisStats = BotManager.GetBotStats(i);

                NetPlayerInfo npi = new NetPlayerInfo();
                npi.botPlayer = BotManager.allBotPlayers[i];
                npi.myKills   = hisStats.kills;
                npi.myDeaths  = hisStats.deaths;
                npi.myHeads   = hisStats.headshots;
                npi.myScore   = hisStats.score;
                sortedPlayers.Add(npi);
            }

            if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills)
            {
                sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills));
            }
            else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score)
            {
                sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore));
            }

            for (int i = 0; i < sortedPlayers.Count; i++)
            {
                NetPlayerInfo current = sortedPlayers[i];
                if (current.botPlayer == null && current.realPlayer == null)
                {
                    continue;
                }

                if (current.myInfo == null)
                {
                    continue;
                }

                int   kills  = current.myKills;
                int   deaths = current.myDeaths;
                int   score  = current.myScore;
                float kd     = (deaths > 0) ? ((float)kills / (float)deaths) : kills;

                if (currentIndex >= 16)
                {
                    continue;
                }

                UserStatsGUI instance = (UserStatsGUI)Instantiate(scoreboardPrefab);
                instance.transform.parent        = individualStart;
                instance.transform.localPosition = Vector3.down * (currentIndex * statsSpacing);
                instance.transform.localScale    = Vector3.one;

                currentIndex++;

                string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : "";
                instance.SetInfo(((current.myInfo != null) ? current.myInfo.rank : 1).ToString(),
                                 clanNameFinal + current.myInfo.username,
                                 kills.ToString(),
                                 deaths.ToString(),
                                 kd.ToString("F2"),
                                 current.myHeads.ToString(),
                                 score.ToString(),
                                 ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(),
                                 (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player),
                                 (currentIndex % 2 == 0));
            }
        }

        if (GeneralVariables.gameModeHasTeams)
        {
            roundLabel.cachedTrans.localPosition    = new Vector3(0f, 245f, -7f);
            spectatorList.cachedTrans.localPosition = new Vector3(-395f, -316f, 0f);
            panelRoot.localPosition = Vector3.zero;
            statsBackground.SetDimensions(270, 530);
            statsOutline.SetDimensions(278, 540);
        }
        else
        {
            roundLabel.cachedTrans.localPosition    = new Vector3(0f, 225f, -7f);
            spectatorList.cachedTrans.localPosition = new Vector3(-395f, -261f, 0f);
            panelRoot.localPosition = Vector3.up * -20f;
            statsBackground.SetDimensions(270, 440);
            statsOutline.SetDimensions(278, 450);
        }

        int roundScore = (int)Topan.Network.player.GetPlayerData("sc", 0);
        int targetExp  = AccountManager.GetTargetExperienceForRank(AccountManager.profileData.rank);

        startExp             = AccountManager.profileData.curXP;
        currentExpValue      = startExp;
        earnedExp            = roundScore;
        earnedCurrency       = Mathf.RoundToInt(roundScore * UnityEngine.Random.Range(0.95f, 1.05f) * 0.237f);
        expBaseAnimationTime = Mathf.Max(0.01f, expBaseAnimationTime);
        animationSpeed       = (float)earnedExp / expBaseAnimationTime;
        expSlowdownTime      = Mathf.Clamp(expSlowdownTime, 0f, 0.99f);

        expAccumulateSound.volume = 0f;
        expProgressBar.value      = (float)startExp / (float)targetExp;
        xpLabel.text        = startExp.ToString() + " XP / " + targetExp.ToString() + " XP";
        xpLeftLabel.text    = (targetExp - startExp).ToString() + " XP REMAINING";
        currencyLabel.alpha = 0f;
        currencyLabel.text  = "+0 CREDITS";
        rankLabel.text      = "[u]" + AccountManager.profileData.username + "[/u]" + "\n" + "RANK " + AccountManager.profileData.rank.ToString() + " [ROOKIE]";
        nextRankLabel.text  = "RANK " + (AccountManager.profileData.rank + 1).ToString() + " [ROOKIE]";

        StartCoroutine(ProcessData());
    }
示例#24
0
        //Please do not change GetPokeStops() in this file, it's specifically set
        //to only find stops within 40 meters
        //this is for gpx pathing, we are not going to the pokestops,
        //so do not make it more than 40 because it will never get close to those stops.
        public static async Task Execute()
        {
            if (Logic._client.Settings.GPXIgnorePokestops)
            {
                return;
            }

            var pokestops = await Inventory.GetPokestops(true);

            while (pokestops.Any())
            {
                var pokestop =
                    pokestops.OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude,
                                                                Logic._client.CurrentLongitude, i.Latitude, i.Longitude)).First();
                pokestops.Remove(pokestop);

                var distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude);

                var fortInfo = await Logic._client.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                var latlngDebug = string.Empty;
                if (Logic._client.Settings.DebugMode)
                {
                    latlngDebug = $"| Latitude: {pokestop.Latitude} - Longitude: {pokestop.Longitude}";
                }
                Logger.Write($"Name: {fortInfo.Name} in {distance:0.##} m distance {latlngDebug}", LogLevel.Pokestop);

                //Catch Lure Pokemon
                if (pokestop.LureInfo != null && Logic._client.Settings.CatchLuredPokemon)
                {
                    await CatchLurePokemonsTask.Execute(pokestop);
                }

                var       timesZeroXPawarded = 0;
                var       fortTry            = 0;  //Current check
                const int retryNumber        = 50; //How many times it needs to check to clear softban
                const int zeroCheck          = 5;  //How many times it checks fort before it thinks it's softban
                do
                {
                    var fortSearch = await Logic._client.Fort.SearchFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                    if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0)
                    {
                        timesZeroXPawarded = 0;
                    }
                    if (fortSearch.ExperienceAwarded == 0)
                    {
                        timesZeroXPawarded++;

                        if (timesZeroXPawarded <= zeroCheck)
                        {
                            continue;
                        }
                        if ((int)fortSearch.CooldownCompleteTimestampMs != 0)
                        {
                            break; // Check if successfully looted, if so program can continue as this was "false alarm".
                        }
                        fortTry += 1;

                        if (Logic._client.Settings.DebugMode)
                        {
                            Logger.Write($"Seems your Soft-Banned. Trying to Unban via Pokestop Spins. Retry {fortTry} of {retryNumber - zeroCheck}", LogLevel.Warning);
                        }

                        await RandomHelper.RandomDelay(75, 100);
                    }
                    else
                    {
                        BotStats.ExperienceThisSession += fortSearch.ExperienceAwarded;
                        BotStats.UpdateConsoleTitle();
                        Logger.Write($"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}", LogLevel.Pokestop);
                        RecycleItemsTask._recycleCounter++;
                        HatchEggsTask._hatchUpdateDelayGPX++;
                        break; //Continue with program as loot was succesfull.
                    }
                } while (fortTry < retryNumber - zeroCheck);
                //Stop trying if softban is cleaned earlier or if 40 times fort looting failed.

                if (RecycleItemsTask._recycleCounter >= 5)
                {
                    await RecycleItemsTask.Execute();
                }
                if (HatchEggsTask._hatchUpdateDelayGPX >= 5)
                {
                    await HatchEggsTask.Execute();
                }
            }
        }
        public static async Task Execute()
        {
            var distanceFromStart = LocationUtils.CalculateDistanceInMeters(
                Logic._client.Settings.DefaultLatitude, Logic._client.Settings.DefaultLongitude,
                Logic._client.CurrentLatitude, Logic._client.CurrentLongitude);

            // Edge case for when the client somehow ends up outside the defined radius
            if (Logic._client.Settings.MaxTravelDistanceInMeters != 0 &&
                distanceFromStart > Logic._client.Settings.MaxTravelDistanceInMeters)
            {
                Logger.Write(
                    $"You're outside of your defined radius! Walking to Default Coords ({distanceFromStart:0.##}m away). Is your LastCoords.ini file correct?",
                    LogLevel.Warning);
                await Navigation.HumanLikeWalking(
                    new GeoUtils(Logic._client.Settings.DefaultLatitude, Logic._client.Settings.DefaultLongitude),
                    async() =>
                {
                    // Catch normal map Pokemon
                    await CatchMapPokemonsTask.Execute();
                    //Catch Incense Pokemon
                    await CatchIncensePokemonsTask.Execute();
                    return(true);
                });
            }

            var pokestops = await Inventory.GetPokestops();

            if (pokestops == null || !pokestops.Any())
            {
                Logger.Write("No usable PokeStops found in your area. Reasons: Softbanned - Server Issues - MaxTravelDistanceInMeters too small",
                             LogLevel.Warning);
            }
            else
            {
                Logger.Write($"Found {pokestops.Count()} {(pokestops.Count() == 1 ? "Pokestop" : "Pokestops")}", LogLevel.Info);
            }

            while (pokestops.Any())
            {
                if (Logic._client.Settings.ExportPokemonToCsvEveryMinutes > 0 && ExportPokemonToCsv._lastExportTime.AddMinutes(Logic._client.Settings.ExportPokemonToCsvEveryMinutes).Ticks < DateTime.Now.Ticks)
                {
                    var _playerProfile = await Logic._client.Player.GetPlayer();

                    await ExportPokemonToCsv.Execute(_playerProfile.PlayerData);
                }
                if (Logic._client.Settings.UseLuckyEggs)
                {
                    await UseLuckyEggTask.Execute();
                }
                if (Logic._client.Settings.CatchIncensePokemon)
                {
                    await UseIncenseTask.Execute();
                }

                var pokestopwithcooldown = pokestops.Where(p => p.CooldownCompleteTimestampMs > DateTime.UtcNow.ToUnixTime()).FirstOrDefault();
                if (pokestopwithcooldown != null)
                {
                    pokestops.Remove(pokestopwithcooldown);
                }

                var pokestop =
                    pokestops.Where(p => p.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime())
                    .OrderBy(
                        i =>
                        LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude,
                                                                Logic._client.CurrentLongitude, i.Latitude, i.Longitude)).First();

                var lured    = string.Empty;
                var distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude);
                if (distance > 100)
                {
                    var lurePokestop = pokestops.FirstOrDefault(x => x.LureInfo != null);
                    if (lurePokestop != null)
                    {
                        distance = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude, Logic._client.CurrentLongitude, pokestop.Latitude, pokestop.Longitude);
                        if (distance < 200)
                        {
                            lured    = " is Lured";
                            pokestop = lurePokestop;
                        }
                        else
                        {
                            pokestops.Remove(pokestop);
                        }
                    }
                }
                else
                {
                    pokestops.Remove(pokestop);
                }

                var fortInfo = await Logic._client.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                var latlngDebug = string.Empty;
                if (Logic._client.Settings.DebugMode)
                {
                    latlngDebug = $" | Latitude: {pokestop.Latitude} - Longitude: {pokestop.Longitude}";
                }
                Logger.Write($"Name: {fortInfo.Name} in {distance:0.##} m distance{lured}{latlngDebug}", LogLevel.Pokestop);

                if (Logic._client.Settings.UseTeleportInsteadOfWalking)
                {
                    await
                    Logic._client.Player.UpdatePlayerLocation(pokestop.Latitude, pokestop.Longitude,
                                                              Logic._client.Settings.DefaultAltitude);

                    await RandomHelper.RandomDelay(500);

                    Logger.Write($"Using Teleport instead of Walking!", LogLevel.Navigation);
                }
                else
                {
                    await
                    Navigation.HumanLikeWalking(new GeoUtils(pokestop.Latitude, pokestop.Longitude),
                                                async() =>
                    {
                        // Catch normal map Pokemon
                        await CatchMapPokemonsTask.Execute();
                        //Catch Incense Pokemon
                        await CatchIncensePokemonsTask.Execute();
                        return(true);
                    });
                }

                //Catch Lure Pokemon
                if (pokestop.LureInfo != null && Logic._client.Settings.CatchLuredPokemon)
                {
                    await CatchLurePokemonsTask.Execute(pokestop);
                }

                var       timesZeroXPawarded = 0;
                var       fortTry            = 0;  //Current check
                const int retryNumber        = 45; //How many times it needs to check to clear softban
                const int zeroCheck          = 5;  //How many times it checks fort before it thinks it's softban
                do
                {
                    var fortSearch = await Logic._client.Fort.SearchFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                    if (fortSearch.ExperienceAwarded > 0 && timesZeroXPawarded > 0)
                    {
                        timesZeroXPawarded = 0;
                    }
                    if (fortSearch.ExperienceAwarded == 0)
                    {
                        if (fortSearch.Result == FortSearchResponse.Types.Result.InCooldownPeriod)
                        {
                            Logger.Write("Pokestop is on Cooldown", LogLevel.Debug);
                            break;
                        }

                        timesZeroXPawarded++;
                        if (timesZeroXPawarded > zeroCheck)
                        {
                            fortTry += 1;

                            if (Logic._client.Settings.DebugMode)
                            {
                                Logger.Write(
                                    $"Seems your Soft-Banned. Trying to Unban via Pokestop Spins. Retry {fortTry} of {retryNumber - zeroCheck}",
                                    LogLevel.Warning);
                            }

                            await RandomHelper.RandomDelay(450);
                        }
                    }
                    else if (fortSearch.ExperienceAwarded != 0)
                    {
                        BotStats.ExperienceThisSession += fortSearch.ExperienceAwarded;
                        BotStats.UpdateConsoleTitle();
                        Logger.Write($"XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}", LogLevel.Pokestop);
                        RecycleItemsTask._recycleCounter++;
                        HatchEggsTask._hatchUpdateDelay++;
                        break;                               //Continue with program as loot was succesfull.
                    }
                } while (fortTry < retryNumber - zeroCheck); //Stop trying if softban is cleaned earlier or if 40 times fort looting failed.

                if (RecycleItemsTask._recycleCounter >= 5)
                {
                    await RecycleItemsTask.Execute();
                }
                if (HatchEggsTask._hatchUpdateDelay >= 15)
                {
                    await HatchEggsTask.Execute();
                }
            }
        }
示例#26
0
 private void Awake()
 {
     bStats = GetComponent <BotStats>();
     hp     = GetComponent <Health>();
     dLog   = GameObject.Find("RunningUI/Text Log/Log Panel/Content").GetComponent <DisplayLog>();
 }
示例#27
0
 public float getAttributeValue(BotStats.ID attID)
 {
     return attributes[(int)attID];
 }
示例#28
0
        public void SaveBotStats(BotStats stats)
        {
            var path = Constants.ConfigRootDirectory + Constants.BotStatistics;

            File.WriteAllText(path, JsonConvert.SerializeObject(stats));
        }
示例#29
0
        public static async Task Execute(dynamic encounter, MapPokemon pokemon, FortData currentFortData = null, ulong encounterId = 0)
        {
            // If the encounter is null nothing will work below, so exit now
            if (encounter == null)
            {
                return;
            }
            float probability = encounter.CaptureProbability?.CaptureProbability_[0];

            var catchType   = encounter is EncounterResponse ? "Normal" : encounter is DiskEncounterResponse ? "Lure" : "Incense";
            var Id          = encounter is EncounterResponse ? pokemon.PokemonId : encounter?.PokemonData.PokemonId;
            var Level       = PokemonInfo.GetLevel(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData);
            var Cp          = encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData?.Cp : encounter?.PokemonData?.Cp ?? 0;
            var MaxCp       = PokemonInfo.CalculateMaxCp(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData);
            var Iv          = PokemonInfo.CalculatePokemonPerfection(encounter is EncounterResponse ? encounter.WildPokemon?.PokemonData : encounter?.PokemonData);
            var Probability = Math.Round(probability * 100, 2);
            var distance    = LocationUtils.CalculateDistanceInMeters(Logic._client.CurrentLatitude,
                                                                      Logic._client.CurrentLongitude,
                                                                      encounter is EncounterResponse || encounter is IncenseEncounterResponse ? pokemon.Latitude : currentFortData.Latitude,
                                                                      encounter is EncounterResponse || encounter is IncenseEncounterResponse ? pokemon.Longitude : currentFortData.Longitude);

            if (!float.IsNaN(probability) && probability < 0.35)
            {
                await
                UseBerry(encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.EncounterId : encounterId,
                         encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.SpawnPointId : currentFortData?.Id);
            }

            CatchPokemonResponse caughtPokemonResponse;
            var attemptCounter = 1;

            do
            {
                var pokeball = await GetBestBall(encounter, probability);

                if (pokeball == ItemId.ItemUnknown)
                {
                    Logger.Write($"You don't own any Pokeballs :( - We missed a {Id} with CP {Cp}", LogLevel.Warning);
                    return;
                }

                caughtPokemonResponse =
                    await Logic._client.Encounter.CatchPokemon(
                        encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.EncounterId : encounterId,
                        encounter is EncounterResponse || encounter is IncenseEncounterResponse?pokemon.SpawnPointId : currentFortData.Id, pokeball);

                if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
                {
                    BotStats.ExperienceThisSession    += caughtPokemonResponse.CaptureAward.Xp.Sum();
                    BotStats.PokemonCaughtThisSession += 1;
                    await BotStats.GetPokeDexCount();

                    await BotStats.GetPokemonCount();

                    var profile = await Logic._client.Player.GetPlayer();

                    BotStats.TotalStardust = profile.PlayerData.Currencies.ToArray()[1].Amount;
                    BotStats.UpdateConsoleTitle();
                }

                if (encounter?.CaptureProbability?.CaptureProbability_ != null)
                {
                    Func <ItemId, string> returnRealBallName = a =>
                    {
                        switch (a)
                        {
                        case ItemId.ItemPokeBall:
                            return("Poke");

                        case ItemId.ItemGreatBall:
                            return("Great");

                        case ItemId.ItemUltraBall:
                            return("Ultra");

                        case ItemId.ItemMasterBall:
                            return("Master");

                        default:
                            return("Unknown");
                        }
                    };

                    var catchStatus = attemptCounter > 1
                        ? $"{caughtPokemonResponse.Status} Attempt #{attemptCounter}"
                        : $"{caughtPokemonResponse.Status}";

                    var receivedXp = caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess
                        ? $"and received XP {caughtPokemonResponse.CaptureAward.Xp.Sum()}"
                        : $"";

                    await Inventory.GetCachedInventory(true);

                    var BallAmount = await Inventory.GetItemAmountByType(pokeball);

                    Logger.Write($"({catchStatus} / {catchType}) | {Id} - Lvl {Level} [CP {Cp}/{MaxCp} | IV: {Iv.ToString("0.00")}% perfect] | Chance: {Probability} | {distance:0.##}m dist | with a {returnRealBallName(pokeball)}Ball [Remaining: {BallAmount}] {receivedXp}", LogLevel.Pokemon);
                }

                attemptCounter++;
            }while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed || caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
        }
示例#30
0
    public void Refresh()
    {
        if (!Topan.Network.isConnected)
        {
            return;
        }

        sortedPlayers = new List <NetPlayerInfo>();

        for (int i = 0; i < Topan.Network.connectedPlayers.Length; i++)
        {
            Topan.NetworkPlayer curPlayer = Topan.Network.connectedPlayers[i];
            NetPlayerInfo       npi       = new NetPlayerInfo();

            npi.realPlayer = curPlayer;
            npi.myKills    = (int)((UInt16)curPlayer.GetPlayerData("k", (UInt16)0));
            npi.myDeaths   = (int)((UInt16)curPlayer.GetPlayerData("d", (UInt16)0));
            npi.myHeads    = (int)((UInt16)curPlayer.GetPlayerData("h", (UInt16)0));
            npi.myScore    = (int)curPlayer.GetPlayerData("sc", 0);
            sortedPlayers.Add(npi);

            if (curPlayer.id == Topan.Network.player.id)
            {
                yourPlayer = npi;
            }
        }

        if (GeneralVariables.gameModeHasTeams)
        {
            int redIndex       = 0;
            int blueIndex      = 0;
            int redTotalScore  = 0;
            int blueTotalScore = 0;

            waitingForRed  = true;
            waitingForBlue = true;

            BotPlayer[] redBots = NetworkingGeneral.GetBotParticipants(0);
            for (int i = 0; i < redBots.Length; i++)
            {
                BotStats hisStats = BotManager.GetBotStats(redBots[i].index);

                NetPlayerInfo npi = new NetPlayerInfo();
                npi.botPlayer = redBots[i];
                npi.myKills   = hisStats.kills;
                npi.myDeaths  = hisStats.deaths;
                npi.myHeads   = hisStats.headshots;
                npi.myScore   = hisStats.score;
                sortedPlayers.Add(npi);
            }

            BotPlayer[] blueBots = NetworkingGeneral.GetBotParticipants(1);
            for (int i = 0; i < blueBots.Length; i++)
            {
                BotStats hisStats = BotManager.GetBotStats(blueBots[i].index);

                NetPlayerInfo npi = new NetPlayerInfo();
                npi.botPlayer = blueBots[i];
                npi.myKills   = hisStats.kills;
                npi.myDeaths  = hisStats.deaths;
                npi.myHeads   = hisStats.headshots;
                npi.myScore   = hisStats.score;
                sortedPlayers.Add(npi);
            }

            if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills)
            {
                sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills));
            }
            else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score)
            {
                sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore));
            }

            tdmSubheader.text = NetworkingGeneral.currentGameType.typeName + " [" + Topan.Network.GameName + "]";
            for (int i = 0; i < sortedPlayers.Count; i++)
            {
                NetPlayerInfo current = sortedPlayers[i];
                if (current.botPlayer == null && current.realPlayer == null)
                {
                    continue;
                }

                if (current.myInfo == null)
                {
                    continue;
                }

                int   kills  = current.myKills;
                int   deaths = current.myDeaths;
                int   score  = current.myScore;
                float kd     = (deaths > 0) ? ((float)kills / (float)deaths) : kills;

                UserStatsGUI usg = null;
                if (current.myTeam == 0)
                {
                    if (redIndex >= 8)
                    {
                        continue;
                    }

                    waitingForRed = false;
                    usg           = redTeam[redIndex];
                    usg.gameObject.SetActive(true);
                    redTotalScore += score;
                    redIndex++;
                }
                else if (current.myTeam == 1)
                {
                    if (blueIndex >= 8)
                    {
                        continue;
                    }

                    waitingForBlue = false;
                    usg            = blueTeam[blueIndex];
                    usg.gameObject.SetActive(true);
                    blueTotalScore += score;
                    blueIndex++;
                }

                int thisListIndex = (current.myTeam == 0) ? redIndex : blueIndex;

                string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : "";
                usg.SetInfo(current.myInfo.rank.ToString(),
                            clanNameFinal + current.myInfo.username,
                            kills.ToString(),
                            deaths.ToString(),
                            kd.ToString("F2"),
                            current.myHeads.ToString(),
                            score.ToString(),
                            ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(),
                            (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player),
                            (thisListIndex % 2 == 0));
            }

            if (redIndex < 7)
            {
                for (int i = redIndex; i < 8; i++)
                {
                    redTeam[i].gameObject.SetActive(false);
                }
            }

            if (blueIndex < 7)
            {
                for (int i = blueIndex; i < 8; i++)
                {
                    blueTeam[i].gameObject.SetActive(false);
                }
            }

            try
            {
                tkRed  = (UInt16)Topan.Network.GetServerInfo("rTK");
                tkBlue = (UInt16)Topan.Network.GetServerInfo("bTK");
                tdRed  = (UInt16)Topan.Network.GetServerInfo("rTD");
                tdBlue = (UInt16)Topan.Network.GetServerInfo("bTD");
            }
            catch
            {
                tkRed  = 0;
                tkBlue = 0;
                tdRed  = 0;
                tdBlue = 0;
            }

            string redTotal = "Total Kills: " + tkRed;
            redTotal += "\n" + "Total Deaths: " + tdRed;
            float redKD = (tdRed > 0) ? ((float)tkRed / (float)tdRed) : tkRed;
            redTotal += "\n" + "Total K/D: " + redKD.ToString("F2");
            redTotal += "\n" + "Team Score: " + redTotalScore.ToString();
            redTotal += "\n----------------";
            redTotal += "\n" + "Team Captures: 0"; //Placeholder, captures if capture the flag, defuses if demolition.

            string blueTotal = "Total Kills: " + tkBlue;
            blueTotal += "\n" + "Total Deaths: " + tdBlue;
            float blueKD = (tdBlue > 0) ? ((float)tkBlue / (float)tdBlue) : tkBlue;
            blueTotal += "\n" + "Total K/D: " + blueKD.ToString("F2");
            blueTotal += "\n" + "Team Score: " + blueTotalScore.ToString();
            blueTotal += "\n----------------";
            blueTotal += "\n" + "Team Captures: 0"; //Placeholder, captures if capture the flag, defuses if demolition.

            totalStatsRed.text  = redTotal;
            totalStatsBlue.text = blueTotal;

            roundVictoryStats.text = "[CE1C1C](RED)[-] " + (byte)Topan.Network.GetServerInfo("rVic") + " [A0A0A0]|[-] " + (byte)Topan.Network.GetServerInfo("bVic") + " [2546A5](BLUE)[-]";
        }
        else
        {
            int currentIndex = 0;
            int yourIndex    = 1;

            for (int i = 0; i < BotManager.allBotPlayers.Length && i < GeneralVariables.Networking.botCount; i++)
            {
                BotStats hisStats = BotManager.GetBotStats(i);

                NetPlayerInfo npi = new NetPlayerInfo();
                npi.botPlayer = BotManager.allBotPlayers[i];
                npi.myKills   = hisStats.kills;
                npi.myDeaths  = hisStats.deaths;
                npi.myHeads   = hisStats.headshots;
                npi.myScore   = hisStats.score;
                sortedPlayers.Add(npi);
            }

            if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills)
            {
                sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills));
            }
            else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score)
            {
                sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore));
            }

            dmSubheader.text = NetworkingGeneral.currentGameType.typeName + " [" + Topan.Network.GameName + "]";
            for (int i = 0; i < sortedPlayers.Count; i++)
            {
                NetPlayerInfo current = sortedPlayers[i];
                if (current.botPlayer == null && current.realPlayer == null)
                {
                    continue;
                }

                if (current.myInfo == null)
                {
                    continue;
                }

                int   kills  = current.myKills;
                int   deaths = current.myDeaths;
                int   score  = current.myScore;
                float kd     = (deaths > 0) ? ((float)kills / (float)deaths) : kills;

                UserStatsGUI usg = null;

                if (currentIndex >= 16)
                {
                    continue;
                }

                usg = individuals[currentIndex];
                usg.gameObject.SetActive(true);
                currentIndex++;

                if (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player)
                {
                    yourIndex = i;
                }

                string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : "";
                usg.SetInfo(current.myInfo.rank.ToString(),
                            clanNameFinal + current.myInfo.username,
                            kills.ToString(),
                            deaths.ToString(),
                            kd.ToString("F2"),
                            current.myHeads.ToString(),
                            score.ToString(),
                            ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(),
                            (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player),
                            (currentIndex % 2 == 0));
            }

            if (currentIndex < 15)
            {
                for (int i = currentIndex; i < 16; i++)
                {
                    individuals[i].gameObject.SetActive(false);
                }
            }

            tkRed  = 0;
            tkBlue = 0;
            tdRed  = 0;
            tdBlue = 0;

            yourPlace.text = "You're in " + DarkRef.OrdinalIndicatorFormat(yourIndex + 1) + " place";
        }

        refreshTimer += refreshTime;
    }