Skip to content

Commit

Permalink
Merge branch '_RHH/master' into _RHH/upcoming
Browse files Browse the repository at this point in the history
  • Loading branch information
AsparagusEduardo committed Feb 2, 2025
2 parents f8c2e86 + a0097ef commit 64c5113
Show file tree
Hide file tree
Showing 19 changed files with 450 additions and 60 deletions.
5 changes: 0 additions & 5 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1727,11 +1727,6 @@
.4byte \failInstr
.endm

.macro tryhitswitchtarget failInstr:req
callnative BS_TryHitSwitchTarget
.4byte \failInstr
.endm

.macro setmagiccoattarget
callnative BS_SetMagicCoatTarget
.endm
Expand Down
33 changes: 21 additions & 12 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -1806,25 +1806,17 @@ BattleScript_EffectFinalGambit::
tryfaintmon BS_ATTACKER
goto BattleScript_MoveEnd

BattleScript_EffectHitSwitchTarget::
call BattleScript_EffectHit_Ret
tryfaintmon BS_TARGET
jumpiffainted BS_TARGET, TRUE, BattleScript_MoveEnd
jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut
jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_MoveEnd
jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted
jumpiftargetdynamaxed BattleScript_HitSwitchTargetDynamaxed
tryhitswitchtarget BattleScript_MoveEnd
BattleScript_TryHitSwitchTarget::
forcerandomswitch BattleScript_HitSwitchTargetForceRandomSwitchFailed
goto BattleScript_MoveEnd
return

BattleScript_HitSwitchTargetDynamaxed:
BattleScript_HitSwitchTargetDynamaxed::
printstring STRINGID_MOVEBLOCKEDBYDYNAMAX
waitmessage B_WAIT_TIME_LONG
BattleScript_HitSwitchTargetForceRandomSwitchFailed:
hitswitchtargetfailed
setbyte sSWITCH_CASE, B_SWITCH_NORMAL
goto BattleScript_MoveEnd
return

BattleScript_EffectToxicThread::
setstatchanger STAT_SPEED, 1, TRUE
Expand Down Expand Up @@ -6722,6 +6714,12 @@ BattleScript_PrintMonIsRooted::
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd

BattleScript_PrintMonIsRootedRet::
pause B_WAIT_TIME_SHORT
printstring STRINGID_PKMNANCHOREDITSELF
waitmessage B_WAIT_TIME_LONG
return

BattleScript_AtkDefDown::
setbyte sSTAT_ANIM_PLAYED, FALSE
playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_ATK, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE | STAT_CHANGE_MULTIPLE_STATS
Expand Down Expand Up @@ -7766,8 +7764,12 @@ BattleScript_IntimidateEffect:
printstring STRINGID_PKMNCUTSATTACKWITH
BattleScript_IntimidateEffect_WaitString:
waitmessage B_WAIT_TIME_LONG
saveattacker
savetarget
copybyte sBATTLER, gBattlerTarget
call BattleScript_TryIntimidateHoldEffects
restoreattacker
restoretarget
BattleScript_IntimidateLoopIncrement:
addbyte gBattlerTarget, 1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_IntimidateLoop
Expand Down Expand Up @@ -8202,6 +8204,13 @@ BattleScript_AbilityPreventsPhasingOut::
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd

BattleScript_AbilityPreventsPhasingOutRet::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
printstring STRINGID_PKMNANCHORSITSELFWITH
waitmessage B_WAIT_TIME_LONG
return

BattleScript_AbilityNoStatLoss::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
Expand Down
Binary file added graphics/battle_interface/move_info_window_l.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/battle_interface/move_info_window_r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ struct BattleStruct
u8 ballSwapped:1; // Used for the last used ball feature
u8 throwingPokeBall:1;
u8 ballSpriteIds[2]; // item gfx, window gfx
u8 moveInfoSpriteId; // move info, window gfx
u8 appearedInBattle; // Bitfield to track which Pokemon appeared in battle. Used for Burmy's form change
u8 skyDropTargets[MAX_BATTLERS_COUNT]; // For Sky Drop, to account for if multiple Pokemon use Sky Drop in a double battle.
// When using a move which hits multiple opponents which is then bounced by a target, we need to make sure, the move hits both opponents, the one with bounce, and the one without.
Expand Down
2 changes: 2 additions & 0 deletions include/battle_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,7 @@ void SwapBallToDisplay(bool32 sameBall);
void ArrowsChangeColorLastBallCycle(bool32 showArrows);
void UpdateAbilityPopup(u8 battlerId);
void CategoryIcons_LoadSpritesGfx(void);
void TryToAddMoveInfoWindow(void);
void TryToHideMoveInfoWindow(void);

