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

Dont copy opponent personality when swapping mon sprite during Mega Evolution #2852

Merged
14 changes: 7 additions & 7 deletions data/battle_anim_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -22317,7 +22317,7 @@ Move_TRANSFORM:
monbg ANIM_ATTACKER
playsewithpan SE_M_TELEPORT, SOUND_PAN_ATTACKER
waitplaysewithpan SE_M_MINIMIZE, SOUND_PAN_ATTACKER, 48
createvisualtask AnimTask_TransformMon, 2, 0, 0
createvisualtask AnimTask_TransformMon, 2, 0, 0, 1
waitforvisualfinish
clearmonbg ANIM_ATTACKER
end
Expand Down Expand Up @@ -24406,7 +24406,7 @@ WeatherFormChangeContinue:
monbg ANIM_ATTACKER
playsewithpan SE_M_TELEPORT, SOUND_PAN_ATTACKER
waitplaysewithpan SE_M_MINIMIZE, SOUND_PAN_ATTACKER, 48
createvisualtask AnimTask_TransformMon, 2, 1, 0
createvisualtask AnimTask_TransformMon, 2, 1, 0, 0
waitforvisualfinish
clearmonbg ANIM_ATTACKER
end
Expand Down Expand Up @@ -24829,14 +24829,14 @@ General_WishHeal:

General_IllusionOff:
monbg ANIM_TARGET
createvisualtask AnimTask_TransformMon, 2, 0, 1
createvisualtask AnimTask_TransformMon, 2, 0, 1, 0
waitforvisualfinish
clearmonbg ANIM_TARGET
end

General_FormChange:
monbg ANIM_ATTACKER
createvisualtask AnimTask_TransformMon, 2, 0, 1
createvisualtask AnimTask_TransformMon, 2, 0, 1, 0
waitforvisualfinish
clearmonbg ANIM_ATTACKER
end
Expand Down Expand Up @@ -24865,7 +24865,7 @@ General_MegaEvolution:
delay 20
createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 0, 16, RGB_WHITEALPHA
waitforvisualfinish
createvisualtask AnimTask_TransformMon, 2, 0, 1
createvisualtask AnimTask_TransformMon, 2, 0, 1, 0
createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 16, 0, RGB_WHITEALPHA
createvisualtask AnimTask_HorizontalShake, 5, 1, 5, 14
waitforvisualfinish
Expand Down Expand Up @@ -25011,7 +25011,7 @@ General_PrimalReversion_Alpha:
delay 20
createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 0, 16, RGB_WHITEALPHA
waitforvisualfinish
createvisualtask AnimTask_TransformMon, 2, 0, 1
createvisualtask AnimTask_TransformMon, 2, 0, 1, 0
createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 16, 0, RGB_WHITEALPHA
createvisualtask AnimTask_HorizontalShake, 5, 1, 5, 14
waitforvisualfinish
Expand All @@ -25038,7 +25038,7 @@ General_PrimalReversion_Omega:
delay 20
createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 0, 16, RGB_WHITEALPHA
waitforvisualfinish
createvisualtask AnimTask_TransformMon, 2, 0, 1
createvisualtask AnimTask_TransformMon, 2, 0, 1, 0
createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 16, 0, RGB_WHITEALPHA
createvisualtask AnimTask_HorizontalShake, 5, 1, 5, 14
waitforvisualfinish
Expand Down
2 changes: 2 additions & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct ResourceFlags
struct DisableStruct
{
u32 transformedMonPersonality;
u32 transformedMonOtId;
u16 disabledMove;
u16 encoredMove;
u8 protectUses;
Expand Down Expand Up @@ -976,6 +977,7 @@ extern u8 gBattlerStatusSummaryTaskId[MAX_BATTLERS_COUNT];
extern u8 gBattlerInMenuId;
extern bool8 gDoingBattleAnim;
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern u32 gTransformedOtIds[MAX_BATTLERS_COUNT];
extern u8 gPlayerDpadHoldFrames;
extern struct BattleSpriteData *gBattleSpritesDataPtr;
extern struct MonSpritesGfx *gMonSpritesGfxPtr;
Expand Down
2 changes: 1 addition & 1 deletion include/battle_gfx_sfx_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId);
void ClearSpritesHealthboxAnimData(void);
void CopyAllBattleSpritesInvisibilities(void);
void CopyBattleSpriteInvisibility(u8 battlerId);
void HandleSpeciesGfxDataChange(u8 attacker, u8 target, bool8 notTransform, bool32 megaEvo, bool8 trackEnemyPersonality);
void HandleSpeciesGfxDataChange(u8 attacker, u8 target, bool8 castform, bool32 megaEvo, bool8 trackEnemyPersonality);
void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite);
void LoadBattleMonGfxAndAnimate(u8 battlerId, bool8 loadMonSprite, u8 spriteId);
void TrySetBehindSubstituteSpriteBit(u8 battlerId, u16 move);
Expand Down
1 change: 1 addition & 0 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
// Additionally, in gen8+ the Healing Wish's effect will be stored until the user switches into a statused or hurt mon.
#define B_DEFOG_CLEARS_TERRAIN GEN_LATEST // In Gen8+, Defog also clears active Terrain.
#define B_STOCKPILE_RAISES_DEFS GEN_LATEST // In Gen4+, Stockpile also raises Defense and Sp. Defense stats. Once Spit Up / Swallow is used, these stat changes are lost.
#define B_TRANSFORM_SHINY GEN_LATEST // In Gen4+, Transform will copy the shiny state of the opponent instead of maintaining its own shiny state.
#define B_TRANSFORM_FORM_CHANGES GEN_LATEST // In Gen5+, Transformed Pokemon cannot change forms.

