31 lines
1.1 KiB
ActionScript
31 lines
1.1 KiB
ActionScript
#include "Utilities/CopyableMoves.as"
|
|
|
|
namespace Gen7 {
|
|
[Move effect=Assist]
|
|
class Assist : PkmnScript {
|
|
void ChangeAttack(MoveTurnChoice@ move, constString &inout moveName) override {
|
|
auto user = move.User;
|
|
auto battle = user.Battle;
|
|
auto party = battle.FindPartyForPokemon(user).Party;
|
|
array<const MoveData@> possibleMoves;
|
|
for (int i = 0; i < party.Length; i++){
|
|
auto mon = party.GetAtIndex(i);
|
|
if (mon is null){ continue; }
|
|
auto moves = mon.GetMoves();
|
|
for (uint j = 0; j < moves.length; j++){
|
|
auto m = moves[j];
|
|
if (m is null){ continue; }
|
|
if (CanCopyMove(m.MoveData)){
|
|
possibleMoves.insertLast(m.MoveData);
|
|
}
|
|
}
|
|
}
|
|
if (possibleMoves.length == 0){
|
|
// TODO: Log failure.
|
|
return;
|
|
}
|
|
auto i = battle.Random.Get(possibleMoves.length);
|
|
moveName = possibleMoves[i].Name;
|
|
}
|
|
}
|
|
} |