more battle labels

This commit is contained in:
DizzyEggg 2018-02-08 12:13:29 +01:00
parent 96290f4ee3
commit 9df5e16343
9 changed files with 268 additions and 267 deletions

View file

@ -100,7 +100,7 @@ _0806BDBC:
lsrs r0, 24
_0806BDC4:
str r0, [sp, 0x34]
ldr r1, =gStringBattler
ldr r1, =gPotentialItemEffectBattler
ldr r0, =gBattlerInMenuId
ldrb r2, [r0]
strb r2, [r1]

View file

@ -673,7 +673,7 @@ extern u8 gBattlerAttacker;
extern u8 gBattlerTarget;
extern u8 gBattlerFainted;
extern u8 gEffectBattler;
extern u8 gStringBattler;
extern u8 gPotentialItemEffectBattler;
extern u8 gAbsentBattlerFlags;
extern u8 gCritMultiplier;
extern u8 gMultiHitCounter;

View file

@ -1102,7 +1102,7 @@ void BtlController_EmitPrintString(u8 bufferId, u16 stringID)
stringInfo->scrActive = gBattleScripting.battler;
stringInfo->unk1605E = gBattleStruct->field_52;
stringInfo->hpScale = gBattleStruct->hpScale;
stringInfo->StringBank = gStringBattler;
stringInfo->StringBank = gPotentialItemEffectBattler;
stringInfo->moveType = gBattleMoves[gCurrentMove].type;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)

View file

