Merge branch 'master' into link
This commit is contained in:
+66
-90
@@ -6,6 +6,7 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "unknown_task.h"
|
||||
#include "battle_setup.h"
|
||||
#include "battle_scripts.h"
|
||||
#include "pokemon.h"
|
||||
#include "palette.h"
|
||||
#include "task.h"
|
||||
@@ -120,14 +121,14 @@ extern u32 gBattleExecBuffer;
|
||||
extern u8 gMultiHitCounter;
|
||||
extern u8 gBattleMoveFlags;
|
||||
extern s32 gBattleMoveDamage;
|
||||
extern const u8* gUnknown_02024230[BATTLE_BANKS_COUNT];
|
||||
extern u16 gUnknownMovesUsedByBanks[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT];
|
||||
extern u16 gUnknown_02024250[BATTLE_BANKS_COUNT];
|
||||
extern u16 gUnknown_02024258[BATTLE_BANKS_COUNT];
|
||||
extern u16 gUnknown_02024260[BATTLE_BANKS_COUNT];
|
||||
extern const u8* gPalaceSelectionBattleScripts[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastPrintedMoves[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastMoves[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastHitByType[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastResultingMoves[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLockedMoves[BATTLE_BANKS_COUNT];
|
||||
extern u8 gUnknown_02024270[BATTLE_BANKS_COUNT];
|
||||
extern u8 gLastHitBy[BATTLE_BANKS_COUNT];
|
||||
extern u8 gUnknown_02024284[BATTLE_BANKS_COUNT];
|
||||
extern u32 gStatuses3[BATTLE_BANKS_COUNT];
|
||||
extern u16 gSideAffecting[2];
|
||||
@@ -141,7 +142,7 @@ extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT];
|
||||
extern u8 gCurrentActionFuncId;
|
||||
extern u8 gLastUsedAbility;
|
||||
extern u8 gUnknown_0203CF00[];
|
||||
extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT];
|
||||
extern const u8* gSelectionBattleScripts[BATTLE_BANKS_COUNT];
|
||||
extern const u8* gBattlescriptCurrInstr;
|
||||
extern u8 gActionsByTurnOrder[BATTLE_BANKS_COUNT];
|
||||
extern u8 gCurrentTurnActionNumber;
|
||||
@@ -149,7 +150,7 @@ extern u16 gDynamicBasePower;
|
||||
extern u8 gCritMultiplier;
|
||||
extern u8 gCurrMovePos;
|
||||
extern u8 gUnknown_020241E9;
|
||||
extern u16 gLastUsedMove;
|
||||
extern u16 gChosenMove;
|
||||
|
||||
extern const struct BattleMove gBattleMoves[];
|
||||
extern const u16 gUnknown_08C004E0[]; // battle textbox palette
|
||||
@@ -179,31 +180,6 @@ extern const u8 gText_Ice[];
|
||||
extern const u8 gText_Confusion[];
|
||||
extern const u8 gText_Love[];
|
||||
|
||||
// battlescripts
|
||||
extern const u8 gUnknown_082DB8BE[];
|
||||
extern const u8 gUnknown_082DB881[];
|
||||
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
|
||||
extern const u8 gUnknown_082DAB11[];
|
||||
extern const u8 gUnknown_082DB9BA[];
|
||||
extern const u8 gUnknown_082DAAFE[];
|
||||
extern const u8 gUnknown_082DAB0B[];
|
||||
extern const u8 BattleScript_FocusPunchSetUp[];
|
||||
extern const u8 BattleScript_LinkBattleWonOrLost[];
|
||||
extern const u8 BattleScript_FrontierTrainerBattleWon[];
|
||||
extern const u8 BattleScript_LocalTrainerBattleWon[];
|
||||
extern const u8 BattleScript_PayDayMoneyAndPickUpItems[];
|
||||
extern const u8 BattleScript_LocalBattleLost[];
|
||||
extern const u8 gUnknown_082DB9C8[];
|
||||
extern const u8 gUnknown_082DAA0B[];
|
||||
extern const u8 gUnknown_082DB9C1[];
|
||||
extern const u8 BattleScript_RanAwayUsingMonAbility[];
|
||||
extern const u8 BattleScript_SmokeBallEscape[];
|
||||
extern const u8 BattleScript_GotAwaySafely[];
|
||||
extern const u8 BattleScript_WildMonFled[];
|
||||
extern const u8 BattleScript_MoveUsedLoafingAround[];
|
||||
extern const u8 BattleScript_ActionSwitch[];
|
||||
extern const u8 BattleScript_PrintFailedToRunString[];
|
||||
|
||||
// functions
|
||||
extern void dp12_8087EA4(void);
|
||||
extern void sub_80356D0(void);
|
||||
@@ -486,7 +462,7 @@ static void sub_8036A5C(void)
|
||||
u32 status = 0;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
|
||||
hp = GetMonData(&gPlayerParty[i], MON_DATA_HP);
|
||||
@@ -1903,7 +1879,7 @@ static void sub_8038B94(u8 taskId)
|
||||
}
|
||||
|
||||
r7 = 0;
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
u16 species = GetMonData(&sp4[i], MON_DATA_SPECIES2);
|
||||
u16 hp = GetMonData(&sp4[i], MON_DATA_HP);
|
||||
@@ -1927,7 +1903,7 @@ static void sub_8038B94(u8 taskId)
|
||||
gTasks[taskId].data[3] = r7;
|
||||
|
||||
r7 = 0;
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
u16 species = GetMonData(&sp8[i], MON_DATA_SPECIES2);
|
||||
u16 hp = GetMonData(&sp8[i], MON_DATA_HP);
|
||||
@@ -2766,17 +2742,17 @@ static void BattleStartClearSetData(void)
|
||||
for (j = 0; j < sizeof(struct DisableStruct); j++)
|
||||
dataPtr[j] = 0;
|
||||
|
||||
gDisableStructs[i].isFirstTurn= 2;
|
||||
gDisableStructs[i].isFirstTurn = 2;
|
||||
gUnknown_02024284[i] = 0;
|
||||
gLastUsedMovesByBanks[i] = 0;
|
||||
gUnknown_02024250[i] = 0;
|
||||
gUnknown_02024258[i] = 0;
|
||||
gUnknown_02024260[i] = 0;
|
||||
gUnknown_02024270[i] = 0xFF;
|
||||
gLastMoves[i] = 0;
|
||||
gLastLandedMoves[i] = 0;
|
||||
gLastHitByType[i] = 0;
|
||||
gLastResultingMoves[i] = 0;
|
||||
gLastHitBy[i] = 0xFF;
|
||||
gLockedMoves[i] = 0;
|
||||
gUnknownMovesUsedByBanks[i] = 0;
|
||||
gLastPrintedMoves[i] = 0;
|
||||
gBattleResources->flags->flags[i] = 0;
|
||||
gUnknown_02024230[i] = 0;
|
||||
gPalaceSelectionBattleScripts[i] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
@@ -2933,14 +2909,14 @@ void SwitchInClearSetData(void)
|
||||
}
|
||||
|
||||
gBattleMoveFlags = 0;
|
||||
gDisableStructs[gActiveBank].isFirstTurn= 2;
|
||||
gDisableStructs[gActiveBank].isFirstTurn = 2;
|
||||
gDisableStructs[gActiveBank].truantUnknownBit = disableStructCopy.truantUnknownBit;
|
||||
gLastUsedMovesByBanks[gActiveBank] = 0;
|
||||
gUnknown_02024250[gActiveBank] = 0;
|
||||
gUnknown_02024258[gActiveBank] = 0;
|
||||
gUnknown_02024260[gActiveBank] = 0;
|
||||
gUnknownMovesUsedByBanks[gActiveBank] = 0;
|
||||
gUnknown_02024270[gActiveBank] = 0xFF;
|
||||
gLastMoves[gActiveBank] = 0;
|
||||
gLastLandedMoves[gActiveBank] = 0;
|
||||
gLastHitByType[gActiveBank] = 0;
|
||||
gLastResultingMoves[gActiveBank] = 0;
|
||||
gLastPrintedMoves[gActiveBank] = 0;
|
||||
gLastHitBy[gActiveBank] = 0xFF;
|
||||
|
||||
*(gBattleStruct->mirrorMoves + gActiveBank * 2 + 0) = 0;
|
||||
*(gBattleStruct->mirrorMoves + gActiveBank * 2 + 1) = 0;
|
||||
@@ -3027,12 +3003,12 @@ void FaintClearSetData(void)
|
||||
|
||||
gDisableStructs[gActiveBank].isFirstTurn = 2;
|
||||
|
||||
gLastUsedMovesByBanks[gActiveBank] = 0;
|
||||
gUnknown_02024250[gActiveBank] = 0;
|
||||
gUnknown_02024258[gActiveBank] = 0;
|
||||
gUnknown_02024260[gActiveBank] = 0;
|
||||
gUnknownMovesUsedByBanks[gActiveBank] = 0;
|
||||
gUnknown_02024270[gActiveBank] = 0xFF;
|
||||
gLastMoves[gActiveBank] = 0;
|
||||
gLastLandedMoves[gActiveBank] = 0;
|
||||
gLastHitByType[gActiveBank] = 0;
|
||||
gLastResultingMoves[gActiveBank] = 0;
|
||||
gLastPrintedMoves[gActiveBank] = 0;
|
||||
gLastHitBy[gActiveBank] = 0xFF;
|
||||
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 0) = 0;
|
||||
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 1) = 0;
|
||||
@@ -3214,7 +3190,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
{
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|
||||
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
@@ -3232,7 +3208,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
|
||||
EmitDrawPartyStatusSummary(0, hpStatus, 0x80);
|
||||
MarkBufferBankForExecution(gActiveBank);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|
||||
|| GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
@@ -3705,7 +3681,7 @@ static void TryDoEventsBeforeFirstTurn(void)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
|
||||
{
|
||||
StopCryAndClearCrySongs();
|
||||
BattleScriptExecute(gUnknown_082DB8BE);
|
||||
BattleScriptExecute(BattleScript_82DB8BE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3793,9 +3769,9 @@ void BattleTurnPassed(void)
|
||||
gRandomTurnNumber = Random();
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
|
||||
BattleScriptExecute(gUnknown_082DB881);
|
||||
BattleScriptExecute(BattleScript_82DB881);
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->field_DA == 0)
|
||||
BattleScriptExecute(gUnknown_082DB8BE);
|
||||
BattleScriptExecute(BattleScript_82DB8BE);
|
||||
}
|
||||
|
||||
u8 IsRunningFromBattleImpossible(void)
|
||||
@@ -4008,7 +3984,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
| BATTLE_TYPE_x2000000))
|
||||
{
|
||||
RecordedBattle_ClearBankAction(gActiveBank, 1);
|
||||
gBattlescriptPtrsForSelection[gActiveBank] = BattleScript_ActionSelectionItemsCantBeUsed;
|
||||
gSelectionBattleScripts[gActiveBank] = BattleScript_ActionSelectionItemsCantBeUsed;
|
||||
gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT;
|
||||
*(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE;
|
||||
*(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN;
|
||||
@@ -4053,7 +4029,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
case ACTION_SAFARI_ZONE_BALL:
|
||||
if (IsPlayerPartyAndPokemonStorageFull())
|
||||
{
|
||||
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB11;
|
||||
gSelectionBattleScripts[gActiveBank] = BattleScript_PrintFullBox;
|
||||
gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT;
|
||||
*(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE;
|
||||
*(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN;
|
||||
@@ -4108,7 +4084,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
&& gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000)
|
||||
&& gBattleBufferB[gActiveBank][1] == ACTION_RUN)
|
||||
{
|
||||
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB9BA;
|
||||
gSelectionBattleScripts[gActiveBank] = BattleScript_AskIfWantsToForfeitMatch;
|
||||
gBattleCommunication[gActiveBank] = 8;
|
||||
*(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE;
|
||||
*(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN;
|
||||
@@ -4118,13 +4094,13 @@ static void HandleTurnActionSelectionState(void)
|
||||
&& !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
|
||||
&& gBattleBufferB[gActiveBank][1] == ACTION_RUN)
|
||||
{
|
||||
BattleScriptExecute(gUnknown_082DAAFE);
|
||||
BattleScriptExecute(BattleScript_PrintCantRunFromTrainer);
|
||||
gBattleCommunication[gActiveBank] = 1;
|
||||
}
|
||||
else if (IsRunningFromBattleImpossible() != 0
|
||||
else if (IsRunningFromBattleImpossible()
|
||||
&& gBattleBufferB[gActiveBank][1] == ACTION_RUN)
|
||||
{
|
||||
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB0B;
|
||||
gSelectionBattleScripts[gActiveBank] = BattleScript_PrintCantEscapeFromBattle;
|
||||
gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT;
|
||||
*(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE;
|
||||
*(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN;
|
||||
@@ -4277,12 +4253,12 @@ static void HandleTurnActionSelectionState(void)
|
||||
else
|
||||
{
|
||||
gBankAttacker = gActiveBank;
|
||||
gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank];
|
||||
gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBank];
|
||||
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
|
||||
{
|
||||
gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]]();
|
||||
}
|
||||
gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr;
|
||||
gSelectionBattleScripts[gActiveBank] = gBattlescriptCurrInstr;
|
||||
}
|
||||
break;
|
||||
case STATE_WAIT_SET_BEFORE_ACTION:
|
||||
@@ -4309,12 +4285,12 @@ static void HandleTurnActionSelectionState(void)
|
||||
else
|
||||
{
|
||||
gBankAttacker = gActiveBank;
|
||||
gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank];
|
||||
gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBank];
|
||||
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
|
||||
{
|
||||
gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]]();
|
||||
}
|
||||
gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr;
|
||||
gSelectionBattleScripts[gActiveBank] = gBattlescriptCurrInstr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -4812,13 +4788,13 @@ static void HandleEndTurn_BattleLost(void)
|
||||
{
|
||||
if (gBattleOutcome & BATTLE_OUTCOME_BIT_x80)
|
||||
{
|
||||
gBattlescriptCurrInstr = gUnknown_082DB9C8;
|
||||
gBattlescriptCurrInstr = BattleScript_82DB9C8;
|
||||
gBattleOutcome &= ~(BATTLE_OUTCOME_BIT_x80);
|
||||
gSaveBlock2Ptr->field_CA9_b = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattlescriptCurrInstr = gUnknown_082DAA0B;
|
||||
gBattlescriptCurrInstr = BattleScript_82DAA0B;
|
||||
gBattleOutcome &= ~(BATTLE_OUTCOME_BIT_x80);
|
||||
}
|
||||
}
|
||||
@@ -4844,13 +4820,13 @@ static void HandleEndTurn_RanFromBattle(void)
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER && gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||
{
|
||||
gBattlescriptCurrInstr = gUnknown_082DB9C1;
|
||||
gBattlescriptCurrInstr = BattleScript_82DB9C1;
|
||||
gBattleOutcome = BATTLE_FORFEITED;
|
||||
gSaveBlock2Ptr->field_CA9_b = 1;
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_x4000000)
|
||||
{
|
||||
gBattlescriptCurrInstr = gUnknown_082DB9C1;
|
||||
gBattlescriptCurrInstr = BattleScript_82DB9C1;
|
||||
gBattleOutcome = BATTLE_FORFEITED;
|
||||
}
|
||||
else
|
||||
@@ -5073,19 +5049,19 @@ static void HandleAction_UseMove(void)
|
||||
if (gProtectStructs[gBankAttacker].onlyStruggle)
|
||||
{
|
||||
gProtectStructs[gBankAttacker].onlyStruggle = 0;
|
||||
gCurrentMove = gLastUsedMove = MOVE_STRUGGLE;
|
||||
gCurrentMove = gChosenMove = MOVE_STRUGGLE;
|
||||
gHitMarker |= HITMARKER_NO_PPDEDUCT;
|
||||
*(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0);
|
||||
}
|
||||
else if (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gBankAttacker].status2 & STATUS2_RECHARGE)
|
||||
{
|
||||
gCurrentMove = gLastUsedMove = gLockedMoves[gBankAttacker];
|
||||
gCurrentMove = gChosenMove = gLockedMoves[gBankAttacker];
|
||||
}
|
||||
// encore forces you to use the same move
|
||||
else if (gDisableStructs[gBankAttacker].encoredMove != MOVE_NONE
|
||||
&& gDisableStructs[gBankAttacker].encoredMove == gBattleMons[gBankAttacker].moves[gDisableStructs[gBankAttacker].encoredMovePos])
|
||||
{
|
||||
gCurrentMove = gLastUsedMove = gDisableStructs[gBankAttacker].encoredMove;
|
||||
gCurrentMove = gChosenMove = gDisableStructs[gBankAttacker].encoredMove;
|
||||
gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBankAttacker].encoredMovePos;
|
||||
*(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0);
|
||||
}
|
||||
@@ -5094,7 +5070,7 @@ static void HandleAction_UseMove(void)
|
||||
&& gDisableStructs[gBankAttacker].encoredMove != gBattleMons[gBankAttacker].moves[gDisableStructs[gBankAttacker].encoredMovePos])
|
||||
{
|
||||
gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBankAttacker].encoredMovePos;
|
||||
gCurrentMove = gLastUsedMove = gBattleMons[gBankAttacker].moves[gCurrMovePos];
|
||||
gCurrentMove = gChosenMove = gBattleMons[gBankAttacker].moves[gCurrMovePos];
|
||||
gDisableStructs[gBankAttacker].encoredMove = MOVE_NONE;
|
||||
gDisableStructs[gBankAttacker].encoredMovePos = 0;
|
||||
gDisableStructs[gBankAttacker].encoreTimer1 = 0;
|
||||
@@ -5102,12 +5078,12 @@ static void HandleAction_UseMove(void)
|
||||
}
|
||||
else if (gBattleMons[gBankAttacker].moves[gCurrMovePos] != gChosenMovesByBanks[gBankAttacker])
|
||||
{
|
||||
gCurrentMove = gLastUsedMove = gBattleMons[gBankAttacker].moves[gCurrMovePos];
|
||||
gCurrentMove = gChosenMove = gBattleMons[gBankAttacker].moves[gCurrMovePos];
|
||||
*(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gCurrentMove = gLastUsedMove = gBattleMons[gBankAttacker].moves[gCurrMovePos];
|
||||
gCurrentMove = gChosenMove = gBattleMons[gBankAttacker].moves[gCurrMovePos];
|
||||
}
|
||||
|
||||
if (gBattleMons[gBankAttacker].hp != 0)
|
||||
@@ -5147,7 +5123,7 @@ static void HandleAction_UseMove(void)
|
||||
}
|
||||
if (var == 4)
|
||||
{
|
||||
if (gBattleMoves[gLastUsedMove].target & MOVE_TARGET_RANDOM)
|
||||
if (gBattleMoves[gChosenMove].target & MOVE_TARGET_RANDOM)
|
||||
{
|
||||
if (GetBankSide(gBankAttacker) == SIDE_PLAYER)
|
||||
{
|
||||
@@ -5192,7 +5168,7 @@ static void HandleAction_UseMove(void)
|
||||
}
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE
|
||||
&& gBattleMoves[gLastUsedMove].target & MOVE_TARGET_RANDOM)
|
||||
&& gBattleMoves[gChosenMove].target & MOVE_TARGET_RANDOM)
|
||||
{
|
||||
if (GetBankSide(gBankAttacker) == SIDE_PLAYER)
|
||||
{
|
||||
@@ -5242,11 +5218,11 @@ static void HandleAction_UseMove(void)
|
||||
gCurrentActionFuncId = 12;
|
||||
return;
|
||||
}
|
||||
else if (gUnknown_02024230[gBankAttacker] != NULL)
|
||||
else if (gPalaceSelectionBattleScripts[gBankAttacker] != NULL)
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 4;
|
||||
gBattlescriptCurrInstr = gUnknown_02024230[gBankAttacker];
|
||||
gUnknown_02024230[gBankAttacker] = NULL;
|
||||
gBattlescriptCurrInstr = gPalaceSelectionBattleScripts[gBankAttacker];
|
||||
gPalaceSelectionBattleScripts[gBankAttacker] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5625,8 +5601,8 @@ static void HandleAction_ActionFinished(void)
|
||||
gBattleMoveFlags = 0;
|
||||
gBattleScripting.animTurn = 0;
|
||||
gBattleScripting.animTargetsHit = 0;
|
||||
gUnknown_02024250[gBankAttacker] = 0;
|
||||
gUnknown_02024258[gBankAttacker] = 0;
|
||||
gLastLandedMoves[gBankAttacker] = 0;
|
||||
gLastHitByType[gBankAttacker] = 0;
|
||||
gBattleStruct->dynamicMoveType = 0;
|
||||
gDynamicBasePower = 0;
|
||||
gBattleScripting.atk49_state = 0;
|
||||
|
||||
@@ -58,7 +58,7 @@ extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern u16 gCurrentMove;
|
||||
extern u8 gBankTarget;
|
||||
extern u8 gAbsentBankFlags;
|
||||
extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastMoves[BATTLE_BANKS_COUNT];
|
||||
extern u16 gTrainerBattleOpponent_A;
|
||||
extern u16 gTrainerBattleOpponent_B;
|
||||
extern u32 gStatuses3[BATTLE_BANKS_COUNT];
|
||||
@@ -633,12 +633,12 @@ static void RecordLastUsedMoveByTarget(void)
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == gLastUsedMovesByBanks[gBankTarget])
|
||||
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == gLastMoves[gBankTarget])
|
||||
break;
|
||||
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] != gLastUsedMovesByBanks[gBankTarget] // HACK: This redundant condition is a hack to make the asm match.
|
||||
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] != gLastMoves[gBankTarget] // HACK: This redundant condition is a hack to make the asm match.
|
||||
&& gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == 0)
|
||||
{
|
||||
gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] = gLastUsedMovesByBanks[gBankTarget];
|
||||
gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] = gLastMoves[gBankTarget];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1252,9 +1252,9 @@ static void BattleAICmd_is_most_powerful_move(void)
|
||||
static void BattleAICmd_get_last_used_bank_move(void)
|
||||
{
|
||||
if (gAIScriptPtr[1] == AI_USER)
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMovesByBanks[sBank_AI];
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI];
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMovesByBanks[gBankTarget];
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[gBankTarget];
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ extern u32 gBattleTypeFlags;
|
||||
extern u32 gStatuses3[BATTLE_BANKS_COUNT];
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
|
||||
extern u16 gUnknown_02024250[BATTLE_BANKS_COUNT];
|
||||
extern u8 gUnknown_02024270[BATTLE_BANKS_COUNT];
|
||||
extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT];
|
||||
extern u8 gLastHitBy[BATTLE_BANKS_COUNT];
|
||||
extern u16 gDynamicBasePower;
|
||||
extern u8 gBattleMoveFlags;
|
||||
extern u8 gCritMultiplier;
|
||||
@@ -141,11 +141,11 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
|
||||
if (HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3 != 0)
|
||||
return FALSE;
|
||||
if (gUnknown_02024250[gActiveBank] == 0)
|
||||
if (gLastLandedMoves[gActiveBank] == 0)
|
||||
return FALSE;
|
||||
if (gUnknown_02024250[gActiveBank] == 0xFFFF)
|
||||
if (gLastLandedMoves[gActiveBank] == 0xFFFF)
|
||||
return FALSE;
|
||||
if (gBattleMoves[gUnknown_02024250[gActiveBank]].power == 0)
|
||||
if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0)
|
||||
return FALSE;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
@@ -162,11 +162,11 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
bankIn2 = gActiveBank;
|
||||
}
|
||||
|
||||
if (gBattleMoves[gUnknown_02024250[gActiveBank]].type == TYPE_FIRE)
|
||||
if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_FIRE)
|
||||
absorbingTypeAbility = ABILITY_FLASH_FIRE;
|
||||
else if (gBattleMoves[gUnknown_02024250[gActiveBank]].type == TYPE_WATER)
|
||||
else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_WATER)
|
||||
absorbingTypeAbility = ABILITY_WATER_ABSORB;
|
||||
else if (gBattleMoves[gUnknown_02024250[gActiveBank]].type == TYPE_ELECTRIC)
|
||||
else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_ELECTRIC)
|
||||
absorbingTypeAbility = ABILITY_VOLT_ABSORB;
|
||||
else
|
||||
return FALSE;
|
||||
@@ -238,13 +238,13 @@ static bool8 ShouldSwitchIfNaturalCure(void)
|
||||
if (gBattleMons[gActiveBank].hp < gBattleMons[gActiveBank].maxHP / 2)
|
||||
return FALSE;
|
||||
|
||||
if ((gUnknown_02024250[gActiveBank] == 0 || gUnknown_02024250[gActiveBank] == 0xFFFF) && Random() & 1)
|
||||
if ((gLastLandedMoves[gActiveBank] == 0 || gLastLandedMoves[gActiveBank] == 0xFFFF) && Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else if (gBattleMoves[gUnknown_02024250[gActiveBank]].power == 0 && Random() & 1)
|
||||
else if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0 && Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
@@ -345,13 +345,13 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
|
||||
u16 move;
|
||||
u8 moveFlags;
|
||||
|
||||
if (gUnknown_02024250[gActiveBank] == 0)
|
||||
if (gLastLandedMoves[gActiveBank] == 0)
|
||||
return FALSE;
|
||||
if (gUnknown_02024250[gActiveBank] == 0xFFFF)
|
||||
if (gLastLandedMoves[gActiveBank] == 0xFFFF)
|
||||
return FALSE;
|
||||
if (gUnknown_02024270[gActiveBank] == 0xFF)
|
||||
if (gLastHitBy[gActiveBank] == 0xFF)
|
||||
return FALSE;
|
||||
if (gBattleMoves[gUnknown_02024250[gActiveBank]].power == 0)
|
||||
if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0)
|
||||
return FALSE;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
@@ -411,10 +411,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
|
||||
else
|
||||
monAbility = gBaseStats[species].ability1;
|
||||
|
||||
moveFlags = AI_TypeCalc(gUnknown_02024250[gActiveBank], species, monAbility);
|
||||
moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBank], species, monAbility);
|
||||
if (moveFlags & flags)
|
||||
{
|
||||
bankIn1 = gUnknown_02024270[gActiveBank];
|
||||
bankIn1 = gLastHitBy[gActiveBank];
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ static void LinkOpponentHandleBallThrowAnim(void);
|
||||
static void LinkOpponentHandlePause(void);
|
||||
static void LinkOpponentHandleMoveAnimation(void);
|
||||
static void LinkOpponentHandlePrintString(void);
|
||||
static void LinkOpponentHandlePrintStringPlayerOnly(void);
|
||||
static void LinkOpponentHandlePrintSelectionString(void);
|
||||
static void LinkOpponentHandleChooseAction(void);
|
||||
static void LinkOpponentHandleUnknownYesNoBox(void);
|
||||
static void LinkOpponentHandleChooseMove(void);
|
||||
@@ -108,7 +108,7 @@ static void LinkOpponentHandleCmd39(void);
|
||||
static void LinkOpponentHandleCmd40(void);
|
||||
static void LinkOpponentHandleHitAnimation(void);
|
||||
static void LinkOpponentHandleCmd42(void);
|
||||
static void LinkOpponentHandleEffectivenessSound(void);
|
||||
static void LinkOpponentHandlePlaySE(void);
|
||||
static void LinkOpponentHandlePlayFanfareOrBGM(void);
|
||||
static void LinkOpponentHandleFaintingCry(void);
|
||||
static void LinkOpponentHandleIntroSlide(void);
|
||||
@@ -154,7 +154,7 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
LinkOpponentHandlePause,
|
||||
LinkOpponentHandleMoveAnimation,
|
||||
LinkOpponentHandlePrintString,
|
||||
LinkOpponentHandlePrintStringPlayerOnly,
|
||||
LinkOpponentHandlePrintSelectionString,
|
||||
LinkOpponentHandleChooseAction,
|
||||
LinkOpponentHandleUnknownYesNoBox,
|
||||
LinkOpponentHandleChooseMove,
|
||||
@@ -180,7 +180,7 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
LinkOpponentHandleCmd40,
|
||||
LinkOpponentHandleHitAnimation,
|
||||
LinkOpponentHandleCmd42,
|
||||
LinkOpponentHandleEffectivenessSound,
|
||||
LinkOpponentHandlePlaySE,
|
||||
LinkOpponentHandlePlayFanfareOrBGM,
|
||||
LinkOpponentHandleFaintingCry,
|
||||
LinkOpponentHandleIntroSlide,
|
||||
@@ -1505,7 +1505,7 @@ static void LinkOpponentHandlePrintString(void)
|
||||
sub_817C95C(*stringId);
|
||||
}
|
||||
|
||||
static void LinkOpponentHandlePrintStringPlayerOnly(void)
|
||||
static void LinkOpponentHandlePrintSelectionString(void)
|
||||
{
|
||||
LinkOpponentBufferExecCompleted();
|
||||
}
|
||||
@@ -1681,7 +1681,7 @@ static void LinkOpponentHandleCmd42(void)
|
||||
LinkOpponentBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void LinkOpponentHandleEffectivenessSound(void)
|
||||
static void LinkOpponentHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static void LinkPartnerHandleBallThrowAnim(void);
|
||||
static void LinkPartnerHandlePause(void);
|
||||
static void LinkPartnerHandleMoveAnimation(void);
|
||||
static void LinkPartnerHandlePrintString(void);
|
||||
static void LinkPartnerHandlePrintStringPlayerOnly(void);
|
||||
static void LinkPartnerHandlePrintSelectionString(void);
|
||||
static void LinkPartnerHandleChooseAction(void);
|
||||
static void LinkPartnerHandleUnknownYesNoBox(void);
|
||||
static void LinkPartnerHandleChooseMove(void);
|
||||
@@ -104,7 +104,7 @@ static void LinkPartnerHandleCmd39(void);
|
||||
static void LinkPartnerHandleCmd40(void);
|
||||
static void LinkPartnerHandleHitAnimation(void);
|
||||
static void LinkPartnerHandleCmd42(void);
|
||||
static void LinkPartnerHandleEffectivenessSound(void);
|
||||
static void LinkPartnerHandlePlaySE(void);
|
||||
static void LinkPartnerHandlePlayFanfareOrBGM(void);
|
||||
static void LinkPartnerHandleFaintingCry(void);
|
||||
static void LinkPartnerHandleIntroSlide(void);
|
||||
@@ -149,7 +149,7 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
LinkPartnerHandlePause,
|
||||
LinkPartnerHandleMoveAnimation,
|
||||
LinkPartnerHandlePrintString,
|
||||
LinkPartnerHandlePrintStringPlayerOnly,
|
||||
LinkPartnerHandlePrintSelectionString,
|
||||
LinkPartnerHandleChooseAction,
|
||||
LinkPartnerHandleUnknownYesNoBox,
|
||||
LinkPartnerHandleChooseMove,
|
||||
@@ -175,7 +175,7 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
LinkPartnerHandleCmd40,
|
||||
LinkPartnerHandleHitAnimation,
|
||||
LinkPartnerHandleCmd42,
|
||||
LinkPartnerHandleEffectivenessSound,
|
||||
LinkPartnerHandlePlaySE,
|
||||
LinkPartnerHandlePlayFanfareOrBGM,
|
||||
LinkPartnerHandleFaintingCry,
|
||||
LinkPartnerHandleIntroSlide,
|
||||
@@ -1327,7 +1327,7 @@ static void LinkPartnerHandlePrintString(void)
|
||||
sub_817C95C(*stringId);
|
||||
}
|
||||
|
||||
static void LinkPartnerHandlePrintStringPlayerOnly(void)
|
||||
static void LinkPartnerHandlePrintSelectionString(void)
|
||||
{
|
||||
LinkPartnerBufferExecCompleted();
|
||||
}
|
||||
@@ -1503,7 +1503,7 @@ static void LinkPartnerHandleCmd42(void)
|
||||
LinkPartnerBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void LinkPartnerHandleEffectivenessSound(void)
|
||||
static void LinkPartnerHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ static void OpponentHandleBallThrow(void);
|
||||
static void OpponentHandlePause(void);
|
||||
static void OpponentHandleMoveAnimation(void);
|
||||
static void OpponentHandlePrintString(void);
|
||||
static void OpponentHandlePrintStringPlayerOnly(void);
|
||||
static void OpponentHandlePrintSelectionString(void);
|
||||
static void OpponentHandleChooseAction(void);
|
||||
static void OpponentHandleUnknownYesNoBox(void);
|
||||
static void OpponentHandleChooseMove(void);
|
||||
@@ -109,7 +109,7 @@ static void OpponentHandleCmd39(void);
|
||||
static void OpponentHandleCmd40(void);
|
||||
static void OpponentHandleHitAnimation(void);
|
||||
static void OpponentHandleCmd42(void);
|
||||
static void OpponentHandleEffectivenessSound(void);
|
||||
static void OpponentHandlePlaySE(void);
|
||||
static void OpponentHandlePlayFanfareOrBGM(void);
|
||||
static void OpponentHandleFaintingCry(void);
|
||||
static void OpponentHandleIntroSlide(void);
|
||||
@@ -155,7 +155,7 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
OpponentHandlePause,
|
||||
OpponentHandleMoveAnimation,
|
||||
OpponentHandlePrintString,
|
||||
OpponentHandlePrintStringPlayerOnly,
|
||||
OpponentHandlePrintSelectionString,
|
||||
OpponentHandleChooseAction,
|
||||
OpponentHandleUnknownYesNoBox,
|
||||
OpponentHandleChooseMove,
|
||||
@@ -181,7 +181,7 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
OpponentHandleCmd40,
|
||||
OpponentHandleHitAnimation,
|
||||
OpponentHandleCmd42,
|
||||
OpponentHandleEffectivenessSound,
|
||||
OpponentHandlePlaySE,
|
||||
OpponentHandlePlayFanfareOrBGM,
|
||||
OpponentHandleFaintingCry,
|
||||
OpponentHandleIntroSlide,
|
||||
@@ -1537,7 +1537,7 @@ static void OpponentHandlePrintString(void)
|
||||
sub_81A57E4(gActiveBank, *stringId);
|
||||
}
|
||||
|
||||
static void OpponentHandlePrintStringPlayerOnly(void)
|
||||
static void OpponentHandlePrintSelectionString(void)
|
||||
{
|
||||
OpponentBufferExecCompleted();
|
||||
}
|
||||
@@ -1826,7 +1826,7 @@ static void OpponentHandleCmd42(void)
|
||||
OpponentBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void OpponentHandleEffectivenessSound(void)
|
||||
static void OpponentHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ static void PlayerHandleBallThrowAnim(void);
|
||||
static void PlayerHandlePause(void);
|
||||
static void PlayerHandleMoveAnimation(void);
|
||||
static void PlayerHandlePrintString(void);
|
||||
static void PlayerHandlePrintStringPlayerOnly(void);
|
||||
static void PlayerHandlePrintSelectionString(void);
|
||||
static void PlayerHandleChooseAction(void);
|
||||
static void PlayerHandleUnknownYesNoBox(void);
|
||||
static void PlayerHandleChooseMove(void);
|
||||
@@ -128,7 +128,7 @@ static void PlayerHandleCmd39(void);
|
||||
static void PlayerHandleCmd40(void);
|
||||
static void PlayerHandleHitAnimation(void);
|
||||
static void PlayerHandleCmd42(void);
|
||||
static void PlayerHandleEffectivenessSound(void);
|
||||
static void PlayerHandlePlaySE(void);
|
||||
static void PlayerHandlePlayFanfareOrBGM(void);
|
||||
static void PlayerHandleFaintingCry(void);
|
||||
static void PlayerHandleIntroSlide(void);
|
||||
@@ -189,7 +189,7 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
PlayerHandlePause,
|
||||
PlayerHandleMoveAnimation,
|
||||
PlayerHandlePrintString,
|
||||
PlayerHandlePrintStringPlayerOnly,
|
||||
PlayerHandlePrintSelectionString,
|
||||
PlayerHandleChooseAction,
|
||||
PlayerHandleUnknownYesNoBox,
|
||||
PlayerHandleChooseMove,
|
||||
@@ -215,7 +215,7 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
PlayerHandleCmd40,
|
||||
PlayerHandleHitAnimation,
|
||||
PlayerHandleCmd42,
|
||||
PlayerHandleEffectivenessSound,
|
||||
PlayerHandlePlaySE,
|
||||
PlayerHandlePlayFanfareOrBGM,
|
||||
PlayerHandleFaintingCry,
|
||||
PlayerHandleIntroSlide,
|
||||
@@ -2576,7 +2576,7 @@ static void PlayerHandlePrintString(void)
|
||||
sub_81A57E4(gActiveBank, *stringId);
|
||||
}
|
||||
|
||||
static void PlayerHandlePrintStringPlayerOnly(void)
|
||||
static void PlayerHandlePrintSelectionString(void)
|
||||
{
|
||||
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
|
||||
PlayerHandlePrintString();
|
||||
@@ -2913,7 +2913,7 @@ static void PlayerHandleCmd42(void)
|
||||
PlayerBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void PlayerHandleEffectivenessSound(void)
|
||||
static void PlayerHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static void PlayerPartnerHandleBallThrowAnim(void);
|
||||
static void PlayerPartnerHandlePause(void);
|
||||
static void PlayerPartnerHandleMoveAnimation(void);
|
||||
static void PlayerPartnerHandlePrintString(void);
|
||||
static void PlayerPartnerHandlePrintStringPlayerOnly(void);
|
||||
static void PlayerPartnerHandlePrintSelectionString(void);
|
||||
static void PlayerPartnerHandleChooseAction(void);
|
||||
static void PlayerPartnerHandleUnknownYesNoBox(void);
|
||||
static void PlayerPartnerHandleChooseMove(void);
|
||||
@@ -104,7 +104,7 @@ static void PlayerPartnerHandleCmd39(void);
|
||||
static void PlayerPartnerHandleCmd40(void);
|
||||
static void PlayerPartnerHandleHitAnimation(void);
|
||||
static void PlayerPartnerHandleCmd42(void);
|
||||
static void PlayerPartnerHandleEffectivenessSound(void);
|
||||
static void PlayerPartnerHandlePlaySE(void);
|
||||
static void PlayerPartnerHandlePlayFanfareOrBGM(void);
|
||||
static void PlayerPartnerHandleFaintingCry(void);
|
||||
static void PlayerPartnerHandleIntroSlide(void);
|
||||
@@ -155,7 +155,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
PlayerPartnerHandlePause,
|
||||
PlayerPartnerHandleMoveAnimation,
|
||||
PlayerPartnerHandlePrintString,
|
||||
PlayerPartnerHandlePrintStringPlayerOnly,
|
||||
PlayerPartnerHandlePrintSelectionString,
|
||||
PlayerPartnerHandleChooseAction,
|
||||
PlayerPartnerHandleUnknownYesNoBox,
|
||||
PlayerPartnerHandleChooseMove,
|
||||
@@ -181,7 +181,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
PlayerPartnerHandleCmd40,
|
||||
PlayerPartnerHandleHitAnimation,
|
||||
PlayerPartnerHandleCmd42,
|
||||
PlayerPartnerHandleEffectivenessSound,
|
||||
PlayerPartnerHandlePlaySE,
|
||||
PlayerPartnerHandlePlayFanfareOrBGM,
|
||||
PlayerPartnerHandleFaintingCry,
|
||||
PlayerPartnerHandleIntroSlide,
|
||||
@@ -1519,7 +1519,7 @@ static void PlayerPartnerHandlePrintString(void)
|
||||
gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter2;
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandlePrintStringPlayerOnly(void)
|
||||
static void PlayerPartnerHandlePrintSelectionString(void)
|
||||
{
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
}
|
||||
@@ -1756,7 +1756,7 @@ static void PlayerPartnerHandleCmd42(void)
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void PlayerPartnerHandleEffectivenessSound(void)
|
||||
static void PlayerPartnerHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ static void RecordedOpponentHandleBallThrowAnim(void);
|
||||
static void RecordedOpponentHandlePause(void);
|
||||
static void RecordedOpponentHandleMoveAnimation(void);
|
||||
static void RecordedOpponentHandlePrintString(void);
|
||||
static void RecordedOpponentHandlePrintStringPlayerOnly(void);
|
||||
static void RecordedOpponentHandlePrintSelectionString(void);
|
||||
static void RecordedOpponentHandleChooseAction(void);
|
||||
static void RecordedOpponentHandleUnknownYesNoBox(void);
|
||||
static void RecordedOpponentHandleChooseMove(void);
|
||||
@@ -107,7 +107,7 @@ static void RecordedOpponentHandleCmd39(void);
|
||||
static void RecordedOpponentHandleCmd40(void);
|
||||
static void RecordedOpponentHandleHitAnimation(void);
|
||||
static void RecordedOpponentHandleCmd42(void);
|
||||
static void RecordedOpponentHandleEffectivenessSound(void);
|
||||
static void RecordedOpponentHandlePlaySE(void);
|
||||
static void RecordedOpponentHandlePlayFanfareOrBGM(void);
|
||||
static void RecordedOpponentHandleFaintingCry(void);
|
||||
static void RecordedOpponentHandleIntroSlide(void);
|
||||
@@ -153,7 +153,7 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void
|
||||
RecordedOpponentHandlePause,
|
||||
RecordedOpponentHandleMoveAnimation,
|
||||
RecordedOpponentHandlePrintString,
|
||||
RecordedOpponentHandlePrintStringPlayerOnly,
|
||||
RecordedOpponentHandlePrintSelectionString,
|
||||
RecordedOpponentHandleChooseAction,
|
||||
RecordedOpponentHandleUnknownYesNoBox,
|
||||
RecordedOpponentHandleChooseMove,
|
||||
@@ -179,7 +179,7 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void
|
||||
RecordedOpponentHandleCmd40,
|
||||
RecordedOpponentHandleHitAnimation,
|
||||
RecordedOpponentHandleCmd42,
|
||||
RecordedOpponentHandleEffectivenessSound,
|
||||
RecordedOpponentHandlePlaySE,
|
||||
RecordedOpponentHandlePlayFanfareOrBGM,
|
||||
RecordedOpponentHandleFaintingCry,
|
||||
RecordedOpponentHandleIntroSlide,
|
||||
@@ -1435,7 +1435,7 @@ static void RecordedOpponentHandlePrintString(void)
|
||||
gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter;
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandlePrintStringPlayerOnly(void)
|
||||
static void RecordedOpponentHandlePrintSelectionString(void)
|
||||
{
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
}
|
||||
@@ -1625,7 +1625,7 @@ static void RecordedOpponentHandleCmd42(void)
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void RecordedOpponentHandleEffectivenessSound(void)
|
||||
static void RecordedOpponentHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ static void RecordedPlayerHandleBallThrowAnim(void);
|
||||
static void RecordedPlayerHandlePause(void);
|
||||
static void RecordedPlayerHandleMoveAnimation(void);
|
||||
static void RecordedPlayerHandlePrintString(void);
|
||||
static void RecordedPlayerHandlePrintStringPlayerOnly(void);
|
||||
static void RecordedPlayerHandlePrintSelectionString(void);
|
||||
static void RecordedPlayerHandleChooseAction(void);
|
||||
static void RecordedPlayerHandleUnknownYesNoBox(void);
|
||||
static void RecordedPlayerHandleChooseMove(void);
|
||||
@@ -107,7 +107,7 @@ static void RecordedPlayerHandleCmd39(void);
|
||||
static void RecordedPlayerHandleCmd40(void);
|
||||
static void RecordedPlayerHandleHitAnimation(void);
|
||||
static void RecordedPlayerHandleCmd42(void);
|
||||
static void RecordedPlayerHandleEffectivenessSound(void);
|
||||
static void RecordedPlayerHandlePlaySE(void);
|
||||
static void RecordedPlayerHandlePlayFanfareOrBGM(void);
|
||||
static void RecordedPlayerHandleFaintingCry(void);
|
||||
static void RecordedPlayerHandleIntroSlide(void);
|
||||
@@ -152,7 +152,7 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void)
|
||||
RecordedPlayerHandlePause,
|
||||
RecordedPlayerHandleMoveAnimation,
|
||||
RecordedPlayerHandlePrintString,
|
||||
RecordedPlayerHandlePrintStringPlayerOnly,
|
||||
RecordedPlayerHandlePrintSelectionString,
|
||||
RecordedPlayerHandleChooseAction,
|
||||
RecordedPlayerHandleUnknownYesNoBox,
|
||||
RecordedPlayerHandleChooseMove,
|
||||
@@ -178,7 +178,7 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void)
|
||||
RecordedPlayerHandleCmd40,
|
||||
RecordedPlayerHandleHitAnimation,
|
||||
RecordedPlayerHandleCmd42,
|
||||
RecordedPlayerHandleEffectivenessSound,
|
||||
RecordedPlayerHandlePlaySE,
|
||||
RecordedPlayerHandlePlayFanfareOrBGM,
|
||||
RecordedPlayerHandleFaintingCry,
|
||||
RecordedPlayerHandleIntroSlide,
|
||||
@@ -1437,7 +1437,7 @@ static void RecordedPlayerHandlePrintString(void)
|
||||
gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter;
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandlePrintStringPlayerOnly(void)
|
||||
static void RecordedPlayerHandlePrintSelectionString(void)
|
||||
{
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
}
|
||||
@@ -1644,7 +1644,7 @@ static void RecordedPlayerHandleCmd42(void)
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void RecordedPlayerHandleEffectivenessSound(void)
|
||||
static void RecordedPlayerHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ static void SafariHandleBallThrowAnim(void);
|
||||
static void SafariHandlePause(void);
|
||||
static void SafariHandleMoveAnimation(void);
|
||||
static void SafariHandlePrintString(void);
|
||||
static void SafariHandlePrintStringPlayerOnly(void);
|
||||
static void SafariHandlePrintSelectionString(void);
|
||||
static void SafariHandleChooseAction(void);
|
||||
static void SafariHandleUnknownYesNoBox(void);
|
||||
static void SafariHandleChooseMove(void);
|
||||
@@ -92,7 +92,7 @@ static void SafariHandleCmd39(void);
|
||||
static void SafariHandleCmd40(void);
|
||||
static void SafariHandleHitAnimation(void);
|
||||
static void SafariHandleCmd42(void);
|
||||
static void SafariHandleEffectivenessSound(void);
|
||||
static void SafariHandlePlaySE(void);
|
||||
static void SafariHandlePlayFanfareOrBGM(void);
|
||||
static void SafariHandleFaintingCry(void);
|
||||
static void SafariHandleIntroSlide(void);
|
||||
@@ -130,7 +130,7 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
SafariHandlePause,
|
||||
SafariHandleMoveAnimation,
|
||||
SafariHandlePrintString,
|
||||
SafariHandlePrintStringPlayerOnly,
|
||||
SafariHandlePrintSelectionString,
|
||||
SafariHandleChooseAction,
|
||||
SafariHandleUnknownYesNoBox,
|
||||
SafariHandleChooseMove,
|
||||
@@ -156,7 +156,7 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
SafariHandleCmd40,
|
||||
SafariHandleHitAnimation,
|
||||
SafariHandleCmd42,
|
||||
SafariHandleEffectivenessSound,
|
||||
SafariHandlePlaySE,
|
||||
SafariHandlePlayFanfareOrBGM,
|
||||
SafariHandleFaintingCry,
|
||||
SafariHandleIntroSlide,
|
||||
@@ -449,7 +449,7 @@ static void SafariHandlePrintString(void)
|
||||
gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter;
|
||||
}
|
||||
|
||||
static void SafariHandlePrintStringPlayerOnly(void)
|
||||
static void SafariHandlePrintSelectionString(void)
|
||||
{
|
||||
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
|
||||
SafariHandlePrintString();
|
||||
@@ -607,7 +607,7 @@ static void SafariHandleCmd42(void)
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void SafariHandleEffectivenessSound(void)
|
||||
static void SafariHandlePlaySE(void)
|
||||
{
|
||||
s8 pan;
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ static void WallyHandleBallThrowAnim(void);
|
||||
static void WallyHandlePause(void);
|
||||
static void WallyHandleMoveAnimation(void);
|
||||
static void WallyHandlePrintString(void);
|
||||
static void WallyHandlePrintStringPlayerOnly(void);
|
||||
static void WallyHandlePrintSelectionString(void);
|
||||
static void WallyHandleChooseAction(void);
|
||||
static void WallyHandleUnknownYesNoBox(void);
|
||||
static void WallyHandleChooseMove(void);
|
||||
@@ -112,7 +112,7 @@ static void WallyHandleCmd39(void);
|
||||
static void WallyHandleCmd40(void);
|
||||
static void WallyHandleHitAnimation(void);
|
||||
static void WallyHandleCmd42(void);
|
||||
static void WallyHandleEffectivenessSound(void);
|
||||
static void WallyHandlePlaySE(void);
|
||||
static void WallyHandlePlayFanfareOrBGM(void);
|
||||
static void WallyHandleFaintingCry(void);
|
||||
static void WallyHandleIntroSlide(void);
|
||||
@@ -155,7 +155,7 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
WallyHandlePause,
|
||||
WallyHandleMoveAnimation,
|
||||
WallyHandlePrintString,
|
||||
WallyHandlePrintStringPlayerOnly,
|
||||
WallyHandlePrintSelectionString,
|
||||
WallyHandleChooseAction,
|
||||
WallyHandleUnknownYesNoBox,
|
||||
WallyHandleChooseMove,
|
||||
@@ -181,7 +181,7 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
|
||||
WallyHandleCmd40,
|
||||
WallyHandleHitAnimation,
|
||||
WallyHandleCmd42,
|
||||
WallyHandleEffectivenessSound,
|
||||
WallyHandlePlaySE,
|
||||
WallyHandlePlayFanfareOrBGM,
|
||||
WallyHandleFaintingCry,
|
||||
WallyHandleIntroSlide,
|
||||
@@ -1211,7 +1211,7 @@ static void WallyHandlePrintString(void)
|
||||
gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter;
|
||||
}
|
||||
|
||||
static void WallyHandlePrintStringPlayerOnly(void)
|
||||
static void WallyHandlePrintSelectionString(void)
|
||||
{
|
||||
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
|
||||
WallyHandlePrintString();
|
||||
@@ -1419,7 +1419,7 @@ static void WallyHandleCmd42(void)
|
||||
WallyBufferExecCompleted();
|
||||
}
|
||||
|
||||
static void WallyHandleEffectivenessSound(void)
|
||||
static void WallyHandlePlaySE(void)
|
||||
{
|
||||
PlaySE(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
|
||||
WallyBufferExecCompleted();
|
||||
|
||||
@@ -37,6 +37,9 @@ extern u16 gBattleWeather;
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern u16 gCurrentMove;
|
||||
extern u16 gLastUsedMove;
|
||||
extern u16 gChosenMove;
|
||||
extern u16 gLastUsedItem;
|
||||
extern u8 gBattleOutcome;
|
||||
extern u8 gLastUsedAbility;
|
||||
extern u8 gStringBank;
|
||||
|
||||
@@ -1118,7 +1121,7 @@ void EmitPrintString(u8 bufferId, u16 stringID)
|
||||
|
||||
stringInfo = (struct StringInfoBattle*)(&sBattleBuffersTransferData[4]);
|
||||
stringInfo->currentMove = gCurrentMove;
|
||||
stringInfo->lastMove = gLastUsedMove;
|
||||
stringInfo->originallyUsedMove = gChosenMove;
|
||||
stringInfo->lastItem = gLastUsedItem;
|
||||
stringInfo->lastAbility = gLastUsedAbility;
|
||||
stringInfo->scrActive = gBattleScripting.bank;
|
||||
@@ -1138,10 +1141,10 @@ void EmitPrintString(u8 bufferId, u16 stringID)
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sizeof(struct StringInfoBattle) + 4);
|
||||
}
|
||||
|
||||
void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringID)
|
||||
void EmitPrintSelectionString(u8 bufferId, u16 stringID)
|
||||
{
|
||||
s32 i;
|
||||
struct StringInfoBattle* stringInfo;
|
||||
struct StringInfoBattle *stringInfo;
|
||||
|
||||
sBattleBuffersTransferData[0] = CONTROLLER_PRINTSTRINGPLAYERONLY;
|
||||
sBattleBuffersTransferData[1] = CONTROLLER_PRINTSTRINGPLAYERONLY;
|
||||
@@ -1150,7 +1153,7 @@ void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringID)
|
||||
|
||||
stringInfo = (struct StringInfoBattle*)(&sBattleBuffersTransferData[4]);
|
||||
stringInfo->currentMove = gCurrentMove;
|
||||
stringInfo->lastMove = gLastUsedMove;
|
||||
stringInfo->originallyUsedMove = gChosenMove;
|
||||
stringInfo->lastItem = gLastUsedItem;
|
||||
stringInfo->lastAbility = gLastUsedAbility;
|
||||
stringInfo->scrActive = gBattleScripting.bank;
|
||||
@@ -1425,7 +1428,7 @@ void EmitCmd42(u8 bufferId)
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4);
|
||||
}
|
||||
|
||||
void EmitEffectivenessSound(u8 bufferId, u16 songId)
|
||||
void EmitPlaySE(u8 bufferId, u16 songId)
|
||||
{
|
||||
sBattleBuffersTransferData[0] = CONTROLLER_EFFECTIVENESSSOUND;
|
||||
sBattleBuffersTransferData[1] = songId;
|
||||
|
||||
+235
-55
@@ -59,7 +59,7 @@ extern const u8* GetTrainer2LoseText(void); // battle_setup
|
||||
extern void GetFrontierTrainerName(u8 *dst, u16 trainerId);
|
||||
extern s32 GetStringCenterAlignXOffsetWithLetterSpacing(u8 fontId, const u8 *str, s32 totalWidth, s16 letterSpacing);
|
||||
extern u8 GetTextSpeedInRecordedBattle(void);
|
||||
extern u8 sav2_get_text_speed(void);
|
||||
extern u8 GetPlayerTextSpeed(void);
|
||||
|
||||
// this file's functions
|
||||
static void sub_814F8F8(u8 *textPtr);
|
||||
@@ -932,58 +932,237 @@ const u16 gSandStormHailDmgStringIds[] =
|
||||
STRINGID_PKMNBUFFETEDBYSANDSTORM, STRINGID_PKMNPELTEDBYHAIL
|
||||
};
|
||||
|
||||
// todo once battlescripts are dumped
|
||||
const u16 gTooLazyToSplitThemStringIds[] =
|
||||
const u16 gSandStormHailEndStringIds[] =
|
||||
{
|
||||
STRINGID_SANDSTORMSUBSIDED, STRINGID_HAILSTOPPED, STRINGID_RAINCONTINUES, STRINGID_DOWNPOURCONTINUES,
|
||||
STRINGID_RAINSTOPPED, STRINGID_PKMNPROTECTEDITSELF2, STRINGID_PKMNBRACEDITSELF,
|
||||
STRINGID_BUTITFAILED, STRINGID_BUTITFAILED, STRINGID_PKMNRAISEDDEF,
|
||||
STRINGID_PKMNRAISEDDEFALITTLE, STRINGID_PKMNRAISEDSPDEF, STRINGID_PKMNRAISEDSPDEFALITTLE,
|
||||
STRINGID_PKMNCOVEREDBYVEIL, STRINGID_PKMNSEEDED, STRINGID_PKMNEVADEDATTACK,
|
||||
STRINGID_SANDSTORMSUBSIDED, STRINGID_HAILSTOPPED
|
||||
};
|
||||
|
||||
const u16 gRainContinuesStringIds[] =
|
||||
{
|
||||
STRINGID_RAINCONTINUES, STRINGID_DOWNPOURCONTINUES, STRINGID_RAINSTOPPED
|
||||
};
|
||||
|
||||
const u16 gProtectLikeUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNPROTECTEDITSELF2, STRINGID_PKMNBRACEDITSELF, STRINGID_BUTITFAILED
|
||||
};
|
||||
|
||||
const u16 gReflectLightScreenSafeguardStringIds[] =
|
||||
{
|
||||
STRINGID_BUTITFAILED, STRINGID_PKMNRAISEDDEF, STRINGID_PKMNRAISEDDEFALITTLE,
|
||||
STRINGID_PKMNRAISEDSPDEF, STRINGID_PKMNRAISEDSPDEFALITTLE, STRINGID_PKMNCOVEREDBYVEIL
|
||||
};
|
||||
|
||||
const u16 gLeechSeedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSEEDED, STRINGID_PKMNEVADEDATTACK,
|
||||
STRINGID_ITDOESNTAFFECT, STRINGID_PKMNSAPPEDBYLEECHSEED, STRINGID_ITSUCKEDLIQUIDOOZE,
|
||||
STRINGID_PKMNWENTTOSLEEP, STRINGID_PKMNSLEPTHEALTHY, STRINGID_PKMNMAKINGUPROAR,
|
||||
STRINGID_PKMNCALMEDDOWN, STRINGID_PKMNSTOCKPILED, STRINGID_PKMNCANTSTOCKPILE,
|
||||
STRINGID_PKMNWOKEUP, STRINGID_PKMNWOKEUPINUPROAR, STRINGID_FAILEDTOSWALLOW,
|
||||
STRINGID_PKMNHPFULL, STRINGID_PKMNCANTSLEEPINUPROAR2, STRINGID_UPROARKEPTPKMNAWAKE,
|
||||
STRINGID_PKMNSTAYEDAWAKEUSING, STRINGID_PKMNSSTATCHANGED, STRINGID_PKMNSSTATCHANGED2,
|
||||
STRINGID_STATSWONTINCREASE, STRINGID_EMPTYSTRING3, STRINGID_USINGXTHEYOFZN,
|
||||
STRINGID_PKMNUSEDXTOGETPUMPED, STRINGID_PKMNSSTATCHANGED3, STRINGID_PKMNSSTATCHANGED4,
|
||||
STRINGID_STATSWONTDECREASE, STRINGID_EMPTYSTRING3, STRINGID_PKMNWHIPPEDWHIRLWIND,
|
||||
STRINGID_PKMNTOOKSUNLIGHT, STRINGID_PKMNLOWEREDHEAD, STRINGID_PKMNISGLOWING,
|
||||
STRINGID_PKMNFLEWHIGH, STRINGID_PKMNDUGHOLE, STRINGID_PKMNHIDUNDERWATER,
|
||||
STRINGID_PKMNSPRANGUP, STRINGID_PKMNSQUEEZEDBYBIND, STRINGID_PKMNWRAPPEDBY,
|
||||
STRINGID_PKMNTRAPPEDINVORTEX, STRINGID_PKMNCLAMPED, STRINGID_PKMNTRAPPEDINVORTEX,
|
||||
STRINGID_PKMNTRAPPEDBYSANDTOMB, STRINGID_PKMNSHROUDEDINMIST, STRINGID_BUTITFAILED,
|
||||
STRINGID_PKMNGETTINGPUMPED, STRINGID_BUTITFAILED, STRINGID_PKMNTRANSFORMEDINTO,
|
||||
STRINGID_BUTITFAILED, STRINGID_PKMNMADESUBSTITUTE, STRINGID_TOOWEAKFORSUBSTITUTE,
|
||||
STRINGID_PKMNWASPOISONED, STRINGID_PKMNPOISONEDBY, STRINGID_PKMNWASPARALYZED,
|
||||
STRINGID_PKMNWASPARALYZEDBY, STRINGID_PKMNFELLASLEEP, STRINGID_PKMNMADESLEEP,
|
||||
STRINGID_PKMNWASBURNED, STRINGID_PKMNBURNEDBY, STRINGID_PKMNWASFROZEN,
|
||||
STRINGID_PKMNFROZENBY, STRINGID_PKMNWASDEFROSTED2, STRINGID_PKMNWASDEFROSTEDBY,
|
||||
STRINGID_ATTACKMISSED, STRINGID_PKMNUNAFFECTED, STRINGID_PKMNFELLINLOVE,
|
||||
STRINGID_PKMNSXINFATUATEDY, STRINGID_PKMNENERGYDRAINED, STRINGID_ITSUCKEDLIQUIDOOZE,
|
||||
STRINGID_ELECTRICITYWEAKENED, STRINGID_FIREWEAKENED, STRINGID_BELLCHIMED,
|
||||
STRINGID_BELLCHIMED, STRINGID_BELLCHIMED, STRINGID_BELLCHIMED,
|
||||
STRINGID_SOOTHINGAROMA, STRINGID_PKMNFORESAWATTACK, STRINGID_PKMNCHOSEXASDESTINY,
|
||||
STRINGID_PKMNBROKEFREE, STRINGID_ITAPPEAREDCAUGHT, STRINGID_AARGHALMOSTHADIT,
|
||||
STRINGID_SHOOTSOCLOSE, STRINGID_ITISRAINING, STRINGID_ITISRAINING,
|
||||
};
|
||||
|
||||
const u16 gRestUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWENTTOSLEEP, STRINGID_PKMNSLEPTHEALTHY
|
||||
};
|
||||
|
||||
const u16 gUproarOverTurnStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNMAKINGUPROAR, STRINGID_PKMNCALMEDDOWN
|
||||
};
|
||||
|
||||
const u16 gStockpileUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSTOCKPILED, STRINGID_PKMNCANTSTOCKPILE,
|
||||
};
|
||||
|
||||
const u16 gWokeUpStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWOKEUP, STRINGID_PKMNWOKEUPINUPROAR
|
||||
};
|
||||
|
||||
const u16 gSwallowFailStringIds[] =
|
||||
{
|
||||
STRINGID_FAILEDTOSWALLOW, STRINGID_PKMNHPFULL
|
||||
};
|
||||
|
||||
const u16 gUproarAwakeStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNCANTSLEEPINUPROAR2, STRINGID_UPROARKEPTPKMNAWAKE, STRINGID_PKMNSTAYEDAWAKEUSING
|
||||
};
|
||||
|
||||
const u16 gStatUpStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSSTATCHANGED, STRINGID_PKMNSSTATCHANGED2, STRINGID_STATSWONTINCREASE,
|
||||
STRINGID_EMPTYSTRING3, STRINGID_USINGXTHEYOFZN, STRINGID_PKMNUSEDXTOGETPUMPED
|
||||
};
|
||||
|
||||
const u16 gStatDownStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSSTATCHANGED3, STRINGID_PKMNSSTATCHANGED4, STRINGID_STATSWONTDECREASE, STRINGID_EMPTYSTRING3
|
||||
};
|
||||
|
||||
const u16 gFirstTurnOfTwoStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWHIPPEDWHIRLWIND, STRINGID_PKMNTOOKSUNLIGHT, STRINGID_PKMNLOWEREDHEAD, STRINGID_PKMNISGLOWING,
|
||||
STRINGID_PKMNFLEWHIGH, STRINGID_PKMNDUGHOLE, STRINGID_PKMNHIDUNDERWATER, STRINGID_PKMNSPRANGUP
|
||||
};
|
||||
|
||||
const u16 gWrappedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSQUEEZEDBYBIND, STRINGID_PKMNWRAPPEDBY, STRINGID_PKMNTRAPPEDINVORTEX,
|
||||
STRINGID_PKMNCLAMPED, STRINGID_PKMNTRAPPEDINVORTEX, STRINGID_PKMNTRAPPEDBYSANDTOMB
|
||||
};
|
||||
|
||||
const u16 gMistUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSHROUDEDINMIST, STRINGID_BUTITFAILED
|
||||
};
|
||||
|
||||
const u16 gFocusEnergyUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNGETTINGPUMPED, STRINGID_BUTITFAILED
|
||||
};
|
||||
|
||||
const u16 gTransformUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNTRANSFORMEDINTO, STRINGID_BUTITFAILED
|
||||
};
|
||||
|
||||
const u16 gSubsituteUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNMADESUBSTITUTE, STRINGID_TOOWEAKFORSUBSTITUTE
|
||||
};
|
||||
|
||||
const u16 gGotPoisonedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWASPOISONED, STRINGID_PKMNPOISONEDBY
|
||||
};
|
||||
|
||||
const u16 gGotParalyzedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWASPARALYZED, STRINGID_PKMNWASPARALYZEDBY
|
||||
};
|
||||
|
||||
const u16 gFellAsleepStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNFELLASLEEP, STRINGID_PKMNMADESLEEP,
|
||||
};
|
||||
|
||||
const u16 gGotBurnedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWASBURNED, STRINGID_PKMNBURNEDBY
|
||||
};
|
||||
|
||||
const u16 gGotFrozenStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWASFROZEN, STRINGID_PKMNFROZENBY
|
||||
};
|
||||
|
||||
const u16 gGotDefrostedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNWASDEFROSTED2, STRINGID_PKMNWASDEFROSTEDBY
|
||||
};
|
||||
|
||||
const u16 gKOFailedStringIds[] =
|
||||
{
|
||||
STRINGID_ATTACKMISSED, STRINGID_PKMNUNAFFECTED
|
||||
};
|
||||
|
||||
const u16 gAttractUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNFELLINLOVE, STRINGID_PKMNSXINFATUATEDY
|
||||
};
|
||||
|
||||
const u16 gLeechSeedDrainStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNENERGYDRAINED, STRINGID_ITSUCKEDLIQUIDOOZE
|
||||
};
|
||||
|
||||
const u16 gSportsUsedStringIds[] =
|
||||
{
|
||||
STRINGID_ELECTRICITYWEAKENED, STRINGID_FIREWEAKENED
|
||||
};
|
||||
|
||||
const u16 gPartyStatusHealStringIds[] =
|
||||
{
|
||||
STRINGID_BELLCHIMED, STRINGID_BELLCHIMED, STRINGID_BELLCHIMED, STRINGID_BELLCHIMED,
|
||||
// interesting how there are four instances of the same string
|
||||
STRINGID_SOOTHINGAROMA
|
||||
};
|
||||
|
||||
const u16 gFutureMoveUsedStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNFORESAWATTACK, STRINGID_PKMNCHOSEXASDESTINY
|
||||
};
|
||||
|
||||
const u16 gBallEscapeStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNBROKEFREE, STRINGID_ITAPPEAREDCAUGHT, STRINGID_AARGHALMOSTHADIT, STRINGID_SHOOTSOCLOSE
|
||||
};
|
||||
|
||||
const u16 gWeatherContinuesStringIds[] =
|
||||
{
|
||||
STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING,
|
||||
STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING,
|
||||
STRINGID_SANDSTORMISRAGING, STRINGID_ITISRAINING, STRINGID_ITISRAINING,
|
||||
STRINGID_ITISRAINING, STRINGID_SUNLIGHTSTRONG, STRINGID_ITISRAINING,
|
||||
STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_PKMNLOAFING,
|
||||
STRINGID_PKMNWONTOBEY, STRINGID_PKMNTURNEDAWAY, STRINGID_PKMNPRETENDNOTNOTICE,
|
||||
STRINGID_PKMNINCAPABLEOFPOWER, STRINGID_CREPTCLOSER, STRINGID_CANTGETCLOSER,
|
||||
STRINGID_PKMNCURIOUSABOUTX, STRINGID_PKMNENTHRALLEDBYX, STRINGID_PKMNIGNOREDX,
|
||||
STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_SANDSTORMISRAGING,
|
||||
STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING,
|
||||
STRINGID_SUNLIGHTSTRONG, STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING
|
||||
};
|
||||
|
||||
const u16 gInobedientStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNLOAFING, STRINGID_PKMNWONTOBEY, STRINGID_PKMNTURNEDAWAY,
|
||||
STRINGID_PKMNPRETENDNOTNOTICE, STRINGID_PKMNINCAPABLEOFPOWER
|
||||
};
|
||||
|
||||
const u16 gSafariGetNearStringIds[] =
|
||||
{
|
||||
STRINGID_CREPTCLOSER, STRINGID_CANTGETCLOSER
|
||||
};
|
||||
|
||||
const u16 gSafariPokeblockResultStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNCURIOUSABOUTX, STRINGID_PKMNENTHRALLEDBYX, STRINGID_PKMNIGNOREDX
|
||||
};
|
||||
|
||||
const u16 gTrainerItemCuredStatusStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSITEMSNAPPEDOUT, STRINGID_PKMNSITEMCUREDPARALYSIS, STRINGID_PKMNSITEMDEFROSTEDIT,
|
||||
STRINGID_PKMNSITEMHEALEDBURN, STRINGID_PKMNSITEMCUREDPOISON, STRINGID_PKMNSITEMWOKEIT,
|
||||
STRINGID_PKMNSITEMCUREDPROBLEM, STRINGID_PKMNSITEMNORMALIZEDSTATUS, STRINGID_PKMNSXPREVENTSBURNS,
|
||||
STRINGID_PKMNSXPREVENTSYSZ, STRINGID_PKMNSXHADNOEFFECTONY, STRINGID_PKMNPREVENTSPARALYSISWITH,
|
||||
STRINGID_PKMNSXPREVENTSYSZ, STRINGID_PKMNSXHADNOEFFECTONY, STRINGID_PKMNPREVENTSPOISONINGWITH,
|
||||
STRINGID_PKMNSXPREVENTSYSZ, STRINGID_PKMNSXHADNOEFFECTONY, STRINGID_PKMNOBTAINEDX,
|
||||
STRINGID_PKMNOBTAINEDX2, STRINGID_PKMNOBTAINEDXYOBTAINEDZ, STRINGID_PKMNRAISEDFIREPOWERWITH,
|
||||
STRINGID_PKMNSXMADEYINEFFECTIVE, STRINGID_PKMNTRANSFERREDSOMEONESPC, STRINGID_PKMNTRANSFERREDLANETTESPC,
|
||||
STRINGID_PKMNBOXSOMEONESPCFULL, STRINGID_PKMNBOXLANETTESPCFULL,
|
||||
STRINGID_PKMNSITEMHEALEDBURN, STRINGID_PKMNSITEMCUREDPOISON, STRINGID_PKMNSITEMWOKEIT
|
||||
};
|
||||
|
||||
const u16 gBerryEffectStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSITEMCUREDPROBLEM, STRINGID_PKMNSITEMNORMALIZEDSTATUS
|
||||
};
|
||||
|
||||
const u16 gBRNPreventionStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNSXPREVENTSBURNS, STRINGID_PKMNSXPREVENTSYSZ, STRINGID_PKMNSXHADNOEFFECTONY
|
||||
};
|
||||
|
||||
const u16 gPRLZPreventionStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNPREVENTSPARALYSISWITH, STRINGID_PKMNSXPREVENTSYSZ, STRINGID_PKMNSXHADNOEFFECTONY
|
||||
};
|
||||
|
||||
const u16 gPSNPreventionStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNPREVENTSPOISONINGWITH, STRINGID_PKMNSXPREVENTSYSZ, STRINGID_PKMNSXHADNOEFFECTONY
|
||||
};
|
||||
|
||||
const u16 gItemSwapStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNOBTAINEDX, STRINGID_PKMNOBTAINEDX2, STRINGID_PKMNOBTAINEDXYOBTAINEDZ
|
||||
};
|
||||
|
||||
const u16 gFlashFireStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNRAISEDFIREPOWERWITH, STRINGID_PKMNSXMADEYINEFFECTIVE
|
||||
};
|
||||
|
||||
const u16 gCaughtMonStringIds[] =
|
||||
{
|
||||
STRINGID_PKMNTRANSFERREDSOMEONESPC, STRINGID_PKMNTRANSFERREDLANETTESPC, STRINGID_PKMNBOXSOMEONESPCFULL, STRINGID_PKMNBOXLANETTESPCFULL,
|
||||
};
|
||||
|
||||
const u16 gTrappingMoves[] =
|
||||
@@ -1102,9 +1281,10 @@ const u8 gText_PkmnGettingIntoPosition[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is
|
||||
const u8 gText_PkmnBeganGrowlingDeeply[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} began growling deeply!");
|
||||
const u8 gText_PkmnEagerForMore[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is eager for more!");
|
||||
|
||||
const u16 gUnknown_085CCF0A[] =
|
||||
const u16 gStringIds_85CCF0A[] =
|
||||
{
|
||||
0x016E, 0x016F, 0x0170, 0x0171
|
||||
STRINGID_GLINTAPPEARSINEYE, STRINGID_PKMNGETTINGINTOPOSITION,
|
||||
STRINGID_PKMNBEGANGROWLINGDEEPLY, STRINGID_PKMNEAGERFORMORE
|
||||
};
|
||||
|
||||
const u8 gText_RefIfNothingIsDecided[] = _("REFEREE: If nothing is decided in\n3 turns, we will go to judging!");
|
||||
@@ -1736,11 +1916,11 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
|
||||
else
|
||||
toCpy = gMoveNames[gStringInfo->currentMove];
|
||||
break;
|
||||
case B_TXT_LAST_MOVE: // last used move name
|
||||
if (gStringInfo->lastMove > LAST_MOVE_INDEX)
|
||||
case B_TXT_LAST_MOVE: // originally used move name
|
||||
if (gStringInfo->originallyUsedMove > LAST_MOVE_INDEX)
|
||||
toCpy = gText_UnknownMoveTypes[gBattleStruct->stringMoveType];
|
||||
else
|
||||
toCpy = gMoveNames[gStringInfo->lastMove];
|
||||
toCpy = gMoveNames[gStringInfo->originallyUsedMove];
|
||||
break;
|
||||
case B_TXT_LAST_ITEM: // last used item
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
|
||||
@@ -2118,7 +2298,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
|
||||
StringGetEnd10(dst);
|
||||
srcID += 3;
|
||||
break;
|
||||
case B_BUFF_NEGATIVE_FLAVOUR: // flavour table
|
||||
case B_BUFF_NEGATIVE_FLAVOR: // flavor table
|
||||
StringAppend(dst, gPokeblockWasTooXStringTable[src[srcID + 1]]);
|
||||
srcID += 2;
|
||||
break;
|
||||
@@ -2266,7 +2446,7 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1)
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
|
||||
speed = sRecordedBattleTextSpeeds[GetTextSpeedInRecordedBattle()];
|
||||
else
|
||||
speed = sav2_get_text_speed();
|
||||
speed = GetPlayerTextSpeed();
|
||||
|
||||
gTextFlags.flag_0 = 1;
|
||||
}
|
||||
|
||||
+437
-516
File diff suppressed because it is too large
Load Diff
+219
-391
File diff suppressed because it is too large
Load Diff
+8
-14
@@ -18,12 +18,6 @@ extern u16 gSpecialVar_ItemId;
|
||||
|
||||
extern const u8 BerryTreeScript[];
|
||||
|
||||
#define BERRY_NAME_LENGTH 6
|
||||
|
||||
#define FIRST_BERRY ITEM_CHERI_BERRY
|
||||
#define LAST_BERRY ITEM_ENIGMA_BERRY
|
||||
|
||||
|
||||
static const u8 sBerryDescriptionPart1_Cheri[] = _("Blooms with delicate pretty flowers.");
|
||||
static const u8 sBerryDescriptionPart2_Cheri[] = _("The bright red BERRY is very spicy.");
|
||||
static const u8 sBerryDescriptionPart1_Chesto[] = _("The BERRY’s thick skin and fruit are");
|
||||
@@ -1062,28 +1056,28 @@ u8 GetStageByBerryTreeId(u8 id)
|
||||
|
||||
u8 ItemIdToBerryType(u16 item)
|
||||
{
|
||||
u16 berry = item - FIRST_BERRY;
|
||||
u16 berry = item - FIRST_BERRY_INDEX;
|
||||
|
||||
if (berry > LAST_BERRY - FIRST_BERRY)
|
||||
if (berry > LAST_BERRY_INDEX - FIRST_BERRY_INDEX)
|
||||
return 1;
|
||||
else
|
||||
return item - FIRST_BERRY + 1;
|
||||
return ITEM_TO_BERRY(item);
|
||||
}
|
||||
|
||||
u16 BerryTypeToItemId(u16 berry)
|
||||
{
|
||||
u16 item = berry - 1;
|
||||
|
||||
if (item > LAST_BERRY - FIRST_BERRY)
|
||||
return FIRST_BERRY;
|
||||
if (item > LAST_BERRY_INDEX - FIRST_BERRY_INDEX)
|
||||
return FIRST_BERRY_INDEX;
|
||||
else
|
||||
return berry + FIRST_BERRY - 1;
|
||||
return berry + FIRST_BERRY_INDEX - 1;
|
||||
}
|
||||
|
||||
void GetBerryNameByBerryType(u8 berry, u8 *string)
|
||||
{
|
||||
memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_LENGTH);
|
||||
string[BERRY_NAME_LENGTH] = EOS;
|
||||
memcpy(string, GetBerryInfo(berry)->name, BERRY_NAME_COUNT - 1);
|
||||
string[BERRY_NAME_COUNT - 1] = EOS;
|
||||
}
|
||||
|
||||
void GetBerryCountStringByBerryType(u8 berry, u8* dest, u32 berryCount)
|
||||
|
||||
+3104
-72
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,3 @@
|
||||
|
||||
// Includes
|
||||
#include "global.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "multiboot.h"
|
||||
@@ -10,6 +8,7 @@
|
||||
#include "task.h"
|
||||
#include "unknown_task.h"
|
||||
#include "window.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
#include "m4a.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "task.h"
|
||||
#include "menu.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
#include "sound.h"
|
||||
#include "main.h"
|
||||
#include "save.h"
|
||||
|
||||
+2
-3
@@ -459,10 +459,9 @@ _08034964:\n\
|
||||
.syntax divided");
|
||||
}
|
||||
|
||||
u32 sub_8034974(void* ptr)
|
||||
u32 sub_8034974(const u8 *ptr)
|
||||
{
|
||||
u8* ptr_ = (u8*)(ptr);
|
||||
return (ptr_[3] << 16) | (ptr_[2] << 8) | (ptr_[1]);
|
||||
return (ptr[3] << 16) | (ptr[2] << 8) | (ptr[1]);
|
||||
}
|
||||
|
||||
bool8 LoadCompressedObjectPicUsingHeap(const struct CompressedSpriteSheet* src)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "decompress.h"
|
||||
#include "malloc.h"
|
||||
#include "text.h"
|
||||
#include "string_util.h"
|
||||
#include "international_string_util.h"
|
||||
#include "script.h"
|
||||
|
||||
@@ -57,8 +57,6 @@ extern const u32 gUnknown_08331F60[]; // tilemap gameboy circle
|
||||
extern const u8 gText_HatchedFromEgg[];
|
||||
extern const u8 gText_NickHatchPrompt[];
|
||||
|
||||
extern u8* GetMonNick(struct Pokemon* mon, u8* dst);
|
||||
extern u8* GetBoxMonNick(struct BoxPokemon* boxMon, u8* dst);
|
||||
extern u8 sav1_map_get_name(void);
|
||||
extern void TVShowConvertInternationalString(u8* str1, u8* str2, u8);
|
||||
extern void sub_806A068(u16, u8);
|
||||
@@ -69,7 +67,6 @@ extern void remove_some_task(void);
|
||||
extern void c2_exit_to_overworld_2_switch(void);
|
||||
extern void play_some_sound(void);
|
||||
extern void DoNamingScreen(u8, const u8*, u16, u8, u32, MainCallback);
|
||||
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str);
|
||||
extern u16 sub_80D22D0(void);
|
||||
extern u8 CountPartyAliveNonEggMonsExcept(u8);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "international_string_util.h"
|
||||
#include "text.h"
|
||||
#include "international_string_util.h"
|
||||
|
||||
extern s32 convert_pixel_width_to_tile_width(s32 a0); // script menu
|
||||
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@
|
||||
#include "text.h"
|
||||
#include "event_data.h"
|
||||
|
||||
extern void ApplyNewEncyprtionKeyToHword(u16* hword, u32 newKey);
|
||||
extern void ApplyNewEncryptionKeyToHword(u16* hword, u32 newKey);
|
||||
extern bool8 InBattlePyramid(void);
|
||||
|
||||
extern const u8 gText_PokeBalls[];
|
||||
@@ -45,19 +45,19 @@ void SetBagItemId(u16* slot, u16 newItemId)
|
||||
*slot = newItemId;
|
||||
}
|
||||
|
||||
void ApplyNewEncyprtionKeyToBagItems(u32 newKey)
|
||||
void ApplyNewEncryptionKeyToBagItems(u32 newKey)
|
||||
{
|
||||
u32 pocket, item;
|
||||
for (pocket = 0; pocket < 5; pocket++)
|
||||
{
|
||||
for (item = 0; item < gBagPockets[pocket].capacity; item++)
|
||||
ApplyNewEncyprtionKeyToHword(&(gBagPockets[pocket].itemSlots[item].quantity), newKey);
|
||||
ApplyNewEncryptionKeyToHword(&(gBagPockets[pocket].itemSlots[item].quantity), newKey);
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyNewEncyprtionKeyToBagItems_(u32 newKey) // really GF?
|
||||
void ApplyNewEncryptionKeyToBagItems_(u32 newKey) // really GF?
|
||||
{
|
||||
ApplyNewEncyprtionKeyToBagItems(newKey);
|
||||
ApplyNewEncryptionKeyToBagItems(newKey);
|
||||
}
|
||||
|
||||
// TODO: move those max values to defines
|
||||
|
||||
+322
-17
@@ -1,21 +1,36 @@
|
||||
#include "global.h"
|
||||
#include "global.h"
|
||||
#include "gba/flash_internal.h"
|
||||
#include "load_save.h"
|
||||
#include "main.h"
|
||||
#include "pokemon.h"
|
||||
#include "rng.h"
|
||||
#include "malloc.h"
|
||||
|
||||
extern void* gUnknown_0203CF5C;
|
||||
|
||||
extern bool16 IdentifyFlash(void);
|
||||
extern void SetBagItemsPointers(void);
|
||||
extern void SetDecorationInventoriesPointers(void);
|
||||
extern void ApplyNewEncryptionKeyToGameStats(u32 key);
|
||||
extern void ApplyNewEncryptionKeyToBagItems(u32 newKey);
|
||||
extern void ApplyNewEncryptionKeyToBagItems_(u32 key);
|
||||
extern void ApplyNewEncryptionKeyToBerryPowder(u32 key);
|
||||
extern void sub_8084FAC(int unused);
|
||||
|
||||
void ApplyNewEncyprtionKeyToAllEncryptedData(u32 encryptionKey);
|
||||
// this is probably wrong or misleading due to it being used in ResetHeap...
|
||||
extern void InitHeap(void *pointer, u32 size);
|
||||
|
||||
#define SAVEBLOCK_MOVE_RANGE 128
|
||||
|
||||
struct LoadedSaveData
|
||||
{
|
||||
/*0x0000*/ struct ItemSlot items[30];
|
||||
/*0x0078*/ struct ItemSlot keyItems[30];
|
||||
/*0x00F0*/ struct ItemSlot pokeBalls[16];
|
||||
/*0x0130*/ struct ItemSlot TMsHMs[64];
|
||||
/*0x0230*/ struct ItemSlot berries[46];
|
||||
/*0x02E8*/ struct MailStruct mail[16];
|
||||
};
|
||||
|
||||
EWRAM_DATA struct SaveBlock2 gSaveblock2 = {0};
|
||||
EWRAM_DATA u8 gSaveblock2_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
|
||||
@@ -25,6 +40,11 @@ EWRAM_DATA u8 gSaveblock1_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
EWRAM_DATA struct PokemonStorage gPokemonStorage = {0};
|
||||
EWRAM_DATA u8 gSaveblock3_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
|
||||
EWRAM_DATA struct LoadedSaveData gLoadedSaveData = {0};
|
||||
EWRAM_DATA u32 gLastEncryptionKey = {0};
|
||||
|
||||
void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey);
|
||||
|
||||
void CheckForFlashMemory(void)
|
||||
{
|
||||
if (!IdentifyFlash())
|
||||
@@ -60,18 +80,45 @@ void SetSaveBlocksPointers(u16 offset)
|
||||
SetDecorationInventoriesPointers();
|
||||
}
|
||||
|
||||
// stuff i used to try and match MoveSaveBlocks_ResetHeap
|
||||
struct SaveBlocksInOne
|
||||
{
|
||||
struct SaveBlock2 sav2;
|
||||
struct SaveBlock1 sav1;
|
||||
struct PokemonStorage sav3;
|
||||
};
|
||||
|
||||
extern struct SaveBlocksInOne gHeap;
|
||||
|
||||
#define ewram_addr 0x02000000 // oh no...
|
||||
#define ewram_addr2 0x02000f2c
|
||||
#define ewram_addr3 0x02004cb4
|
||||
|
||||
#define eSaveBlockCopy (*(struct SaveBlocksInOne *)(ewram_addr + 0x0))
|
||||
#define eSaveBlock2Copy (*(struct SaveBlock2 *)((void*)(ewram_addr + 0x0)))
|
||||
#define eSaveBlock1Copy (*(struct SaveBlock1 *)((void*)(ewram_addr + sizeof(struct SaveBlock2))))
|
||||
#define eSaveBlock3Copy (*(struct PokemonStorage *)((void*)(ewram_addr + sizeof(struct SaveBlock2) + sizeof(struct SaveBlock1))))
|
||||
|
||||
#ifdef NONMATCHING // this is one devil of a motherfucker
|
||||
/*
|
||||
The reason MoveSaveBlocks_ResetHeap mismatches is due to incorrect memcpys. Various
|
||||
things have been tried, such as: direct struct copys, ewram casts, use of defining
|
||||
the addresses manually, using memcpy anyway, delayed allocation of pointers at
|
||||
the start of function, as seen above and below. Scope declaration has been used to try and
|
||||
reproduce the correct macro thought to be used, but nothing has worked. It is worth
|
||||
noting that at this point that the compiler will delay the allocation of the save block
|
||||
pointers at the beginningto be allocated later: which might matter for matching this.
|
||||
Due to loading shared ewram heap areas directly, it is very likely emerald used ewram
|
||||
defines for this function, but there is no known example of a matching define.
|
||||
In addition, dead code might be present in the form of a runtime variable used
|
||||
to fix the address of the save blocks. This has been tested and is shown to affect
|
||||
the registers as well.
|
||||
*/
|
||||
void MoveSaveBlocks_ResetHeap(void)
|
||||
{
|
||||
void *vblankCB, *hblankCB;
|
||||
u32 encryptionKey;
|
||||
struct SaveBlocksInOne* copiedSavs;
|
||||
struct SaveBlock1 **sav1Copy = &gSaveBlock1Ptr; // r10;
|
||||
|
||||
// save interrupt functions and turn them off
|
||||
vblankCB = gMain.vblankCallback;
|
||||
@@ -80,24 +127,22 @@ void MoveSaveBlocks_ResetHeap(void)
|
||||
gMain.hblankCallback = NULL;
|
||||
gUnknown_0203CF5C = NULL;
|
||||
|
||||
copiedSavs = (void*)(gHeap);
|
||||
|
||||
// copy saveblocks' content
|
||||
copiedSavs->sav2 = *gSaveBlock2Ptr;
|
||||
copiedSavs->sav1 = *gSaveBlock1Ptr;
|
||||
copiedSavs->sav3 = *gPokemonStoragePtr;
|
||||
// backup the saves.
|
||||
eSaveBlock1Copy = **sav1Copy;
|
||||
eSaveBlock2Copy = *gSaveBlock2Ptr;
|
||||
eSaveBlock3Copy = *gPokemonStoragePtr;
|
||||
|
||||
// change saveblocks' pointers
|
||||
// argument is a sum of the individual trainerId bytes
|
||||
SetSaveBlocksPointers(copiedSavs->sav2.playerTrainerId[0] + copiedSavs->sav2.playerTrainerId[1] + copiedSavs->sav2.playerTrainerId[2] + copiedSavs->sav2.playerTrainerId[3]);
|
||||
SetSaveBlocksPointers(eSaveBlock2Copy.playerTrainerId[0] + eSaveBlock2Copy.playerTrainerId[1] + eSaveBlock2Copy.playerTrainerId[2] + eSaveBlock2Copy.playerTrainerId[3]);
|
||||
|
||||
// restore saveblock data since the pointers changed
|
||||
*gSaveBlock2Ptr = copiedSavs->sav2;
|
||||
*gSaveBlock1Ptr = copiedSavs->sav1;
|
||||
*gPokemonStoragePtr = copiedSavs->sav3;
|
||||
**sav1Copy = eSaveBlock1Copy;
|
||||
*gSaveBlock2Ptr = eSaveBlock2Copy;
|
||||
*gPokemonStoragePtr = eSaveBlock3Copy;
|
||||
|
||||
// heap was destroyed in the copying process, so reset it
|
||||
InitHeap(gHeap, sizeof(gHeap));
|
||||
InitHeap((void*)(0x02000000), 0x1C000);
|
||||
|
||||
// restore interrupt functions
|
||||
gMain.hblankCallback = hblankCB;
|
||||
@@ -105,6 +150,266 @@ void MoveSaveBlocks_ResetHeap(void)
|
||||
|
||||
// create a new encryption key
|
||||
encryptionKey = (Random() << 0x10) + (Random());
|
||||
ApplyNewEncyprtionKeyToAllEncryptedData(encryptionKey);
|
||||
ApplyNewEncryptionKeyToAllEncryptedData(encryptionKey);
|
||||
gSaveBlock2Ptr->encryptionKey = encryptionKey;
|
||||
}*/
|
||||
}
|
||||
#else
|
||||
__attribute__((naked))
|
||||
void MoveSaveBlocks_ResetHeap(void)
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r10\n\
|
||||
mov r6, r9\n\
|
||||
mov r5, r8\n\
|
||||
push {r5-r7}\n\
|
||||
sub sp, 0x8\n\
|
||||
ldr r5, =gMain\n\
|
||||
ldr r0, [r5, 0xC]\n\
|
||||
str r0, [sp]\n\
|
||||
ldr r1, [r5, 0x10]\n\
|
||||
str r1, [sp, 0x4]\n\
|
||||
movs r0, 0\n\
|
||||
str r0, [r5, 0xC]\n\
|
||||
str r0, [r5, 0x10]\n\
|
||||
ldr r1, =gUnknown_0203CF5C\n\
|
||||
str r0, [r1]\n\
|
||||
ldr r4, =0x02000000\n\
|
||||
ldr r0, =gSaveBlock2Ptr\n\
|
||||
ldr r1, [r0]\n\
|
||||
ldr r6, =0x00000f2c\n\
|
||||
adds r0, r4, 0\n\
|
||||
adds r2, r6, 0\n\
|
||||
bl memcpy\n\
|
||||
ldr r1, =gSaveBlock1Ptr\n\
|
||||
mov r10, r1\n\
|
||||
ldr r1, [r1]\n\
|
||||
ldr r7, =0x00003d88\n\
|
||||
ldr r0, =0x02000f2c\n\
|
||||
adds r2, r7, 0\n\
|
||||
bl memcpy\n\
|
||||
ldr r0, =gPokemonStoragePtr\n\
|
||||
mov r8, r0\n\
|
||||
ldr r1, [r0]\n\
|
||||
ldr r0, =0x000083d0\n\
|
||||
mov r9, r0\n\
|
||||
ldr r0, =0x02004cb4\n\
|
||||
mov r2, r9\n\
|
||||
bl memcpy\n\
|
||||
ldrb r1, [r4, 0xA]\n\
|
||||
ldrb r0, [r4, 0xB]\n\
|
||||
adds r1, r0\n\
|
||||
ldrb r0, [r4, 0xC]\n\
|
||||
adds r1, r0\n\
|
||||
ldrb r0, [r4, 0xD]\n\
|
||||
adds r0, r1\n\
|
||||
bl SetSaveBlocksPointers\n\
|
||||
ldr r1, =gSaveBlock2Ptr\n\
|
||||
ldr r0, [r1]\n\
|
||||
adds r1, r4, 0\n\
|
||||
adds r2, r6, 0\n\
|
||||
bl memcpy\n\
|
||||
mov r1, r10\n\
|
||||
ldr r0, [r1]\n\
|
||||
ldr r1, =0x02000f2c\n\
|
||||
adds r2, r7, 0\n\
|
||||
bl memcpy\n\
|
||||
mov r1, r8\n\
|
||||
ldr r0, [r1]\n\
|
||||
ldr r1, =0x02004cb4\n\
|
||||
mov r2, r9\n\
|
||||
bl memcpy\n\
|
||||
movs r1, 0xE0\n\
|
||||
lsls r1, 9\n\
|
||||
adds r0, r4, 0\n\
|
||||
bl InitHeap\n\
|
||||
ldr r0, [sp, 0x4]\n\
|
||||
str r0, [r5, 0x10]\n\
|
||||
ldr r1, [sp]\n\
|
||||
str r1, [r5, 0xC]\n\
|
||||
bl Random\n\
|
||||
adds r4, r0, 0\n\
|
||||
bl Random\n\
|
||||
lsls r4, 16\n\
|
||||
lsls r0, 16\n\
|
||||
lsrs r0, 16\n\
|
||||
adds r4, r0\n\
|
||||
adds r0, r4, 0\n\
|
||||
bl ApplyNewEncryptionKeyToAllEncryptedData\n\
|
||||
ldr r1, =gSaveBlock2Ptr\n\
|
||||
ldr r0, [r1]\n\
|
||||
adds r0, 0xAC\n\
|
||||
str r4, [r0]\n\
|
||||
add sp, 0x8\n\
|
||||
pop {r3-r5}\n\
|
||||
mov r8, r3\n\
|
||||
mov r9, r4\n\
|
||||
mov r10, r5\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.pool\n\
|
||||
.syntax divided\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
u8 sav2_x1_query_bit1(void)
|
||||
{
|
||||
return gSaveBlock2Ptr->specialSaveWarp & 1;
|
||||
}
|
||||
|
||||
void sav2_x9_clear_bit1(void)
|
||||
{
|
||||
gSaveBlock2Ptr->specialSaveWarp &= ~1;
|
||||
}
|
||||
|
||||
void sub_8076D48(void)
|
||||
{
|
||||
gSaveBlock2Ptr->specialSaveWarp |= 1;
|
||||
}
|
||||
|
||||
void sub_8076D5C(void)
|
||||
{
|
||||
sub_8084FAC(0);
|
||||
gSaveBlock2Ptr->specialSaveWarp |= 1;
|
||||
}
|
||||
|
||||
void sav2_gender2_inplace_and_xFE(void)
|
||||
{
|
||||
gSaveBlock2Ptr->specialSaveWarp &= ~1;
|
||||
}
|
||||
|
||||
void copy_player_party_to_sav1(void) // SavePlayerParty
|
||||
{
|
||||
int i;
|
||||
|
||||
gSaveBlock1Ptr->playerPartyCount = gPlayerPartyCount;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
gSaveBlock1Ptr->playerParty[i] = gPlayerParty[i];
|
||||
}
|
||||
|
||||
void copy_player_party_from_sav1(void) // LoadPlayerParty
|
||||
{
|
||||
int i;
|
||||
|
||||
gPlayerPartyCount = gSaveBlock1Ptr->playerPartyCount;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
gPlayerParty[i] = gSaveBlock1Ptr->playerParty[i];
|
||||
}
|
||||
|
||||
void save_serialize_npcs(void) // SaveMapObjects
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
gSaveBlock1Ptr->mapObjects[i] = gMapObjects[i];
|
||||
}
|
||||
|
||||
void save_deserialize_npcs(void) // LoadMapObjects
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
gMapObjects[i] = gSaveBlock1Ptr->mapObjects[i];
|
||||
}
|
||||
|
||||
void SaveSerializedGame(void)
|
||||
{
|
||||
copy_player_party_to_sav1();
|
||||
save_serialize_npcs();
|
||||
}
|
||||
|
||||
void LoadSerializedGame(void)
|
||||
{
|
||||
copy_player_party_from_sav1();
|
||||
save_deserialize_npcs();
|
||||
}
|
||||
|
||||
void copy_bags_and_unk_data_from_save_blocks(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// load player items.
|
||||
for (i = 0; i < 30; i++)
|
||||
gLoadedSaveData.items[i] = gSaveBlock1Ptr->bagPocket_Items[i];
|
||||
|
||||
// load player key items.
|
||||
for (i = 0; i < 30; i++)
|
||||
gLoadedSaveData.keyItems[i] = gSaveBlock1Ptr->bagPocket_KeyItems[i];
|
||||
|
||||
// load player pokeballs.
|
||||
for (i = 0; i < 16; i++)
|
||||
gLoadedSaveData.pokeBalls[i] = gSaveBlock1Ptr->bagPocket_PokeBalls[i];
|
||||
|
||||
// load player TMs and HMs.
|
||||
for (i = 0; i < 64; i++)
|
||||
gLoadedSaveData.TMsHMs[i] = gSaveBlock1Ptr->bagPocket_TMHM[i];
|
||||
|
||||
// load player berries.
|
||||
for (i = 0; i < 46; i++)
|
||||
gLoadedSaveData.berries[i] = gSaveBlock1Ptr->bagPocket_Berries[i];
|
||||
|
||||
// load mail.
|
||||
for (i = 0; i < 16; i++)
|
||||
gLoadedSaveData.mail[i] = gSaveBlock1Ptr->mail[i];
|
||||
|
||||
gLastEncryptionKey = gSaveBlock2Ptr->encryptionKey;
|
||||
}
|
||||
|
||||
void copy_bags_and_unk_data_to_save_blocks(void)
|
||||
{
|
||||
int i;
|
||||
u32 encryptionKeyBackup;
|
||||
|
||||
// save player items.
|
||||
for (i = 0; i < 30; i++)
|
||||
gSaveBlock1Ptr->bagPocket_Items[i] = gLoadedSaveData.items[i];
|
||||
|
||||
// save player key items.
|
||||
for (i = 0; i < 30; i++)
|
||||
gSaveBlock1Ptr->bagPocket_KeyItems[i] = gLoadedSaveData.keyItems[i];
|
||||
|
||||
// save player pokeballs.
|
||||
for (i = 0; i < 16; i++)
|
||||
gSaveBlock1Ptr->bagPocket_PokeBalls[i] = gLoadedSaveData.pokeBalls[i];
|
||||
|
||||
// save player TMs and HMs.
|
||||
for (i = 0; i < 64; i++)
|
||||
gSaveBlock1Ptr->bagPocket_TMHM[i] = gLoadedSaveData.TMsHMs[i];
|
||||
|
||||
// save player berries.
|
||||
for (i = 0; i < 46; i++)
|
||||
gSaveBlock1Ptr->bagPocket_Berries[i] = gLoadedSaveData.berries[i];
|
||||
|
||||
// save mail.
|
||||
for (i = 0; i < 16; i++)
|
||||
gSaveBlock1Ptr->mail[i] = gLoadedSaveData.mail[i];
|
||||
|
||||
encryptionKeyBackup = gSaveBlock2Ptr->encryptionKey;
|
||||
gSaveBlock2Ptr->encryptionKey = gLastEncryptionKey;
|
||||
ApplyNewEncryptionKeyToBagItems(encryptionKeyBackup);
|
||||
gSaveBlock2Ptr->encryptionKey = encryptionKeyBackup; // updated twice?
|
||||
}
|
||||
|
||||
void ApplyNewEncryptionKeyToHword(u16 *hWord, u32 newKey)
|
||||
{
|
||||
*hWord ^= gSaveBlock2Ptr->encryptionKey;
|
||||
*hWord ^= newKey;
|
||||
}
|
||||
|
||||
void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey)
|
||||
{
|
||||
*word ^= gSaveBlock2Ptr->encryptionKey;
|
||||
*word ^= newKey;
|
||||
}
|
||||
|
||||
void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey)
|
||||
{
|
||||
ApplyNewEncryptionKeyToGameStats(encryptionKey);
|
||||
ApplyNewEncryptionKeyToBagItems_(encryptionKey);
|
||||
ApplyNewEncryptionKeyToBerryPowder(encryptionKey);
|
||||
ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->money, encryptionKey);
|
||||
ApplyNewEncryptionKeyToHword(&gSaveBlock1Ptr->coins, encryptionKey);
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ void m4aMPlayVolumeControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16
|
||||
mplayInfo->ident = ID_NUMBER;
|
||||
}
|
||||
|
||||
void m4aMPlayPitchControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16 pitch)
|
||||
void m4aMPlayPitchControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, s16 pitch)
|
||||
{
|
||||
s32 i;
|
||||
u32 bit;
|
||||
@@ -66,7 +66,7 @@ void m4aMPlayPitchControl(struct MusicPlayerInfo *mplayInfo, u16 trackBits, u16
|
||||
{
|
||||
if (track->flags & MPT_FLG_EXIST)
|
||||
{
|
||||
track->keyShiftX = (s16)pitch >> 8;
|
||||
track->keyShiftX = pitch >> 8;
|
||||
track->pitX = pitch;
|
||||
track->flags |= MPT_FLG_PITCHG;
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,14 +1,12 @@
|
||||
|
||||
// Includes
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "overworld.h"
|
||||
#include "task.h"
|
||||
#include "unknown_task.h"
|
||||
#include "palette.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "text.h"
|
||||
#include "text_window.h"
|
||||
#include "string_util.h"
|
||||
#include "international_string_util.h"
|
||||
|
||||
+2
-2
@@ -1297,13 +1297,13 @@ bool8 IsPokeSpriteNotFlipped(u16 species)
|
||||
return gBaseStats[species].noFlip;
|
||||
}
|
||||
|
||||
s8 GetMonFlavourRelation(struct Pokemon *mon, u8 a2)
|
||||
s8 GetMonFlavorRelation(struct Pokemon *mon, u8 a2)
|
||||
{
|
||||
u8 nature = GetNature(mon);
|
||||
return gPokeblockFlavorCompatibilityTable[nature * 5 + a2];
|
||||
}
|
||||
|
||||
s8 GetFlavourRelationByPersonality(u32 personality, u8 a2)
|
||||
s8 GetFlavorRelationByPersonality(u32 personality, u8 a2)
|
||||
{
|
||||
u8 nature = GetNatureFromPersonality(personality);
|
||||
return gPokeblockFlavorCompatibilityTable[nature * 5 + a2];
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "sound.h"
|
||||
#include "species.h"
|
||||
#include "sprite.h"
|
||||
#include "unk_text_util.h"
|
||||
#include "string_util.h"
|
||||
#include "task.h"
|
||||
#include "text.h"
|
||||
@@ -166,9 +167,7 @@ extern s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth);
|
||||
extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth);
|
||||
extern bool8 sub_81A6BF4();
|
||||
extern bool8 sub_81B9E94();
|
||||
extern void sub_81AFBF0();
|
||||
extern u8 sub_81AFC0C(u8 a, u8 *b);
|
||||
extern void sub_81AFC28(u8 *a, u8 *b);
|
||||
extern void UnkTextUtil_Reset();
|
||||
extern void sub_8124610(u8 *a, u8 b);
|
||||
extern int GetPlayerIDAsU32();
|
||||
extern u8 GetCurrentPpToMaxPpState(u8 a, u8 b);
|
||||
@@ -2993,12 +2992,12 @@ void sub_81C307C()
|
||||
{
|
||||
struct PokeSummary *sum = &gUnknown_0203CF1C->summary;
|
||||
u8 *text;
|
||||
sub_81AFBF0();
|
||||
sub_81AFC0C(0, gUnknown_0861CE74);
|
||||
sub_81AFC0C(1, gUnknown_0861CE7B);
|
||||
UnkTextUtil_Reset();
|
||||
UnkTextUtil_SetPtrI(0, gUnknown_0861CE74);
|
||||
UnkTextUtil_SetPtrI(1, gUnknown_0861CE7B);
|
||||
sub_81C31C0();
|
||||
if (sub_81A6BF4() == TRUE || sub_81B9E94() == TRUE || sub_81C3304() == TRUE)
|
||||
sub_81AFC28(gStringVar4, gText_XNature);
|
||||
UnkTextUtil_StringExpandPlaceholders(gStringVar4, gText_XNature);
|
||||
else
|
||||
{
|
||||
u8 *alloced1 = Alloc(32);
|
||||
@@ -3007,7 +3006,7 @@ void sub_81C307C()
|
||||
if (sum->metLocation <= 0xD4)
|
||||
{
|
||||
sub_8124610(alloced2, sum->metLocation);
|
||||
sub_81AFC0C(4, alloced2);
|
||||
UnkTextUtil_SetPtrI(4, alloced2);
|
||||
}
|
||||
if (sub_81C3220() == 1)
|
||||
{
|
||||
@@ -3022,7 +3021,7 @@ void sub_81C307C()
|
||||
text = (sum->metLocation > 0xD4) ? gText_XNatureObtainedInTrade : gText_XNatureProbablyMetAt;
|
||||
else
|
||||
text = gText_XNatureObtainedInTrade;
|
||||
sub_81AFC28(gStringVar4, text);
|
||||
UnkTextUtil_StringExpandPlaceholders(gStringVar4, text);
|
||||
Free(alloced1);
|
||||
Free(alloced2);
|
||||
}
|
||||
@@ -3036,8 +3035,8 @@ void sub_81C3194()
|
||||
void sub_81C31C0()
|
||||
{
|
||||
struct UnkSummaryStruct *sumStruct = gUnknown_0203CF1C;
|
||||
sub_81AFC0C(2, gNatureNamePointers[sumStruct->summary.nature]);
|
||||
sub_81AFC0C(5, gText_EmptyString5);
|
||||
UnkTextUtil_SetPtrI(2, gNatureNamePointers[sumStruct->summary.nature]);
|
||||
UnkTextUtil_SetPtrI(5, gText_EmptyString5);
|
||||
}
|
||||
|
||||
void sub_81C31F0(u8 *a)
|
||||
@@ -3046,7 +3045,7 @@ void sub_81C31F0(u8 *a)
|
||||
if (level == 0)
|
||||
level = 5;
|
||||
ConvertIntToDecimalStringN(a, level, 0, 3);
|
||||
sub_81AFC0C(3, a);
|
||||
UnkTextUtil_SetPtrI(3, a);
|
||||
}
|
||||
|
||||
u8 sub_81C3220()
|
||||
@@ -3301,12 +3300,12 @@ void sub_81C3710()
|
||||
ConvertIntToDecimalStringN(alloced2, gUnknown_0203CF1C->summary.maxHP, 1, 3);
|
||||
ConvertIntToDecimalStringN(alloced3, gUnknown_0203CF1C->summary.atk, 1, 7);
|
||||
ConvertIntToDecimalStringN(alloced4, gUnknown_0203CF1C->summary.def, 1, 7);
|
||||
sub_81AFBF0();
|
||||
sub_81AFC0C(0, alloced1);
|
||||
sub_81AFC0C(1, alloced2);
|
||||
sub_81AFC0C(2, alloced3);
|
||||
sub_81AFC0C(3, alloced4);
|
||||
sub_81AFC28(gStringVar4, gUnknown_0861CE82);
|
||||
UnkTextUtil_Reset();
|
||||
UnkTextUtil_SetPtrI(0, alloced1);
|
||||
UnkTextUtil_SetPtrI(1, alloced2);
|
||||
UnkTextUtil_SetPtrI(2, alloced3);
|
||||
UnkTextUtil_SetPtrI(3, alloced4);
|
||||
UnkTextUtil_StringExpandPlaceholders(gStringVar4, gUnknown_0861CE82);
|
||||
Free(alloced1);
|
||||
Free(alloced2);
|
||||
Free(alloced3);
|
||||
@@ -3323,11 +3322,11 @@ void sub_81C3808()
|
||||
ConvertIntToDecimalStringN(gStringVar1, gUnknown_0203CF1C->summary.spatk, 1, 3);
|
||||
ConvertIntToDecimalStringN(gStringVar2, gUnknown_0203CF1C->summary.spdef, 1, 3);
|
||||
ConvertIntToDecimalStringN(gStringVar3, gUnknown_0203CF1C->summary.speed, 1, 3);
|
||||
sub_81AFBF0();
|
||||
sub_81AFC0C(0, gStringVar1);
|
||||
sub_81AFC0C(1, gStringVar2);
|
||||
sub_81AFC0C(2, gStringVar3);
|
||||
sub_81AFC28(gStringVar4, gUnknown_0861CE8E);
|
||||
UnkTextUtil_Reset();
|
||||
UnkTextUtil_SetPtrI(0, gStringVar1);
|
||||
UnkTextUtil_SetPtrI(1, gStringVar2);
|
||||
UnkTextUtil_SetPtrI(2, gStringVar3);
|
||||
UnkTextUtil_StringExpandPlaceholders(gStringVar4, gUnknown_0861CE8E);
|
||||
}
|
||||
|
||||
void sub_81C3890()
|
||||
@@ -3436,10 +3435,10 @@ void sub_81C3B08(u8 a)
|
||||
sub_81C25A4(r8, gMoveNames[move], 0, (a<<4) + 1, 0, 1);
|
||||
ConvertIntToDecimalStringN(gStringVar1, r10->summary.pp[a], 1, 2);
|
||||
ConvertIntToDecimalStringN(gStringVar2, r6, 1, 2);
|
||||
sub_81AFBF0();
|
||||
sub_81AFC0C(0, gStringVar1);
|
||||
sub_81AFC0C(1, gStringVar2);
|
||||
sub_81AFC28(gStringVar4, gUnknown_0861CE97);
|
||||
UnkTextUtil_Reset();
|
||||
UnkTextUtil_SetPtrI(0, gStringVar1);
|
||||
UnkTextUtil_SetPtrI(1, gStringVar2);
|
||||
UnkTextUtil_StringExpandPlaceholders(gStringVar4, gUnknown_0861CE97);
|
||||
text = gStringVar4;
|
||||
r5 = GetCurrentPpToMaxPpState(r10->summary.pp[a], r6) + 9;
|
||||
offset = GetStringRightAlignXOffset(1, text, 0x2C);
|
||||
@@ -3531,17 +3530,17 @@ void sub_81C3B08(u8 a)
|
||||
movs r2, 0x1\n\
|
||||
movs r3, 0x2\n\
|
||||
bl ConvertIntToDecimalStringN\n\
|
||||
bl sub_81AFBF0\n\
|
||||
bl UnkTextUtil_Reset\n\
|
||||
movs r0, 0\n\
|
||||
mov r1, r8\n\
|
||||
bl sub_81AFC0C\n\
|
||||
bl UnkTextUtil_SetPtrI\n\
|
||||
movs r0, 0x1\n\
|
||||
adds r1, r4, 0\n\
|
||||
bl sub_81AFC0C\n\
|
||||
bl UnkTextUtil_SetPtrI\n\
|
||||
ldr r4, =gStringVar4\n\
|
||||
ldr r1, =gUnknown_0861CE97\n\
|
||||
adds r0, r4, 0\n\
|
||||
bl sub_81AFC28\n\
|
||||
bl UnkTextUtil_StringExpandPlaceholders\n\
|
||||
adds r7, r4, 0\n\
|
||||
ldrb r0, [r5]\n\
|
||||
adds r1, r6, 0\n\
|
||||
|
||||
+1
-3
@@ -1,7 +1,6 @@
|
||||
|
||||
// Includes
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
@@ -17,7 +16,6 @@
|
||||
#include "string_util.h"
|
||||
#include "international_string_util.h"
|
||||
#include "strings.h"
|
||||
#include "text.h"
|
||||
#include "text_window.h"
|
||||
#include "songs.h"
|
||||
#include "m4a.h"
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#define MSG_WIN_TOP 12
|
||||
#define CLOCK_WIN_TOP (MSG_WIN_TOP - 4)
|
||||
|
||||
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str);
|
||||
|
||||
extern void (*gGameContinueCallback)(void);
|
||||
|
||||
extern u32 gDamagedSaveSectors;
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@ extern void CopyWindowToVram(u8 windowId, u8 mode);
|
||||
extern u16 Font6Func(struct TextPrinter *textPrinter);
|
||||
extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese);
|
||||
extern void PlaySE(u16 songNum);
|
||||
extern u8* sub_81AFC74(u8 a1);
|
||||
extern u8* UnkTextUtil_GetPtrI(u8 a1);
|
||||
|
||||
EWRAM_DATA struct TextPrinter gTempTextPrinter = {0};
|
||||
EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0};
|
||||
@@ -190,7 +190,7 @@ bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*ca
|
||||
gTempTextPrinter.japanese = 0;
|
||||
|
||||
GenerateFontHalfRowLookupTable(textSubPrinter->fontColor_h, textSubPrinter->bgColor, textSubPrinter->shadowColor);
|
||||
if (speed != 0xFF && speed != 0x0)
|
||||
if (speed != TEXT_SPEED_FF && speed != 0x0)
|
||||
{
|
||||
--gTempTextPrinter.text_speed;
|
||||
gTextPrinters[textSubPrinter->windowId] = gTempTextPrinter;
|
||||
@@ -204,7 +204,7 @@ bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*ca
|
||||
break;
|
||||
}
|
||||
|
||||
if (speed != 0xFF)
|
||||
if (speed != TEXT_SPEED_FF)
|
||||
CopyWindowToVram(gTempTextPrinter.subPrinter.windowId, 2);
|
||||
gTextPrinters[textSubPrinter->windowId].sub_union.sub.active = 0;
|
||||
}
|
||||
@@ -2932,7 +2932,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
|
||||
}
|
||||
case 0xF7:
|
||||
if (bufferPointer == NULL)
|
||||
bufferPointer = sub_81AFC74(*++str);
|
||||
bufferPointer = UnkTextUtil_GetPtrI(*++str);
|
||||
while (*bufferPointer != 0xFF)
|
||||
{
|
||||
glyphWidth = func(*bufferPointer++, isJapanese);
|
||||
|
||||
@@ -1883,7 +1883,7 @@ void PutFishingAdviceShowOnTheAir(void)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80EDA3C(u16 species)
|
||||
void SetPokemonAnglerSpecies(u16 species)
|
||||
{
|
||||
sPokemonAnglerSpecies = species;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "global.h"
|
||||
#include "text.h"
|
||||
#include "unk_text_util.h"
|
||||
#include "string_util.h"
|
||||
|
||||
static EWRAM_DATA const u8 *sStringPointers[8] = {};
|
||||
|
||||
void UnkTextUtil_Reset(void)
|
||||
{
|
||||
const u8 **ptr;
|
||||
u8 *fillval;
|
||||
const u8 **ptr2;
|
||||
|
||||
ptr = sStringPointers;
|
||||
fillval = NULL;
|
||||
ptr2 = ptr + (ARRAY_COUNT(sStringPointers) - 1);
|
||||
do
|
||||
{
|
||||
*ptr2-- = fillval;
|
||||
} while ((int)ptr2 >= (int)ptr);
|
||||
}
|
||||
|
||||
void UnkTextUtil_SetPtrI(u8 idx, const u8 *ptr)
|
||||
{
|
||||
if (idx < ARRAY_COUNT(sStringPointers))
|
||||
{
|
||||
sStringPointers[idx] = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
u8 *UnkTextUtil_StringExpandPlaceholders(u8 *dest, const u8 *src)
|
||||
{
|
||||
while (*src != EOS)
|
||||
{
|
||||
if (*src != CHAR_SPECIAL_F7)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
src++;
|
||||
if (sStringPointers[*src] != NULL)
|
||||
{
|
||||
dest = StringCopy(dest, sStringPointers[*src]);
|
||||
}
|
||||
src++;
|
||||
}
|
||||
}
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
const u8 *UnkTextUtil_GetPtrI(u8 idx)
|
||||
{
|
||||
return sStringPointers[idx];
|
||||
}
|
||||
@@ -0,0 +1,933 @@
|
||||
#include "global.h"
|
||||
#include "wild_encounter.h"
|
||||
#include "pokemon.h"
|
||||
#include "species.h"
|
||||
#include "metatile_behavior.h"
|
||||
#include "fieldmap.h"
|
||||
#include "rng.h"
|
||||
#include "map_constants.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "abilities.h"
|
||||
#include "event_data.h"
|
||||
#include "safari_zone.h"
|
||||
#include "pokeblock.h"
|
||||
#include "battle_setup.h"
|
||||
#include "roamer.h"
|
||||
#include "game_stat.h"
|
||||
#include "tv.h"
|
||||
#include "link.h"
|
||||
#include "script.h"
|
||||
#include "items.h"
|
||||
|
||||
extern const u8 EventScript_RepelWoreOff[];
|
||||
|
||||
#define NUM_FEEBAS_SPOTS 6
|
||||
|
||||
extern const u16 gRoute119WaterTileData[];
|
||||
extern const struct WildPokemonHeader gBattlePikeWildMonHeaders[];
|
||||
extern const struct WildPokemonHeader gBattlePyramidWildMonHeaders[];
|
||||
extern const struct WildPokemon gWildFeebasRoute119Data;
|
||||
|
||||
extern u8 GetBattlePikeWildMonHeaderId(void);
|
||||
extern bool32 TryGenerateBattlePikeWildMon(bool8 checkKeenEyeIntimidate);
|
||||
extern void GenerateBattlePyramidWildMon(void);
|
||||
extern bool8 InBattlePike(void);
|
||||
extern bool8 InBattlePyramid(void);
|
||||
|
||||
// this file's functions
|
||||
static u16 FeebasRandom(void);
|
||||
static void FeebasSeedRng(u16 seed);
|
||||
static bool8 IsWildLevelAllowedByRepel(u8 level);
|
||||
static void ApplyFluteEncounterRateMod(u32 *encRate);
|
||||
static void ApplyCleanseTagEncounterRateMod(u32 *encRate);
|
||||
static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex);
|
||||
static bool8 IsAbilityAllowingEncounter(u8 level);
|
||||
|
||||
EWRAM_DATA u8 sWildEncountersDisabled = 0;
|
||||
EWRAM_DATA u32 sFeebasRngValue = 0;
|
||||
|
||||
void DisableWildEncounters(bool8 disabled)
|
||||
{
|
||||
sWildEncountersDisabled = disabled;
|
||||
}
|
||||
|
||||
static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section)
|
||||
{
|
||||
u16 xCur;
|
||||
u16 yCur;
|
||||
u16 yMin = gRoute119WaterTileData[section * 3 + 0];
|
||||
u16 yMax = gRoute119WaterTileData[section * 3 + 1];
|
||||
u16 tileNum = gRoute119WaterTileData[section * 3 + 2];
|
||||
|
||||
for (yCur = yMin; yCur <= yMax; yCur++)
|
||||
{
|
||||
for (xCur = 0; xCur < gMapHeader.mapData->width; xCur++)
|
||||
{
|
||||
u8 tileBehaviorId = MapGridGetMetatileBehaviorAt(xCur + 7, yCur + 7);
|
||||
if (MetatileBehavior_IsSurfableAndNotWaterfall(tileBehaviorId) == TRUE)
|
||||
{
|
||||
tileNum++;
|
||||
if (x == xCur && y == yCur)
|
||||
return tileNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tileNum + 1;
|
||||
}
|
||||
|
||||
static bool8 CheckFeebas(void)
|
||||
{
|
||||
u8 i;
|
||||
u16 feebasSpots[NUM_FEEBAS_SPOTS];
|
||||
s16 x;
|
||||
s16 y;
|
||||
u8 route119Section = 0;
|
||||
u16 waterTileNum;
|
||||
|
||||
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_ROUTE119
|
||||
&& gSaveBlock1Ptr->location.mapNum == MAP_ID_ROUTE119)
|
||||
{
|
||||
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
||||
x -= 7;
|
||||
y -= 7;
|
||||
|
||||
#ifdef NONMATCHING
|
||||
if (y >= gRoute119WaterTileData[3 * 1 + 0] && y <= gRoute119WaterTileData[3 * 1 + 1])
|
||||
route119Section = 1;
|
||||
if (y >= gRoute119WaterTileData[3 * 2 + 0] && y <= gRoute119WaterTileData[3 * 2 + 1])
|
||||
route119Section = 2;
|
||||
#else
|
||||
{
|
||||
register const u16 *arr asm("r0");
|
||||
if (y >= (arr = gRoute119WaterTileData)[3 * 1 + 0] && y <= arr[3 * 1 + 1])
|
||||
route119Section = 1;
|
||||
if (y >= arr[3 * 2 + 0] && y <= arr[3 * 2 + 1])
|
||||
route119Section = 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Random() % 100 > 49) // 50% chance of encountering Feebas
|
||||
return FALSE;
|
||||
|
||||
FeebasSeedRng(gSaveBlock1Ptr->easyChatPairs[0].unk2);
|
||||
for (i = 0; i != NUM_FEEBAS_SPOTS;)
|
||||
{
|
||||
feebasSpots[i] = FeebasRandom() % 447;
|
||||
if (feebasSpots[i] == 0)
|
||||
feebasSpots[i] = 447;
|
||||
if (feebasSpots[i] < 1 || feebasSpots[i] >= 4)
|
||||
i++;
|
||||
}
|
||||
waterTileNum = GetRoute119WaterTileNum(x, y, route119Section);
|
||||
for (i = 0; i < NUM_FEEBAS_SPOTS; i++)
|
||||
{
|
||||
if (waterTileNum == feebasSpots[i])
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// The number 1103515245 comes from the example implementation of rand and srand
|
||||
// in the ISO C standard.
|
||||
|
||||
static u16 FeebasRandom(void)
|
||||
{
|
||||
sFeebasRngValue = (1103515245 * sFeebasRngValue) + 12345;
|
||||
return sFeebasRngValue >> 16;
|
||||
}
|
||||
|
||||
static void FeebasSeedRng(u16 seed)
|
||||
{
|
||||
sFeebasRngValue = seed;
|
||||
}
|
||||
|
||||
static u8 ChooseWildMonIndex_Land(void)
|
||||
{
|
||||
u8 rand = Random() % 100;
|
||||
|
||||
if (rand < 20) // 20% chance
|
||||
return 0;
|
||||
else if (rand >= 20 && rand < 40) // 20% chance
|
||||
return 1;
|
||||
else if (rand >= 40 && rand < 50) // 10% chance
|
||||
return 2;
|
||||
else if (rand >= 50 && rand < 60) // 10% chance
|
||||
return 3;
|
||||
else if (rand >= 60 && rand < 70) // 10% chance
|
||||
return 4;
|
||||
else if (rand >= 70 && rand < 80) // 10% chance
|
||||
return 5;
|
||||
else if (rand >= 80 && rand < 85) // 5% chance
|
||||
return 6;
|
||||
else if (rand >= 85 && rand < 90) // 5% chance
|
||||
return 7;
|
||||
else if (rand >= 90 && rand < 94) // 4% chance
|
||||
return 8;
|
||||
else if (rand >= 94 && rand < 98) // 4% chance
|
||||
return 9;
|
||||
else if (rand == 98) // 1% chance
|
||||
return 10;
|
||||
else // 1% chance
|
||||
return 11;
|
||||
}
|
||||
|
||||
static u8 ChooseWildMonIndex_WaterRock(void)
|
||||
{
|
||||
u8 rand = Random() % 100;
|
||||
|
||||
if (rand < 60) // 60% chance
|
||||
return 0;
|
||||
else if (rand >= 60 && rand < 90) // 30% chance
|
||||
return 1;
|
||||
else if (rand >= 90 && rand < 95) // 5% chance
|
||||
return 2;
|
||||
else if (rand >= 95 && rand < 99) // 4% chance
|
||||
return 3;
|
||||
else // 1% chance
|
||||
return 4;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
OLD_ROD,
|
||||
GOOD_ROD,
|
||||
SUPER_ROD
|
||||
};
|
||||
|
||||
static u8 ChooseWildMonIndex_Fishing(u8 rod)
|
||||
{
|
||||
u8 wildMonIndex = 0;
|
||||
u8 rand = Random() % 100;
|
||||
|
||||
switch (rod)
|
||||
{
|
||||
case OLD_ROD:
|
||||
if (rand < 70) // 70% chance
|
||||
wildMonIndex = 0;
|
||||
else // 30% chance
|
||||
wildMonIndex = 1;
|
||||
break;
|
||||
case GOOD_ROD:
|
||||
if (rand < 60) // 60% chance
|
||||
wildMonIndex = 2;
|
||||
if (rand >= 60 && rand < 80) // 20% chance
|
||||
wildMonIndex = 3;
|
||||
if (rand >= 80 && rand < 100) // 20% chance
|
||||
wildMonIndex = 4;
|
||||
break;
|
||||
case SUPER_ROD:
|
||||
if (rand < 40) // 40% chance
|
||||
wildMonIndex = 5;
|
||||
if (rand >= 40 && rand < 80) // 40% chance
|
||||
wildMonIndex = 6;
|
||||
if (rand >= 80 && rand < 95) // 15% chance
|
||||
wildMonIndex = 7;
|
||||
if (rand >= 95 && rand < 99) // 4% chance
|
||||
wildMonIndex = 8;
|
||||
if (rand == 99) // 1% chance
|
||||
wildMonIndex = 9;
|
||||
break;
|
||||
}
|
||||
return wildMonIndex;
|
||||
}
|
||||
|
||||
static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon)
|
||||
{
|
||||
u8 min;
|
||||
u8 max;
|
||||
u8 range;
|
||||
u8 rand;
|
||||
|
||||
// Make sure minimum level is less than maximum level
|
||||
if (wildPokemon->maxLevel >= wildPokemon->minLevel)
|
||||
{
|
||||
min = wildPokemon->minLevel;
|
||||
max = wildPokemon->maxLevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
min = wildPokemon->maxLevel;
|
||||
max = wildPokemon->minLevel;
|
||||
}
|
||||
range = max - min + 1;
|
||||
rand = Random() % range;
|
||||
|
||||
// check ability for max level mon
|
||||
if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
|
||||
{
|
||||
u8 ability = GetMonAbility(&gPlayerParty[0]);
|
||||
if (ability == ABILITY_HUSTLE || ability == ABILITY_VITAL_SPIRIT || ability == ABILITY_PRESSURE)
|
||||
{
|
||||
if (Random() % 2 == 0)
|
||||
return max;
|
||||
|
||||
if (rand != 0)
|
||||
rand--;
|
||||
}
|
||||
}
|
||||
|
||||
return min + rand;
|
||||
}
|
||||
|
||||
static u16 GetCurrentMapWildMonHeaderId(void)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
const struct WildPokemonHeader *wildHeader = &gWildMonHeaders[i];
|
||||
if (wildHeader->mapGroup == 0xFF)
|
||||
break;
|
||||
|
||||
if (gWildMonHeaders[i].mapGroup == gSaveBlock1Ptr->location.mapGroup &&
|
||||
gWildMonHeaders[i].mapNum == gSaveBlock1Ptr->location.mapNum)
|
||||
{
|
||||
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_ALTERING_CAVE &&
|
||||
gSaveBlock1Ptr->location.mapNum == MAP_ID_ALTERING_CAVE)
|
||||
{
|
||||
u16 alteringCaveId = VarGet(VAR_ALTERING_CAVE_WILD_SET);
|
||||
if (alteringCaveId > 8)
|
||||
alteringCaveId = 0;
|
||||
|
||||
i += alteringCaveId;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static u8 PickWildMonNature(void)
|
||||
{
|
||||
u8 i;
|
||||
u8 j;
|
||||
struct Pokeblock *safariPokeblock;
|
||||
u8 natures[25];
|
||||
|
||||
if (GetSafariZoneFlag() == TRUE && Random() % 100 < 80)
|
||||
{
|
||||
safariPokeblock = SafariZoneGetActivePokeblock();
|
||||
if (safariPokeblock != NULL)
|
||||
{
|
||||
for (i = 0; i < 25; i++)
|
||||
natures[i] = i;
|
||||
for (i = 0; i < 24; i++)
|
||||
{
|
||||
for (j = i + 1; j < 25; j++)
|
||||
{
|
||||
if (Random() & 1)
|
||||
{
|
||||
u8 temp = natures[i];
|
||||
|
||||
natures[i] = natures[j];
|
||||
natures[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 25; i++)
|
||||
{
|
||||
if (PokeblockGetGain(natures[i], safariPokeblock) > 0)
|
||||
return natures[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// check synchronize for a pokemon with the same ability
|
||||
if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)
|
||||
&& GetMonAbility(&gPlayerParty[0]) == ABILITY_SYNCHRONIZE
|
||||
&& Random() % 2 == 0)
|
||||
{
|
||||
return GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY) % 25;
|
||||
}
|
||||
|
||||
// random nature
|
||||
return Random() % 25;
|
||||
}
|
||||
|
||||
static void CreateWildMon(u16 species, u8 level)
|
||||
{
|
||||
bool32 checkCuteCharm;
|
||||
|
||||
ZeroEnemyPartyMons();
|
||||
checkCuteCharm = TRUE;
|
||||
|
||||
switch (gBaseStats[species].genderRatio)
|
||||
{
|
||||
case MON_MALE:
|
||||
case MON_FEMALE:
|
||||
case MON_GENDERLESS:
|
||||
checkCuteCharm = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (checkCuteCharm
|
||||
&& !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3)
|
||||
&& GetMonAbility(&gPlayerParty[0]) == ABILITY_CUTE_CHARM
|
||||
&& Random() % 3 != 0)
|
||||
{
|
||||
u16 leadingMonSpecies = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES);
|
||||
u32 leadingMonPersonality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY);
|
||||
u8 gender = GetGenderFromSpeciesAndPersonality(leadingMonSpecies, leadingMonPersonality);
|
||||
|
||||
// misses mon is genderless check, although no genderless mon can have cute charm as ability
|
||||
if (gender == MON_FEMALE)
|
||||
gender = MON_MALE;
|
||||
else
|
||||
gender = MON_FEMALE;
|
||||
|
||||
CreateMonWithGenderNatureLetter(&gEnemyParty[0], species, level, 32, gender, PickWildMonNature(), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
CreateMonWithNature(&gEnemyParty[0], species, level, 32, PickWildMonNature());
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
WILD_AREA_LAND,
|
||||
WILD_AREA_WATER,
|
||||
WILD_AREA_ROCKS,
|
||||
WILD_AREA_FISHING,
|
||||
};
|
||||
|
||||
#define WILD_CHECK_REPEL 0x1
|
||||
#define WILD_CHECK_KEEN_EYE 0x2
|
||||
|
||||
static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags)
|
||||
{
|
||||
u8 wildMonIndex = 0;
|
||||
u8 level;
|
||||
|
||||
switch (area)
|
||||
{
|
||||
case WILD_AREA_LAND:
|
||||
if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_STEEL, ABILITY_MAGNET_PULL, &wildMonIndex))
|
||||
break;
|
||||
if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex))
|
||||
break;
|
||||
|
||||
wildMonIndex = ChooseWildMonIndex_Land();
|
||||
break;
|
||||
case WILD_AREA_WATER:
|
||||
if (TryGetAbilityInfluencedWildMonIndex(wildMonInfo->wildPokemon, TYPE_ELECTRIC, ABILITY_STATIC, &wildMonIndex))
|
||||
break;
|
||||
|
||||
wildMonIndex = ChooseWildMonIndex_WaterRock();
|
||||
break;
|
||||
case WILD_AREA_ROCKS:
|
||||
wildMonIndex = ChooseWildMonIndex_WaterRock();
|
||||
break;
|
||||
}
|
||||
|
||||
level = ChooseWildMonLevel(&wildMonInfo->wildPokemon[wildMonIndex]);
|
||||
if (flags & WILD_CHECK_REPEL && !IsWildLevelAllowedByRepel(level))
|
||||
return FALSE;
|
||||
if (gMapHeader.mapDataId != 0x166 && flags & WILD_CHECK_KEEN_EYE && !IsAbilityAllowingEncounter(level))
|
||||
return FALSE;
|
||||
|
||||
CreateWildMon(wildMonInfo->wildPokemon[wildMonIndex].species, level);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u16 GenerateFishingWildMon(const struct WildPokemonInfo *wildMonInfo, u8 rod)
|
||||
{
|
||||
u8 wildMonIndex = ChooseWildMonIndex_Fishing(rod);
|
||||
u8 level = ChooseWildMonLevel(&wildMonInfo->wildPokemon[wildMonIndex]);
|
||||
|
||||
CreateWildMon(wildMonInfo->wildPokemon[wildMonIndex].species, level);
|
||||
return wildMonInfo->wildPokemon[wildMonIndex].species;
|
||||
}
|
||||
|
||||
static bool8 SetUpMassOutbreakEncounter(u8 flags)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
if (flags & WILD_CHECK_REPEL && !IsWildLevelAllowedByRepel(gSaveBlock1Ptr->outbreakPokemonLevel))
|
||||
return FALSE;
|
||||
|
||||
CreateWildMon(gSaveBlock1Ptr->outbreakPokemonSpecies, gSaveBlock1Ptr->outbreakPokemonLevel);
|
||||
for (i = 0; i < 4; i++)
|
||||
SetMonMoveSlot(&gEnemyParty[0], gSaveBlock1Ptr->outbreakPokemonMoves[i], i);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 DoMassOutbreakEncounterTest(void)
|
||||
{
|
||||
if (gSaveBlock1Ptr->outbreakPokemonSpecies != 0
|
||||
&& gSaveBlock1Ptr->location.mapNum == gSaveBlock1Ptr->outbreakLocationMapNum
|
||||
&& gSaveBlock1Ptr->location.mapGroup == gSaveBlock1Ptr->outbreakLocationMapGroup)
|
||||
{
|
||||
if (Random() % 100 < gSaveBlock1Ptr->outbreakPokemonProbability)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 DoWildEncounterRateDiceRoll(u16 encounterRate)
|
||||
{
|
||||
if (Random() % 2880 < encounterRate)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility)
|
||||
{
|
||||
encounterRate *= 16;
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
|
||||
encounterRate = encounterRate * 80 / 100;
|
||||
ApplyFluteEncounterRateMod(&encounterRate);
|
||||
ApplyCleanseTagEncounterRateMod(&encounterRate);
|
||||
if (!ignoreAbility && !GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
|
||||
{
|
||||
u32 ability = GetMonAbility(&gPlayerParty[0]);
|
||||
|
||||
if (ability == ABILITY_STENCH && gMapHeader.mapDataId == 0x169)
|
||||
encounterRate = encounterRate * 3 / 4;
|
||||
else if (ability == ABILITY_STENCH)
|
||||
encounterRate /= 2;
|
||||
else if (ability == ABILITY_ILLUMINATE)
|
||||
encounterRate *= 2;
|
||||
else if (ability == ABILITY_WHITE_SMOKE)
|
||||
encounterRate /= 2;
|
||||
else if (ability == ABILITY_ARENA_TRAP)
|
||||
encounterRate *= 2;
|
||||
else if (ability == ABILITY_SAND_VEIL && gSaveBlock1Ptr->weather == 8)
|
||||
encounterRate /= 2;
|
||||
}
|
||||
if (encounterRate > 2880)
|
||||
encounterRate = 2880;
|
||||
return DoWildEncounterRateDiceRoll(encounterRate);
|
||||
}
|
||||
|
||||
static bool8 DoGlobalWildEncounterDiceRoll(void)
|
||||
{
|
||||
if (Random() % 100 >= 60)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 AreLegendariesInSootopolisPreventingEncounters(void)
|
||||
{
|
||||
if (gSaveBlock1Ptr->location.mapGroup != MAP_GROUP_SOOTOPOLIS_CITY
|
||||
|| gSaveBlock1Ptr->location.mapNum != MAP_ID_SOOTOPOLIS_CITY)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FlagGet(FLAG_LEGENDARIES_IN_SOOTOPOLIS);
|
||||
}
|
||||
|
||||
bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavior)
|
||||
{
|
||||
u16 headerId;
|
||||
struct Roamer *roamer;
|
||||
|
||||
if (sWildEncountersDisabled == TRUE)
|
||||
return FALSE;
|
||||
|
||||
headerId = GetCurrentMapWildMonHeaderId();
|
||||
if (headerId == 0xFFFF) // invalid
|
||||
{
|
||||
if (gMapHeader.mapDataId == 0x166)
|
||||
{
|
||||
headerId = GetBattlePikeWildMonHeaderId();
|
||||
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
|
||||
return FALSE;
|
||||
else if (DoWildEncounterRateTest(gBattlePikeWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
|
||||
return FALSE;
|
||||
else if (TryGenerateWildMon(gBattlePikeWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE) != TRUE)
|
||||
return FALSE;
|
||||
else if (!TryGenerateBattlePikeWildMon(TRUE))
|
||||
return FALSE;
|
||||
|
||||
BattleSetup_StartBattlePikeWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
if (gMapHeader.mapDataId == 0x169)
|
||||
{
|
||||
headerId = gSaveBlock2Ptr->battlePyramidWildHeaderId;
|
||||
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
|
||||
return FALSE;
|
||||
else if (DoWildEncounterRateTest(gBattlePyramidWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
|
||||
return FALSE;
|
||||
else if (TryGenerateWildMon(gBattlePyramidWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_KEEN_EYE) != TRUE)
|
||||
return FALSE;
|
||||
|
||||
GenerateBattlePyramidWildMon();
|
||||
BattleSetup_StartWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MetatileBehavior_IsLandWildEncounter(currMetaTileBehavior) == TRUE)
|
||||
{
|
||||
if (gWildMonHeaders[headerId].landMonsInfo == NULL)
|
||||
return FALSE;
|
||||
else if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
|
||||
return FALSE;
|
||||
else if (DoWildEncounterRateTest(gWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
|
||||
return FALSE;
|
||||
|
||||
if (TryStartRoamerEncounter() == TRUE)
|
||||
{
|
||||
roamer = &gSaveBlock1Ptr->roamer;
|
||||
if (!IsWildLevelAllowedByRepel(roamer->level))
|
||||
return FALSE;
|
||||
|
||||
BattleSetup_StartRoamerBattle();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DoMassOutbreakEncounterTest() == TRUE && SetUpMassOutbreakEncounter(WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
|
||||
{
|
||||
BattleSetup_StartWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// try a regular wild land encounter
|
||||
if (TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
|
||||
{
|
||||
BattleSetup_StartWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (MetatileBehavior_IsWaterWildEncounter(currMetaTileBehavior) == TRUE
|
||||
|| (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING) && MetatileBehavior_IsBridge(currMetaTileBehavior) == TRUE))
|
||||
{
|
||||
if (AreLegendariesInSootopolisPreventingEncounters() == TRUE)
|
||||
return FALSE;
|
||||
else if (gWildMonHeaders[headerId].waterMonsInfo == NULL)
|
||||
return FALSE;
|
||||
else if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
|
||||
return FALSE;
|
||||
else if (DoWildEncounterRateTest(gWildMonHeaders[headerId].waterMonsInfo->encounterRate, FALSE) != TRUE)
|
||||
return FALSE;
|
||||
|
||||
if (TryStartRoamerEncounter() == TRUE)
|
||||
{
|
||||
roamer = &gSaveBlock1Ptr->roamer;
|
||||
if (!IsWildLevelAllowedByRepel(roamer->level))
|
||||
return FALSE;
|
||||
|
||||
BattleSetup_StartRoamerBattle();
|
||||
return TRUE;
|
||||
}
|
||||
else // try a regular surfing encounter
|
||||
{
|
||||
if (TryGenerateWildMon(gWildMonHeaders[headerId].waterMonsInfo, WILD_AREA_WATER, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
|
||||
{
|
||||
BattleSetup_StartWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void RockSmashWildEncounter(void)
|
||||
{
|
||||
u16 headerId = GetCurrentMapWildMonHeaderId();
|
||||
|
||||
if (headerId != 0xFFFF)
|
||||
{
|
||||
const struct WildPokemonInfo *wildPokemonInfo = gWildMonHeaders[headerId].rockSmashMonsInfo;
|
||||
|
||||
if (wildPokemonInfo == NULL)
|
||||
{
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
else if (DoWildEncounterRateTest(wildPokemonInfo->encounterRate, 1) == TRUE
|
||||
&& TryGenerateWildMon(wildPokemonInfo, 2, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
|
||||
{
|
||||
BattleSetup_StartWildBattle();
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 SweetScentWildEncounter(void)
|
||||
{
|
||||
s16 x, y;
|
||||
u16 headerId;
|
||||
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
headerId = GetCurrentMapWildMonHeaderId();
|
||||
if (headerId == 0xFFFF) // invalid
|
||||
{
|
||||
if (gMapHeader.mapDataId == 0x166)
|
||||
{
|
||||
headerId = GetBattlePikeWildMonHeaderId();
|
||||
if (TryGenerateWildMon(gBattlePikeWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, 0) != TRUE)
|
||||
return FALSE;
|
||||
|
||||
TryGenerateBattlePikeWildMon(FALSE);
|
||||
BattleSetup_StartBattlePikeWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
if (gMapHeader.mapDataId == 0x169)
|
||||
{
|
||||
headerId = gSaveBlock2Ptr->battlePyramidWildHeaderId;
|
||||
if (TryGenerateWildMon(gBattlePyramidWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, 0) != TRUE)
|
||||
return FALSE;
|
||||
|
||||
GenerateBattlePyramidWildMon();
|
||||
BattleSetup_StartWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MetatileBehavior_IsLandWildEncounter(MapGridGetMetatileBehaviorAt(x, y)) == TRUE)
|
||||
{
|
||||
if (gWildMonHeaders[headerId].landMonsInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (TryStartRoamerEncounter() == TRUE)
|
||||
{
|
||||
BattleSetup_StartRoamerBattle();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (DoMassOutbreakEncounterTest() == TRUE)
|
||||
SetUpMassOutbreakEncounter(0);
|
||||
else
|
||||
TryGenerateWildMon(gWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, 0);
|
||||
|
||||
BattleSetup_StartWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
else if (MetatileBehavior_IsWaterWildEncounter(MapGridGetMetatileBehaviorAt(x, y)) == TRUE)
|
||||
{
|
||||
if (AreLegendariesInSootopolisPreventingEncounters() == TRUE)
|
||||
return FALSE;
|
||||
if (gWildMonHeaders[headerId].waterMonsInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (TryStartRoamerEncounter() == TRUE)
|
||||
{
|
||||
BattleSetup_StartRoamerBattle();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TryGenerateWildMon(gWildMonHeaders[headerId].waterMonsInfo, WILD_AREA_WATER, 0);
|
||||
BattleSetup_StartWildBattle();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 DoesCurrentMapHaveFishingMons(void)
|
||||
{
|
||||
u16 headerId = GetCurrentMapWildMonHeaderId();
|
||||
|
||||
if (headerId != 0xFFFF && gWildMonHeaders[headerId].fishingMonsInfo != NULL)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void FishingWildEncounter(u8 rod)
|
||||
{
|
||||
u16 species;
|
||||
|
||||
if (CheckFeebas() == TRUE)
|
||||
{
|
||||
u8 level = ChooseWildMonLevel(&gWildFeebasRoute119Data);
|
||||
|
||||
species = gWildFeebasRoute119Data.species;
|
||||
CreateWildMon(species, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
species = GenerateFishingWildMon(gWildMonHeaders[GetCurrentMapWildMonHeaderId()].fishingMonsInfo, rod);
|
||||
}
|
||||
IncrementGameStat(GAME_STAT_FISHING_CAPTURES);
|
||||
SetPokemonAnglerSpecies(species);
|
||||
BattleSetup_StartWildBattle();
|
||||
}
|
||||
|
||||
u16 GetLocalWildMon(bool8 *isWaterMon)
|
||||
{
|
||||
u16 headerId;
|
||||
const struct WildPokemonInfo *landMonsInfo;
|
||||
const struct WildPokemonInfo *waterMonsInfo;
|
||||
|
||||
*isWaterMon = FALSE;
|
||||
headerId = GetCurrentMapWildMonHeaderId();
|
||||
if (headerId == 0xFFFF)
|
||||
return SPECIES_NONE;
|
||||
landMonsInfo = gWildMonHeaders[headerId].landMonsInfo;
|
||||
waterMonsInfo = gWildMonHeaders[headerId].waterMonsInfo;
|
||||
// Neither
|
||||
if (landMonsInfo == NULL && waterMonsInfo == NULL)
|
||||
return SPECIES_NONE;
|
||||
// Land Pokemon
|
||||
else if (landMonsInfo != NULL && waterMonsInfo == NULL)
|
||||
return landMonsInfo->wildPokemon[ChooseWildMonIndex_Land()].species;
|
||||
// Water Pokemon
|
||||
else if (landMonsInfo == NULL && waterMonsInfo != NULL)
|
||||
{
|
||||
*isWaterMon = TRUE;
|
||||
return waterMonsInfo->wildPokemon[ChooseWildMonIndex_WaterRock()].species;
|
||||
}
|
||||
// Either land or water Pokemon
|
||||
if ((Random() % 100) < 80)
|
||||
{
|
||||
return landMonsInfo->wildPokemon[ChooseWildMonIndex_Land()].species;
|
||||
}
|
||||
else
|
||||
{
|
||||
*isWaterMon = TRUE;
|
||||
return waterMonsInfo->wildPokemon[ChooseWildMonIndex_WaterRock()].species;
|
||||
}
|
||||
}
|
||||
|
||||
u16 GetLocalWaterMon(void)
|
||||
{
|
||||
u16 headerId = GetCurrentMapWildMonHeaderId();
|
||||
|
||||
if (headerId != 0xFFFF)
|
||||
{
|
||||
const struct WildPokemonInfo *waterMonsInfo = gWildMonHeaders[headerId].waterMonsInfo;
|
||||
|
||||
if (waterMonsInfo)
|
||||
return waterMonsInfo->wildPokemon[ChooseWildMonIndex_WaterRock()].species;
|
||||
}
|
||||
return SPECIES_NONE;
|
||||
}
|
||||
|
||||
bool8 UpdateRepelCounter(void)
|
||||
{
|
||||
u16 steps;
|
||||
|
||||
if (InBattlePike() || InBattlePyramid())
|
||||
return FALSE;
|
||||
if (InUnionRoom() == TRUE)
|
||||
return FALSE;
|
||||
|
||||
steps = VarGet(VAR_REPEL_STEP_COUNT);
|
||||
|
||||
if (steps != 0)
|
||||
{
|
||||
steps--;
|
||||
VarSet(VAR_REPEL_STEP_COUNT, steps);
|
||||
if (steps == 0)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_RepelWoreOff);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 IsWildLevelAllowedByRepel(u8 wildLevel)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
if (!VarGet(VAR_REPEL_STEP_COUNT))
|
||||
return TRUE;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_HP) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
||||
{
|
||||
u8 ourLevel = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL);
|
||||
|
||||
if (wildLevel < ourLevel)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 IsAbilityAllowingEncounter(u8 level)
|
||||
{
|
||||
u8 ability;
|
||||
|
||||
if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
|
||||
return TRUE;
|
||||
|
||||
ability = GetMonAbility(&gPlayerParty[0]);
|
||||
if (ability == ABILITY_KEEN_EYE || ability == ABILITY_INTIMIDATE)
|
||||
{
|
||||
u8 playerMonLevel = GetMonData(&gPlayerParty[0], MON_DATA_LEVEL);
|
||||
if (playerMonLevel > 5 && level <= playerMonLevel - 5 && !(Random() % 2))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 TryGetRandomWildMonIndexByType(const struct WildPokemon *wildMon, u8 type, u8 numMon, u8 *monIndex)
|
||||
{
|
||||
u8 validIndexes[numMon]; // variable length array, an interesting feature
|
||||
u8 i, validMonCount;
|
||||
|
||||
for (i = 0; i < numMon; i++)
|
||||
validIndexes[i] = 0;
|
||||
|
||||
for (validMonCount = 0, i = 0; i < numMon; i++)
|
||||
{
|
||||
if (gBaseStats[wildMon[i].species].type1 == type || gBaseStats[wildMon[i].species].type2 == type)
|
||||
validIndexes[validMonCount++] = i;
|
||||
}
|
||||
|
||||
if (validMonCount == 0 || validMonCount == numMon)
|
||||
return FALSE;
|
||||
|
||||
*monIndex = validIndexes[Random() % validMonCount];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[0], MON_DATA_SANITY_BIT3))
|
||||
return FALSE;
|
||||
else if (GetMonAbility(&gPlayerParty[0]) != ability)
|
||||
return FALSE;
|
||||
else if (Random() % 2 != 0)
|
||||
return FALSE;
|
||||
|
||||
return TryGetRandomWildMonIndexByType(wildMon, type, LAND_WILD_COUNT, monIndex);
|
||||
}
|
||||
|
||||
static void ApplyFluteEncounterRateMod(u32 *encRate)
|
||||
{
|
||||
if (FlagGet(FLAG_SYS_ENC_UP_ITEM) == TRUE)
|
||||
*encRate += *encRate / 2;
|
||||
else if (FlagGet(FLAG_SYS_ENC_DOWN_ITEM) == TRUE)
|
||||
*encRate = *encRate / 2;
|
||||
}
|
||||
|
||||
static void ApplyCleanseTagEncounterRateMod(u32 *encRate)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[0], MON_DATA_HELD_ITEM) == ITEM_CLEANSE_TAG)
|
||||
*encRate = *encRate * 2 / 3;
|
||||
}
|
||||
Reference in New Issue
Block a user