Surprisingly, more moves
This commit is contained in:
57
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Present.cs
Normal file
57
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Present.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using PkmnLib.Static.Moves;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "present")]
|
||||
public class Present : Script
|
||||
{
|
||||
private bool _isHealing;
|
||||
private byte _basePower;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
||||
{
|
||||
var battleRandom = move.User.BattleData?.Battle.Random;
|
||||
if (battleRandom == null)
|
||||
return;
|
||||
var percentRoll = battleRandom.GetFloat() * 100.0;
|
||||
if (percentRoll < 20.0)
|
||||
{
|
||||
_isHealing = true;
|
||||
_basePower = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isHealing = false;
|
||||
_basePower = percentRoll switch
|
||||
{
|
||||
< 30 => 120,
|
||||
< 60 => 80,
|
||||
_ => 40,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
|
||||
{
|
||||
if (_isHealing)
|
||||
category = MoveCategory.Status;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
|
||||
{
|
||||
basePower = _basePower;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (!_isHealing)
|
||||
return;
|
||||
|
||||
var healAmount = (ushort)(target.MaxHealth / 4);
|
||||
target.Heal(healAmount);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user