Merge branch 'RHH/upcoming' into RHH/pr/upcoming/variousGone1

# Conflicts:
#	include/constants/battle_script_commands.h
#	src/battle_script_commands.c
This commit is contained in:
Eduardo Quezada 2023-09-07 15:54:55 -03:00
commit 3333395ff7
53 changed files with 4255 additions and 4091 deletions

View File

@ -1312,6 +1312,12 @@
.4byte \failInstr
.endm
.macro jumpifcantfling battler:req, jumpInstr:req
callnative BS_JumpIfCantFling
.byte \battler
.4byte \jumpInstr
.endm
.macro jumpifholdeffect battler:req, holdEffect:req, jumpInstr:req
callnative BS_JumpIfHoldEffect
.byte \battler
@ -2054,11 +2060,6 @@
.4byte \jumpInstr
.endm
.macro jumpifcantfling battler:req, jumpInstr:req
various \battler, VARIOUS_JUMP_IF_CANT_FLING
.4byte \jumpInstr
.endm
.macro curecertainstatuses battler:req
various \battler, VARIOUS_CURE_CERTAIN_STATUSES
.endm

View File

@ -367,7 +367,7 @@ B_ATK_PARTNER_NAME = FD 0E
B_ATK_NAME_WITH_PREFIX = FD 0F
B_DEF_NAME_WITH_PREFIX = FD 10
B_EFF_NAME_WITH_PREFIX = FD 11 @ EFF = short for gEffectBattler
B_ACTIVE_NAME_WITH_PREFIX = FD 12
@ FD 12 - preiously gActiveBattler with prefix
B_SCR_ACTIVE_NAME_WITH_PREFIX = FD 13
B_CURRENT_MOVE = FD 14
B_LAST_MOVE = FD 15
@ -409,8 +409,8 @@ B_ATK_TEAM2 = FD 38
B_DEF_NAME = FD 39
B_DEF_TEAM1 = FD 3A
B_DEF_TEAM2 = FD 3B
B_ACTIVE_NAME = FD 3C
B_ACTIVE_NAME2 = FD 3D @ no Illusion check
@ FD 3C - preiously gActiveBattler
@ FD 3D - preiously gActiveBattler without Illusion Check
@ indicates the end of a town/city name (before " TOWN" or " CITY")
NAME_END = FC 00

View File

@ -1882,28 +1882,28 @@ Move_MAGNET_RISE:
delay 0
createvisualtask AnimTask_BlendColorCycle, 2, (F_PAL_BG | F_PAL_BATTLERS), -31, 1, 5, 5, RGB(31, 31, 20)
playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_ATTACKER
createvisualtask AnimTask_WindUpLunge, 5, ANIM_OPPONENT_RIGHT, 0, -12, 4, 10, 10, 12, 6
createsprite gSparkElectricitySpriteTemplate, 0, 7, 32, 24, 190, 12, 0, 1, 0
createvisualtask AnimTask_WindUpLunge, 5, ANIM_ATTACKER, -12, 4, 10, 10, 12, 6
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 32, 24, 190, 12, ANIM_ATTACKER, 1, 0
delay 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 80, 24, 22, 12, 0, 1, 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 156, 24, 121, 13, 0, 1, 1
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 80, 24, 22, 12, ANIM_ATTACKER, 1, 0
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 156, 24, 121, 13, ANIM_ATTACKER, 1, 1
delay 0
playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_ATTACKER
delay 4
createsprite gSparkElectricitySpriteTemplate, 0, 7, 100, 24, 60, 10, 0, 1, 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 170, 24, 42, 11, 0, 1, 1
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 100, 24, 60, 10, ANIM_ATTACKER, 1, 0
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 170, 24, 42, 11, ANIM_ATTACKER, 1, 1
delay 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 238, 24, 165, 10, 0, 1, 1
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 238, 24, 165, 10, ANIM_ATTACKER, 1, 1
delay 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 32, 24, 190, 12, 0, 1, 0
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 32, 24, 190, 12, ANIM_ATTACKER, 1, 0
delay 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 80, 24, 22, 12, 0, 1, 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 156, 24, 121, 13, 0, 1, 1
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 80, 24, 22, 12, ANIM_ATTACKER, 1, 0
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 156, 24, 121, 13, ANIM_ATTACKER, 1, 1
delay 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 100, 24, 60, 10, 0, 1, 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 170, 24, 42, 11, 0, 1, 1
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 100, 24, 60, 10, ANIM_ATTACKER, 1, 0
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 170, 24, 42, 11, ANIM_ATTACKER, 1, 1
delay 0
createsprite gSparkElectricitySpriteTemplate, 0, 7, 238, 24, 165, 10, 0, 1, 1
createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 238, 24, 165, 10, ANIM_ATTACKER, 1, 1
delay 0
createvisualtask AnimTask_BlendColorCycle, 2, (F_PAL_BG | F_PAL_BATTLERS), -31, 1, 0, 0, RGB(31, 31, 20)
delay 20
@ -8927,7 +8927,7 @@ Boomburst_Doubles:
Move_FAIRY_LOCK::
loadspritegfx ANIM_TAG_CHAIN_LINK @Chain Colour
loadspritegfx ANIM_TAG_FAIRY_LOCK_CHAINS @Fairy Lock Chain
loadspritegfx ANIM_TAG_FAIRY_LOCK_CHAINS @AnimTask is missing for Fairy Lock Chain
setalpha 8, 8
monbg ANIM_ATK_PARTNER
createvisualtask AnimTask_BlendBattleAnimPal, 0xa, F_PAL_BG, 0x1, 0x0, 0x8, 0x6B1F

View File

@ -918,12 +918,10 @@ BattleScript_SkyDropFlyingAlreadyConfused:
goto BattleScript_ThrashConfuses
BattleScript_EffectFling:
attackcanceler
jumpifcantfling BS_ATTACKER, BattleScript_FailedFromAtkString
jumpifstatus3 BS_ATTACKER, STATUS3_EMBARGO, BattleScript_FailedFromAtkString
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MAGIC_ROOM, BattleScript_FailedFromAtkString
setlastuseditem BS_ATTACKER
removeitem BS_ATTACKER
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
pause B_WAIT_TIME_SHORT
@ -966,6 +964,10 @@ BattleScript_FlingEnd:
trysymbiosis
goto BattleScript_MoveEnd
BattleScript_FlingFailConsumeItem::
removeitem BS_ATTACKER
goto BattleScript_FailedFromAtkString
BattleScript_FlingFlameOrb:
setmoveeffect MOVE_EFFECT_BURN
seteffectprimary

View File

@ -112,6 +112,7 @@ BattleScript_ItemSetFocusEnergy::
setfocusenergy
playmoveanimation BS_ATTACKER, MOVE_FOCUS_ENERGY
waitanimation
copybyte sBATTLER, gBattlerAttacker
printstring STRINGID_PKMNUSEDXTOGETPUMPED
waitmessage B_WAIT_TIME_LONG
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 B

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

View File

@ -353,6 +353,7 @@ struct BattleResources
struct BattleHistory *battleHistory;
u8 bufferA[MAX_BATTLERS_COUNT][0x200];
u8 bufferB[MAX_BATTLERS_COUNT][0x200];
u8 transferBuffer[0x100];
};
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
@ -925,7 +926,6 @@ extern u8 gBattleTerrain;
extern u32 gUnusedFirstBattleVar1;
extern u8 *gBattleAnimBgTileBuffer;
extern u8 *gBattleAnimBgTilemapBuffer;
extern u8 gActiveBattler;
extern u32 gBattleControllerExecFlags;
extern u8 gBattlersCount;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];

View File

@ -22,7 +22,7 @@
u8 ComputeBattleAiScores(u8 battler);
void BattleAI_SetupItems(void);
void BattleAI_SetupFlags(void);
void BattleAI_SetupAIData(u8 defaultScoreMoves);
void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler);
u8 BattleAI_ChooseMoveOrAction(void);
void Ai_InitPartyStruct(void);
void Ai_UpdateSwitchInData(u32 battler);

View File

@ -2,8 +2,8 @@
#define GUARD_BATTLE_AI_SWITCH_ITEMS_H
void GetAIPartyIndexes(u32 battlerId, s32 *firstId, s32 *lastId);
void AI_TrySwitchOrUseItem(void);
u8 GetMostSuitableMonToSwitchInto(void);
bool32 ShouldSwitch(void);
void AI_TrySwitchOrUseItem(u32 battler);
u8 GetMostSuitableMonToSwitchInto(u32 battler);
bool32 ShouldSwitch(u32 battler);
#endif // GUARD_BATTLE_AI_SWITCH_ITEMS_H

View File

@ -209,52 +209,52 @@ void SetUpBattleVarsAndBirchZigzagoon(void);
void InitBattleControllers(void);
bool32 IsValidForBattle(struct Pokemon *mon);
void TryReceiveLinkBattleData(void);
void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data);
void PrepareBufferDataTransferLink(u32 battler, u32 bufferId, u16 size, u8 *data);
// emitters
void BtlController_EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck);
void BtlController_EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
void BtlController_EmitLoadMonSprite(u8 bufferId);
void BtlController_EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void BtlController_EmitReturnMonToBall(u8 bufferId, bool8 skipAnim);
void BtlController_EmitDrawTrainerPic(u8 bufferId);
void BtlController_EmitTrainerSlide(u8 bufferId);
void BtlController_EmitTrainerSlideBack(u8 bufferId);
void BtlController_EmitFaintAnimation(u8 bufferId);
void BtlController_EmitBallThrowAnim(u8 bufferId, u8 caseId);
void BtlController_EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit);
void BtlController_EmitPrintString(u8 bufferId, u16 stringId);
void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringId);
void BtlController_EmitChooseAction(u8 bufferId, u8 action, u16 itemId);
void BtlController_EmitYesNoBox(u8 bufferId);
void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
void BtlController_EmitChooseItem(u8 bufferId, u8 *battlePartyOrder);
void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 slotId, u16 abilityId, u8 *data);
void BtlController_EmitHealthBarUpdate(u8 bufferId, u16 hpValue);
void BtlController_EmitExpUpdate(u8 bufferId, u8 partyId, s32 expPoints);
void BtlController_EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2);
void BtlController_EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status);
void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data);
void BtlController_EmitTwoReturnValues(u8 bufferId, u8 ret8, u32 ret32);
void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 partyId, u8 *battlePartyOrder);
void BtlController_EmitOneReturnValue(u8 bufferId, u16 ret);
void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 ret);
void BtlController_EmitHitAnimation(u8 bufferId);
void BtlController_EmitCantSwitch(u8 bufferId);
void BtlController_EmitPlaySE(u8 bufferId, u16 songId);
void BtlController_EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM);
void BtlController_EmitFaintingCry(u8 bufferId);
void BtlController_EmitIntroSlide(u8 bufferId, u8 terrainId);
void BtlController_EmitIntroTrainerBallThrow(u8 bufferId);
void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 flags);
void BtlController_EmitHidePartyStatusSummary(u8 bufferId);
void BtlController_EmitEndBounceEffect(u8 bufferId);
void BtlController_EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void BtlController_EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 mode, bool32 record);
void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome);
void BtlController_EmitDebugMenu(u8 bufferId);
void BtlController_EmitGetMonData(u32 battler, u32 bufferId, u8 requestId, u8 monToCheck);
void BtlController_EmitSetMonData(u32 battler, u32 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
void BtlController_EmitLoadMonSprite(u32 battler, u32 bufferId);
void BtlController_EmitSwitchInAnim(u32 battler, u32 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void BtlController_EmitReturnMonToBall(u32 battler, u32 bufferId, bool8 skipAnim);
void BtlController_EmitDrawTrainerPic(u32 battler, u32 bufferId);
void BtlController_EmitTrainerSlide(u32 battler, u32 bufferId);
void BtlController_EmitTrainerSlideBack(u32 battler, u32 bufferId);
void BtlController_EmitFaintAnimation(u32 battler, u32 bufferId);
void BtlController_EmitBallThrowAnim(u32 battler, u32 bufferId, u8 caseId);
void BtlController_EmitMoveAnimation(u32 battler, u32 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit);
void BtlController_EmitPrintString(u32 battler, u32 bufferId, u16 stringId);
void BtlController_EmitPrintSelectionString(u32 battler, u32 bufferId, u16 stringId);
void BtlController_EmitChooseAction(u32 battler, u32 bufferId, u8 action, u16 itemId);
void BtlController_EmitYesNoBox(u32 battler, u32 bufferId);
void BtlController_EmitChooseMove(u32 battler, u32 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
void BtlController_EmitChooseItem(u32 battler, u32 bufferId, u8 *battlePartyOrder);
void BtlController_EmitChoosePokemon(u32 battler, u32 bufferId, u8 caseId, u8 slotId, u16 abilityId, u8 *data);
void BtlController_EmitHealthBarUpdate(u32 battler, u32 bufferId, u16 hpValue);
void BtlController_EmitExpUpdate(u32 battler, u32 bufferId, u8 partyId, s32 expPoints);
void BtlController_EmitStatusIconUpdate(u32 battler, u32 bufferId, u32 status1, u32 status2);
void BtlController_EmitStatusAnimation(u32 battler, u32 bufferId, bool8 status2, u32 status);
void BtlController_EmitDataTransfer(u32 battler, u32 bufferId, u16 size, void *data);
void BtlController_EmitTwoReturnValues(u32 battler, u32 bufferId, u8 ret8, u32 ret32);
void BtlController_EmitChosenMonReturnValue(u32 battler, u32 bufferId, u8 partyId, u8 *battlePartyOrder);
void BtlController_EmitOneReturnValue(u32 battler, u32 bufferId, u16 ret);
void BtlController_EmitOneReturnValue_Duplicate(u32 battler, u32 bufferId, u16 ret);
void BtlController_EmitHitAnimation(u32 battler, u32 bufferId);
void BtlController_EmitCantSwitch(u32 battler, u32 bufferId);
void BtlController_EmitPlaySE(u32 battler, u32 bufferId, u16 songId);
void BtlController_EmitPlayFanfareOrBGM(u32 battler, u32 bufferId, u16 songId, bool8 playBGM);
void BtlController_EmitFaintingCry(u32 battler, u32 bufferId);
void BtlController_EmitIntroSlide(u32 battler, u32 bufferId, u8 terrainId);
void BtlController_EmitIntroTrainerBallThrow(u32 battler, u32 bufferId);
void BtlController_EmitDrawPartyStatusSummary(u32 battler, u32 bufferId, struct HpAndStatus* hpAndStatus, u8 flags);
void BtlController_EmitHidePartyStatusSummary(u32 battler, u32 bufferId);
void BtlController_EmitEndBounceEffect(u32 battler, u32 bufferId);
void BtlController_EmitSpriteInvisibility(u32 battler, u32 bufferId, bool8 isInvisible);
void BtlController_EmitBattleAnimation(u32 battler, u32 bufferId, u8 animationId, u16 argument);
void BtlController_EmitLinkStandbyMsg(u32 battler, u32 bufferId, u8 mode, bool32 record);
void BtlController_EmitResetActionMoveSelection(u32 battler, u32 bufferId, u8 caseId);
void BtlController_EmitEndLinkBattle(u32 battler, u32 bufferId, u8 battleOutcome);
void BtlController_EmitDebugMenu(u32 battler, u32 bufferId);
void BattleControllerComplete(u32 battler); // Can be used for all the controllers.
void BtlController_Empty(u32 battler); // Empty command, does nothing, only completes the execution.

View File

@ -3,40 +3,40 @@
void AllocateBattleSpritesData(void);
void FreeBattleSpritesData(void);
u16 ChooseMoveAndTargetInBattlePalace(void);
u16 ChooseMoveAndTargetInBattlePalace(u32 battler);
void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *sprite);
void SpriteCB_TrainerSlideIn(struct Sprite *sprite);
void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status);
void InitAndLaunchChosenStatusAnimation(u32 battler, bool32 isStatus2, u32 status);
bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattlerId, u8 attacker, u8 target, u8 tableId, u16 argument);
void InitAndLaunchSpecialAnimation(u8 activeBattlerId, u8 attacker, u8 target, u8 tableId);
bool8 IsBattleSEPlaying(u8 battlerId);
void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId);
bool8 IsBattleSEPlaying(u8 battler);
void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battler);
void BattleGfxSfxDummy2(u16 species);
void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId);
void DecompressTrainerBackPic(u16 backPicId, u8 battlerId);
void DecompressTrainerFrontPic(u16 frontPicId, u8 battler);
void DecompressTrainerBackPic(u16 backPicId, u8 battler);
void FreeTrainerFrontPicPalette(u16 frontPicId);
bool8 BattleLoadAllHealthBoxesGfx(u8 state);
void LoadBattleBarGfx(u8 unused);
bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId);
bool8 BattleInitAllSprites(u8 *state1, u8 *battler);
void ClearSpritesHealthboxAnimData(void);
void CopyAllBattleSpritesInvisibilities(void);
void CopyBattleSpriteInvisibility(u8 battlerId);
void CopyBattleSpriteInvisibility(u8 battler);
void HandleSpeciesGfxDataChange(u8 attacker, u8 target, bool32 megaEvo, bool8 trackEnemyPersonality);
void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite);
void LoadBattleMonGfxAndAnimate(u8 battlerId, bool8 loadMonSprite, u8 spriteId);
void TrySetBehindSubstituteSpriteBit(u8 battlerId, u16 move);
void ClearBehindSubstituteBit(u8 battlerId);
void HandleLowHpMusicChange(struct Pokemon *mon, u8 battlerId);
void BattleLoadSubstituteOrMonSpriteGfx(u8 battler, bool8 loadMonSprite);
void LoadBattleMonGfxAndAnimate(u8 battler, bool8 loadMonSprite, u8 spriteId);
void TrySetBehindSubstituteSpriteBit(u8 battler, u16 move);
void ClearBehindSubstituteBit(u8 battler);
void HandleLowHpMusicChange(struct Pokemon *mon, u8 battler);
void BattleStopLowHpSound(void);
u8 GetMonHPBarLevel(struct Pokemon *mon);
void HandleBattleLowHpMusicChange(void);
void SetBattlerSpriteAffineMode(u8 affineMode);
void LoadAndCreateEnemyShadowSprites(void);
void SpriteCB_SetInvisible(struct Sprite *sprite);
void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species);
void HideBattlerShadowSprite(u8 battlerId);
void SetBattlerShadowSpriteCallback(u8 battler, u16 species);
void HideBattlerShadowSprite(u8 battler);
void FillAroundBattleWindows(void);
void ClearTemporarySpeciesSpriteData(u8 battlerId, bool8 dontClearSubstitute);
void ClearTemporarySpeciesSpriteData(u8 battler, bool8 dontClearSubstitute);
void AllocateMonSpritesGfx(void);
void FreeMonSpritesGfx(void);
bool32 ShouldPlayNormalMonCry(struct Pokemon *mon);

View File

@ -53,10 +53,10 @@ void SpriteCB_TrainerThrowObject(struct Sprite *sprite);
void AnimSetCenterToCornerVecX(struct Sprite *sprite);
void BeginBattleIntroDummy(void);
void BeginBattleIntro(void);
void SwitchInClearSetData(void);
void FaintClearSetData(void);
void SwitchInClearSetData(u32 battler);
void FaintClearSetData(u32 battler);
void BattleTurnPassed(void);
u8 IsRunningFromBattleImpossible(void);
u8 IsRunningFromBattleImpossible(u32 battler);
void SwitchPartyOrder(u8 battlerId);
void SwapTurnOrder(u8 id1, u8 id2);
u32 GetBattlerTotalSpeedStat(u8 battlerId);

View File

