Implements accuracy/evasion
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Libraries;
|
||||
@@ -48,6 +50,33 @@ public class Gen7BattleStatCalculator : IBattleStatCalculator
|
||||
return (uint)boostedStat;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public byte CalculateModifiedAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, byte moveAccuracy)
|
||||
{
|
||||
var accuracyModifier = 1.0f;
|
||||
executingMove.RunScriptHook(x => x.ChangeAccuracyModifier(executingMove, target, hitIndex, ref accuracyModifier));
|
||||
var modifiedAccuracy = (int)(moveAccuracy * accuracyModifier);
|
||||
var targetEvasion = target.StatBoost.Evasion;
|
||||
var userAccuracy = executingMove.User.StatBoost.Accuracy;
|
||||
var difference = targetEvasion - userAccuracy;
|
||||
var statModifier = difference switch
|
||||
{
|
||||
> 0 => 3.0f / (3.0f + difference),
|
||||
< 0 => 3.0f + Math.Abs(difference) / 3.0f,
|
||||
_ => 1.0f
|
||||
};
|
||||
modifiedAccuracy = (int)(modifiedAccuracy * statModifier);
|
||||
modifiedAccuracy = modifiedAccuracy switch
|
||||
{
|
||||
> 255 => 255,
|
||||
< 0 => 0,
|
||||
_ => modifiedAccuracy
|
||||
};
|
||||
// NOTE: the main games also consider friendship here, but we don't yet have the concept of a "player Pokémon"
|
||||
// in the battle system, so for now we're just ignoring that.
|
||||
return (byte)modifiedAccuracy;
|
||||
}
|
||||
|
||||
private static uint CalculateHealthStat(IPokemon pokemon)
|
||||
{
|
||||
var baseValue = (ulong)pokemon.Form.BaseStats.Hp;
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
public class AuroraVeilEffect : Script
|
||||
{
|
||||
public int NumberOfTurns { get; set; }
|
||||
|
||||
private AuroraVeilEffect(){}
|
||||
|
||||
public AuroraVeilEffect(int numberOfTurns)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user