Skip to content

Commit

Permalink
Master into upcoming merger (#4833)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Jun 18, 2024
2 parents eb0c3b0 + a24b767 commit cba3cf4
Show file tree
Hide file tree
Showing 24 changed files with 819 additions and 223 deletions.
1 change: 0 additions & 1 deletion data/battle_anim_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -4221,7 +4221,6 @@ Move_SMACK_DOWN::
createvisualtask AnimTask_SmokescreenImpact, 0x8, 0x400, 0x1902
fadetobg BG_IN_AIR
waitbgfadeout
createvisualtask AnimTask_StartSlidingBg, 5, 0x0, 0x0, 0x0, 0xffff
createvisualtask AnimTask_SeismicTossBgAccelerateDownAtEnd, 3
goto SeismicTossWeak

Expand Down
4 changes: 3 additions & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -5828,6 +5828,7 @@ BattleScript_DoSwitchOut::

BattleScript_PursuitDmgOnSwitchOut::
pause B_WAIT_TIME_SHORT
orword gHitMarker, HITMARKER_OBEYS
attackstring
ppreduce
critcalc
Expand All @@ -5845,11 +5846,12 @@ BattleScript_PursuitDmgOnSwitchOut::
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET
moveendfromto MOVEEND_ABILITIES, MOVEEND_CHOICE_MOVE
moveendfromto MOVEEND_ABILITIES, MOVEEND_ATTACKER_INVISIBLE @ MOVEEND_CHOICE_MOVE has to be included
jumpiffainted BS_TARGET, FALSE, BattleScript_PursuitDmgOnSwitchOutRet
setbyte sGIVEEXP_STATE, 0
getexp BS_TARGET
BattleScript_PursuitDmgOnSwitchOutRet:
bicword gHitMarker, HITMARKER_OBEYS
return

BattleScript_Pausex20::
Expand Down
3 changes: 3 additions & 0 deletions data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ MossdeepCity_SpaceCenter_2F_EventScript_DefeatedMaxieTabitha::
setobjectmovementtype LOCALID_SCIENTIST, MOVEMENT_TYPE_WANDER_AROUND
addobject LOCALID_SCIENTIST
fadescreen FADE_FROM_BLACK
#ifdef BUGFIX
releaseall
#endif
end

MossdeepCity_SpaceCenter_2F_EventScript_StevenFacePlayer::
Expand Down
8 changes: 4 additions & 4 deletions include/battle_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ u8 GetBattlerSpriteDefault_Y(u8 battlerId);
u8 GetSubstituteSpriteDefault_Y(u8 battlerId);

// battle_anim_status_effects.c
#define STAT_ANIM_PLUS1 MOVE_EFFECT_ATK_PLUS_1 - 1
#define STAT_ANIM_PLUS2 MOVE_EFFECT_ATK_PLUS_2 - 1
#define STAT_ANIM_MINUS1 MOVE_EFFECT_ATK_MINUS_1 - 1
#define STAT_ANIM_MINUS2 MOVE_EFFECT_ATK_MINUS_2 - 1
#define STAT_ANIM_PLUS1 (MOVE_EFFECT_ATK_PLUS_1 - 1)
#define STAT_ANIM_PLUS2 (MOVE_EFFECT_ATK_PLUS_2 - 1)
#define STAT_ANIM_MINUS1 (MOVE_EFFECT_ATK_MINUS_1 - 1)
#define STAT_ANIM_MINUS2 (MOVE_EFFECT_ATK_MINUS_2 - 1)
#define STAT_ANIM_MULTIPLE_PLUS1 55
#define STAT_ANIM_MULTIPLE_PLUS2 56
#define STAT_ANIM_MULTIPLE_MINUS1 57
Expand Down
15 changes: 8 additions & 7 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,15 @@ struct Roamer
/*0x08*/ u16 species;
/*0x0A*/ u16 hp;
/*0x0C*/ u8 level;
/*0x0D*/ u16 status;
/*0x0F*/ u8 cool;
/*0x10*/ u8 beauty;
/*0x11*/ u8 cute;
/*0x12*/ u8 smart;
/*0x0D*/ u8 statusA;
/*0x0E*/ u8 cool;
/*0x0F*/ u8 beauty;
/*0x10*/ u8 cute;
/*0x11*/ u8 smart;
/*0x12*/ u8 tough;
/*0x13*/ bool8 active;
/*0x14*/ u8 tough;
/*0x15*/ u8 filler[0x7];
/*0x14*/ u8 statusB; // Stores frostbite
/*0x14*/ u8 filler[0x7];
};