// Ability settings
Expand Down
4 changes: 3 additions & 1 deletion src/battle_anim_effects_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,8 @@ void AnimTask_TransformMon(u8 taskId)
SetAnimBgAttribute(2, BG_ANIM_MOSAIC, 1);

gTasks[taskId].data[10] = gBattleAnimArgs[0];
gTasks[taskId].data[11] = gBattleAnimArgs[1];
gTasks[taskId].data[12] = gBattleAnimArgs[2];
gTasks[taskId].data[0]++;
break;
case 1:
Expand All @@ -2364,7 +2366,7 @@ void AnimTask_TransformMon(u8 taskId)
}
break;
case 2:
HandleSpeciesGfxDataChange(gBattleAnimAttacker, gBattleAnimTarget, gTasks[taskId].data[10], gBattleAnimArgs[1], TRUE);
HandleSpeciesGfxDataChange(gBattleAnimAttacker, gBattleAnimTarget, gTasks[taskId].data[10], gTasks[taskId].data[11], gTasks[taskId].data[12]);
GetBgDataForTransform(&animBg, gBattleAnimAttacker);

if (IsContest())
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_link_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ static void LinkOpponentHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = LinkOpponentDoMoveAnimation;
BattleTv_SetDataBasedOnMove(move, gWeatherMoveAnim, gAnimDisableStructPtr);
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_link_partner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ static void LinkPartnerHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = LinkPartnerDoMoveAnimation;
BattleTv_SetDataBasedOnMove(move, gWeatherMoveAnim, gAnimDisableStructPtr);
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ static void OpponentHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = OpponentDoMoveAnimation;
}
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -2709,6 +2709,7 @@ static void PlayerHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = PlayerDoMoveAnimation;
BattleTv_SetDataBasedOnMove(move, gWeatherMoveAnim, gAnimDisableStructPtr);
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_player_partner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ static void PlayerPartnerHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerDoMoveAnimation;
}
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_recorded_opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,7 @@ static void RecordedOpponentHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentDoMoveAnimation;
}
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_recorded_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ static void RecordedPlayerHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerDoMoveAnimation;
}
Expand Down
1 change: 1 addition & 0 deletions src/battle_controller_wally.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ static void WallyHandleMoveAnimation(void)
gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8);
gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16];
gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality;
gTransformedOtIds[gActiveBattler] = gAnimDisableStructPtr->transformedMonOtId;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerControllerFuncs[gActiveBattler] = WallyDoMoveAnimation;
}
Expand Down
34 changes: 29 additions & 5 deletions src/battle_gfx_sfx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ bool8 IsBattleSEPlaying(u8 battlerId)

