This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using PkmnLib.Dynamic.AI.Explicit;
|
||||
using PkmnLib.Plugin.Gen7.Libraries.Battling;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Status;
|
||||
using PkmnLib.Static.Moves;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.AI;
|
||||
@@ -157,6 +158,8 @@ public static class AIHelperFunctions
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly StringKey FoulPlayAbilityName = "foul_play";
|
||||
|
||||
private static void GetTargetStatRaiseScoreOne(ref int score, IPokemon target, Statistic stat, sbyte increment,
|
||||
AIMoveState move, float desireMult = 1)
|
||||
{
|
||||
@@ -200,7 +203,7 @@ public static class AIHelperFunctions
|
||||
{
|
||||
var hasPhysicalMoves = target.Moves.WhereNotNull().Any(x =>
|
||||
x.MoveData.Category == MoveCategory.Physical &&
|
||||
x.MoveData.SecondaryEffect?.Name != "foul_play");
|
||||
x.MoveData.SecondaryEffect?.Name != FoulPlayAbilityName);
|
||||
var inc = hasPhysicalMoves ? 8 : 12;
|
||||
score += (int)(inc * incMult);
|
||||
}
|
||||
@@ -334,4 +337,55 @@ public static class AIHelperFunctions
|
||||
|
||||
private static bool Opposes(this IPokemon pokemon, IPokemon target) =>
|
||||
pokemon.BattleData?.BattleSide != target.BattleData?.BattleSide;
|
||||
|
||||
public static bool WantsStatusProblem(IPokemon pokemon, StringKey? status)
|
||||
{
|
||||
if (status is null)
|
||||
return true;
|
||||
if (pokemon.ActiveAbility != null)
|
||||
{
|
||||
if (pokemon.ActiveAbility.Name == "guts" && status != ScriptUtils.ResolveName<Sleep>() &&
|
||||
status != ScriptUtils.ResolveName<Frozen>() &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.Attack, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "marvel_scale" &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.Defense, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "quick_feet" && status != ScriptUtils.ResolveName<Sleep>() &&
|
||||
status != ScriptUtils.ResolveName<Frozen>() && IsStatRaiseWorthwhile(pokemon, Statistic.Speed, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "flare_boost" && status == ScriptUtils.ResolveName<Burned>() &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.SpecialAttack, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "toxic_boost" &&
|
||||
(status == ScriptUtils.ResolveName<Poisoned>() || status == ScriptUtils.ResolveName<BadlyPoisoned>()) &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.Attack, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "poison_heal" && status == ScriptUtils.ResolveName<Poisoned>())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "magic_guard")
|
||||
{
|
||||
if (status != ScriptUtils.ResolveName<Poisoned>() &&
|
||||
status != ScriptUtils.ResolveName<BadlyPoisoned>() && status != ScriptUtils.ResolveName<Burned>())
|
||||
return false;
|
||||
if (IsStatRaiseWorthwhile(pokemon, Statistic.Attack, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user