From 32e63d8cc7bae997c2dc520a27a17ee18984b285 Mon Sep 17 00:00:00 2001 From: Ultimate_Bob Date: Mon, 1 May 2023 11:15:03 +1000 Subject: [PATCH] Don't copy opponent personality when swapping mon sprite during Mega Evolution (#2852) Co-authored-by: Eduardo Quezada D'Ottone --- data/battle_anim_scripts.s | 14 +++++----- include/battle.h | 2 ++ include/battle_gfx_sfx_util.h | 2 +- include/config/battle.h | 1 + src/battle_anim_effects_3.c | 4 ++- src/battle_controller_link_opponent.c | 1 + src/battle_controller_link_partner.c | 1 + src/battle_controller_opponent.c | 1 + src/battle_controller_player.c | 1 + src/battle_controller_player_partner.c | 1 + src/battle_controller_recorded_opponent.c | 1 + src/battle_controller_recorded_player.c | 1 + src/battle_controller_wally.c | 1 + src/battle_gfx_sfx_util.c | 34 +++++++++++++++++++---- src/battle_main.c | 1 + src/battle_script_commands.c | 1 + 16 files changed, 53 insertions(+), 14 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index adcb88c88..dcfdac88e 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/include/battle.h b/include/battle.h index 4ba3cba6e..35c3525b8 100644 --- a/include/battle.h +++ b/include/battle.h @@ -62,6 +62,7 @@ struct ResourceFlags struct DisableStruct { u32 transformedMonPersonality; + u32 transformedMonOtId; u16 disabledMove; u16 encoredMove; u8 protectUses; @@ -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; diff --git a/include/battle_gfx_sfx_util.h b/include/battle_gfx_sfx_util.h index 491d5fefd..9a0b79c31 100644 --- a/include/battle_gfx_sfx_util.h +++ b/include/battle_gfx_sfx_util.h @@ -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); diff --git a/include/config/battle.h b/include/config/battle.h index 4b3caf4ab..4861d046c 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -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 diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index ff5f04446..7d449c767 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -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: @@ -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()) diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 908363907..b4936da5c 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -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); diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 1ef5d6355..d07a92e93 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -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); diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 4eda81b09..c3e4a9037 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -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; } diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 106599416..b9eb566c0 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -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); diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 4c54b68aa..b94d5347a 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -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; } diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index e7fc6fd84..ea9882054 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -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; } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 87f575839..8957b285a 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -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; } diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index ae20c54ec..fa1fa00fb 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -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; } diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index bc541f0a0..d926494a8 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -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) @@ -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) { @@ -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); @@ -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, @@ -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], diff --git a/src/battle_main.c b/src/battle_main.c index e59653f31..91d5c3aa5 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -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; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index aead0fe3c..cdc8cfa90 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -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;