struct RamScriptData
Expand Down
3 changes: 3 additions & 0 deletions include/test/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ struct BattleTestData
struct BattleTestRunnerState
{
u8 battlersCount;
bool8 forceMoveAnim;
u16 parametersCount; // Valid only in BattleTest_Setup.
u16 parameters;
u16 runParameter;
Expand Down Expand Up @@ -991,6 +992,8 @@ void SendOut(u32 sourceLine, struct BattlePokemon *, u32 partyIndex);
#define NONE_OF for (OpenQueueGroup(__LINE__, QUEUE_GROUP_NONE_OF); gBattleTestRunnerState->data.queueGroupType != QUEUE_GROUP_NONE; CloseQueueGroup(__LINE__))
#define NOT NONE_OF

#define FORCE_MOVE_ANIM(set) gBattleTestRunnerState->forceMoveAnim = (set)

#define ABILITY_POPUP(battler, ...) QueueAbility(__LINE__, battler, (struct AbilityEventContext) { __VA_ARGS__ })
#define ANIMATION(type, id, ...) QueueAnimation(__LINE__, type, id, (struct AnimationEventContext) { __VA_ARGS__ })
#define HP_BAR(battler, ...) QueueHP(__LINE__, battler, (struct HPEventContext) { R_APPEND_TRUE(__VA_ARGS__) })
Expand Down
2 changes: 1 addition & 1 deletion src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3758,7 +3758,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
ADJUST_SCORE(GOOD_EFFECT);
break;
case EFFECT_SANDSTORM:
if (ShouldSetSandstorm(battlerAtk, aiData->holdEffects[battlerAtk], aiData->holdEffects[battlerAtk]))
if (ShouldSetSandstorm(battlerAtk, aiData->abilities[battlerAtk], aiData->holdEffects[battlerAtk]))
{
ADJUST_SCORE(DECENT_EFFECT);
if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_SMOOTH_ROCK)
Expand Down
2 changes: 1 addition & 1 deletion src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ struct SimulatedDamage AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u
}
else if (gMovesInfo[move].effect == EFFECT_PHOTON_GEYSER)
gBattleStruct->swapDamageCategory = (GetCategoryBasedOnStats(gBattlerAttacker) == DAMAGE_CATEGORY_PHYSICAL);
else if (move == MOVE_SHELL_SIDE_ARM && gBattleStruct->shellSideArmCategory[battlerAtk][battlerDef] == DAMAGE_CATEGORY_SPECIAL)
else if (move == MOVE_SHELL_SIDE_ARM && gBattleStruct->shellSideArmCategory[battlerAtk][battlerDef] == DAMAGE_CATEGORY_PHYSICAL)
gBattleStruct->swapDamageCategory = TRUE;
else if (gMovesInfo[move].effect == EFFECT_NATURE_POWER)
move = GetNaturePowerMove();
Expand Down
8 changes: 6 additions & 2 deletions src/battle_anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "sprite.h"
#include "task.h"
#include "test_runner.h"
#include "test/battle.h"
#include "constants/battle_anim.h"
#include "constants/moves.h"