#endif // GUARD_BATTLE_INTERFACE_H
5 changes: 4 additions & 1 deletion include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,10 @@ extern const u8 BattleScript_EffectDefenseUp3[];
extern const u8 BattleScript_EffectNobleRoar[];
extern const u8 BattleScript_EffectVenomDrench[];
extern const u8 BattleScript_EffectToxicThread[];
extern const u8 BattleScript_EffectHitSwitchTarget[];
extern const u8 BattleScript_TryHitSwitchTarget[];
extern const u8 BattleScript_HitSwitchTargetDynamaxed[];
extern const u8 BattleScript_AbilityPreventsPhasingOutRet[];
extern const u8 BattleScript_PrintMonIsRootedRet[];
extern const u8 BattleScript_EffectFinalGambit[];
extern const u8 BattleScript_EffectAutotomize[];
extern const u8 BattleScript_EffectCopycat[];
Expand Down
1 change: 1 addition & 0 deletions include/constants/battle_script_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ enum MoveEndEffects
MOVEEND_ITEM_EFFECTS_TARGET,
MOVEEND_MOVE_EFFECTS2,
MOVEEND_ITEM_EFFECTS_ALL,
MOVEEND_HIT_SWITCH_TARGET,
MOVEEND_KINGSROCK, // These item effects will occur each strike of a multi-hit move
MOVEEND_NUM_HITS,
MOVEEND_SUBSTITUTE,
Expand Down
5 changes: 4 additions & 1 deletion src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ void HandleInputChooseMove(u32 battler)

if (JOY_NEW(A_BUTTON) && !gBattleStruct->descriptionSubmenu)
{
TryToHideMoveInfoWindow();
PlaySE(SE_SELECT);

moveTarget = GetBattlerMoveTargetType(battler, moveInfo->moves[gMoveSelectionCursor[battler]]);
Expand Down Expand Up @@ -779,6 +780,7 @@ void HandleInputChooseMove(u32 battler)
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, 0xFFFF);
HideGimmickTriggerSprite();
PlayerBufferExecCompleted(battler);
TryToHideMoveInfoWindow();
}
}
else if (JOY_NEW(DPAD_LEFT) && !gBattleStruct->zmove.viewing)
Expand Down Expand Up @@ -878,7 +880,7 @@ void HandleInputChooseMove(u32 battler)
MoveSelectionDisplayMoveType(battler);
}
}
else if (JOY_NEW(B_MOVE_DESCRIPTION_BUTTON) && B_MOVE_DESCRIPTION_BUTTON != B_LAST_USED_BALL_BUTTON)
else if (JOY_NEW(B_MOVE_DESCRIPTION_BUTTON))
{
gBattleStruct->descriptionSubmenu = TRUE;
MoveSelectionDisplayMoveDescription(battler);
Expand Down Expand Up @@ -2127,6 +2129,7 @@ void PlayerHandleChooseMove(u32 battler)

InitMoveSelectionsVarsAndStrings(battler);
gBattleStruct->gimmick.playerSelect = FALSE;
TryToAddMoveInfoWindow();

AssignUsableZMoves(battler, moveInfo->moves);
gBattleStruct->zmove.viable = (gBattleStruct->zmove.possibleZMoves[battler] & (1u << gMoveSelectionCursor[battler])) != 0;
Expand Down
99 changes: 93 additions & 6 deletions src/battle_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static void Task_FreeAbilityPopUpGfx(u8);

static void SpriteCB_LastUsedBall(struct Sprite *);
static void SpriteCB_LastUsedBallWin(struct Sprite *);
static void SpriteCB_MoveInfoWin(struct Sprite *sprite);

static const struct OamData sOamData_64x32 =
{
Expand Down Expand Up @@ -732,6 +733,7 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId)

gBattleStruct->ballSpriteIds[0] = MAX_SPRITES;
gBattleStruct->ballSpriteIds[1] = MAX_SPRITES;
gBattleStruct->moveInfoSpriteId = MAX_SPRITES;

return healthboxLeftSpriteId;
}
Expand Down Expand Up @@ -2886,6 +2888,36 @@ static const struct SpriteTemplate sSpriteTemplate_LastUsedBallWindow =
.callback = SpriteCB_LastUsedBallWin
};

#define MOVE_INFO_WINDOW_TAG 0xE722

static const struct OamData sOamData_MoveInfoWindow =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = SPRITE_SHAPE(32x32),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x32),
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0,
};

