コード例 #1
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
 public bool IsPokemonUsable(Pokemon pokemon)
 {
     if (_client.IsInBattle)
     {
         if (Side != null)
         {
             var sidePoke = Side.pokemon.ToList().Find(p => p.personality
                                                       == pokemon.PokemonData.Pokemon.Payload.Personality &&
                                                       p.trainer?.ToLowerInvariant() == _client.ActiveBattle._playerName?.ToLowerInvariant());
             if (sidePoke != null)
             {
                 var pok = Battle.GetSwitchedPokemon(sidePoke);
                 return(IsPokemonUsable(pok));
             }
         }
         return(false);
     }
     if (pokemon.CurrentHealth > 0)
     {
         foreach (PokemonMove move in pokemon.Moves)
         {
             MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);
             if (move.CurrentPoints > 0 && IsMoveOffensive(move, moveData) &&
                 move.Id + 1 != DreamEater && move.Id + 1 != Synchronoise && move.Id + 1 != DoubleEdge)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #2
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
 private bool IsMoveOffensive(PokemonMove move, MovesManager.MoveData moveData)
 {
     if (move.Data is null is false)
     {
         return(moveData.RealPower > 0 || move.Data.ID == DragonRage || move.Data.ID == SeismicToss || move.Data.ID == NightShade || move.Data.ID == Psywave);
     }
     return(moveData.RealPower > 0 || move.Id + 1 == DragonRage || move.Id + 1 == SeismicToss || move.Id + 1 == NightShade || move.Id + 1 == Psywave);
 }
コード例 #3
0
ファイル: BattleAI.cs プロジェクト: johnnymo87/proshine
 public bool IsPokemonUsable(Pokemon pokemon)
 {
     if (pokemon.CurrentHealth > 0)
     {
         foreach (PokemonMove move in pokemon.Moves)
         {
             MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);
             if (move.CurrentPoints > 0 && IsMoveOffensive(move, moveData) && move.Id != DreamEater)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #4
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
 public bool IsPokemonUsable(SwitchedPokemon pokemon)
 {
     if (pokemon.Health > 0)
     {
         foreach (var move in pokemon.Moves)
         {
             MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.id);
             if (move.pp > 0 && IsMoveOffensive(moveData) && !move.disabled &&
                 moveData.ID != DreamEater && moveData.ID != Synchronoise && moveData.ID != DoubleEdge)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #5
0
 public bool IsPokemonUsable(Pokemon pokemon)
 {
     if ((pokemon.CurrentHealth > 0 && !_client.IsInBattle) || (pokemon.BattleCurrentHealth > 0 && _client.IsInBattle))
     {
         foreach (PokemonMove move in pokemon.Moves)
         {
             MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);
             if (move.CurrentPoints > 0 && IsMoveOffensive(move, moveData) &&
                 move.Id + 1 != DreamEater && move.Id + 1 != Synchronoise && move.Id + 1 != DoubleEdge)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #6
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
        public bool IsPokemonUsable(PSXAPI.Response.Payload.BattlePokemon sidePoke)
        {
            var pokemon = Battle.GetSwitchedPokemon(sidePoke);

            if (pokemon.Health > 0)
            {
                foreach (var move in pokemon.Moves)
                {
                    MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.id);
                    if (move.pp > 0 && IsMoveOffensive(moveData) && !move.disabled &&
                        moveData.ID != DreamEater && moveData.ID != Synchronoise && moveData.ID != DoubleEdge)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #7
0
 public bool LegacyUseMove(string moveName)
 {
     if (LegacyUsePreconditions())
     {
         return(true);
     }
     for (int i = 0; i < ActivePokemon.Moves.Length; ++i)
     {
         PokemonMove move = ActivePokemon.Moves[i];
         if (move.CurrentPoints > 0)
         {
             MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);
             if (moveData.Name.ToUpperInvariant() == moveName)
             {
                 _client.UseAttack(i + 1);
                 return(true);
             }
         }
     }
     return(LegacyAttack());
 }
コード例 #8
0
        public bool UseMove(string moveName)
        {
            if (ActivePokemon.BattleCurrentHealth == 0)
            {
                return(false);
            }

            moveName = moveName.ToUpperInvariant();
            for (int i = 0; i < ActivePokemon.Moves.Length; ++i)
            {
                PokemonMove move = ActivePokemon.Moves[i];
                if (move.CurrentPoints > 0)
                {
                    MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);
                    if (moveData.Name.ToUpperInvariant() == moveName)
                    {
                        if (ActiveOpponentPokemons.Length > 1)
                        {
                            var selected = 0;
                            for (int j = 0; j < ActivePokemons.Length; ++j)
                            {
                                if (ActivePokemons[i].Trainer == _client.ActiveBattle._playerName &&
                                    _client.Team.FindIndex(p => p.PokemonData.Pokemon.Payload.Personality == ActivePokemons[i].Personality) >= 0)
                                {
                                    selected = j;
                                }
                            }
                            _client.UseAttack(i + 1, selected == 0 ? 0 : selected, _client.Rand.Next(0, ActiveOpponentPokemons.Length - 1) + 1);
                        }
                        else
                        {
                            _client.UseAttack(i + 1);
                        }

                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #9
0
ファイル: BattleAI.cs プロジェクト: darkendvoid/proshine
        public bool UseMove(string moveName)
        {
            if (ActivePokemon.CurrentHealth == 0)
            {
                return(false);
            }

            moveName = moveName.ToUpperInvariant();
            for (int i = 0; i < ActivePokemon.Moves.Length; ++i)
            {
                PokemonMove move = ActivePokemon.Moves[i];
                if (move.CurrentPoints > 0)
                {
                    MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);
                    if (moveData.Name.ToUpperInvariant() == moveName)
                    {
                        _client.UseAttack(i + 1);
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #10
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
        public bool UseMove(string moveName)
        {
            if (ActivePokemon.BattleCurrentHealth == 0)
            {
                return(false);
            }

            moveName = moveName.ToUpperInvariant();
            for (int i = 0; i < ActivePokemon.Moves.Length; ++i)
            {
                var activePoke = ActivePokemons.FirstOrDefault(x => x.Personality == ActivePokemon.PokemonData.Pokemon.Payload.Personality);
                var move       = activePoke.Moves[i];
                if (move.pp > 0 && !move.disabled)
                {
                    MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.id);
                    if (moveData.Name.ToUpperInvariant() == moveName)
                    {
                        _client.UseAttack(i + 1);
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #11
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
        private double ApplySpecialEffects(MovesManager.MoveData move, SwitchedPokemon poke, SwitchedPokemon active, double power)
        {
            if (move.ID == DragonRage)
            {
                return(poke.Health <= 40 ? 10000.0 : 1.0);
            }

            if (move.ID == SeismicToss || move.ID == NightShade)
            {
                return(poke.Health <= active.Level ? 10000.0 : 1.0);
            }

            if (move.ID == Psywave)
            {
                return(poke.Health <= (active.Level / 2) ? 10000.0 : 1.0);
            }

            if (move.ID == FalseSwipe)
            {
                return(0.1);
            }

            return(power);
        }
コード例 #12
0
ファイル: BattleAI.cs プロジェクト: FakeRainx/pporise
 private bool IsMoveOffensive(PokemonMove move, MovesManager.MoveData moveData, PokemonType opponentType1, PokemonType opponentType2)
 {
     return(moveData.Power > 0 ||
            move.Id == DragonRage && opponentType1 != PokemonType.Fairy && opponentType2 != PokemonType.Fairy ||
            move.Id == SeismicToss || move.Id == NightShade || move.Id == Psywave);
 }
コード例 #13
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
 private bool IsMoveOffensive(MovesManager.MoveData moveData)
 {
     return(moveData != null && (moveData.RealPower > 0 || moveData.ID == DragonRage || moveData.ID == SeismicToss || moveData.ID == NightShade || moveData.ID == Psywave));
 }
コード例 #14
0
        private bool UseAttack(bool useBestAttack)
        {
            PokemonMove bestMove  = null;
            int         bestIndex = 0;
            double      bestPower = 0;

            PokemonMove worstMove  = null;
            int         worstIndex = 0;
            double      worstPower = 0;

            for (int i = 0; i < ActivePokemon.Moves.Length; ++i)
            {
                PokemonMove move = ActivePokemon.Moves[i];
                if (move.CurrentPoints == 0)
                {
                    continue;
                }

                MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);

                if (move.Id == DreamEater && _client.ActiveBattle.WildPokemon.Status != "SLEEP")
                {
                    continue;
                }

                if (move.Id == Explosion || move.Id == Selfdestruct ||
                    (move.Id == DoubleEdge && ActivePokemon.CurrentHealth < _client.ActiveBattle.WildPokemon.CurrentHealth / 3))
                {
                    continue;
                }

                if (!IsMoveOffensive(move, moveData))
                {
                    continue;
                }

                PokemonType attackType = PokemonTypeExtensions.FromName(moveData.Type);

                PokemonType playerType1 = TypesManager.Instance.Type1[ActivePokemon.Id];
                PokemonType playerType2 = TypesManager.Instance.Type2[ActivePokemon.Id];

                PokemonType opponentType1 = _client.ActiveBattle.WildPokemon.Type1;
                PokemonType opponentType2 = _client.ActiveBattle.WildPokemon.Type2;

                double accuracy = (moveData.Accuracy < 0 ? 101.0 : moveData.Accuracy);

                double power = moveData.Power * accuracy;

                if (attackType == playerType1 || attackType == playerType2)
                {
                    power *= 1.5;
                }

                power *= TypesManager.Instance.GetMultiplier(attackType, opponentType1);
                power *= TypesManager.Instance.GetMultiplier(attackType, opponentType2);

                if (attackType == PokemonType.Ground && _levitatingPokemons.Contains(_client.ActiveBattle.WildPokemon.Id))
                {
                    power = 0;
                }

                power = ApplySpecialEffects(move, power);

                if (move.Id == Synchronoise)
                {
                    if (playerType1 != opponentType1 && playerType1 != opponentType2 &&
                        (playerType2 == PokemonType.None || playerType2 != opponentType1) &&
                        (playerType2 == PokemonType.None || playerType2 != opponentType2))
                    {
                        power = 0;
                    }
                }

                if (move.Id == DragonRage)
                {
                    if (opponentType1 == PokemonType.Fairy || opponentType2 == PokemonType.Fairy)
                    {
                        power = 0;
                    }
                }

                if (power < 0.01)
                {
                    continue;
                }

                if (bestMove == null || power > bestPower)
                {
                    bestMove  = move;
                    bestPower = power;
                    bestIndex = i;
                }

                if (worstMove == null || power < worstPower)
                {
                    worstMove  = move;
                    worstPower = power;
                    worstIndex = i;
                }
            }


            switch (useBestAttack)
            {
            case true when bestMove != null:
                _client.UseAttack(bestIndex);
                return(true);

            case false when worstMove != null:
                _client.UseAttack(worstIndex);
                return(true);

            default:
                return(false);
            }
        }
コード例 #15
0
ファイル: BattleAI.cs プロジェクト: darkendvoid/proshine
 private bool IsMoveOffensive(PokemonMove move, MovesManager.MoveData moveData)
 {
     return(moveData.Power > 0 || move.Id == DragonRage || move.Id == SeismicToss || move.Id == NightShade || move.Id == Psywave);
 }
コード例 #16
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
        private ResultUsingMove UseAttack(bool useBestAttack, int activePoke, int oppenentPoke)
        {
            var activePokemon = ActivePokemons[activePoke];

            if (!IsPokemonUsable(activePokemon))
            {
                if (Pokemons.FindAll(x => !x.Sent && (IsPokemonUsable(x) || x.Health > 0)).Count <= 0)
                {
                    if (activePokemon.Health <= 0)
                    {
                        _client.UseAttack(0, activePoke + 1);
                        return(ResultUsingMove.Success);
                    }
                    else
                    {
                        return(ResultUsingMove.NoLongerUsable);
                    }
                }
                return(ResultUsingMove.Fainted);
            }

            PSXAPI.Response.Payload.BattleMove bestMove = null;
            int    bestIndex = 0;
            double bestPower = 0;

            PSXAPI.Response.Payload.BattleMove worstMove = null;
            int    worstIndex = 0;
            double worstPower = 0;

            if (activePoke < 0)
            {
                return(ResultUsingMove.NoLongerUsable);
            }

            for (int i = 0; i < activePokemon.Moves.Length; i++)
            {
                var move = activePokemon.Moves[i];
                if (move is null)
                {
                    continue;
                }
                if (move.pp == 0 || move.disabled)
                {
                    continue;
                }

                MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.id);

                if (moveData is null)
                {
                    continue;
                }

                if (moveData.ID == DreamEater && ActiveOpponentPokemons[oppenentPoke].Status != "slp")
                {
                    continue;
                }

                if (moveData.ID == Explosion || moveData.ID == Selfdestruct ||
                    (moveData.ID == DoubleEdge && activePokemon.Health < ActiveOpponentPokemons[oppenentPoke].Health / 3))
                {
                    continue;
                }

                if (!IsMoveOffensive(moveData))
                {
                    continue;
                }

                PokemonType attackType = PokemonTypeExtensions.FromName(moveData.Type);

                PokemonType playerType1 = TypesManager.Instance.Type1[activePokemon.ID];
                PokemonType playerType2 = TypesManager.Instance.Type2[activePokemon.ID];

                PokemonType opponentType1 = TypesManager.Instance.Type1[ActiveOpponentPokemons[oppenentPoke].ID];
                PokemonType opponentType2 = TypesManager.Instance.Type2[ActiveOpponentPokemons[oppenentPoke].ID];

                double accuracy = (moveData.Accuracy < 0 ? 101.0 : moveData.Accuracy);

                double power = moveData.RealPower * accuracy;

                if (attackType == playerType1 || attackType == playerType2)
                {
                    power *= 1.5;
                }

                power *= TypesManager.Instance.GetMultiplier(attackType, opponentType1);
                power *= TypesManager.Instance.GetMultiplier(attackType, opponentType2);

                if (attackType == PokemonType.Ground && PokemonManager.Instance.IsLavitatingPokemon(ActiveOpponentPokemons[oppenentPoke].ID))
                {
                    power = 0;
                }

                power = ApplySpecialEffects(moveData, ActiveOpponentPokemons[oppenentPoke], activePokemon, power);

                if (moveData.ID == Synchronoise)
                {
                    if (playerType1 != opponentType1 && playerType1 != opponentType2 &&
                        (playerType2 == PokemonType.None || playerType2 != opponentType1) &&
                        (playerType2 == PokemonType.None || playerType2 != opponentType2))
                    {
                        power = 0;
                    }
                }

                if (power < 0.01)
                {
                    continue;
                }

                if (bestMove == null || power > bestPower)
                {
                    bestMove  = move;
                    bestPower = power;
                    bestIndex = i;
                }

                if (worstMove == null || power < worstPower)
                {
                    worstMove  = move;
                    worstPower = power;
                    worstIndex = i;
                }
            }

            if (ActivePokemons.Length <= 1)
            {
                IsBusy = true;
            }

            if (useBestAttack && bestMove != null)
            {
                _client.UseAttack(bestIndex + 1, activePoke + 1, ActiveOpponentPokemons.Length == 1 ? oppenentPoke : oppenentPoke + 1);
                return(ResultUsingMove.Success);
            }
            if (!useBestAttack && worstMove != null)
            {
                _client.UseAttack(worstIndex + 1, activePoke + 1, ActiveOpponentPokemons.Length == 1 ? oppenentPoke : oppenentPoke + 1);
                return(ResultUsingMove.Success);
            }
            return(ResultUsingMove.NoLongerUsable);
        }
コード例 #17
0
ファイル: BattleAI.cs プロジェクト: Hexaros/pokeone-pluse
        private bool UseAttack(bool useBestAttack)
        {
            PokemonMove bestMove  = null;
            int         bestIndex = 0;
            double      bestPower = 0;

            PokemonMove worstMove  = null;
            int         worstIndex = 0;
            double      worstPower = 0;

            for (int i = 0; i < ActivePokemon.Moves.Length; ++i)
            {
                PokemonMove move = ActivePokemon.Moves[i];
                if (move.CurrentPoints == 0)
                {
                    continue;
                }

                MovesManager.MoveData moveData = MovesManager.Instance.GetMoveData(move.Id);

                if (move.Id + 1 == DreamEater && _client.ActiveBattle.OpponentStatus != "slp")
                {
                    continue;
                }

                if (move.Id + 1 == Explosion || move.Id + 1 == Selfdestruct ||
                    (move.Id + 1 == DoubleEdge && ActivePokemon.BattleCurrentHealth < _client.ActiveBattle.CurrentHealth / 3))
                {
                    continue;
                }

                if (!IsMoveOffensive(move, moveData))
                {
                    continue;
                }

                PokemonType attackType = PokemonTypeExtensions.FromName(moveData.Type);

                PokemonType playerType1 = TypesManager.Instance.Type1[ActivePokemon.Id];
                PokemonType playerType2 = TypesManager.Instance.Type2[ActivePokemon.Id];

                PokemonType opponentType1 = TypesManager.Instance.Type1[_client.ActiveBattle.OpponentId];
                PokemonType opponentType2 = TypesManager.Instance.Type2[_client.ActiveBattle.OpponentId];

                double accuracy = (moveData.Accuracy < 0 ? 101.0 : moveData.Accuracy);

                double power = moveData.RealPower * accuracy;

                if (attackType == playerType1 || attackType == playerType2)
                {
                    power *= 1.5;
                }

                power *= TypesManager.Instance.GetMultiplier(attackType, opponentType1);
                power *= TypesManager.Instance.GetMultiplier(attackType, opponentType2);

                if (attackType == PokemonType.Ground && PokemonManager.Instance.IsLavitatingPokemon(_client.ActiveBattle.OpponentId))
                {
                    power = 0;
                }

                power = ApplySpecialEffects(move, power);

                if (move.Id + 1 == Synchronoise)
                {
                    if (playerType1 != opponentType1 && playerType1 != opponentType2 &&
                        (playerType2 == PokemonType.None || playerType2 != opponentType1) &&
                        (playerType2 == PokemonType.None || playerType2 != opponentType2))
                    {
                        power = 0;
                    }
                }

                if (power < 0.01)
                {
                    continue;
                }

                if (bestMove == null || power > bestPower)
                {
                    bestMove  = move;
                    bestPower = power;
                    bestIndex = i;
                }

                if (worstMove == null || power < worstPower)
                {
                    worstMove  = move;
                    worstPower = power;
                    worstIndex = i;
                }
            }

            if (useBestAttack && bestMove != null)
            {
                _client.UseAttack(bestIndex + 1);
                return(true);
            }
            if (!useBestAttack && worstMove != null)
            {
                _client.UseAttack(worstIndex + 1);
                return(true);
            }
            return(false);
        }