Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gimmick Refactor #4449

Merged
merged 41 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0fba9e9
consolidated gimmick checks, triggers, communication, and activation;…
AgustinGDLV Apr 26, 2024
8898196
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV Apr 26, 2024
bafc3f2
fixed improper use of .usableGimmick
AgustinGDLV Apr 26, 2024
927f15c
cleaning up battle_dynamax.c, changing function args to u32s
AgustinGDLV Apr 26, 2024
8c5b70f
fixed '#ifdef TESTING' causing errors
AgustinGDLV Apr 30, 2024
2289f58
updated z-moves to use gimmick interface, pared down redundancies; no…
AgustinGDLV May 2, 2024
45c0929
added support for z-moves in tests, consolidated gimmick fields
AgustinGDLV May 2, 2024
64fb357
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV May 2, 2024
01ce4e5
removed ShouldUseMaxMove and .usingMaxMove
AgustinGDLV May 2, 2024
addd03a
renamed TryChangeZIndicator, updated z move display
AgustinGDLV May 2, 2024
1ea39fe
added several z-move tests and fixed various z-move interactions; fix…
AgustinGDLV May 2, 2024
6c30bae
fixed useless battler arg in GetTypeBasedZMove
AgustinGDLV May 2, 2024
0c2a48e
added basic test check for bad Z-Move or Mega usage
AgustinGDLV May 3, 2024
02de343
reworked test runner gimmick functionality; added support for Ultra B…
AgustinGDLV May 3, 2024
0ff5eea
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV May 16, 2024
dc25f84
fixed gimmick test logic; fixed damage category override
AgustinGDLV May 18, 2024
f3301df
fixed mega rayquaza test fail
AgustinGDLV May 18, 2024
d197aa7
consolidated gimmick indicator logic; added graphics to gGimmicksInfo
AgustinGDLV May 20, 2024
70a3c99
removed TeraData struct
AgustinGDLV May 20, 2024
dbfd0b1
reimplemented AI logic for Z-Moves; no changes
AgustinGDLV May 20, 2024
6555305
updated Z-Move and Ultra Burst trigger gfx
AgustinGDLV May 20, 2024
1be7250
added testrunner check for multiple gimmick use
AgustinGDLV May 20, 2024
ca58010
fixed duplicate z-move call in test
AgustinGDLV May 20, 2024
fd3235f
reorganized data/graphics/gimmicks.h
AgustinGDLV May 29, 2024
eef7281
added signature Z-Move ability tests; implemented Guardian of Alola
AgustinGDLV May 29, 2024
efc5e60
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV May 29, 2024
e795879
fixed bad test update
AgustinGDLV May 29, 2024
179d4ca
fixed Thousand Arrows not affecting Tera Flying; clean-up
AgustinGDLV May 30, 2024
145931d
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV Jun 5, 2024
e6f21c6
fixed -ate tests
AgustinGDLV Jun 6, 2024
544d054
fixed tera tests
AgustinGDLV Jun 6, 2024
3f3d56b
fixed tera tests really
AgustinGDLV Jun 6, 2024
abae734
fixed last batch of tests
AgustinGDLV Jun 7, 2024
4bf0fdd
fixed -ate mega test again
AgustinGDLV Jun 7, 2024
e23f2b0
code review
AgustinGDLV Jun 10, 2024
fe2bf5a
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV Jun 10, 2024
ea80bf6
code review pt.2
AgustinGDLV Jun 10, 2024
1eb2000
tweaked CanTera again
AgustinGDLV Jun 13, 2024
35f423d
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV Jun 15, 2024
d434657
dynamax flag only required for player
AgustinGDLV Jun 15, 2024
8501cc8
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
AgustinGDLV Jun 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/battle_controllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ enum {

// Special return values in gBattleBufferB from Battle Controller functions.
#define RET_VALUE_LEVELED_UP 11
#define RET_GIMMICK (1 << 7)
#define RET_GIMMICK (1 << 7)

struct UnusedControllerStruct
{
Expand Down
10 changes: 5 additions & 5 deletions include/battle_gimmick.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ enum Gimmick

struct GimmickInfo
{
const struct SpritePalette * triggerPal; // trigger gfx data
const struct SpriteSheet * triggerSheet;
const struct SpriteTemplate * triggerTemplate;
const struct SpritePalette * indicatorPal; // indicator gfx data
const struct SpriteSheet * indicatorSheet;
const struct SpritePalette *triggerPal; // trigger gfx data
const struct SpriteSheet *triggerSheet;
const struct SpriteTemplate *triggerTemplate;
const struct SpritePalette *indicatorPal; // indicator gfx data
const struct SpriteSheet *indicatorSheet;
bool32 (*CanActivate)(u32 battler);
void (*ActivateGimmick)(u32 battler);
};
Expand Down
46 changes: 23 additions & 23 deletions include/battle_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,34 @@ enum
#define TAG_MEGA_INDICATOR_TILE 0xD778
#define TAG_ALPHA_INDICATOR_TILE 0xD779
#define TAG_OMEGA_INDICATOR_TILE 0xD77A
#define TAG_DYNAMAX_INDICATOR_TILE 0xD77E

#define TAG_NORMAL_INDICATOR_TILE 0xD77F
#define TAG_FIGHTING_INDICATOR_TILE 0xD780
#define TAG_FLYING_INDICATOR_TILE 0xD781
#define TAG_POISON_INDICATOR_TILE 0xD782
#define TAG_GROUND_INDICATOR_TILE 0xD783
#define TAG_ROCK_INDICATOR_TILE 0xD784
#define TAG_BUG_INDICATOR_TILE 0xD785
#define TAG_GHOST_INDICATOR_TILE 0xD786
#define TAG_STEEL_INDICATOR_TILE 0xD787
#define TAG_DYNAMAX_INDICATOR_TILE 0xD77B

#define TAG_NORMAL_INDICATOR_TILE 0xD77C
#define TAG_FIGHTING_INDICATOR_TILE 0xD77D
#define TAG_FLYING_INDICATOR_TILE 0xD77E
#define TAG_POISON_INDICATOR_TILE 0xD77F
#define TAG_GROUND_INDICATOR_TILE 0xD780
#define TAG_ROCK_INDICATOR_TILE 0xD781
#define TAG_BUG_INDICATOR_TILE 0xD782
#define TAG_GHOST_INDICATOR_TILE 0xD783
#define TAG_STEEL_INDICATOR_TILE 0xD784
// empty spot for TYPE_MYSTERY
#define TAG_FIRE_INDICATOR_TILE 0xD789
#define TAG_WATER_INDICATOR_TILE 0xD78A
#define TAG_GRASS_INDICATOR_TILE 0xD78B
#define TAG_ELECTRIC_INDICATOR_TILE 0xD78C
#define TAG_PSYCHIC_INDICATOR_TILE 0xD78D
#define TAG_ICE_INDICATOR_TILE 0xD78E
#define TAG_DRAGON_INDICATOR_TILE 0xD78F
#define TAG_DARK_INDICATOR_TILE 0xD790
#define TAG_FAIRY_INDICATOR_TILE 0xD791
#define TAG_STELLAR_INDICATOR_TILE 0xD792
#define TAG_TERA_TRIGGER_TILE 0xD793
#define TAG_FIRE_INDICATOR_TILE 0xD786
#define TAG_WATER_INDICATOR_TILE 0xD787
#define TAG_GRASS_INDICATOR_TILE 0xD788
#define TAG_ELECTRIC_INDICATOR_TILE 0xD789
#define TAG_PSYCHIC_INDICATOR_TILE 0xD78A
#define TAG_ICE_INDICATOR_TILE 0xD78B
#define TAG_DRAGON_INDICATOR_TILE 0xD78C
#define TAG_DARK_INDICATOR_TILE 0xD78D
#define TAG_FAIRY_INDICATOR_TILE 0xD78E
#define TAG_STELLAR_INDICATOR_TILE 0xD78F
#define TAG_TERA_TRIGGER_TILE 0xD790

#define TAG_GIMMICK_TRIGGER_PAL 0xD777
#define TAG_MEGA_INDICATOR_PAL 0xD778
#define TAG_MISC_INDICATOR_PAL 0xD779 // Alpha, Omega, and Dynamax indicators use the same palette as each of them only uses 4 different colors.
#define TAG_TERA_INDICATOR_PAL 0xD77E
#define TAG_TERA_INDICATOR_PAL 0xD77A

enum
{
Expand Down
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// still has them in the ROM. This is because the developers forgot
// to define NDEBUG before release, however this has been changed as
// Ruby's actual debug build does not use the AGBPrint features.
// #define NDEBUG
#define NDEBUG

// To enable printf debugging, comment out "#define NDEBUG". This allows
// the various AGBPrint functions to be used. (See include/gba/isagbprint.h).
Expand Down
3 changes: 2 additions & 1 deletion include/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ struct TrainerMon
u8 nature:5;
bool8 gender:2;
bool8 isShiny:1;
u8 useGimmick:4;
u8 dynamaxLevel:4;
u8 teraType:5;
bool8 gigantamaxFactor:1;
u8 useGimmick:4;
u8 padding:2;
};

#define TRAINER_PARTY(partyArray) partyArray, .partySize = ARRAY_COUNT(partyArray)
Expand Down
11 changes: 6 additions & 5 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ s32 AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u8 *typeEffectivenes
*typeEffectiveness = AI_GetEffectiveness(effectivenessMultiplier);

// Undo temporary settings
gBattleStruct->aiCalcInProgress = FALSE;
gBattleStruct->swapDamageCategory = FALSE;
gBattleStruct->zmove.baseMoves[battlerAtk] = MOVE_NONE;
if (toggledGimmick)
Expand Down Expand Up @@ -3764,20 +3765,20 @@ bool32 ShouldUseZMove(u32 battlerAtk, u32 battlerDef, u32 chosenMove)
if (IsViableZMove(battlerAtk, chosenMove))
{
u8 effectiveness;
u32 zmove = GetUsableZMove(battlerAtk, chosenMove);
u32 zMove = GetUsableZMove(battlerAtk, chosenMove);

if (gBattleMons[battlerDef].ability == ABILITY_DISGUISE
&& !gMovesInfo[zmove].ignoresTargetAbility
&& !gMovesInfo[zMove].ignoresTargetAbility
&& (gBattleMons[battlerDef].species == SPECIES_MIMIKYU_DISGUISED || gBattleMons[battlerDef].species == SPECIES_MIMIKYU_TOTEM_DISGUISED))
return FALSE; // Don't waste a Z-Move busting disguise
if (gBattleMons[battlerDef].ability == ABILITY_ICE_FACE
&& !gMovesInfo[zmove].ignoresTargetAbility
&& !gMovesInfo[zMove].ignoresTargetAbility
&& gBattleMons[battlerDef].species == SPECIES_EISCUE_ICE_FACE && IS_MOVE_PHYSICAL(chosenMove))
return FALSE; // Don't waste a Z-Move busting Ice Face

if (IS_MOVE_STATUS(chosenMove) && !IS_MOVE_STATUS(zmove))
if (IS_MOVE_STATUS(chosenMove) && !IS_MOVE_STATUS(zMove))
return FALSE;
else if (!IS_MOVE_STATUS(chosenMove) && IS_MOVE_STATUS(zmove))
else if (!IS_MOVE_STATUS(chosenMove) && IS_MOVE_STATUS(zMove))
return FALSE;

if (!IS_MOVE_STATUS(chosenMove) && AI_CalcDamageSaveBattlers(chosenMove, battlerAtk, battlerDef, &effectiveness, FALSE, DMG_ROLL_DEFAULT) >= gBattleMons[battlerDef].hp)
Expand Down
6 changes: 2 additions & 4 deletions src/battle_controller_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,13 @@ static void OpponentHandleChooseMove(u32 battler)
}
// If opponent can and should use a gimmick (considering trainer data), do it
if (gBattleStruct->gimmick.usableGimmick[battler] != GIMMICK_NONE
&& !(gBattleStruct->gimmick.usableGimmick[battler] == GIMMICK_Z_MOVE
&& !ShouldUseZMove(battler, gBattlerTarget, moveInfo->moves[chosenMoveId])))
&& !(gBattleStruct->gimmick.usableGimmick[battler] == GIMMICK_Z_MOVE
&& !ShouldUseZMove(battler, gBattlerTarget, moveInfo->moves[chosenMoveId])))
{
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_GIMMICK) | (gBattlerTarget << 8));
}
else
{
AgustinGDLV marked this conversation as resolved.
Show resolved Hide resolved
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
}
}
break;
}
Expand Down
3 changes: 1 addition & 2 deletions src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,14 +780,13 @@ static void HandleInputChooseMove(u32 battler)
else if ((JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) && !sDescriptionSubmenu)
{
PlaySE(SE_SELECT);
gBattleStruct->gimmick.playerSelect = FALSE;
if (gBattleStruct->zmove.viewing)
{
gBattleStruct->gimmick.playerSelect = FALSE;
ReloadMoveNames(battler);
}
else
{
gBattleStruct->gimmick.playerSelect = FALSE;
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0xFFFF);
HideGimmickTriggerSprite();
PlayerBufferExecCompleted(battler);
Expand Down
6 changes: 2 additions & 4 deletions src/battle_controller_player_partner.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,13 @@ static void PlayerPartnerHandleChooseMove(u32 battler)
}
// If partner can and should use a gimmick (considering trainer data), do it
if (gBattleStruct->gimmick.usableGimmick[battler] != GIMMICK_NONE
&& !(gBattleStruct->gimmick.usableGimmick[battler] == GIMMICK_Z_MOVE
&& !ShouldUseZMove(battler, gBattlerTarget, moveInfo->moves[chosenMoveId])))
&& !(gBattleStruct->gimmick.usableGimmick[battler] == GIMMICK_Z_MOVE
&& !ShouldUseZMove(battler, gBattlerTarget, moveInfo->moves[chosenMoveId])))
{
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_GIMMICK) | (gBattlerTarget << 8));
}
else
{
AgustinGDLV marked this conversation as resolved.
Show resolved Hide resolved
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
}
}