static const struct SpriteTemplate sSpriteTemplate_MoveInfoWindow =
{
.tileTag = MOVE_INFO_WINDOW_TAG,
.paletteTag = ABILITY_POP_UP_TAG,
.oam = &sOamData_MoveInfoWindow,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_MoveInfoWin
};

#if B_LAST_USED_BALL_BUTTON == R_BUTTON && B_LAST_USED_BALL_CYCLE == TRUE
static const u8 ALIGNED(4) sLastUsedBallWindowGfx[] = INCBIN_U8("graphics/battle_interface/last_used_ball_r_cycle.4bpp");
#elif B_LAST_USED_BALL_CYCLE == TRUE
Expand All @@ -2900,6 +2932,17 @@ static const struct SpriteSheet sSpriteSheet_LastUsedBallWindow =
sLastUsedBallWindowGfx, sizeof(sLastUsedBallWindowGfx), LAST_BALL_WINDOW_TAG
};

#if B_MOVE_DESCRIPTION_BUTTON == R_BUTTON
static const u8 sMoveInfoWindowGfx[] = INCBIN_U8("graphics/battle_interface/move_info_window_r.4bpp");
#else
static const u8 sMoveInfoWindowGfx[] = INCBIN_U8("graphics/battle_interface/move_info_window_l.4bpp");
#endif

static const struct SpriteSheet sSpriteSheet_MoveInfoWindow =
{
sMoveInfoWindowGfx, sizeof(sMoveInfoWindowGfx), MOVE_INFO_WINDOW_TAG
};

#define LAST_USED_BALL_X_F 14
#define LAST_USED_BALL_X_0 -14
#define LAST_USED_BALL_Y ((IsDoubleBattle()) ? 78 : 68)
Expand Down Expand Up @@ -2958,7 +3001,7 @@ void TryAddLastUsedBallItemSprites(void)
gBattleStruct->ballSpriteIds[0] = AddItemIconSprite(102, 102, gBallToDisplay);
gSprites[gBattleStruct->ballSpriteIds[0]].x = LAST_USED_BALL_X_0;
gSprites[gBattleStruct->ballSpriteIds[0]].y = LAST_USED_BALL_Y;
gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore
gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE;
gLastUsedBallMenuPresent = TRUE;
gSprites[gBattleStruct->ballSpriteIds[0]].callback = SpriteCB_LastUsedBall;
}
Expand All @@ -2973,7 +3016,8 @@ void TryAddLastUsedBallItemSprites(void)
gBattleStruct->ballSpriteIds[1] = CreateSprite(&sSpriteTemplate_LastUsedBallWindow,
LAST_BALL_WIN_X_0,
LAST_USED_WIN_Y, 5);
gSprites[gBattleStruct->ballSpriteIds[1]].sHide = FALSE; // restore
gSprites[gBattleStruct->ballSpriteIds[1]].sHide = FALSE;
gSprites[gBattleStruct->moveInfoSpriteId].sHide = TRUE;
gLastUsedBallMenuPresent = TRUE;
}
if (B_LAST_USED_BALL_CYCLE == TRUE)
Expand All @@ -2996,6 +3040,32 @@ static void DestroyLastUsedBallGfx(struct Sprite *sprite)
gBattleStruct->ballSpriteIds[0] = MAX_SPRITES;
}

void TryToAddMoveInfoWindow(void)
{
LoadSpritePalette(&sSpritePalette_AbilityPopUp);
if (GetSpriteTileStartByTag(MOVE_INFO_WINDOW_TAG) == 0xFFFF)
LoadSpriteSheet(&sSpriteSheet_MoveInfoWindow);

if (gBattleStruct->moveInfoSpriteId == MAX_SPRITES)
{
gBattleStruct->moveInfoSpriteId = CreateSprite(&sSpriteTemplate_MoveInfoWindow, LAST_BALL_WIN_X_0, LAST_USED_WIN_Y + 32, 6);
gSprites[gBattleStruct->moveInfoSpriteId].sHide = FALSE;
}
}

void TryToHideMoveInfoWindow(void)
{
gSprites[gBattleStruct->moveInfoSpriteId].sHide = TRUE;
}

static void DestroyMoveInfoWinGfx(struct Sprite *sprite)
{
FreeSpriteTilesByTag(MOVE_INFO_WINDOW_TAG);
FreeSpritePaletteByTag(ABILITY_POP_UP_TAG);
DestroySprite(sprite);
gBattleStruct->moveInfoSpriteId = MAX_SPRITES;
}

