Gen7Data/Scripts/Moves/ModifyDamageIfHitByTarget.as

22 lines
931 B
ActionScript

namespace Gen7 {
// For moves such as Avalanche
[Move effect=ModifyDamageIfHitByTarget]
class ModifyDamageIfHitByTarget : PkmnScript {
void OverrideDamage(ExecutingMove@ move, Pokemon@ target, uint8 hit, uint &inout damage) override {
auto historyElement = move.User.Battle.History.TopElement;
auto turn = move.User.Battle.CurrentTurn;
while (historyElement !is null){
if (historyElement.TurnNumber < turn){
break;
}
if (historyElement.Kind == HistoryElementKind::AttackUse){
auto attackEvent = cast<const AttackUseHistory@>(historyElement);
if (attackEvent.Move.User is target && attackEvent.Move.IsPokemonTarget(move.User)){
damage *= 2;
break;
}
}
}
};
}
}