@ -27,7 +27,7 @@
#define B_TXT_ATK_NAME_WITH_PREFIX 0xF
#define B_TXT_DEF_NAME_WITH_PREFIX 0x10
#define B_TXT_EFF_NAME_WITH_PREFIX 0x11 // EFF = short for gEffectBank
#define B_TXT_ACTIVE_NAME_WITH_PREFIX 0x12
// #define B_TXT_ACTIVE_NAME_WITH_PREFIX 0x12 - removed
#define B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX 0x13
#define B_TXT_CURRENT_MOVE 0x14
#define B_TXT_LAST_MOVE 0x15
@ -69,8 +69,8 @@
#define B_TXT_DEF_NAME 0x39
#define B_TXT_DEF_TEAM1 0x3A // Your/The opposing
#define B_TXT_DEF_TEAM2 0x3B // your/the opposing
#define B_TXT_ACTIVE_NAME 0x3C
#define B_TXT_ACTIVE_NAME2 0x3D // no Illusion check
// #define B_TXT_SELECTION_NAME 0x3C - removed
// #define B_TXT_SELECTION_NAME2 0x3D no Illusion check - removed
// for B_TXT_BUFF1, B_TXT_BUFF2 and B_TXT_BUFF3
@ -240,13 +240,13 @@ enum
TRAINER_SLIDE_BEFORE_FIRST_TURN,
};
void BufferStringBattle(u16 stringID);
void BufferStringBattle(u16 stringID, u32 battler);
u32 BattleStringExpandPlaceholdersToDisplayedString(const u8 *src);
u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst);
void BattlePutTextOnWindow(const u8 *text, u8 windowId);
void SetPpNumbersPaletteInMoveSelection(void);
void SetPpNumbersPaletteInMoveSelection(u32 battler);
u8 GetCurrentPpToMaxPpState(u8 currentPp, u8 maxPp);
u32 ShouldDoTrainerSlide(u32 battlerId, u32 which); // return 1 for TrainerA, 2 forTrainerB
u32 ShouldDoTrainerSlide(u32 battler, u32 which); // return 1 for TrainerA, 2 forTrainerB
void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);
extern struct BattleMsgData *gBattleMsgDataPtr;

View File

@ -10,6 +10,7 @@ extern const u8 BattleScript_MakeMoveMissed[];
extern const u8 BattleScript_PrintMoveMissed[];
extern const u8 BattleScript_MoveMissedPause[];
extern const u8 BattleScript_MoveMissed[];
extern const u8 BattleScript_FlingFailConsumeItem[];
extern const u8 BattleScript_FailedFromAtkString[];
extern const u8 BattleScript_ButItFailed[];
extern const u8 BattleScript_StatUp[];

View File

@ -54,7 +54,8 @@
#define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK)))
#define IS_WHOLE_SIDE_ALIVE(battler)((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler))))
#define IS_WHOLE_SIDE_ALIVE(battler) ((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler))))
#define IS_ALIVE_AND_PRESENT(battler) (IsBattlerAlive(battler) && IsBattlerSpritePresent(battler))
// for Natural Gift and Fling
struct TypePower
@ -114,22 +115,22 @@ u8 GetBattlerForBattleScript(u8 caseId);
void PressurePPLose(u8 target, u8 attacker, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 attacker);
void PressurePPLoseOnUsingImprison(u8 attacker);
bool32 IsBattlerMarkedForControllerExec(u8 battlerId);
void MarkBattlerForControllerExec(u8 battlerId);
void MarkBattlerReceivedLinkData(u8 battlerId);
void CancelMultiTurnMoves(u8 battlerId);
bool8 WasUnableToUseMove(u8 battlerId);
void PrepareStringBattle(u16 stringId, u8 battlerId);
bool32 IsBattlerMarkedForControllerExec(u8 battler);
void MarkBattlerForControllerExec(u8 battler);
void MarkBattlerReceivedLinkData(u8 battler);
void CancelMultiTurnMoves(u8 battler);
bool8 WasUnableToUseMove(u8 battler);
void PrepareStringBattle(u16 stringId, u8 battler);
void ResetSentPokesToOpponentValue(void);
void OpponentSwitchInResetSentPokesToOpponentValue(u8 battlerId);
void UpdateSentPokesToOpponentValue(u8 battlerId);
void OpponentSwitchInResetSentPokesToOpponentValue(u8 battler);
void UpdateSentPokesToOpponentValue(u8 battler);
void BattleScriptPush(const u8 *bsPtr);
void BattleScriptPushCursor(void);
void BattleScriptPop(void);
u8 TrySetCantSelectMoveBattleScript(void);
u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u16 check);
bool8 AreAllMovesUnusable(void);
u8 GetImprisonedMovesCount(u8 battlerId, u16 move);
u32 TrySetCantSelectMoveBattleScript(u32 battler);
u8 CheckMoveLimitations(u8 battler, u8 unusableMoves, u16 check);
bool32 AreAllMovesUnusable(u32 battler);
u8 GetImprisonedMovesCount(u8 battler, u16 move);
u8 DoFieldEndTurnEffects(void);
s32 GetDrainedBigRootHp(u32 battler, s32 hp);
u8 DoBattlerEndTurnEffects(void);
@ -139,34 +140,34 @@ void TryClearRageAndFuryCutter(void);
u8 AtkCanceller_UnableToUseMove(u32 moveType);
void SetAtkCancellerForCalledMove(void);
u8 AtkCanceller_UnableToUseMove2(void);
bool8 HasNoMonsToSwitch(u8 battlerId, u8 r1, u8 r2);
bool8 HasNoMonsToSwitch(u8 battler, u8 r1, u8 r2);
bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility);
u8 AbilityBattleEffects(u8 caseID, u8 battlerId, u16 ability, u8 special, u16 moveArg);
bool32 TryPrimalReversion(u8 battlerId);
u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 moveArg);
bool32 TryPrimalReversion(u8 battler);
bool32 IsNeutralizingGasOnField(void);
u32 GetBattlerAbility(u8 battlerId);
u32 IsAbilityOnSide(u32 battlerId, u32 ability);
u32 IsAbilityOnOpposingSide(u32 battlerId, u32 ability);
u32 GetBattlerAbility(u8 battler);
u32 IsAbilityOnSide(u32 battler, u32 ability);
u32 IsAbilityOnOpposingSide(u32 battler, u32 ability);
u32 IsAbilityOnField(u32 ability);
u32 IsAbilityOnFieldExcept(u32 battlerId, u32 ability);
u32 IsAbilityPreventingEscape(u32 battlerId);
bool32 IsBattlerProtected(u8 battlerId, u16 move);
bool32 CanBattlerEscape(u32 battlerId); // no ability check
u32 IsAbilityOnFieldExcept(u32 battler, u32 ability);
u32 IsAbilityPreventingEscape(u32 battler);
bool32 IsBattlerProtected(u8 battler, u16 move);
bool32 CanBattlerEscape(u32 battler); // no ability check
void BattleScriptExecute(const u8 *BS_ptr);
void BattleScriptPushCursorAndCallback(const u8 *BS_ptr);
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 battlerId);
u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 battler);
void HandleAction_RunBattleScript(void);
u32 SetRandomTarget(u32 battlerId);
u32 SetRandomTarget(u32 battler);
u32 GetMoveTarget(u16 move, u8 setTarget);
u8 IsMonDisobedient(void);
u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating);
u32 GetBattlerHoldEffectParam(u8 battlerId);
u32 GetBattlerHoldEffect(u8 battler, bool32 checkNegating);
u32 GetBattlerHoldEffectParam(u8 battler);
bool32 IsMoveMakingContact(u16 move, u8 battlerAtk);
bool32 IsBattlerGrounded(u8 battlerId);
bool32 IsBattlerAlive(u8 battlerId);
bool32 IsBattlerGrounded(u8 battler);
bool32 IsBattlerAlive(u8 battler);
u8 GetBattleMonMoveSlot(struct BattlePokemon *battleMon, u16 move);
u32 GetBattlerWeight(u8 battlerId);
u32 GetBattlerWeight(u8 battler);
u32 CalcRolloutBasePower(u32 battlerAtk, u32 basePower, u32 rolloutTimer);
u32 CalcFuryCutterBasePower(u32 basePower, u32 furyCutterCounter);
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor, bool32 updateFlags);
@ -174,46 +175,46 @@ s32 CalculateMoveDamageAndEffectiveness(u16 move, u8 battlerAtk, u8 battlerDef,
uq4_12_t CalcTypeEffectivenessMultiplier(u16 move, u8 moveType, u8 battlerAtk, u8 battlerDef, bool32 recordAbilities);
uq4_12_t CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef);
uq4_12_t GetTypeModifier(u8 atkType, u8 defType);
s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId);
s32 GetStealthHazardDamage(u8 hazardType, u8 battler);
s32 GetStealthHazardDamageByTypesAndHP(u8 hazardType, u8 type1, u8 type2, u32 maxHp);
bool32 CanMegaEvolve(u8 battlerId);
bool32 CanUltraBurst(u8 battlerId);
bool32 IsBattlerMegaEvolved(u8 battlerId);
bool32 IsBattlerPrimalReverted(u8 battlerId);
bool32 IsBattlerUltraBursted(u8 battlerId);
u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method);
bool32 TryBattleFormChange(u8 battlerId, u16 method);
bool32 CanMegaEvolve(u8 battler);
bool32 CanUltraBurst(u8 battler);
bool32 IsBattlerMegaEvolved(u8 battler);
bool32 IsBattlerPrimalReverted(u8 battler);
bool32 IsBattlerUltraBursted(u8 battler);
u16 GetBattleFormChangeTargetSpecies(u8 battler, u16 method);
bool32 TryBattleFormChange(u8 battler, u16 method);
bool32 DoBattlersShareType(u32 battler1, u32 battler2);
bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId);
u32 GetIllusionMonSpecies(u32 battlerId);
struct Pokemon *GetIllusionMonPtr(u32 battlerId);
void ClearIllusionMon(u32 battlerId);
bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId);
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
bool32 CanBattlerGetOrLoseItem(u8 battler, u16 itemId);
u32 GetIllusionMonSpecies(u32 battler);
struct Pokemon *GetIllusionMonPtr(u32 battler);
void ClearIllusionMon(u32 battler);
bool32 SetIllusionMon(struct Pokemon *mon, u32 battler);
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battler);
u8 GetBattleMoveSplit(u32 moveId);
bool32 CanFling(u8 battlerId);
bool32 CanFling(u32 battler);
bool32 IsTelekinesisBannedSpecies(u16 species);
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId);
bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
u8 GetSplitBasedOnStats(u8 battlerId);
bool32 HasEnoughHpToEatBerry(u32 battler, u32 hpFraction, u32 itemId);
bool32 IsPartnerMonFromSameTrainer(u8 battler);
u8 GetSplitBasedOnStats(u8 battler);
bool32 TestSheerForceFlag(u8 battler, u16 move);
void TryRestoreHeldItems(void);
bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item);
void TrySaveExchangedItem(u8 battlerId, u16 stolenItem);
bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
void TrySaveExchangedItem(u8 battler, u16 stolenItem);
bool32 IsPartnerMonFromSameTrainer(u8 battler);
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute);
bool32 IsBattlerAffectedByHazards(u8 battlerId, bool32 toxicSpikes);
bool32 IsBattlerAffectedByHazards(u8 battler, bool32 toxicSpikes);
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind);
bool32 TryRoomService(u8 battlerId);
void BufferStatChange(u8 battlerId, u8 statId, u8 stringId);
bool32 CompareStat(u8 battler, u8 statId, u8 cmpTo, u8 cmpKind);
bool32 TryRoomService(u8 battler);
void BufferStatChange(u8 battler, u8 statId, u8 stringId);
bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget);
u16 GetUsedHeldItem(u8 battler);
bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags);
u32 GetBattlerMoveTargetType(u8 battlerId, u16 move);
bool32 IsBattlerWeatherAffected(u8 battler, u32 weatherFlags);
u32 GetBattlerMoveTargetType(u8 battler, u16 move);
bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move);
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId);
bool8 IsMoveAffectedByParentalBond(u16 move, u8 battler);
void CopyMonLevelAndBaseStatsToBattleMon(u32 battler, struct Pokemon *mon);
void CopyMonAbilityAndTypesToBattleMon(u32 battler, struct Pokemon *mon);
void RecalcBattlerStats(u32 battler, struct Pokemon *mon);
@ -228,21 +229,21 @@ bool32 IsGastroAcidBannedAbility(u16 ability);
bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
bool32 CanSleep(u8 battlerId);
bool32 CanSleep(u8 battler);
bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget);
bool32 CanBeBurned(u8 battlerId);
bool32 CanBeParalyzed(u8 battlerId);
bool32 CanBeFrozen(u8 battlerId);
bool32 CanGetFrostbite(u8 battlerId);
bool32 CanBeConfused(u8 battlerId);
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag);
u32 GetBattlerFriendshipScore(u8 battlerId);
u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc);
bool32 CanBeBurned(u8 battler);
bool32 CanBeParalyzed(u8 battler);
bool32 CanBeFrozen(u8 battler);
bool32 CanGetFrostbite(u8 battler);
bool32 CanBeConfused(u8 battler);
bool32 IsBattlerTerrainAffected(u8 battler, u32 terrainFlag);
u32 GetBattlerFriendshipScore(u8 battler);
u32 CountBattlerStatIncreases(u8 battler, bool32 countEvasionAcc);
bool32 IsMyceliumMightOnField(void);
bool8 ChangeTypeBasedOnTerrain(u8 battlerId);
void RemoveConfusionStatus(u8 battlerId);
u8 GetBattlerGender(u8 battlerId);
bool8 ChangeTypeBasedOnTerrain(u8 battler);
void RemoveConfusionStatus(u8 battler);
u8 GetBattlerGender(u8 battler);
bool8 AreBattlersOfOppositeGender(u8 battler1, u8 battler2);
u32 CalcSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance);
u32 CalcSecondaryEffectChance(u8 battler, u8 secondaryEffectChance);
#endif // GUARD_BATTLE_UTIL_H

View File

@ -14,18 +14,18 @@ struct SignatureZMove
};
bool8 IsZMove(u16 move);
void QueueZMove(u8 battlerId, u16 baseMove);
bool32 IsViableZMove(u8 battlerId, u16 move);
bool32 TryChangeZIndicator(u8 battlerId, u8 moveIndex);
void QueueZMove(u8 battler, u16 baseMove);
bool32 IsViableZMove(u8 battler, u16 move);
bool32 TryChangeZIndicator(u8 battler, u8 moveIndex);
void CreateZMoveTriggerSprite(u8, bool8);
void HideZMoveTriggerSprite(void);
bool32 IsZMoveTriggerSpriteActive(void);
void DestroyZMoveTriggerSprite(void);
bool32 MoveSelectionDisplayZMove(u16 zmove);
bool32 MoveSelectionDisplayZMove(u16 zmove, u32 battler);
const u8 *GetZMoveName(u16 move);
void SetZEffect(void);
bool32 IsZMoveUsable(u8 battlerId, u16 moveIndex);
void GetUsableZMoves(u8 battlerId, u16 *moves);
bool32 IsZMoveUsable(u8 battler, u16 moveIndex);
void GetUsableZMoves(u8 battler, u16 *moves);
u16 GetZMovePower(u16 move);
#endif // GUARD_BATTLE_Z_MOVE_H

View File

@ -229,28 +229,27 @@
#define VARIOUS_SET_SKY_DROP 137
#define VARIOUS_CLEAR_SKY_DROP 138
#define VARIOUS_SKY_DROP_YAWN 139
#define VARIOUS_JUMP_IF_CANT_FLING 140
#define VARIOUS_JUMP_IF_HOLD_EFFECT 141
#define VARIOUS_CURE_CERTAIN_STATUSES 142
#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 143
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 144
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 145
#define VARIOUS_SAVE_BATTLER_ITEM 146
#define VARIOUS_RESTORE_BATTLER_ITEM 147
#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 148
#define VARIOUS_SET_BEAK_BLAST 149
#define VARIOUS_SWAP_SIDE_STATUSES 150
#define VARIOUS_SWAP_STATS 151
#define VARIOUS_TEATIME_INVUL 152
#define VARIOUS_TEATIME_TARGETS 153
#define VARIOUS_TRY_WIND_RIDER_POWER 154
#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 155
#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 156
#define VARIOUS_STORE_HEALING_WISH 157
#define VARIOUS_HIT_SWITCH_TARGET_FAILED 158
#define VARIOUS_TRY_REVIVAL_BLESSING 159
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 160
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 161
#define VARIOUS_JUMP_IF_HOLD_EFFECT 140
#define VARIOUS_CURE_CERTAIN_STATUSES 141
#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 142
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 143
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 144
#define VARIOUS_SAVE_BATTLER_ITEM 145
#define VARIOUS_RESTORE_BATTLER_ITEM 146
#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 147
#define VARIOUS_SET_BEAK_BLAST 148
#define VARIOUS_SWAP_SIDE_STATUSES 149
#define VARIOUS_SWAP_STATS 150
#define VARIOUS_TEATIME_INVUL 151
#define VARIOUS_TEATIME_TARGETS 152
#define VARIOUS_TRY_WIND_RIDER_POWER 153
#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 154
#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 155
#define VARIOUS_STORE_HEALING_WISH 156
#define VARIOUS_HIT_SWITCH_TARGET_FAILED 157
#define VARIOUS_TRY_REVIVAL_BLESSING 158
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 159
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 160
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -305,10 +305,8 @@
// - Unown has 1 frame, presumably to avoid the work of animating all 28 of its forms
#define MAX_MON_PIC_FRAMES 2
#define BATTLE_ALIVE_EXCEPT_ACTIVE 0
#define BATTLE_ALIVE_ATK_SIDE 1
#define BATTLE_ALIVE_DEF_SIDE 2
#define BATTLE_ALIVE_EXCEPT_ATTACKER 3
#define BATTLE_ALIVE_EXCEPT_BATTLER 0
#define BATTLE_ALIVE_SIDE 1
#define SKIP_FRONT_ANIM (1 << 7)

View File

@ -9322,9 +9322,9 @@ extern const u32 gConfetti_Gfx[];
extern const u32 gConfetti_Pal[];
extern const u32 gBattleInterfaceGfx_BattleBar[];
extern const u32 gSubstituteDollBackGfx[];
extern const u32 gSubstituteDollFrontGfx[];
extern const u32 gSubstituteDollPal[];
extern const u32 gBattleAnimSpriteGfx_Substitute[];
extern const u32 gBattleAnimSpriteGfx_SubstituteBack[];
extern const u32 gBattleAnimSpritePal_Substitute[];
extern const u32 gHealthboxSinglesPlayerGfx[];
extern const u32 gHealthboxSinglesOpponentGfx[];
extern const u32 gHealthboxDoublesPlayerGfx[];
@ -10145,9 +10145,6 @@ extern const u32 gBattleAnimSpritePal_StonePillar[];
extern const u32 gBattleAnimSpriteGfx_StraightBeam[];
extern const u32 gBattleAnimSpritePal_StraightBeam[];
extern const u32 gBattleAnimSpritePal_Poltergeist[];
extern const u32 gBattleAnimSpriteGfx_SubstituteBack[];
extern const u32 gBattleAnimSpriteGfx_SubstituteFront[];
extern const u32 gBattleAnimSpritePal_SubstituteFront[];
extern const u32 gBattleAnimSpritePal_NewSurf[];
extern const u32 gBattleAnimSpriteGfx_NewSword[];
extern const u32 gBattleAnimSpritePal_NewSword[];

View File

@ -48,7 +48,7 @@ extern const struct SpriteTemplate gBallSpriteTemplates[];
#define POKEBALL_PLAYER_SENDOUT 0xFF
#define POKEBALL_OPPONENT_SENDOUT 0xFE
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow);
u8 DoPokeballSendOutAnimation(u32 battler, s16 pan, u8 kindOfThrow);
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriority, u8 delay, u32 fadePalettes, u16 species);
u8 CreateTradePokeballSprite(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 delay, u32 fadePalettes);
void StartHealthboxSlideIn(u8 battler);

View File

@ -490,7 +490,7 @@ void GiveBoxMonInitialMoveset_Fast(struct BoxPokemon *boxMon);
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove);
void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move);
void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move);
u8 CountAliveMonsInBattle(u8 caseId);
u8 CountAliveMonsInBattle(u8 caseId, u32 battler);
u8 GetDefaultMoveTarget(u8 battlerId);
u8 GetMonGender(struct Pokemon *mon);
u8 GetBoxMonGender(struct BoxPokemon *boxMon);
@ -538,7 +538,7 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex);
bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 item, u8 partyIndex, u8 moveIndex);
bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 moveIndex, u8 e);
bool8 HealStatusConditions(struct Pokemon *mon, u32 battlePartyId, u32 healMask, u8 battlerId);
u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit);
u8 GetItemEffectParamOffset(u32 battler, u16 itemId, u8 effectByte, u8 effectBit);
u8 *UseStatIncreaseItem(u16 itemId);
u8 GetNature(struct Pokemon *mon);
u8 GetNatureFromPersonality(u32 personality);