static void SpriteCB_LastUsedBallWin(struct Sprite *sprite)
{
if (sprite->sHide)
Expand Down Expand Up @@ -3033,6 +3103,23 @@ static void SpriteCB_LastUsedBall(struct Sprite *sprite)
}
}

static void SpriteCB_MoveInfoWin(struct Sprite *sprite)
{
if (sprite->sHide)
{
if (sprite->x != LAST_BALL_WIN_X_0)
sprite->x--;

if (sprite->x == LAST_BALL_WIN_X_0)
DestroyMoveInfoWinGfx(sprite);
}
else
{
if (sprite->x != LAST_BALL_WIN_X_F)
sprite->x++;
}
}

static void TryHideOrRestoreLastUsedBall(u8 caseId)
{
if (B_LAST_USED_BALL == FALSE)
Expand All @@ -3044,16 +3131,16 @@ static void TryHideOrRestoreLastUsedBall(u8 caseId)
{
case 0: // hide
if (gBattleStruct->ballSpriteIds[0] != MAX_SPRITES)
gSprites[gBattleStruct->ballSpriteIds[0]].sHide = TRUE; // hide
gSprites[gBattleStruct->ballSpriteIds[0]].sHide = TRUE;
if (gBattleStruct->ballSpriteIds[1] != MAX_SPRITES)
gSprites[gBattleStruct->ballSpriteIds[1]].sHide = TRUE; // hide
gSprites[gBattleStruct->ballSpriteIds[1]].sHide = TRUE;
gLastUsedBallMenuPresent = FALSE;
break;
case 1: // restore
if (gBattleStruct->ballSpriteIds[0] != MAX_SPRITES)
gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore
gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE;
if (gBattleStruct->ballSpriteIds[1] != MAX_SPRITES)
gSprites[gBattleStruct->ballSpriteIds[1]].sHide = FALSE; // restore
gSprites[gBattleStruct->ballSpriteIds[1]].sHide = FALSE;
gLastUsedBallMenuPresent = TRUE;
break;
}
Expand Down
32 changes: 18 additions & 14 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5829,11 +5829,12 @@ u32 GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, u8 *ateBoost)
u32 moveType = GetMoveType(move);
u32 moveEffect = GetMoveEffect(move);
u32 species, heldItem, holdEffect, ability, type1, type2, type3;
bool32 monInBattle = gMain.inBattle && gPartyMenu.menuType != PARTY_MENU_TYPE_IN_BATTLE;

if (move == MOVE_STRUGGLE)
return TYPE_NORMAL;

if (gMain.inBattle)
if (monInBattle)
{
species = gBattleMons[battler].species;
heldItem = gBattleMons[battler].item;
Expand All @@ -5857,18 +5858,21 @@ u32 GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, u8 *ateBoost)
switch (moveEffect)
{
case EFFECT_WEATHER_BALL:
if (gMain.inBattle && HasWeatherEffect())
if (monInBattle)
{
if (gBattleWeather & B_WEATHER_RAIN && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA)
return TYPE_WATER;
else if (gBattleWeather & B_WEATHER_SANDSTORM)
return TYPE_ROCK;
else if (gBattleWeather & B_WEATHER_SUN && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA)
return TYPE_FIRE;
else if (gBattleWeather & (B_WEATHER_SNOW | B_WEATHER_HAIL))
return TYPE_ICE;
else
return moveType;
if (HasWeatherEffect())
{
if (gBattleWeather & B_WEATHER_RAIN && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA)
return TYPE_WATER;
else if (gBattleWeather & B_WEATHER_SANDSTORM)
return TYPE_ROCK;
else if (gBattleWeather & B_WEATHER_SUN && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA)
return TYPE_FIRE;
else if (gBattleWeather & (B_WEATHER_SNOW | B_WEATHER_HAIL))
return TYPE_ICE;
else
return moveType;
}
}
else
{
Expand All @@ -5895,7 +5899,7 @@ u32 GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, u8 *ateBoost)
case EFFECT_HIDDEN_POWER:
{
u32 typeBits = 0;
if (gMain.inBattle)
if (monInBattle)
{
typeBits = ((gBattleMons[battler].hpIV & 1) << 0)
| ((gBattleMons[battler].attackIV & 1) << 1)
Expand Down Expand Up @@ -5974,7 +5978,7 @@ u32 GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, u8 *ateBoost)
else
return moveType;
case EFFECT_TERRAIN_PULSE:
if (gMain.inBattle)
if (monInBattle)
{
if (IsBattlerTerrainAffected(battler, STATUS_FIELD_TERRAIN_ANY))
{
Expand Down
Loading

0 comments on commit 64c5113

Please sign in to comment.