PlayerPartnerBufferExecCompleted(battler);
Expand Down
9 changes: 5 additions & 4 deletions src/battle_dynamax.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ bool32 CanDynamax(u32 battler)
u16 holdEffect = GetBattlerHoldEffect(battler, FALSE);

// Check if Dynamax battle flag is set. This needs to be defined in include/config/battle.h
if ((B_FLAG_DYNAMAX_BATTLE == 0 || (B_FLAG_DYNAMAX_BATTLE != 0 && !FlagGet(B_FLAG_DYNAMAX_BATTLE))) && !TESTING)
if (!TESTING && (B_FLAG_DYNAMAX_BATTLE == 0 || (B_FLAG_DYNAMAX_BATTLE != 0 && !FlagGet(B_FLAG_DYNAMAX_BATTLE))))
return FALSE;

// Check if Player has a Dynamax Band.
if ((GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT))
&& !CheckBagHasItem(ITEM_DYNAMAX_BAND, 1) && !TESTING)
if (!TESTING && (GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT
|| (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT))
&& !CheckBagHasItem(ITEM_DYNAMAX_BAND, 1))
return FALSE;

// Check if species isn't allowed to Dynamax.
Expand All @@ -104,7 +105,7 @@ bool32 CanDynamax(u32 battler)
return FALSE;