View File

@ -70,13 +70,13 @@ void PlayRecordedBattle(void (*CB2_After)(void));
u8 GetRecordedBattleFrontierFacility(void);
u8 GetRecordedBattleFronterBrainSymbol(void);
void RecordedBattle_SaveParties(void);
u8 GetActiveBattlerLinkPlayerGender(void);
u8 GetBattlerLinkPlayerGender(u32 battler);
void RecordedBattle_ClearFrontierPassFlag(void);
void RecordedBattle_SetFrontierPassFlagFromHword(u16 flags);
u8 RecordedBattle_GetFrontierPassFlag(void);
u8 GetBattleSceneInRecordedBattle(void);
u8 GetTextSpeedInRecordedBattle(void);
void RecordedBattle_CopyBattlerMoves(void);
void RecordedBattle_CopyBattlerMoves(u32 battler);
void RecordedBattle_CheckMovesetChanges(u8 mode);
u32 GetAiScriptsInRecordedBattle(void);
void RecordedBattle_SetPlaybackFinished(void);

View File

@ -180,7 +180,7 @@ void BattleAI_SetupFlags(void)
}
// sBattler_AI set in ComputeBattleAiScores
void BattleAI_SetupAIData(u8 defaultScoreMoves)
void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler)
{
s32 i, move, dmg;
u8 moveLimitations;
@ -201,7 +201,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
defaultScoreMoves >>= 1;
}
moveLimitations = AI_DATA->moveLimitations[gActiveBattler];
moveLimitations = AI_DATA->moveLimitations[battler];
// Ignore moves that aren't possible to use.
for (i = 0; i < MAX_MON_MOVES; i++)
@ -210,7 +210,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
AI_THINKING_STRUCT->score[i] = 0;
}
//sBattler_AI = gActiveBattler;
//sBattler_AI = battler;
gBattlerTarget = SetRandomTarget(sBattler_AI);
gBattleStruct->aiChosenTarget[sBattler_AI] = gBattlerTarget;
}
@ -237,7 +237,7 @@ u8 BattleAI_ChooseMoveOrAction(void)
u8 ComputeBattleAiScores(u8 battler)
{
sBattler_AI = battler;
BattleAI_SetupAIData(0xF);
BattleAI_SetupAIData(0xF, sBattler_AI);
return BattleAI_ChooseMoveOrAction();
}
@ -335,15 +335,15 @@ void Ai_UpdateFaintData(u32 battler)
aiMon->isFainted = TRUE;
}
static void SetBattlerAiData(u8 battlerId)
static void SetBattlerAiData(u8 battler)
{
AI_DATA->abilities[battlerId] = AI_GetAbility(battlerId);
AI_DATA->items[battlerId] = gBattleMons[battlerId].item;
AI_DATA->holdEffects[battlerId] = AI_GetHoldEffect(battlerId);
AI_DATA->holdEffectParams[battlerId] = GetBattlerHoldEffectParam(battlerId);
AI_DATA->predictedMoves[battlerId] = gLastMoves[battlerId];
AI_DATA->hpPercents[battlerId] = GetHealthPercentage(battlerId);
AI_DATA->moveLimitations[battlerId] = CheckMoveLimitations(battlerId, 0, MOVE_LIMITATIONS_ALL);
AI_DATA->abilities[battler] = AI_GetAbility(battler);
AI_DATA->items[battler] = gBattleMons[battler].item;
AI_DATA->holdEffects[battler] = AI_GetHoldEffect(battler);
AI_DATA->holdEffectParams[battler] = GetBattlerHoldEffectParam(battler);
AI_DATA->predictedMoves[battler] = gLastMoves[battler];
AI_DATA->hpPercents[battler] = GetHealthPercentage(battler);
AI_DATA->moveLimitations[battler] = CheckMoveLimitations(battler, 0, MOVE_LIMITATIONS_ALL);
}
void GetAiLogicData(void)
@ -399,48 +399,48 @@ void GetAiLogicData(void)
}
}
static bool32 AI_SwitchMonIfSuitable(u32 battlerId)
static bool32 AI_SwitchMonIfSuitable(u32 battler)
{
u32 monToSwitchId = GetMostSuitableMonToSwitchInto();
u32 monToSwitchId = GetMostSuitableMonToSwitchInto(battler);
if (monToSwitchId != PARTY_SIZE)
{
AI_DATA->shouldSwitchMon |= gBitTable[battlerId];
AI_DATA->monToSwitchId[battlerId] = monToSwitchId;
AI_DATA->shouldSwitchMon |= gBitTable[battler];
AI_DATA->monToSwitchId[battler] = monToSwitchId;
return TRUE;
}
return FALSE;
}
static bool32 AI_ShouldSwitchIfBadMoves(u32 battlerId, bool32 doubleBattle)
static bool32 AI_ShouldSwitchIfBadMoves(u32 battler, bool32 doubleBattle)
{
u32 i, j;
// If can switch.
if (CountUsablePartyMons(battlerId) > 0
&& !IsBattlerTrapped(battlerId, TRUE)
if (CountUsablePartyMons(battler) > 0
&& !IsBattlerTrapped(battler, TRUE)
&& !(gBattleTypeFlags & (BATTLE_TYPE_ARENA | BATTLE_TYPE_PALACE))
&& AI_THINKING_STRUCT->aiFlags & (AI_FLAG_CHECK_VIABILITY | AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_PREFER_BATON_PASS))
{
// Consider switching if all moves are worthless to use.
if (GetTotalBaseStat(gBattleMons[battlerId].species) >= 310 // Mon is not weak.
&& gBattleMons[battlerId].hp >= gBattleMons[battlerId].maxHP / 2) // Mon has more than 50% of its HP
if (GetTotalBaseStat(gBattleMons[battler].species) >= 310 // Mon is not weak.
&& gBattleMons[battler].hp >= gBattleMons[battler].maxHP / 2) // Mon has more than 50% of its HP
{
s32 cap = AI_THINKING_STRUCT->aiFlags & (AI_FLAG_CHECK_VIABILITY) ? 95 : 93;
if (doubleBattle)
{
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (i != battlerId && IsBattlerAlive(i))
if (i != battler && IsBattlerAlive(i))
{
for (j = 0; j < MAX_MON_MOVES; j++)
{
if (gBattleStruct->aiFinalScore[battlerId][i][j] > cap)
if (gBattleStruct->aiFinalScore[battler][i][j] > cap)
break;
}
if (j != MAX_MON_MOVES)
break;
}
}
if (i == MAX_BATTLERS_COUNT && AI_SwitchMonIfSuitable(battlerId))
if (i == MAX_BATTLERS_COUNT && AI_SwitchMonIfSuitable(battler))
return TRUE;
}
else
@ -451,7 +451,7 @@ static bool32 AI_ShouldSwitchIfBadMoves(u32 battlerId, bool32 doubleBattle)
break;
}
if (i == MAX_MON_MOVES && AI_SwitchMonIfSuitable(battlerId))
if (i == MAX_MON_MOVES && AI_SwitchMonIfSuitable(battler))
return TRUE;
}
@ -459,11 +459,11 @@ static bool32 AI_ShouldSwitchIfBadMoves(u32 battlerId, bool32 doubleBattle)
// Consider switching if your mon with truant is bodied by Protect spam.
// Or is using a double turn semi invulnerable move(such as Fly) and is faster.
if (GetBattlerAbility(battlerId) == ABILITY_TRUANT
&& IsTruantMonVulnerable(battlerId, gBattlerTarget)
&& gDisableStructs[battlerId].truantCounter
&& gBattleMons[battlerId].hp >= gBattleMons[battlerId].maxHP / 2
&& AI_SwitchMonIfSuitable(battlerId))
if (GetBattlerAbility(battler) == ABILITY_TRUANT
&& IsTruantMonVulnerable(battler, gBattlerTarget)
&& gDisableStructs[battler].truantCounter
&& gBattleMons[battler].hp >= gBattleMons[battler].maxHP / 2
&& AI_SwitchMonIfSuitable(battler))
{
return TRUE;
}
@ -502,8 +502,6 @@ static u8 ChooseMoveOrAction_Singles(void)
if (AI_THINKING_STRUCT->aiAction & AI_ACTION_WATCH)
return AI_CHOICE_WATCH;
gActiveBattler = sBattler_AI;
// Switch mon if there are no good moves to use.
if (AI_ShouldSwitchIfBadMoves(sBattler_AI, FALSE))
return AI_CHOICE_SWITCH;
@ -556,9 +554,9 @@ static u8 ChooseMoveOrAction_Doubles(void)
else
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4);
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4, sBattler_AI);
else
BattleAI_SetupAIData(0xF);
BattleAI_SetupAIData(0xF, sBattler_AI);
gBattlerTarget = i;
if ((i & BIT_SIDE) != (sBattler_AI & BIT_SIDE))
@ -3761,7 +3759,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
}
break;
case EFFECT_BATON_PASS:
if (ShouldSwitch() && (gBattleMons[battlerAtk].status2 & STATUS2_SUBSTITUTE
if (ShouldSwitch(battlerAtk) && (gBattleMons[battlerAtk].status2 & STATUS2_SUBSTITUTE
|| (gStatuses3[battlerAtk] & (STATUS3_ROOTED | STATUS3_AQUA_RING | STATUS3_MAGNET_RISE | STATUS3_POWER_TRICK))
|| AnyStatIsRaised(battlerAtk)))
score += 5;

File diff suppressed because it is too large Load Diff

View File

@ -2563,14 +2563,11 @@ enum {
bool32 ShouldPivot(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u8 moveIndex)
{
bool8 hasStatBoost = AnyUsefulStatIsRaised(battlerAtk) || gBattleMons[battlerDef].statStages[STAT_EVASION] >= 9; //Significant boost in evasion for any class
u8 backupBattler = gActiveBattler;
bool32 shouldSwitch;
u8 battlerToSwitch;
gActiveBattler = battlerAtk;
shouldSwitch = ShouldSwitch();
battlerToSwitch = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler);
gActiveBattler = backupBattler;
shouldSwitch = ShouldSwitch(battlerAtk);
battlerToSwitch = *(gBattleStruct->AI_monToSwitchIntoId + battlerAtk);
if (PartyBattlerShouldAvoidHazards(battlerAtk, battlerToSwitch))
return DONT_PIVOT;
@ -3322,7 +3319,7 @@ bool32 ShouldUseWishAromatherapy(u8 battlerAtk, u8 battlerDef, u16 move)
GetAIPartyIndexes(battlerAtk, &firstId, &lastId);
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerAtk) == B_SIDE_PLAYER)
party = gPlayerParty;
else
party = gEnemyParty;

View File

@ -435,30 +435,25 @@ static void Cmd_unloadspritegfx(void)
static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
{
u8 numTargets = 1;
u8 numTargets = 0;
int idx = 0;
u32 battler = gBattleAnimArgs[battlerArgIndex];
switch (GetBattlerMoveTargetType(gBattleAnimAttacker, gAnimMoveIndex))
{
case MOVE_TARGET_BOTH:
targets[0] = gBattleAnimArgs[battlerArgIndex];
numTargets = 1;
if (IsBattlerAlive(BATTLE_PARTNER(targets[0])))
{
targets[1] = BATTLE_PARTNER(targets[0]);
numTargets = 2;
}
break;
case MOVE_TARGET_FOES_AND_ALLY:
targets[0] = gBattleAnimArgs[battlerArgIndex];
numTargets = 1;
if (IsBattlerAlive(BATTLE_PARTNER(targets[0])))
{
targets[1] = BATTLE_PARTNER(targets[0]);
if (IS_ALIVE_AND_PRESENT(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)))) {
targets[idx++] = BATTLE_PARTNER(BATTLE_OPPOSITE(battler));
numTargets++;
}
if (IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(targets[0]))))
{
targets[2] = BATTLE_PARTNER(BATTLE_OPPOSITE(targets[0]));
// fallthrough
case MOVE_TARGET_BOTH:
if (IS_ALIVE_AND_PRESENT(battler)) {
targets[idx++] = battler;
numTargets++;
}
battler = BATTLE_PARTNER(battler);
if (IS_ALIVE_AND_PRESENT(battler)) {
targets[idx++] = battler;
numTargets++;
}
break;
@ -551,6 +546,8 @@ static void CreateSpriteOnTargets(const struct SpriteTemplate *template, u8 argV
subpriority = GetSubpriorityForMoveAnim(argVar);
ntargets = GetBattleAnimMoveTargets(battlerArgIndex, targets);
if (ntargets == 0)
return;
for (i = 0; i < ntargets; i++) {
@ -676,6 +673,8 @@ static void Cmd_createvisualtaskontargets(void)
}
numArgs = GetBattleAnimMoveTargets(battlerArgIndex, targets);
if (numArgs == 0)
return;
for (i = 0; i < numArgs; i++)
{

View File

@ -370,7 +370,7 @@ static void LinkOpponentBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else

View File

@ -196,7 +196,7 @@ static void LinkPartnerBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else

View File

@ -387,7 +387,7 @@ static void OpponentBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
@ -511,7 +511,7 @@ static void OpponentHandlePrintString(u32 battler)
static void OpponentHandleChooseAction(u32 battler)
{
AI_TrySwitchOrUseItem();
AI_TrySwitchOrUseItem(battler);
OpponentBufferExecCompleted(battler);
}
@ -525,7 +525,7 @@ static void OpponentHandleChooseMove(u32 battler)
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace(battler));
}
else
{
@ -534,16 +534,16 @@ static void OpponentHandleChooseMove(u32 battler)
switch (chosenMoveId)
{
case AI_CHOICE_WATCH:
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
break;
case AI_CHOICE_FLEE:
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_RUN, 0);
break;
case AI_CHOICE_SWITCH:
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0xFFFF);
break;
case 6:
BtlController_EmitTwoReturnValues(BUFFER_B, 15, gBattlerTarget);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 15, gBattlerTarget);
break;
default:
{
@ -560,11 +560,11 @@ static void OpponentHandleChooseMove(u32 battler)
if (ShouldUseZMove(battler, gBattlerTarget, chosenMove))
QueueZMove(battler, chosenMove);
if (CanMegaEvolve(battler)) // If opponent can mega evolve, do it.
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
else if (CanUltraBurst(gActiveBattler))
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_ULTRA_BURST) | (gBattlerTarget << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
else if (CanUltraBurst(battler))
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_ULTRA_BURST) | (gBattlerTarget << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
}
break;
}
@ -582,7 +582,7 @@ static void OpponentHandleChooseMove(u32 battler)
} while (move == MOVE_NONE);
if (GetBattlerMoveTargetType(battler, move) & (MOVE_TARGET_USER_OR_SELECTED | MOVE_TARGET_USER))
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (battler << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (battler << 8));
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
do {
@ -616,16 +616,16 @@ static void OpponentHandleChooseMove(u32 battler)
}
}
if (isPartnerEnemy && CanTargetBattler(battler, target, move))
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(battler)) << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(BATTLE_PARTNER(battler)) << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (target << 8));
}
else
#endif
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (target << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (target << 8));
}
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
OpponentBufferExecCompleted(battler);
}
@ -633,7 +633,7 @@ static void OpponentHandleChooseMove(u32 battler)
static void OpponentHandleChooseItem(u32 battler)
{
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
BtlController_EmitOneReturnValue(battler, BUFFER_B, gBattleStruct->chosenItem[battler]);
OpponentBufferExecCompleted(battler);
}
@ -650,7 +650,7 @@ static void OpponentHandleChoosePokemon(u32 battler)
// Switching out
else if (*(gBattleStruct->AI_monToSwitchIntoId + battler) == PARTY_SIZE)
{
chosenMonId = GetMostSuitableMonToSwitchInto();
chosenMonId = GetMostSuitableMonToSwitchInto(battler);
if (chosenMonId == PARTY_SIZE)
{
s32 battler1, battler2, firstId, lastId;
@ -689,7 +689,7 @@ static void OpponentHandleChoosePokemon(u32 battler)
*(gBattleStruct->AI_monToSwitchIntoId + battler) = PARTY_SIZE;
*(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId;
}
BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, chosenMonId, NULL);
OpponentBufferExecCompleted(battler);
}

View File

