mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
remove assist array from battle struct (#2816)
This commit is contained in:
commit
dca6182ed2
@ -534,7 +534,6 @@ struct BattleStruct
|
||||
u8 wildVictorySong;
|
||||
u8 dynamicMoveType;
|
||||
u8 wrappedBy[MAX_BATTLERS_COUNT];
|
||||
u16 assistPossibleMoves[PARTY_SIZE * MAX_MON_MOVES]; // Each of mons can know max 4 moves.
|
||||
u8 focusPunchBattlerId;
|
||||
u8 battlerPreventingSwitchout;
|
||||
u8 moneyMultiplier:6;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "main.h"
|
||||
#include "palette.h"
|
||||
#include "money.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "string_util.h"
|
||||
#include "pokemon_icon.h"
|
||||
@ -14766,38 +14767,40 @@ static void Cmd_assistattackselect(void)
|
||||
s32 chooseableMovesNo = 0;
|
||||
struct Pokemon *party;
|
||||
s32 monId, moveId;
|
||||
u16 *validMoves = gBattleStruct->assistPossibleMoves;
|
||||
u16 *validMoves = Alloc(sizeof(u16) * PARTY_SIZE * MAX_MON_MOVES);
|
||||
|
||||
if (GET_BATTLER_SIDE(gBattlerAttacker) != B_SIDE_PLAYER)
|
||||
party = gEnemyParty;
|
||||
else
|
||||
party = gPlayerParty;
|
||||
|
||||
for (monId = 0; monId < PARTY_SIZE; monId++)
|
||||
if (validMoves != NULL)
|
||||
{
|
||||
if (monId == gBattlerPartyIndexes[gBattlerAttacker])
|
||||
continue;
|
||||
if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE)
|
||||
continue;
|
||||
if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG)
|
||||
continue;
|
||||
if (GET_BATTLER_SIDE(gBattlerAttacker) != B_SIDE_PLAYER)
|
||||
party = gEnemyParty;
|
||||
else
|
||||
party = gPlayerParty;
|
||||
|
||||
for (moveId = 0; moveId < MAX_MON_MOVES; moveId++)
|
||||
for (monId = 0; monId < PARTY_SIZE; monId++)
|
||||
{
|
||||
s32 i = 0;
|
||||
u16 move = GetMonData(&party[monId], MON_DATA_MOVE1 + moveId);
|
||||
|
||||
if (sForbiddenMoves[move] & FORBIDDEN_ASSIST)
|
||||
if (monId == gBattlerPartyIndexes[gBattlerAttacker])
|
||||
continue;
|
||||
if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE)
|
||||
continue;
|
||||
if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG)
|
||||
continue;
|
||||
|
||||
validMoves[chooseableMovesNo] = move;
|
||||
chooseableMovesNo++;
|
||||
for (moveId = 0; moveId < MAX_MON_MOVES; moveId++)
|
||||
{
|
||||
u16 move = GetMonData(&party[monId], MON_DATA_MOVE1 + moveId);
|
||||
|
||||
if (sForbiddenMoves[move] & FORBIDDEN_ASSIST)
|
||||
continue;
|
||||
|
||||
validMoves[chooseableMovesNo++] = move;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (chooseableMovesNo)
|
||||
{
|
||||
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
|
||||
gCalledMove = validMoves[((Random() & 0xFF) * chooseableMovesNo) >> 8];
|
||||
gCalledMove = validMoves[Random() % chooseableMovesNo];
|
||||
gBattlerTarget = GetMoveTarget(gCalledMove, NO_TARGET_OVERRIDE);
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
}
|
||||
@ -14805,6 +14808,8 @@ static void Cmd_assistattackselect(void)
|
||||
{
|
||||
gBattlescriptCurrInstr = cmd->failInstr;
|
||||
}
|
||||
|
||||
TRY_FREE_AND_SET_NULL(validMoves);
|
||||
}
|
||||
|
||||
static void Cmd_trysetmagiccoat(void)
|
||||
|
22
test/move_effect_assist.c
Normal file
22
test/move_effect_assist.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include "global.h"
|
||||
#include "test_battle.h"
|
||||
|
||||
ASSUMPTIONS
|
||||
{
|
||||
ASSUME(gBattleMoves[MOVE_ASSIST].effect == EFFECT_ASSIST);
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Assist fails if there are no valid moves to choose from")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) {Moves(MOVE_ASSIST, MOVE_CELEBRATE, MOVE_METRONOME, MOVE_ME_FIRST); }
|
||||
PLAYER(SPECIES_WOBBUFFET) {Moves(MOVE_ASSIST, MOVE_ENDURE, MOVE_DRAGON_TAIL, MOVE_SPOTLIGHT); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_ASSIST); }
|
||||
} SCENE {
|
||||
MESSAGE("Wobbuffet used Assist!");
|
||||
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_ASSIST, player);
|
||||
MESSAGE("But it failed!");
|
||||
}
|
||||
}
|
@ -1227,6 +1227,7 @@ void Move(u32 sourceLine, struct BattlePokemon *battler, struct MoveContext ctx)
|
||||
const struct BattleMove *move = &gBattleMoves[moveId];
|
||||
if (move->target == MOVE_TARGET_RANDOM
|
||||
|| move->target == MOVE_TARGET_BOTH
|
||||
|| move->target == MOVE_TARGET_DEPENDS
|
||||
|| move->target == MOVE_TARGET_FOES_AND_ALLY
|
||||
|| move->target == MOVE_TARGET_OPPONENTS_FIELD
|
||||
|| move->target == MOVE_TARGET_ALL_BATTLERS)
|
||||
|
Loading…
Reference in New Issue
Block a user