// Check if battler is holding a Z-Crystal or Mega Stone.
if ((holdEffect == HOLD_EFFECT_Z_CRYSTAL || holdEffect == HOLD_EFFECT_MEGA_STONE) && !TESTING)
if (!TESTING && (holdEffect == HOLD_EFFECT_Z_CRYSTAL || holdEffect == HOLD_EFFECT_MEGA_STONE)) // tests make this check already
return FALSE;

// TODO: Cannot Dynamax in a Max Raid if you don't have Dynamax Energy.
Expand Down
31 changes: 8 additions & 23 deletions src/battle_gimmick.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool32 ShouldTrainerBattlerUseGimmick(u32 battler, enum Gimmick gimmick)
}
// The player can bypass these checks because they can choose through the controller.
else if (GetBattlerSide(battler) == B_SIDE_PLAYER
&& !((gBattleTypeFlags & BATTLE_TYPE_MULTI) && battler == B_POSITION_PLAYER_RIGHT))
&& !((gBattleTypeFlags & BATTLE_TYPE_MULTI) && battler == B_POSITION_PLAYER_RIGHT))
{
return TRUE;
}
Expand Down Expand Up @@ -100,9 +100,7 @@ bool32 HasTrainerUsedGimmick(u32 battler, enum Gimmick gimmick)
}
// Otherwise, return whether current battler has used gimmick.
else
{
AgustinGDLV marked this conversation as resolved.
Show resolved Hide resolved
return gBattleStruct->gimmick.activated[battler][gimmick];
}
}