@ -173,7 +173,7 @@ static void PlayerBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
@ -303,7 +303,7 @@ static void HandleInputChooseAction(u32 battler)
PlaySE(SE_SELECT);
ArrowsChangeColorLastBallCycle(FALSE);
TryHideLastUsedBall();
BtlController_EmitTwoReturnValues(1, B_ACTION_THROW_BALL, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_THROW_BALL, 0);
PlayerBufferExecCompleted(battler);
}
return;
@ -318,16 +318,16 @@ static void HandleInputChooseAction(u32 battler)
switch (gActionSelectionCursor[battler])
{
case 0: // Top left
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_MOVE, 0);
break;
case 1: // Top right
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_ITEM, 0);
break;
case 2: // Bottom left
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SWITCH, 0);
break;
case 3: // Bottom right
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_RUN, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_RUN, 0);
break;
}
PlayerBufferExecCompleted(battler);
@ -385,7 +385,7 @@ static void HandleInputChooseAction(u32 battler)
AddBagItem(itemId, 1);
}
PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_CANCEL_PARTNER, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_CANCEL_PARTNER, 0);
PlayerBufferExecCompleted(battler);
}
}
@ -396,7 +396,7 @@ static void HandleInputChooseAction(u32 battler)
#if DEBUG_BATTLE_MENU == TRUE
else if (JOY_NEW(SELECT_BUTTON))
{
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_DEBUG, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_DEBUG, 0);
PlayerBufferExecCompleted(battler);
}
#endif
@ -405,7 +405,7 @@ static void HandleInputChooseAction(u32 battler)
{
PlaySE(SE_SELECT);
TryHideLastUsedBall();
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_THROW_BALL, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_THROW_BALL, 0);
PlayerBufferExecCompleted(battler);
}
#endif
@ -435,11 +435,11 @@ static void HandleInputChooseTarget(u32 battler)
PlaySE(SE_SELECT);
gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCB_HideAsMoveTarget;
if (gBattleStruct->mega.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
else if (gBattleStruct->burst.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX);
TryHideLastUsedBall();
HideTriggerSprites();
@ -595,11 +595,11 @@ static void HandleInputShowEntireFieldTargets(u32 battler)
PlaySE(SE_SELECT);
HideAllTargets();
if (gBattleStruct->mega.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
else if (gBattleStruct->burst.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
HideTriggerSprites();
PlayerBufferExecCompleted(battler);
}
@ -625,11 +625,11 @@ static void HandleInputShowTargets(u32 battler)
PlaySE(SE_SELECT);
HideShownTargets(battler);
if (gBattleStruct->mega.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
else if (gBattleStruct->burst.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
HideTriggerSprites();
TryHideLastUsedBall();
PlayerBufferExecCompleted(battler);
@ -644,12 +644,12 @@ static void HandleInputShowTargets(u32 battler)
}
}
static void TryShowAsTarget(u32 battlerId)
static void TryShowAsTarget(u32 battler)
{
if (IsBattlerAlive(battlerId))
if (IsBattlerAlive(battler))
{
DoBounceEffect(battlerId, BOUNCE_HEALTHBOX, 15, 1);
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCB_ShowAsMoveTarget;
DoBounceEffect(battler, BOUNCE_HEALTHBOX, 15, 1);
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_ShowAsMoveTarget;
}
}
@ -710,7 +710,7 @@ static void HandleInputChooseMove(u32 battler)
{
canSelectTarget = 0;
}
else if (!(moveTarget & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED)) && CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) <= 1)
else if (!(moveTarget & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED)) && CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_BATTLER, battler) <= 1)
{
gMultiUsePlayerCursor = GetDefaultMoveTarget(battler);
canSelectTarget = 0;
@ -742,11 +742,11 @@ static void HandleInputChooseMove(u32 battler)
case 0:
default:
if (gBattleStruct->mega.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8));
else if (gBattleStruct->burst.playerSelect)
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_ULTRA_BURST | (gMultiUsePlayerCursor << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
HideTriggerSprites();
TryHideLastUsedBall();
PlayerBufferExecCompleted(battler);
@ -783,7 +783,7 @@ static void HandleInputChooseMove(u32 battler)
gBattleStruct->mega.playerSelect = FALSE;
gBattleStruct->burst.playerSelect = FALSE;
gBattleStruct->zmove.viable = FALSE;
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0xFFFF);
HideTriggerSprites();
PlayerBufferExecCompleted(battler);
}
@ -866,7 +866,7 @@ static void HandleInputChooseMove(u32 battler)
ChangeMegaTriggerSprite(gBattleStruct->mega.triggerSpriteId, gBattleStruct->mega.playerSelect);
PlaySE(SE_SELECT);
}
else if (CanUltraBurst(gActiveBattler))
else if (CanUltraBurst(battler))
{
gBattleStruct->burst.playerSelect ^= 1;
ChangeBurstTriggerSprite(gBattleStruct->burst.triggerSpriteId, gBattleStruct->burst.playerSelect);
@ -878,7 +878,7 @@ static void HandleInputChooseMove(u32 battler)
//TODO: brighten z move symbol
PlaySE(SE_SELECT);
if (!gBattleStruct->zmove.viewing)
MoveSelectionDisplayZMove(gBattleStruct->zmove.chosenZMove);
MoveSelectionDisplayZMove(gBattleStruct->zmove.chosenZMove, battler);
else
ReloadMoveNames(battler);
}
@ -1398,12 +1398,11 @@ static s32 GetTaskExpValue(u8 taskId)
static void Task_GiveExpToMon(u8 taskId)
{
u32 savedActiveBattler;
u32 monId = (u8)(gTasks[taskId].tExpTask_monId);
u8 battlerId = gTasks[taskId].tExpTask_battler;
u8 battler = gTasks[taskId].tExpTask_battler;
s32 gainedExp = GetTaskExpValue(taskId);
if (WhichBattleCoords(battlerId) == 1 || monId != gBattlerPartyIndexes[battlerId]) // Give exp without moving the expbar.
if (WhichBattleCoords(battler) == 1 || monId != gBattlerPartyIndexes[battler]) // Give exp without moving the expbar.
{
struct Pokemon *mon = &gPlayerParty[monId];
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -1416,13 +1415,10 @@ static void Task_GiveExpToMon(u8 taskId)
SetMonData(mon, MON_DATA_EXP, &nextLvlExp);
CalculateMonStats(mon);
gainedExp -= nextLvlExp - currExp;
savedActiveBattler = gActiveBattler;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
gActiveBattler = savedActiveBattler;
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
if (IsDoubleBattle() == TRUE
&& (monId == gBattlerPartyIndexes[battlerId] || monId == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]))
&& (monId == gBattlerPartyIndexes[battler] || monId == gBattlerPartyIndexes[BATTLE_PARTNER(battler)]))
gTasks[taskId].func = Task_LaunchLvlUpAnim;
else
gTasks[taskId].func = Task_SetControllerToWaitForString;
@ -1431,7 +1427,7 @@ static void Task_GiveExpToMon(u8 taskId)
{
currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
gBattlerControllerFuncs[battler] = Controller_WaitForString;
DestroyTask(taskId);
}
}
@ -1445,7 +1441,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
s32 gainedExp = GetTaskExpValue(taskId);
u8 battlerId = gTasks[taskId].tExpTask_battler;
u8 battler = gTasks[taskId].tExpTask_battler;
struct Pokemon *mon = &gPlayerParty[monIndex];
u8 level = GetMonData(mon, MON_DATA_LEVEL);
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -1455,7 +1451,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
exp -= currLvlExp;
expToNextLvl = gExperienceTables[gSpeciesInfo[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP);
gTasks[taskId].func = Task_GiveExpWithExpBar;
}
@ -1474,10 +1470,10 @@ static void Task_GiveExpWithExpBar(u8 taskId)
{
u8 monId = gTasks[taskId].tExpTask_monId;
s32 gainedExp = GetTaskExpValue(taskId);
u8 battlerId = gTasks[taskId].tExpTask_battler;
u8 battler = gTasks[taskId].tExpTask_battler;
newExpPoints = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
newExpPoints = MoveBattleBar(battler, gHealthboxSpriteIds[battler], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battler]);
if (newExpPoints == -1) // The bar has been filled with given exp points.
{
m4aSongNumStop(SE_EXP);
@ -1488,22 +1484,17 @@ static void Task_GiveExpWithExpBar(u8 taskId)
if (currExp + gainedExp >= expOnNextLvl)
{
u8 savedActiveBattler;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &expOnNextLvl);
CalculateMonStats(&gPlayerParty[monId]);
gainedExp -= expOnNextLvl - currExp;
savedActiveBattler = gActiveBattler;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
gActiveBattler = savedActiveBattler;
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
gTasks[taskId].func = Task_LaunchLvlUpAnim;
}
else
{
currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
gBattlerControllerFuncs[battler] = Controller_WaitForString;
DestroyTask(taskId);
}
}
@ -1512,28 +1503,28 @@ static void Task_GiveExpWithExpBar(u8 taskId)
static void Task_LaunchLvlUpAnim(u8 taskId)
{
u8 battlerId = gTasks[taskId].tExpTask_battler;
u8 battler = gTasks[taskId].tExpTask_battler;
u8 monIndex = gTasks[taskId].tExpTask_monId;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)])
battlerId ^= BIT_FLANK;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battler)])
battler ^= BIT_FLANK;
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_LVL_UP);
gTasks[taskId].func = Task_UpdateLvlInHealthbox;
}
static void Task_UpdateLvlInHealthbox(u8 taskId)
{
u8 battlerId = gTasks[taskId].tExpTask_battler;
u8 battler = gTasks[taskId].tExpTask_battler;
if (!gBattleSpritesDataPtr->healthBoxesData[battlerId].specialAnimActive)
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)])
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battlerId)], &gPlayerParty[monIndex], HEALTHBOX_ALL);
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[BATTLE_PARTNER(battler)])
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(battler)], &gPlayerParty[monIndex], HEALTHBOX_ALL);
else
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[monIndex], HEALTHBOX_ALL);
gTasks[taskId].func = Task_SetControllerToWaitForString;
}
@ -1541,8 +1532,8 @@ static void Task_UpdateLvlInHealthbox(u8 taskId)
static void Task_SetControllerToWaitForString(u8 taskId)
{
u8 battlerId = gTasks[taskId].tExpTask_battler;
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
u8 battler = gTasks[taskId].tExpTask_battler;
gBattlerControllerFuncs[battler] = Controller_WaitForString;
DestroyTask(taskId);
}
@ -1565,9 +1556,9 @@ static void WaitForMonSelection(u32 battler)
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
if (gPartyMenuUseExitCallback == TRUE)
BtlController_EmitChosenMonReturnValue(BUFFER_B, gSelectedMonPartyId, gBattlePartyCurrentOrder);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, gSelectedMonPartyId, gBattlePartyCurrentOrder);
else
BtlController_EmitChosenMonReturnValue(BUFFER_B, PARTY_SIZE, NULL);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, PARTY_SIZE, NULL);
if ((gBattleResources->bufferA[battler][1] & 0xF) == 1)
PrintLinkStandbyMsg();
@ -1591,7 +1582,7 @@ static void CompleteWhenChoseItem(u32 battler)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
BtlController_EmitOneReturnValue(battler, BUFFER_B, gSpecialVar_ItemId);
PlayerBufferExecCompleted(battler);
}
}
@ -1618,9 +1609,9 @@ static void PlayerHandleYesNoInput(u32 battler)
PlaySE(SE_SELECT);
if (gMultiUsePlayerCursor != 0)
BtlController_EmitTwoReturnValues(BUFFER_B, 0xE, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 0xE, 0);
else
BtlController_EmitTwoReturnValues(BUFFER_B, 0xD, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 0xD, 0);
PlayerBufferExecCompleted(battler);
}
@ -1663,7 +1654,7 @@ static void MoveSelectionDisplayPpNumber(u32 battler)
if (gBattleResources->bufferA[battler][2] == TRUE) // check if we didn't want to display pp number
return;
SetPpNumbersPaletteInMoveSelection();
SetPpNumbersPaletteInMoveSelection(battler);
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, moveInfo->currentPp[gMoveSelectionCursor[battler]], STR_CONV_MODE_RIGHT_ALIGN, 2);
*(txtPtr)++ = CHAR_SLASH;
@ -1915,6 +1906,7 @@ static void PlayerHandleChooseAction(u32 battler)
TryRestoreLastUsedBall();
ActionSelectionCreateCursorAt(gActionSelectionCursor[battler], 0);
PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, battler, gBattlerPartyIndexes[battler]);
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT);
}
@ -1952,7 +1944,7 @@ static void PlayerChooseMoveInBattlePalace(u32 battler)
if (--*(gBattleStruct->arenaMindPoints + battler) == 0)
{
gBattlePalaceMoveSelectionRngValue = gRngValue;
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace(battler));
PlayerBufferExecCompleted(battler);
}
}
@ -2021,7 +2013,7 @@ static void PlayerHandleChoosePokemon(u32 battler)
if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleResources->bufferA[battler][1] & 0xF) != PARTY_ACTION_CANT_SWITCH
&& (gBattleResources->bufferA[battler][1] & 0xF) != PARTY_ACTION_CHOOSE_FAINTED_MON)
{
BtlController_EmitChosenMonReturnValue(BUFFER_B, gBattlerPartyIndexes[battler] + 1, gBattlePartyCurrentOrder);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, gBattlerPartyIndexes[battler] + 1, gBattlePartyCurrentOrder);
PlayerBufferExecCompleted(battler);
}
else
@ -2120,25 +2112,25 @@ static void PlayerHandlePlayBGM(u32 battler)
static void PlayerHandleTwoReturnValues(u32 battler)
{
BtlController_EmitTwoReturnValues(BUFFER_B, 0, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 0, 0);
PlayerBufferExecCompleted(battler);
}
static void PlayerHandleChosenMonReturnValue(u32 battler)
{
BtlController_EmitChosenMonReturnValue(BUFFER_B, 0, NULL);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, 0, NULL);
PlayerBufferExecCompleted(battler);
}
static void PlayerHandleOneReturnValue(u32 battler)
{
BtlController_EmitOneReturnValue(BUFFER_B, 0);
BtlController_EmitOneReturnValue(battler, BUFFER_B, 0);
PlayerBufferExecCompleted(battler);
}
static void PlayerHandleOneReturnValue_Duplicate(u32 battler)
{
BtlController_EmitOneReturnValue_Duplicate(BUFFER_B, 0);
BtlController_EmitOneReturnValue_Duplicate(battler, BUFFER_B, 0);
PlayerBufferExecCompleted(battler);
}

View File

@ -267,7 +267,7 @@ static void PlayerPartnerBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
@ -346,7 +346,7 @@ static void PlayerPartnerHandlePrintString(u32 battler)
static void PlayerPartnerHandleChooseAction(u32 battler)
{
AI_TrySwitchOrUseItem();
AI_TrySwitchOrUseItem(battler);
PlayerPartnerBufferExecCompleted(battler);
}
@ -360,7 +360,7 @@ static void PlayerPartnerHandleChooseMove(u32 battler)
if (chosenMoveId == AI_CHOICE_SWITCH)
{
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0xFFFF);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0xFFFF);
}
else
{
@ -378,11 +378,11 @@ static void PlayerPartnerHandleChooseMove(u32 battler)
// If partner can mega evolve, do it.
if (CanMegaEvolve(battler))
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_MEGA_EVOLUTION) | (gBattlerTarget << 8));
else if (CanUltraBurst(battler))
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (RET_ULTRA_BURST) | (gBattlerTarget << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (RET_ULTRA_BURST) | (gBattlerTarget << 8));
else
BtlController_EmitTwoReturnValues(BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, (chosenMoveId) | (gBattlerTarget << 8));
}
PlayerPartnerBufferExecCompleted(battler);
@ -399,7 +399,7 @@ static void PlayerPartnerHandleChoosePokemon(u32 battler)
// Switching out
else if (gBattleStruct->monToSwitchIntoId[battler] == PARTY_SIZE)
{
chosenMonId = GetMostSuitableMonToSwitchInto();
chosenMonId = GetMostSuitableMonToSwitchInto(battler);
if (chosenMonId == PARTY_SIZE) // just switch to the next mon
{
u8 playerMonIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
@ -420,10 +420,10 @@ static void PlayerPartnerHandleChoosePokemon(u32 battler)
else // Mon to switch out has been already chosen.
{
chosenMonId = gBattleStruct->monToSwitchIntoId[battler];
*(gBattleStruct->AI_monToSwitchIntoId + battler) = PARTY_SIZE;
*(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId;
gBattleStruct->AI_monToSwitchIntoId[battler] = PARTY_SIZE;
gBattleStruct->monToSwitchIntoId[battler] = chosenMonId;
}
BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, chosenMonId, NULL);
PlayerPartnerBufferExecCompleted(battler);
}

View File

@ -140,7 +140,7 @@ static void RecordedOpponentBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
@ -404,7 +404,7 @@ static void RecordedOpponentHandleDrawTrainerPic(u32 battler)
}
else
{
trainerPicId = PlayerGenderToFrontTrainerPicId(GetActiveBattlerLinkPlayerGender());
trainerPicId = PlayerGenderToFrontTrainerPicId(GetBattlerLinkPlayerGender(battler));
}
}
else
@ -442,7 +442,7 @@ static void RecordedOpponentHandlePrintString(u32 battler)
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
BufferStringBattle(*stringId);
BufferStringBattle(*stringId, battler);
if (gTestRunnerEnabled)
{
@ -460,7 +460,7 @@ static void RecordedOpponentHandlePrintString(u32 battler)
static void RecordedOpponentHandleChooseAction(u32 battler)
{
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
RecordedOpponentBufferExecCompleted(battler);
}
@ -468,13 +468,13 @@ static void RecordedOpponentHandleChooseMove(u32 battler)
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace(battler));
}
else
{
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, battler);
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, battler);
BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, moveId | (target << 8));
}
RecordedOpponentBufferExecCompleted(battler);
@ -487,7 +487,7 @@ static void RecordedOpponentHandleChooseItem(u32 battler)
gBattleStruct->chosenItem[battler] = (byte1 << 8) | byte2;
gBattleStruct->itemPartyIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, battler);
gBattleStruct->itemMoveIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, battler);
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
BtlController_EmitOneReturnValue(battler, BUFFER_B, gBattleStruct->chosenItem[battler]);
RecordedOpponentBufferExecCompleted(battler);
}
@ -495,7 +495,7 @@ static void RecordedOpponentHandleChoosePokemon(u32 battler)
{
*(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler);
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
RecordedOpponentBufferExecCompleted(battler);
}

View File

@ -346,7 +346,7 @@ static void RecordedPlayerBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
@ -374,7 +374,7 @@ static void RecordedPlayerHandleDrawTrainerPic(u32 battler)
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
trainerPicId = GetActiveBattlerLinkPlayerGender();
trainerPicId = GetBattlerLinkPlayerGender(battler);
else
trainerPicId = gLinkPlayers[gRecordedBattleMultiplayerId].gender;
}
@ -432,7 +432,7 @@ static void RecordedPlayerHandlePrintString(u32 battler)
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
BufferStringBattle(*stringId);
BufferStringBattle(*stringId, battler);
if (gTestRunnerEnabled)
{
@ -452,7 +452,7 @@ static void ChooseActionInBattlePalace(u32 battler)
{
if (gBattleCommunication[4] >= gBattlersCount / 2)
{
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_BATTLE_PALACE_ACTION, battler), 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_BATTLE_PALACE_ACTION, battler), 0);
RecordedPlayerBufferExecCompleted(battler);
}
}
@ -465,7 +465,7 @@ static void RecordedPlayerHandleChooseAction(u32 battler)
}
else
{
BtlController_EmitTwoReturnValues(BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RecordedBattle_GetBattlerAction(RECORDED_ACTION_TYPE, battler), 0);
RecordedPlayerBufferExecCompleted(battler);
}
}
@ -474,13 +474,13 @@ static void RecordedPlayerHandleChooseMove(u32 battler)
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
BtlController_EmitTwoReturnValues(BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace());
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace(battler));
}
else
{
u8 moveId = RecordedBattle_GetBattlerAction(RECORDED_MOVE_SLOT, battler);
u8 target = RecordedBattle_GetBattlerAction(RECORDED_MOVE_TARGET, battler);
BtlController_EmitTwoReturnValues(BUFFER_B, 10, moveId | (target << 8));
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, moveId | (target << 8));
}
RecordedPlayerBufferExecCompleted(battler);
@ -493,7 +493,7 @@ static void RecordedPlayerHandleChooseItem(u32 battler)
gBattleStruct->chosenItem[battler] = (byte1 << 8) | byte2;
gBattleStruct->itemPartyIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, battler);
gBattleStruct->itemMoveIndex[battler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, battler);
BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[battler]);
BtlController_EmitOneReturnValue(battler, BUFFER_B, gBattleStruct->chosenItem[battler]);
RecordedPlayerBufferExecCompleted(battler);
}
@ -501,7 +501,7 @@ static void RecordedPlayerHandleChoosePokemon(u32 battler)
{
*(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler);
gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing
BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL);
RecordedPlayerBufferExecCompleted(battler);
}

View File

@ -130,16 +130,16 @@ static void HandleInputChooseAction(u32 battler)
switch (gActionSelectionCursor[battler])
{
case 0:
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_BALL, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_BALL, 0);
break;
case 1:
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_POKEBLOCK, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_POKEBLOCK, 0);
break;
case 2:
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_GO_NEAR, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_GO_NEAR, 0);
break;
case 3:
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SAFARI_RUN, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_SAFARI_RUN, 0);
break;
}
SafariBufferExecCompleted(battler);
@ -216,7 +216,7 @@ static void CompleteWhenChosePokeblock(u32 battler)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
BtlController_EmitOneReturnValue(battler, BUFFER_B, gSpecialVar_ItemId);
SafariBufferExecCompleted(battler);
}
}
@ -228,7 +228,7 @@ static void SafariBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else

View File

