18 lines
842 B
ActionScript
18 lines
842 B
ActionScript
namespace Gen7 {
|
|
[Ability effect=Aftermath]
|
|
class Aftermath : PkmnScript {
|
|
void OnFaint(Pokemon@ mon, DamageSource source) override {
|
|
// If the mon fainted due to something that was not a move, ignore
|
|
if (source != DamageSource::AttackDamage){
|
|
return;
|
|
}
|
|
// Last used attack on the target should always be the move that caused the faint if the source is AttackDamage
|
|
auto lastMoveEvent = mon.Battle.History.GetLastUsedAttackOnTarget(mon, 1);
|
|
// Check if the move is a contact move
|
|
if (lastMoveEvent.Move.UseMove.HasFlag("contact")){
|
|
// Damage by 1/4th of the mon's max HP.
|
|
lastMoveEvent.Move.User.Damage(lastMoveEvent.Move.User.MaxHealth / 4, DamageSource::Misc);
|
|
}
|
|
}
|
|
}
|
|
} |