// Sets a gimmick as used by a trainer with checks for Multi Battles.
Expand Down Expand Up @@ -137,28 +135,26 @@ void CreateGimmickTriggerSprite(u32 battler)

// Exit if there shouldn't be a sprite produced.
if (GetBattlerSide(battler) == B_SIDE_OPPONENT
|| gBattleStruct->gimmick.usableGimmick[battler] == GIMMICK_NONE
|| gimmick->triggerSheet == NULL)
|| gBattleStruct->gimmick.usableGimmick[battler] == GIMMICK_NONE
|| gimmick->triggerSheet == NULL)
{
return;
}

LoadSpritePalette(gimmick->triggerPal);
if (GetSpriteTileStartByTag(TAG_GIMMICK_TRIGGER_TILE) == 0xFFFF)
{
LoadSpriteSheet(gimmick->triggerSheet);
}

if (gBattleStruct->gimmick.triggerSpriteId == 0xFF)
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
gBattleStruct->gimmick.triggerSpriteId = CreateSprite(gimmick->triggerTemplate,
gSprites[gHealthboxSpriteIds[battler]].x - DOUBLES_GIMMICK_TRIGGER_POS_X_SLIDE,
gSprites[gHealthboxSpriteIds[battler]].y - DOUBLES_GIMMICK_TRIGGER_POS_Y_DIFF, 0);
gSprites[gHealthboxSpriteIds[battler]].x - DOUBLES_GIMMICK_TRIGGER_POS_X_SLIDE,
gSprites[gHealthboxSpriteIds[battler]].y - DOUBLES_GIMMICK_TRIGGER_POS_Y_DIFF, 0);
else
gBattleStruct->gimmick.triggerSpriteId = CreateSprite(gimmick->triggerTemplate,
gSprites[gHealthboxSpriteIds[battler]].x - SINGLES_GIMMICK_TRIGGER_POS_X_SLIDE,
gSprites[gHealthboxSpriteIds[battler]].y - SINGLES_GIMMICK_TRIGGER_POS_Y_DIFF, 0);
gSprites[gHealthboxSpriteIds[battler]].x - SINGLES_GIMMICK_TRIGGER_POS_X_SLIDE,
gSprites[gHealthboxSpriteIds[battler]].y - SINGLES_GIMMICK_TRIGGER_POS_Y_DIFF, 0);
}