@ -149,7 +149,7 @@ static void WallyHandleActions(u32 battler)
if (--gBattleStruct->wallyWaitFrames == 0)
{
PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_MOVE, 0);
WallyBufferExecCompleted(battler);
gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0;
@ -160,7 +160,7 @@ static void WallyHandleActions(u32 battler)
if (--gBattleStruct->wallyWaitFrames == 0)
{
PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_MOVE, 0);
WallyBufferExecCompleted(battler);
gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0;
@ -170,7 +170,7 @@ static void WallyHandleActions(u32 battler)
case 3:
if (--gBattleStruct->wallyWaitFrames == 0)
{
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_WALLY_THROW, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_WALLY_THROW, 0);
WallyBufferExecCompleted(battler);
gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0;
@ -191,7 +191,7 @@ static void WallyHandleActions(u32 battler)
if (--gBattleStruct->wallyWaitFrames == 0)
{
PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, B_ACTION_USE_ITEM, 0);
WallyBufferExecCompleted(battler);
}
break;
@ -213,7 +213,7 @@ static void CompleteOnChosenItem(u32 battler)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
BtlController_EmitOneReturnValue(BUFFER_B, gSpecialVar_ItemId);
BtlController_EmitOneReturnValue(battler, BUFFER_B, gSpecialVar_ItemId);
WallyBufferExecCompleted(battler);
}
}
@ -283,7 +283,7 @@ static void WallyBufferExecCompleted(u32 battler)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
PrepareBufferDataTransferLink(battler, 2, 4, &playerId);
gBattleResources->bufferA[battler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
@ -382,7 +382,7 @@ static void WallyHandleChooseMove(u32 battler)
if (--gBattleStruct->wallyMoveFrames == 0)
{
PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(BUFFER_B, 10, 0x100);
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0x100);
WallyBufferExecCompleted(battler);
}
break;

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,8 @@ extern const struct CompressedSpriteSheet gSpriteSheet_EnemyShadow;
extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;
// this file's functions
static u8 GetBattlePalaceMoveGroup(u8 battlerId, u16 move);
static u16 GetBattlePalaceTarget(void);
static u8 GetBattlePalaceMoveGroup(u8 battler, u16 move);
static u16 GetBattlePalaceTarget(u32 battler);
static void SpriteCB_TrainerSlideVertical(struct Sprite *sprite);
static bool8 ShouldAnimBeDoneRegardlessOfSubstitute(u8 animId);
static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId);
@ -104,12 +104,12 @@ void FreeBattleSpritesData(void)
}
// Pokemon chooses move to use in Battle Palace rather than player
u16 ChooseMoveAndTargetInBattlePalace(void)
u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
{
s32 i, var1, var2;
s32 chosenMoveId = -1;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, MOVE_LIMITATIONS_ALL);
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
u8 unusableMovesBits = CheckMoveLimitations(battler, 0, MOVE_LIMITATIONS_ALL);
s32 percent = Random() % 100;
// Heavy variable re-use here makes this hard to read without defines
@ -125,7 +125,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
// If battler is < 50% HP and not asleep, use second set of move group likelihoods
// otherwise use first set
i = (gBattleStruct->palaceFlags & gBitTable[gActiveBattler]) ? 2 : 0;
i = (gBattleStruct->palaceFlags & gBitTable[battler]) ? 2 : 0;
minGroupNum = i;
maxGroupNum = i + 2; // + 2 because there are two percentages per set of likelihoods
@ -136,7 +136,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
// Otherwise use move from "Support" group
for (; i < maxGroupNum; i++)
{
if (gBattlePalaceNatureToMoveGroupLikelihood[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)][i] > percent)
if (gBattlePalaceNatureToMoveGroupLikelihood[GetNatureFromPersonality(gBattleMons[battler].personality)][i] > percent)
break;
}
selectedGroup = i - minGroupNum;
@ -148,7 +148,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
{
if (moveInfo->moves[i] == MOVE_NONE)
break;
if (selectedGroup == GetBattlePalaceMoveGroup(gActiveBattler, moveInfo->moves[i]) && moveInfo->currentPp[i] != 0)
if (selectedGroup == GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) && moveInfo->currentPp[i] != 0)
selectedMoves |= gBitTable[i];
}
@ -159,8 +159,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
// Clear the rest of palaceFlags, then set the selected moves in the upper 4 bits.
gBattleStruct->palaceFlags &= (1 << MAX_BATTLERS_COUNT) - 1;
gBattleStruct->palaceFlags |= (selectedMoves << MAX_BATTLERS_COUNT);
sBattler_AI = gActiveBattler;
BattleAI_SetupAIData(selectedMoves);
BattleAI_SetupAIData(selectedMoves, battler);
chosenMoveId = BattleAI_ChooseMoveOrAction();
}
@ -178,11 +177,11 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
{
// Count the number of usable moves the battler has in each move group.
// The totals will be stored separately in 3 groups of 4 bits each in numMovesPerGroup.
if (GetBattlePalaceMoveGroup(gActiveBattler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_ATTACK && !(gBitTable[i] & unusableMovesBits))
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_ATTACK && !(gBitTable[i] & unusableMovesBits))
numMovesPerGroup += (1 << 0);
if (GetBattlePalaceMoveGroup(gActiveBattler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_DEFENSE && !(gBitTable[i] & unusableMovesBits))
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_DEFENSE && !(gBitTable[i] & unusableMovesBits))
numMovesPerGroup += (1 << 4);
if (GetBattlePalaceMoveGroup(gActiveBattler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_SUPPORT && !(gBitTable[i] & unusableMovesBits))
if (GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]) == PALACE_MOVE_GROUP_SUPPORT && !(gBitTable[i] & unusableMovesBits))
numMovesPerGroup += (1 << 8);
}
@ -241,7 +240,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
do
{
i = Random() % MAX_MON_MOVES;
if (!(gBitTable[i] & unusableMovesBits) && randSelectGroup == GetBattlePalaceMoveGroup(gActiveBattler, moveInfo->moves[i]))
if (!(gBitTable[i] & unusableMovesBits) && randSelectGroup == GetBattlePalaceMoveGroup(battler, moveInfo->moves[i]))
chosenMoveId = i;
} while (chosenMoveId == -1);
}
@ -250,14 +249,14 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
// that it will be unable to use it. This could have been checked earlier to avoid the above work.
if (Random() % 100 >= 50)
{
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
return 0;
}
}
else
{
// All the battler's moves were flagged as unusable.
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
gProtectStructs[battler].palaceUnableToUseMove = TRUE;
return 0;
}
}
@ -271,15 +270,15 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
}
else
{
moveTarget = GetBattlerMoveTargetType(gActiveBattler, moveInfo->moves[chosenMoveId]);
moveTarget = GetBattlerMoveTargetType(battler, moveInfo->moves[chosenMoveId]);
}
if (moveTarget & MOVE_TARGET_USER)
chosenMoveId |= (gActiveBattler << 8);
chosenMoveId |= (battler << 8);
else if (moveTarget == MOVE_TARGET_SELECTED)
chosenMoveId |= GetBattlePalaceTarget();
chosenMoveId |= GetBattlePalaceTarget(battler);
else
chosenMoveId |= (GetBattlerAtPosition(BATTLE_OPPOSITE(GET_BATTLER_SIDE(gActiveBattler))) << 8);
chosenMoveId |= (GetBattlerAtPosition(BATTLE_OPPOSITE(GET_BATTLER_SIDE(battler))) << 8);
return chosenMoveId;
}
@ -293,9 +292,9 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
#undef numMultipleMoveGroups
#undef randSelectGroup
static u8 GetBattlePalaceMoveGroup(u8 battlerId, u16 move)
static u8 GetBattlePalaceMoveGroup(u8 battler, u16 move)
{
switch (GetBattlerMoveTargetType(battlerId, move))
switch (GetBattlerMoveTargetType(battler, move))
{
case MOVE_TARGET_SELECTED:
case MOVE_TARGET_USER_OR_SELECTED:
@ -317,13 +316,13 @@ static u8 GetBattlePalaceMoveGroup(u8 battlerId, u16 move)
}
}
static u16 GetBattlePalaceTarget(void)
static u16 GetBattlePalaceTarget(u32 battler)
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
u8 opposing1, opposing2;
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
opposing1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposing2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
@ -335,9 +334,9 @@ static u16 GetBattlePalaceTarget(void)
}
if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp)
return (BATTLE_OPPOSITE(gActiveBattler & BIT_SIDE) + (Random() & 2)) << 8;
return (BATTLE_OPPOSITE(battler & BIT_SIDE) + (Random() & 2)) << 8;
switch (gBattlePalaceNatureToMoveTarget[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)])
switch (gBattlePalaceNatureToMoveTarget[GetNatureFromPersonality(gBattleMons[battler].personality)])
{
case PALACE_TARGET_STRONGER:
if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp)
@ -350,11 +349,11 @@ static u16 GetBattlePalaceTarget(void)
else
return opposing2 << 8;
case PALACE_TARGET_RANDOM:
return (BATTLE_OPPOSITE(gActiveBattler & BIT_SIDE) + (Random() & 2)) << 8;
return (BATTLE_OPPOSITE(battler & BIT_SIDE) + (Random() & 2)) << 8;
}
}
return BATTLE_OPPOSITE(gActiveBattler) << 8;
return BATTLE_OPPOSITE(battler) << 8;
}
// Wait for the pokemon to finish appearing out from the pokeball on send out
@ -418,38 +417,38 @@ static void SpriteCB_TrainerSlideVertical(struct Sprite *sprite)
#undef sSpeedX
void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status)
void InitAndLaunchChosenStatusAnimation(u32 battler, bool32 isStatus2, u32 status)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 1;
gBattleSpritesDataPtr->healthBoxesData[battler].statusAnimActive = 1;
if (!isStatus2)
{
if (status == STATUS1_FREEZE || status == STATUS1_FROSTBITE)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_FRZ);
LaunchStatusAnimation(battler, B_ANIM_STATUS_FRZ);
else if (status == STATUS1_POISON || status & STATUS1_TOXIC_POISON)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_PSN);
LaunchStatusAnimation(battler, B_ANIM_STATUS_PSN);
else if (status == STATUS1_BURN)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_BRN);
LaunchStatusAnimation(battler, B_ANIM_STATUS_BRN);
else if (status & STATUS1_SLEEP)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_SLP);
LaunchStatusAnimation(battler, B_ANIM_STATUS_SLP);
else if (status == STATUS1_PARALYSIS)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_PRZ);
LaunchStatusAnimation(battler, B_ANIM_STATUS_PRZ);
else // no animation
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[battler].statusAnimActive = 0;
}
else
{
if (status & STATUS2_INFATUATION)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_INFATUATION);
LaunchStatusAnimation(battler, B_ANIM_STATUS_INFATUATION);
else if (status & STATUS2_CONFUSION)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_CONFUSION);
LaunchStatusAnimation(battler, B_ANIM_STATUS_CONFUSION);
else if (status & STATUS2_CURSED)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_CURSED);
LaunchStatusAnimation(battler, B_ANIM_STATUS_CURSED);
else if (status & STATUS2_NIGHTMARE)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_NIGHTMARE);
LaunchStatusAnimation(battler, B_ANIM_STATUS_NIGHTMARE);
else if (status & STATUS2_WRAPPED)
LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_WRAPPED); // this animation doesn't actually exist
LaunchStatusAnimation(battler, B_ANIM_STATUS_WRAPPED); // this animation doesn't actually exist
else // no animation
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[battler].statusAnimActive = 0;
}
}
@ -546,14 +545,14 @@ static void Task_ClearBitWhenSpecialAnimDone(u8 taskId)
#undef tBattlerId
// Check if SE has finished or 30 calls, whichever comes first
bool8 IsBattleSEPlaying(u8 battlerId)
bool8 IsBattleSEPlaying(u8 battler)
{
u8 zero = 0;
if (IsSEPlaying())
{
gBattleSpritesDataPtr->healthBoxesData[battlerId].soundTimer++;
if (gBattleSpritesDataPtr->healthBoxesData[battlerId].soundTimer < 30)
gBattleSpritesDataPtr->healthBoxesData[battler].soundTimer++;
if (gBattleSpritesDataPtr->healthBoxesData[battler].soundTimer < 30)
return TRUE;
m4aMPlayStop(&gMPlayInfo_SE1);
@ -561,7 +560,7 @@ bool8 IsBattleSEPlaying(u8 battlerId)
}
if (zero == 0)
{
gBattleSpritesDataPtr->healthBoxesData[battlerId].soundTimer = 0;
gBattleSpritesDataPtr->healthBoxesData[battler].soundTimer = 0;
return FALSE;
}
@ -569,11 +568,11 @@ bool8 IsBattleSEPlaying(u8 battlerId)
return TRUE;
}
void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId)
void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battler)
{
u32 monsPersonality, currentPersonality, otId, currentOtId, species, paletteOffset, position;
const void *lzPaletteData;
struct Pokemon *illusionMon = GetIllusionMonPtr(battlerId);
struct Pokemon *illusionMon = GetIllusionMonPtr(battler);
if (illusionMon != NULL)
mon = illusionMon;
@ -583,7 +582,7 @@ void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId)
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
otId = GetMonData(mon, MON_DATA_OT_ID);
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_NONE)
{
species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality;
@ -591,18 +590,18 @@ void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId)
}
else
{
species = gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies;
species = gBattleSpritesDataPtr->battlerData[battler].transformSpecies;
#if B_TRANSFORM_SHINY >= GEN_4
currentPersonality = gTransformedPersonalities[battlerId];
currentOtId = gTransformedOtIds[battlerId];
currentPersonality = gTransformedPersonalities[battler];
currentOtId = gTransformedOtIds[battler];
#else
currentPersonality = monsPersonality;
currentOtId = otId;
#endif
}
position = GetBattlerPosition(battlerId);
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
position = GetBattlerPosition(battler);
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
{
HandleLoadSpecialPokePic(TRUE,
gMonSpritesGfxPtr->sprites.ptr[position],
@ -615,19 +614,19 @@ void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId)
species, currentPersonality);
}
paletteOffset = OBJ_PLTT_ID(battlerId);
paletteOffset = OBJ_PLTT_ID(battler);
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon);
else
lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(species, currentOtId, currentPersonality);
LZDecompressWram(lzPaletteData, gDecompressionBuffer);
LoadPalette(gDecompressionBuffer, paletteOffset, PLTT_SIZE_4BPP);
LoadPalette(gDecompressionBuffer, BG_PLTT_ID(8) + BG_PLTT_ID(battlerId), PLTT_SIZE_4BPP);
LoadPalette(gDecompressionBuffer, BG_PLTT_ID(8) + BG_PLTT_ID(battler), PLTT_SIZE_4BPP);
// transform's pink color
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(&gPlttBufferFaded[paletteOffset], &gPlttBufferUnfaded[paletteOffset], PLTT_SIZEOF(16));
@ -638,23 +637,23 @@ void BattleGfxSfxDummy2(u16 species)
{
}
void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId)
void DecompressTrainerFrontPic(u16 frontPicId, u8 battler)
{
u8 position = GetBattlerPosition(battlerId);
u8 position = GetBattlerPosition(battler);
DecompressPicFromTable(&gTrainerFrontPicTable[frontPicId],
gMonSpritesGfxPtr->sprites.ptr[position],
SPECIES_NONE);
LoadCompressedSpritePalette(&gTrainerFrontPicPaletteTable[frontPicId]);
}
void DecompressTrainerBackPic(u16 backPicId, u8 battlerId)
void DecompressTrainerBackPic(u16 backPicId, u8 battler)
{
u8 position = GetBattlerPosition(battlerId);
u8 position = GetBattlerPosition(battler);
DecompressPicFromTable(&gTrainerBackPicTable[backPicId],
gMonSpritesGfxPtr->sprites.ptr[position],
SPECIES_NONE);
LoadCompressedPalette(gTrainerBackPicPaletteTable[backPicId].data,
OBJ_PLTT_ID(battlerId), PLTT_SIZE_4BPP);
OBJ_PLTT_ID(battler), PLTT_SIZE_4BPP);
}
void FreeTrainerFrontPicPalette(u16 frontPicId)
@ -754,7 +753,7 @@ void LoadBattleBarGfx(u8 unused)
LZDecompressWram(gBattleInterfaceGfx_BattleBar, gMonSpritesGfxPtr->barFontGfx);
}
bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId)
bool8 BattleInitAllSprites(u8 *state1, u8 *battler)
{
bool8 retVal = FALSE;
@ -765,13 +764,13 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId)
(*state1)++;
break;
case 1:
if (!BattleLoadAllHealthBoxesGfx(*battlerId))
if (!BattleLoadAllHealthBoxesGfx(*battler))
{
(*battlerId)++;
(*battler)++;
}
else
{
*battlerId = 0;
*battler = 0;
(*state1)++;
}
break;
@ -779,47 +778,47 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId)
(*state1)++;
break;
case 3:
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *battlerId == 0)
gHealthboxSpriteIds[*battlerId] = CreateSafariPlayerHealthboxSprites();
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *battler == 0)
gHealthboxSpriteIds[*battler] = CreateSafariPlayerHealthboxSprites();
else
gHealthboxSpriteIds[*battlerId] = CreateBattlerHealthboxSprites(*battlerId);
gHealthboxSpriteIds[*battler] = CreateBattlerHealthboxSprites(*battler);
(*battlerId)++;
if (*battlerId == gBattlersCount)
(*battler)++;
if (*battler == gBattlersCount)
{
*battlerId = 0;
*battler = 0;
(*state1)++;
}
break;
case 4:
InitBattlerHealthboxCoords(*battlerId);
if (gBattlerPositions[*battlerId] <= B_POSITION_OPPONENT_LEFT)
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], FALSE);
InitBattlerHealthboxCoords(*battler);
if (gBattlerPositions[*battler] <= B_POSITION_OPPONENT_LEFT)
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battler], FALSE);
else
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], TRUE);
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battler], TRUE);
(*battlerId)++;
if (*battlerId == gBattlersCount)
(*battler)++;
if (*battler == gBattlersCount)
{
*battlerId = 0;
*battler = 0;
(*state1)++;
}
break;
case 5:
if (GetBattlerSide(*battlerId) == B_SIDE_PLAYER)
if (GetBattlerSide(*battler) == B_SIDE_PLAYER)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
UpdateHealthboxAttribute(gHealthboxSpriteIds[*battlerId], &gPlayerParty[gBattlerPartyIndexes[*battlerId]], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[*battler], &gPlayerParty[gBattlerPartyIndexes[*battler]], HEALTHBOX_ALL);
}
else
{
UpdateHealthboxAttribute(gHealthboxSpriteIds[*battlerId], &gEnemyParty[gBattlerPartyIndexes[*battlerId]], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[*battler], &gEnemyParty[gBattlerPartyIndexes[*battler]], HEALTHBOX_ALL);
}
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[*battlerId]);
(*battlerId)++;
if (*battlerId == gBattlersCount)
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[*battler]);
(*battler)++;
if (*battler == gBattlersCount)
{
*battlerId = 0;
*battler = 0;
(*state1)++;
}
break;
@ -853,9 +852,9 @@ void CopyAllBattleSpritesInvisibilities(void)
gBattleSpritesDataPtr->battlerData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible;
}
void CopyBattleSpriteInvisibility(u8 battlerId)
void CopyBattleSpriteInvisibility(u8 battler)
{
gBattleSpritesDataPtr->battlerData[battlerId].invisible = gSprites[gBattlerSpriteIds[battlerId]].invisible;
gBattleSpritesDataPtr->battlerData[battler].invisible = gSprites[gBattlerSpriteIds[battler]].invisible;
}
void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool32 megaEvo, bool8 trackEnemyPersonality)
@ -950,84 +949,85 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool32 megaEvo, bo
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], 0);
}
void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite)
void BattleLoadSubstituteOrMonSpriteGfx(u8 battler, bool8 loadMonSprite)
{
s32 i, position, palOffset;
if (!loadMonSprite)
{
if (IsContest())
position = B_POSITION_PLAYER_LEFT;
else
position = GetBattlerPosition(battlerId);
position = GetBattlerPosition(battler);
if (IsContest())
LZDecompressVram(gSubstituteDollBackGfx, gMonSpritesGfxPtr->sprites.ptr[position]);
else if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
LZDecompressVram(gSubstituteDollFrontGfx, gMonSpritesGfxPtr->sprites.ptr[position]);
LZDecompressVram(gBattleAnimSpriteGfx_SubstituteBack, gMonSpritesGfxPtr->sprites.ptr[position]);
else if (GetBattlerSide(battler) != B_SIDE_PLAYER)
LZDecompressVram(gBattleAnimSpriteGfx_Substitute, gMonSpritesGfxPtr->sprites.ptr[position]);
else
LZDecompressVram(gSubstituteDollBackGfx, gMonSpritesGfxPtr->sprites.ptr[position]);
LZDecompressVram(gBattleAnimSpriteGfx_SubstituteBack, gMonSpritesGfxPtr->sprites.ptr[position]);
for (i = 1; i < 4; i++)
{
Dma3CopyLarge32_(gMonSpritesGfxPtr->sprites.ptr[position], &gMonSpritesGfxPtr->sprites.byte[position][MON_PIC_SIZE * i], MON_PIC_SIZE);
}
palOffset = OBJ_PLTT_ID(battlerId);
LoadCompressedPalette(gSubstituteDollPal, palOffset, PLTT_SIZE_4BPP);
palOffset = OBJ_PLTT_ID(battler);
LoadCompressedPalette(gBattleAnimSpritePal_Substitute, palOffset, PLTT_SIZE_4BPP);
}
else
{
if (!IsContest())
BattleLoadMonSpriteGfx(&GetBattlerParty(battlerId)[gBattlerPartyIndexes[battlerId]], battlerId);
BattleLoadMonSpriteGfx(&GetBattlerParty(battler)[gBattlerPartyIndexes[battler]], battler);
}
}
void LoadBattleMonGfxAndAnimate(u8 battlerId, bool8 loadMonSprite, u8 spriteId)
void LoadBattleMonGfxAndAnimate(u8 battler, bool8 loadMonSprite, u8 spriteId)
{
BattleLoadSubstituteOrMonSpriteGfx(battlerId, loadMonSprite);
BattleLoadSubstituteOrMonSpriteGfx(battler, loadMonSprite);
StartSpriteAnim(&gSprites[spriteId], 0);
if (!loadMonSprite)
gSprites[spriteId].y = GetSubstituteSpriteDefault_Y(battlerId);
gSprites[spriteId].y = GetSubstituteSpriteDefault_Y(battler);
else
gSprites[spriteId].y = GetBattlerSpriteDefault_Y(battlerId);
gSprites[spriteId].y = GetBattlerSpriteDefault_Y(battler);
}
void TrySetBehindSubstituteSpriteBit(u8 battlerId, u16 move)
void TrySetBehindSubstituteSpriteBit(u8 battler, u16 move)
{
if (move == MOVE_SUBSTITUTE)
gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute = 1;
gBattleSpritesDataPtr->battlerData[battler].behindSubstitute = 1;
}
void ClearBehindSubstituteBit(u8 battlerId)
void ClearBehindSubstituteBit(u8 battler)
{
gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute = 0;
gBattleSpritesDataPtr->battlerData[battler].behindSubstitute = 0;
}
void HandleLowHpMusicChange(struct Pokemon *mon, u8 battlerId)
void HandleLowHpMusicChange(struct Pokemon *mon, u8 battler)
{
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[battlerId].lowHpSong)
if (!gBattleSpritesDataPtr->battlerData[battler].lowHpSong)
{
if (!gBattleSpritesDataPtr->battlerData[BATTLE_PARTNER(battlerId)].lowHpSong)
if (!gBattleSpritesDataPtr->battlerData[BATTLE_PARTNER(battler)].lowHpSong)
PlaySE(SE_LOW_HEALTH);
gBattleSpritesDataPtr->battlerData[battlerId].lowHpSong = 1;
gBattleSpritesDataPtr->battlerData[battler].lowHpSong = 1;
}
}
else
{
gBattleSpritesDataPtr->battlerData[battlerId].lowHpSong = 0;
gBattleSpritesDataPtr->battlerData[battler].lowHpSong = 0;
if (!IsDoubleBattle())
{
m4aSongNumStop(SE_LOW_HEALTH);
return;
}
if (IsDoubleBattle() && !gBattleSpritesDataPtr->battlerData[BATTLE_PARTNER(battlerId)].lowHpSong)
if (IsDoubleBattle() && !gBattleSpritesDataPtr->battlerData[BATTLE_PARTNER(battler)].lowHpSong)
{
m4aSongNumStop(SE_LOW_HEALTH);
return;
@ -1096,46 +1096,46 @@ void SetBattlerSpriteAffineMode(u8 affineMode)
void LoadAndCreateEnemyShadowSprites(void)
{
u8 battlerId;
u8 battler;
LoadCompressedSpriteSheet(&gSpriteSheet_EnemyShadow);
battlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X),
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_Y) + 29,
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow,
GetBattlerSpriteCoord(battler, BATTLER_COORD_X),
GetBattlerSpriteCoord(battler, BATTLER_COORD_Y) + 29,
0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].data[0] = battlerId;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteId].data[0] = battler;
if (IsDoubleBattle())
{
battlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X),
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_Y) + 29,
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow,
GetBattlerSpriteCoord(battler, BATTLER_COORD_X),
GetBattlerSpriteCoord(battler, BATTLER_COORD_Y) + 29,
0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].data[0] = battlerId;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteId].data[0] = battler;
}
}
void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
{
bool8 invisible = FALSE;
u8 battlerId = shadowSprite->tBattlerId;
struct Sprite *battlerSprite = &gSprites[gBattlerSpriteIds[battlerId]];
u8 battler = shadowSprite->tBattlerId;
struct Sprite *battlerSprite = &gSprites[gBattlerSpriteIds[battler]];
if (!battlerSprite->inUse || !IsBattlerSpritePresent(battlerId))
if (!battlerSprite->inUse || !IsBattlerSpritePresent(battler))
{
shadowSprite->callback = SpriteCB_SetInvisible;
return;
}
if (gAnimScriptActive || battlerSprite->invisible)
invisible = TRUE;
else if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies] == 0)
else if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[battler].transformSpecies] == 0)
invisible = TRUE;
if (gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute)
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
invisible = TRUE;
shadowSprite->x = battlerSprite->x;
@ -1150,24 +1150,24 @@ void SpriteCB_SetInvisible(struct Sprite *sprite)
sprite->invisible = TRUE;
}
void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species)
void SetBattlerShadowSpriteCallback(u8 battler, u16 species)
{
// The player's shadow is never seen.
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER || gBattleScripting.monCaught)
if (GetBattlerSide(battler) == B_SIDE_PLAYER || gBattleScripting.monCaught)
return;
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
species = gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies;
if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies != SPECIES_NONE)
species = gBattleSpritesDataPtr->battlerData[battler].transformSpecies;
if (gEnemyMonElevation[species] != 0)
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].callback = SpriteCB_EnemyShadow;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteId].callback = SpriteCB_EnemyShadow;
else
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].callback = SpriteCB_SetInvisible;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteId].callback = SpriteCB_SetInvisible;
}
void HideBattlerShadowSprite(u8 battlerId)
void HideBattlerShadowSprite(u8 battler)
{
gSprites[gBattleSpritesDataPtr->healthBoxesData[battlerId].shadowSpriteId].callback = SpriteCB_SetInvisible;
gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].shadowSpriteId].callback = SpriteCB_SetInvisible;
}
// Color the background tiles surrounding the action selection and move windows
@ -1194,11 +1194,11 @@ void FillAroundBattleWindows(void)
}
}
void ClearTemporarySpeciesSpriteData(u8 battlerId, bool8 dontClearSubstitute)
void ClearTemporarySpeciesSpriteData(u8 battler, bool8 dontClearSubstitute)
{
gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = SPECIES_NONE;
gBattleSpritesDataPtr->battlerData[battler].transformSpecies = SPECIES_NONE;
if (!dontClearSubstitute)
ClearBehindSubstituteBit(battlerId);
ClearBehindSubstituteBit(battler);
}
void AllocateMonSpritesGfx(void)

