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

Add FORM_CHANGE_BATTLE_TERASTALLIZATION + allow species to force tera types #4438

Merged
merged 19 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
18 changes: 9 additions & 9 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,7 @@ static void Cmd_adjustdamage(void)
gLastUsedItem = gBattleMons[gBattlerTarget].item;
gSpecialStatuses[gBattlerTarget].focusBanded = FALSE;
gSpecialStatuses[gBattlerTarget].focusSashed = FALSE;

}
else if (gSpecialStatuses[gBattlerTarget].sturdied)
{
Expand Down Expand Up @@ -3172,8 +3172,8 @@ void SetMoveEffect(bool32 primary, bool32 certain)
{
gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[gBattleScripting.moveEffect];
gBattlescriptCurrInstr++;
}
else
}
else
{
gBattlescriptCurrInstr++;
}
Expand Down Expand Up @@ -6243,7 +6243,7 @@ static void Cmd_moveend(void)
break;
}
}

if (!(gBattleStruct->lastMoveFailed & gBitTable[gBattlerAttacker]
|| (!gSpecialStatuses[gBattlerAttacker].dancerUsedMove
&& gBattleStruct->bouncedMoveIsUsed)))
Expand Down Expand Up @@ -6341,9 +6341,9 @@ static void Cmd_moveend(void)
&& (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) // And it is unusable
&& (gBattleMons[gBattlerAttacker].status2 & STATUS2_LOCK_CONFUSE) != STATUS2_LOCK_CONFUSE_TURN(1)) // And won't end this turn
CancelMultiTurnMoves(gBattlerAttacker); // Cancel it



if (gBattleStruct->savedAttackerCount > 0)
{
// #if TESTING
Expand Down Expand Up @@ -16845,8 +16845,8 @@ void BS_AllySwitchFailChance(void)
void BS_SetPhotonGeyserCategory(void)
{
NATIVE_ARGS();
if (!(gMovesInfo[gCurrentMove].effect == EFFECT_TERA_BLAST && !IsTerastallized(gBattlerAttacker))
&& !(gMovesInfo[gCurrentMove].effect == EFFECT_TERA_STARSTORM && gBattleMons[gBattlerAttacker].species != SPECIES_TERAPAGOS_STELLAR))
if (!((gMovesInfo[gCurrentMove].effect == EFFECT_TERA_BLAST && !IsTerastallized(gBattlerAttacker))
|| (gMovesInfo[gCurrentMove].effect == EFFECT_TERA_STARSTORM && !(IsTerastallized(gBattlerAttacker) && gBattleMons[gBattlerAttacker].species == SPECIES_TERAPAGOS_STELLAR))))
gBattleStruct->swapDamageCategory = (GetCategoryBasedOnStats(gBattlerAttacker) == DAMAGE_CATEGORY_PHYSICAL);
gBattlescriptCurrInstr = cmd->nextInstr;
}
Expand Down
6 changes: 5 additions & 1 deletion src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2774,14 +2774,18 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)
break;
case MON_DATA_TERA_TYPE:
if (gSpeciesInfo[substruct0->species].forceTeraType)
{
retVal = gSpeciesInfo[substruct0->species].forceTeraType;
else if (substruct0->teraType == 0) // Tera Type hasn't been modified so we can just use the personality
}
else if (substruct0->teraType == TYPE_NONE) // Tera Type hasn't been modified so we can just use the personality
{
const u8 *types = gSpeciesInfo[substruct0->species].types;
retVal = (boxMon->personality & 0x1) == 0 ? types[0] : types[1];
}
else
{
retVal = substruct0->teraType;
}
break;
case MON_DATA_EVOLUTION_TRACKER:
evoTracker.asField.a = substruct1->evolutionTracker1;
Expand Down
21 changes: 20 additions & 1 deletion test/battle/gimmick/terastal.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ SINGLE_BATTLE_TEST("(TERA) Protean cannot change the type of a Terastallized Pok
PLAYER(SPECIES_GRENINJA) { Ability(ABILITY_PROTEAN); TeraType(TYPE_GRASS); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_BUBBLE, tera: TRUE);
TURN { MOVE(player, MOVE_BUBBLE, tera: TRUE);
MOVE(opponent, MOVE_EMBER); }
} SCENE {
MESSAGE("Greninja used Bubble!");
Expand Down Expand Up @@ -793,3 +793,22 @@ SINGLE_BATTLE_TEST("(TERA) All type indicators function correctly")
TURN { MOVE(player, MOVE_CELEBRATE, tera: TRUE); }
}
}