Expand Down Expand Up @@ -239,6 +240,9 @@ void LaunchBattleAnimation(u32 animType, u32 animId)
TestRunner_Battle_RecordAnimation(animType, animId);
// Play Transform and Ally Switch even in Headless as these move animations also change mon data.
if (gTestRunnerHeadless
#if TESTING // Because gBattleTestRunnerState is not seen outside of test env.
&& !gBattleTestRunnerState->forceMoveAnim
#endif // TESTING
&& !(animType == ANIM_TYPE_MOVE && (animId == MOVE_TRANSFORM || animId == MOVE_ALLY_SWITCH)))
{
gAnimScriptCallback = Nop;
Expand Down Expand Up @@ -446,7 +450,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
u32 i;
u32 ignoredTgt = gBattlerAttacker;
u32 target = GetBattlerMoveTargetType(gBattleAnimAttacker, gAnimMoveIndex);

switch (battlerAnimId)
{
case ANIM_ATTACKER:
Expand All @@ -458,7 +462,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
ignoredTgt = gBattlerAttacker;
break;
}

switch (target)
{
case MOVE_TARGET_FOES_AND_ALLY:
Expand Down
64 changes: 37 additions & 27 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ static void Cmd_damagecalc(void)
u8 moveType;

GET_MOVE_TYPE(gCurrentMove, moveType);
if (gBattleStruct->shellSideArmCategory[gBattlerAttacker][gBattlerTarget] == DAMAGE_CATEGORY_SPECIAL && gCurrentMove == MOVE_SHELL_SIDE_ARM)
if (gBattleStruct->shellSideArmCategory[gBattlerAttacker][gBattlerTarget] == DAMAGE_CATEGORY_PHYSICAL && gCurrentMove == MOVE_SHELL_SIDE_ARM)
gBattleStruct->swapDamageCategory = TRUE;
gBattleMoveDamage = CalculateMoveDamage(gCurrentMove, gBattlerAttacker, gBattlerTarget, moveType, 0, gIsCriticalHit, TRUE, TRUE);
gBattlescriptCurrInstr = cmd->nextInstr;
Expand Down Expand Up @@ -5389,7 +5389,6 @@ static void Cmd_moveend(void)
bool32 effect = FALSE;
u32 moveType = 0;
u32 holdEffectAtk = 0;
u16 *choicedMoveAtk = NULL;
u32 endMode, endState;
u32 originallyUsedMove;

Expand All @@ -5402,7 +5401,6 @@ static void Cmd_moveend(void)
endState = cmd->endState;

holdEffectAtk = GetBattlerHoldEffect(gBattlerAttacker, TRUE);
choicedMoveAtk = &gBattleStruct->choicedMove[gBattlerAttacker];
GET_MOVE_TYPE(gCurrentMove, moveType);

do
Expand Down Expand Up @@ -5612,29 +5610,34 @@ static void Cmd_moveend(void)
gBattleScripting.moveendState++;
break;
case MOVEEND_CHOICE_MOVE: // update choice band move
if (gHitMarker & HITMARKER_OBEYS
&& (HOLD_EFFECT_CHOICE(holdEffectAtk) || GetBattlerAbility(gBattlerAttacker) == ABILITY_GORILLA_TACTICS)
&& gChosenMove != MOVE_STRUGGLE
&& (*choicedMoveAtk == MOVE_NONE || *choicedMoveAtk == MOVE_UNAVAILABLE))
{
if ((gMovesInfo[gChosenMove].effect == EFFECT_BATON_PASS
|| gMovesInfo[gChosenMove].effect == EFFECT_HEALING_WISH)
&& !(gMoveResultFlags & MOVE_RESULT_FAILED))
u16 *choicedMoveAtk = &gBattleStruct->choicedMove[gBattlerAttacker];
if (gHitMarker & HITMARKER_OBEYS
&& (HOLD_EFFECT_CHOICE(holdEffectAtk) || GetBattlerAbility(gBattlerAttacker) == ABILITY_GORILLA_TACTICS)
&& gChosenMove != MOVE_STRUGGLE
&& (*choicedMoveAtk == MOVE_NONE || *choicedMoveAtk == MOVE_UNAVAILABLE))
{
gBattleScripting.moveendState++;
break;
if ((gMovesInfo[gChosenMove].effect == EFFECT_BATON_PASS
|| gMovesInfo[gChosenMove].effect == EFFECT_HEALING_WISH)
&& !(gMoveResultFlags & MOVE_RESULT_FAILED))
{
gBattleScripting.moveendState++;
break;
}
*choicedMoveAtk = gChosenMove;
}
*choicedMoveAtk = gChosenMove;
}
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (gBattleMons[gBattlerAttacker].moves[i] == *choicedMoveAtk)
break;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (gBattleMons[gBattlerAttacker].moves[i] == *choicedMoveAtk)
break;
}
if (i == MAX_MON_MOVES)
{
*choicedMoveAtk = MOVE_NONE;
}
gBattleScripting.moveendState++;
break;
}
if (i == MAX_MON_MOVES)
*choicedMoveAtk = MOVE_NONE;
gBattleScripting.moveendState++;
break;
case MOVEEND_CHANGED_ITEMS: // changed held items
for (i = 0; i < gBattlersCount; i++)
{
Expand Down Expand Up @@ -12825,7 +12828,11 @@ static void Cmd_trysetencore(void)
{
gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i];
gDisableStructs[gBattlerTarget].encoredMovePos = i;
gDisableStructs[gBattlerTarget].encoreTimer = 3;
// Encore always lasts 3 turns, but we need to account for a scenario where Encore changes the move during the same turn.
if (GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget))
gDisableStructs[gBattlerTarget].encoreTimer = 4;
else
gDisableStructs[gBattlerTarget].encoreTimer = 3;
gBattlescriptCurrInstr = cmd->nextInstr;
}
else
Expand Down Expand Up @@ -13543,7 +13550,7 @@ static void Cmd_jumpifnopursuitswitchdmg(void)
gActionsByTurnOrder[i] = B_ACTION_TRY_FINISH;
}

