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); }
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); }
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); }
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); }
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); }
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); }
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()); }
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); }
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); }
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); }
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); }
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); }
private bool IsMoveOffensive(MovesManager.MoveData moveData) { return(moveData != null && (moveData.RealPower > 0 || moveData.ID == DragonRage || moveData.ID == SeismicToss || moveData.ID == NightShade || moveData.ID == Psywave)); }
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); } }
private bool IsMoveOffensive(PokemonMove move, MovesManager.MoveData moveData) { return(moveData.Power > 0 || move.Id == DragonRage || move.Id == SeismicToss || move.Id == NightShade || move.Id == Psywave); }
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); }
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); }