File diff suppressed because it is too large Load Diff

View File

@ -266,17 +266,17 @@ static const u8 sText_XFoundOneY[] = _("{B_ATK_NAME_WITH_PREFIX} found\none {B_L
static const u8 sText_SoothingAroma[] = _("A soothing aroma wafted\nthrough the area!");
static const u8 sText_ItemsCantBeUsedNow[] = _("Items can't be used now.{PAUSE 64}");
static const u8 sText_ForXCommaYZ[] = _("For {B_SCR_ACTIVE_NAME_WITH_PREFIX},\n{B_LAST_ITEM} {B_BUFF1}");
static const u8 sText_PkmnUsedXToGetPumped[] = _("{B_ACTIVE_NAME_WITH_PREFIX} used\n{B_LAST_ITEM} to get pumped!");
static const u8 sText_PkmnUsedXToGetPumped[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} used\n{B_LAST_ITEM} to get pumped!");
static const u8 sText_PkmnLostFocus[] = _("{B_ATK_NAME_WITH_PREFIX} lost its\nfocus and couldn't move!");
static const u8 sText_PkmnWasDraggedOut[] = _("{B_DEF_NAME_WITH_PREFIX} was\ndragged out!\p");
static const u8 sText_TheWallShattered[] = _("The wall shattered!");
static const u8 sText_ButNoEffect[] = _("But it had no effect!");
static const u8 sText_PkmnHasNoMovesLeft[] = _("{B_ACTIVE_NAME_WITH_PREFIX} has no\nmoves left!\p");
static const u8 sText_PkmnMoveIsDisabled[] = _("{B_ACTIVE_NAME_WITH_PREFIX}'s {B_CURRENT_MOVE}\nis disabled!\p");
static const u8 sText_PkmnCantUseMoveTorment[] = _("{B_ACTIVE_NAME_WITH_PREFIX} can't use the same\nmove in a row due to the Torment!\p");
static const u8 sText_PkmnCantUseMoveTaunt[] = _("{B_ACTIVE_NAME_WITH_PREFIX} can't use\n{B_CURRENT_MOVE} after the Taunt!\p");
static const u8 sText_PkmnCantUseMoveSealed[] = _("{B_ACTIVE_NAME_WITH_PREFIX} can't use the\nsealed {B_CURRENT_MOVE}!\p");
static const u8 sText_PkmnCantUseMoveThroatChop[] = _("{B_ACTIVE_NAME_WITH_PREFIX} can't use\n{B_CURRENT_MOVE} due to Throat Chop!\p");
static const u8 sText_PkmnHasNoMovesLeft[] = _("{B_ATK_NAME_WITH_PREFIX} has no\nmoves left!\p");
static const u8 sText_PkmnMoveIsDisabled[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_CURRENT_MOVE}\nis disabled!\p");
static const u8 sText_PkmnCantUseMoveTorment[] = _("{B_ATK_NAME_WITH_PREFIX} can't use the same\nmove in a row due to the Torment!\p");
static const u8 sText_PkmnCantUseMoveTaunt[] = _("{B_ATK_NAME_WITH_PREFIX} can't use\n{B_CURRENT_MOVE} after the Taunt!\p");
static const u8 sText_PkmnCantUseMoveSealed[] = _("{B_ATK_NAME_WITH_PREFIX} can't use the\nsealed {B_CURRENT_MOVE}!\p");
static const u8 sText_PkmnCantUseMoveThroatChop[] = _("{B_ATK_NAME_WITH_PREFIX} can't use\n{B_CURRENT_MOVE} due to Throat Chop!\p");
static const u8 sText_PkmnMadeItRain[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nmade it rain!");
static const u8 sText_PkmnRaisedSpeed[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nraised its SPEED!");
static const u8 sText_PkmnProtectedBy[] = _("{B_DEF_NAME_WITH_PREFIX} was protected\nby {B_DEF_ABILITY}!");
@ -1951,7 +1951,7 @@ const u8 gText_PkmnIsEvolving[] = _("What?\n{STR_VAR_1} is evolving!");
const u8 gText_CongratsPkmnEvolved[] = _("Congratulations! Your {STR_VAR_1}\nevolved into {STR_VAR_2}!{WAIT_SE}\p");
const u8 gText_PkmnStoppedEvolving[] = _("Huh? {STR_VAR_1}\nstopped evolving!\p");
const u8 gText_EllipsisQuestionMark[] = _("……?\p");
const u8 gText_WhatWillPkmnDo[] = _("What will\n{B_ACTIVE_NAME2} do?");
const u8 gText_WhatWillPkmnDo[] = _("What will\n{B_BUFF1} do?");
const u8 gText_WhatWillPkmnDo2[] = _("What will\n{B_PLAYER_NAME} do?");
const u8 gText_WhatWillWallyDo[] = _("What will\nWALLY do?");
const u8 gText_LinkStandby[] = _("{PAUSE 16}Link standby…");
@ -2638,12 +2638,12 @@ static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] =
static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0};
void BufferStringBattle(u16 stringID)
void BufferStringBattle(u16 stringID, u32 battler)
{
s32 i;
const u8 *stringPtr = NULL;
gBattleMsgDataPtr = (struct BattleMsgData *)(&gBattleResources->bufferA[gActiveBattler][4]);
gBattleMsgDataPtr = (struct BattleMsgData *)(&gBattleResources->bufferA[battler][4]);
gLastUsedItem = gBattleMsgDataPtr->lastItem;
gLastUsedAbility = gBattleMsgDataPtr->lastAbility;
gBattleScripting.battler = gBattleMsgDataPtr->scrActive;
@ -2716,9 +2716,9 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_INTROSENDOUT: // poke first send-out
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]))
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]))
{
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
stringPtr = sText_InGamePartnerSentOutZGoN;
@ -2736,7 +2736,7 @@ void BufferStringBattle(u16 stringID)
}
else
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]))
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]))
{
if (BATTLE_TWO_VS_ONE_OPPONENT)
stringPtr = sText_Trainer1SentOutTwoPkmn;
@ -2763,7 +2763,7 @@ void BufferStringBattle(u16 stringID)
}
break;
case STRINGID_RETURNMON: // sending poke to ball msg
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
if (*(&gBattleStruct->hpScale) == 0)
stringPtr = sText_PkmnThatsEnough;
@ -2852,7 +2852,7 @@ void BufferStringBattle(u16 stringID)
if (gBattleTextBuff1[0] & B_OUTCOME_LINK_BATTLE_RAN)
{
gBattleTextBuff1[0] &= ~(B_OUTCOME_LINK_BATTLE_RAN);
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
if (GetBattlerSide(battler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTextBuff1[0] == B_OUTCOME_LOST || gBattleTextBuff1[0] == B_OUTCOME_DREW)
@ -2864,7 +2864,7 @@ void BufferStringBattle(u16 stringID)
}
else
{
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
if (GetBattlerSide(battler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW)
gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON);
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
@ -2971,24 +2971,24 @@ static const u8 *TryGetStatusString(u8 *src)
return NULL;
}
static void GetBattlerNick(u32 battlerId, u8 *dst)
static void GetBattlerNick(u32 battler, u8 *dst)
{
struct Pokemon *mon, *illusionMon;
if (GET_BATTLER_SIDE(battlerId) == B_SIDE_PLAYER)
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
if (GET_BATTLER_SIDE(battler) == B_SIDE_PLAYER)
mon = &gPlayerParty[gBattlerPartyIndexes[battler]];
else
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
mon = &gEnemyParty[gBattlerPartyIndexes[battler]];
illusionMon = GetIllusionMonPtr(battlerId);
illusionMon = GetIllusionMonPtr(battler);
if (illusionMon != NULL)
mon = illusionMon;
GetMonData(mon, MON_DATA_NICKNAME, dst);
StringGet_Nickname(dst);
}
#define HANDLE_NICKNAME_STRING_CASE(battlerId) \
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) \
#define HANDLE_NICKNAME_STRING_CASE(battler) \
if (GetBattlerSide(battler) != B_SIDE_PLAYER) \
{ \
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) \
toCpy = sText_FoePkmnPrefix; \
@ -3001,10 +3001,10 @@ static void GetBattlerNick(u32 battlerId, u8 *dst)
toCpy++; \
} \
} \
GetBattlerNick(battlerId, text); \
GetBattlerNick(battler, text); \
toCpy = text;
static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text, u8 multiplayerId, u8 battlerId)
static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text, u8 multiplayerId, u8 battler)
{
const u8 *toCpy;
@ -3024,9 +3024,9 @@ static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text,
else if (trainerId == TRAINER_LINK_OPPONENT)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battlerId)].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battler)].name;
else
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battlerId) & BIT_SIDE].name;
toCpy = gLinkPlayers[GetBattlerMultiplayerId(battler) & BIT_SIDE].name;
}
else if (trainerId == TRAINER_FRONTIER_BRAIN)
{
@ -3056,31 +3056,31 @@ static const u8 *BattleStringGetOpponentNameByTrainerId(u16 trainerId, u8 *text,
return toCpy;
}
static const u8 *BattleStringGetOpponentName(u8 *text, u8 multiplayerId, u8 battlerId)
static const u8 *BattleStringGetOpponentName(u8 *text, u8 multiplayerId, u8 battler)
{
const u8 *toCpy;
switch (GetBattlerPosition(battlerId))
switch (GetBattlerPosition(battler))
{
case B_POSITION_OPPONENT_LEFT:
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId);
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battler);
break;
case B_POSITION_OPPONENT_RIGHT:
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_MULTI) && !BATTLE_TWO_VS_ONE_OPPONENT)
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_B, text, multiplayerId, battlerId);
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_B, text, multiplayerId, battler);
else
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battlerId);
toCpy = BattleStringGetOpponentNameByTrainerId(gTrainerBattleOpponent_A, text, multiplayerId, battler);
break;
}
return toCpy;
}
static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId)
static const u8 *BattleStringGetPlayerName(u8 *text, u8 battler)
{
const u8 *toCpy;
switch (GetBattlerPosition(battlerId))
switch (GetBattlerPosition(battler))
{
case B_POSITION_PLAYER_LEFT:
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -3113,12 +3113,12 @@ static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId)
return toCpy;
}
static const u8 *BattleStringGetTrainerName(u8 *text, u8 multiplayerId, u8 battlerId)
static const u8 *BattleStringGetTrainerName(u8 *text, u8 multiplayerId, u8 battler)
{
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return BattleStringGetPlayerName(text, battlerId);
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
return BattleStringGetPlayerName(text, battler);
else
return BattleStringGetOpponentName(text, multiplayerId, battlerId);
return BattleStringGetOpponentName(text, multiplayerId, battler);
}
static const u8 *BattleStringGetOpponentClassByTrainerId(u16 trainerId)
@ -3257,25 +3257,10 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
GetBattlerNick(gBattlerTarget, text);
toCpy = text;
break;
case B_TXT_ACTIVE_NAME: // active name
GetBattlerNick(gActiveBattler, text);
toCpy = text;
break;
case B_TXT_ACTIVE_NAME2: // active battlerId name with prefix, no illusion
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_NICKNAME, text);
else
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_NICKNAME, text);
StringGet_Nickname(text);
toCpy = text;
break;
case B_TXT_EFF_NAME_WITH_PREFIX: // effect battlerId name with prefix
case B_TXT_EFF_NAME_WITH_PREFIX: // effect battler name with prefix
HANDLE_NICKNAME_STRING_CASE(gEffectBattler)
break;
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active battlerId name with prefix
HANDLE_NICKNAME_STRING_CASE(gActiveBattler)
break;
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active battlerId name with prefix
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active battler name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler)
break;
case B_TXT_CURRENT_MOVE: // current move name
@ -3349,7 +3334,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[sBattlerAbilities[gBattleScripting.battler]];
break;
case B_TXT_EFF_ABILITY: // effect battlerId ability
case B_TXT_EFF_ABILITY: // effect battler ability
toCpy = gAbilityNames[sBattlerAbilities[gEffectBattler]];
break;
case B_TXT_TRAINER1_CLASS: // trainer class name
@ -3588,7 +3573,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
return dstID;
}
static void IllusionNickHack(u32 battlerId, u32 partyId, u8 *dst)
static void IllusionNickHack(u32 battler, u32 partyId, u8 *dst)
{
s32 id, i;
// we know it's gEnemyParty
@ -3596,8 +3581,8 @@ static void IllusionNickHack(u32 battlerId, u32 partyId, u8 *dst)
if (GetMonAbility(mon) == ABILITY_ILLUSION)
{
if (IsBattlerAlive(BATTLE_PARTNER(battlerId)))
partnerMon = &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]];
if (IsBattlerAlive(BATTLE_PARTNER(battler)))
partnerMon = &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]];
else
partnerMon = mon;
@ -3901,17 +3886,17 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId)
}
}
void SetPpNumbersPaletteInMoveSelection(void)
void SetPpNumbersPaletteInMoveSelection(u32 battler)
{
struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
const u16 *palPtr = gPPTextPalette;
u8 var;
if (!gBattleStruct->zmove.viewing)
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]],
chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBattler]]);
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[battler]],
chooseMoveStruct->maxPp[gMoveSelectionCursor[battler]]);
else
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]], gBattleMoves[gMoveSelectionCursor[gActiveBattler]].pp);
var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[battler]], gBattleMoves[gMoveSelectionCursor[battler]].pp);
gPlttBufferUnfaded[BG_PLTT_ID(5) + 12] = palPtr[(var * 2) + 0];
gPlttBufferUnfaded[BG_PLTT_ID(5) + 11] = palPtr[(var * 2) + 1];
@ -4018,38 +4003,38 @@ enum
NOT_EQUAL,
};
u32 BattlerHPPercentage(u32 battlerId, u32 operation, u32 threshold)
u32 BattlerHPPercentage(u32 battler, u32 operation, u32 threshold)
{
switch (operation)
{
case LESS_THAN:
return gBattleMons[battlerId].hp < (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp < (gBattleMons[battler].maxHP / threshold);
case EQUAL:
return gBattleMons[battlerId].hp == (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp == (gBattleMons[battler].maxHP / threshold);
case GREATER_THAN:
return gBattleMons[battlerId].hp > (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp > (gBattleMons[battler].maxHP / threshold);
case LESS_THAN_OR_EQUAL:
return gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp <= (gBattleMons[battler].maxHP / threshold);
case GREATER_THAN_OR_EQUAL:
return gBattleMons[battlerId].hp >= (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp >= (gBattleMons[battler].maxHP / threshold);
case NOT_EQUAL:
return gBattleMons[battlerId].hp != (gBattleMons[battlerId].maxHP / threshold);
return gBattleMons[battler].hp != (gBattleMons[battler].maxHP / threshold);
default:
break;
}
}
u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
u32 ShouldDoTrainerSlide(u32 battler, u32 which)
{
u32 i, firstId, lastId, trainerId, retValue = 1;
if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) || GetBattlerSide(battlerId) != B_SIDE_OPPONENT)
if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) || GetBattlerSide(battler) != B_SIDE_OPPONENT)
return 0;
// Two opponents support.
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
if (gBattlerPartyIndexes[battlerId] >= 3)
if (gBattlerPartyIndexes[battler] >= 3)
{
firstId = 3, lastId = PARTY_SIZE;
trainerId = gTrainerBattleOpponent_B;
@ -4073,11 +4058,11 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
&& (((gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && sTrainerSlides[i].isFrontierTrainer)
|| (!(gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && !sTrainerSlides[i].isFrontierTrainer)))
{
gBattleScripting.battler = battlerId;
gBattleScripting.battler = battler;
switch (which)
{
case TRAINER_SLIDE_LAST_SWITCHIN:
if (sTrainerSlides[i].msgLastSwitchIn != NULL && !CanBattlerSwitch(battlerId))
if (sTrainerSlides[i].msgLastSwitchIn != NULL && !CanBattlerSwitch(battler))
{
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastSwitchIn;
return retValue;
@ -4086,7 +4071,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_LAST_LOW_HP:
if (sTrainerSlides[i].msgLastLowHp != NULL
&& GetEnemyMonCount(firstId, lastId, TRUE) == 1
&& BattlerHPPercentage(battlerId, GREATER_THAN_OR_EQUAL, 4)
&& BattlerHPPercentage(battler, GREATER_THAN_OR_EQUAL, 4)
&& !gBattleStruct->trainerSlideLowHpMsgDone)
{
gBattleStruct->trainerSlideLowHpMsgDone = TRUE;
@ -4104,7 +4089,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_LAST_HALF_HP:
if (sTrainerSlides[i].msgLastHalfHp != NULL
&& GetEnemyMonCount(firstId, lastId, TRUE) == GetEnemyMonCount(firstId, lastId, FALSE) - 1
&& BattlerHPPercentage(battlerId, LESS_THAN_OR_EQUAL, 2) && BattlerHPPercentage(battlerId, GREATER_THAN, 4)
&& BattlerHPPercentage(battler, LESS_THAN_OR_EQUAL, 2) && BattlerHPPercentage(battler, GREATER_THAN, 4)
&& !gBattleStruct->trainerSlideHalfHpMsgDone)
{
gBattleStruct->trainerSlideHalfHpMsgDone = TRUE;
@ -4123,7 +4108,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which)
case TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT:
if (sTrainerSlides[i].msgFirstSuperEffectiveHit != NULL
&& gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState == 1
&& gBattleMons[battlerId].hp)
&& gBattleMons[battler].hp)
{
gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState = 2;
gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstSuperEffectiveHit;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -72,7 +72,7 @@ void FreeBattleResources(void)
}
}
void AdjustFriendshipOnBattleFaint(u8 battlerId)
void AdjustFriendshipOnBattleFaint(u8 battler)
{
u8 opposingBattlerId;
@ -91,28 +91,28 @@ void AdjustFriendshipOnBattleFaint(u8 battlerId)
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
}
if (gBattleMons[opposingBattlerId].level > gBattleMons[battlerId].level)
if (gBattleMons[opposingBattlerId].level > gBattleMons[battler].level)
{
if (gBattleMons[opposingBattlerId].level - gBattleMons[battlerId].level > 29)
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_LARGE);
if (gBattleMons[opposingBattlerId].level - gBattleMons[battler].level > 29)
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battler]], FRIENDSHIP_EVENT_FAINT_LARGE);
else
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_SMALL);
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battler]], FRIENDSHIP_EVENT_FAINT_SMALL);
}
else
{
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], FRIENDSHIP_EVENT_FAINT_SMALL);
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battler]], FRIENDSHIP_EVENT_FAINT_SMALL);
}
}
void SwitchPartyOrderInGameMulti(u8 battlerId, u8 arg1)
void SwitchPartyOrderInGameMulti(u8 battler, u8 arg1)
{
if (GetBattlerSide(battlerId) != B_SIDE_OPPONENT)
if (GetBattlerSide(battler) != B_SIDE_OPPONENT)
{
s32 i;
for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++)
gBattlePartyCurrentOrder[i] = *(0 * 3 + i + (u8 *)(gBattleStruct->battlerPartyOrders));
SwitchPartyMonSlots(GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battlerId]), GetPartyIdFromBattlePartyId(arg1));
SwitchPartyMonSlots(GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battler]), GetPartyIdFromBattlePartyId(arg1));
for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++)
*(0 * 3 + i + (u8 *)(gBattleStruct->battlerPartyOrders)) = gBattlePartyCurrentOrder[i];
@ -121,7 +121,7 @@ void SwitchPartyOrderInGameMulti(u8 battlerId, u8 arg1)
// Called when a Pokémon is unable to attack during a Battle Palace battle.
// Check if it was because they are frozen/asleep, and if so try to cure the status.
u32 BattlePalace_TryEscapeStatus(u8 battlerId)
u32 BattlePalace_TryEscapeStatus(u8 battler)
{
u32 effect = 0;
@ -130,13 +130,13 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
switch (gBattleCommunication[MULTIUSE_STATE])
{
case 0:
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
{
if (UproarWakeUpCheck(battlerId))
if (UproarWakeUpCheck(battler))
{
// Wake up from Uproar
gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
gBattleMons[battler].status1 &= ~(STATUS1_SLEEP);
gBattleMons[battler].status2 &= ~(STATUS2_NIGHTMARE);
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WOKE_UP_UPROAR;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
@ -146,18 +146,18 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
{
u32 toSub;
if (GetBattlerAbility(battlerId) == ABILITY_EARLY_BIRD)
if (GetBattlerAbility(battler) == ABILITY_EARLY_BIRD)
toSub = 2;
else
toSub = 1;
// Reduce number of sleep turns
if ((gBattleMons[battlerId].status1 & STATUS1_SLEEP) < toSub)
gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
if ((gBattleMons[battler].status1 & STATUS1_SLEEP) < toSub)
gBattleMons[battler].status1 &= ~(STATUS1_SLEEP);
else
gBattleMons[battlerId].status1 -= toSub;
gBattleMons[battler].status1 -= toSub;
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
if (gBattleMons[battler].status1 & STATUS1_SLEEP)
{
// Still asleep
gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep;
@ -166,7 +166,7 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
else
{
// Wake up
gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
gBattleMons[battler].status2 &= ~(STATUS2_NIGHTMARE);
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WOKE_UP;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
@ -177,7 +177,7 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 1:
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
if (gBattleMons[battler].status1 & STATUS1_FREEZE)
{
if (Random() % 5 != 0)
{
@ -187,7 +187,7 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
else
{
// Unfreeze
gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE);
gBattleMons[battler].status1 &= ~(STATUS1_FREEZE);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DEFROSTED;
@ -204,9 +204,8 @@ u32 BattlePalace_TryEscapeStatus(u8 battlerId)
if (effect == 2)
{
gActiveBattler = battlerId;
BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler);
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1);
MarkBattlerForControllerExec(battler);
}
return effect;

View File

@ -48,12 +48,12 @@
static void SpriteCB_ZMoveTrigger(struct Sprite *sprite);
static u16 GetSignatureZMove(u16 move, u16 species, u16 item);
static u16 GetTypeBasedZMove(u16 move, u8 battler);
static void ZMoveSelectionDisplayPpNumber(void);
static void ZMoveSelectionDisplayPpNumber(u32 battler);
static void ZMoveSelectionDisplayPower(u16 move, u16 zMove);
static void ShowZMoveTriggerSprite(u8 battleId);
static bool32 AreStatsMaxed(u8 battlerId, u8 n);
static bool32 AreStatsMaxed(u8 battler, u8 n);
static u8 GetZMoveScore(u8 battlerAtk, u8 battlerDef, u16 baseMove, u16 zMove);
static void ZMoveSelectionDisplayMoveType(u16 zMove);
static void ZMoveSelectionDisplayMoveType(u16 zMove, u32 battler);
// Const Data
static const struct SignatureZMove sSignatureZMoves[] =
@ -146,52 +146,52 @@ bool8 IsZMove(u16 move)
return move >= FIRST_Z_MOVE && move <= LAST_Z_MOVE;
}
void QueueZMove(u8 battlerId, u16 baseMove)
void QueueZMove(u8 battler, u16 baseMove)
{
gBattleStruct->zmove.toBeUsed[battlerId] = gBattleStruct->zmove.chosenZMove;
gBattleStruct->zmove.baseMoves[battlerId] = baseMove;
gBattleStruct->zmove.toBeUsed[battler] = gBattleStruct->zmove.chosenZMove;
gBattleStruct->zmove.baseMoves[battler] = baseMove;
if (gBattleStruct->zmove.chosenZMove == MOVE_LIGHT_THAT_BURNS_THE_SKY)
gBattleStruct->zmove.splits[battlerId] = GetSplitBasedOnStats(battlerId);
gBattleStruct->zmove.splits[battler] = GetSplitBasedOnStats(battler);
else
gBattleStruct->zmove.splits[battlerId] = gBattleMoves[baseMove].split;
gBattleStruct->zmove.splits[battler] = gBattleMoves[baseMove].split;
}
bool32 IsViableZMove(u8 battlerId, u16 move)
bool32 IsViableZMove(u8 battler, u16 move)
{
struct Pokemon *mon;
u8 battlerPosition = GetBattlerPosition(battlerId);
u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId));
u8 battlerPosition = GetBattlerPosition(battler);
u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battler));
u32 item;
u16 holdEffect;
u16 species;
int moveSlotIndex;
species = gBattleMons[battlerId].species;
item = gBattleMons[battlerId].item;
species = gBattleMons[battler].species;
item = gBattleMons[battler].item;
for (moveSlotIndex = 0; moveSlotIndex < MAX_MON_MOVES; moveSlotIndex++)
{
if (gBattleMons[battlerId].moves[moveSlotIndex] == move && gBattleMons[battlerId].pp[moveSlotIndex] == 0)
if (gBattleMons[battler].moves[moveSlotIndex] == move && gBattleMons[battler].pp[moveSlotIndex] == 0)
return FALSE;
}
if (gBattleStruct->zmove.used[battlerId])
if (gBattleStruct->zmove.used[battler])
return FALSE;
if (gBattleTypeFlags & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FRONTIER))
return FALSE;
if ((GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_Z_POWER_RING, 1))
if ((GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT || (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT)) && !CheckBagHasItem(ITEM_Z_POWER_RING, 1))
return FALSE;
if (item == ITEM_ENIGMA_BERRY_E_READER)
return FALSE; // HoldEffect = gEnigmaBerries[battlerId].holdEffect;
return FALSE; // HoldEffect = gEnigmaBerries[battler].holdEffect;
else
holdEffect = ItemId_GetHoldEffect(item);
if (holdEffect == HOLD_EFFECT_Z_CRYSTAL)
{
u16 zMove = GetSignatureZMove(move, gBattleMons[battlerId].species, item);
u16 zMove = GetSignatureZMove(move, gBattleMons[battler].species, item);
if (zMove != MOVE_NONE)
{
gBattleStruct->zmove.chosenZMove = zMove; // Signature z move exists
@ -200,7 +200,7 @@ bool32 IsViableZMove(u8 battlerId, u16 move)
if (move != MOVE_NONE && zMove != MOVE_Z_STATUS && gBattleMoves[move].type == ItemId_GetSecondaryId(item))
{
gBattleStruct->zmove.chosenZMove = GetTypeBasedZMove(move, battlerId);
gBattleStruct->zmove.chosenZMove = GetTypeBasedZMove(move, battler);
return TRUE;
}
}
@ -208,34 +208,34 @@ bool32 IsViableZMove(u8 battlerId, u16 move)
return FALSE;
}
void GetUsableZMoves(u8 battlerId, u16 *moves)
void GetUsableZMoves(u8 battler, u16 *moves)
{
u32 i;
gBattleStruct->zmove.possibleZMoves[battlerId] = 0;
gBattleStruct->zmove.possibleZMoves[battler] = 0;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && IsViableZMove(battlerId, moves[i]))
gBattleStruct->zmove.possibleZMoves[battlerId] |= (1 << i);
if (moves[i] != MOVE_NONE && IsViableZMove(battler, moves[i]))
gBattleStruct->zmove.possibleZMoves[battler] |= (1 << i);
}
}
bool32 IsZMoveUsable(u8 battlerId, u16 moveIndex)
bool32 IsZMoveUsable(u8 battler, u16 moveIndex)
{
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && IsPartnerMonFromSameTrainer(battlerId) && gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(battlerId)] != MOVE_NONE)
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && IsPartnerMonFromSameTrainer(battler) && gBattleStruct->zmove.toBeUsed[BATTLE_PARTNER(battler)] != MOVE_NONE)
return FALSE; // Player's other mon has a z move queued up already
if (gBattleStruct->zmove.possibleZMoves[battlerId] & (1 << moveIndex))
if (gBattleStruct->zmove.possibleZMoves[battler] & (1 << moveIndex))
return TRUE;
return FALSE;
}
bool32 TryChangeZIndicator(u8 battlerId, u8 moveIndex)
bool32 TryChangeZIndicator(u8 battler, u8 moveIndex)
{
bool32 viableZMove = IsZMoveUsable(battlerId, moveIndex);
bool32 viableZMove = IsZMoveUsable(battler, moveIndex);
if (gBattleStruct->zmove.viable && !viableZMove)
HideZMoveTriggerSprite(); // Was a viable z move, now is not -> slide out
else if (!gBattleStruct->zmove.viable && viableZMove)
ShowZMoveTriggerSprite(battlerId); // Was not a viable z move, now is -> slide back in
ShowZMoveTriggerSprite(battler); // Was not a viable z move, now is -> slide back in
}
#define SINGLES_Z_TRIGGER_POS_X_OPTIMAL (29)
@ -251,7 +251,7 @@ bool32 TryChangeZIndicator(u8 battlerId, u8 moveIndex)
#define tBattler data[0]
#define tHide data[1]
void CreateZMoveTriggerSprite(u8 battlerId, bool8 viable)
void CreateZMoveTriggerSprite(u8 battler, bool8 viable)
{
s16 x, y;
@ -261,19 +261,19 @@ void CreateZMoveTriggerSprite(u8 battlerId, bool8 viable)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
x = gSprites[gHealthboxSpriteIds[battlerId]].x - DOUBLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battlerId]].y - DOUBLES_Z_TRIGGER_POS_Y_DIFF;
x = gSprites[gHealthboxSpriteIds[battler]].x - DOUBLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battler]].y - DOUBLES_Z_TRIGGER_POS_Y_DIFF;
}
else
{
x = gSprites[gHealthboxSpriteIds[battlerId]].x - SINGLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battlerId]].y - SINGLES_Z_TRIGGER_POS_Y_DIFF, 0;
x = gSprites[gHealthboxSpriteIds[battler]].x - SINGLES_Z_TRIGGER_POS_X_SLIDE;
y = gSprites[gHealthboxSpriteIds[battler]].y - SINGLES_Z_TRIGGER_POS_Y_DIFF, 0;
}
if (gBattleStruct->zmove.triggerSpriteId == 0xFF)
gBattleStruct->zmove.triggerSpriteId = CreateSprite(&sSpriteTemplate_ZMoveTrigger, x, y, 0);
gSprites[gBattleStruct->zmove.triggerSpriteId].tBattler = battlerId;
gSprites[gBattleStruct->zmove.triggerSpriteId].tBattler = battler;
gSprites[gBattleStruct->zmove.triggerSpriteId].tHide = (viable == TRUE) ? FALSE : TRUE;
}
@ -348,11 +348,11 @@ void HideZMoveTriggerSprite(void)
sprite->tHide = TRUE;
}
static void ShowZMoveTriggerSprite(u8 battlerId)
static void ShowZMoveTriggerSprite(u8 battler)
{
struct Sprite *sprite = &gSprites[gBattleStruct->zmove.triggerSpriteId];
gBattleStruct->zmove.viable = TRUE;
CreateZMoveTriggerSprite(battlerId, TRUE);
CreateZMoveTriggerSprite(battler, TRUE);
}
void DestroyZMoveTriggerSprite(void)
@ -392,11 +392,11 @@ static u16 GetTypeBasedZMove(u16 move, u8 battler)
return MOVE_BREAKNECK_BLITZ + (moveType - 1);
}
bool32 MoveSelectionDisplayZMove(u16 zmove)
bool32 MoveSelectionDisplayZMove(u16 zmove, u32 battler)
{
u32 i;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
u16 move = moveInfo->moves[gMoveSelectionCursor[gActiveBattler]];
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
u16 move = moveInfo->moves[gMoveSelectionCursor[battler]];
PlaySE(SE_SELECT);
gBattleStruct->zmove.viewing = TRUE;
@ -507,8 +507,8 @@ bool32 MoveSelectionDisplayZMove(u16 zmove)
}
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_NAME_1);
ZMoveSelectionDisplayPpNumber();
ZMoveSelectionDisplayMoveType(zmove);
ZMoveSelectionDisplayPpNumber(battler);
ZMoveSelectionDisplayMoveType(zmove, battler);
MoveSelectionCreateCursorAt(0, 0);
return TRUE;
}
@ -532,26 +532,26 @@ static void ZMoveSelectionDisplayPower(u16 move, u16 zMove)
}
}
static void ZMoveSelectionDisplayPpNumber(void)
static void ZMoveSelectionDisplayPpNumber(u32 battler)
{
u8 *txtPtr;
struct ChooseMoveStruct *moveInfo;
if (gBattleResources->bufferA[gActiveBattler][2] == TRUE) // Check if we didn't want to display pp number
if (gBattleResources->bufferA[battler][2] == TRUE) // Check if we didn't want to display pp number
return;
SetPpNumbersPaletteInMoveSelection();
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
SetPpNumbersPaletteInMoveSelection(battler);
moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, 1, STR_CONV_MODE_RIGHT_ALIGN, 2);
*(txtPtr)++ = CHAR_SLASH;
ConvertIntToDecimalStringN(txtPtr, 1, STR_CONV_MODE_RIGHT_ALIGN, 2);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_PP_REMAINING);
}
static void ZMoveSelectionDisplayMoveType(u16 zMove)
static void ZMoveSelectionDisplayMoveType(u16 zMove, u32 battler)
{
u8 *txtPtr;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[gActiveBattler][4]);
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleResources->bufferA[battler][4]);
u8 zMoveType;
GET_MOVE_TYPE(zMove, zMoveType);
@ -683,12 +683,12 @@ void SetZEffect(void)
gBattleStruct->zmove.zStatusActive = FALSE;
}
static bool32 AreStatsMaxed(u8 battlerId, u8 n)
static bool32 AreStatsMaxed(u8 battler, u8 n)
{
u32 i;
for (i = STAT_ATK; i <= n; i++)
{
if (STAT_STAGE(battlerId, i) < MAX_STAT_STAGE)
if (STAT_STAGE(battler, i) < MAX_STAT_STAGE)
return FALSE;
}
return TRUE;

View File

@ -1156,11 +1156,7 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] =
{gBattleAnimSpriteGfx_Shock2, 0x0600, ANIM_TAG_SHOCK_2},
{gBattleAnimSpriteGfx_ClosingEye2, 0x0200, ANIM_TAG_CLOSING_EYE_2},
{gBattleAnimSpriteGfx_MetalBall, 0x0080, ANIM_TAG_METAL_BALL},
#if NEW_SUBSTITUTE_PARTICLE
{gBattleAnimSpriteGfx_NewSubstituteFront, 0x0200, ANIM_TAG_MONSTER_DOLL},
#else
{gBattleAnimSpriteGfx_MonsterDoll, 0x0200, ANIM_TAG_MONSTER_DOLL},
#endif
{gBattleAnimSpriteGfx_Whirlwind, 0x0800, ANIM_TAG_WHIRLWIND},
{gBattleAnimSpriteGfx_Whirlwind2, 0x0080, ANIM_TAG_WHIRLWIND_2},
{gBattleAnimSpriteGfx_Explosion4, 0x0a00, ANIM_TAG_EXPLOSION_4},
@ -1607,11 +1603,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] =
{gBattleAnimSpritePal_Shock2, ANIM_TAG_SHOCK_2},
{gBattleAnimSpritePal_ClosingEye2, ANIM_TAG_CLOSING_EYE_2},
{gBattleAnimSpritePal_MetalBall, ANIM_TAG_METAL_BALL},
#if NEW_SUBSTITUTE_PARTICLE
{gBattleAnimSpritePal_NewSubstituteFront, ANIM_TAG_MONSTER_DOLL},
#else
{gBattleAnimSpritePal_MonsterDoll, ANIM_TAG_MONSTER_DOLL},
#endif
{gBattleAnimSpritePal_Whirlwind, ANIM_TAG_WHIRLWIND},
{gBattleAnimSpritePal_Whirlwind, ANIM_TAG_WHIRLWIND_2},
{gBattleAnimSpritePal_Explosion4, ANIM_TAG_EXPLOSION_4},

