2025-07-11 17:03:08 +02:00

51 lines
1.5 KiB
C#

using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Status;
[Script(ScriptCategory.Status, "burned")]
public class Burned : Script, IScriptChangeMoveDamage, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
{
private IPokemon? _target;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
throw new ArgumentException("Burned script can only be added to a Pokemon");
_target = pokemon;
}
/// <inheritdoc />
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (move.UseMove.Category == MoveCategory.Physical)
{
damage = (uint)(damage / 2f);
}
}
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
{
if (_target == null)
return;
var damage = (uint)(_target.MaxHealth / 16f);
var eventBatch = new EventBatchId();
battle.EventHook.Invoke(new DialogEvent("hurt_by_burn", new Dictionary<string, object>
{
{ "pokemon", _target },
{ "damage", damage },
})
{
BatchId = eventBatch,
});
_target.Damage(damage, DamageSource.Status, eventBatch);
}
/// <inheritdoc />
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
{
if (_target != null)
damage += (int)(_target.MaxHealth / 16f);
}
}