@ -22,6 +22,7 @@
#include "blend_palette.h"
#include "contest.h"
#include "constants/songs.h"
#include "constants/rgb.h"
extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2;
@ -57,7 +58,7 @@ extern const u8 gBlankGfxCompressed[];
extern const u16 gBattleInterface_BallStatusBarPal[];
extern const u16 gBattleInterface_BallDisplayPal[];
extern u8 sub_80688F8(u8, u8 bank);
extern u8 sub_80688F8(u8, u8 battlerId);
extern u8 pokemon_order_func(u8); // party menu
extern void sub_81B8C68(void);
@ -410,7 +411,7 @@ void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status)
}
}
#define tBank data[0]
#define tBattlerId data[0]
bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId, u16 argument)
{
@ -440,8 +441,8 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank,
gBattleSpritesDataPtr->animationData->animArg = argument;
LaunchBattleAnimation(gBattleAnims_VariousTable, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10);
gTasks[taskId].tBank = activeBank;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].animFromTableActive = 1;
gTasks[taskId].tBattlerId = activeBank;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].animFromTableActive = 1;
return FALSE;
}
@ -451,12 +452,12 @@ static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].animFromTableActive = 0;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].animFromTableActive = 0;
DestroyTask(taskId);
}
}
#undef tBank
#undef tBattlerId
static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId)
{
@ -474,7 +475,7 @@ static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId)
}
}
#define tBank data[0]
#define tBattlerId data[0]
void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId)
{
@ -484,8 +485,8 @@ void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tab
gBattleAnimTarget = defBank;
LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10);
gTasks[taskId].tBank = activeBank;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].specialAnimActive = 1;
gTasks[taskId].tBattlerId = activeBank;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].specialAnimActive = 1;
}
static void Task_ClearBitWhenSpecialAnimDone(u8 taskId)
@ -493,12 +494,12 @@ static void Task_ClearBitWhenSpecialAnimDone(u8 taskId)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].specialAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].specialAnimActive = 0;
DestroyTask(taskId);
}
}
#undef tBank
#undef tBattlerId
// great function to include newly added moves that don't have animation yet
bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn)
@ -506,13 +507,13 @@ bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn)
return FALSE;
}
bool8 mplay_80342A4(u8 bank)
bool8 mplay_80342A4(u8 battlerId)
{
u8 zero = 0;
if (IsSEPlaying())
{
gBattleSpritesDataPtr->healthBoxesData[bank].field_8++;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_8++;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_8 < 30)
return TRUE;
@ -521,14 +522,14 @@ bool8 mplay_80342A4(u8 bank)
}
if (zero == 0)
{
gBattleSpritesDataPtr->healthBoxesData[bank].field_8 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_8 = 0;
return FALSE;
}
return TRUE;
}
void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank)
void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
{
u32 monsPersonality, currentPersonality, otId;
u16 species;
@ -538,50 +539,50 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank)
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
{
species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality;
}
else
{
species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
currentPersonality = gTransformedPersonalities[bank];
species = gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies;
currentPersonality = gTransformedPersonalities[battlerId];
}
otId = GetMonData(mon, MON_DATA_OT_ID);
position = GetBattlerPosition(bank);
position = GetBattlerPosition(battlerId);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
gMonSpritesGfxPtr->sprites[position],
species, currentPersonality);
paletteOffset = 0x100 + bank * 16;
paletteOffset = 0x100 + battlerId * 16;
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon);
else
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
LZDecompressWram(lzPaletteData, gDecompressionBuffer);
LoadPalette(gDecompressionBuffer, paletteOffset, 0x20);
LoadPalette(gDecompressionBuffer, 0x80 + bank * 16, 0x20);
LoadPalette(gDecompressionBuffer, 0x80 + battlerId * 16, 0x20);
if (species == SPECIES_CASTFORM)
{
paletteOffset = 0x100 + bank * 16;
paletteOffset = 0x100 + battlerId * 16;
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]);
LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[bank]], paletteOffset, 0x20);
LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20);
}
// transform's pink color
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, 0x7FFF);
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
}
}
void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
{
u32 monsPersonality, currentPersonality, otId;
u16 species;
@ -591,21 +592,21 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
{
species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality;
}
else
{
species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
currentPersonality = gTransformedPersonalities[bank];
species = gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies;
currentPersonality = gTransformedPersonalities[battlerId];
}
otId = GetMonData(mon, MON_DATA_OT_ID);
position = GetBattlerPosition(bank);
position = GetBattlerPosition(battlerId);
if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
if (sub_80688F8(1, battlerId) == 1 || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
{
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species],
gMonSpritesGfxPtr->sprites[position],
@ -618,28 +619,28 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
species, currentPersonality);
}
paletteOffset = 0x100 + bank * 16;
paletteOffset = 0x100 + battlerId * 16;
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon);
else
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
LZDecompressWram(lzPaletteData, gDecompressionBuffer);
LoadPalette(gDecompressionBuffer, paletteOffset, 0x20);
LoadPalette(gDecompressionBuffer, 0x80 + bank * 16, 0x20);
LoadPalette(gDecompressionBuffer, 0x80 + battlerId * 16, 0x20);
if (species == SPECIES_CASTFORM)
{
paletteOffset = 0x100 + bank * 16;
paletteOffset = 0x100 + battlerId * 16;
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]);
LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[bank]], paletteOffset, 0x20);
LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20);
}
// transform's pink color
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, 0x7FFF);
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
}
}
@ -652,23 +653,23 @@ void nullsub_24(u16 species)
{
}
void DecompressTrainerFrontPic(u16 frontPicId, u8 bank)
void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId)
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
DecompressPicFromTable_2(&gTrainerFrontPicTable[frontPicId],
gMonSpritesGfxPtr->sprites[position],
SPECIES_NONE);
LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[frontPicId]);
}
void DecompressTrainerBackPic(u16 backPicId, u8 bank)
void DecompressTrainerBackPic(u16 backPicId, u8 battlerId)
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
DecompressPicFromTable_2(&gTrainerBackPicTable[backPicId],
gMonSpritesGfxPtr->sprites[position],
SPECIES_NONE);
LoadCompressedPalette(gTrainerBackPicPaletteTable[backPicId].data,
0x100 + 16 * bank, 0x20);
0x100 + 16 * battlerId, 0x20);
}
void nullsub_25(u8 arg0)
@ -765,7 +766,7 @@ void LoadBattleBarGfx(u8 arg0)
LZDecompressWram(gUnknown_08C093F0, gMonSpritesGfxPtr->barFontGfx);
}
bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId)
{
bool8 retVal = FALSE;
@ -776,13 +777,13 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
(*state1)++;
break;
case 1:
if (!BattleLoadAllHealthBoxesGfx(*bank))
if (!BattleLoadAllHealthBoxesGfx(*battlerId))
{
(*bank)++;
(*battlerId)++;
}
else
{
*bank = 0;
*battlerId = 0;
(*state1)++;
}
break;
@ -790,47 +791,47 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
(*state1)++;
break;
case 3:
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0)
gHealthboxSpriteIds[*bank] = CreateSafariPlayerHealthboxSprites();
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *battlerId == 0)
gHealthboxSpriteIds[*battlerId] = CreateSafariPlayerHealthboxSprites();
else
gHealthboxSpriteIds[*bank] = CreateBattlerHealthboxSprites(*bank);
gHealthboxSpriteIds[*battlerId] = CreateBattlerHealthboxSprites(*battlerId);
(*bank)++;
if (*bank == gBattlersCount)
(*battlerId)++;
if (*battlerId == gBattlersCount)
{
*bank = 0;
*battlerId = 0;
(*state1)++;
}
break;
case 4:
InitBattlerHealthboxCoords(*bank);
if (gBattlerPositions[*bank] <= 1)
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*bank], FALSE);
InitBattlerHealthboxCoords(*battlerId);
if (gBattlerPositions[*battlerId] <= 1)
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], FALSE);
else
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*bank], TRUE);
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], TRUE);
(*bank)++;
if (*bank == gBattlersCount)
(*battlerId)++;
if (*battlerId == gBattlersCount)
{
*bank = 0;
*battlerId = 0;
(*state1)++;
}
break;
case 5:
if (GetBattlerSide(*bank) == B_SIDE_PLAYER)
if (GetBattlerSide(*battlerId) == B_SIDE_PLAYER)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
UpdateHealthboxAttribute(gHealthboxSpriteIds[*bank], &gPlayerParty[gBattlerPartyIndexes[*bank]], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[*battlerId], &gPlayerParty[gBattlerPartyIndexes[*battlerId]], HEALTHBOX_ALL);
}
else
{
UpdateHealthboxAttribute(gHealthboxSpriteIds[*bank], &gEnemyParty[gBattlerPartyIndexes[*bank]], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[*battlerId], &gEnemyParty[gBattlerPartyIndexes[*battlerId]], HEALTHBOX_ALL);
}
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[*bank]);
(*bank)++;
if (*bank == gBattlersCount)
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[*battlerId]);
(*battlerId)++;
if (*battlerId == gBattlersCount)
{
*bank = 0;
*battlerId = 0;
(*state1)++;
}
break;
@ -864,9 +865,9 @@ void CopyAllBattleSpritesInvisibilities(void)
gBattleSpritesDataPtr->battlerData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible;
}
void CopyBattleSpriteInvisibility(u8 bank)
void CopyBattleSpriteInvisibility(u8 battlerId)
{
gBattleSpritesDataPtr->battlerData[bank].invisible = gSprites[gBattlerSpriteIds[bank]].invisible;
gBattleSpritesDataPtr->battlerData[battlerId].invisible = gSprites[gBattlerSpriteIds[battlerId]].invisible;
}
void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
@ -885,7 +886,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg;
if (gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, 0x7FFF);
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
}
gSprites[gBattlerSpriteIds[bankAtk]].pos1.y = GetBattlerSpriteDefault_Y(bankAtk);
@ -954,7 +955,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[bankDef] * 16, paletteOffset, 32);
}
BlendPalette(paletteOffset, 16, 6, 0x7FFF);
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
if (!IsContest())
@ -968,7 +969,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
}
}
void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite)
void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite)
{
u8 position;
s32 i;
@ -980,17 +981,17 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite)
if (IsContest())
position = 0;
else
position = GetBattlerPosition(bank);
position = GetBattlerPosition(battlerId);
if (IsContest())
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]);
else if (GetBattlerSide(bank) != B_SIDE_PLAYER)
else if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites[position]);
else
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]);
i = 1;
var = bank * 16;
var = battlerId * 16;
substitutePal = gSubstituteDollPal;
for (; i < 4; i++)
{
@ -1007,59 +1008,59 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite)
{
if (!IsContest())
{
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
else
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank);
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId);
}
}
}
void LoadBattleMonGfxAndAnimate(u8 bank, bool8 loadMonSprite, u8 spriteId)
void LoadBattleMonGfxAndAnimate(u8 battlerId, bool8 loadMonSprite, u8 spriteId)
{
BattleLoadSubstituteOrMonSpriteGfx(bank, loadMonSprite);
StartSpriteAnim(&gSprites[spriteId], gBattleMonForms[bank]);
BattleLoadSubstituteOrMonSpriteGfx(battlerId, loadMonSprite);
StartSpriteAnim(&gSprites[spriteId], gBattleMonForms[battlerId]);
if (!loadMonSprite)
gSprites[spriteId].pos1.y = GetSubstituteSpriteDefault_Y(bank);
gSprites[spriteId].pos1.y = GetSubstituteSpriteDefault_Y(battlerId);
else
gSprites[spriteId].pos1.y = GetBattlerSpriteDefault_Y(bank);
gSprites[spriteId].pos1.y = GetBattlerSpriteDefault_Y(battlerId);
}
void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move)
void TrySetBehindSubstituteSpriteBit(u8 battlerId, u16 move)
{
if (move == MOVE_SUBSTITUTE)
gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 1;
gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute = 1;
}
void ClearBehindSubstituteBit(u8 bank)
void ClearBehindSubstituteBit(u8 battlerId)
{
gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 0;
gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute = 0;
}
void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank)
void HandleLowHpMusicChange(struct Pokemon *mon, u8 battlerId)
{
u16 hp = GetMonData(mon, MON_DATA_HP);
u16 maxHP = GetMonData(mon, MON_DATA_MAX_HP);
if (GetHPBarLevel(hp, maxHP) == HP_BAR_RED)
{
if (!gBattleSpritesDataPtr->battlerData[bank].lowHpSong)
if (!gBattleSpritesDataPtr->battlerData[battlerId].lowHpSong)
{
if (!gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong)
if (!gBattleSpritesDataPtr->battlerData[battlerId ^ BIT_FLANK].lowHpSong)
PlaySE(SE_HINSI);
gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 1;
gBattleSpritesDataPtr->battlerData[battlerId].lowHpSong = 1;
}
}
else
{
gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 0;
gBattleSpritesDataPtr->battlerData[battlerId].lowHpSong = 0;
if (!IsDoubleBattle())
{
m4aSongNumStop(SE_HINSI);
return;
}
if (IsDoubleBattle() && !gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong)
if (IsDoubleBattle() && !gBattleSpritesDataPtr->battlerData[battlerId ^ BIT_FLANK].lowHpSong)
{
m4aSongNumStop(SE_HINSI);
return;
@ -1124,44 +1125,44 @@ void sub_805EB9C(u8 affineMode)
}
}
#define tBank data[0]
#define tBattlerId data[0]
void LoadAndCreateEnemyShadowSprites(void)
{
u8 bank;
u8 battlerId;
LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow);
bank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(bank, 0), GetBattlerSpriteCoord(bank, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank;
battlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(battlerId, 0), GetBattlerSpriteCoord(battlerId, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].data[0] = battlerId;
if (IsDoubleBattle())
{
bank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(bank, 0), GetBattlerSpriteCoord(bank, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank;
battlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(battlerId, 0), GetBattlerSpriteCoord(battlerId, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].data[0] = battlerId;
}
}
void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
{
bool8 invisible = FALSE;
u8 bank = shadowSprite->tBank;
struct Sprite *bankSprite = &gSprites[gBattlerSpriteIds[bank]];
u8 battlerId = shadowSprite->tBattlerId;
struct Sprite *bankSprite = &gSprites[gBattlerSpriteIds[battlerId]];
if (!bankSprite->inUse || !IsBattlerSpritePresent(bank))
if (!bankSprite->inUse || !IsBattlerSpritePresent(battlerId))
{
shadowSprite->callback = SpriteCB_SetInvisible;
return;
}
if (gAnimScriptActive || bankSprite->invisible)
invisible = TRUE;
else if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[bank].transformSpecies] == 0)
else if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies] == 0)
invisible = TRUE;
if (gBattleSpritesDataPtr->battlerData[bank].behindSubstitute)
if (gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute)
invisible = TRUE;
shadowSprite->pos1.x = bankSprite->pos1.x;
@ -1169,31 +1170,31 @@ void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
shadowSprite->invisible = invisible;
}
#undef tBank
#undef tBattlerId
void SpriteCB_SetInvisible(struct Sprite *sprite)
{
sprite->invisible = 1;
}
void SetBattlerShadowSpriteCallback(u8 bank, u16 species)
void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species)
{
// The player's shadow is never seen
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return;
if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
species = gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies;
if (gEnemyMonElevation[species] != 0)
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_EnemyShadow;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].callback = SpriteCB_EnemyShadow;
else
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].callback = SpriteCB_SetInvisible;
}
void HideBattlerShadowSprite(u8 bank)
void HideBattlerShadowSprite(u8 battlerId)
{
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].callback = SpriteCB_SetInvisible;
}
void sub_805EF14(void)
@ -1219,12 +1220,12 @@ void sub_805EF14(void)
}
}
void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute)
void ClearTemporarySpeciesSpriteData(u8 battlerId, bool8 dontClearSubstitute)
{
gBattleSpritesDataPtr->battlerData[bank].transformSpecies = SPECIES_NONE;
gBattleMonForms[bank] = 0;
gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = SPECIES_NONE;
gBattleMonForms[battlerId] = 0;
if (!dontClearSubstitute)
ClearBehindSubstituteBit(bank);
ClearBehindSubstituteBit(battlerId);
}
void AllocateMonSpritesGfx(void)

