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

Fixed multiple transform/form change graphical issues #6005

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,10 @@
.byte \battler
.endm

.macro switchinanim battler:req, dontClearSubstitute:req
.macro switchinanim battler:req, dontClearTransform:req, dontClearSubstitute:req
.byte 0x4e
.byte \battler
.byte \dontClearTransform
.byte \dontClearSubstitute
.endm

Expand Down
24 changes: 12 additions & 12 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ BattleScript_MoveSwitchOpenPartyScreen:
printstring STRINGID_EMPTYSTRING3
waitmessage 1
printstring STRINGID_SWITCHINMON
switchinanim BS_ATTACKER, TRUE
switchinanim BS_ATTACKER, FALSE, TRUE
waitstate
switchineffects BS_ATTACKER
BattleScript_MoveSwitchEnd:
Expand Down Expand Up @@ -469,7 +469,7 @@ BattleScript_EffectRevivalBlessingSendOut:
getswitchedmondata BS_SCRIPTING
switchindataupdate BS_SCRIPTING
hpthresholds BS_SCRIPTING
switchinanim BS_SCRIPTING, FALSE
switchinanim BS_SCRIPTING, FALSE, FALSE
waitstate
switchineffects BS_SCRIPTING
goto BattleScript_MoveEnd
Expand Down Expand Up @@ -2390,7 +2390,7 @@ BattleScript_EffectHealingWish::
trytoclearprimalweather
flushtextbox
printstring STRINGID_SWITCHINMON
switchinanim BS_ATTACKER, TRUE
switchinanim BS_ATTACKER, FALSE, TRUE
waitstate
switchineffects BS_ATTACKER
.endif
Expand Down Expand Up @@ -4386,7 +4386,7 @@ BattleScript_EffectBatonPass::
trytoclearprimalweather
flushtextbox
printstring STRINGID_SWITCHINMON
switchinanim BS_ATTACKER, TRUE
switchinanim BS_ATTACKER, FALSE, TRUE
waitstate
switchineffects BS_ATTACKER
goto BattleScript_MoveEnd
Expand Down Expand Up @@ -5492,7 +5492,7 @@ BattleScript_FaintedMonTryChoose:
flushtextbox
printstring STRINGID_SWITCHINMON
hidepartystatussummary BS_ATTACKER
switchinanim BS_ATTACKER, 0
switchinanim BS_ATTACKER, FALSE, FALSE
waitstate
setbyte sSHIFT_SWITCHED, 1
BattleScript_FaintedMonSendOutNew:
Expand All @@ -5504,7 +5504,7 @@ BattleScript_FaintedMonSendOutNew:
flushtextbox
printstring STRINGID_SWITCHINMON
hidepartystatussummary BS_FAINTED
switchinanim BS_FAINTED, FALSE
switchinanim BS_FAINTED, FALSE, FALSE
waitstate
resetplayerfainted
trytrainerslidelastonmsg BS_FAINTED
Expand Down Expand Up @@ -5538,7 +5538,7 @@ BattleScript_HandleFaintedMonLoop::
flushtextbox
printstring STRINGID_SWITCHINMON
hidepartystatussummary BS_FAINTED
switchinanim BS_FAINTED, FALSE
switchinanim BS_FAINTED, FALSE, FALSE
waitstate
switchineffects BS_FAINTED_MULTIPLE_1
jumpifbytenotequal gBattlerFainted, gBattlersCount, BattleScript_HandleFaintedMonLoop
Expand Down Expand Up @@ -5763,7 +5763,7 @@ BattleScript_DoSwitchOut::
flushtextbox
printstring STRINGID_SWITCHINMON
hidepartystatussummary BS_ATTACKER
switchinanim BS_ATTACKER, FALSE
switchinanim BS_ATTACKER, FALSE, FALSE
waitstate
switchineffects BS_ATTACKER
moveendcase MOVEEND_STATUS_IMMUNITY_ABILITIES
Expand Down Expand Up @@ -6080,7 +6080,7 @@ BattleScript_RoarSuccessSwitch::
switchindataupdate BS_TARGET
trytoclearprimalweather
flushtextbox
switchinanim BS_TARGET, FALSE
switchinanim BS_TARGET, FALSE, FALSE
waitstate
printstring STRINGID_PKMNWASDRAGGEDOUT
switchineffects BS_TARGET
Expand Down Expand Up @@ -7648,7 +7648,7 @@ BattleScript_EmergencyExitNoPopUp::
switchindataupdate BS_TARGET
hpthresholds BS_TARGET
printstring STRINGID_SWITCHINMON
switchinanim BS_TARGET, TRUE
switchinanim BS_TARGET, FALSE, TRUE
waitstate
switchineffects BS_TARGET
BattleScript_EmergencyExitRet:
Expand Down Expand Up @@ -9617,7 +9617,7 @@ BattleScript_EjectButtonActivates::
trytoclearprimalweather
flushtextbox
printstring 0x3
switchinanim BS_SCRIPTING 0x1
switchinanim BS_SCRIPTING, FALSE, TRUE
waitstate
switchineffects BS_SCRIPTING
BattleScript_EjectButtonEnd:
Expand Down Expand Up @@ -9981,7 +9981,7 @@ BattleScript_DynamaxBegins::
returnatktoball
pause B_WAIT_TIME_SHORT
returntoball BS_SCRIPTING, TRUE
switchinanim BS_SCRIPTING, TRUE
switchinanim BS_SCRIPTING, TRUE, TRUE
updatedynamax
playanimation BS_SCRIPTING, B_ANIM_DYNAMAX_GROWTH
waitanimation
Expand Down
2 changes: 1 addition & 1 deletion data/battle_scripts_2.s
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BattleScript_ItemRestoreHP_Party::
return