View File

@ -265,10 +265,6 @@ const u32 gBattleAnimSpritePal_SteelBeam[] = INCBIN_U32("graphics/battle_anims/s
const u32 gBattleAnimSpriteGfx_StraightBeam[] = INCBIN_U32("graphics/battle_anims/sprites/straight_beam.4bpp.lz");
const u32 gBattleAnimSpritePal_StraightBeam[] = INCBIN_U32("graphics/battle_anims/sprites/straight_beam.gbapal.lz");
const u32 gBattleAnimSpriteGfx_SubstituteBack[] = INCBIN_U32("graphics/battle_anims/sprites/substitute_back_new.4bpp.lz");
const u32 gBattleAnimSpriteGfx_NewSubstituteFront[] = INCBIN_U32("graphics/battle_anims/sprites/substitute_new.4bpp.lz");
const u32 gBattleAnimSpritePal_NewSubstituteFront[] = INCBIN_U32("graphics/battle_anims/sprites/substitute_new.gbapal.lz");
const u32 gBattleAnimSpritePal_NewSurf[] = INCBIN_U32("graphics/battle_anims/sprites/surf_new.gbapal.lz");
const u32 gBattleAnimSpriteGfx_NewSword[] = INCBIN_U32("graphics/battle_anims/sprites/sword_new.4bpp.lz");
@ -1174,9 +1170,9 @@ const u32 gBattleAnimSpritePal_HandsAndFeet[] = INCBIN_U32("graphics/battle_anim
const u32 gBattleAnimSpriteGfx_Confetti[] = INCBIN_U32("graphics/battle_anims/sprites/confetti.4bpp.lz");
const u32 gBattleAnimSpritePal_Confetti[] = INCBIN_U32("graphics/battle_anims/sprites/confetti.gbapal.lz");
const u32 gSubstituteDollPal[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.gbapal.lz");
const u32 gSubstituteDollFrontGfx[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.4bpp.lz");
const u32 gSubstituteDollBackGfx[] = INCBIN_U32("graphics/battle_anims/sprites/substitute_back.4bpp.lz");
const u32 gBattleAnimSpriteGfx_Substitute[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.4bpp.lz");
const u32 gBattleAnimSpriteGfx_SubstituteBack[] = INCBIN_U32("graphics/battle_anims/sprites/substitute_back.4bpp.lz");
const u32 gBattleAnimSpritePal_Substitute[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.gbapal.lz");
const u32 gBattleAnimSpriteGfx_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.4bpp.lz");
const u32 gBattleAnimSpritePal_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.gbapal.lz");

View File

@ -527,17 +527,17 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
#define tBattler data[3]
#define tOpponentBattler data[4]
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
u8 DoPokeballSendOutAnimation(u32 battler, s16 pan, u8 kindOfThrow)
{
u8 taskId;
gDoingBattleAnim = TRUE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive = TRUE;
gBattleSpritesDataPtr->healthBoxesData[battler].ballAnimActive = TRUE;
taskId = CreateTask(Task_DoPokeballSendOutAnim, 5);
gTasks[taskId].tPan = pan;
gTasks[taskId].tThrowId = kindOfThrow;
gTasks[taskId].tBattler = gActiveBattler;
gTasks[taskId].tBattler = battler;
return 0;
}

View File

@ -4408,38 +4408,24 @@ void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move)
SetBoxMonData(boxMon, MON_DATA_PP_BONUSES, &ppBonuses);
}
u8 CountAliveMonsInBattle(u8 caseId)
u8 CountAliveMonsInBattle(u8 caseId, u32 battler)
{
s32 i;
u8 retVal = 0;
switch (caseId)
{
case BATTLE_ALIVE_EXCEPT_ACTIVE:
case BATTLE_ALIVE_EXCEPT_BATTLER:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i]))
if (i != battler && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
case BATTLE_ALIVE_ATK_SIDE:
case BATTLE_ALIVE_SIDE:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBattlerSide(i) == GetBattlerSide(gBattlerAttacker) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
case BATTLE_ALIVE_DEF_SIDE:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
case BATTLE_ALIVE_EXCEPT_ATTACKER:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (i != gBattlerAttacker && !(gAbsentBattlerFlags & gBitTable[i]))
if (GetBattlerSide(i) == GetBattlerSide(battler) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
@ -4454,7 +4440,7 @@ u8 GetDefaultMoveTarget(u8 battlerId)
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
return GetBattlerAtPosition(opposing);
if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) > 1)
if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_BATTLER, battlerId) > 1)
{
u8 position;
@ -6230,7 +6216,7 @@ bool8 HealStatusConditions(struct Pokemon *mon, u32 battlePartyId, u32 healMask,
}
}
u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
u8 GetItemEffectParamOffset(u32 battler, u16 itemId, u8 effectByte, u8 effectBit)
{
const u8 *temp;
const u8 *itemEffect;
@ -6248,7 +6234,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
if (itemId == ITEM_ENIGMA_BERRY_E_READER)
{
temp = gEnigmaBerries[gActiveBattler].itemEffect;
temp = gEnigmaBerries[battler].itemEffect;
}
itemEffect = temp;

View File

@ -616,13 +616,13 @@ static void RecordedBattle_RestoreSavedParties(void)
}
}
u8 GetActiveBattlerLinkPlayerGender(void)
u8 GetBattlerLinkPlayerGender(u32 battler)
{
s32 i;
for (i = 0; i < MAX_LINK_PLAYERS; i++)
{
if (gLinkPlayers[i].id == gActiveBattler)
if (gLinkPlayers[i].id == battler)
break;
}
@ -658,11 +658,11 @@ u8 GetTextSpeedInRecordedBattle(void)
return sTextSpeed;
}
void RecordedBattle_CopyBattlerMoves(void)
void RecordedBattle_CopyBattlerMoves(u32 battler)
{
s32 i;
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
return;
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))
return;
@ -670,7 +670,7 @@ void RecordedBattle_CopyBattlerMoves(void)
return;
for (i = 0; i < MAX_MON_MOVES; i++)
sPlayerMonMoves[gActiveBattler / 2][i] = gBattleMons[gActiveBattler].moves[i];
sPlayerMonMoves[battler / 2][i] = gBattleMons[battler].moves[i];
}
// This is a special battle action only used by this function