static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 opponent)
{
u32 monsPersonality, currentPersonality, otId, species, paletteOffset, position;
u32 monsPersonality, currentPersonality, otId, currentOtId, species, paletteOffset, position;
const void *lzPaletteData;
struct Pokemon *illusionMon = GetIllusionMonPtr(battlerId);
if (illusionMon != NULL)
Expand All @@ -561,18 +561,26 @@ static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 op
return;

monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
otId = GetMonData(mon, MON_DATA_OT_ID);

if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
{
species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality;
currentOtId = otId;
}
else
{
species = gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies;
currentPersonality = gTransformedPersonalities[battlerId];
#if B_TRANSFORM_SHINY >= GEN_4
currentPersonality = gTransformedPersonalities[battlerId];
currentOtId = gTransformedOtIds[battlerId];
#else
currentPersonality = monsPersonality;
currentOtId = otId;
#endif
}

otId = GetMonData(mon, MON_DATA_OT_ID);
position = GetBattlerPosition(battlerId);
if (opponent)
{
Expand All @@ -592,7 +600,7 @@ static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 op
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon);
else
lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(species, currentOtId, currentPersonality);

LZDecompressWram(lzPaletteData, gDecompressionBuffer);
LoadPalette(gDecompressionBuffer, paletteOffset, PLTT_SIZE_4BPP);
Expand Down Expand Up @@ -880,10 +888,18 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo

if (GetBattlerSide(battlerAtk) == B_SIDE_PLAYER)
{
#if B_TRANSFORM_SHINY >= GEN_4
if (trackEnemyPersonality)
{
personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
}
else
#endif
{
personalityValue = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
}
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);

HandleLoadSpecialPokePic(FALSE,
Expand All @@ -893,11 +909,19 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo
}
else
{
#if B_TRANSFORM_SHINY >= GEN_4
if (trackEnemyPersonality)
{
personalityValue = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);

}
else
#endif
{
personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
}

HandleLoadSpecialPokePic(TRUE,
gMonSpritesGfxPtr->sprites.ptr[position],
Expand Down
1 change: 1 addition & 0 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ EWRAM_DATA u8 gBattlerStatusSummaryTaskId[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gBattlerInMenuId = 0;
EWRAM_DATA bool8 gDoingBattleAnim = FALSE;
EWRAM_DATA u32 gTransformedPersonalities[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u32 gTransformedOtIds[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gPlayerDpadHoldFrames = 0;
EWRAM_DATA struct BattleSpriteData *gBattleSpritesDataPtr = NULL;
EWRAM_DATA struct MonSpritesGfx *gMonSpritesGfxPtr = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -12881,6 +12881,7 @@ static void Cmd_transformdataexecution(void)
gDisableStructs[gBattlerAttacker].disabledMove = MOVE_NONE;
gDisableStructs[gBattlerAttacker].disableTimer = 0;
gDisableStructs[gBattlerAttacker].transformedMonPersonality = gBattleMons[gBattlerTarget].personality;
gDisableStructs[gBattlerAttacker].transformedMonOtId = gBattleMons[gBattlerTarget].otId;
gDisableStructs[gBattlerAttacker].mimickedMoves = 0;
gDisableStructs[gBattlerAttacker].usedMoves = 0;

Expand Down