Adds a lot more move effects
This commit is contained in:
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Recoil.cs
Normal file
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Recoil.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Dynamic.Models.BattleFlow;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "recoil")]
|
||||
public class Recoil : Script
|
||||
{
|
||||
private float _recoilPercentage;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
if (parameters == null)
|
||||
return;
|
||||
if (parameters.TryGetValue("recoil_percentage", out var recoilPercentage))
|
||||
_recoilPercentage = recoilPercentage as float? ?? 0f;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (_recoilPercentage <= 0)
|
||||
return;
|
||||
var hitData = move.GetHitData(target, hit);
|
||||
var recoilDamage = (uint)(hitData.Damage * _recoilPercentage);
|
||||
move.User.Damage(recoilDamage, DamageSource.Misc);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user