This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Static.Species;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Libraries.Battling;
|
||||
|
||||
@@ -11,6 +12,8 @@ public class Gen7CaptureLibrary : ICaptureLibrary
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public bool HasPokemonBeenCaughtBefore(ISpecies species) => _configuration.TimesSpeciesCaught(species) > 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public CaptureResult TryCapture(IPokemon target, IItem captureItem, IBattleRandom random)
|
||||
{
|
||||
@@ -18,18 +21,17 @@ public class Gen7CaptureLibrary : ICaptureLibrary
|
||||
var currentHealth = target.CurrentHealth;
|
||||
var catchRate = target.Species.CaptureRate;
|
||||
|
||||
byte bonusBall = 1;
|
||||
if (target.Library.ScriptResolver.TryResolveBattleItemScript(captureItem, out var script) &&
|
||||
script is PokeballScript pokeballScript)
|
||||
{
|
||||
bonusBall = pokeballScript.GetCatchRate(target);
|
||||
pokeballScript.ChangeCatchRate(target, ref catchRate);
|
||||
}
|
||||
|
||||
byte bonusStatus = 1;
|
||||
target.RunScriptHook<IScriptChangeCatchRateBonus>(x =>
|
||||
x.ChangeCatchRateBonus(target, captureItem, ref bonusStatus));
|
||||
|
||||
var modifiedCatchRate = (3.0f * maxHealth - 2.0f * currentHealth) * catchRate * bonusBall / (3.0f * maxHealth);
|
||||
var modifiedCatchRate = (3.0f * maxHealth - 2.0f * currentHealth) * catchRate / (3.0f * maxHealth);
|
||||
modifiedCatchRate *= bonusStatus;
|
||||
|
||||
var shakeProbability = 65536 / Math.Pow(255 / modifiedCatchRate, 0.1875f);
|
||||
|
||||
Reference in New Issue
Block a user