Implements several new move scripts.

This commit is contained in:
2021-05-13 14:32:56 +02:00
parent 76f62d6c2d
commit 5071f309f3
10 changed files with 136 additions and 4 deletions

31
Scripts/Moves/Assist.as Normal file
View File

@@ -0,0 +1,31 @@
#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;
}
}
}

View File

@@ -0,0 +1,20 @@
namespace Gen7 {
[Move effect=CurePartyStatus]
shared class CurePartyStatus : PkmnScript{
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override {
auto user = attack.User;
user.ClearStatus();
auto battleParty = user.Battle.FindPartyForPokemon(user);
if (battleParty !is null){
auto party = battleParty.Party;
for (int i = 0; i < party.Length; i++){
auto m = party.GetAtIndex(i);
if (m !is null){
m.ClearStatus();
}
}
}
}
}
}