SINGLE_BATTLE_TEST("(TERA) Pokemon with Tera forms change upon Terastallizing")
{
u32 species1;
u32 species2;
PARAMETRIZE { species1 = SPECIES_OGERPON_TEAL_MASK; species2 = SPECIES_OGERPON_TEAL_MASK_TERA; }
PARAMETRIZE { species1 = SPECIES_OGERPON_WELLSPRING_MASK; species2 = SPECIES_OGERPON_WELLSPRING_MASK_TERA; }
PARAMETRIZE { species1 = SPECIES_OGERPON_HEARTHFLAME_MASK; species2 = SPECIES_OGERPON_HEARTHFLAME_MASK_TERA; }
PARAMETRIZE { species1 = SPECIES_OGERPON_CORNERSTONE_MASK; species2 = SPECIES_OGERPON_CORNERSTONE_MASK_TERA; }
PARAMETRIZE { species1 = SPECIES_TERAPAGOS_TERASTAL; species2 = SPECIES_TERAPAGOS_STELLAR; }
GIVEN {
PLAYER(species1);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_CELEBRATE, tera: TRUE); }
} THEN {
EXPECT_EQ(player->species, species2);
}
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
}
61 changes: 61 additions & 0 deletions test/battle/move_effect/tera_starstorm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gMovesInfo[MOVE_TERA_STARSTORM].effect == EFFECT_TERA_STARSTORM);
}

SINGLE_BATTLE_TEST("Tera Starstorm changes from Normal-type to Stellar-type if used by Terapagos-Stellar")
{
GIVEN {
ASSUME(gMovesInfo[MOVE_TERA_STARSTORM].type == TYPE_NORMAL);
PLAYER(SPECIES_TERAPAGOS_STELLAR);
OPPONENT(SPECIES_MISDREAVUS);
} WHEN {
TURN { MOVE(player, MOVE_TERA_STARSTORM); }
} SCENE {
MESSAGE("Terapagos used Tera Starstorm!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TERA_STARSTORM, player);
HP_BAR(opponent);
NOT { MESSAGE("It doesn't affect Foe Misdreavus…"); }
}
}

DOUBLE_BATTLE_TEST("Tera Starstorm targets both opponents in a double battle if used by Terapagos-Stellar")
{
GIVEN {
ASSUME(gMovesInfo[MOVE_TERA_STARSTORM].target == MOVE_TARGET_SELECTED);
PLAYER(SPECIES_TERAPAGOS_STELLAR);
PLAYER(SPECIES_WYNAUT);
OPPONENT(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WYNAUT);
} WHEN {
TURN { MOVE(playerLeft, MOVE_TERA_STARSTORM, target:opponentLeft); }
} SCENE {
MESSAGE("Terapagos used Tera Starstorm!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TERA_STARSTORM, playerLeft);
HP_BAR(opponentLeft);
HP_BAR(opponentRight);
}
}

SINGLE_BATTLE_TEST("Tera Starstorm becomes a physical move if the user is Terapagos-Stellar, is Terastallized, and has a higher Attack stat", s16 damage)
{
bool32 tera;
PARAMETRIZE { tera = FALSE; }
PARAMETRIZE { tera = TRUE; }
GIVEN {
ASSUME(gMovesInfo[MOVE_TERA_STARSTORM].category == DAMAGE_CATEGORY_SPECIAL);
PLAYER(SPECIES_TERAPAGOS_STELLAR) { Attack(100); SpAttack(50); }
OPPONENT(SPECIES_WOBBUFFET) { Defense(200); SpDefense(200); }
} WHEN {
TURN { MOVE(player, MOVE_TERA_STARSTORM, tera: tera); }
} SCENE {
MESSAGE("Terapagos used Tera Starstorm!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TERA_STARSTORM, player);
HP_BAR(opponent, captureDamage: &results[i].damage);
} FINALLY {
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(2.5), results[1].damage);
}
}
Loading