BattleScript_ItemRestoreHP_SendOutRevivedBattler:
switchinanim BS_SCRIPTING, FALSE
switchinanim BS_SCRIPTING, FALSE, FALSE
waitstate
switchineffects BS_SCRIPTING
end
Expand Down
4 changes: 2 additions & 2 deletions include/battle_controllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void PrepareBufferDataTransferLink(u32 battler, u32 bufferId, u16 size, u8 *data
void BtlController_EmitGetMonData(u32 battler, u32 bufferId, u8 requestId, u8 monToCheck);
void BtlController_EmitSetMonData(u32 battler, u32 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
void BtlController_EmitLoadMonSprite(u32 battler, u32 bufferId);
void BtlController_EmitSwitchInAnim(u32 battler, u32 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void BtlController_EmitSwitchInAnim(u32 battler, u32 bufferId, u8 partyId, bool8 dontClearTransform, bool8 dontClearSubstituteBit);
void BtlController_EmitReturnMonToBall(u32 battler, u32 bufferId, bool8 skipAnim);
void BtlController_EmitDrawTrainerPic(u32 battler, u32 bufferId);
void BtlController_EmitTrainerSlide(u32 battler, u32 bufferId);
Expand Down Expand Up @@ -255,7 +255,7 @@ void BattleControllerComplete(u32 battler); // Can be used for all the controlle
void BtlController_Empty(u32 battler); // Empty command, does nothing, only completes the execution.
void BtlController_TerminatorNop(u32 battler); // Dummy function at the end of the table.
void BattleControllerDummy(u32 battler);
void StartSendOutAnim(u32 battler, bool32 dontClearSubstituteBit, bool32 doSlideIn);
void StartSendOutAnim(u32 battler, bool32 dontClearTransform, bool32 dontClearSubstituteBit, bool32 doSlideIn);
void Controller_WaitForString(u32 battler);
void Controller_WaitForHealthBar(u32 battler);

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 @@ -38,7 +38,7 @@ void SpriteCB_SetInvisible(struct Sprite *sprite);
void SetBattlerShadowSpriteCallback(u8 battler, u16 species);
void HideBattlerShadowSprite(u8 battler);
void FillAroundBattleWindows(void);
void ClearTemporarySpeciesSpriteData(u8 battler, bool8 dontClearSubstitute);
void ClearTemporarySpeciesSpriteData(u32 battler, bool32 dontClearTransform, bool32 dontClearSubstitute);
void AllocateMonSpritesGfx(void);
void FreeMonSpritesGfx(void);
bool32 ShouldPlayNormalMonCry(struct Pokemon *mon);
Expand Down
1 change: 1 addition & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ u8 GetItemEffectParamOffset(u32 battler, u16 itemId, u8 effectByte, u8 effectBit
u8 *UseStatIncreaseItem(u16 itemId);
u8 GetNature(struct Pokemon *mon);
u8 GetNatureFromPersonality(u32 personality);
u32 GetGMaxTargetSpecies(u32 species);
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16 evolutionItem, struct Pokemon *tradePartner);
bool8 IsMonPastEvolutionLevel(struct Pokemon *mon);
u16 NationalPokedexNumToSpecies(u16 nationalNum);
Expand Down
48 changes: 17 additions & 31 deletions src/battle_anim_mons.c
Original file line number Diff line number Diff line change
Expand Up @@ -2117,24 +2117,26 @@ s16 GetBattlerSpriteCoordAttr(u8 battlerId, u8 attr)
}
else
{
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
struct Pokemon *mon = GetPartyBattlerData(battlerId);

spriteInfo = gBattleSpritesDataPtr->battlerData;
if (!spriteInfo[battlerId].transformSpecies)
{
spriteInfo = gBattleSpritesDataPtr->battlerData;
if (!spriteInfo[battlerId].transformSpecies)
{
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
personality = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_PERSONALITY);
}
else
{
species = spriteInfo[battlerId].transformSpecies;
personality = gTransformedPersonalities[battlerId];
}
species = GetMonData(mon, MON_DATA_SPECIES);
personality = GetMonData(mon, MON_DATA_PERSONALITY);
}
else
{
species = spriteInfo[battlerId].transformSpecies;
personality = gTransformedPersonalities[battlerId];
}

species = SanitizeSpeciesId(species);
if (species == SPECIES_UNOWN)
species = GetUnownSpeciesId(personality);
species = SanitizeSpeciesId(species);
if (species == SPECIES_UNOWN)
species = GetUnownSpeciesId(personality);

if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
{
#if P_GENDER_DIFFERENCES
if (gSpeciesInfo[species].backPicFemale != NULL && IsPersonalityFemale(species, personality))
size = gSpeciesInfo[species].backPicSizeFemale;
Expand All @@ -2146,22 +2148,6 @@ s16 GetBattlerSpriteCoordAttr(u8 battlerId, u8 attr)
}
else
{
spriteInfo = gBattleSpritesDataPtr->battlerData;
if (!spriteInfo[battlerId].transformSpecies)
{
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_PERSONALITY);
}
else
{
species = spriteInfo[battlerId].transformSpecies;
personality = gTransformedPersonalities[battlerId];
}

species = SanitizeSpeciesId(species);
if (species == SPECIES_UNOWN)
species = GetUnownSpeciesId(personality);

#if P_GENDER_DIFFERENCES
if (gSpeciesInfo[species].frontPicFemale != NULL && IsPersonalityFemale(species, personality))
size = gSpeciesInfo[species].frontPicSizeFemale;
Expand Down
20 changes: 10 additions & 10 deletions src/battle_controllers.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,12 +976,12 @@ void BtlController_EmitLoadMonSprite(u32 battler, u32 bufferId)
PrepareBufferDataTransfer(battler, bufferId, gBattleResources->transferBuffer, 4);
}

void BtlController_EmitSwitchInAnim(u32 battler, u32 bufferId, u8 partyId, bool8 dontClearSubstituteBit)
void BtlController_EmitSwitchInAnim(u32 battler, u32 bufferId, u8 partyId, bool8 dontClearTransform, bool8 dontClearSubstituteBit)
{
gBattleResources->transferBuffer[0] = CONTROLLER_SWITCHINANIM;
gBattleResources->transferBuffer[1] = partyId;
gBattleResources->transferBuffer[2] = dontClearSubstituteBit;
gBattleResources->transferBuffer[3] = 5;
gBattleResources->transferBuffer[2] = dontClearTransform;
gBattleResources->transferBuffer[3] = dontClearSubstituteBit;
PrepareBufferDataTransfer(battler, bufferId, gBattleResources->transferBuffer, 4);
}

Expand Down Expand Up @@ -2111,13 +2111,13 @@ static bool8 ShouldDoSlideInAnim(void)
return TRUE;
}

