28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "power_split")]
|
|
public class PowerSplit : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var user = move.User;
|
|
var userStats = user.FlatStats;
|
|
var targetStats = target.FlatStats;
|
|
|
|
var userAttack = userStats.GetStatistic(Statistic.Attack);
|
|
var targetAttack = targetStats.GetStatistic(Statistic.Attack);
|
|
var userSpecialAttack = userStats.GetStatistic(Statistic.SpecialAttack);
|
|
var targetSpecialAttack = targetStats.GetStatistic(Statistic.SpecialAttack);
|
|
|
|
var newAttack = (userAttack + targetAttack) / 2;
|
|
var newSpecialAttack = (userSpecialAttack + targetSpecialAttack) / 2;
|
|
|
|
userStats.SetStatistic(Statistic.Attack, newAttack);
|
|
userStats.SetStatistic(Statistic.SpecialAttack, newSpecialAttack);
|
|
targetStats.SetStatistic(Statistic.Attack, newAttack);
|
|
targetStats.SetStatistic(Statistic.SpecialAttack, newSpecialAttack);
|
|
user.RecalculateBoostedStats();
|
|
target.RecalculateBoostedStats();
|
|
}
|
|
} |