merge daycare with master
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "tv.h"
|
||||
#include "safari_zone.h"
|
||||
#include "battle_string_ids.h"
|
||||
#include "data2.h"
|
||||
|
||||
struct UnknownStruct6
|
||||
{
|
||||
@@ -353,7 +354,7 @@ static const u8 sUnknown_0831BCF3[] = {4, 4, 4, 4};
|
||||
void CB2_InitBattle(void)
|
||||
{
|
||||
MoveSaveBlocks_ResetHeap();
|
||||
AllocateBattleResrouces();
|
||||
AllocateBattleResources();
|
||||
AllocateBattleSpritesData();
|
||||
AllocateMonSpritesGfx();
|
||||
sub_8185F84();
|
||||
@@ -509,7 +510,7 @@ static void sub_8036A5C(void)
|
||||
|
||||
gBattleStruct->field_182 = r6;
|
||||
*(&gBattleStruct->field_183) = r6 >> 8;
|
||||
gBattleStruct->field_183 |= FlagGet(SYS_FRONTIER_PASS) << 7;
|
||||
gBattleStruct->field_183 |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
|
||||
}
|
||||
|
||||
static void SetPlayerBerryDataInBattleStruct(void)
|
||||
@@ -1610,7 +1611,7 @@ void BattleMainCB2(void)
|
||||
|
||||
if (gMain.heldKeys & B_BUTTON && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450())
|
||||
{
|
||||
gScriptResult = gBattleOutcome = BATTLE_PLAYER_TELEPORTED;
|
||||
gSpecialVar_Result = gBattleOutcome = BATTLE_PLAYER_TELEPORTED;
|
||||
ResetPaletteFadeControl();
|
||||
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
|
||||
SetMainCallback2(CB2_QuitRecordedBattle);
|
||||
@@ -2068,7 +2069,7 @@ static void sub_8038F34(void)
|
||||
|
||||
if (!gSaveBlock2Ptr->field_CA9_b && i == monsCount)
|
||||
{
|
||||
if (FlagGet(SYS_FRONTIER_PASS))
|
||||
if (FlagGet(FLAG_SYS_FRONTIER_PASS))
|
||||
{
|
||||
FreeAllWindowBuffers();
|
||||
SetMainCallback2(sub_80392A8);
|
||||
@@ -2477,15 +2478,6 @@ static void sub_80398D0(struct Sprite *sprite)
|
||||
}
|
||||
}
|
||||
|
||||
// to get rid of once the struct is declared in a header
|
||||
struct MonCoords
|
||||
{
|
||||
// This would use a bitfield, but sub_8079F44
|
||||
// uses it as a u8 and casting won't match.
|
||||
u8 coords; // u8 x:4, y:4;
|
||||
u8 y_offset;
|
||||
};
|
||||
|
||||
extern const struct MonCoords gMonFrontPicCoords[];
|
||||
extern const struct MonCoords gCastformFrontSpriteCoords[];
|
||||
|
||||
@@ -2853,9 +2845,9 @@ static void BattleStartClearSetData(void)
|
||||
*(i + 3 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
|
||||
{
|
||||
*(gBattleStruct->field_294 + i) = 6;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + i) = 6;
|
||||
}
|
||||
|
||||
gBattleStruct->field_DF = 0;
|
||||
@@ -2935,8 +2927,8 @@ void SwitchInClearSetData(void)
|
||||
{
|
||||
gDisableStructs[gActiveBank].substituteHP = disableStructCopy.substituteHP;
|
||||
gDisableStructs[gActiveBank].bankWithSureHit = disableStructCopy.bankWithSureHit;
|
||||
gDisableStructs[gActiveBank].perishSong1 = disableStructCopy.perishSong1;
|
||||
gDisableStructs[gActiveBank].perishSong2 = disableStructCopy.perishSong2;
|
||||
gDisableStructs[gActiveBank].perishSongTimer1 = disableStructCopy.perishSongTimer1;
|
||||
gDisableStructs[gActiveBank].perishSongTimer2 = disableStructCopy.perishSongTimer2;
|
||||
gDisableStructs[gActiveBank].bankPreventingEscape = disableStructCopy.bankPreventingEscape;
|
||||
}
|
||||
|
||||
@@ -3682,7 +3674,7 @@ static void TryDoEventsBeforeFirstTurn(void)
|
||||
}
|
||||
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
|
||||
{
|
||||
*(gBattleStruct->field_5C + i) = 6;
|
||||
*(gBattleStruct->monToSwitchIntoId + i) = 6;
|
||||
gActionForBanks[i] = ACTION_INIT_VALUE;
|
||||
gChosenMovesByBanks[i] = MOVE_NONE;
|
||||
}
|
||||
@@ -3793,7 +3785,7 @@ void BattleTurnPassed(void)
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
*(gBattleStruct->field_5C + i) = 6;
|
||||
*(gBattleStruct->monToSwitchIntoId + i) = 6;
|
||||
|
||||
*(&gBattleStruct->field_91) = gAbsentBankFlags;
|
||||
BattleHandleAddTextPrinter(gText_EmptyString3, 0);
|
||||
@@ -3884,7 +3876,7 @@ void sub_803BDA0(u8 bank)
|
||||
gUnknown_0203CF00[i] = *(bank * 3 + i + (u8*)(gBattleStruct->field_60));
|
||||
|
||||
r4 = pokemon_order_func(gBattlePartyID[bank]);
|
||||
r1 = pokemon_order_func(*(gBattleStruct->field_5C + bank));
|
||||
r1 = pokemon_order_func(*(gBattleStruct->monToSwitchIntoId + bank));
|
||||
sub_81B8FB0(r4, r1);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
@@ -3932,7 +3924,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
gBattleCommunication[gActiveBank] = STATE_BEFORE_ACTION_CHOSEN;
|
||||
break;
|
||||
case STATE_BEFORE_ACTION_CHOSEN: // choose an action
|
||||
*(gBattleStruct->field_5C + gActiveBank) = 6;
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_MULTI
|
||||
|| !(identity & BIT_MON)
|
||||
|| gBattleStruct->field_91 & gBitTable[GetBankByIdentity(identity ^ BIT_MON)]
|
||||
@@ -4050,9 +4042,9 @@ static void HandleTurnActionSelectionState(void)
|
||||
else
|
||||
{
|
||||
if (gActiveBank == 2 && gActionForBanks[0] == ACTION_SWITCH)
|
||||
EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
|
||||
EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
|
||||
else if (gActiveBank == 3 && gActionForBanks[1] == ACTION_SWITCH)
|
||||
EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
|
||||
EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
|
||||
else
|
||||
EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
|
||||
}
|
||||
@@ -4339,7 +4331,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
for (i = 0; i < gNoOfAllBanks; i++)
|
||||
{
|
||||
if (gActionForBanks[i] == ACTION_SWITCH)
|
||||
sub_80571DC(i, *(gBattleStruct->field_5C + i));
|
||||
sub_80571DC(i, *(gBattleStruct->monToSwitchIntoId + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4363,7 +4355,7 @@ static bool8 sub_803CDB8(void)
|
||||
|
||||
static void sub_803CDF8(void)
|
||||
{
|
||||
*(gBattleStruct->field_5C + gActiveBank) = gBattleBufferB[gActiveBank][1];
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = gBattleBufferB[gActiveBank][1];
|
||||
RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
@@ -4435,7 +4427,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves)
|
||||
|
||||
// badge boost
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER))
|
||||
&& FlagGet(BADGE03_GET)
|
||||
&& FlagGet(FLAG_BADGE03_GET)
|
||||
&& GetBankSide(bank1) == SIDE_PLAYER)
|
||||
{
|
||||
speedBank1 = (speedBank1 * 110) / 100;
|
||||
@@ -4469,7 +4461,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves)
|
||||
|
||||
// badge boost
|
||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER))
|
||||
&& FlagGet(BADGE03_GET)
|
||||
&& FlagGet(FLAG_BADGE03_GET)
|
||||
&& GetBankSide(bank2) == SIDE_PLAYER)
|
||||
{
|
||||
speedBank2 = (speedBank2 * 110) / 100;
|
||||
@@ -4758,7 +4750,7 @@ static void HandleEndTurn_BattleWon(void)
|
||||
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
|
||||
{
|
||||
gScriptResult = gBattleOutcome;
|
||||
gSpecialVar_Result = gBattleOutcome;
|
||||
gBattleTextBuff1[0] = gBattleOutcome;
|
||||
gBankAttacker = GetBankByIdentity(IDENTITY_PLAYER_MON1);
|
||||
gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost;
|
||||
@@ -5020,7 +5012,7 @@ static void ReturnFromBattleToOverworld(void)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK && gReceivedRemoteLinkPlayers != 0)
|
||||
return;
|
||||
|
||||
gScriptResult = gBattleOutcome;
|
||||
gSpecialVar_Result = gBattleOutcome;
|
||||
gMain.inBattle = 0;
|
||||
gMain.callback1 = gPreBattleCallback1;
|
||||
|
||||
@@ -5618,7 +5610,7 @@ static void HandleAction_NothingIsFainted(void)
|
||||
|
||||
static void HandleAction_ActionFinished(void)
|
||||
{
|
||||
*(gBattleStruct->field_5C + gBanksByTurnOrder[gCurrentTurnActionNumber]) = 6;
|
||||
*(gBattleStruct->monToSwitchIntoId + gBanksByTurnOrder[gCurrentTurnActionNumber]) = 6;
|
||||
gCurrentTurnActionNumber++;
|
||||
gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber];
|
||||
SpecialStatusesClear();
|
||||
|
||||
@@ -36,9 +36,9 @@ static bool8 ShouldUseItem(void);
|
||||
static bool8 ShouldSwitchIfPerishSong(void)
|
||||
{
|
||||
if (gStatuses3[gActiveBank] & STATUS3_PERISH_SONG
|
||||
&& gDisableStructs[gActiveBank].perishSong1 == 0)
|
||||
&& gDisableStructs[gActiveBank].perishSongTimer1 == 0)
|
||||
{
|
||||
*(gBattleStruct->field_294 + gActiveBank) = 6;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
|
||||
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % 3 < 2)
|
||||
{
|
||||
// we found a mon
|
||||
*(gBattleStruct->field_294 + gActiveBank) = i;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -206,9 +206,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
continue;
|
||||
if (i == gBattlePartyID[bankIn2])
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn1))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn2))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
|
||||
continue;
|
||||
|
||||
species = GetMonData(&party[i], MON_DATA_SPECIES);
|
||||
@@ -220,7 +220,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
if (absorbingTypeAbility == monAbility && Random() & 1)
|
||||
{
|
||||
// we found a mon
|
||||
*(gBattleStruct->field_294 + gActiveBank) = i;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -240,13 +240,13 @@ static bool8 ShouldSwitchIfNaturalCure(void)
|
||||
|
||||
if ((gUnknown_02024250[gActiveBank] == 0 || gUnknown_02024250[gActiveBank] == 0xFFFF) && Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->field_294 + gActiveBank) = 6;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else if (gBattleMoves[gUnknown_02024250[gActiveBank]].power == 0 && Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->field_294 + gActiveBank) = 6;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ static bool8 ShouldSwitchIfNaturalCure(void)
|
||||
return TRUE;
|
||||
if (Random() & 1)
|
||||
{
|
||||
*(gBattleStruct->field_294 + gActiveBank) = 6;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -400,9 +400,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
|
||||
continue;
|
||||
if (i == gBattlePartyID[bankIn2])
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn1))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn2))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
|
||||
continue;
|
||||
|
||||
species = GetMonData(&party[i], MON_DATA_SPECIES);
|
||||
@@ -425,7 +425,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
|
||||
moveFlags = AI_TypeCalc(move, gBattleMons[bankIn1].species, gBattleMons[bankIn1].ability);
|
||||
if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % moduloPercent == 0)
|
||||
{
|
||||
*(gBattleStruct->field_294 + gActiveBank) = i;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i;
|
||||
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -508,9 +508,9 @@ static bool8 ShouldSwitch(void)
|
||||
continue;
|
||||
if (i == gBattlePartyID[bankIn2])
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn1))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn2))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
|
||||
continue;
|
||||
|
||||
availableToSwitch++;
|
||||
@@ -554,7 +554,7 @@ void AI_TrySwitchOrUseItem(void)
|
||||
{
|
||||
if (ShouldSwitch())
|
||||
{
|
||||
if (*(gBattleStruct->field_294 + gActiveBank) == 6)
|
||||
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) == 6)
|
||||
{
|
||||
s32 monToSwitchId = GetMostSuitableMonToSwitchInto();
|
||||
if (monToSwitchId == 6)
|
||||
@@ -590,19 +590,19 @@ void AI_TrySwitchOrUseItem(void)
|
||||
continue;
|
||||
if (monToSwitchId == gBattlePartyID[bankIn2])
|
||||
continue;
|
||||
if (monToSwitchId == *(gBattleStruct->field_5C + bankIn1))
|
||||
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn1))
|
||||
continue;
|
||||
if (monToSwitchId == *(gBattleStruct->field_5C + bankIn2))
|
||||
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn2))
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*(gBattleStruct->field_294 + gActiveBank) = monToSwitchId;
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = monToSwitchId;
|
||||
}
|
||||
|
||||
*(gBattleStruct->field_5C + gActiveBank) = *(gBattleStruct->field_294 + gActiveBank);
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank);
|
||||
return;
|
||||
}
|
||||
else if (ShouldUseItem())
|
||||
@@ -614,28 +614,25 @@ void AI_TrySwitchOrUseItem(void)
|
||||
EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBank ^ BIT_SIDE) << 8);
|
||||
}
|
||||
|
||||
#define TYPE_FORESIGHT 0xFE
|
||||
#define TYPE_ENDTABLE 0xFF
|
||||
|
||||
static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var)
|
||||
{
|
||||
s32 i = 0;
|
||||
|
||||
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
else if (gTypeEffectiveness[i] == atkType)
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == atkType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == defType1)
|
||||
*var = (*var * gTypeEffectiveness[i + 2]) / 10;
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
|
||||
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == defType2 && defType1 != defType2)
|
||||
*var = (*var * gTypeEffectiveness[i + 2]) / 10;
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
|
||||
*var = (*var * TYPE_EFFECT_MULTIPLIER(i)) / 10;
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
@@ -654,8 +651,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
|
||||
u8 invalidMons;
|
||||
u16 move;
|
||||
|
||||
if (*(gBattleStruct->field_5C + gActiveBank) != 6)
|
||||
return *(gBattleStruct->field_5C + gActiveBank);
|
||||
if (*(gBattleStruct->monToSwitchIntoId + gActiveBank) != 6)
|
||||
return *(gBattleStruct->monToSwitchIntoId + gActiveBank);
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
|
||||
return gBattlePartyID[gActiveBank] + 1;
|
||||
|
||||
@@ -711,8 +708,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
|
||||
&& !(gBitTable[i] & invalidMons)
|
||||
&& gBattlePartyID[bankIn1] != i
|
||||
&& gBattlePartyID[bankIn2] != i
|
||||
&& i != *(gBattleStruct->field_5C + bankIn1)
|
||||
&& i != *(gBattleStruct->field_5C + bankIn2))
|
||||
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn1)
|
||||
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn2))
|
||||
{
|
||||
u8 type1 = gBaseStats[species].type1;
|
||||
u8 type2 = gBaseStats[species].type2;
|
||||
@@ -771,9 +768,9 @@ u8 GetMostSuitableMonToSwitchInto(void)
|
||||
continue;
|
||||
if (gBattlePartyID[bankIn2] == i)
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn1))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->field_5C + bankIn2))
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn2))
|
||||
continue;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
|
||||
@@ -36,7 +36,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
|
||||
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleOutcome;
|
||||
extern u16 gBattle_BG0_X;
|
||||
|
||||
@@ -36,7 +36,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
|
||||
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleOutcome;
|
||||
extern u16 gBattle_BG0_X;
|
||||
|
||||
@@ -1168,7 +1168,7 @@ static void OpponentHandleLoadMonSprite(void)
|
||||
|
||||
static void OpponentHandleSwitchInAnim(void)
|
||||
{
|
||||
*(gBattleStruct->field_5C + gActiveBank) = 6;
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6;
|
||||
gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1];
|
||||
sub_80613DC(gActiveBank, gBattleBufferA[gActiveBank][2]);
|
||||
gBattleBankFunc[gActiveBank] = sub_805FDF0;
|
||||
@@ -1627,7 +1627,7 @@ static void OpponentHandleChoosePokemon(void)
|
||||
{
|
||||
s32 chosenMonId;
|
||||
|
||||
if (*(gBattleStruct->field_294 + gActiveBank) == 6)
|
||||
if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) == 6)
|
||||
{
|
||||
chosenMonId = GetMostSuitableMonToSwitchInto();
|
||||
|
||||
@@ -1670,12 +1670,12 @@ static void OpponentHandleChoosePokemon(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
chosenMonId = *(gBattleStruct->field_294 + gActiveBank);
|
||||
*(gBattleStruct->field_294 + gActiveBank) = 6;
|
||||
chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank);
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6;
|
||||
}
|
||||
|
||||
|
||||
*(gBattleStruct->field_5C + gActiveBank) = chosenMonId;
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = chosenMonId;
|
||||
EmitChosenMonReturnValue(1, chosenMonId, NULL);
|
||||
OpponentBufferExecCompleted();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ extern struct MusicPlayerInfo gMPlay_BGM;
|
||||
extern u16 gPartnerTrainerId;
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u8 gBattleMonForms[BATTLE_BANKS_COUNT];
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gUnknown_0203CEE8;
|
||||
extern u8 gUnknown_0203CEE9;
|
||||
extern u8 gUnknown_0203CF00[];
|
||||
@@ -1416,7 +1416,7 @@ static void CompleteWhenChoseItem(void)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
EmitOneReturnValue(1, gScriptItemId);
|
||||
EmitOneReturnValue(1, gSpecialVar_ItemId);
|
||||
PlayerBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
|
||||
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleOutcome;
|
||||
extern u16 gBattle_BG0_X;
|
||||
@@ -1581,7 +1581,7 @@ static void PlayerPartnerHandleChoosePokemon(void)
|
||||
}
|
||||
}
|
||||
|
||||
*(gBattleStruct->field_5C + gActiveBank) = chosenMonId;
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = chosenMonId;
|
||||
EmitChosenMonReturnValue(1, chosenMonId, NULL);
|
||||
PlayerPartnerBufferExecCompleted();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
|
||||
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleOutcome;
|
||||
extern u16 gBattle_BG0_X;
|
||||
@@ -1474,8 +1474,8 @@ static void RecordedOpponentHandleChooseItem(void)
|
||||
|
||||
static void RecordedOpponentHandleChoosePokemon(void)
|
||||
{
|
||||
*(gBattleStruct->field_5C + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
|
||||
EmitChosenMonReturnValue(1, *(gBattleStruct->field_5C + gActiveBank), NULL);
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
|
||||
EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBank), NULL);
|
||||
RecordedOpponentBufferExecCompleted();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
|
||||
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleOutcome;
|
||||
extern u16 gBattle_BG0_X;
|
||||
@@ -1492,8 +1492,8 @@ static void RecordedPlayerHandleChooseItem(void)
|
||||
|
||||
static void RecordedPlayerHandleChoosePokemon(void)
|
||||
{
|
||||
*(gBattleStruct->field_5C + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
|
||||
EmitChosenMonReturnValue(1, *(gBattleStruct->field_5C + gActiveBank), NULL);
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank);
|
||||
EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBank), NULL);
|
||||
RecordedPlayerBufferExecCompleted();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
|
||||
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleOutcome;
|
||||
extern u16 gBattle_BG0_X;
|
||||
@@ -305,7 +305,7 @@ static void CompleteWhenChosePokeblock(void)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
EmitOneReturnValue(1, gScriptItemId);
|
||||
EmitOneReturnValue(1, gSpecialVar_ItemId);
|
||||
SafariBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ extern struct MusicPlayerInfo gMPlay_BGM;
|
||||
extern u16 gPartnerTrainerId;
|
||||
extern struct SpriteTemplate gUnknown_0202499C;
|
||||
extern u8 gBattleMonForms[BATTLE_BANKS_COUNT];
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT];
|
||||
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
|
||||
extern u8 gBattleOutcome;
|
||||
@@ -314,7 +314,7 @@ static void CompleteOnChosenItem(void)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
|
||||
{
|
||||
EmitOneReturnValue(1, gScriptItemId);
|
||||
EmitOneReturnValue(1, gSpecialVar_ItemId);
|
||||
WallyBufferExecCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1907,7 +1907,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
|
||||
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.bank, *(&gBattleStruct->field_52))
|
||||
break;
|
||||
case B_TXT_PC_CREATOR_NAME: // lanette pc
|
||||
if (FlagGet(SYS_PC_LANETTE))
|
||||
if (FlagGet(FLAG_SYS_PC_LANETTE))
|
||||
toCpy = gText_Lanettes;
|
||||
else
|
||||
toCpy = gText_Someones;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "calculate_base_damage.h"
|
||||
#include "rng.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "battle_interface.h"
|
||||
#include "species.h"
|
||||
#include "songs.h"
|
||||
#include "text.h"
|
||||
@@ -118,9 +119,7 @@ struct TrainerMoney
|
||||
|
||||
extern const struct BattleMove gBattleMoves[];
|
||||
extern const struct BaseStats gBaseStats[];
|
||||
extern const u8 gTypeEffectiveness[];
|
||||
extern const u16 gMissStringIds[];
|
||||
extern const u16 gTrappingMoves[];
|
||||
extern const u8 gTypeEffectiveness[336];
|
||||
extern const struct TrainerMoney gTrainerMoneyTable[];
|
||||
extern const u8* const gBattleScriptsForMoveEffects[];
|
||||
|
||||
@@ -139,7 +138,6 @@ extern void sub_81A5BF8(void); // battle frontier 2
|
||||
extern void sub_81A5D44(void); // battle frontier 2
|
||||
extern void sub_81B8E80(u8 bank, u8, u8); // party menu
|
||||
extern bool8 sub_81B1250(void); // ?
|
||||
extern u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); // battle interface
|
||||
extern bool8 InBattlePike(void);
|
||||
extern bool8 InBattlePyramid(void);
|
||||
extern u16 GetBattlePyramidPickupItemId(void);
|
||||
@@ -340,7 +338,7 @@ static void atk48_playstatchangeanimation(void);
|
||||
static void atk49_moveend(void);
|
||||
static void atk4A_typecalc2(void);
|
||||
static void atk4B_return_atk_to_ball(void);
|
||||
static void atk4C_copy_poke_data(void);
|
||||
static void atk4C_get_switched_mon_data(void);
|
||||
static void atk4D_switch_data_update(void);
|
||||
static void atk4E_switchin_anim(void);
|
||||
static void atk4F_jump_if_cannot_switch(void);
|
||||
@@ -368,7 +366,7 @@ static void atk64_statusanimation(void);
|
||||
static void atk65_status2animation(void);
|
||||
static void atk66_chosenstatusanimation(void);
|
||||
static void atk67_yesnobox(void);
|
||||
static void atk68_80246A0(void);
|
||||
static void atk68_cancel_everyones_actions(void);
|
||||
static void atk69_dmg_adjustment3(void);
|
||||
static void atk6A_removeitem(void);
|
||||
static void atk6B_atknameinbuff1(void);
|
||||
@@ -457,7 +455,7 @@ static void atkBD_copyfoestats(void);
|
||||
static void atkBE_rapidspinfree(void);
|
||||
static void atkBF_set_defense_curl(void);
|
||||
static void atkC0_recoverbasedonsunlight(void);
|
||||
static void atkC1_hidden_power(void);
|
||||
static void atkC1_hidden_power_calc(void);
|
||||
static void atkC2_selectnexttarget(void);
|
||||
static void atkC3_setfutureattack(void);
|
||||
static void atkC4_beat_up(void);
|
||||
@@ -592,7 +590,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atk49_moveend,
|
||||
atk4A_typecalc2,
|
||||
atk4B_return_atk_to_ball,
|
||||
atk4C_copy_poke_data,
|
||||
atk4C_get_switched_mon_data,
|
||||
atk4D_switch_data_update,
|
||||
atk4E_switchin_anim,
|
||||
atk4F_jump_if_cannot_switch,
|
||||
@@ -620,7 +618,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atk65_status2animation,
|
||||
atk66_chosenstatusanimation,
|
||||
atk67_yesnobox,
|
||||
atk68_80246A0,
|
||||
atk68_cancel_everyones_actions,
|
||||
atk69_dmg_adjustment3,
|
||||
atk6A_removeitem,
|
||||
atk6B_atknameinbuff1,
|
||||
@@ -709,7 +707,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atkBE_rapidspinfree,
|
||||
atkBF_set_defense_curl,
|
||||
atkC0_recoverbasedonsunlight,
|
||||
atkC1_hidden_power,
|
||||
atkC1_hidden_power_calc,
|
||||
atkC2_selectnexttarget,
|
||||
atkC3_setfutureattack,
|
||||
atkC4_beat_up,
|
||||
@@ -828,7 +826,7 @@ static const u32 sStatusFlagsForMoveEffects[] =
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
STATUS2_ESCAPE_PREVENTION,
|
||||
0x08000000,
|
||||
STATUS2_NIGHTMARE,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
@@ -1244,7 +1242,7 @@ bool8 JumpIfMoveAffectedByProtect(u16 move)
|
||||
return affected;
|
||||
}
|
||||
|
||||
bool8 AccuracyCalcHelper(u16 move)
|
||||
static bool8 AccuracyCalcHelper(u16 move)
|
||||
{
|
||||
if (gStatuses3[gBankTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBankTarget].bankWithSureHit == gBankAttacker)
|
||||
{
|
||||
@@ -1543,9 +1541,6 @@ static void ModulateDmgByType(u8 multiplier)
|
||||
}
|
||||
}
|
||||
|
||||
#define TYPE_FORESIGHT 0xFE
|
||||
#define TYPE_ENDTABLE 0xFF
|
||||
|
||||
static void atk06_typecalc(void)
|
||||
{
|
||||
s32 i = 0;
|
||||
@@ -1577,24 +1572,24 @@ static void atk06_typecalc(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
else if (gTypeEffectiveness[i] == moveType)
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1)
|
||||
ModulateDmgByType(gTypeEffectiveness[i + 2]);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1)
|
||||
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2 &&
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 &&
|
||||
gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2)
|
||||
ModulateDmgByType(gTypeEffectiveness[i + 2]);
|
||||
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
@@ -1636,45 +1631,46 @@ static void CheckWonderGuardAndLevitate(void)
|
||||
return;
|
||||
}
|
||||
|
||||
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
if (gTypeEffectiveness[i] == moveType)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check no effect
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1 && gTypeEffectiveness[i + 2] == 0)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
gProtectStructs[gBankAttacker].targetNotAffected = 1;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2 &&
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 &&
|
||||
gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 &&
|
||||
gTypeEffectiveness[i + 2] == TYPE_MUL_NO_EFFECT)
|
||||
TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
gProtectStructs[gBankAttacker].targetNotAffected = 1;
|
||||
}
|
||||
|
||||
// check super effective
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1 && gTypeEffectiveness[i + 2] == 20)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20)
|
||||
flags |= 1;
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
flags |= 1;
|
||||
|
||||
// check not very effective
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1 && gTypeEffectiveness[i + 2] == 5)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5)
|
||||
flags |= 2;
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == TYPE_MUL_NOT_EFFECTIVE)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
flags |= 2;
|
||||
}
|
||||
i += 3;
|
||||
@@ -1749,9 +1745,9 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i]!= TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[bankDef].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
@@ -1759,15 +1755,15 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef)
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (gTypeEffectiveness[i] == moveType)
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[bankDef].type1)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[bankDef].type1)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[bankDef].type2 &&
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[bankDef].type2 &&
|
||||
gBattleMons[bankDef].type1 != gBattleMons[bankDef].type2)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
@@ -1801,21 +1797,21 @@ u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
if (gTypeEffectiveness[i] == moveType)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == type1)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == type1)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == type2 && type1 != type2)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == type2 && type1 != type2)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
@@ -5235,9 +5231,9 @@ static void atk4A_typecalc2(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i]!= TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT)
|
||||
{
|
||||
@@ -5250,43 +5246,43 @@ static void atk4A_typecalc2(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (gTypeEffectiveness[i] == moveType)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1)
|
||||
{
|
||||
if (gTypeEffectiveness[i + 2] == 0)
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
break;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 2] == 5)
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_NOTVERYEFFECTIVE;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 2] == 20)
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_SUPEREFFECTIVE;
|
||||
}
|
||||
}
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == 0)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
break;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == 5)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_NOTVERYEFFECTIVE;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == 20)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_SUPEREFFECTIVE;
|
||||
}
|
||||
@@ -5325,16 +5321,16 @@ static void atk4B_return_atk_to_ball(void)
|
||||
gBattlescriptCurrInstr++;
|
||||
}
|
||||
|
||||
static void atk4C_copy_poke_data(void)
|
||||
static void atk4C_get_switched_mon_data(void)
|
||||
{
|
||||
if (gBattleExecBuffer)
|
||||
return;
|
||||
|
||||
gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]);
|
||||
|
||||
gBattlePartyID[gActiveBank] = *(gBattleStruct->field_5C + gActiveBank);
|
||||
gBattlePartyID[gActiveBank] = *(gBattleStruct->monToSwitchIntoId + gActiveBank);
|
||||
|
||||
EmitGetMonData(0, 0, gBitTable[gBattlePartyID[gActiveBank]]);
|
||||
EmitGetMonData(0, REQUEST_ALL_BATTLE, gBitTable[gBattlePartyID[gActiveBank]]);
|
||||
MarkBufferBankForExecution(gActiveBank);
|
||||
|
||||
gBattlescriptCurrInstr += 2;
|
||||
@@ -5371,7 +5367,7 @@ static void atk4D_switch_data_update(void)
|
||||
|
||||
if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
for (i = 0; i < BATTLE_STATS_NO; i++)
|
||||
{
|
||||
gBattleMons[gActiveBank].statStages[i] = oldData.statStages[i];
|
||||
}
|
||||
@@ -5387,11 +5383,8 @@ static void atk4D_switch_data_update(void)
|
||||
}
|
||||
|
||||
gBattleScripting.bank = gActiveBank;
|
||||
gBattleTextBuff1[0] = PLACEHOLDER_BEGIN;
|
||||
gBattleTextBuff1[1] = 7;
|
||||
gBattleTextBuff1[2] = gActiveBank;
|
||||
gBattleTextBuff1[3] = gBattlePartyID[gActiveBank];
|
||||
gBattleTextBuff1[4] = EOS;
|
||||
|
||||
PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gActiveBank, gBattlePartyID[gActiveBank]);
|
||||
|
||||
gBattlescriptCurrInstr += 2;
|
||||
}
|
||||
@@ -5579,7 +5572,7 @@ static void atk4F_jump_if_cannot_switch(void)
|
||||
static void sub_804CF10(u8 arg0)
|
||||
{
|
||||
*(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank];
|
||||
*(gBattleStruct->field_5C + gActiveBank) = 6;
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6;
|
||||
gBattleStruct->field_93 &= ~(gBitTable[gActiveBank]);
|
||||
|
||||
EmitChoosePokemon(0, 1, arg0, 0, gBattleStruct->field_60[gActiveBank]);
|
||||
@@ -5643,7 +5636,7 @@ static void atk50_openpartyscreen(void)
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBank].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->field_5C[2]);
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[2]);
|
||||
gSpecialStatuses[gActiveBank].flag40 = 1;
|
||||
}
|
||||
else
|
||||
@@ -5665,7 +5658,7 @@ static void atk50_openpartyscreen(void)
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBank].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->field_5C[0]);
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[0]);
|
||||
gSpecialStatuses[gActiveBank].flag40 = 1;
|
||||
}
|
||||
else if (!(flags & 1))
|
||||
@@ -5686,7 +5679,7 @@ static void atk50_openpartyscreen(void)
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBank].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->field_5C[3]);
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[3]);
|
||||
gSpecialStatuses[gActiveBank].flag40 = 1;
|
||||
}
|
||||
else
|
||||
@@ -5708,7 +5701,7 @@ static void atk50_openpartyscreen(void)
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBank].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->field_5C[1]);
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[1]);
|
||||
gSpecialStatuses[gActiveBank].flag40 = 1;
|
||||
}
|
||||
else if (!(flags & 2))
|
||||
@@ -5771,7 +5764,7 @@ static void atk50_openpartyscreen(void)
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBank].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->field_5C[0]);
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[0]);
|
||||
gSpecialStatuses[gActiveBank].flag40 = 1;
|
||||
}
|
||||
}
|
||||
@@ -5787,7 +5780,7 @@ static void atk50_openpartyscreen(void)
|
||||
}
|
||||
else if (!gSpecialStatuses[gActiveBank].flag40)
|
||||
{
|
||||
sub_804CF10(gBattleStruct->field_5C[1]);
|
||||
sub_804CF10(gBattleStruct->monToSwitchIntoId[1]);
|
||||
gSpecialStatuses[gActiveBank].flag40 = 1;
|
||||
}
|
||||
}
|
||||
@@ -5841,10 +5834,10 @@ static void atk50_openpartyscreen(void)
|
||||
{
|
||||
gActiveBank = bank;
|
||||
*(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank];
|
||||
*(gBattleStruct->field_5C + gActiveBank) = 6;
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6;
|
||||
gBattleStruct->field_93 &= ~(gBitTable[gActiveBank]);
|
||||
|
||||
EmitChoosePokemon(0, hitmarkerFaintBits, *(gBattleStruct->field_5C + (gActiveBank ^ 2)), 0, gBattleStruct->field_60[gActiveBank]);
|
||||
EmitChoosePokemon(0, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + (gActiveBank ^ 2)), 0, gBattleStruct->field_60[gActiveBank]);
|
||||
MarkBufferBankForExecution(gActiveBank);
|
||||
|
||||
gBattlescriptCurrInstr += 6;
|
||||
@@ -5891,7 +5884,7 @@ static void atk51_switch_handle_order(void)
|
||||
{
|
||||
if (gBattleBufferB[i][0] == 0x22)
|
||||
{
|
||||
*(gBattleStruct->field_5C + i) = gBattleBufferB[i][1];
|
||||
*(gBattleStruct->monToSwitchIntoId + i) = gBattleBufferB[i][1];
|
||||
if (!(gBattleStruct->field_93 & gBitTable[i]))
|
||||
{
|
||||
RecordedBattle_SetBankAction(i, gBattleBufferB[i][1]);
|
||||
@@ -5913,7 +5906,7 @@ static void atk51_switch_handle_order(void)
|
||||
// fall through
|
||||
case 3:
|
||||
gBattleCommunication[0] = gBattleBufferB[gActiveBank][1];
|
||||
*(gBattleStruct->field_5C + gActiveBank) = gBattleBufferB[gActiveBank][1];
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBank) = gBattleBufferB[gActiveBank][1];
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
@@ -5927,7 +5920,7 @@ static void atk51_switch_handle_order(void)
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|
||||
{
|
||||
sub_80571DC(gActiveBank, *(gBattleStruct->field_5C + gActiveBank));
|
||||
sub_80571DC(gActiveBank, *(gBattleStruct->monToSwitchIntoId + gActiveBank));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6576,7 +6569,7 @@ static void atk67_yesnobox(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void atk68_80246A0(void)
|
||||
static void atk68_cancel_everyones_actions(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
@@ -8034,7 +8027,7 @@ static void atk8F_forcerandomswitch(void)
|
||||
|| GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE
|
||||
|| GetMonData(&party[i], MON_DATA_HP) == 0);
|
||||
}
|
||||
*(gBattleStruct->field_5C + gBankTarget) = i;
|
||||
*(gBattleStruct->monToSwitchIntoId + gBankTarget) = i;
|
||||
|
||||
if (!sub_81B1250())
|
||||
sub_803BDA0(gBankTarget);
|
||||
@@ -8558,13 +8551,11 @@ static void atk9D_mimicattackcopy(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static void atk9E_metronome(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
const u16 *move;
|
||||
s32 i, j;
|
||||
s32 i;
|
||||
|
||||
gCurrentMove = (Random() & 0x1FF) + 1;
|
||||
if (gCurrentMove > LAST_MOVE_INDEX)
|
||||
@@ -8572,102 +8563,26 @@ static void atk9E_metronome(void)
|
||||
|
||||
for (i = 0; i < 4; i++); // ?
|
||||
|
||||
for (move = sMovesForbiddenToCopy; ; move++)
|
||||
i = -1;
|
||||
while (1)
|
||||
{
|
||||
if (*move == gCurrentMove)
|
||||
i++;
|
||||
if (sMovesForbiddenToCopy[i] == gCurrentMove)
|
||||
break;
|
||||
if (*move == METRONOME_FORBIDDEN_END)
|
||||
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
|
||||
break;
|
||||
}
|
||||
|
||||
if (*move == METRONOME_FORBIDDEN_END)
|
||||
break;
|
||||
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
|
||||
{
|
||||
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
|
||||
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
|
||||
gBankTarget = GetMoveTarget(gCurrentMove, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
|
||||
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
|
||||
gBankTarget = GetMoveTarget(gCurrentMove, 0);
|
||||
}
|
||||
|
||||
#else
|
||||
__attribute__((naked))
|
||||
static void atk9E_metronome(void)
|
||||
{
|
||||
asm(
|
||||
"\n\
|
||||
.syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r8\n\
|
||||
push {r7}\n\
|
||||
ldr r7, =gCurrentMove\n\
|
||||
movs r6, 0xB1\n\
|
||||
lsls r6, 1\n\
|
||||
ldr r5, =sMovesForbiddenToCopy\n\
|
||||
ldr r0, =gBattlescriptCurrInstr\n\
|
||||
mov r8, r0\n\
|
||||
_080524EE:\n\
|
||||
bl Random\n\
|
||||
ldr r2, =0x000001ff\n\
|
||||
adds r1, r2, 0\n\
|
||||
ands r0, r1\n\
|
||||
adds r0, 0x1\n\
|
||||
strh r0, [r7]\n\
|
||||
cmp r0, r6\n\
|
||||
bhi _080524EE\n\
|
||||
movs r0, 0x3\n\
|
||||
_08052502:\n\
|
||||
subs r0, 0x1\n\
|
||||
cmp r0, 0\n\
|
||||
bge _08052502\n\
|
||||
ldr r4, =gCurrentMove\n\
|
||||
ldrh r2, [r4]\n\
|
||||
ldr r3, =0x0000ffff\n\
|
||||
subs r0, r5, 0x2\n\
|
||||
_08052510:\n\
|
||||
adds r0, 0x2\n\
|
||||
ldrh r1, [r0]\n\
|
||||
cmp r1, r2\n\
|
||||
beq _0805251C\n\
|
||||
cmp r1, r3\n\
|
||||
bne _08052510\n\
|
||||
_0805251C:\n\
|
||||
ldr r0, =0x0000ffff\n\
|
||||
cmp r1, r0\n\
|
||||
bne _080524EE\n\
|
||||
ldr r2, =gHitMarker\n\
|
||||
ldr r0, [r2]\n\
|
||||
ldr r1, =0xfffffbff\n\
|
||||
ands r0, r1\n\
|
||||
str r0, [r2]\n\
|
||||
ldr r3, =gBattleScriptsForMoveEffects\n\
|
||||
ldr r2, =gBattleMoves\n\
|
||||
ldrh r1, [r4]\n\
|
||||
lsls r0, r1, 1\n\
|
||||
adds r0, r1\n\
|
||||
lsls r0, 2\n\
|
||||
adds r0, r2\n\
|
||||
ldrb r0, [r0]\n\
|
||||
lsls r0, 2\n\
|
||||
adds r0, r3\n\
|
||||
ldr r0, [r0]\n\
|
||||
mov r1, r8\n\
|
||||
str r0, [r1]\n\
|
||||
ldrh r0, [r4]\n\
|
||||
movs r1, 0\n\
|
||||
bl GetMoveTarget\n\
|
||||
ldr r1, =gBankTarget\n\
|
||||
strb r0, [r1]\n\
|
||||
pop {r3}\n\
|
||||
mov r8, r3\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.pool\n\
|
||||
.syntax divided");
|
||||
}
|
||||
|
||||
#endif // NONMATCHING
|
||||
|
||||
static void atk9F_dmgtolevel(void)
|
||||
{
|
||||
gBattleMoveDamage = gBattleMons[gBankAttacker].level;
|
||||
@@ -8814,7 +8729,6 @@ static void atkA5_painsplitdmgcalc(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static void atkA6_settypetorandomresistance(void) // conversion 2
|
||||
{
|
||||
if (gUnknown_02024250[gBankAttacker] == 0
|
||||
@@ -8829,298 +8743,58 @@ static void atkA6_settypetorandomresistance(void) // conversion 2
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 type = 0, rands = 0;
|
||||
do
|
||||
s32 i, j, rands;
|
||||
|
||||
for (rands = 0; rands < 1000; rands++)
|
||||
{
|
||||
while (((type = (Random() & 0x7F)) > 0x70));
|
||||
while (((i = (Random() & 0x7F)) > sizeof(gTypeEffectiveness) / 3));
|
||||
|
||||
type *= 3;
|
||||
i *= 3;
|
||||
|
||||
if (gTypeEffectiveness[type] == gUnknown_02024258[gBankAttacker]
|
||||
&& gTypeEffectiveness[type + 2] <= 5
|
||||
&& gBattleMons[gBankAttacker].type1 != gTypeEffectiveness[type + 1]
|
||||
&& gBattleMons[gBankAttacker].type2 != gTypeEffectiveness[type + 1])
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == gUnknown_02024258[gBankAttacker]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) <= TYPE_MUL_NOT_EFFECTIVE
|
||||
&& gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i)
|
||||
&& gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i))
|
||||
{
|
||||
gBattleMons[gBankAttacker].type1 = type;
|
||||
gBattleMons[gBankAttacker].type2 = type;
|
||||
gBattleMons[gBankAttacker].type1 = TYPE_EFFECT_DEF_TYPE(i);
|
||||
gBattleMons[gBankAttacker].type2 = TYPE_EFFECT_DEF_TYPE(i);
|
||||
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, type)
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(i))
|
||||
|
||||
gBattlescriptCurrInstr += 5;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rands++;
|
||||
} while (rands <= 999);
|
||||
|
||||
type = 0, rands = 0;
|
||||
do
|
||||
for (j = 0, rands = 0; rands < sizeof(gTypeEffectiveness); j += 3, rands += 3)
|
||||
{
|
||||
s8 var = (s8)(gTypeEffectiveness[type]);
|
||||
if (var > -1 || var < -2)
|
||||
switch (TYPE_EFFECT_ATK_TYPE(j))
|
||||
{
|
||||
if (gTypeEffectiveness[type] == gUnknown_02024258[gBankAttacker]
|
||||
&& gTypeEffectiveness[type + 2] <= 5
|
||||
&& gBattleMons[gBankAttacker].type1 != gTypeEffectiveness[type + 1]
|
||||
&& gBattleMons[gBankAttacker].type2 != gTypeEffectiveness[type + 1])
|
||||
case TYPE_ENDTABLE:
|
||||
case TYPE_FORESIGHT:
|
||||
break;
|
||||
default:
|
||||
if (TYPE_EFFECT_ATK_TYPE(j) == gUnknown_02024258[gBankAttacker]
|
||||
&& TYPE_EFFECT_MULTIPLIER(j) <= 5
|
||||
&& gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i)
|
||||
&& gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i))
|
||||
{
|
||||
gBattleMons[gBankAttacker].type1 = gTypeEffectiveness[rands + 1];
|
||||
gBattleMons[gBankAttacker].type2 = gTypeEffectiveness[rands + 1];
|
||||
gBattleMons[gBankAttacker].type1 = TYPE_EFFECT_DEF_TYPE(rands);
|
||||
gBattleMons[gBankAttacker].type2 = TYPE_EFFECT_DEF_TYPE(rands);
|
||||
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, gTypeEffectiveness[rands + 1])
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(rands))
|
||||
|
||||
gBattlescriptCurrInstr += 5;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
type += 3, rands += 3;
|
||||
} while (rands < 336);
|
||||
}
|
||||
|
||||
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
__attribute__((naked))
|
||||
static void atkA6_settypetorandomresistance(void) // conversion 2
|
||||
{
|
||||
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\
|
||||
ldr r1, =gUnknown_02024250\n\
|
||||
ldr r4, =gBankAttacker\n\
|
||||
ldrb r0, [r4]\n\
|
||||
lsls r0, 1\n\
|
||||
adds r2, r0, r1\n\
|
||||
ldrh r1, [r2]\n\
|
||||
cmp r1, 0\n\
|
||||
beq _08052B7E\n\
|
||||
ldr r0, =0x0000ffff\n\
|
||||
cmp r1, r0\n\
|
||||
beq _08052B7E\n\
|
||||
ldrh r0, [r2]\n\
|
||||
bl IsTwoTurnsMove\n\
|
||||
lsls r0, 24\n\
|
||||
cmp r0, 0\n\
|
||||
beq _08052C1C\n\
|
||||
ldr r1, =gBattleMons\n\
|
||||
ldr r2, =gUnknown_02024270\n\
|
||||
ldrb r0, [r4]\n\
|
||||
adds r0, r2\n\
|
||||
ldrb r2, [r0]\n\
|
||||
movs r0, 0x58\n\
|
||||
muls r0, r2\n\
|
||||
adds r1, 0x50\n\
|
||||
adds r0, r1\n\
|
||||
ldr r0, [r0]\n\
|
||||
movs r1, 0x80\n\
|
||||
lsls r1, 5\n\
|
||||
ands r0, r1\n\
|
||||
cmp r0, 0\n\
|
||||
beq _08052C1C\n\
|
||||
_08052B7E:\n\
|
||||
ldr r3, =gBattlescriptCurrInstr\n\
|
||||
ldr r2, [r3]\n\
|
||||
ldrb r1, [r2, 0x1]\n\
|
||||
ldrb r0, [r2, 0x2]\n\
|
||||
lsls r0, 8\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x3]\n\
|
||||
lsls r0, 16\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x4]\n\
|
||||
lsls r0, 24\n\
|
||||
orrs r1, r0\n\
|
||||
str r1, [r3]\n\
|
||||
b _08052D08\n\
|
||||
.pool\n\
|
||||
_08052BB4:\n\
|
||||
mov r0, r12\n\
|
||||
strb r5, [r0]\n\
|
||||
mov r1, r10\n\
|
||||
ldrb r0, [r1]\n\
|
||||
muls r0, r2\n\
|
||||
adds r0, r7\n\
|
||||
adds r0, 0x22\n\
|
||||
strb r5, [r0]\n\
|
||||
ldr r1, =gBattleTextBuff1\n\
|
||||
movs r0, 0xFD\n\
|
||||
strb r0, [r1]\n\
|
||||
movs r0, 0x3\n\
|
||||
strb r0, [r1, 0x1]\n\
|
||||
strb r5, [r1, 0x2]\n\
|
||||
movs r0, 0xFF\n\
|
||||
strb r0, [r1, 0x3]\n\
|
||||
ldr r1, =gBattlescriptCurrInstr\n\
|
||||
b _08052C0A\n\
|
||||
.pool\n\
|
||||
_08052BE0:\n\
|
||||
mov r0, r8\n\
|
||||
adds r0, 0x1\n\
|
||||
adds r0, r3\n\
|
||||
ldrb r2, [r0]\n\
|
||||
strb r2, [r4]\n\
|
||||
mov r4, r10\n\
|
||||
ldrb r0, [r4]\n\
|
||||
muls r0, r6\n\
|
||||
ldr r7, =gBattleMons\n\
|
||||
adds r0, r7\n\
|
||||
adds r0, 0x22\n\
|
||||
strb r2, [r0]\n\
|
||||
ldr r1, =gBattleTextBuff1\n\
|
||||
movs r0, 0xFD\n\
|
||||
strb r0, [r1]\n\
|
||||
movs r0, 0x3\n\
|
||||
strb r0, [r1, 0x1]\n\
|
||||
strb r2, [r1, 0x2]\n\
|
||||
movs r0, 0xFF\n\
|
||||
strb r0, [r1, 0x3]\n\
|
||||
mov r1, r12\n\
|
||||
_08052C0A:\n\
|
||||
ldr r0, [r1]\n\
|
||||
adds r0, 0x5\n\
|
||||
str r0, [r1]\n\
|
||||
b _08052D08\n\
|
||||
.pool\n\
|
||||
_08052C1C:\n\
|
||||
movs r4, 0\n\
|
||||
mov r8, r4\n\
|
||||
movs r7, 0x7F\n\
|
||||
mov r9, r7\n\
|
||||
_08052C24:\n\
|
||||
bl Random\n\
|
||||
mov r4, r9\n\
|
||||
ands r4, r0\n\
|
||||
cmp r4, 0x70\n\
|
||||
bhi _08052C24\n\
|
||||
lsls r0, r4, 1\n\
|
||||
adds r4, r0, r4\n\
|
||||
ldr r6, =gTypeEffectiveness\n\
|
||||
adds r3, r4, r6\n\
|
||||
ldr r1, =gUnknown_02024258\n\
|
||||
ldr r2, =gBankAttacker\n\
|
||||
ldrb r5, [r2]\n\
|
||||
lsls r0, r5, 1\n\
|
||||
adds r0, r1\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r10, r2\n\
|
||||
ldrh r0, [r0]\n\
|
||||
cmp r1, r0\n\
|
||||
bne _08052C80\n\
|
||||
adds r0, r4, 0x2\n\
|
||||
adds r0, r6\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, 0x5\n\
|
||||
bhi _08052C80\n\
|
||||
ldr r7, =gBattleMons\n\
|
||||
movs r2, 0x58\n\
|
||||
adds r0, r5, 0\n\
|
||||
muls r0, r2\n\
|
||||
adds r3, r0, r7\n\
|
||||
movs r0, 0x21\n\
|
||||
adds r0, r3\n\
|
||||
mov r12, r0\n\
|
||||
adds r0, r4, 0x1\n\
|
||||
adds r0, r6\n\
|
||||
ldrb r5, [r0]\n\
|
||||
mov r1, r12\n\
|
||||
ldrb r0, [r1]\n\
|
||||
adds r1, r5, 0\n\
|
||||
cmp r0, r1\n\
|
||||
beq _08052C80\n\
|
||||
adds r0, r3, 0\n\
|
||||
adds r0, 0x22\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, r1\n\
|
||||
bne _08052BB4\n\
|
||||
_08052C80:\n\
|
||||
movs r7, 0x1\n\
|
||||
add r8, r7\n\
|
||||
ldr r0, =0x000003e7\n\
|
||||
cmp r8, r0\n\
|
||||
ble _08052C24\n\
|
||||
movs r0, 0\n\
|
||||
mov r8, r0\n\
|
||||
ldr r1, =gBattlescriptCurrInstr\n\
|
||||
mov r12, r1\n\
|
||||
ldr r3, =gTypeEffectiveness\n\
|
||||
adds r0, r4, 0x1\n\
|
||||
adds r0, r3\n\
|
||||
mov r9, r0\n\
|
||||
adds r5, r3, 0\n\
|
||||
_08052C9C:\n\
|
||||
ldrb r1, [r5]\n\
|
||||
cmp r1, 0xFF\n\
|
||||
bgt _08052CA6\n\
|
||||
cmp r1, 0xFE\n\
|
||||
bge _08052CE0\n\
|
||||
_08052CA6:\n\
|
||||
mov r4, r10\n\
|
||||
ldrb r2, [r4]\n\
|
||||
lsls r0, r2, 1\n\
|
||||
ldr r7, =gUnknown_02024258\n\
|
||||
adds r0, r7\n\
|
||||
ldrh r0, [r0]\n\
|
||||
cmp r1, r0\n\
|
||||
bne _08052CE0\n\
|
||||
ldrb r0, [r5, 0x2]\n\
|
||||
cmp r0, 0x5\n\
|
||||
bhi _08052CE0\n\
|
||||
movs r6, 0x58\n\
|
||||
adds r0, r2, 0\n\
|
||||
muls r0, r6\n\
|
||||
ldr r1, =gBattleMons\n\
|
||||
adds r2, r0, r1\n\
|
||||
adds r4, r2, 0\n\
|
||||
adds r4, 0x21\n\
|
||||
ldrb r0, [r4]\n\
|
||||
mov r7, r9\n\
|
||||
ldrb r1, [r7]\n\
|
||||
cmp r0, r1\n\
|
||||
beq _08052CE0\n\
|
||||
adds r0, r2, 0\n\
|
||||
adds r0, 0x22\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, r1\n\
|
||||
beq _08052CE0\n\
|
||||
b _08052BE0\n\
|
||||
_08052CE0:\n\
|
||||
adds r5, 0x3\n\
|
||||
movs r0, 0x3\n\
|
||||
add r8, r0\n\
|
||||
ldr r0, =0x0000014f\n\
|
||||
cmp r8, r0\n\
|
||||
bls _08052C9C\n\
|
||||
mov r1, r12\n\
|
||||
ldr r2, [r1]\n\
|
||||
ldrb r1, [r2, 0x1]\n\
|
||||
ldrb r0, [r2, 0x2]\n\
|
||||
lsls r0, 8\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x3]\n\
|
||||
lsls r0, 16\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x4]\n\
|
||||
lsls r0, 24\n\
|
||||
orrs r1, r0\n\
|
||||
mov r4, r12\n\
|
||||
str r1, [r4]\n\
|
||||
_08052D08:\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");
|
||||
}
|
||||
#endif // NONMATCHING
|
||||
|
||||
static void atkA7_setalwayshitflag(void)
|
||||
{
|
||||
gStatuses3[gBankTarget] &= ~(STATUS3_ALWAYS_HITS);
|
||||
@@ -9504,8 +9178,8 @@ static void atkB2_setperishsong(void)
|
||||
else
|
||||
{
|
||||
gStatuses3[i] |= STATUS3_PERISH_SONG;
|
||||
gDisableStructs[i].perishSong1 = 3;
|
||||
gDisableStructs[i].perishSong2 = 3;
|
||||
gDisableStructs[i].perishSongTimer1 = 3;
|
||||
gDisableStructs[i].perishSongTimer2 = 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9859,24 +9533,24 @@ static void atkC0_recoverbasedonsunlight(void)
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static void atkC1_hidden_power(void)
|
||||
static void atkC1_hidden_power_calc(void)
|
||||
{
|
||||
s32 powerBits;
|
||||
s32 typeBits;
|
||||
u32 powerBits = 0;
|
||||
u32 typeBits = 0;
|
||||
|
||||
powerBits = ((gBattleMons[gBankAttacker].hpIV & 2) >> 1)
|
||||
| ((gBattleMons[gBankAttacker].attackIV & 2) << 0)
|
||||
| ((gBattleMons[gBankAttacker].defenseIV & 2) << 1)
|
||||
| ((gBattleMons[gBankAttacker].speedIV & 2) << 2)
|
||||
| ((gBattleMons[gBankAttacker].spAttackIV & 2) << 3)
|
||||
| ((gBattleMons[gBankAttacker].spDefenseIV & 2) << 4);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].hpIV & 2) >> 1);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].attackIV & 2) << 0);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].defenseIV & 2) << 1);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].speedIV & 2) << 2);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].spAttackIV & 2) << 3);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].spDefenseIV & 2) << 4);
|
||||
|
||||
typeBits = ((gBattleMons[gBankAttacker].hpIV & 1) << 0)
|
||||
| ((gBattleMons[gBankAttacker].attackIV & 1) << 1)
|
||||
| ((gBattleMons[gBankAttacker].defenseIV & 1) << 2)
|
||||
| ((gBattleMons[gBankAttacker].speedIV & 1) << 3)
|
||||
| ((gBattleMons[gBankAttacker].spAttackIV & 1) << 4)
|
||||
| ((gBattleMons[gBankAttacker].spDefenseIV & 1) << 5);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].hpIV & 1) << 0);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].attackIV & 1) << 1);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].defenseIV & 1) << 2);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].speedIV & 1) << 3);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].spAttackIV & 1) << 4);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].spDefenseIV & 1) << 5);
|
||||
|
||||
gDynamicBasePower = (40 * powerBits) / 63 + 30;
|
||||
|
||||
@@ -9890,7 +9564,7 @@ static void atkC1_hidden_power(void)
|
||||
|
||||
#else
|
||||
__attribute__((naked))
|
||||
static void atkC1_hidden_power(void)
|
||||
static void atkC1_hidden_power_calc(void)
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
@@ -11171,7 +10845,7 @@ static void atkF0_give_caught_mon(void)
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
|
||||
}
|
||||
|
||||
if (FlagGet(SYS_PC_LANETTE))
|
||||
if (FlagGet(FLAG_SYS_PC_LANETTE))
|
||||
gBattleCommunication[MULTISTRING_CHOOSER]++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1292,9 +1292,9 @@ bool8 sub_8041364(void)
|
||||
gBattleTextBuff1[1] = 1;
|
||||
gBattleTextBuff1[2] = 1;
|
||||
gBattleTextBuff1[3] = 1;
|
||||
gBattleTextBuff1[4] = gDisableStructs[gActiveBank].perishSong1;
|
||||
gBattleTextBuff1[4] = gDisableStructs[gActiveBank].perishSongTimer1;
|
||||
gBattleTextBuff1[5] = EOS;
|
||||
if (gDisableStructs[gActiveBank].perishSong1 == 0)
|
||||
if (gDisableStructs[gActiveBank].perishSongTimer1 == 0)
|
||||
{
|
||||
gStatuses3[gActiveBank] &= ~STATUS3_PERISH_SONG;
|
||||
gBattleMoveDamage = gBattleMons[gActiveBank].hp;
|
||||
@@ -1302,7 +1302,7 @@ bool8 sub_8041364(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
gDisableStructs[gActiveBank].perishSong1--;
|
||||
gDisableStructs[gActiveBank].perishSongTimer1--;
|
||||
gBattlescriptCurrInstr = gUnknown_082DAF20;
|
||||
}
|
||||
BattleScriptExecute(gBattlescriptCurrInstr);
|
||||
@@ -1805,7 +1805,7 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2)
|
||||
&& GetMonData(&party[i], MON_DATA_SPECIES2) != 0
|
||||
&& GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG
|
||||
// FIXME: Using index[array] instead of array[index] is BAD!
|
||||
&& i != r1 && i != r2 && i != r7[gBattleStruct->field_5C] && i != r6[gBattleStruct->field_5C])
|
||||
&& i != r1 && i != r2 && i != r7[gBattleStruct->monToSwitchIntoId] && i != r6[gBattleStruct->monToSwitchIntoId])
|
||||
break;
|
||||
}
|
||||
return (i == 6);
|
||||
@@ -3511,16 +3511,16 @@ u8 IsPokeDisobedient(void)
|
||||
return 0;
|
||||
if (!IsOtherTrainer(gBattleMons[gBankAttacker].otId, gBattleMons[gBankAttacker].otName))
|
||||
return 0;
|
||||
if (FlagGet(BADGE08_GET))
|
||||
if (FlagGet(FLAG_BADGE08_GET))
|
||||
return 0;
|
||||
|
||||
obedienceLevel = 10;
|
||||
|
||||
if (FlagGet(BADGE02_GET))
|
||||
if (FlagGet(FLAG_BADGE02_GET))
|
||||
obedienceLevel = 30;
|
||||
if (FlagGet(BADGE04_GET))
|
||||
if (FlagGet(FLAG_BADGE04_GET))
|
||||
obedienceLevel = 50;
|
||||
if (FlagGet(BADGE06_GET))
|
||||
if (FlagGet(FLAG_BADGE06_GET))
|
||||
obedienceLevel = 70;
|
||||
}
|
||||
|
||||
|
||||
219
src/battle_util2.c
Normal file
219
src/battle_util2.c
Normal file
@@ -0,0 +1,219 @@
|
||||
#include "global.h"
|
||||
#include "battle.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "malloc.h"
|
||||
#include "pokemon.h"
|
||||
#include "event_data.h"
|
||||
#include "abilities.h"
|
||||
#include "rng.h"
|
||||
|
||||
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
|
||||
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
|
||||
extern u8 gUnknown_0203CF00[];
|
||||
extern const u8* gBattlescriptCurrInstr;
|
||||
extern u8 gBattleCommunication[];
|
||||
extern u8 gActiveBank;
|
||||
|
||||
extern const u8 BattleScript_MoveUsedWokeUp[];
|
||||
extern const u8 BattleScript_MoveUsedIsFrozen[];
|
||||
extern const u8 BattleScript_MoveUsedUnfroze[];
|
||||
extern const u8 BattleScript_MoveUsedIsAsleep[];
|
||||
|
||||
extern void sub_81D55D0(void);
|
||||
extern void sub_81D5694(void);
|
||||
extern u8 pokemon_order_func(u8);
|
||||
extern void sub_81B8FB0(u8, u8);
|
||||
|
||||
void AllocateBattleResources(void)
|
||||
{
|
||||
gBattleResources = gBattleResources; // something dumb needed to match
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_x4000000)
|
||||
sub_81D55D0();
|
||||
|
||||
gBattleStruct = AllocZeroed(sizeof(*gBattleStruct));
|
||||
|
||||
gBattleResources = AllocZeroed(sizeof(*gBattleResources));
|
||||
gBattleResources->secretBase = AllocZeroed(sizeof(*gBattleResources->secretBase));
|
||||
gBattleResources->flags = AllocZeroed(sizeof(*gBattleResources->flags));
|
||||
gBattleResources->battleScriptsStack = AllocZeroed(sizeof(*gBattleResources->battleScriptsStack));
|
||||
gBattleResources->battleCallbackStack = AllocZeroed(sizeof(*gBattleResources->battleCallbackStack));
|
||||
gBattleResources->statsBeforeLvlUp = AllocZeroed(sizeof(*gBattleResources->statsBeforeLvlUp));
|
||||
gBattleResources->ai = AllocZeroed(sizeof(*gBattleResources->ai));
|
||||
gBattleResources->battleHistory = AllocZeroed(sizeof(*gBattleResources->battleHistory));
|
||||
gBattleResources->AI_ScriptsStack = AllocZeroed(sizeof(*gBattleResources->AI_ScriptsStack));
|
||||
|
||||
gLinkBattleSendBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE);
|
||||
gLinkBattleRecvBuffer = AllocZeroed(BATTLE_BUFFER_LINK_SIZE);
|
||||
|
||||
gUnknown_0202305C = AllocZeroed(0x2000);
|
||||
gUnknown_02023060 = AllocZeroed(0x1000);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
|
||||
{
|
||||
u16 currSecretBaseId = VarGet(VAR_0x4054);
|
||||
CreateSecretBaseEnemyParty(&gSaveBlock1Ptr->secretBases[currSecretBaseId]);
|
||||
}
|
||||
}
|
||||
|
||||
void FreeBattleResources(void)
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_x4000000)
|
||||
sub_81D5694();
|
||||
|
||||
if (gBattleResources != NULL)
|
||||
{
|
||||
FREE_AND_SET_NULL(gBattleStruct);
|
||||
|
||||
FREE_AND_SET_NULL(gBattleResources->secretBase);
|
||||
FREE_AND_SET_NULL(gBattleResources->flags);
|
||||
FREE_AND_SET_NULL(gBattleResources->battleScriptsStack);
|
||||
FREE_AND_SET_NULL(gBattleResources->battleCallbackStack);
|
||||
FREE_AND_SET_NULL(gBattleResources->statsBeforeLvlUp);
|
||||
FREE_AND_SET_NULL(gBattleResources->ai);
|
||||
FREE_AND_SET_NULL(gBattleResources->battleHistory);
|
||||
FREE_AND_SET_NULL(gBattleResources->AI_ScriptsStack);
|
||||
FREE_AND_SET_NULL(gBattleResources);
|
||||
|
||||
FREE_AND_SET_NULL(gLinkBattleSendBuffer);
|
||||
FREE_AND_SET_NULL(gLinkBattleRecvBuffer);
|
||||
|
||||
FREE_AND_SET_NULL(gUnknown_0202305C);
|
||||
FREE_AND_SET_NULL(gUnknown_02023060);
|
||||
}
|
||||
}
|
||||
|
||||
void AdjustFriendshipOnBattleFaint(u8 bank)
|
||||
{
|
||||
u8 opposingBank;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
u8 opposingBank2;
|
||||
|
||||
opposingBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
|
||||
opposingBank2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2);
|
||||
|
||||
if (gBattleMons[opposingBank2].level > gBattleMons[opposingBank].level)
|
||||
opposingBank = opposingBank2;
|
||||
}
|
||||
else
|
||||
{
|
||||
opposingBank = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
|
||||
}
|
||||
|
||||
if (gBattleMons[opposingBank].level > gBattleMons[bank].level)
|
||||
{
|
||||
if (gBattleMons[opposingBank].level - gBattleMons[bank].level > 29)
|
||||
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 8);
|
||||
else
|
||||
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80571DC(u8 bank, u8 arg1)
|
||||
{
|
||||
if (GetBankSide(bank) != SIDE_OPPONENT)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
// gBattleStruct->field_60[0][i]
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
gUnknown_0203CF00[i] = *(0 * 3 + i + (u8*)(gBattleStruct->field_60));
|
||||
|
||||
sub_81B8FB0(pokemon_order_func(gBattlePartyID[bank]), pokemon_order_func(arg1));
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
*(0 * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i];
|
||||
}
|
||||
}
|
||||
|
||||
u32 sub_805725C(u8 bank)
|
||||
{
|
||||
u32 effect = 0;
|
||||
|
||||
do
|
||||
{
|
||||
switch (gBattleCommunication[MULTIUSE_STATE])
|
||||
{
|
||||
case 0:
|
||||
if (gBattleMons[bank].status1 & STATUS_SLEEP)
|
||||
{
|
||||
if (UproarWakeUpCheck(bank))
|
||||
{
|
||||
gBattleMons[bank].status1 &= ~(STATUS_SLEEP);
|
||||
gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
BattleScriptPushCursor();
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
|
||||
effect = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 toSub;
|
||||
|
||||
if (gBattleMons[bank].ability == ABILITY_EARLY_BIRD)
|
||||
toSub = 2;
|
||||
else
|
||||
toSub = 1;
|
||||
|
||||
if ((gBattleMons[bank].status1 & STATUS_SLEEP) < toSub)
|
||||
gBattleMons[bank].status1 &= ~(STATUS_SLEEP);
|
||||
else
|
||||
gBattleMons[bank].status1 -= toSub;
|
||||
|
||||
if (gBattleMons[bank].status1 & STATUS_SLEEP)
|
||||
{
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep;
|
||||
effect = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
BattleScriptPushCursor();
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
|
||||
effect = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
break;
|
||||
case 1:
|
||||
if (gBattleMons[bank].status1 & STATUS_FREEZE)
|
||||
{
|
||||
if (Random() % 5 != 0)
|
||||
{
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedIsFrozen;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMons[bank].status1 &= ~(STATUS_FREEZE);
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
|
||||
}
|
||||
effect = 2;
|
||||
}
|
||||
gBattleCommunication[MULTIUSE_STATE]++;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
||||
} while (gBattleCommunication[MULTIUSE_STATE] != 2 && effect == 0);
|
||||
|
||||
if (effect == 2)
|
||||
{
|
||||
gActiveBank = bank;
|
||||
EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1);
|
||||
MarkBufferBankForExecution(gActiveBank);
|
||||
}
|
||||
|
||||
return effect;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ extern void CB2_ChooseBerry(void);
|
||||
extern const u8* GetFieldObjectScriptPointerForComparison(void);
|
||||
extern bool8 sub_8092E9C(u8, u8, u8);
|
||||
|
||||
extern u16 gScriptItemId;
|
||||
extern u16 gSpecialVar_ItemId;
|
||||
|
||||
extern const u8 BerryTreeScript[];
|
||||
|
||||
@@ -1169,7 +1169,7 @@ void FieldObjectInteractionGetBerryTreeData(void)
|
||||
id = FieldObjectGetBerryTreeId(gSelectedMapObject);
|
||||
berry = GetBerryTypeByBerryTreeId(id);
|
||||
ResetBerryTreeSparkleFlag(id);
|
||||
unk = gScriptLastTalked;
|
||||
unk = gSpecialVar_LastTalked;
|
||||
num = gSaveBlock1Ptr->location.mapNum;
|
||||
group = gSaveBlock1Ptr->location.mapGroup;
|
||||
if (sub_8092E9C(unk, num, group))
|
||||
@@ -1202,7 +1202,7 @@ void Bag_ChooseBerry(void)
|
||||
|
||||
void FieldObjectInteractionPlantBerryTree(void)
|
||||
{
|
||||
u8 berry = ItemIdToBerryType(gScriptItemId);
|
||||
u8 berry = ItemIdToBerryType(gSpecialVar_ItemId);
|
||||
|
||||
PlantBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject), berry, 1, TRUE);
|
||||
FieldObjectInteractionGetBerryTreeData();
|
||||
@@ -1219,7 +1219,7 @@ void FieldObjectInteractionPickBerryTree(void)
|
||||
void FieldObjectInteractionRemoveBerryTree(void)
|
||||
{
|
||||
RemoveBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject));
|
||||
sub_8092EF0(gScriptLastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
sub_8092EF0(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
}
|
||||
|
||||
u8 PlayerHasBerries(void)
|
||||
|
||||
@@ -33,7 +33,7 @@ void sub_8179944(void);
|
||||
|
||||
bool8 ShouldDoBrailleDigEffect(void)
|
||||
{
|
||||
if (!FlagGet(SYS_BRAILLE_DIG)
|
||||
if (!FlagGet(FLAG_SYS_BRAILLE_DIG)
|
||||
&& (gSaveBlock1Ptr->location.mapGroup == 0x18
|
||||
&& gSaveBlock1Ptr->location.mapNum == 0x47))
|
||||
{
|
||||
@@ -58,7 +58,7 @@ void DoBrailleDigEffect(void)
|
||||
MapGridSetMetatileIdAt(18, 9, 3636);
|
||||
DrawWholeMapView();
|
||||
PlaySE(SE_BAN);
|
||||
FlagSet(SYS_BRAILLE_DIG);
|
||||
FlagSet(FLAG_SYS_BRAILLE_DIG);
|
||||
ScriptContext2_Disable();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ bool8 CheckRelicanthWailord(void)
|
||||
void ShouldDoBrailleStrengthEffectOld(void)
|
||||
{
|
||||
/*
|
||||
if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1.location.mapGroup == MAP_GROUP_DESERT_RUINS && gSaveBlock1.location.mapNum == MAP_ID_DESERT_RUINS))
|
||||
if (!FlagGet(FLAG_SYS_BRAILLE_STRENGTH) && (gSaveBlock1.location.mapGroup == MAP_GROUP_DESERT_RUINS && gSaveBlock1.location.mapNum == MAP_ID_DESERT_RUINS))
|
||||
{
|
||||
if (gSaveBlock1.pos.x == 10 && gSaveBlock1.pos.y == 23)
|
||||
return TRUE;
|
||||
@@ -105,13 +105,13 @@ void DoBrailleStrengthEffect(void)
|
||||
MapGridSetMetatileIdAt(16, 27, 3636);
|
||||
DrawWholeMapView();
|
||||
PlaySE(SE_BAN);
|
||||
FlagSet(SYS_BRAILLE_STRENGTH);
|
||||
FlagSet(FLAG_SYS_BRAILLE_STRENGTH);
|
||||
ScriptContext2_Disable();
|
||||
}
|
||||
|
||||
bool8 ShouldDoBrailleFlyEffect(void)
|
||||
{
|
||||
if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1.location.mapGroup == MAP_GROUP_ANCIENT_TOMB && gSaveBlock1.location.mapNum == MAP_ID_ANCIENT_TOMB))
|
||||
if (!FlagGet(FLAG_SYS_BRAILLE_FLY) && (gSaveBlock1.location.mapGroup == MAP_GROUP_ANCIENT_TOMB && gSaveBlock1.location.mapNum == MAP_ID_ANCIENT_TOMB))
|
||||
{
|
||||
if (gSaveBlock1.pos.x == 8 && gSaveBlock1.pos.y == 25)
|
||||
return TRUE;
|
||||
@@ -151,7 +151,7 @@ void UseFlyAncientTomb_Finish(void)
|
||||
MapGridSetMetatileIdAt(16, 27, 3636);
|
||||
DrawWholeMapView();
|
||||
PlaySE(SE_BAN);
|
||||
FlagSet(SYS_BRAILLE_FLY);
|
||||
FlagSet(FLAG_SYS_BRAILLE_FLY);
|
||||
ScriptContext2_Disable();
|
||||
}
|
||||
*/
|
||||
@@ -205,7 +205,7 @@ void SealedChamberShakingEffect(u8 taskId)
|
||||
// moved later in the function because it was rewritten.
|
||||
bool8 ShouldDoBrailleStrengthEffect(void)
|
||||
{
|
||||
if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x06))
|
||||
if (!FlagGet(FLAG_SYS_BRAILLE_STRENGTH) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x06))
|
||||
{
|
||||
if (gSaveBlock1Ptr->pos.x == 6 && gSaveBlock1Ptr->pos.y == 23)
|
||||
{ gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; }
|
||||
@@ -240,13 +240,13 @@ void sub_8179860(void)
|
||||
MapGridSetMetatileIdAt(16, 27, 3636);
|
||||
DrawWholeMapView();
|
||||
PlaySE(SE_BAN);
|
||||
FlagSet(SYS_BRAILLE_STRENGTH);
|
||||
FlagSet(FLAG_SYS_BRAILLE_STRENGTH);
|
||||
ScriptContext2_Disable();
|
||||
}
|
||||
|
||||
bool8 ShouldDoBrailleFlyEffect(void)
|
||||
{
|
||||
if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x44))
|
||||
if (!FlagGet(FLAG_SYS_BRAILLE_FLY) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x44))
|
||||
{
|
||||
if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 25)
|
||||
{ gBraillePuzzleCallbackFlag = FLY_PUZZLE; return TRUE; }
|
||||
@@ -276,7 +276,7 @@ void sub_8179944(void)
|
||||
MapGridSetMetatileIdAt(16, 27, 3636);
|
||||
DrawWholeMapView();
|
||||
PlaySE(SE_BAN);
|
||||
FlagSet(SYS_BRAILLE_FLY);
|
||||
FlagSet(FLAG_SYS_BRAILLE_FLY);
|
||||
ScriptContext2_Disable();
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ void sub_8179944(void)
|
||||
void DoBrailleWait(void)
|
||||
{
|
||||
/*
|
||||
if (!FlagGet(SYS_BRAILLE_WAIT))
|
||||
if (!FlagGet(FLAG_SYS_BRAILLE_WAIT))
|
||||
CreateTask(Task_BrailleWait, 0x50);
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ bool8 ShouldDoBrailleRegicePuzzle(void)
|
||||
if (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x43)
|
||||
{
|
||||
// _08179A1A
|
||||
if (FlagGet(SYS_BRAILLE_WAIT) != FALSE)
|
||||
if (FlagGet(FLAG_SYS_BRAILLE_WAIT) != FALSE)
|
||||
return FALSE;
|
||||
if (FlagGet(2) == FALSE)
|
||||
return FALSE;
|
||||
|
||||
@@ -84,13 +84,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
||||
if (attacker->ability == ABILITY_HUGE_POWER || attacker->ability == ABILITY_PURE_POWER)
|
||||
attack *= 2;
|
||||
|
||||
if (ShouldGetStatBadgeBoost(BADGE01_GET, bankAtk))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE01_GET, bankAtk))
|
||||
attack = (110 * attack) / 100;
|
||||
if (ShouldGetStatBadgeBoost(BADGE05_GET, bankDef))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE05_GET, bankDef))
|
||||
defense = (110 * defense) / 100;
|
||||
if (ShouldGetStatBadgeBoost(BADGE07_GET, bankAtk))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankAtk))
|
||||
spAttack = (110 * spAttack) / 100;
|
||||
if (ShouldGetStatBadgeBoost(BADGE07_GET, bankDef))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankDef))
|
||||
spDefense = (110 * spDefense) / 100;
|
||||
|
||||
for (i = 0; i < 17; i++)
|
||||
|
||||
@@ -1600,7 +1600,7 @@ void sub_81289F0(u8 taskId)
|
||||
{
|
||||
sCurDecorMapX = gTasks[taskId].data[0] - 7;
|
||||
sCurDecorMapY = gTasks[taskId].data[1] - 7;
|
||||
ScriptContext1_SetupScript(gUnknown_08275D1F);
|
||||
ScriptContext1_SetupScript(EventScript_275D1F);
|
||||
}
|
||||
gSprites[sDecor_CameraSpriteObjectIdx1].pos1.y += 2;
|
||||
if (gMapHeader.regionMapSectionId == REGION_MAP_SECRET_BASE)
|
||||
@@ -1700,7 +1700,7 @@ void sub_8128C64(u8 taskId)
|
||||
data[2] ++;
|
||||
break;
|
||||
case 1:
|
||||
ScriptContext1_SetupScript(gUnknown_08275D0C);
|
||||
ScriptContext1_SetupScript(EventScript_275D0C);
|
||||
data[2] ++;
|
||||
break;
|
||||
case 2:
|
||||
@@ -2133,10 +2133,10 @@ void sub_8129708(void)
|
||||
u16 i;
|
||||
|
||||
gSpecialVar_0x8005 = 0;
|
||||
gScriptResult = 0;
|
||||
gSpecialVar_Result = 0;
|
||||
if (gSpecialVar_0x8004 == sCurDecorSelectedInRearrangement)
|
||||
{
|
||||
gScriptResult = 1;
|
||||
gSpecialVar_Result = 1;
|
||||
}
|
||||
else if (gDecorations[gUnknown_0203A17C.items[sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx]].permission == DECORPERM_SOLID_MAT)
|
||||
{
|
||||
@@ -2206,7 +2206,7 @@ void sub_81298EC(u8 taskId)
|
||||
case 1:
|
||||
if (!gPaletteFade.active) {
|
||||
DrawWholeMapView();
|
||||
ScriptContext1_SetupScript(gUnknown_08275D2E);
|
||||
ScriptContext1_SetupScript(EventScript_275D2E);
|
||||
sub_8197434(0, 1);
|
||||
gTasks[taskId].data[2] = 2;
|
||||
}
|
||||
@@ -2691,7 +2691,7 @@ void sub_812A2C4(u8 taskId)
|
||||
data[2] ++;
|
||||
break;
|
||||
case 1:
|
||||
ScriptContext1_SetupScript(gUnknown_08275D0C);
|
||||
ScriptContext1_SetupScript(EventScript_275D0C);
|
||||
data[2] ++;
|
||||
break;
|
||||
case 2:
|
||||
|
||||
@@ -17,11 +17,11 @@ EWRAM_DATA u16 gSpecialVar_0x8008 = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_0x8009 = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_0x800A = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_0x800B = 0;
|
||||
EWRAM_DATA u16 gScriptResult = 0;
|
||||
EWRAM_DATA u16 gScriptLastTalked = 0;
|
||||
EWRAM_DATA u16 gScriptFacing = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_0x8012 = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_0x8013 = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_Result = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_LastTalked = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_Facing = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_MonBoxId = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_MonBoxPos = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_0x8014 = 0;
|
||||
EWRAM_DATA static u8 gUnknown_020375FC[16] = {0};
|
||||
|
||||
@@ -40,11 +40,11 @@ void ClearTempFieldEventData(void)
|
||||
{
|
||||
memset(gSaveBlock1Ptr->flags, 0, TEMP_FLAGS_SIZE);
|
||||
memset(gSaveBlock1Ptr->vars, 0, TEMP_VARS_SIZE);
|
||||
FlagClear(SYS_ENC_UP_ITEM);
|
||||
FlagClear(SYS_ENC_DOWN_ITEM);
|
||||
FlagClear(SYS_USE_STRENGTH);
|
||||
FlagClear(SYS_CTRL_OBJ_DELETE);
|
||||
FlagClear(SYS_UNKNOWN_880);
|
||||
FlagClear(FLAG_SYS_ENC_UP_ITEM);
|
||||
FlagClear(FLAG_SYS_ENC_DOWN_ITEM);
|
||||
FlagClear(FLAG_SYS_USE_STRENGTH);
|
||||
FlagClear(FLAG_SYS_CTRL_OBJ_DELETE);
|
||||
FlagClear(FLAG_SYS_UNKNOWN_880);
|
||||
}
|
||||
|
||||
// probably had different flag splits at one point.
|
||||
@@ -58,7 +58,7 @@ void DisableNationalPokedex(void)
|
||||
u16 *nationalDexVar = GetVarPointer(VAR_NATIONAL_DEX);
|
||||
gSaveBlock2Ptr->pokedex.nationalMagic = 0;
|
||||
*nationalDexVar = 0;
|
||||
FlagClear(SYS_NATIONAL_DEX);
|
||||
FlagClear(FLAG_SYS_NATIONAL_DEX);
|
||||
}
|
||||
|
||||
void EnableNationalPokedex(void)
|
||||
@@ -66,7 +66,7 @@ void EnableNationalPokedex(void)
|
||||
u16 *nationalDexVar = GetVarPointer(VAR_NATIONAL_DEX);
|
||||
gSaveBlock2Ptr->pokedex.nationalMagic = 0xDA;
|
||||
*nationalDexVar = 0x302;
|
||||
FlagSet(SYS_NATIONAL_DEX);
|
||||
FlagSet(FLAG_SYS_NATIONAL_DEX);
|
||||
gSaveBlock2Ptr->pokedex.unknown1 = 1;
|
||||
gSaveBlock2Ptr->pokedex.order = 0;
|
||||
sub_80BB358();
|
||||
@@ -74,7 +74,7 @@ void EnableNationalPokedex(void)
|
||||
|
||||
bool32 IsNationalPokedexEnabled(void)
|
||||
{
|
||||
if (gSaveBlock2Ptr->pokedex.nationalMagic == 0xDA && VarGet(VAR_NATIONAL_DEX) == 0x302 && FlagGet(SYS_NATIONAL_DEX))
|
||||
if (gSaveBlock2Ptr->pokedex.nationalMagic == 0xDA && VarGet(VAR_NATIONAL_DEX) == 0x302 && FlagGet(FLAG_SYS_NATIONAL_DEX))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
@@ -82,32 +82,32 @@ bool32 IsNationalPokedexEnabled(void)
|
||||
|
||||
void DisableMysteryEvent(void)
|
||||
{
|
||||
FlagClear(SYS_MYSTERY_EVENT_ENABLE);
|
||||
FlagClear(FLAG_SYS_MYSTERY_EVENT_ENABLE);
|
||||
}
|
||||
|
||||
void EnableMysteryEvent(void)
|
||||
{
|
||||
FlagSet(SYS_MYSTERY_EVENT_ENABLE);
|
||||
FlagSet(FLAG_SYS_MYSTERY_EVENT_ENABLE);
|
||||
}
|
||||
|
||||
bool32 IsMysteryEventEnabled(void)
|
||||
{
|
||||
return FlagGet(SYS_MYSTERY_EVENT_ENABLE);
|
||||
return FlagGet(FLAG_SYS_MYSTERY_EVENT_ENABLE);
|
||||
}
|
||||
|
||||
void DisableMysteryGift(void)
|
||||
{
|
||||
FlagClear(SYS_MYSTERY_GIFT_ENABLE);
|
||||
FlagClear(FLAG_SYS_MYSTERY_GIFT_ENABLE);
|
||||
}
|
||||
|
||||
void EnableMysteryGift(void)
|
||||
{
|
||||
FlagSet(SYS_MYSTERY_GIFT_ENABLE);
|
||||
FlagSet(FLAG_SYS_MYSTERY_GIFT_ENABLE);
|
||||
}
|
||||
|
||||
bool32 IsMysteryGiftEnabled(void)
|
||||
{
|
||||
return FlagGet(SYS_MYSTERY_GIFT_ENABLE);
|
||||
return FlagGet(FLAG_SYS_MYSTERY_GIFT_ENABLE);
|
||||
}
|
||||
|
||||
void sub_809D4D8(void)
|
||||
@@ -145,18 +145,18 @@ void sub_809D570(void)
|
||||
void DisableResetRTC(void)
|
||||
{
|
||||
VarSet(VAR_RESET_RTC_ENABLE, 0);
|
||||
FlagClear(SYS_RESET_RTC_ENABLE);
|
||||
FlagClear(FLAG_SYS_RESET_RTC_ENABLE);
|
||||
}
|
||||
|
||||
void EnableResetRTC(void)
|
||||
{
|
||||
VarSet(VAR_RESET_RTC_ENABLE, 0x920);
|
||||
FlagSet(SYS_RESET_RTC_ENABLE);
|
||||
FlagSet(FLAG_SYS_RESET_RTC_ENABLE);
|
||||
}
|
||||
|
||||
bool32 CanResetRTC(void)
|
||||
{
|
||||
if (FlagGet(SYS_RESET_RTC_ENABLE) && VarGet(VAR_RESET_RTC_ENABLE) == 0x920)
|
||||
if (FlagGet(FLAG_SYS_RESET_RTC_ENABLE) && VarGet(VAR_RESET_RTC_ENABLE) == 0x920)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
@@ -1765,10 +1765,10 @@ void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 decorCat)
|
||||
switch (decorCat)
|
||||
{
|
||||
case DECORCAT_DOLL:
|
||||
sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A2);
|
||||
sub_808F228(&gMapObjects[mapObjectId], EventScript_2766A2);
|
||||
break;
|
||||
case DECORCAT_CUSHION:
|
||||
sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A6);
|
||||
sub_808F228(&gMapObjects[mapObjectId], EventScript_2766A6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ void sub_80FB768(void)
|
||||
|
||||
void sub_80FB7A4(void)
|
||||
{
|
||||
FlagSet(SYS_CRUISE_MODE);
|
||||
FlagSet(FLAG_SYS_CRUISE_MODE);
|
||||
FlagSet(0x4001);
|
||||
FlagSet(0x4000);
|
||||
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
|
||||
|
||||
@@ -165,11 +165,11 @@ bool8 HasAtLeastOneBerry(void)
|
||||
{
|
||||
if (CheckBagHasItem(i, 1) == TRUE)
|
||||
{
|
||||
gScriptResult = 1;
|
||||
gSpecialVar_Result = 1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
gScriptResult = 0;
|
||||
gSpecialVar_Result = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ static EWRAM_DATA struct LilycoveLadyFavour *gUnknown_0203CD64 = NULL;
|
||||
static EWRAM_DATA struct LilycoveLadyQuiz *gUnknown_0203CD68 = NULL;
|
||||
static EWRAM_DATA struct LilycoveLadyContest *gUnknown_0203CD6C = NULL;
|
||||
|
||||
extern EWRAM_DATA u16 gScriptItemId;
|
||||
extern EWRAM_DATA u16 gSpecialVar_ItemId;
|
||||
|
||||
u8 GetLilycoveLadyId(void)
|
||||
{
|
||||
@@ -242,11 +242,11 @@ void sub_818D9C0(void)
|
||||
{
|
||||
lilycoveLady = &gSaveBlock1Ptr->lilycoveLady;
|
||||
VarSet(VAR_0x4011, gUnknown_0860B074[lilycoveLady->contest.category]);
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ void SetLilycoveLadyRandomly(void)
|
||||
|
||||
void sub_818DAEC(void)
|
||||
{
|
||||
gScriptResult = GetLilycoveLadyId();
|
||||
gSpecialVar_Result = GetLilycoveLadyId();
|
||||
}
|
||||
|
||||
static u8 sub_818DB04(const u16 *data)
|
||||
@@ -459,7 +459,7 @@ static bool8 sub_818DD84(u16 itemId)
|
||||
|
||||
bool8 sub_818DE44(void)
|
||||
{
|
||||
return sub_818DD84(gScriptItemId);
|
||||
return sub_818DD84(gSpecialVar_ItemId);
|
||||
}
|
||||
|
||||
bool8 sub_818DE5C(void)
|
||||
@@ -845,7 +845,7 @@ void sub_818E47C(void)
|
||||
|
||||
void sub_818E490(void)
|
||||
{
|
||||
RemoveBagItem(gScriptItemId, 1);
|
||||
RemoveBagItem(gSpecialVar_ItemId, 1);
|
||||
}
|
||||
|
||||
void sub_818E4A4(void)
|
||||
@@ -853,7 +853,7 @@ void sub_818E4A4(void)
|
||||
u8 i;
|
||||
|
||||
gUnknown_0203CD68 = &gSaveBlock1Ptr->lilycoveLady.quiz;
|
||||
gUnknown_0203CD68->itemId = gScriptItemId;
|
||||
gUnknown_0203CD68->itemId = gSpecialVar_ItemId;
|
||||
for (i = 0; i < 4; i ++)
|
||||
{
|
||||
gUnknown_0203CD68->playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
|
||||
|
||||
@@ -42,7 +42,7 @@ void SetRandomLotteryNumber(u16 i)
|
||||
void RetrieveLotteryNumber(void)
|
||||
{
|
||||
u16 lottoNumber = GetLotteryNumber();
|
||||
gScriptResult = lottoNumber;
|
||||
gSpecialVar_Result = lottoNumber;
|
||||
}
|
||||
|
||||
void PickLotteryCornerTicket(void)
|
||||
@@ -66,7 +66,7 @@ void PickLotteryCornerTicket(void)
|
||||
if (!GetMonData(pkmn, MON_DATA_IS_EGG))
|
||||
{
|
||||
u32 otId = GetMonData(pkmn, MON_DATA_OT_ID);
|
||||
u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId);
|
||||
u8 numMatchingDigits = GetMatchingDigits(gSpecialVar_Result, otId);
|
||||
|
||||
if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ void PickLotteryCornerTicket(void)
|
||||
!GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_IS_EGG))
|
||||
{
|
||||
u32 otId = GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_OT_ID);
|
||||
u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId);
|
||||
u8 numMatchingDigits = GetMatchingDigits(gSpecialVar_Result, otId);
|
||||
|
||||
if (numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1)
|
||||
{
|
||||
|
||||
@@ -386,7 +386,7 @@ bool8 sub_81215EC(void)
|
||||
CopyBgTilemapBufferToVram(2);
|
||||
break;
|
||||
case 12:
|
||||
LoadPalette(sub_8098C64(), 240, 32);
|
||||
LoadPalette(GetOverworldTextboxPalettePtr(), 240, 32);
|
||||
gPlttBufferUnfaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
|
||||
gPlttBufferFaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
|
||||
gPlttBufferUnfaded[251] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color12;
|
||||
|
||||
@@ -59,7 +59,7 @@ extern void ResetContestLinkResults(void);
|
||||
extern void ResetPokeJumpResults(void);
|
||||
extern void SetBerryPowder(u32* powder, u32 newValue);
|
||||
|
||||
extern u8 gUnknown_082715DE[];
|
||||
extern u8 EventScript_2715DE[];
|
||||
|
||||
void WriteUnalignedWord(u32 var, u8 *dataPtr)
|
||||
{
|
||||
@@ -198,7 +198,7 @@ void NewGameInitData(void)
|
||||
ResetFanClub();
|
||||
ResetLotteryCorner();
|
||||
WarpToTruck();
|
||||
ScriptContext2_RunNewScript(gUnknown_082715DE);
|
||||
ScriptContext2_RunNewScript(EventScript_2715DE);
|
||||
ResetMiniGamesResults();
|
||||
copy_strings_to_sav1();
|
||||
SetLilycoveLady();
|
||||
|
||||
@@ -1087,10 +1087,10 @@ u8 SendMonToPC(struct Pokemon* mon)
|
||||
{
|
||||
MonRestorePP(mon);
|
||||
CopyMon(checkingMon, &mon->box, sizeof(mon->box));
|
||||
gSpecialVar_0x8012 = boxNo;
|
||||
gSpecialVar_0x8013 = boxPos;
|
||||
gSpecialVar_MonBoxId = boxNo;
|
||||
gSpecialVar_MonBoxPos = boxPos;
|
||||
if (get_unknown_box_id() != boxNo)
|
||||
FlagClear(SYS_STORAGE_UNKNOWN_FLAG);
|
||||
FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
|
||||
VarSet(VAR_STORAGE_UNKNOWN, boxNo);
|
||||
return MON_GIVEN_TO_PC;
|
||||
}
|
||||
|
||||
@@ -109,13 +109,13 @@ static void FormatMonSizeRecord(u8 *string, u32 size)
|
||||
|
||||
static u8 CompareMonSize(u16 species, u16 *sizeRecord)
|
||||
{
|
||||
if (gScriptResult == 0xFF)
|
||||
if (gSpecialVar_Result == 0xFF)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Pokemon *pkmn = &gPlayerParty[gScriptResult];
|
||||
struct Pokemon *pkmn = &gPlayerParty[gSpecialVar_Result];
|
||||
|
||||
if (GetMonData(pkmn, MON_DATA_IS_EGG) == TRUE || GetMonData(pkmn, MON_DATA_SPECIES) != species)
|
||||
{
|
||||
@@ -173,7 +173,7 @@ void CompareSeedotSize(void)
|
||||
{
|
||||
u16 *sizeRecord = GetVarPointer(VAR_SEEDOT_SIZE_RECORD);
|
||||
|
||||
gScriptResult = CompareMonSize(SPECIES_SEEDOT, sizeRecord);
|
||||
gSpecialVar_Result = CompareMonSize(SPECIES_SEEDOT, sizeRecord);
|
||||
}
|
||||
|
||||
void InitLotadSizeRecord(void)
|
||||
@@ -192,7 +192,7 @@ void CompareLotadSize(void)
|
||||
{
|
||||
u16 *sizeRecord = GetVarPointer(VAR_LOTAD_SIZE_RECORD);
|
||||
|
||||
gScriptResult = CompareMonSize(SPECIES_LOTAD, sizeRecord);
|
||||
gSpecialVar_Result = CompareMonSize(SPECIES_LOTAD, sizeRecord);
|
||||
}
|
||||
|
||||
void GiveGiftRibbonToParty(u8 index, u8 ribbonId)
|
||||
@@ -217,6 +217,6 @@ void GiveGiftRibbonToParty(u8 index, u8 ribbonId)
|
||||
}
|
||||
}
|
||||
if (gotRibbon)
|
||||
FlagSet(SYS_RIBBON_GET);
|
||||
FlagSet(FLAG_SYS_RIBBON_GET);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ struct PokeblockFeeder
|
||||
extern u8 gBattleOutcome;
|
||||
extern void* gFieldCallback;
|
||||
|
||||
extern u8 gUnknown_082A4B8A[];
|
||||
extern u8 gUnknown_082A4B6F[];
|
||||
extern u8 gUnknown_082A4B4C[];
|
||||
extern u8 gUnknown_082A4B9B[];
|
||||
extern u8 EventScript_2A4B8A[];
|
||||
extern u8 EventScript_2A4B6F[];
|
||||
extern u8 EventScript_2A4B4C[];
|
||||
extern u8 EventScript_2A4B9B[];
|
||||
extern const u8* const gPokeblockNames[];
|
||||
|
||||
extern void sub_80EE44C(u8, u8);
|
||||
@@ -50,17 +50,17 @@ static void DecrementFeederStepCounters(void);
|
||||
|
||||
bool32 GetSafariZoneFlag(void)
|
||||
{
|
||||
return FlagGet(SYS_SAFARI_MODE);
|
||||
return FlagGet(FLAG_SYS_SAFARI_MODE);
|
||||
}
|
||||
|
||||
void SetSafariZoneFlag(void)
|
||||
{
|
||||
FlagSet(SYS_SAFARI_MODE);
|
||||
FlagSet(FLAG_SYS_SAFARI_MODE);
|
||||
}
|
||||
|
||||
void ResetSafariZoneFlag(void)
|
||||
{
|
||||
FlagClear(SYS_SAFARI_MODE);
|
||||
FlagClear(FLAG_SYS_SAFARI_MODE);
|
||||
}
|
||||
|
||||
void EnterSafariMode(void)
|
||||
@@ -94,7 +94,7 @@ bool8 SafariZoneTakeStep(void)
|
||||
sSafariZoneStepCounter--;
|
||||
if (sSafariZoneStepCounter == 0)
|
||||
{
|
||||
ScriptContext1_SetupScript(gUnknown_082A4B8A);
|
||||
ScriptContext1_SetupScript(EventScript_2A4B8A);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -102,7 +102,7 @@ bool8 SafariZoneTakeStep(void)
|
||||
|
||||
void SafariZoneRetirePrompt(void)
|
||||
{
|
||||
ScriptContext1_SetupScript(gUnknown_082A4B6F);
|
||||
ScriptContext1_SetupScript(EventScript_2A4B6F);
|
||||
}
|
||||
|
||||
void sub_80FC190(void)
|
||||
@@ -116,14 +116,14 @@ void sub_80FC190(void)
|
||||
}
|
||||
else if (gBattleOutcome == BATTLE_SAFARI_OUT_OF_BALLS)
|
||||
{
|
||||
ScriptContext2_RunNewScript(gUnknown_082A4B4C);
|
||||
ScriptContext2_RunNewScript(EventScript_2A4B4C);
|
||||
warp_in();
|
||||
gFieldCallback = sub_80AF6F0;
|
||||
SetMainCallback2(c2_load_new_map);
|
||||
}
|
||||
else if (gBattleOutcome == BATTLE_CAUGHT)
|
||||
{
|
||||
ScriptContext1_SetupScript(gUnknown_082A4B9B);
|
||||
ScriptContext1_SetupScript(EventScript_2A4B9B);
|
||||
ScriptContext1_Stop();
|
||||
SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music);
|
||||
}
|
||||
@@ -152,13 +152,13 @@ void GetPokeblockFeederInFront(void)
|
||||
&& sPokeblockFeeders[i].x == x
|
||||
&& sPokeblockFeeders[i].y == y)
|
||||
{
|
||||
gScriptResult = i;
|
||||
gSpecialVar_Result = i;
|
||||
StringCopy(gStringVar1, gPokeblockNames[sPokeblockFeeders[i].pokeblock.color]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gScriptResult = -1;
|
||||
gSpecialVar_Result = -1;
|
||||
}
|
||||
|
||||
void GetPokeblockFeederWithinRange(void)
|
||||
@@ -181,13 +181,13 @@ void GetPokeblockFeederWithinRange(void)
|
||||
y *= -1;
|
||||
if ((x + y) <= 5)
|
||||
{
|
||||
gScriptResult = i;
|
||||
gSpecialVar_Result = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gScriptResult = -1;
|
||||
gSpecialVar_Result = -1;
|
||||
}
|
||||
|
||||
// unused
|
||||
@@ -195,20 +195,20 @@ struct Pokeblock *SafariZoneGetPokeblockInFront(void)
|
||||
{
|
||||
GetPokeblockFeederInFront();
|
||||
|
||||
if (gScriptResult == 0xFFFF)
|
||||
if (gSpecialVar_Result == 0xFFFF)
|
||||
return NULL;
|
||||
else
|
||||
return &sPokeblockFeeders[gScriptResult].pokeblock;
|
||||
return &sPokeblockFeeders[gSpecialVar_Result].pokeblock;
|
||||
}
|
||||
|
||||
struct Pokeblock *SafariZoneGetActivePokeblock(void)
|
||||
{
|
||||
GetPokeblockFeederWithinRange();
|
||||
|
||||
if (gScriptResult == 0xFFFF)
|
||||
if (gSpecialVar_Result == 0xFFFF)
|
||||
return NULL;
|
||||
else
|
||||
return &sPokeblockFeeders[gScriptResult].pokeblock;
|
||||
return &sPokeblockFeeders[gSpecialVar_Result].pokeblock;
|
||||
}
|
||||
|
||||
void SafariZoneActivatePokeblockFeeder(u8 pkblId)
|
||||
@@ -255,13 +255,13 @@ bool8 GetInFrontFeederPokeblockAndSteps(void)
|
||||
{
|
||||
GetPokeblockFeederInFront();
|
||||
|
||||
if (gScriptResult == 0xFFFF)
|
||||
if (gSpecialVar_Result == 0xFFFF)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ConvertIntToDecimalStringN(gStringVar2,
|
||||
sPokeblockFeeders[gScriptResult].stepCounter,
|
||||
sPokeblockFeeders[gSpecialVar_Result].stepCounter,
|
||||
STR_CONV_MODE_LEADING_ZEROS, 3);
|
||||
|
||||
return TRUE;
|
||||
|
||||
168
src/scrcmd.c
168
src/scrcmd.c
@@ -69,9 +69,9 @@ extern u16 gSpecialVar_0x8001;
|
||||
extern u16 gSpecialVar_0x8002;
|
||||
extern u16 gSpecialVar_0x8004;
|
||||
|
||||
extern u16 gScriptResult;
|
||||
extern u16 gSpecialVar_Result;
|
||||
|
||||
extern u16 gScriptContestCategory;
|
||||
extern u16 gSpecialVar_ContestCategory;
|
||||
|
||||
IWRAM_DATA u8 gUnknown_03000F30;
|
||||
|
||||
@@ -491,25 +491,25 @@ bool8 ScrCmd_random(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 max = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = Random() % max;
|
||||
gSpecialVar_Result = Random() % max;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_additem(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_giveitem(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
u32 quantity = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = AddBagItem(itemId, (u8)quantity);
|
||||
gSpecialVar_Result = AddBagItem(itemId, (u8)quantity);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_removeitem(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_takeitem(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
u32 quantity = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = RemoveBagItem(itemId, (u8)quantity);
|
||||
gSpecialVar_Result = RemoveBagItem(itemId, (u8)quantity);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -518,7 +518,7 @@ bool8 ScrCmd_checkitemspace(struct ScriptContext *ctx)
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
u32 quantity = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = CheckBagHasSpace(itemId, (u8)quantity);
|
||||
gSpecialVar_Result = CheckBagHasSpace(itemId, (u8)quantity);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ bool8 ScrCmd_checkitem(struct ScriptContext *ctx)
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
u32 quantity = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = CheckBagHasItem(itemId, (u8)quantity);
|
||||
gSpecialVar_Result = CheckBagHasItem(itemId, (u8)quantity);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -535,16 +535,16 @@ bool8 ScrCmd_checkitemtype(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = GetPocketByItemId(itemId);
|
||||
gSpecialVar_Result = GetPocketByItemId(itemId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_addpcitem(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_givepcitem(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 quantity = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = AddPCItem(itemId, quantity);
|
||||
gSpecialVar_Result = AddPCItem(itemId, quantity);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -553,23 +553,31 @@ bool8 ScrCmd_checkpcitem(struct ScriptContext *ctx)
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 quantity = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = CheckPCHasItem(itemId, quantity);
|
||||
gSpecialVar_Result = CheckPCHasItem(itemId, quantity);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_adddecor(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_givedecoration(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 decorId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = DecorationAdd(decorId);
|
||||
gSpecialVar_Result = DecorationAdd(decorId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_removedecor(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_takedecoration(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 decorId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = DecorationRemove(decorId);
|
||||
gSpecialVar_Result = DecorationRemove(decorId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_checkdecorspace(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 decorId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gSpecialVar_Result = DecorationCheckSpace(decorId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -577,15 +585,7 @@ bool8 ScrCmd_checkdecor(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 decorId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = DecorationCheckSpace(decorId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_hasdecor(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 decorId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = CheckHasDecoration(decorId);
|
||||
gSpecialVar_Result = CheckHasDecoration(decorId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -613,14 +613,14 @@ bool8 ScrCmd_incrementgamestat(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_animdarklevel(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_animateflash(struct ScriptContext *ctx)
|
||||
{
|
||||
sub_80B009C(ScriptReadByte(ctx));
|
||||
ScriptContext1_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_setdarklevel(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setflashradius(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 flashLevel = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
@@ -643,12 +643,12 @@ bool8 ScrCmd_fadescreen(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_fadescreendelay(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_fadescreenspeed(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 mode = ScriptReadByte(ctx);
|
||||
u8 delay = ScriptReadByte(ctx);
|
||||
u8 speed = ScriptReadByte(ctx);
|
||||
|
||||
fade_screen(mode, delay);
|
||||
fade_screen(mode, speed);
|
||||
SetupNativeScript(ctx, IsPaletteNotActive);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -736,7 +736,7 @@ bool8 ScrCmd_doweather(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_tileeffect(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setstepcallback(struct ScriptContext *ctx)
|
||||
{
|
||||
ActivatePerStepCallback(ScriptReadByte(ctx));
|
||||
return FALSE;
|
||||
@@ -907,9 +907,9 @@ bool8 ScrCmd_getplayerxy(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_countpokemon(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_getpartysize(struct ScriptContext *ctx)
|
||||
{
|
||||
gScriptResult = CalculatePlayerPartyCount();
|
||||
gSpecialVar_Result = CalculatePlayerPartyCount();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1121,7 +1121,7 @@ bool8 ScrCmd_moveobjectoffscreen(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_showobject(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_showobject_at(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 localId = VarGet(ScriptReadHalfword(ctx));
|
||||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
@@ -1131,7 +1131,7 @@ bool8 ScrCmd_showobject(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_hideobject(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_hideobject_at(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 localId = VarGet(ScriptReadHalfword(ctx));
|
||||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
@@ -1339,7 +1339,7 @@ static bool8 WaitForAorBPress(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_waitbutton(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_waitbuttonpress(struct ScriptContext *ctx)
|
||||
{
|
||||
SetupNativeScript(ctx, WaitForAorBPress);
|
||||
return TRUE;
|
||||
@@ -1454,7 +1454,7 @@ bool8 ScrCmd_drawboxtext(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_drawpokepic(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_showmonpic(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 species = VarGet(ScriptReadHalfword(ctx));
|
||||
u8 x = ScriptReadByte(ctx);
|
||||
@@ -1464,7 +1464,7 @@ bool8 ScrCmd_drawpokepic(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_erasepokepic(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx)
|
||||
{
|
||||
bool8 (*func)(void) = ScriptMenu_GetPicboxWaitFunc();
|
||||
|
||||
@@ -1474,7 +1474,7 @@ bool8 ScrCmd_erasepokepic(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_drawcontestwinner(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 v1 = ScriptReadByte(ctx);
|
||||
|
||||
@@ -1694,7 +1694,7 @@ bool8 ScrCmd_vmessage(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getspeciesname(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferspeciesname(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 species = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1703,7 +1703,7 @@ bool8 ScrCmd_getspeciesname(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getfirstpartypokename(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferleadmonspeciesname(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
|
||||
@@ -1714,7 +1714,7 @@ bool8 ScrCmd_getfirstpartypokename(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getpartypokename(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferpartymonnick(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1724,7 +1724,7 @@ bool8 ScrCmd_getpartypokename(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getitemname(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferitemname(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1733,7 +1733,7 @@ bool8 ScrCmd_getitemname(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getitemnameplural(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferitemnameplural(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 itemId = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1743,7 +1743,7 @@ bool8 ScrCmd_getitemnameplural(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getdecorname(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferdecorationname(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 decorId = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1752,7 +1752,7 @@ bool8 ScrCmd_getdecorname(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getmovename(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_buffermovename(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 moveId = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1761,7 +1761,7 @@ bool8 ScrCmd_getmovename(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getnumberstring(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 v1 = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1771,7 +1771,7 @@ bool8 ScrCmd_getnumberstring(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getstdstring(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferstdstring(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 index = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1780,7 +1780,7 @@ bool8 ScrCmd_getstdstring(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getcontesttype(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_buffercontesttype(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 index = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1789,7 +1789,7 @@ bool8 ScrCmd_getcontesttype(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getstring(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferstring(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
const u8 *text = (u8 *)ScriptReadWord(ctx);
|
||||
@@ -1806,7 +1806,7 @@ bool8 ScrCmd_vloadword(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_vgetstring(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_vbufferstring(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u32 addr = ScriptReadWord(ctx);
|
||||
@@ -1817,7 +1817,7 @@ bool8 ScrCmd_vgetstring(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_getboxname(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_bufferboxname(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 boxId = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -1826,7 +1826,7 @@ bool8 ScrCmd_getboxname(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_givepoke(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_givemon(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 species = VarGet(ScriptReadHalfword(ctx));
|
||||
u8 level = ScriptReadByte(ctx);
|
||||
@@ -1835,7 +1835,7 @@ bool8 ScrCmd_givepoke(struct ScriptContext *ctx)
|
||||
u32 unkParam2 = ScriptReadWord(ctx);
|
||||
u8 unkParam3 = ScriptReadByte(ctx);
|
||||
|
||||
gScriptResult = ScriptGiveMon(species, level, item, unkParam1, unkParam2, unkParam3);
|
||||
gSpecialVar_Result = ScriptGiveMon(species, level, item, unkParam1, unkParam2, unkParam3);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1843,11 +1843,11 @@ bool8 ScrCmd_giveegg(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 species = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = ScriptGiveEgg(species);
|
||||
gSpecialVar_Result = ScriptGiveEgg(species);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_setpokemove(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setmonmove(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 partyIndex = ScriptReadByte(ctx);
|
||||
u8 slot = ScriptReadByte(ctx);
|
||||
@@ -1857,12 +1857,12 @@ bool8 ScrCmd_setpokemove(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_checkpokemove(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_checkpartymove(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 i;
|
||||
u16 moveId = ScriptReadHalfword(ctx);
|
||||
|
||||
gScriptResult = 6;
|
||||
gSpecialVar_Result = 6;
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL);
|
||||
@@ -1871,7 +1871,7 @@ bool8 ScrCmd_checkpokemove(struct ScriptContext *ctx)
|
||||
// UB: GetMonData() arguments don't match function definition
|
||||
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && pokemon_has_move(&gPlayerParty[i], moveId) == TRUE)
|
||||
{
|
||||
gScriptResult = i;
|
||||
gSpecialVar_Result = i;
|
||||
gSpecialVar_0x8004 = species;
|
||||
break;
|
||||
}
|
||||
@@ -1905,7 +1905,7 @@ bool8 ScrCmd_checkmoney(struct ScriptContext *ctx)
|
||||
u8 ignore = ScriptReadByte(ctx);
|
||||
|
||||
if (!ignore)
|
||||
gScriptResult = IsEnoughMoney(&gSaveBlock1Ptr->money, amount);
|
||||
gSpecialVar_Result = IsEnoughMoney(&gSaveBlock1Ptr->money, amount);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1973,7 +1973,7 @@ bool8 ScrCmd_trainerbattle(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_battlebegin(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_dotrainerbattle(struct ScriptContext *ctx)
|
||||
{
|
||||
BattleSetup_StartTrainerBattle();
|
||||
return TRUE;
|
||||
@@ -2041,7 +2041,7 @@ bool8 ScrCmd_pokemart(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_pokemartdecor(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_pokemartdecoration(struct ScriptContext *ctx)
|
||||
{
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
@@ -2050,7 +2050,7 @@ bool8 ScrCmd_pokemartdecor(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_pokemartbp(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_pokemartdecoration2(struct ScriptContext *ctx)
|
||||
{
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
@@ -2068,7 +2068,7 @@ bool8 ScrCmd_playslotmachine(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_plantberrytree(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setberrytree(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 treeId = ScriptReadByte(ctx);
|
||||
u8 berry = ScriptReadByte(ctx);
|
||||
@@ -2085,7 +2085,7 @@ bool8 ScrCmd_getpricereduction(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 value = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = GetPriceReduction(value);
|
||||
gSpecialVar_Result = GetPriceReduction(value);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2113,7 +2113,7 @@ bool8 ScrCmd_showcontestresults(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_contestlinktransfer(struct ScriptContext *ctx)
|
||||
{
|
||||
sub_80F84C4(gScriptContestCategory);
|
||||
sub_80F84C4(gSpecialVar_ContestCategory);
|
||||
ScriptContext1_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2127,7 +2127,7 @@ bool8 ScrCmd_dofieldeffect(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_setfieldeffect(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setfieldeffectarg(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 argNum = ScriptReadByte(ctx);
|
||||
|
||||
@@ -2150,7 +2150,7 @@ bool8 ScrCmd_waitfieldeffect(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_sethealplace(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setrespawn(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 healLocationId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
@@ -2160,11 +2160,11 @@ bool8 ScrCmd_sethealplace(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_checkplayergender(struct ScriptContext *ctx)
|
||||
{
|
||||
gScriptResult = gSaveBlock2Ptr->playerGender;
|
||||
gSpecialVar_Result = gSaveBlock2Ptr->playerGender;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_playpokecry(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_playmoncry(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 species = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 mode = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -2173,13 +2173,13 @@ bool8 ScrCmd_playpokecry(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_waitpokecry(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_waitmoncry(struct ScriptContext *ctx)
|
||||
{
|
||||
SetupNativeScript(ctx, IsCryFinished);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_setmaptile(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -2285,9 +2285,9 @@ bool8 ScrCmd_givecoins(struct ScriptContext *ctx)
|
||||
u16 coins = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
if (GiveCoins(coins) == TRUE)
|
||||
gScriptResult = 0;
|
||||
gSpecialVar_Result = 0;
|
||||
else
|
||||
gScriptResult = 1;
|
||||
gSpecialVar_Result = 1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2296,9 +2296,9 @@ bool8 ScrCmd_takecoins(struct ScriptContext *ctx)
|
||||
u16 coins = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
if (TakeCoins(coins) == TRUE)
|
||||
gScriptResult = 0;
|
||||
gSpecialVar_Result = 0;
|
||||
else
|
||||
gScriptResult = 1;
|
||||
gSpecialVar_Result = 1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2353,8 +2353,8 @@ bool8 ScrCmd_cmdD9(struct ScriptContext *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// This command will force the Pokémon to be obedient, you don't get to choose which value to set its obedience to
|
||||
bool8 ScrCmd_setpokeobedient(struct ScriptContext *ctx)
|
||||
// This command will force the Pokémon to be obedient, you don't get to make it disobedient
|
||||
bool8 ScrCmd_setmonobedient(struct ScriptContext *ctx)
|
||||
{
|
||||
bool8 obedient = TRUE;
|
||||
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -2363,11 +2363,11 @@ bool8 ScrCmd_setpokeobedient(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_checkpokeobedience(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_checkmonobedience(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
gScriptResult = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OBEDIENCE, NULL);
|
||||
gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OBEDIENCE, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2398,7 +2398,7 @@ bool8 ScrCmd_warpD1(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_setpokemetlocation(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_setmonmetlocation(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 partyIndex = VarGet(ScriptReadHalfword(ctx));
|
||||
u8 location = ScriptReadByte(ctx);
|
||||
@@ -2414,7 +2414,7 @@ void sub_809BDB4(void)
|
||||
RemoveWindow(gUnknown_03000F30);
|
||||
}
|
||||
|
||||
bool8 ScrCmd_gettrainerclass(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_buffertrainerclassname(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 trainerClassId = VarGet(ScriptReadHalfword(ctx));
|
||||
@@ -2423,7 +2423,7 @@ bool8 ScrCmd_gettrainerclass(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_gettrainername(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_buffertrainername(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 trainerClassId = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
@@ -175,14 +175,14 @@ void sub_80E8B6C(void)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
for (i = 0; i < 20; i ++)
|
||||
{
|
||||
if (sCurSecretBaseId != gSaveBlock1Ptr->secretBases[i].secretBaseId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
VarSet(VAR_0x4054, i);
|
||||
break;
|
||||
}
|
||||
@@ -192,11 +192,11 @@ void sub_80E8BC8(void)
|
||||
{
|
||||
if (gSaveBlock1Ptr->secretBases[0].secretBaseId != 0)
|
||||
{
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,22 +544,22 @@ void sub_80E933C(void)
|
||||
metatile = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
|
||||
if (MetatileBehavior_IsMB_B5(metatile) == TRUE || MetatileBehavior_IsMB_C3(metatile) == TRUE)
|
||||
{
|
||||
gScriptResult = gMapHeader.events->mapObjects[objIdx].graphicsId + VAR_0x3F20;
|
||||
VarSet(gScriptResult, gDecorations[roomDecor[decorIdx]].tiles[0]);
|
||||
gScriptResult = gMapHeader.events->mapObjects[objIdx].localId;
|
||||
gSpecialVar_Result = gMapHeader.events->mapObjects[objIdx].graphicsId + VAR_0x3F20;
|
||||
VarSet(gSpecialVar_Result, gDecorations[roomDecor[decorIdx]].tiles[0]);
|
||||
gSpecialVar_Result = gMapHeader.events->mapObjects[objIdx].localId;
|
||||
FlagClear(gSpecialVar_0x8004 + 0xAE);
|
||||
show_sprite(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
sub_808EBA8(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
|
||||
sub_808F254(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
show_sprite(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
sub_808EBA8(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
|
||||
sub_808F254(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
if (CurrentMapIsSecretBase() == TRUE && VarGet(VAR_0x4054) != 0)
|
||||
{
|
||||
if (category == DECORCAT_DOLL)
|
||||
{
|
||||
sub_808F28C(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_DOLL);
|
||||
sub_808F28C(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_DOLL);
|
||||
}
|
||||
else if (category == DECORCAT_CUSHION)
|
||||
{
|
||||
sub_808F28C(gScriptResult, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_CUSHION);
|
||||
sub_808F28C(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, DECORCAT_CUSHION);
|
||||
}
|
||||
}
|
||||
gSpecialVar_0x8004 ++;
|
||||
@@ -608,14 +608,14 @@ void sub_80E9668(struct Coords16 *coords, struct MapEvents *events)
|
||||
{
|
||||
sub_80E9608(coords, events);
|
||||
sub_80E8B6C();
|
||||
ScriptContext1_SetupScript(gUnknown_08275BB7);
|
||||
ScriptContext1_SetupScript(EventScript_275BB7);
|
||||
}
|
||||
|
||||
bool8 sub_80E9680(void)
|
||||
{
|
||||
sub_80E8B58();
|
||||
sub_80E8B6C();
|
||||
if (gScriptResult == TRUE)
|
||||
if (gSpecialVar_Result == TRUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -657,11 +657,11 @@ void sub_80E9744(void)
|
||||
{
|
||||
if (gSaveBlock1Ptr->secretBases[0].secretBaseId != sCurSecretBaseId)
|
||||
{
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1016,15 +1016,15 @@ void sub_80E9BDC(void)
|
||||
{
|
||||
if (sub_80E9878(VarGet(VAR_0x4054)) == TRUE)
|
||||
{
|
||||
gScriptResult = 1;
|
||||
gSpecialVar_Result = 1;
|
||||
}
|
||||
else if (sub_80E9BA8() > 9)
|
||||
{
|
||||
gScriptResult = 2;
|
||||
gSpecialVar_Result = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
gScriptResult = 0;
|
||||
gSpecialVar_Result = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1289,41 +1289,41 @@ const u8 *sub_80EA250(void)
|
||||
param = sub_80EA20C(VarGet(VAR_0x4054));
|
||||
if (param == 0)
|
||||
{
|
||||
return gUnknown_08274966;
|
||||
return SecretBase_RedCave1_Text_274966;
|
||||
}
|
||||
if (param == 1)
|
||||
{
|
||||
return gUnknown_08274D13;
|
||||
return SecretBase_RedCave1_Text_274D13;
|
||||
}
|
||||
if (param == 2)
|
||||
{
|
||||
return gUnknown_08274FFE;
|
||||
return SecretBase_RedCave1_Text_274FFE;
|
||||
}
|
||||
if (param == 3)
|
||||
{
|
||||
return gUnknown_08275367;
|
||||
return SecretBase_RedCave1_Text_275367;
|
||||
}
|
||||
if (param == 4)
|
||||
{
|
||||
return gUnknown_082756C7;
|
||||
return SecretBase_RedCave1_Text_2756C7;
|
||||
}
|
||||
if (param == 5)
|
||||
{
|
||||
return gUnknown_08274B24;
|
||||
return SecretBase_RedCave1_Text_274B24;
|
||||
}
|
||||
if (param == 6)
|
||||
{
|
||||
return gUnknown_08274E75;
|
||||
return SecretBase_RedCave1_Text_274E75;
|
||||
}
|
||||
if (param == 7)
|
||||
{
|
||||
return gUnknown_082751E1;
|
||||
return SecretBase_RedCave1_Text_2751E1;
|
||||
}
|
||||
if (param == 8)
|
||||
{
|
||||
return gUnknown_082754F6;
|
||||
return SecretBase_RedCave1_Text_2754F6;
|
||||
}
|
||||
return gUnknown_082758CC;
|
||||
return SecretBase_RedCave1_Text_2758CC;
|
||||
}
|
||||
|
||||
void sub_80EA2E4(void)
|
||||
@@ -1335,7 +1335,7 @@ void sub_80EA2E4(void)
|
||||
|
||||
void sub_80EA30C(void)
|
||||
{
|
||||
gSaveBlock1Ptr->secretBases[VarGet(VAR_0x4054)].sbr_field_1_5 = gScriptResult;
|
||||
gSaveBlock1Ptr->secretBases[VarGet(VAR_0x4054)].sbr_field_1_5 = gSpecialVar_Result;
|
||||
}
|
||||
|
||||
void sub_80EA354(void)
|
||||
@@ -1353,7 +1353,7 @@ void sub_80EA354(void)
|
||||
FlagSet(0x922);
|
||||
}
|
||||
gSpecialVar_0x8004 = sub_80EA20C(secretBaseRecordId);
|
||||
gScriptResult = gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_1_5;
|
||||
gSpecialVar_Result = gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_1_5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -74,12 +74,12 @@ void AddStartMenuAction(u8 action)
|
||||
|
||||
static void BuildStartMenuActions_Normal(void)
|
||||
{
|
||||
if (FlagGet(SYS_POKEDEX_GET) == TRUE)
|
||||
if (FlagGet(FLAG_SYS_POKEDEX_GET) == TRUE)
|
||||
AddStartMenuAction(MENU_ACTION_POKEDEX);
|
||||
if (FlagGet(SYS_POKEMON_GET) == TRUE)
|
||||
if (FlagGet(FLAG_SYS_POKEMON_GET) == TRUE)
|
||||
AddStartMenuAction(MENU_ACTION_POKEMON);
|
||||
AddStartMenuAction(MENU_ACTION_BAG);
|
||||
if (FlagGet(SYS_POKENAV_GET) == TRUE)
|
||||
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
|
||||
AddStartMenuAction(MENU_ACTION_POKENAV);
|
||||
AddStartMenuAction(MENU_ACTION_PLAYER);
|
||||
AddStartMenuAction(MENU_ACTION_SAVE);
|
||||
@@ -102,7 +102,7 @@ static void BuildStartMenuActions_LinkMode(void)
|
||||
{
|
||||
AddStartMenuAction(MENU_ACTION_POKEMON);
|
||||
AddStartMenuAction(MENU_ACTION_BAG);
|
||||
if (FlagGet(SYS_POKENAV_GET) == TRUE)
|
||||
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
|
||||
AddStartMenuAction(MENU_ACTION_POKENAV);
|
||||
AddStartMenuAction(MENU_ACTION_PLAYER_LINK);
|
||||
AddStartMenuAction(MENU_ACTION_OPTION);
|
||||
@@ -113,7 +113,7 @@ static void BuildStartMenuActions_UnionRoom(void)
|
||||
{
|
||||
AddStartMenuAction(MENU_ACTION_POKEMON);
|
||||
AddStartMenuAction(MENU_ACTION_BAG);
|
||||
if (FlagGet(SYS_POKENAV_GET) == TRUE)
|
||||
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
|
||||
AddStartMenuAction(MENU_ACTION_POKENAV);
|
||||
AddStartMenuAction(MENU_ACTION_PLAYER);
|
||||
AddStartMenuAction(MENU_ACTION_OPTION);
|
||||
|
||||
391
src/starter_choose.c
Normal file
391
src/starter_choose.c
Normal file
@@ -0,0 +1,391 @@
|
||||
#include "global.h"
|
||||
#include "starter_choose.h"
|
||||
#include "palette.h"
|
||||
#include "sprite.h"
|
||||
#include "pokemon.h"
|
||||
#include "task.h"
|
||||
#include "bg.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "main.h"
|
||||
#include "window.h"
|
||||
#include "text.h"
|
||||
#include "decompress.h"
|
||||
#include "menu.h"
|
||||
#include "sound.h"
|
||||
#include "songs.h"
|
||||
#include "event_data.h"
|
||||
#include "pokedex.h"
|
||||
#include "data2.h"
|
||||
#include "international_string_util.h"
|
||||
#include "trig.h"
|
||||
|
||||
#define STARTER_MON_COUNT 3
|
||||
|
||||
// Position of the sprite of the selected starter Pokemon
|
||||
#define STARTER_PKMN_POS_X 120
|
||||
#define STARTER_PKMN_POS_Y 64
|
||||
|
||||
// graphics
|
||||
extern const u32 gBirchHelpGfx[];
|
||||
extern const u32 gBirchBagTilemap[];
|
||||
extern const u32 gBirchGrassTilemap[];
|
||||
extern const u16 gBirchBagGrassPal[];
|
||||
|
||||
// text
|
||||
extern const u8 gText_BirchInTrouble[];
|
||||
extern const u8 gText_ConfirmStarterChoice[];
|
||||
|
||||
extern const u16 sStarterMon[STARTER_MON_COUNT];
|
||||
extern const struct BgTemplate gUnknown_085B1E00[3];
|
||||
extern const struct WindowTemplate gUnknown_085B1DCC[];
|
||||
extern const struct WindowTemplate gUnknown_085B1DDC;
|
||||
extern const struct CompressedSpriteSheet gUnknown_085B1ED8[];
|
||||
extern const struct CompressedSpriteSheet gUnknown_085B1EE8[];
|
||||
extern const struct SpritePalette gUnknown_085B1EF8[];
|
||||
extern const struct SpriteTemplate sSpriteTemplate_PokeBall;
|
||||
extern const struct SpriteTemplate sSpriteTemplate_Hand;
|
||||
extern const struct SpriteTemplate gUnknown_085B1F40;
|
||||
extern const union AffineAnimCmd *const gUnknown_085B1ED0;
|
||||
extern const u8 sPokeballCoords[STARTER_MON_COUNT][2];
|
||||
extern const struct WindowTemplate gUnknown_085B1DE4;
|
||||
extern const u8 gStarterChoose_LabelCoords[][2];
|
||||
extern const u8 gUnknown_085B1E0C[];
|
||||
extern const u8 gUnknown_085B1E28[][2];
|
||||
|
||||
extern void sub_809882C(u8, u16, u8);
|
||||
extern void remove_some_task(void);
|
||||
extern void clear_scheduled_bg_copies_to_vram(void);
|
||||
extern void dp13_810BB8C(void);
|
||||
extern void do_scheduled_bg_tilemap_copies_to_vram(void);
|
||||
extern u16 sub_818D820(u16);
|
||||
extern const u16 *GetOverworldTextboxPalettePtr(void);
|
||||
extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16);
|
||||
|
||||
// this file's functions
|
||||
static void MainCallback2_StarterChoose(void);
|
||||
static void sub_8134604(void);
|
||||
static void Task_StarterChoose1(u8 taskId);
|
||||
static void Task_StarterChoose2(u8 taskId);
|
||||
static void Task_StarterChoose3(u8 taskId);
|
||||
static void Task_StarterChoose4(u8 taskId);
|
||||
static void Task_StarterChoose5(u8 taskId);
|
||||
static void Task_StarterChoose6(u8 taskId);
|
||||
static void Task_MoveStarterChooseCursor(u8 taskId);
|
||||
static void sub_8134668(u8 taskId);
|
||||
static void CreateStarterPokemonLabel(u8 selection);
|
||||
static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y);
|
||||
static void StarterPokemonSpriteCallback(struct Sprite *sprite);
|
||||
|
||||
static IWRAM_DATA u16 sStarterChooseWindowId;
|
||||
|
||||
u16 GetStarterPokemon(u16 chosenStarterId)
|
||||
{
|
||||
if (chosenStarterId > STARTER_MON_COUNT)
|
||||
chosenStarterId = 0;
|
||||
return sStarterMon[chosenStarterId];
|
||||
}
|
||||
|
||||
static void VblankCB_StarterChoose(void)
|
||||
{
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
}
|
||||
|
||||
#define tStarterSelection data[0]
|
||||
#define tPkmnSpriteId data[1]
|
||||
#define tCircleSpriteId data[2]
|
||||
|
||||
void CB2_ChooseStarter(void)
|
||||
{
|
||||
u16 savedIme;
|
||||
u8 taskId;
|
||||
u8 spriteId;
|
||||
|
||||
SetVBlankCallback(NULL);
|
||||
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG3CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG2CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0CNT, 0);
|
||||
|
||||
ChangeBgX(0, 0, 0);
|
||||
ChangeBgY(0, 0, 0);
|
||||
ChangeBgX(1, 0, 0);
|
||||
ChangeBgY(1, 0, 0);
|
||||
ChangeBgX(2, 0, 0);
|
||||
ChangeBgY(2, 0, 0);
|
||||
ChangeBgX(3, 0, 0);
|
||||
ChangeBgY(3, 0, 0);
|
||||
|
||||
DmaFill16(3, 0, VRAM, VRAM_SIZE);
|
||||
DmaFill32(3, 0, OAM, OAM_SIZE);
|
||||
DmaFill16(3, 0, PLTT, PLTT_SIZE);
|
||||
|
||||
LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM);
|
||||
LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000));
|
||||
LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800));
|
||||
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, gUnknown_085B1E00, ARRAY_COUNT(gUnknown_085B1E00));
|
||||
InitWindows(gUnknown_085B1DCC);
|
||||
|
||||
DeactivateAllTextPrinters();
|
||||
sub_809882C(0, 0x2A8, 0xD0);
|
||||
clear_scheduled_bg_copies_to_vram();
|
||||
remove_some_task();
|
||||
ResetTasks();
|
||||
ResetSpriteData();
|
||||
ResetPaletteFade();
|
||||
FreeAllSpritePalettes();
|
||||
dp13_810BB8C();
|
||||
|
||||
LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20);
|
||||
LoadPalette(gBirchBagGrassPal, 0, 0x40);
|
||||
LoadCompressedObjectPic(&gUnknown_085B1ED8[0]);
|
||||
LoadCompressedObjectPic(&gUnknown_085B1EE8[0]);
|
||||
LoadSpritePalettes(gUnknown_085B1EF8);
|
||||
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
|
||||
|
||||
EnableInterrupts(DISPSTAT_VBLANK);
|
||||
SetVBlankCallback(VblankCB_StarterChoose);
|
||||
SetMainCallback2(MainCallback2_StarterChoose);
|
||||
|
||||
SetGpuReg(REG_OFFSET_WININ, 0x3F);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, 0x1F);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0xFE);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDY, 7);
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
||||
|
||||
ShowBg(0);
|
||||
ShowBg(2);
|
||||
ShowBg(3);
|
||||
|
||||
taskId = CreateTask(Task_StarterChoose1, 0);
|
||||
gTasks[taskId].tStarterSelection = 1;
|
||||
|
||||
// Create hand sprite
|
||||
spriteId = CreateSprite(&sSpriteTemplate_Hand, 120, 56, 2);
|
||||
gSprites[spriteId].data0 = taskId;
|
||||
|
||||
// Create three Pokeball sprites
|
||||
spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[0][0], sPokeballCoords[0][1], 2);
|
||||
gSprites[spriteId].data0 = taskId;
|
||||
gSprites[spriteId].data1 = 0;
|
||||
|
||||
spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[1][0], sPokeballCoords[1][1], 2);
|
||||
gSprites[spriteId].data0 = taskId;
|
||||
gSprites[spriteId].data1 = 1;
|
||||
|
||||
spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[2][0], sPokeballCoords[2][1], 2);
|
||||
gSprites[spriteId].data0 = taskId;
|
||||
gSprites[spriteId].data1 = 2;
|
||||
|
||||
sStarterChooseWindowId = 0xFF;
|
||||
}
|
||||
|
||||
static void MainCallback2_StarterChoose(void)
|
||||
{
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
BuildOamBuffer();
|
||||
do_scheduled_bg_tilemap_copies_to_vram();
|
||||
UpdatePaletteFade();
|
||||
}
|
||||
|
||||
static void Task_StarterChoose1(u8 taskId)
|
||||
{
|
||||
CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection);
|
||||
SetWindowBorderStyle(0, FALSE, 0x2A8, 0xD);
|
||||
PrintTextOnWindow(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL);
|
||||
PutWindowTilemap(0);
|
||||
schedule_bg_copy_tilemap_to_vram(0);
|
||||
gTasks[taskId].func = Task_StarterChoose2;
|
||||
}
|
||||
|
||||
static void Task_StarterChoose2(u8 taskId)
|
||||
{
|
||||
u8 selection = gTasks[taskId].tStarterSelection;
|
||||
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
u8 spriteId;
|
||||
|
||||
sub_8134604();
|
||||
|
||||
// Create white circle background
|
||||
spriteId = CreateSprite(&gUnknown_085B1F40, sPokeballCoords[selection][0], sPokeballCoords[selection][1], 1);
|
||||
gTasks[taskId].tCircleSpriteId = spriteId;
|
||||
|
||||
// Create Pokemon sprite
|
||||
spriteId = CreatePokemonFrontSprite(GetStarterPokemon(gTasks[taskId].tStarterSelection), sPokeballCoords[selection][0], sPokeballCoords[selection][1]);
|
||||
gSprites[spriteId].affineAnims = &gUnknown_085B1ED0;
|
||||
gSprites[spriteId].callback = StarterPokemonSpriteCallback;
|
||||
|
||||
gTasks[taskId].tPkmnSpriteId = spriteId;
|
||||
gTasks[taskId].func = Task_StarterChoose3;
|
||||
}
|
||||
else if ((gMain.newKeys & DPAD_LEFT) && selection > 0)
|
||||
{
|
||||
gTasks[taskId].tStarterSelection--;
|
||||
gTasks[taskId].func = Task_MoveStarterChooseCursor;
|
||||
}
|
||||
else if ((gMain.newKeys & DPAD_RIGHT) && selection < (STARTER_MON_COUNT - 1))
|
||||
{
|
||||
gTasks[taskId].tStarterSelection++;
|
||||
gTasks[taskId].func = Task_MoveStarterChooseCursor;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_StarterChoose3(u8 taskId)
|
||||
{
|
||||
if (gSprites[gTasks[taskId].tCircleSpriteId].affineAnimEnded &&
|
||||
gSprites[gTasks[taskId].tCircleSpriteId].pos1.x == STARTER_PKMN_POS_X &&
|
||||
gSprites[gTasks[taskId].tCircleSpriteId].pos1.y == STARTER_PKMN_POS_Y)
|
||||
{
|
||||
gTasks[taskId].func = Task_StarterChoose4;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_StarterChoose4(u8 taskId)
|
||||
{
|
||||
PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0);
|
||||
FillWindowPixelBuffer(0, 0x11);
|
||||
PrintTextOnWindow(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL);
|
||||
schedule_bg_copy_tilemap_to_vram(0);
|
||||
CreateYesNoMenu(&gUnknown_085B1DDC, 0x2A8, 0xD, 0);
|
||||
gTasks[taskId].func = Task_StarterChoose5;
|
||||
}
|
||||
|
||||
static void Task_StarterChoose5(u8 taskId)
|
||||
{
|
||||
u8 spriteId;
|
||||
|
||||
switch (sub_8198C58())
|
||||
{
|
||||
case 0: // YES
|
||||
// Return the starter choice and exit.
|
||||
gSpecialVar_Result = gTasks[taskId].tStarterSelection;
|
||||
dp13_810BB8C();
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
break;
|
||||
case 1: // NO
|
||||
case -1: // B button
|
||||
PlaySE(SE_SELECT);
|
||||
spriteId = gTasks[taskId].tPkmnSpriteId;
|
||||
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
|
||||
sub_818D820(spriteId);
|
||||
|
||||
spriteId = gTasks[taskId].tCircleSpriteId;
|
||||
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
|
||||
DestroySprite(&gSprites[spriteId]);
|
||||
gTasks[taskId].func = Task_StarterChoose6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_StarterChoose6(u8 taskId)
|
||||
{
|
||||
gTasks[taskId].func = Task_StarterChoose1;
|
||||
}
|
||||
|
||||
static void CreateStarterPokemonLabel(u8 selection)
|
||||
{
|
||||
u8 text[32];
|
||||
struct WindowTemplate winTemplate;
|
||||
const u8 *speciesName;
|
||||
s32 width;
|
||||
u8 labelLeft, labelRight, labelTop, labelBottom;
|
||||
|
||||
u16 species = GetStarterPokemon(selection);
|
||||
CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text);
|
||||
speciesName = gSpeciesNames[species];
|
||||
|
||||
winTemplate = gUnknown_085B1DE4;
|
||||
winTemplate.tilemapLeft = gStarterChoose_LabelCoords[selection][0];
|
||||
winTemplate.tilemapTop = gStarterChoose_LabelCoords[selection][1];
|
||||
|
||||
sStarterChooseWindowId = AddWindow(&winTemplate);
|
||||
FillWindowPixelBuffer(sStarterChooseWindowId, 0);
|
||||
|
||||
width = GetStringCenterAlignXOffset(7, text, 0x68);
|
||||
box_print(sStarterChooseWindowId, 7, width, 1, gUnknown_085B1E0C, 0, text);
|
||||
|
||||
width = GetStringCenterAlignXOffset(1, speciesName, 0x68);
|
||||
box_print(sStarterChooseWindowId, 1, width, 0x11, gUnknown_085B1E0C, 0, speciesName);
|
||||
|
||||
PutWindowTilemap(sStarterChooseWindowId);
|
||||
schedule_bg_copy_tilemap_to_vram(0);
|
||||
|
||||
labelLeft = gStarterChoose_LabelCoords[selection][0] * 8 - 4;
|
||||
labelRight = (gStarterChoose_LabelCoords[selection][0] + 13) * 8 + 4;
|
||||
labelTop = gStarterChoose_LabelCoords[selection][1] * 8;
|
||||
labelBottom = (gStarterChoose_LabelCoords[selection][1] + 4) * 8;
|
||||
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(labelLeft, labelRight));
|
||||
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(labelTop, labelBottom));
|
||||
}
|
||||
|
||||
static void sub_8134604(void)
|
||||
{
|
||||
FillWindowPixelBuffer(sStarterChooseWindowId, 0);
|
||||
ClearWindowTilemap(sStarterChooseWindowId);
|
||||
RemoveWindow(sStarterChooseWindowId);
|
||||
sStarterChooseWindowId = 0xFF;
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, 0);
|
||||
schedule_bg_copy_tilemap_to_vram(0);
|
||||
}
|
||||
|
||||
static void Task_MoveStarterChooseCursor(u8 taskId)
|
||||
{
|
||||
sub_8134604();
|
||||
gTasks[taskId].func = sub_8134668;
|
||||
}
|
||||
|
||||
static void sub_8134668(u8 taskId)
|
||||
{
|
||||
CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection);
|
||||
gTasks[taskId].func = Task_StarterChoose2;
|
||||
}
|
||||
|
||||
static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y)
|
||||
{
|
||||
u8 spriteId;
|
||||
|
||||
spriteId = sub_818D3E4(species, 8, 0, 1, x, y, 0xE, 0xFFFF);
|
||||
gSprites[spriteId].oam.priority = 0;
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
static void sub_81346DC(struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos1.x = gUnknown_085B1E28[gTasks[sprite->data0].tStarterSelection][0];
|
||||
sprite->pos1.y = gUnknown_085B1E28[gTasks[sprite->data0].tStarterSelection][1];
|
||||
sprite->pos2.y = Sin(sprite->data1, 8);
|
||||
sprite->data1 = (u8)(sprite->data1) + 4;
|
||||
}
|
||||
|
||||
static void sub_813473C(struct Sprite *sprite)
|
||||
{
|
||||
if (gTasks[sprite->data0].tStarterSelection == sprite->data1)
|
||||
StartSpriteAnimIfDifferent(sprite, 1);
|
||||
else
|
||||
StartSpriteAnimIfDifferent(sprite, 0);
|
||||
}
|
||||
|
||||
static void StarterPokemonSpriteCallback(struct Sprite *sprite)
|
||||
{
|
||||
//Move sprite to upper center of screen
|
||||
if (sprite->pos1.x > STARTER_PKMN_POS_X)
|
||||
sprite->pos1.x -= 4;
|
||||
if (sprite->pos1.x < STARTER_PKMN_POS_X)
|
||||
sprite->pos1.x += 4;
|
||||
if (sprite->pos1.y > STARTER_PKMN_POS_Y)
|
||||
sprite->pos1.y -= 2;
|
||||
if (sprite->pos1.y < STARTER_PKMN_POS_Y)
|
||||
sprite->pos1.y += 2;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ const struct TilesPal* sub_8098758(u8 id)
|
||||
void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset)
|
||||
{
|
||||
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_08DDD748, 0x1C0, destOffset);
|
||||
LoadPalette(sub_8098C64(), palOffset, 0x20);
|
||||
LoadPalette(GetOverworldTextboxPalettePtr(), palOffset, 0x20);
|
||||
}
|
||||
|
||||
void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset)
|
||||
@@ -113,7 +113,7 @@ const u16* stdpal_get(u8 id)
|
||||
return &gUnknown_0851017C[id];
|
||||
}
|
||||
|
||||
const u16* sub_8098C64(void)
|
||||
const u16* GetOverworldTextboxPalettePtr(void)
|
||||
{
|
||||
return gUnknown_08DDD728;
|
||||
}
|
||||
|
||||
168
src/tv.c
168
src/tv.c
@@ -214,23 +214,23 @@ const struct {
|
||||
|
||||
// TODO: Figure out what these are, and define constants in include/flags.h
|
||||
const u16 sGoldSymbolFlags[] = {
|
||||
SYS_TOWER_GOLD,
|
||||
SYS_DOME_GOLD,
|
||||
SYS_PALACE_GOLD,
|
||||
SYS_ARENA_GOLD,
|
||||
SYS_FACTORY_GOLD,
|
||||
SYS_PIKE_GOLD,
|
||||
SYS_PYRAMID_GOLD
|
||||
FLAG_SYS_TOWER_GOLD,
|
||||
FLAG_SYS_DOME_GOLD,
|
||||
FLAG_SYS_PALACE_GOLD,
|
||||
FLAG_SYS_ARENA_GOLD,
|
||||
FLAG_SYS_FACTORY_GOLD,
|
||||
FLAG_SYS_PIKE_GOLD,
|
||||
FLAG_SYS_PYRAMID_GOLD
|
||||
};
|
||||
|
||||
const u16 sSilverSymbolFlags[] = {
|
||||
SYS_TOWER_SILVER,
|
||||
SYS_DOME_SILVER,
|
||||
SYS_PALACE_SILVER,
|
||||
SYS_ARENA_SILVER,
|
||||
SYS_FACTORY_SILVER,
|
||||
SYS_PIKE_SILVER,
|
||||
SYS_PYRAMID_SILVER
|
||||
FLAG_SYS_TOWER_SILVER,
|
||||
FLAG_SYS_DOME_SILVER,
|
||||
FLAG_SYS_PALACE_SILVER,
|
||||
FLAG_SYS_ARENA_SILVER,
|
||||
FLAG_SYS_FACTORY_SILVER,
|
||||
FLAG_SYS_PIKE_SILVER,
|
||||
FLAG_SYS_PYRAMID_SILVER
|
||||
};
|
||||
|
||||
// TODO: Figure out what these are, and define constants in include/vars.h
|
||||
@@ -823,7 +823,7 @@ u8 FindAnyTVShowOnTheAir(void)
|
||||
|
||||
void UpdateTVScreensOnMap(int width, int height)
|
||||
{
|
||||
FlagSet(SYS_TV_WATCH);
|
||||
FlagSet(FLAG_SYS_TV_WATCH);
|
||||
switch (CheckForBigMovieOrEmergencyNewsOnTV())
|
||||
{
|
||||
case 1:
|
||||
@@ -836,9 +836,9 @@ void UpdateTVScreensOnMap(int width, int height)
|
||||
{
|
||||
SetTVMetatilesOnMap(width, height, 0x3);
|
||||
}
|
||||
else if (FlagGet(SYS_TV_START) && (FindAnyTVShowOnTheAir() != 0xff || FindAnyTVNewsOnTheAir() != 0xff || IsTVShowInSearchOfTrainersAiring()))
|
||||
else if (FlagGet(FLAG_SYS_TV_START) && (FindAnyTVShowOnTheAir() != 0xff || FindAnyTVNewsOnTheAir() != 0xff || IsTVShowInSearchOfTrainersAiring()))
|
||||
{
|
||||
FlagClear(SYS_TV_WATCH);
|
||||
FlagClear(FLAG_SYS_TV_WATCH);
|
||||
SetTVMetatilesOnMap(width, height, 0x3);
|
||||
}
|
||||
break;
|
||||
@@ -1263,7 +1263,7 @@ void InterviewAfter_ContestLiveUpdates(void)
|
||||
show2->contestLiveUpdates.kind = TVSHOW_CONTEST_LIVE_UPDATES;
|
||||
show2->contestLiveUpdates.active = TRUE;
|
||||
StringCopy(show2->contestLiveUpdates.playerName, gSaveBlock2Ptr->playerName);
|
||||
show2->contestLiveUpdates.category = gScriptContestCategory;
|
||||
show2->contestLiveUpdates.category = gSpecialVar_ContestCategory;
|
||||
show2->contestLiveUpdates.species = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_SPECIES, NULL);
|
||||
show2->contestLiveUpdates.winningSpecies = show->contestLiveUpdates.winningSpecies;
|
||||
show2->contestLiveUpdates.appealFlags2 = show->contestLiveUpdates.appealFlags2;
|
||||
@@ -1288,7 +1288,7 @@ void PutBattleUpdateOnTheAir(u8 a0, u16 a1, u16 a2, u16 a3)
|
||||
if (sCurTVShowSlot != -1)
|
||||
{
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BATTLE_UPDATE);
|
||||
if (gScriptResult != 1)
|
||||
if (gSpecialVar_Result != 1)
|
||||
{
|
||||
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
|
||||
show->battleUpdate.kind = TVSHOW_BATTLE_UPDATE;
|
||||
@@ -1337,7 +1337,7 @@ bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unus
|
||||
return FALSE;
|
||||
}
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_3_CHEERS_FOR_POKEBLOCKS);
|
||||
if (gScriptResult == 1)
|
||||
if (gSpecialVar_Result == 1)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1527,8 +1527,8 @@ void BravoTrainerPokemonProfile_BeforeInterview2(u8 a0)
|
||||
if (sCurTVShowSlot != -1)
|
||||
{
|
||||
show->bravoTrainer.contestResult = a0;
|
||||
show->bravoTrainer.contestCategory = gScriptContestCategory;
|
||||
show->bravoTrainer.contestRank = gUnknown_02039F2E;
|
||||
show->bravoTrainer.contestCategory = gSpecialVar_ContestCategory;
|
||||
show->bravoTrainer.contestRank = gSpecialVar_ContestRank;
|
||||
show->bravoTrainer.species = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_SPECIES, NULL);
|
||||
GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_NICKNAME, show->bravoTrainer.pokemonNickname);
|
||||
StripExtCtrlCodes(show->bravoTrainer.pokemonNickname);
|
||||
@@ -1606,7 +1606,7 @@ void PutNameRaterShowOnTheAir(void)
|
||||
TVShow *show;
|
||||
|
||||
InterviewBefore_NameRater();
|
||||
if (gScriptResult != 1)
|
||||
if (gSpecialVar_Result != 1)
|
||||
{
|
||||
GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar1);
|
||||
if (StringLength(gSaveBlock2Ptr->playerName) > 1 && StringLength(gStringVar1) > 1)
|
||||
@@ -1653,7 +1653,7 @@ void PutLilycoveContestLadyShowOnTheAir(void)
|
||||
TVShow *show;
|
||||
|
||||
sub_80EFA88();
|
||||
if (gScriptResult != TRUE)
|
||||
if (gSpecialVar_Result != TRUE)
|
||||
{
|
||||
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
|
||||
sub_818E848(&show->contestLiveUpdates2.language);
|
||||
@@ -1731,7 +1731,7 @@ void sub_80ED718(void)
|
||||
u16 outbreakIdx;
|
||||
TVShow *show;
|
||||
|
||||
if (FlagGet(SYS_GAME_CLEAR))
|
||||
if (FlagGet(FLAG_SYS_GAME_CLEAR))
|
||||
{
|
||||
for (i = 0; i < 24; i ++)
|
||||
{
|
||||
@@ -1943,7 +1943,7 @@ void sub_80EDB44(void)
|
||||
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
|
||||
show->rivalTrainer.kind = TVSHOW_TODAYS_RIVAL_TRAINER;
|
||||
show->rivalTrainer.active = FALSE;
|
||||
for (i = BADGE01_GET, nBadges = 0; i < BADGE01_GET + 8; i ++)
|
||||
for (i = FLAG_BADGE01_GET, nBadges = 0; i < FLAG_BADGE01_GET + 8; i ++)
|
||||
{
|
||||
if (FlagGet(i))
|
||||
{
|
||||
@@ -2613,7 +2613,7 @@ bool8 sub_80EE7C0(void)
|
||||
return TRUE;
|
||||
}
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL);
|
||||
if (gScriptResult == TRUE)
|
||||
if (gSpecialVar_Result == TRUE)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2814,7 +2814,7 @@ void sub_80EED88(void)
|
||||
{
|
||||
u8 newsKind;
|
||||
|
||||
if (FlagGet(SYS_GAME_CLEAR))
|
||||
if (FlagGet(FLAG_SYS_GAME_CLEAR))
|
||||
{
|
||||
sCurTVShowSlot = sub_80EEE30(gSaveBlock1Ptr->pokeNews);
|
||||
if (sCurTVShowSlot != -1 && rbernoulli(1, 100) != TRUE)
|
||||
@@ -2905,7 +2905,7 @@ void DoPokeNews(void)
|
||||
i = FindAnyTVNewsOnTheAir();
|
||||
if (i == 0xFF)
|
||||
{
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2928,7 +2928,7 @@ void DoPokeNews(void)
|
||||
gSaveBlock1Ptr->pokeNews[i].state = 0;
|
||||
ShowFieldMessage(sPokeNewsTextGroup_Upcoming[gSaveBlock1Ptr->pokeNews[i].kind]);
|
||||
}
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2959,7 +2959,7 @@ bool8 IsPriceDiscounted(u8 newsKind)
|
||||
switch (newsKind)
|
||||
{
|
||||
case POKENEWS_SLATEPORT:
|
||||
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_SLATEPORT_CITY && gSaveBlock1Ptr->location.mapNum == MAP_ID_SLATEPORT_CITY && gScriptLastTalked == 25)
|
||||
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP_SLATEPORT_CITY && gSaveBlock1Ptr->location.mapNum == MAP_ID_SLATEPORT_CITY && gSpecialVar_LastTalked == 25)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -3005,7 +3005,7 @@ void sub_80EF120(u16 days)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSaveBlock1Ptr->pokeNews[i].state == 0 && FlagGet(SYS_GAME_CLEAR) == TRUE)
|
||||
if (gSaveBlock1Ptr->pokeNews[i].state == 0 && FlagGet(FLAG_SYS_GAME_CLEAR) == TRUE)
|
||||
{
|
||||
gSaveBlock1Ptr->pokeNews[i].state = 1;
|
||||
}
|
||||
@@ -3189,7 +3189,7 @@ void FindActiveBroadcastByShowType_SetScriptResult(u8 kind)
|
||||
{
|
||||
if (gSaveBlock1Ptr->tvShows[i].common.active == TRUE)
|
||||
{
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3205,7 +3205,7 @@ void FindActiveBroadcastByShowType_SetScriptResult(u8 kind)
|
||||
|
||||
void InterviewBefore(void)
|
||||
{
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
switch (gSpecialVar_0x8005)
|
||||
{
|
||||
case TVSHOW_FAN_CLUB_LETTER:
|
||||
@@ -3244,7 +3244,7 @@ void InterviewBefore(void)
|
||||
void InterviewBefore_FanClubLetter(void)
|
||||
{
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_LETTER);
|
||||
if (!gScriptResult)
|
||||
if (!gSpecialVar_Result)
|
||||
{
|
||||
StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL)]);
|
||||
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].fanclubLetter.words, 6);
|
||||
@@ -3254,7 +3254,7 @@ void InterviewBefore_FanClubLetter(void)
|
||||
void InterviewBefore_RecentHappenings(void)
|
||||
{
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_RECENT_HAPPENINGS);
|
||||
if (!gScriptResult)
|
||||
if (!gSpecialVar_Result)
|
||||
{
|
||||
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].recentHappenings.words, 6);
|
||||
}
|
||||
@@ -3263,7 +3263,7 @@ void InterviewBefore_RecentHappenings(void)
|
||||
void InterviewBefore_PkmnFanClubOpinions(void)
|
||||
{
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_PKMN_FAN_CLUB_OPINIONS);
|
||||
if (!gScriptResult)
|
||||
if (!gSpecialVar_Result)
|
||||
{
|
||||
StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL)]);
|
||||
GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_NICKNAME, gStringVar2);
|
||||
@@ -3274,7 +3274,7 @@ void InterviewBefore_PkmnFanClubOpinions(void)
|
||||
|
||||
void InterviewBefore_Dummy(void)
|
||||
{
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
|
||||
void InterviewBefore_NameRater(void)
|
||||
@@ -3285,7 +3285,7 @@ void InterviewBefore_NameRater(void)
|
||||
void InterviewBefore_BravoTrainerPkmnProfile(void)
|
||||
{
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE);
|
||||
if (!gScriptResult)
|
||||
if (!gSpecialVar_Result)
|
||||
{
|
||||
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].bravoTrainer.words, 2);
|
||||
}
|
||||
@@ -3304,7 +3304,7 @@ void InterviewBefore_3CheersForPokeblocks(void)
|
||||
void InterviewBefore_BravoTrainerBTProfile(void)
|
||||
{
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE);
|
||||
if (!gScriptResult)
|
||||
if (!gSpecialVar_Result)
|
||||
{
|
||||
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].bravoTrainerTower.words, 1);
|
||||
}
|
||||
@@ -3313,7 +3313,7 @@ void InterviewBefore_BravoTrainerBTProfile(void)
|
||||
void InterviewBefore_FanClubSpecial(void)
|
||||
{
|
||||
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL);
|
||||
if (!gScriptResult)
|
||||
if (!gSpecialVar_Result)
|
||||
{
|
||||
InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].fanClubSpecial.words, 1);
|
||||
}
|
||||
@@ -3429,11 +3429,11 @@ void sub_80EFA88(void)
|
||||
gSpecialVar_0x8006 = sCurTVShowSlot;
|
||||
if (sCurTVShowSlot == -1)
|
||||
{
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3636,7 +3636,7 @@ void ChangeBoxPokemonNickname(void)
|
||||
{
|
||||
struct BoxPokemon *boxMon;
|
||||
|
||||
boxMon = GetBoxedMonPtr(gSpecialVar_0x8012, gSpecialVar_0x8013);
|
||||
boxMon = GetBoxedMonPtr(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos);
|
||||
GetBoxMonData(boxMon, MON_DATA_NICKNAME, gStringVar3);
|
||||
GetBoxMonData(boxMon, MON_DATA_NICKNAME, gStringVar2);
|
||||
DoNamingScreen(3, gStringVar2, GetBoxMonData(boxMon, MON_DATA_SPECIES, NULL), GetBoxMonGender(boxMon), GetBoxMonData(boxMon, MON_DATA_PERSONALITY, NULL), ChangeBoxPokemonNickname_CB);
|
||||
@@ -3644,7 +3644,7 @@ void ChangeBoxPokemonNickname(void)
|
||||
|
||||
void ChangeBoxPokemonNickname_CB(void)
|
||||
{
|
||||
SetBoxMonNickFromAnyBox(gSpecialVar_0x8012, gSpecialVar_0x8013, gStringVar2);
|
||||
SetBoxMonNickFromAnyBox(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2);
|
||||
c2_exit_to_overworld_1_continue_scripts_restart_music();
|
||||
}
|
||||
|
||||
@@ -3658,11 +3658,11 @@ void TV_CheckMonOTIDEqualsPlayerID(void)
|
||||
{
|
||||
if (GetPlayerIDAsU32() == GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_ID, NULL))
|
||||
{
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3712,11 +3712,11 @@ u8 CheckForBigMovieOrEmergencyNewsOnTV(void)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (FlagGet(SYS_TV_LATI) == TRUE)
|
||||
if (FlagGet(FLAG_SYS_TV_LATI) == TRUE)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (FlagGet(SYS_TV_HOME) == TRUE)
|
||||
if (FlagGet(FLAG_SYS_TV_HOME) == TRUE)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
@@ -4561,7 +4561,7 @@ void sub_80F0B64(void)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
if (FlagGet(SYS_GAME_CLEAR) != TRUE)
|
||||
if (FlagGet(FLAG_SYS_GAME_CLEAR) != TRUE)
|
||||
{
|
||||
for (i = 0; i < 24; i ++)
|
||||
{
|
||||
@@ -4736,7 +4736,7 @@ void sub_80F0F24(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
if (FlagGet(SYS_GAME_CLEAR) != TRUE)
|
||||
if (FlagGet(FLAG_SYS_GAME_CLEAR) != TRUE)
|
||||
{
|
||||
for (i = 0; i < 16; i ++)
|
||||
{
|
||||
@@ -5108,7 +5108,7 @@ void DoTVShowBravoTrainerPokemonProfile(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -5180,7 +5180,7 @@ void DoTVShowBravoTrainerBattleTower(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch(state)
|
||||
{
|
||||
@@ -5277,7 +5277,7 @@ void DoTVShowTodaysSmartShopper(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch(state)
|
||||
{
|
||||
@@ -5400,7 +5400,7 @@ void DoTVShowTheNameRaterShow(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -5498,7 +5498,7 @@ void DoTVShowPokemonTodaySuccessfulCapture(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -5576,7 +5576,7 @@ void DoTVShowPokemonTodayFailedCapture(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -5630,7 +5630,7 @@ void DoTVShowPokemonFanClubLetter(void)
|
||||
u16 rval;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -5683,7 +5683,7 @@ void DoTVShowRecentHappenings(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -5718,7 +5718,7 @@ void DoTVShowPokemonFanClubOpinions(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -5768,7 +5768,7 @@ void DoTVShowPokemonContestLiveUpdates(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6115,7 +6115,7 @@ void DoTVShowPokemonBattleUpdate(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6187,7 +6187,7 @@ void DoTVShow3CheersForPokeblocks(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6288,7 +6288,7 @@ void DoTVShowInSearchOfTrainers(void)
|
||||
{
|
||||
u8 state;
|
||||
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6344,7 +6344,7 @@ void DoTVShowInSearchOfTrainers(void)
|
||||
CopyEasyChatWord(gStringVar1, gSaveBlock1Ptr->gabbyAndTyData.quote[0]);
|
||||
StringCopy(gStringVar2, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon1]);
|
||||
StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon2]);
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
sTVShowState = 0;
|
||||
TakeTVShowInSearchOfTrainersOffTheAir();
|
||||
break;
|
||||
@@ -6358,7 +6358,7 @@ void DoTVShowPokemonAngler(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
if (show->pokemonAngler.nBites < show->pokemonAngler.nFails)
|
||||
{
|
||||
sTVShowState = 0;
|
||||
@@ -6392,7 +6392,7 @@ void DoTVShowTheWorldOfMasters(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6422,7 +6422,7 @@ void DoTVShowTodaysRivalTrainer(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6571,7 +6571,7 @@ void DoTVShowDewfordTrendWatcherNetwork(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6627,7 +6627,7 @@ void DoTVShowHoennTreasureInvestigators(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6671,7 +6671,7 @@ void DoTVShowFindThatGamer(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6745,7 +6745,7 @@ void DoTVShowBreakingNewsTV(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6848,7 +6848,7 @@ void DoTVShowSecretBaseVisit(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -6944,7 +6944,7 @@ void DoTVShowPokemonLotteryWinnerFlashReport(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
TVShowConvertInternationalString(gStringVar1, show->lottoWinner.playerName, show->lottoWinner.language);
|
||||
if (show->lottoWinner.whichPrize == 0)
|
||||
@@ -6974,7 +6974,7 @@ void DoTVShowThePokemonBattleSeminar(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7038,7 +7038,7 @@ void DoTVShowTrainerFanClubSpecial(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7104,7 +7104,7 @@ void DoTVShowTrainerFanClub(void)
|
||||
u32 playerId;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7191,7 +7191,7 @@ void DoTVShowSpotTheCuties(void)
|
||||
u32 playerId;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7296,7 +7296,7 @@ void DoTVShowPokemonNewsBattleFrontier(void)
|
||||
u32 playerId;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7445,7 +7445,7 @@ void DoTVShowWhatsNo1InHoennToday(void)
|
||||
u32 playerId;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7561,7 +7561,7 @@ void DoTVShowSecretBaseSecrets(void)
|
||||
u16 i;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7797,7 +7797,7 @@ void DoTVShowSafariFanClub(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7884,7 +7884,7 @@ void DoTVShowPokemonContestLiveUpdates2(void)
|
||||
u8 state;
|
||||
|
||||
show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004];
|
||||
gScriptResult = FALSE;
|
||||
gSpecialVar_Result = FALSE;
|
||||
state = sTVShowState;
|
||||
switch (state)
|
||||
{
|
||||
@@ -7916,7 +7916,7 @@ void DoTVShowPokemonContestLiveUpdates2(void)
|
||||
|
||||
void TVShowDone(void)
|
||||
{
|
||||
gScriptResult = TRUE;
|
||||
gSpecialVar_Result = TRUE;
|
||||
sTVShowState = 0;
|
||||
gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004].common.active = FALSE;
|
||||
}
|
||||
|
||||
@@ -98,17 +98,17 @@ u16 TryGetWallpaperWithWaldaPhrase(void)
|
||||
u16 backgroundClr, foregroundClr;
|
||||
u8 patternId, iconId;
|
||||
u16 trainerId = ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId);
|
||||
gScriptResult = TryCalculateWallpaper(&backgroundClr, &foregroundClr, &iconId, &patternId, trainerId, GetWaldaPhrasePtr());
|
||||
gSpecialVar_Result = TryCalculateWallpaper(&backgroundClr, &foregroundClr, &iconId, &patternId, trainerId, GetWaldaPhrasePtr());
|
||||
|
||||
if (gScriptResult)
|
||||
if (gSpecialVar_Result)
|
||||
{
|
||||
SetWaldaWallpaperPatternId(patternId);
|
||||
SetWaldaWallpaperIconId(iconId);
|
||||
SetWaldaWallpaperColors(backgroundClr, foregroundClr);
|
||||
}
|
||||
|
||||
SetWaldaWallpaperLockedOrUnlocked(gScriptResult);
|
||||
return (bool8)(gScriptResult);
|
||||
SetWaldaWallpaperLockedOrUnlocked(gSpecialVar_Result);
|
||||
return (bool8)(gSpecialVar_Result);
|
||||
}
|
||||
|
||||
static u8 GetLetterTableId(u8 letter)
|
||||
|
||||
Reference in New Issue
Block a user