namespace PkmnLib.Plugin.Gen7.Scripts.Items.Pokeballs; [ItemScript("level_ball")] public class LevelBall : PokeballScript { /// public LevelBall(IItem item) : base(item) { } /// public override void ChangeCatchRate(IPokemon target, ref byte catchRate) { if (target.BattleData is null) return; var opponentSide = target.BattleData.SideIndex == 0 ? 1 : 0; var opponent = target.BattleData.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null); if (opponent is null) return; var levelDifferenceModifier = (float)target.Level / opponent.Level; var catchModifier = levelDifferenceModifier switch { >= 1f => 1f, >= 0.5f => 2f, >= 0.25f => 4f, _ => 8f, }; catchRate = catchRate.MultiplyOrMax(catchModifier); } }