View File

@ -0,0 +1,336 @@
#include "global.h"
#include "test/battle.h"
ASSUMPTIONS
{
ASSUME(gBattleMoves[MOVE_FLING].effect == EFFECT_FLING);
}
SINGLE_BATTLE_TEST("Fling fails if pokemon holds no item")
{
u16 item;
PARAMETRIZE {item = ITEM_NONE; }
PARAMETRIZE {item = ITEM_RAZOR_CLAW; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_FLING);}
} SCENE {
MESSAGE("Wobbuffet used Fling!");
if (item != ITEM_NONE) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
} else {
MESSAGE("But it failed!");
}
}
}
SINGLE_BATTLE_TEST("Fling fails if pokemon is under the effects of Embargo or Magic Room")
{
u16 move;
PARAMETRIZE {move = MOVE_CELEBRATE; }
PARAMETRIZE {move = MOVE_EMBARGO; }
PARAMETRIZE {move = MOVE_MAGIC_ROOM; }
GIVEN {
ASSUME(gBattleMoves[MOVE_EMBARGO].effect == EFFECT_EMBARGO);
ASSUME(gBattleMoves[MOVE_MAGIC_ROOM].effect == EFFECT_MAGIC_ROOM);
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_RAZOR_CLAW); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, move); }
TURN { MOVE(player, MOVE_FLING); }
} SCENE {
MESSAGE("Wobbuffet used Fling!");
if (move == MOVE_CELEBRATE) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
} else {
MESSAGE("But it failed!");
}
}
}
SINGLE_BATTLE_TEST("Fling fails for pokemon with Klutz ability")
{
u16 ability;
PARAMETRIZE {ability = ABILITY_KLUTZ; }
PARAMETRIZE {ability = ABILITY_RUN_AWAY; }
GIVEN {
ASSUME(P_GEN_4_POKEMON == TRUE);
ASSUME(B_KLUTZ_FLING_INTERACTION >= GEN_5);
PLAYER(SPECIES_BUNEARY) { Item(ITEM_RAZOR_CLAW); Ability(ability); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_FLING); }
} SCENE {
MESSAGE("Buneary used Fling!");
if (ability != ABILITY_KLUTZ) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
} else {
MESSAGE("But it failed!");
}
}
}
SINGLE_BATTLE_TEST("Fling's thrown item can be regained with Recycle")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_RECYCLE].effect == EFFECT_RECYCLE);
PLAYER(SPECIES_WOBBUFFET) {Item(ITEM_RAZOR_CLAW); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_FLING);}
TURN { MOVE(player, MOVE_RECYCLE);}
TURN { MOVE(player, MOVE_FLING);}
} SCENE {
MESSAGE("Wobbuffet used Fling!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
MESSAGE("Wobbuffet used Recycle!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_RECYCLE, player);
MESSAGE("Wobbuffet found one Razor Claw!");
MESSAGE("Wobbuffet used Fling!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
}
}
SINGLE_BATTLE_TEST("Fling - Item is lost even when there is no target")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_SELF_DESTRUCT].effect == EFFECT_EXPLOSION);
PLAYER(SPECIES_WOBBUFFET) {Item(ITEM_RAZOR_CLAW); Speed(2); }
OPPONENT(SPECIES_WOBBUFFET) {Speed(5); }
OPPONENT(SPECIES_WOBBUFFET) {Speed(5); }
} WHEN {
TURN { MOVE(opponent, MOVE_SELF_DESTRUCT); MOVE(player, MOVE_FLING); SEND_OUT(opponent, 1); }
TURN { MOVE(player, MOVE_FLING); }
} SCENE {
MESSAGE("Foe Wobbuffet used SelfDestruct!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_SELF_DESTRUCT, opponent);
HP_BAR(player);
MESSAGE("Foe Wobbuffet fainted!");
MESSAGE("Wobbuffet used Fling!");
MESSAGE("But it failed!");
MESSAGE("Wobbuffet used Fling!");
MESSAGE("But it failed!");
} THEN {
EXPECT_EQ(player->item, ITEM_NONE);
}
}
SINGLE_BATTLE_TEST("Fling - Item is lost when target protects itself")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_PROTECT].effect == EFFECT_PROTECT);
PLAYER(SPECIES_WOBBUFFET) {Item(ITEM_RAZOR_CLAW); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_PROTECT); MOVE(player, MOVE_FLING);}
TURN { MOVE(player, MOVE_FLING); }
} SCENE {
MESSAGE("Foe Wobbuffet used Protect!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_PROTECT, opponent);
MESSAGE("Wobbuffet used Fling!");
MESSAGE("Foe Wobbuffet protected itself!");
MESSAGE("Wobbuffet used Fling!");
MESSAGE("But it failed!");
} THEN {
EXPECT_EQ(player->item, ITEM_NONE);
}
}
SINGLE_BATTLE_TEST("Fling doesn't consume the item if pokemon is asleep/frozen/paralyzed")
{
u32 status;
u16 item;
PARAMETRIZE {status = STATUS1_SLEEP_TURN(2); item = ITEM_RAZOR_CLAW; }
PARAMETRIZE {status = STATUS1_PARALYSIS; item = ITEM_RAZOR_CLAW; }
PARAMETRIZE {status = STATUS1_FREEZE; item = ITEM_RAZOR_CLAW; }
PARAMETRIZE {status = STATUS1_SLEEP_TURN(2); item = ITEM_NONE; }
PARAMETRIZE {status = STATUS1_PARALYSIS; item = ITEM_NONE; }
PARAMETRIZE {status = STATUS1_FREEZE; item = ITEM_NONE; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET) {Item(item); Status1(status); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
if (status == STATUS1_FREEZE) {
TURN { MOVE(player, MOVE_FLING, WITH_RNG(RNG_FROZEN, FALSE)); }
TURN { MOVE(player, MOVE_FLING, WITH_RNG(RNG_FROZEN, TRUE)); }
} else if (status == STATUS1_PARALYSIS) {
TURN { MOVE(player, MOVE_FLING, WITH_RNG(RNG_PARALYSIS, FALSE)); }
TURN { MOVE(player, MOVE_FLING, WITH_RNG(RNG_PARALYSIS, TRUE)); }
} else {
TURN { MOVE(player, MOVE_FLING); }
TURN { MOVE(player, MOVE_FLING); }
}
} SCENE {
if (status == STATUS1_FREEZE) {
MESSAGE("Wobbuffet is frozen solid!");
MESSAGE("Wobbuffet was defrosted!");
}
else if (status == STATUS1_PARALYSIS) {
MESSAGE("Wobbuffet is paralyzed! It can't move!");
}
else {
MESSAGE("Wobbuffet is fast asleep.");
MESSAGE("Wobbuffet woke up!");
}
MESSAGE("Wobbuffet used Fling!");
if (item != ITEM_NONE) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
} else {
MESSAGE("But it failed!");
}
} THEN {
EXPECT_EQ(player->item, ITEM_NONE);
}
}
SINGLE_BATTLE_TEST("Fling applies special effects when throwing specific Items")
{
u16 item, effect;
PARAMETRIZE {item = ITEM_FLAME_ORB; effect = EFFECT_WILL_O_WISP; }
PARAMETRIZE {item = ITEM_TOXIC_ORB; effect = EFFECT_TOXIC; }
PARAMETRIZE {item = ITEM_POISON_BARB; effect = EFFECT_POISON; }
PARAMETRIZE {item = ITEM_LIGHT_BALL; effect = EFFECT_PARALYZE; }
PARAMETRIZE {item = ITEM_RAZOR_FANG; effect = EFFECT_FLINCH_HIT; }
PARAMETRIZE {item = ITEM_KINGS_ROCK; effect = EFFECT_FLINCH_HIT; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_FLING); }
} SCENE {
MESSAGE("Wobbuffet used Fling!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
switch (effect)
{
case EFFECT_WILL_O_WISP:
MESSAGE("Foe Wobbuffet was burned!");
STATUS_ICON(opponent, STATUS1_BURN);
break;
case EFFECT_PARALYZE:
MESSAGE("Foe Wobbuffet is paralyzed! It may be unable to move!");
STATUS_ICON(opponent, STATUS1_PARALYSIS);
break;
case EFFECT_POISON:
MESSAGE("Foe Wobbuffet was poisoned!");
STATUS_ICON(opponent, STATUS1_POISON);
break;
case EFFECT_TOXIC:
MESSAGE("Foe Wobbuffet is badly poisoned!");
STATUS_ICON(opponent, STATUS1_TOXIC_POISON);
break;
case EFFECT_FLINCH_HIT:
MESSAGE("Foe Wobbuffet flinched!");
break;
}
}
}
SINGLE_BATTLE_TEST("Fling - thrown berry's effect activates for the target even if the trigger conditions are not met")
{
u16 item, effect;
u8 statId = 0;
u32 status1 = STATUS1_NONE;
PARAMETRIZE { item = ITEM_ORAN_BERRY; effect = HOLD_EFFECT_RESTORE_HP; }
PARAMETRIZE { item = ITEM_SITRUS_BERRY; effect = HOLD_EFFECT_RESTORE_HP; }
PARAMETRIZE { item = ITEM_CHESTO_BERRY; effect = HOLD_EFFECT_CURE_SLP; status1 = STATUS1_SLEEP; }
PARAMETRIZE { item = ITEM_CHERI_BERRY; effect = HOLD_EFFECT_CURE_PAR; status1 = STATUS1_PARALYSIS; }
PARAMETRIZE { item = ITEM_PECHA_BERRY; effect = HOLD_EFFECT_CURE_PSN; status1 = STATUS1_POISON; }
PARAMETRIZE { item = ITEM_PECHA_BERRY; effect = HOLD_EFFECT_CURE_PSN; status1 = STATUS1_TOXIC_POISON; }
PARAMETRIZE { item = ITEM_RAWST_BERRY; effect = HOLD_EFFECT_CURE_BRN; status1 = STATUS1_BURN; }
PARAMETRIZE { item = ITEM_ASPEAR_BERRY; effect = HOLD_EFFECT_CURE_FRZ; status1 = STATUS1_FREEZE; }
PARAMETRIZE { item = ITEM_APICOT_BERRY; effect = HOLD_EFFECT_SP_DEFENSE_UP; statId = STAT_SPDEF; }
PARAMETRIZE { item = ITEM_MARANGA_BERRY; effect = HOLD_EFFECT_MARANGA_BERRY; statId = STAT_SPDEF; }
PARAMETRIZE { item = ITEM_GANLON_BERRY; effect = HOLD_EFFECT_DEFENSE_UP; statId = STAT_DEF; }
PARAMETRIZE { item = ITEM_KEE_BERRY; effect = HOLD_EFFECT_KEE_BERRY; statId = STAT_DEF; }
PARAMETRIZE { item = ITEM_LIECHI_BERRY; effect = HOLD_EFFECT_ATTACK_UP; statId = STAT_ATK; }
PARAMETRIZE { item = ITEM_PETAYA_BERRY; effect = HOLD_EFFECT_SP_ATTACK_UP; statId = STAT_SPATK; }
PARAMETRIZE { item = ITEM_SALAC_BERRY; effect = HOLD_EFFECT_SPEED_UP; statId = STAT_SPEED; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(item); }
OPPONENT(SPECIES_WOBBUFFET) { Status1(status1); HP(399); MaxHP(400); }
} WHEN {
TURN { MOVE(player, MOVE_FLING); }
} SCENE {
MESSAGE("Wobbuffet used Fling!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, player);
HP_BAR(opponent);
if (effect == HOLD_EFFECT_RESTORE_HP) {
if (item == ITEM_ORAN_BERRY) {
MESSAGE("Foe Wobbuffet's Oran Berry restored health!");
} else {
MESSAGE("Foe Wobbuffet's Sitrus Berry restored health!");
}
HP_BAR(opponent);
}
else if (status1 != STATUS1_NONE) {
if (status1 == STATUS1_BURN) {
MESSAGE("Foe Wobbuffet's Rawst Berry healed its burn!");
} else if (status1 == STATUS1_SLEEP) {
MESSAGE("Foe Wobbuffet's Chesto Berry woke it from its sleep!");
} else if (status1 == STATUS1_FREEZE) {
MESSAGE("Foe Wobbuffet's Aspear Berry defrosted it!");
} else if (status1 == STATUS1_PARALYSIS) {
MESSAGE("Foe Wobbuffet's Cheri Berry cured paralysis!");
} else if (status1 == STATUS1_TOXIC_POISON || status1 == STATUS1_POISON) {
MESSAGE("Foe Wobbuffet's Pecha Berry cured poison!");
}
NOT STATUS_ICON(opponent, status1);
}
else if (statId != 0) {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
if (statId == STAT_ATK) {
MESSAGE("Using Liechi Berry, the Attack of Foe Wobbuffet rose!");
} else if (statId == STAT_DEF) {
if (item == ITEM_GANLON_BERRY) {
MESSAGE("Using Ganlon Berry, the Defense of Foe Wobbuffet rose!");
} else {
MESSAGE("Using Kee Berry, the Defense of Foe Wobbuffet rose!");
}
} else if (statId == STAT_SPDEF) {
if (item == ITEM_APICOT_BERRY) {
MESSAGE("Using Apicot Berry, the Sp. Def of Foe Wobbuffet rose!");
} else {
MESSAGE("Using Maranga Berry, the Sp. Def of Foe Wobbuffet rose!");
}
} else if (statId == STAT_SPEED) {
MESSAGE("Using Salac Berry, the Speed of Foe Wobbuffet rose!");
} else if (statId == STAT_SPATK) {
MESSAGE("Using Petaya Berry, the Sp. Atk of Foe Wobbuffet rose!");
}
}
} THEN {
if (effect == HOLD_EFFECT_RESTORE_HP) {
EXPECT_EQ(opponent->hp, opponent->maxHP);
} else if (status1 != STATUS1_NONE) {
EXPECT_EQ(opponent->status1, STATUS1_NONE);
}
else if (statId != 0) {
EXPECT_EQ(opponent->statStages[statId], DEFAULT_STAT_STAGE + 1);
}
}
}