View file

@ -232,7 +232,7 @@ EWRAM_DATA u8 gBattlerAttacker = 0;
EWRAM_DATA u8 gBattlerTarget = 0;
EWRAM_DATA u8 gBattlerFainted = 0;
EWRAM_DATA u8 gEffectBattler = 0;
EWRAM_DATA u8 gStringBattler = 0;
EWRAM_DATA u8 gPotentialItemEffectBattler = 0;
EWRAM_DATA u8 gAbsentBattlerFlags = 0;
EWRAM_DATA u8 gCritMultiplier = 0;
EWRAM_DATA u8 gMultiHitCounter = 0;
@ -3815,7 +3815,7 @@ u8 IsRunningFromBattleImpossible(void)
else
holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item);
gStringBattler = gActiveBattler;
gPotentialItemEffectBattler = gActiveBattler;
if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN)
return 0;
@ -4417,8 +4417,8 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
}
speedBattler1 = (gBattleMons[battler1].speed * speedMultiplierBattler1)
* (gStatStageRatios[gBattleMons[battler1].statStages[STAT_STAGE_SPEED]][0])
/ (gStatStageRatios[gBattleMons[battler1].statStages[STAT_STAGE_SPEED]][1]);
* (gStatStageRatios[gBattleMons[battler1].statStages[STAT_SPEED]][0])
/ (gStatStageRatios[gBattleMons[battler1].statStages[STAT_SPEED]][1]);
if (gBattleMons[battler1].item == ITEM_ENIGMA_BERRY)
{
@ -4451,8 +4451,8 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
// check second battlerId's speed
speedBattler2 = (gBattleMons[battler2].speed * speedMultiplierBattler2)
* (gStatStageRatios[gBattleMons[battler2].statStages[STAT_STAGE_SPEED]][0])
/ (gStatStageRatios[gBattleMons[battler2].statStages[STAT_STAGE_SPEED]][1]);
* (gStatStageRatios[gBattleMons[battler2].statStages[STAT_SPEED]][0])
/ (gStatStageRatios[gBattleMons[battler2].statStages[STAT_SPEED]][1]);
if (gBattleMons[battler2].item == ITEM_ENIGMA_BERRY)
{
@ -5380,7 +5380,7 @@ bool8 TryRunFromBattle(u8 battler)
else
holdEffect = ItemId_GetHoldEffect(gBattleMons[battler].item);
gStringBattler = battler;
gPotentialItemEffectBattler = battler;
if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN)
{

View file

@ -1421,7 +1421,7 @@ void BufferStringBattle(u16 stringID)
gBattleScripting.battler = gStringInfo->scrActive;
*(&gBattleStruct->field_52) = gStringInfo->unk1605E;
*(&gBattleStruct->hpScale) = gStringInfo->hpScale;
gStringBattler = gStringInfo->StringBank;
gPotentialItemEffectBattler = gStringInfo->StringBank;
*(&gBattleStruct->stringMoveType) = gStringInfo->moveType;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
@ -1915,10 +1915,10 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
if ((gBattleScripting.multiplayerId != 0 && (gStringBattler & BIT_SIDE))
|| (gBattleScripting.multiplayerId == 0 && !(gStringBattler & BIT_SIDE)))
if ((gBattleScripting.multiplayerId != 0 && (gPotentialItemEffectBattler & BIT_SIDE))
|| (gBattleScripting.multiplayerId == 0 && !(gPotentialItemEffectBattler & BIT_SIDE)))
{
StringCopy(text, gEnigmaBerries[gStringBattler].name);
StringCopy(text, gEnigmaBerries[gPotentialItemEffectBattler].name);
StringAppend(text, gText_BerrySuffix);
toCpy = text;
}
@ -1929,9 +1929,9 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
}
else
{
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler)
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gPotentialItemEffectBattler)
{
StringCopy(text, gEnigmaBerries[gStringBattler].name);
StringCopy(text, gEnigmaBerries[gPotentialItemEffectBattler].name);
StringAppend(text, gText_BerrySuffix);
toCpy = text;
}
@ -2298,9 +2298,9 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
{
if (hword == ITEM_ENIGMA_BERRY)
{
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler)
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gPotentialItemEffectBattler)
{
StringCopy(dst, gEnigmaBerries[gStringBattler].name);
StringCopy(dst, gEnigmaBerries[gPotentialItemEffectBattler].name);
StringAppend(dst, gText_BerrySuffix);
}
else

