Gen7Data/Scripts/Moves/SwapWithTarget.as

18 lines
701 B
ActionScript
Raw Normal View History

2021-03-28 18:22:46 +00:00
namespace Gen7 {
[Move effect=SwapWithTarget]
shared class SwapWithTarget : PkmnScript {
void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
auto userSide = move.User.BattleSide;
auto targetSide = target.BattleSide;
if (userSide !is targetSide){
move.GetHitData(target, hit).Fail();
return;
}
auto userIndex = userSide.GetPokemonIndex(move.User);
auto targetIndex = userSide.GetPokemonIndex(target);
if (!userSide.SwapPositions(userIndex, targetIndex)){
move.GetHitData(target, hit).Fail();
}
}
}
}