gSprites[gBattleStruct->gimmick.triggerSpriteId].tBattler = battler;
Expand Down Expand Up @@ -263,17 +259,12 @@ void LoadIndicatorSpritesGfx(void)
for (gimmick = 0; gimmick < GIMMICKS_COUNT; ++gimmick)
{
if (gimmick == GIMMICK_TERA) // special case
{
LoadSpriteSheets(sTeraIndicatorSpriteSheets);
}
else if (gGimmicksInfo[gimmick].indicatorSheet != NULL)
{
LoadSpriteSheet(gGimmicksInfo[gimmick].indicatorSheet);
}

if (gGimmicksInfo[gimmick].indicatorPal != NULL)
{
LoadSpritePalette(gGimmicksInfo[gimmick].indicatorPal);
}
}
// Primal reversion graphics aren't loaded as part of gimmick data
LoadSpriteSheet(&sSpriteSheet_AlphaIndicator);
Expand Down Expand Up @@ -323,17 +314,11 @@ u32 GetIndicatorPalTag(u32 battler)
{
u32 gimmick = GetActiveGimmick(battler);
if (IsBattlerPrimalReverted(battler))
{
return TAG_MISC_INDICATOR_PAL;
}
else if (gGimmicksInfo[gimmick].indicatorPal != NULL)
{
return gGimmicksInfo[gimmick].indicatorPal->tag;
}
else
{
return TAG_NONE;
}
}

