Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pkmnsnfrn committed Jul 14, 2024
1 parent 9b66584 commit e0ca421
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
12 changes: 12 additions & 0 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,26 @@ Debug_EventScript_Text_DefensiveIVs:
.string "HP IVs: {STR_VAR_1}, DEF IVs: {STR_VAR_2}, SPDEF IVs: {STR_VAR_3}$"

Debug_EventScript_Script_1::
setflag FLAG_BADGE01_GET
setflag FLAG_BADGE02_GET
setflag FLAG_BADGE03_GET
setflag FLAG_BADGE04_GET
setflag FLAG_BADGE05_GET
setflag FLAG_BADGE06_GET
setflag FLAG_BADGE07_GET
setflag FLAG_BADGE08_GET
givemon SPECIES_ARCEUS, 100, ITEM_EARTH_PLATE, ball=ITEM_POKE_BALL
givemon SPECIES_ARCEUS, 100, ITEM_PIXIE_PLATE, ball=ITEM_GREAT_BALL
release
end

Debug_EventScript_Script_2::
trainerbattle_double TRAINER_GINA_AND_MIA_1, Route104_Text_GinaIntro, Route104_Text_GinaDefeat, Route104_Text_GinaNotEnoughMons
release
end

Debug_EventScript_Script_3::
trainerbattle_single TRAINER_CINDY_1, Route104_Text_CindyIntro, Route104_Text_CindyDefeat, Route104_EventScript_TryRegisterCindyAfterBattle
release
end

Expand Down
7 changes: 5 additions & 2 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@
#define B_NEW_MORNING_SUN_STAR_PARTICLE TRUE // If set to TRUE, it updates Morning Sun's star particles.
#define B_NEW_IMPACT_PALETTE TRUE // If set to TRUE, it updates the basic 'hit' palette.
#define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette.
#define B_OPPONENT_THROW_BALLS GEN_LATEST // In GEN_6+, opposing Trainers throw PokéBalls into battle instead of just dropping them.
#define B_THROW_BALLS_SOUND GEN_LATEST // In GEN_5+, Trainers PokéBalls make a sound when thrown to send out a Pokémon.

// Poké Ball animation and sounds
#define B_ENEMY_THROW_BALLS GEN_LATEST // In GEN_6+, enemy Trainers throw Poké Balls into battle instead of them just appearing on the ground and opening.
#define B_ENEMY_THROW_BALLS_SOUND GEN_LATEST // In GEN_5+, enemy Trainer's Poké Balls make a sound when thrown to send out a Pokémon. This can only be used when B_ENEMY_THROW_BALLS is set to GEN_6 or later.
#define B_PLAYER_THROW_BALLS_SOUND GEN_LATEST // In GEN_5+, the player's Poké Balls make a sound when thrown to send out a Pokémon.

#endif // GUARD_CONFIG_BATTLE_H
29 changes: 17 additions & 12 deletions src/pokeball.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "constants/songs.h"

static void Task_DoPokeballSendOutAnim(u8 taskId);
static void DoPokeballSendOutSoundEffect(void);
static void *GetOpponentMonSendOutCallback(void);
static bool32 IsBattlerPlayer(u32 battler);
static inline void DoPokeballSendOutSoundEffect(u32 battler);
static inline void *GetOpponentMonSendOutCallback(void);
static inline bool32 IsBattlerPlayer(u32 battler);
static void SpriteCB_MonSendOut_1(struct Sprite *sprite);
static void SpriteCB_MonSendOut_2(struct Sprite *sprite);
static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite);
Expand Down Expand Up @@ -551,8 +551,8 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
{
u32 throwCaseId, ballId, battlerId, ballSpriteId;
bool32 notSendOut = FALSE;
u32 throwXoffset = (B_OPPONENT_THROW_BALLS >= GEN_6) ? 24 : 0;
s32 throwYoffset = (B_OPPONENT_THROW_BALLS >= GEN_6) ? -16 : 24;
u32 throwXoffset = (B_ENEMY_THROW_BALLS >= GEN_6) ? 24 : 0;
s32 throwYoffset = (B_ENEMY_THROW_BALLS >= GEN_6) ? -16 : 24;

if (gTasks[taskId].tFrames == 0)
{
Expand Down Expand Up @@ -581,15 +581,15 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
gSprites[ballSpriteId].x = 24;
gSprites[ballSpriteId].y = 68;
gSprites[ballSpriteId].callback = SpriteCB_MonSendOut_1;
DoPokeballSendOutSoundEffect();
DoPokeballSendOutSoundEffect(battlerId);
break;
case POKEBALL_OPPONENT_SENDOUT:
gSprites[ballSpriteId].x = GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X) + throwXoffset;
gSprites[ballSpriteId].y = GetBattlerSpriteCoord(battlerId, BATTLER_COORD_Y) + throwYoffset;
gBattlerTarget = battlerId;
gSprites[ballSpriteId].data[0] = 0;
gSprites[ballSpriteId].callback = GetOpponentMonSendOutCallback();
DoPokeballSendOutSoundEffect();
DoPokeballSendOutSoundEffect(battlerId);
break;
default:
gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
Expand All @@ -616,17 +616,22 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
PlaySE(SE_BALL_THROW);
}

static void DoPokeballSendOutSoundEffect(void)
STATIC_ASSERT(B_ENEMY_THROW_BALLS_SOUND < GEN_5 || B_ENEMY_THROW_BALLS >= GEN_6,OpponentThrowBallAndSoundMustBeOnTogether)

static inline void DoPokeballSendOutSoundEffect(u32 battler)
{
if (B_THROW_BALLS_SOUND < GEN_5)
if (IsBattlerPlayer(battler) && B_PLAYER_THROW_BALLS_SOUND < GEN_5)
return;

if (!IsBattlerPlayer(battler) && B_ENEMY_THROW_BALLS_SOUND < GEN_5)
return;

PlaySE(SE_BALL_THROW);
}

static void *GetOpponentMonSendOutCallback(void)
static inline void *GetOpponentMonSendOutCallback(void)
{
return (B_OPPONENT_THROW_BALLS >= GEN_6) ? SpriteCB_MonSendOut_1 : SpriteCB_OpponentMonSendOut;
return (B_ENEMY_THROW_BALLS >= GEN_6) ? SpriteCB_MonSendOut_1 : SpriteCB_OpponentMonSendOut;
}

// This sequence of functions is very similar to those that get run when
Expand Down Expand Up @@ -1130,7 +1135,7 @@ static void SpriteCB_BallThrow_CaptureMon(struct Sprite *sprite)
}
}

static bool32 IsBattlerPlayer(u32 battler)
static inline bool32 IsBattlerPlayer(u32 battler)
{
return (battler % B_POSITION_PLAYER_RIGHT) ? FALSE : TRUE;
}
Expand Down

0 comments on commit e0ca421

Please sign in to comment.