void StartSendOutAnim(u32 battler, bool32 dontClearSubstituteBit, bool32 doSlideIn)
void StartSendOutAnim(u32 battler, bool32 dontClearTransform, bool32 dontClearSubstituteBit, bool32 doSlideIn)
{
u16 species;
u32 side = GetBattlerSide(battler);
struct Pokemon *party = GetBattlerParty(battler);

ClearTemporarySpeciesSpriteData(battler, dontClearSubstituteBit);
ClearTemporarySpeciesSpriteData(battler, dontClearTransform, dontClearSubstituteBit);
gBattlerPartyIndexes[battler] = gBattleResources->bufferA[battler][1];
species = GetIllusionMonSpecies(battler);
if (species == SPECIES_NONE)
Expand Down Expand Up @@ -2462,11 +2462,11 @@ void BtlController_HandleLoadMonSprite(u32 battler, void (*controllerCallback)(u
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(u32 battler))
{
if (isPlayerSide)
ClearTemporarySpeciesSpriteData(battler, gBattleResources->bufferA[battler][2]);
ClearTemporarySpeciesSpriteData(battler, gBattleResources->bufferA[battler][2], gBattleResources->bufferA[battler][3]);
gBattlerPartyIndexes[battler] = gBattleResources->bufferA[battler][1];
if (isPlayerSide)
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
StartSendOutAnim(battler, gBattleResources->bufferA[battler][2], FALSE);
StartSendOutAnim(battler, gBattleResources->bufferA[battler][2], gBattleResources->bufferA[battler][3], FALSE);
gBattlerControllerFuncs[battler] = controllerCallback;
}

Expand Down Expand Up @@ -2965,17 +2965,17 @@ static void Task_StartSendOutAnim(u8 taskId)
if (TwoMonsAtSendOut(battler))
{
gBattleResources->bufferA[battler][1] = gBattlerPartyIndexes[battler];
StartSendOutAnim(battler, FALSE, ShouldDoSlideInAnim());
StartSendOutAnim(battler, FALSE, FALSE, ShouldDoSlideInAnim());

battlerPartner = battler ^ BIT_FLANK;
gBattleResources->bufferA[battlerPartner][1] = gBattlerPartyIndexes[battlerPartner];
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerPartner]], battlerPartner);
StartSendOutAnim(battlerPartner, FALSE, ShouldDoSlideInAnim());
StartSendOutAnim(battlerPartner, FALSE, FALSE, ShouldDoSlideInAnim());
}
else
{
gBattleResources->bufferA[battler][1] = gBattlerPartyIndexes[battler];
StartSendOutAnim(battler, FALSE, ShouldDoSlideInAnim());
StartSendOutAnim(battler, FALSE, FALSE, ShouldDoSlideInAnim());
}
gBattlerControllerFuncs[battler] = (void*)(GetWordTaskArg(taskId, tControllerFunc_1));
DestroyTask(taskId);
Expand Down
Loading
Loading