void UpdateIndicatorVisibilityAndType(u32 healthboxId, bool32 invisible)
Expand Down
4 changes: 2 additions & 2 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5784,8 +5784,8 @@ void SetTypeBeforeUsingMove(u32 move, u32 battlerAtk)

attackerAbility = GetBattlerAbility(battlerAtk);
if (gMovesInfo[move].type == TYPE_NORMAL
&& TrySetAteType(move, battlerAtk, attackerAbility)
&& GetActiveGimmick(battlerAtk) != GIMMICK_DYNAMAX)
&& TrySetAteType(move, battlerAtk, attackerAbility)
&& GetActiveGimmick(battlerAtk) != GIMMICK_DYNAMAX)
{
gBattleStruct->ateBoost[battlerAtk] = 1;
}
Expand Down
6 changes: 4 additions & 2 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,8 @@ static void Cmd_attackcanceler(void)
}

// Z-moves and Max Moves bypass protection, but deal reduced damage (factored in AccumulateOtherModifiers)
if ((IsZMove(gCurrentMove) || IsMaxMove(gCurrentMove))
if ((IsZMove(gCurrentMove)
|| IsMaxMove(gCurrentMove))
&& IS_BATTLER_PROTECTED(gBattlerTarget))
{
BattleScriptPush(cmd->nextInstr);
Expand Down Expand Up @@ -9825,7 +9826,8 @@ static void Cmd_various(void)
|| gMovesInfo[move].instructBanned
|| gBattleMoveEffects[gMovesInfo[move].effect].twoTurnEffect
|| (GetActiveGimmick(gBattlerTarget) == GIMMICK_DYNAMAX)
|| IsZMove(move) || IsMaxMove(move))
|| IsZMove(move)
|| IsMaxMove(move))
{
gBattlescriptCurrInstr = cmd->failInstr;
}
Expand Down
15 changes: 8 additions & 7 deletions src/battle_terastal.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ bool32 CanTerastallize(u32 battler)
u32 holdEffect = GetBattlerHoldEffect(battler, FALSE);

// Check if Player has Tera Orb and has charge.
if ((!CheckBagHasItem(ITEM_TERA_ORB, 1)
|| !((B_FLAG_TERA_ORB_NO_COST != 0 && FlagGet(B_FLAG_TERA_ORB_NO_COST))
|| (B_FLAG_TERA_ORB_CHARGED != 0 && FlagGet(B_FLAG_TERA_ORB_CHARGED)
&& ((battler == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && battler == B_POSITION_PLAYER_RIGHT))))))
&& !TESTING)
if (!TESTING && !(B_FLAG_TERA_ORB_NO_COST != 0 && FlagGet(B_FLAG_TERA_ORB_NO_COST))
&& (battler == B_POSITION_PLAYER_LEFT
|| (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && battler == B_POSITION_PLAYER_RIGHT)))
{
return FALSE;
if (!CheckBagHasItem(ITEM_TERA_ORB, 1))
return FALSE;
if (B_FLAG_TERA_ORB_CHARGED != 0 && !FlagGet(B_FLAG_TERA_ORB_CHARGED))
return FALSE;
AgustinGDLV marked this conversation as resolved.
Show resolved Hide resolved
}

// Check if Trainer has already Terastallized.
Expand All @@ -86,7 +87,7 @@ bool32 CanTerastallize(u32 battler)
return FALSE;

// Check if battler is holding a Z-Crystal or Mega Stone.
if ((holdEffect == HOLD_EFFECT_Z_CRYSTAL || holdEffect == HOLD_EFFECT_MEGA_STONE) && !TESTING)
if (!TESTING && (holdEffect == HOLD_EFFECT_Z_CRYSTAL || holdEffect == HOLD_EFFECT_MEGA_STONE)) // tests make this check already
return FALSE;

// Every check passed!
Expand Down
Loading
Loading