View file

@ -62,7 +62,7 @@ extern const struct TrainerMoney gTrainerMoneyTable[];
extern const u8* const gBattleScriptsForMoveEffects[];
// functions
extern void sub_81A5718(u8 bank); // battle frontier 2
extern void sub_81A5718(u8 battlerId); // battle frontier 2
extern void sub_81A56B4(void); // battle frontier 2
extern void sub_81BFA38(struct Pokemon* party, u8 monPartyId, u8 monCount, void (*callback)(void), u16 move); // pokemon summary screen
extern u8 sub_81C1B94(void); // pokemon summary screen
@ -73,7 +73,7 @@ extern u8* GetMonNickname(struct Pokemon* mon, u8* dst); // party_menu
extern u8 sub_81A5258(u8* arg0); // battle frontier 2
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 void sub_81B8E80(u8 battlerId, u8, u8); // party menu
extern bool8 sub_81B1250(void); // ?
extern bool8 InBattlePike(void);
extern bool8 InBattlePyramid(void);
@ -104,7 +104,7 @@ extern const u8 gText_BattleYesNoChoice[];
// this file's functions
static bool8 IsTwoTurnsMove(u16 move);
static void TrySetDestinyBondToHappen(void);
static u8 AttacksThisTurn(u8 bank, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2.
static u8 AttacksThisTurn(u8 battlerId, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2.
static void CheckWonderGuardAndLevitate(void);
static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr);
static bool32 IsMonGettingExpSentOut(void);
@ -1174,13 +1174,13 @@ static void atk01_accuracycheck(void)
if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT)
{
u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ACC];
u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_ACC];
buff = acc;
}
else
{
u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ACC];
buff = acc + 6 - gBattleMons[gBattlerTarget].statStages[STAT_STAGE_EVASION];
u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_ACC];
buff = acc + 6 - gBattleMons[gBattlerTarget].statStages[STAT_EVASION];
}
if (buff < 0)
@ -1214,7 +1214,7 @@ static void atk01_accuracycheck(void)
param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item);
}
gStringBattler = gBattlerTarget;
gPotentialItemEffectBattler = gBattlerTarget;
if (holdEffect == HOLD_EFFECT_EVASION_UP)
calc = (calc * (100 - param)) / 100;
@ -1307,7 +1307,7 @@ static void atk04_critcalc(void)
else
holdEffect = ItemId_GetHoldEffect(item);
gStringBattler = gBattlerAttacker;
gPotentialItemEffectBattler = gBattlerAttacker;
critChance = 2 * ((gBattleMons[gBattlerAttacker].status2 & STATUS2_FOCUS_ENERGY) != 0)
+ (gBattleMoves[gCurrentMove].effect == EFFECT_HIGH_CRITICAL)
@ -1716,7 +1716,7 @@ static void atk07_adjustnormaldamage(void)
param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item);
}
gStringBattler = gBattlerTarget;
gPotentialItemEffectBattler = gBattlerTarget;
if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param)
{
@ -1765,7 +1765,7 @@ static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't
param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item);
}
gStringBattler = gBattlerTarget;
gPotentialItemEffectBattler = gBattlerTarget;
if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param)
{
@ -1972,7 +1972,7 @@ static void atk0C_datahpupdate(void)
if (!gSpecialStatuses[gActiveBattler].dmg && !(gHitMarker & HITMARKER_x100000))
gSpecialStatuses[gActiveBattler].dmg = gHpDealt;
if (moveType <= 8 && !(gHitMarker & HITMARKER_x100000) && gCurrentMove != MOVE_PAIN_SPLIT)
if (IS_MOVE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_x100000) && gCurrentMove != MOVE_PAIN_SPLIT)
{
gProtectStructs[gActiveBattler].physicalDmg = gHpDealt;
gSpecialStatuses[gActiveBattler].physicalDmg = gHpDealt;
@ -1987,7 +1987,7 @@ static void atk0C_datahpupdate(void)
gSpecialStatuses[gActiveBattler].physicalBattlerId = gBattlerTarget;
}
}
else if (moveType > 8 && !(gHitMarker & HITMARKER_x100000))
else if (!IS_MOVE_PHYSICAL(moveType) && !(gHitMarker & HITMARKER_x100000))
{
gProtectStructs[gActiveBattler].specialDmg = gHpDealt;
gSpecialStatuses[gActiveBattler].specialDmg = gHpDealt;
@ -2114,7 +2114,7 @@ static void atk0F_resultmessage(void)
break;
case MOVE_RESULT_FOE_HUNG_ON:
gLastUsedItem = gBattleMons[gBattlerTarget].item;
gStringBattler = gBattlerTarget;
gPotentialItemEffectBattler = gBattlerTarget;
gMoveResultFlags &= ~(MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_HangedOnMsg;
@ -2143,7 +2143,7 @@ static void atk0F_resultmessage(void)
else if (gMoveResultFlags & MOVE_RESULT_FOE_HUNG_ON)
{
gLastUsedItem = gBattleMons[gBattlerTarget].item;
gStringBattler = gBattlerTarget;
gPotentialItemEffectBattler = gBattlerTarget;
gMoveResultFlags &= ~(MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_HangedOnMsg;
@ -2239,12 +2239,12 @@ static void atk14_printselectionstringfromtable(void)
}
}
u8 GetBattlerTurnOrderNum(u8 bank)
u8 GetBattlerTurnOrderNum(u8 battlerId)
{
s32 i;
for (i = 0; i < gBattlersCount; i++)
{
if (gBattleTurnOrder[i] == bank)
if (gBattleTurnOrder[i] == battlerId)
break;
}
return i;
@ -2271,7 +2271,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_AFFECTS_USER)
{
gEffectBattler = gBattlerAttacker; // bank that effects get applied on
gEffectBattler = gBattlerAttacker; // battlerId that effects get applied on
gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_AFFECTS_USER);
affectsUser = MOVE_EFFECT_AFFECTS_USER;
gBattleScripting.battler = gBattlerTarget; // theoretically the attacker
@ -3028,18 +3028,18 @@ static void atk19_tryfaintmon(void)
}
else
{
u8 bank;
u8 battlerId;
if (gBattlescriptCurrInstr[1] == BS_ATTACKER)
{
gActiveBattler = gBattlerAttacker;
bank = gBattlerTarget;
battlerId = gBattlerTarget;
BS_ptr = BattleScript_FaintAttacker;
}
else
{
gActiveBattler = gBattlerTarget;
bank = gBattlerAttacker;
battlerId = gBattlerAttacker;
BS_ptr = BattleScript_FaintTarget;
}
if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])
@ -3065,7 +3065,7 @@ static void atk19_tryfaintmon(void)
{
gHitMarker &= ~(HITMARKER_DESTINYBOND);
BattleScriptPush(gBattlescriptCurrInstr);
gBattleMoveDamage = gBattleMons[bank].hp;
gBattleMoveDamage = gBattleMons[battlerId].hp;
gBattlescriptCurrInstr = BattleScript_DestinyBondTakesLife;
}
if ((gStatuses3[gBattlerTarget] & STATUS3_GRUDGE)
@ -3124,11 +3124,11 @@ static void atk1B_cleareffectsonfaint(void)
static void atk1C_jumpifstatus(void)
{
u8 bank = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u32 flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2);
const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6);
if (gBattleMons[bank].status1 & flags && gBattleMons[bank].hp)
if (gBattleMons[battlerId].status1 & flags && gBattleMons[battlerId].hp)
gBattlescriptCurrInstr = jumpPtr;
else
gBattlescriptCurrInstr += 10;
@ -3136,11 +3136,11 @@ static void atk1C_jumpifstatus(void)
static void atk1D_jumpifstatus2(void)
{
u8 bank = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u32 flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2);
const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6);
if (gBattleMons[bank].status2 & flags && gBattleMons[bank].hp)
if (gBattleMons[battlerId].status2 & flags && gBattleMons[battlerId].hp)
gBattlescriptCurrInstr = jumpPtr;
else
gBattlescriptCurrInstr += 10;
@ -3148,45 +3148,45 @@ static void atk1D_jumpifstatus2(void)
static void atk1E_jumpifability(void)
{
u8 bank;
u8 battlerId;
u8 ability = gBattlescriptCurrInstr[2];
const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3);
if (gBattlescriptCurrInstr[1] == BS_ATTACKER_SIDE)
{
bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBattlerAttacker, ability, 0, 0);
if (bank)
battlerId = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBattlerAttacker, ability, 0, 0);
if (battlerId)
{
gLastUsedAbility = ability;
gBattlescriptCurrInstr = jumpPtr;
RecordAbilityBattle(bank - 1, gLastUsedAbility);
gBattleScripting.battlerWithAbility = bank - 1;
RecordAbilityBattle(battlerId - 1, gLastUsedAbility);
gBattleScripting.battlerWithAbility = battlerId - 1;
}
else
gBattlescriptCurrInstr += 7;
}
else if (gBattlescriptCurrInstr[1] == BS_NOT_ATTACKER_SIDE)
{
bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBattlerAttacker, ability, 0, 0);
if (bank)
battlerId = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBattlerAttacker, ability, 0, 0);
if (battlerId)
{
gLastUsedAbility = ability;
gBattlescriptCurrInstr = jumpPtr;
RecordAbilityBattle(bank - 1, gLastUsedAbility);
gBattleScripting.battlerWithAbility = bank - 1;
RecordAbilityBattle(battlerId - 1, gLastUsedAbility);
gBattleScripting.battlerWithAbility = battlerId - 1;
}
else
gBattlescriptCurrInstr += 7;
}
else
{
bank = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
if (gBattleMons[bank].ability == ability)
battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
if (gBattleMons[battlerId].ability == ability)
{
gLastUsedAbility = ability;
gBattlescriptCurrInstr = jumpPtr;
RecordAbilityBattle(bank, gLastUsedAbility);
gBattleScripting.battlerWithAbility = bank;
RecordAbilityBattle(battlerId, gLastUsedAbility);
gBattleScripting.battlerWithAbility = battlerId;
}
else
gBattlescriptCurrInstr += 7;
@ -3216,8 +3216,8 @@ static void atk1F_jumpifsideaffecting(void)
static void atk20_jumpifstat(void)
{
u8 ret = 0;
u8 bank = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u8 value = gBattleMons[bank].statStages[gBattlescriptCurrInstr[3]];
u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u8 value = gBattleMons[battlerId].statStages[gBattlescriptCurrInstr[3]];
switch (gBattlescriptCurrInstr[2])
{
@ -3280,11 +3280,11 @@ static void atk21_jumpifstatus3condition(void)
static void atk22_jumpiftype(void)
{
u8 bank = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u8 type = gBattlescriptCurrInstr[2];
const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3);
if (gBattleMons[bank].type1 == type || gBattleMons[bank].type2 == type)
if (gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type)
gBattlescriptCurrInstr = jumpPtr;
else
gBattlescriptCurrInstr += 7;
@ -3435,7 +3435,7 @@ static void atk23_getexp(void)
i = 0x149;
}
// get exp getter bank
// get exp getter battlerId
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
if (!(gBattlerPartyIndexes[2] != gBattleStruct->expGetterMonId) && !(gAbsentBattlerFlags & gBitTable[2]))
@ -4312,9 +4312,9 @@ static void atk41_call(void)
static void atk42_jumpiftype2(void)
{
u8 bank = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
if (gBattlescriptCurrInstr[2] == gBattleMons[bank].type1 || gBattlescriptCurrInstr[2] == gBattleMons[bank].type2)
if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].type1 || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].type2)
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 3);
else
gBattlescriptCurrInstr += 7;
@ -4469,8 +4469,8 @@ static void atk48_playstatchangeanimation(void)
else if (!gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer
&& gBattleMons[gActiveBattler].ability != ABILITY_CLEAR_BODY
&& gBattleMons[gActiveBattler].ability != ABILITY_WHITE_SMOKE
&& !(gBattleMons[gActiveBattler].ability == ABILITY_KEEN_EYE && currStat == STAT_STAGE_ACC)
&& !(gBattleMons[gActiveBattler].ability == ABILITY_HYPER_CUTTER && currStat == STAT_STAGE_ATK))
&& !(gBattleMons[gActiveBattler].ability == ABILITY_KEEN_EYE && currStat == STAT_ACC)
&& !(gBattleMons[gActiveBattler].ability == ABILITY_HYPER_CUTTER && currStat == STAT_ATK))
{
if (gBattleMons[gActiveBattler].statStages[currStat] > 0)
{
@ -4824,9 +4824,9 @@ static void atk49_moveend(void)
&& gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget
&& GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED
&& gBattleMoves[gCurrentMove].power && gBattleMons[gBattlerTarget].statStages[STAT_STAGE_ATK] <= 0xB)
&& gBattleMoves[gCurrentMove].power && gBattleMons[gBattlerTarget].statStages[STAT_ATK] <= 0xB)
{
gBattleMons[gBattlerTarget].statStages[STAT_STAGE_ATK]++;
gBattleMons[gBattlerTarget].statStages[STAT_ATK]++;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_RageIsBuilding;
effect = TRUE;
@ -4861,7 +4861,7 @@ static void atk49_moveend(void)
break;
case 4: // status immunities
if (AbilityBattleEffects(ABILITYEFFECT_IMMUNITY, 0, 0, 0, 0))
effect = TRUE; // it loops through all banks, so we increment after its done with all banks
effect = TRUE; // it loops through all battlers, so we increment after its done with all battlers
else
gBattleScripting.atk49_state++;
break;
@ -4905,7 +4905,7 @@ static void atk49_moveend(void)
}
gBattleScripting.atk49_state++;
break;
case 11: // item effects for all banks
case 11: // item effects for all battlers
if (ItemBattleEffects(3, 0, FALSE))
effect = TRUE;
else
@ -5039,10 +5039,10 @@ static void atk49_moveend(void)
&& !gProtectStructs[gBattlerAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH
&& !(gHitMarker & HITMARKER_NO_ATTACKSTRING))
{
u8 bank = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget)));
if (gBattleMons[bank].hp != 0)
u8 battlerId = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget)));
if (gBattleMons[battlerId].hp != 0)
{
gBattlerTarget = bank;
gBattlerTarget = battlerId;
gHitMarker |= HITMARKER_NO_ATTACKSTRING;
gBattleScripting.atk49_state = 0;
MoveValuesCleanUp();
@ -5440,10 +5440,10 @@ static void atk50_openpartyscreen(void)
{
u32 flags;
u8 hitmarkerFaintBits;
u8 bank;
u8 battlerId;
const u8 *jumpPtr;
bank = 0;
battlerId = 0;
flags = 0;
jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
@ -5675,21 +5675,21 @@ static void atk50_openpartyscreen(void)
else
hitmarkerFaintBits = 1;
bank = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(0x80));
if (gSpecialStatuses[bank].flag40)
battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(0x80));
if (gSpecialStatuses[battlerId].flag40)
{
gBattlescriptCurrInstr += 6;
}
else if (sub_80423F4(bank, 6, 6))
else if (sub_80423F4(battlerId, 6, 6))
{
gActiveBattler = bank;
gActiveBattler = battlerId;
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
gBattlescriptCurrInstr = jumpPtr;
}
else
{
gActiveBattler = bank;
gActiveBattler = battlerId;
*(gBattleStruct->field_58 + gActiveBattler) = gBattlerPartyIndexes[gActiveBattler];
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6;
gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]);
@ -5706,7 +5706,7 @@ static void atk50_openpartyscreen(void)
{
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
{
if (gActiveBattler != bank)
if (gActiveBattler != battlerId)
{
BtlController_EmitLinkStandbyMsg(0, 2, 0);
MarkBattlerForControllerExec(gActiveBattler);
@ -5715,7 +5715,7 @@ static void atk50_openpartyscreen(void)
}
else
{
gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(bank) ^ BIT_SIDE);
gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(battlerId) ^ BIT_SIDE);
if (gAbsentBattlerFlags & gBitTable[gActiveBattler])
gActiveBattler ^= BIT_FLANK;
@ -6451,7 +6451,7 @@ static void atk69_adjustsetdamage(void) // The same as 0x7, except there's no ra
param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item);
}
gStringBattler = gBattlerTarget;
gPotentialItemEffectBattler = gBattlerTarget;
if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param)
{
@ -6805,7 +6805,7 @@ static void atk70_recordlastability(void)
{
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for bank argument.
gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for battlerId argument.
}
void BufferMoveToLearnIntoBattleTextBuff2(void)
@ -7363,13 +7363,13 @@ static void atk83_nop(void)
gBattlescriptCurrInstr++;
}
bool8 UproarWakeUpCheck(u8 bank)
bool8 UproarWakeUpCheck(u8 battlerId)
{
s32 i;
for (i = 0; i < gBattlersCount; i++)
{
if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || gBattleMons[bank].ability == ABILITY_SOUNDPROOF)
if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || gBattleMons[battlerId].ability == ABILITY_SOUNDPROOF)
continue;
gBattleScripting.battler = i;
@ -7569,7 +7569,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr)
return STAT_CHANGE_DIDNT_WORK;
}
else if (gBattleMons[gActiveBattler].ability == ABILITY_KEEN_EYE
&& !certain && statId == STAT_STAGE_ACC)
&& !certain && statId == STAT_ACC)
{
if (flags == STAT_CHANGE_BS_PTR)
{
@ -7582,7 +7582,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr)
return STAT_CHANGE_DIDNT_WORK;
}
else if (gBattleMons[gActiveBattler].ability == ABILITY_HYPER_CUTTER
&& !certain && statId == STAT_STAGE_ATK)
&& !certain && statId == STAT_ATK)
{
if (flags == STAT_CHANGE_BS_PTR)
{
@ -7753,8 +7753,8 @@ static bool8 TryDoForceSwitchOut(void)
static void atk8F_forcerandomswitch(void)
{
s32 i;
s32 bank1PartyId = 0;
s32 bank2PartyId = 0;
s32 battler1PartyId = 0;
s32 battler2PartyId = 0;
#ifdef NONMATCHING
s32 lastMonId = 0; // + 1
@ -7791,8 +7791,8 @@ static void atk8F_forcerandomswitch(void)
}
monsCount = 3;
minNeeded = 1;
bank2PartyId = gBattlerPartyIndexes[gBattlerTarget];
bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
battler2PartyId = gBattlerPartyIndexes[gBattlerTarget];
battler1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
}
else if ((gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
|| (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_x2000000))
@ -7809,8 +7809,8 @@ static void atk8F_forcerandomswitch(void)
}
monsCount = 3;
minNeeded = 1;
bank2PartyId = gBattlerPartyIndexes[gBattlerTarget];
bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
battler2PartyId = gBattlerPartyIndexes[gBattlerTarget];
battler1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
}
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
@ -7836,8 +7836,8 @@ static void atk8F_forcerandomswitch(void)
monsCount = 3;
minNeeded = 1;
}
bank2PartyId = gBattlerPartyIndexes[gBattlerTarget];
bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
battler2PartyId = gBattlerPartyIndexes[gBattlerTarget];
battler1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
}
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
@ -7845,8 +7845,8 @@ static void atk8F_forcerandomswitch(void)
lastMonId = 6;
monsCount = 6;
minNeeded = 2;
bank2PartyId = gBattlerPartyIndexes[gBattlerTarget];
bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
battler2PartyId = gBattlerPartyIndexes[gBattlerTarget];
battler1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK];
}
else
{
@ -7854,8 +7854,8 @@ static void atk8F_forcerandomswitch(void)
lastMonId = 6;
monsCount = 6;
minNeeded = 1;
bank2PartyId = gBattlerPartyIndexes[gBattlerTarget]; // there is only one pokemon out in single battles
bank1PartyId = gBattlerPartyIndexes[gBattlerTarget];
battler2PartyId = gBattlerPartyIndexes[gBattlerTarget]; // there is only one pokemon out in single battles
battler1PartyId = gBattlerPartyIndexes[gBattlerTarget];
}
for (i = firstMonId; i < lastMonId; i++)
@ -7881,8 +7881,8 @@ static void atk8F_forcerandomswitch(void)
i = Random() % monsCount;
i += firstMonId;
}
while (i == bank2PartyId
|| i == bank1PartyId
while (i == battler2PartyId
|| i == battler1PartyId
|| GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE
|| GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE
|| GetMonData(&party[i], MON_DATA_HP) == 0);
@ -8030,7 +8030,7 @@ static void atk93_tryKO(void)
param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item);
}
gStringBattler = gBattlerTarget;
gPotentialItemEffectBattler = gBattlerTarget;
if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param)
{
@ -8738,7 +8738,7 @@ static bool8 IsInvalidForSleepTalkOrAssist(u16 move)
return FALSE;
}
static u8 AttacksThisTurn(u8 bank, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2
static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2
{
// first argument is unused
if (gBattleMoves[move].effect == EFFECT_SOLARBEAM
@ -9296,10 +9296,10 @@ static void atkBC_maxattackhalvehp(void) // belly drum
if (!(gBattleMons[gBattlerAttacker].maxHP / 2))
halfHp = 1;
if (gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ATK] < 12
if (gBattleMons[gBattlerAttacker].statStages[STAT_ATK] < 12
&& gBattleMons[gBattlerAttacker].hp > halfHp)
{
gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ATK] = 12;
gBattleMons[gBattlerAttacker].statStages[STAT_ATK] = 12;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -9719,8 +9719,8 @@ static void atkC8_sethail(void)
static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento
{
if (gBattleMons[gBattlerTarget].statStages[STAT_STAGE_ATK] == 0
&& gBattleMons[gBattlerTarget].statStages[STAT_STAGE_SPATK] == 0
if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == 0
&& gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == 0
&& gBattleCommunication[6] != 1)
{
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1);
@ -10056,13 +10056,13 @@ static void atkDB_tryimprision(void)
}
else
{
u8 bank, sideAttacker;
u8 battlerId, sideAttacker;
sideAttacker = GetBattlerSide(gBattlerAttacker);
PressurePPLoseOnUsingImprision(gBattlerAttacker);
for (bank = 0; bank < gBattlersCount; bank++)
for (battlerId = 0; battlerId < gBattlersCount; battlerId++)
{
if (sideAttacker != GetBattlerSide(bank))
if (sideAttacker != GetBattlerSide(battlerId))
{
s32 attackerMoveId;
for (attackerMoveId = 0; attackerMoveId < 4; attackerMoveId++)
@ -10070,7 +10070,7 @@ static void atkDB_tryimprision(void)
s32 i;
for (i = 0; i < 4; i++)
{
if (gBattleMons[gBattlerAttacker].moves[attackerMoveId] == gBattleMons[bank].moves[i]
if (gBattleMons[gBattlerAttacker].moves[attackerMoveId] == gBattleMons[battlerId].moves[i]
&& gBattleMons[gBattlerAttacker].moves[attackerMoveId] != MOVE_NONE)
break;
}
@ -10085,7 +10085,7 @@ static void atkDB_tryimprision(void)
}
}
}
if (bank == gBattlersCount) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes
if (battlerId == gBattlersCount) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1);
}
}

View file

@ -383,7 +383,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
else
holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item);
gStringBattler = gActiveBattler;
gPotentialItemEffectBattler = gActiveBattler;
if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move)
{
@ -427,7 +427,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
else
holdEffect = ItemId_GetHoldEffect(gBattleMons[battlerId].item);
gStringBattler = battlerId;
gPotentialItemEffectBattler = battlerId;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
@ -1912,9 +1912,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
}
break;
case ABILITY_SPEED_BOOST:
if (gBattleMons[battler].statStages[STAT_STAGE_SPEED] < 0xC && gDisableStructs[battler].isFirstTurn != 2)
if (gBattleMons[battler].statStages[STAT_SPEED] < 0xC && gDisableStructs[battler].isFirstTurn != 2)
{
gBattleMons[battler].statStages[STAT_STAGE_SPEED]++;
gBattleMons[battler].statStages[STAT_SPEED]++;
gBattleScripting.animArg1 = 0x11;
gBattleScripting.animArg2 = 0;
BattleScriptPushCursorAndCallback(BattleScript_SpeedBoostActivates);
@ -2564,7 +2564,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (effect)
{
gBattleScripting.battler = battlerId;
gStringBattler = battlerId;
gPotentialItemEffectBattler = battlerId;
gActiveBattler = gBattlerAttacker = battlerId;
BattleScriptExecute(BattleScript_WhiteHerbEnd2);
}
@ -2635,7 +2635,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (effect)
{
gBattleScripting.battler = battlerId;
gStringBattler = battlerId;
gPotentialItemEffectBattler = battlerId;
gActiveBattler = gBattlerAttacker = battlerId;
BattleScriptExecute(BattleScript_WhiteHerbEnd2);
}
@ -2747,66 +2747,66 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
// copy/paste again, smh
case HOLD_EFFECT_ATTACK_UP:
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_STAGE_ATK] < 0xC)
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_ATK] < 0xC)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_ATK);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK);
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
gEffectBattler = battlerId;
SET_STATCHANGER(STAT_STAGE_ATK, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_ATK;
SET_STATCHANGER(STAT_ATK, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_ATK;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE;
}
break;
case HOLD_EFFECT_DEFENSE_UP:
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_STAGE_DEF] < 0xC)
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_DEF] < 0xC)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_DEF);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_DEF);
gEffectBattler = battlerId;
SET_STATCHANGER(STAT_STAGE_DEF, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_DEF;
SET_STATCHANGER(STAT_DEF, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_DEF;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE;
}
break;
case HOLD_EFFECT_SPEED_UP:
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_STAGE_SPEED] < 0xC)
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPEED] < 0xC)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_SPEED);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPEED);
gEffectBattler = battlerId;
SET_STATCHANGER(STAT_STAGE_SPEED, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPEED;
SET_STATCHANGER(STAT_SPEED, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_SPEED;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE;
}
break;
case HOLD_EFFECT_SP_ATTACK_UP:
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_STAGE_SPATK] < 0xC)
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPATK] < 0xC)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_SPATK);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK);
gEffectBattler = battlerId;
SET_STATCHANGER(STAT_STAGE_SPATK, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPATK;
SET_STATCHANGER(STAT_SPATK, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_SPATK;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE;
}
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_STAGE_SPDEF] < 0xC)
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / bankQuality && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPDEF] < 0xC)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_SPDEF);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPDEF);
gEffectBattler = battlerId;
SET_STATCHANGER(STAT_STAGE_SPDEF, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPDEF;
SET_STATCHANGER(STAT_SPDEF, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_SPDEF;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE;
@ -2825,7 +2825,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{
for (i = 0; i < 5; i++)
{
if (gBattleMons[battlerId].statStages[STAT_STAGE_ATK + i] < 0xC)
if (gBattleMons[battlerId].statStages[STAT_ATK + i] < 0xC)
break;
}
if (i != 5)
@ -2833,7 +2833,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
do
{
i = Random() % 5;
} while (gBattleMons[battlerId].statStages[STAT_STAGE_ATK + i] == 0xC);
} while (gBattleMons[battlerId].statStages[STAT_ATK + i] == 0xC);
PREPARE_STAT_BUFFER(gBattleTextBuff1, i + 1);
@ -2963,7 +2963,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (effect)
{
gBattleScripting.battler = battlerId;
gStringBattler = battlerId;
gPotentialItemEffectBattler = battlerId;
gActiveBattler = gBattlerAttacker = battlerId;
switch (effect)
{
@ -3111,7 +3111,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (effect)
{
gBattleScripting.battler = battlerId;
gStringBattler = battlerId;
gPotentialItemEffectBattler = battlerId;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
return effect; // unnecessary return
@ -3121,7 +3121,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (effect)
{
gBattleScripting.battler = battlerId;
gStringBattler = battlerId;
gPotentialItemEffectBattler = battlerId;
gActiveBattler = battlerId;
BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler);
@ -3156,7 +3156,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
&& gBattleMons[gBattlerAttacker].hp != 0)
{
gLastUsedItem = atkItem;
gStringBattler = gBattlerAttacker;
gPotentialItemEffectBattler = gBattlerAttacker;
gBattleScripting.battler = gBattlerAttacker;
gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].dmg / atkQuality) * -1;
if (gBattleMoveDamage == 0)

View file

@ -29,7 +29,7 @@ extern u8 gActiveBattler;
extern u8 gBattlerInMenuId;
extern u8 gBattlerTarget;
extern u8 gBattlerAttacker;
extern u8 gStringBattler;
extern u8 gPotentialItemEffectBattler;
extern u16 gTrainerBattleOpponent_A;
extern u32 gBattleTypeFlags;
extern u8 gBattleMonForms[4];
@ -233,7 +233,7 @@ u8 *sub_806CF78(u16 itemId)
itemEffect = gItemEffectTable[itemId - 13];
}
gStringBattler = gBattlerInMenuId;
gPotentialItemEffectBattler = gBattlerInMenuId;
for (i = 0; i < 3; i++)
{