gCurrentMove = gChosenMoveByBattler[gBattlerTarget];
gCurrentMove = gChosenMove = gChosenMoveByBattler[gBattlerTarget];
gCurrMovePos = gChosenMovePos = *(gBattleStruct->chosenMovePositions + gBattlerTarget);
gBattlescriptCurrInstr = cmd->nextInstr;
gBattleScripting.animTurn = 1;
Expand Down Expand Up @@ -16437,9 +16444,9 @@ void BS_SetRemoveTerrain(void)
}
else
{
u16 atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE);
u32 atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE);

gFieldStatuses &= ~STATUS_FIELD_TERRAIN_ANY;
gFieldStatuses &= ~(STATUS_FIELD_TERRAIN_ANY | STATUS_FIELD_TERRAIN_PERMANENT);
gFieldStatuses |= statusFlag;
gFieldTimers.terrainTimer = (atkHoldEffect == HOLD_EFFECT_TERRAIN_EXTENDER) ? 8 : 5;
gBattlescriptCurrInstr = cmd->nextInstr;
Expand Down Expand Up @@ -16537,7 +16544,8 @@ void BS_TryRelicSong(void)
{
NATIVE_ARGS();

if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SHEER_FORCE && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED))
if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SHEER_FORCE && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED)
&& (gBattleMons[gBattlerAttacker].species == SPECIES_MELOETTA_ARIA || gBattleMons[gBattlerAttacker].species == SPECIES_MELOETTA_PIROUETTE))
{
if (gBattleMons[gBattlerAttacker].species == SPECIES_MELOETTA_ARIA)
gBattleMons[gBattlerAttacker].species = SPECIES_MELOETTA_PIROUETTE;
Expand All @@ -16548,7 +16556,9 @@ void BS_TryRelicSong(void)
gBattlescriptCurrInstr = BattleScript_AttackerFormChangeMoveEffect;
}
else
{
gBattlescriptCurrInstr = cmd->nextInstr;
}
}

void BS_SetPledge(void)
Expand Down
Loading

0 comments on commit cba3cf4

Please sign in to comment.