mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
Fix bugs related to Trainer Slide messages (#2699)
* start working on trainer slides * use cmd->nextInstr
This commit is contained in:
parent
137c13aa69
commit
44d2cc7232
@ -192,16 +192,30 @@ BattleScript_ActionWallyThrow:
|
|||||||
waitmessage B_WAIT_TIME_LONG
|
waitmessage B_WAIT_TIME_LONG
|
||||||
end2
|
end2
|
||||||
|
|
||||||
BattleScript_TrainerSlideMsgRet::
|
BattleScript_TrainerASlideMsgRet::
|
||||||
handletrainerslidemsg BS_SCRIPTING, 0
|
handletrainerslidemsg BS_SCRIPTING, 0
|
||||||
trainerslidein 1
|
trainerslidein B_POSITION_OPPONENT_LEFT
|
||||||
handletrainerslidemsg BS_SCRIPTING, 1
|
handletrainerslidemsg BS_SCRIPTING, 1
|
||||||
waitstate
|
waitstate
|
||||||
trainerslideout 1
|
trainerslideout B_POSITION_OPPONENT_LEFT
|
||||||
handletrainerslidemsg BS_SCRIPTING, 2
|
|
||||||
waitstate
|
waitstate
|
||||||
|
handletrainerslidemsg BS_SCRIPTING, 2
|
||||||
return
|
return
|
||||||
|
|
||||||
BattleScript_TrainerSlideMsgEnd2::
|
BattleScript_TrainerASlideMsgEnd2::
|
||||||
call BattleScript_TrainerSlideMsgRet
|
call BattleScript_TrainerASlideMsgRet
|
||||||
|
end2
|
||||||
|
|
||||||
|
BattleScript_TrainerBSlideMsgRet::
|
||||||
|
handletrainerslidemsg BS_SCRIPTING, 0
|
||||||
|
trainerslidein B_POSITION_OPPONENT_RIGHT
|
||||||
|
handletrainerslidemsg BS_SCRIPTING, 1
|
||||||
|
waitstate
|
||||||
|
trainerslideout B_POSITION_OPPONENT_RIGHT
|
||||||
|
waitstate
|
||||||
|
handletrainerslidemsg BS_SCRIPTING, 2
|
||||||
|
return
|
||||||
|
|
||||||
|
BattleScript_TrainerBSlideMsgEnd2::
|
||||||
|
call BattleScript_TrainerBSlideMsgRet
|
||||||
end2
|
end2
|
||||||
|
@ -237,7 +237,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst);
|
|||||||
void BattlePutTextOnWindow(const u8 *text, u8 windowId);
|
void BattlePutTextOnWindow(const u8 *text, u8 windowId);
|
||||||
void SetPpNumbersPaletteInMoveSelection(void);
|
void SetPpNumbersPaletteInMoveSelection(void);
|
||||||
u8 GetCurrentPpToMaxPpState(u8 currentPp, u8 maxPp);
|
u8 GetCurrentPpToMaxPpState(u8 currentPp, u8 maxPp);
|
||||||
bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which);
|
u32 ShouldDoTrainerSlide(u32 battlerId, u32 which); // return 1 for TrainerA, 2 forTrainerB
|
||||||
void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);
|
void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);
|
||||||
|
|
||||||
extern struct BattleMsgData *gBattleMsgDataPtr;
|
extern struct BattleMsgData *gBattleMsgDataPtr;
|
||||||
|
@ -295,8 +295,10 @@ extern const u8 BattleScript_MoveEffectClearSmog[];
|
|||||||
extern const u8 BattleScript_SideStatusWoreOffReturn[];
|
extern const u8 BattleScript_SideStatusWoreOffReturn[];
|
||||||
extern const u8 BattleScript_MoveEffectSmackDown[];
|
extern const u8 BattleScript_MoveEffectSmackDown[];
|
||||||
extern const u8 BattleScript_MoveEffectFlameBurst[];
|
extern const u8 BattleScript_MoveEffectFlameBurst[];
|
||||||
extern const u8 BattleScript_TrainerSlideMsgRet[];
|
extern const u8 BattleScript_TrainerASlideMsgRet[];
|
||||||
extern const u8 BattleScript_TrainerSlideMsgEnd2[];
|
extern const u8 BattleScript_TrainerASlideMsgEnd2[];
|
||||||
|
extern const u8 BattleScript_TrainerBSlideMsgRet[];
|
||||||
|
extern const u8 BattleScript_TrainerBSlideMsgEnd2[];
|
||||||
extern const u8 BattleScript_MoveEffectFeint[];
|
extern const u8 BattleScript_MoveEffectFeint[];
|
||||||
extern const u8 BattleScript_ProteanActivates[];
|
extern const u8 BattleScript_ProteanActivates[];
|
||||||
extern const u8 BattleScript_DazzlingProtected[];
|
extern const u8 BattleScript_DazzlingProtected[];
|
||||||
|
@ -3866,8 +3866,8 @@ void BattleTurnPassed(void)
|
|||||||
BattleScriptExecute(BattleScript_PalacePrintFlavorText);
|
BattleScriptExecute(BattleScript_PalacePrintFlavorText);
|
||||||
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaTurnCounter == 0)
|
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaTurnCounter == 0)
|
||||||
BattleScriptExecute(BattleScript_ArenaTurnBeginning);
|
BattleScriptExecute(BattleScript_ArenaTurnBeginning);
|
||||||
else if (ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), gTrainerBattleOpponent_A, TRAINER_SLIDE_LAST_LOW_HP))
|
else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_LAST_LOW_HP)))
|
||||||
BattleScriptExecute(BattleScript_TrainerSlideMsgEnd2);
|
BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 IsRunningFromBattleImpossible(void)
|
u8 IsRunningFromBattleImpossible(void)
|
||||||
|
@ -3887,11 +3887,11 @@ static const struct TrainerSlide sTrainerSlides[] =
|
|||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
static u32 GetEnemyMonCount(bool32 onlyAlive)
|
static u32 GetEnemyMonCount(u32 firstId, u32 lastId, bool32 onlyAlive)
|
||||||
{
|
{
|
||||||
u32 i, count = 0;
|
u32 i, count = 0;
|
||||||
|
|
||||||
for (i = 0; i < PARTY_SIZE; i++)
|
for (i = firstId; i < lastId; i++)
|
||||||
{
|
{
|
||||||
u32 species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2, NULL);
|
u32 species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2, NULL);
|
||||||
if (species != SPECIES_NONE
|
if (species != SPECIES_NONE
|
||||||
@ -3911,12 +3911,33 @@ static bool32 IsBattlerHpLow(u32 battler)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which)
|
u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
|
||||||
{
|
{
|
||||||
s32 i;
|
u32 i, firstId, lastId, trainerId, retValue = 1;
|
||||||
|
|
||||||
if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) || GetBattlerSide(battlerId) != B_SIDE_OPPONENT)
|
if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) || GetBattlerSide(battlerId) != B_SIDE_OPPONENT)
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
|
// Two opponents support.
|
||||||
|
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
|
||||||
|
{
|
||||||
|
if (gBattlerPartyIndexes[battlerId] >= 3)
|
||||||
|
{
|
||||||
|
firstId = 3, lastId = PARTY_SIZE;
|
||||||
|
trainerId = gTrainerBattleOpponent_B;
|
||||||
|
retValue = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstId = 0, lastId = 3;
|
||||||
|
trainerId = gTrainerBattleOpponent_A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstId = 0, lastId = PARTY_SIZE;
|
||||||
|
trainerId = gTrainerBattleOpponent_A;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(sTrainerSlides); i++)
|
for (i = 0; i < ARRAY_COUNT(sTrainerSlides); i++)
|
||||||
{
|
{
|
||||||
@ -3926,28 +3947,28 @@ bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which)
|
|||||||
switch (which)
|
switch (which)
|
||||||
{
|
{
|
||||||
case TRAINER_SLIDE_LAST_SWITCHIN:
|
case TRAINER_SLIDE_LAST_SWITCHIN:
|
||||||
if (sTrainerSlides[i].msgLastSwitchIn != NULL && GetEnemyMonCount(TRUE) == 1)
|
if (sTrainerSlides[i].msgLastSwitchIn != NULL && !CanBattlerSwitch(battlerId))
|
||||||
{
|
{
|
||||||
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastSwitchIn;
|
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastSwitchIn;
|
||||||
return TRUE;
|
return retValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TRAINER_SLIDE_LAST_LOW_HP:
|
case TRAINER_SLIDE_LAST_LOW_HP:
|
||||||
if (sTrainerSlides[i].msgLastLowHp != NULL
|
if (sTrainerSlides[i].msgLastLowHp != NULL
|
||||||
&& GetEnemyMonCount(TRUE) == 1
|
&& GetEnemyMonCount(firstId, lastId, TRUE) == 1
|
||||||
&& IsBattlerHpLow(battlerId)
|
&& IsBattlerHpLow(battlerId)
|
||||||
&& !gBattleStruct->trainerSlideLowHpMsgDone)
|
&& !gBattleStruct->trainerSlideLowHpMsgDone)
|
||||||
{
|
{
|
||||||
gBattleStruct->trainerSlideLowHpMsgDone = TRUE;
|
gBattleStruct->trainerSlideLowHpMsgDone = TRUE;
|
||||||
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastLowHp;
|
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastLowHp;
|
||||||
return TRUE;
|
return retValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TRAINER_SLIDE_FIRST_DOWN:
|
case TRAINER_SLIDE_FIRST_DOWN:
|
||||||
if (sTrainerSlides[i].msgFirstDown != NULL && GetEnemyMonCount(TRUE) == GetEnemyMonCount(FALSE) - 1)
|
if (sTrainerSlides[i].msgFirstDown != NULL && GetEnemyMonCount(firstId, lastId, TRUE) == GetEnemyMonCount(firstId, lastId, FALSE) - 1)
|
||||||
{
|
{
|
||||||
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstDown;
|
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstDown;
|
||||||
return TRUE;
|
return retValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3955,5 +3976,5 @@ bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10109,7 +10109,8 @@ static void Cmd_various(void)
|
|||||||
VARIOUS_ARGS(u8 case_);
|
VARIOUS_ARGS(u8 case_);
|
||||||
if (cmd->case_ == 0)
|
if (cmd->case_ == 0)
|
||||||
{
|
{
|
||||||
gBattleScripting.savedDmg = gBattlerSpriteIds[gActiveBattler];
|
// Save sprite IDs, because trainer slide in will overwrite gBattlerSpriteIds variable.
|
||||||
|
gBattleScripting.savedDmg = (gBattlerSpriteIds[gActiveBattler] & 0xFF) | (gBattlerSpriteIds[BATTLE_PARTNER(gActiveBattler)] << 8);
|
||||||
HideBattlerShadowSprite(gActiveBattler);
|
HideBattlerShadowSprite(gActiveBattler);
|
||||||
}
|
}
|
||||||
else if (cmd->case_ == 1)
|
else if (cmd->case_ == 1)
|
||||||
@ -10119,12 +10120,19 @@ static void Cmd_various(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gBattlerSpriteIds[gActiveBattler] = gBattleScripting.savedDmg;
|
gBattlerSpriteIds[BATTLE_PARTNER(gActiveBattler)] = gBattleScripting.savedDmg >> 8;
|
||||||
if (gBattleMons[gActiveBattler].hp != 0)
|
gBattlerSpriteIds[gActiveBattler] = gBattleScripting.savedDmg & 0xFF;
|
||||||
|
if (IsBattlerAlive(gActiveBattler))
|
||||||
{
|
{
|
||||||
SetBattlerShadowSpriteCallback(gActiveBattler, gBattleMons[gActiveBattler].species);
|
SetBattlerShadowSpriteCallback(gActiveBattler, gBattleMons[gActiveBattler].species);
|
||||||
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
|
||||||
}
|
}
|
||||||
|
i = BATTLE_PARTNER(gActiveBattler);
|
||||||
|
if (IsBattlerAlive(i))
|
||||||
|
{
|
||||||
|
SetBattlerShadowSpriteCallback(i, gBattleMons[i].species);
|
||||||
|
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[i]], i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||||
return;
|
return;
|
||||||
@ -10132,11 +10140,11 @@ static void Cmd_various(void)
|
|||||||
case VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF:
|
case VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF:
|
||||||
{
|
{
|
||||||
VARIOUS_ARGS();
|
VARIOUS_ARGS();
|
||||||
if (ShouldDoTrainerSlide(gActiveBattler, gTrainerBattleOpponent_A, TRAINER_SLIDE_FIRST_DOWN))
|
if ((i = ShouldDoTrainerSlide(gActiveBattler, TRAINER_SLIDE_FIRST_DOWN)))
|
||||||
{
|
{
|
||||||
gBattleScripting.battler = gActiveBattler;
|
gBattleScripting.battler = gActiveBattler;
|
||||||
BattleScriptPush(cmd->nextInstr);
|
BattleScriptPush(cmd->nextInstr);
|
||||||
gBattlescriptCurrInstr = BattleScript_TrainerSlideMsgRet;
|
gBattlescriptCurrInstr = (i == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -10144,11 +10152,11 @@ static void Cmd_various(void)
|
|||||||
case VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON:
|
case VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON:
|
||||||
{
|
{
|
||||||
VARIOUS_ARGS();
|
VARIOUS_ARGS();
|
||||||
if (ShouldDoTrainerSlide(gActiveBattler, gTrainerBattleOpponent_A, TRAINER_SLIDE_LAST_SWITCHIN))
|
if ((i = ShouldDoTrainerSlide(gActiveBattler, TRAINER_SLIDE_LAST_SWITCHIN)))
|
||||||
{
|
{
|
||||||
gBattleScripting.battler = gActiveBattler;
|
gBattleScripting.battler = gActiveBattler;
|
||||||
BattleScriptPush(cmd->nextInstr);
|
BattleScriptPush(cmd->nextInstr);
|
||||||
gBattlescriptCurrInstr = BattleScript_TrainerSlideMsgRet;
|
gBattlescriptCurrInstr = (i == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user