From 34ba9b4e0d4f710f4f0961a7b73902266c06f38a Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 28 Nov 2022 14:36:19 -0500 Subject: [PATCH 01/24] convert a few various to callnatives --- asm/macros/battle_script.inc | 50 ++++++------ include/constants/battle_script_commands.h | 5 -- src/battle_script_commands.c | 95 ++++++++++++++-------- src/battle_z_move.c | 4 +- 4 files changed, 88 insertions(+), 66 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 27c5a86c41..0fa2212292 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1310,6 +1310,33 @@ callnative BS_CalcMetalBurstDmg .4byte \ptr .endm + + .macro setzeffect + callnative BS_SetZEffect + .endm + + @ Used by effects that may proc Symbiosis but do not call removeitem. + .macro trysymbiosis + callnative BS_TrySymbiosis + .endm + + @ returns TRUE or FALSE to gBattleCommunication[0] + .macro canteleport battler:req + callnative BS_CanTeleport + .byte \battler + .endm + + @ returns B_SIDE_x to gBattleCommunication[0] + .macro getbattlerside battler:req + callnative BS_GetBattlerSide + .byte \battler + .endm + + .macro checkparentalbondcounter counter:req, ptr:req + callnative BS_CheckParentalBondCounter + .byte \counter + .4byte \ptr + .endm @ various command changed to more readable macros .macro cancelmultiturnmoves battler:req @@ -1791,10 +1818,6 @@ various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH .endm - .macro setzeffect - various BS_ATTACKER, VARIOUS_SET_Z_EFFECT - .endm - .macro consumeberry battler:req, frombattler:req various \battler, VARIOUS_CONSUME_BERRY .byte \frombattler @@ -1986,20 +2009,6 @@ various BS_ATTACKER, VARIOUS_SWAP_SIDE_STATUSES .endm - .macro canteleport battler:req - various \battler, VARIOUS_CAN_TELEPORT - .endm - - .macro getbattlerside battler:req - various \battler, VARIOUS_GET_BATTLER_SIDE - .endm - - .macro checkparentalbondcounter counter:req, ptr:req - various BS_ATTACKER, VARIOUS_CHECK_PARENTAL_BOND_COUNTER - .byte \counter - .4byte \ptr - .endm - @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7 @@ -2152,8 +2161,3 @@ .macro skydropyawn various 0, VARIOUS_SKY_DROP_YAWN .endm - - @ Used by effects that may proc Symbiosis but do not call removeitem. - .macro trysymbiosis - various BS_ATTACKER, VARIOUS_TRY_SYMBIOSIS - .endm diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 06a09fc179..e8f25f77f3 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -241,11 +241,6 @@ #define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 150 #define VARIOUS_SET_BEAK_BLAST 151 #define VARIOUS_SWAP_SIDE_STATUSES 152 -#define VARIOUS_SET_Z_EFFECT 153 -#define VARIOUS_TRY_SYMBIOSIS 154 -#define VARIOUS_CAN_TELEPORT 155 -#define VARIOUS_GET_BATTLER_SIDE 156 -#define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 157 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b7551ab9ee..770a5444a3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9434,9 +9434,6 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe) } return; - case VARIOUS_SET_Z_EFFECT: - SetZEffect(); //handles battle script jumping internally - return; case VARIOUS_MOVEEND_ITEM_EFFECTS: if (ItemBattleEffects(ITEMEFFECT_NORMAL, gActiveBattler, FALSE)) return; @@ -10035,39 +10032,6 @@ static void Cmd_various(void) case VARIOUS_SWAP_SIDE_STATUSES: CourtChangeSwapSideStatuses(); break; - case VARIOUS_TRY_SYMBIOSIS: //called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem. - if (SYMBIOSIS_CHECK(gActiveBattler, BATTLE_PARTNER(gActiveBattler))) - { - BestowItem(BATTLE_PARTNER(gActiveBattler), gActiveBattler); - gLastUsedAbility = gBattleMons[BATTLE_PARTNER(gActiveBattler)].ability; - gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(gActiveBattler); - gBattlerAttacker = gActiveBattler; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; - return; - } - break; - case VARIOUS_CAN_TELEPORT: - gBattleCommunication[0] = CanTeleport(gActiveBattler); - break; - case VARIOUS_GET_BATTLER_SIDE: - if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - gBattleCommunication[0] = B_SIDE_PLAYER; - else - gBattleCommunication[0] = B_SIDE_OPPONENT; - break; - case VARIOUS_CHECK_PARENTAL_BOND_COUNTER: - { - // Some effects should only happen on the first or second strike of Parental Bond, - // so a way to check this in battle scripts is useful - u8 counter = T1_READ_8(gBattlescriptCurrInstr + 3); - if (gSpecialStatuses[gBattlerAttacker].parentalBondState == counter && gBattleMons[gBattlerTarget].hp != 0) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4); - else - gBattlescriptCurrInstr += 8; - return; - } - break; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3; @@ -14861,3 +14825,62 @@ static bool8 IsFinalStrikeEffect(u16 move) } return FALSE; } + +// 10 bytes long (callnative(5) + counter(1) + ptr(4)) +void BS_CheckParentalBondCounter(void) +{ + // Some effects should only happen on the first or second strike of Parental Bond, + // so a way to check this in battle scripts is useful + u8 counter = T1_READ_8(gBattlescriptCurrInstr + 5); + if (gSpecialStatuses[gBattlerAttacker].parentalBondState == counter && gBattleMons[gBattlerTarget].hp != 0) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 6); + else + gBattlescriptCurrInstr += 10; +} + +// 6 bytes long (callnative(5) + battler(1)) +void BS_GetBattlerSide(void) +{ + u8 battler = gBattlescriptCurrInstr[5]; + if (GetBattlerSide(battler) == B_SIDE_PLAYER) + gBattleCommunication[0] = B_SIDE_PLAYER; + else + gBattleCommunication[0] = B_SIDE_OPPONENT; + + gBattlescriptCurrInstr += 6; +} + +// 6 bytes long (callnative(5) + battler(1)) +void BS_CanTeleport(void) +{ + u8 battler = gBattlescriptCurrInstr[5]; + gBattleCommunication[0] = CanTeleport(battler); + gBattlescriptCurrInstr += 6; +} + +// 5 bytes long +void BS_TrySymbiosis(void) +{ + //called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem. + gActiveBattler = gBattlerAttacker; + if (SYMBIOSIS_CHECK(gBattlerAttacker, BATTLE_PARTNER(gActiveBattler))) + { + BestowItem(BATTLE_PARTNER(gActiveBattler), gActiveBattler); + gLastUsedAbility = gBattleMons[BATTLE_PARTNER(gActiveBattler)].ability; + gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(gActiveBattler); + gBattlerAttacker = gActiveBattler; + BattleScriptPushCursor(gBattlescriptCurrInstr + 5); + gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; + } + else + { + gBattlescriptCurrInstr += 5; + } +} + +void BS_SetZEffect(void) +{ + SetZEffect(); // Handles battle script jumping internally +} + + diff --git a/src/battle_z_move.c b/src/battle_z_move.c index 2eccd82f52..e27304853c 100644 --- a/src/battle_z_move.c +++ b/src/battle_z_move.c @@ -593,7 +593,7 @@ const u8 *GetZMoveName(u16 move) return gZMoveNames[0]; // Failsafe } -#define Z_EFFECT_BS_LENGTH 3 +#define Z_EFFECT_BS_LENGTH 5 // This function kinda cheats by setting a return battle script to after the setzeffect various command // and then jumping to a z effect script void SetZEffect(void) @@ -684,7 +684,7 @@ void SetZEffect(void) gBattlescriptCurrInstr = BattleScript_StatUpZMove; break; default: - gBattlescriptCurrInstr += 3; + gBattlescriptCurrInstr += Z_EFFECT_BS_LENGTH; break; } From cd7abea6fe50f9e75a4712ee5061b378707b4834 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 28 Nov 2022 14:47:56 -0500 Subject: [PATCH 02/24] fix BS_TrySymbiosis --- src/battle_script_commands.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 770a5444a3..55487eab76 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14869,13 +14869,12 @@ void BS_TrySymbiosis(void) gLastUsedAbility = gBattleMons[BATTLE_PARTNER(gActiveBattler)].ability; gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(gActiveBattler); gBattlerAttacker = gActiveBattler; - BattleScriptPushCursor(gBattlescriptCurrInstr + 5); + BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; + return; } - else - { - gBattlescriptCurrInstr += 5; - } + + gBattlescriptCurrInstr += 5; } void BS_SetZEffect(void) From 4b799f2571bc6ba49c190e1bf908566d99992d95 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 28 Nov 2022 15:10:42 -0500 Subject: [PATCH 03/24] optimize BS_GetBattlerSide --- src/battle_script_commands.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 55487eab76..7ad6567373 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14841,12 +14841,7 @@ void BS_CheckParentalBondCounter(void) // 6 bytes long (callnative(5) + battler(1)) void BS_GetBattlerSide(void) { - u8 battler = gBattlescriptCurrInstr[5]; - if (GetBattlerSide(battler) == B_SIDE_PLAYER) - gBattleCommunication[0] = B_SIDE_PLAYER; - else - gBattleCommunication[0] = B_SIDE_OPPONENT; - + gBattleCommunication[0] = GetBattlerSide(gBattlescriptCurrInstr[5]); gBattlescriptCurrInstr += 6; } From f6089a00578ca9e5779f30b4b64f94349f9234e3 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 7 Mar 2023 22:34:57 +0100 Subject: [PATCH 04/24] Mega Evolution after switching and based on speed --- data/battle_scripts_1.s | 8 +-- data/scripts/debug.inc | 1 + include/battle.h | 3 +- include/battle_util.h | 1 - src/battle_main.c | 143 +++++++++++++++++++++---------------- src/battle_util.c | 5 +- src/data/trainer_parties.h | 16 ++--- test/mega_evolution.c | 38 ++++++++++ 8 files changed, 138 insertions(+), 77 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8b93edb78a..ef4a739a54 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -561,7 +561,7 @@ BattleScript_ShellTrapSetUp:: playanimation BS_ATTACKER, B_ANIM_SHELL_TRAP_SETUP, NULL printstring STRINGID_PREPARESHELLTRAP waitmessage B_WAIT_TIME_LONG - end2 + end3 BattleScript_EffectShellTrap:: attackcanceler @@ -635,7 +635,7 @@ BattleScript_BeakBlastSetUp:: playanimation BS_ATTACKER, B_ANIM_BEAK_BLAST_SETUP, NULL printstring STRINGID_HEATUPBEAK waitmessage B_WAIT_TIME_LONG - end2 + end3 BattleScript_BeakBlastBurn:: setbyte cMULTISTRING_CHOOSER, 0 @@ -7825,7 +7825,7 @@ BattleScript_FocusPunchSetUp:: playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP printstring STRINGID_PKMNTIGHTENINGFOCUS waitmessage B_WAIT_TIME_LONG - end2 + end3 BattleScript_MegaEvolution:: printstring STRINGID_MEGAEVOREACTING @@ -7840,7 +7840,7 @@ BattleScript_MegaEvolutionAfeterString: printstring STRINGID_MEGAEVOEVOLVED waitmessage B_WAIT_TIME_LONG switchinabilities BS_ATTACKER - end2 + end3 BattleScript_WishMegaEvolution:: printstring STRINGID_FERVENTWISHREACHED diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 191fe69327..a6f68b1f70 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -55,6 +55,7 @@ Debug_FlagsNotSetMessage_Text: .string "'include/constants/overworld{UNDERSCORE}config.h'!$" Debug_Script_1:: + multi_fixed_2_vs_2 TRAINER_ROXANNE_2, Debug_FlagsNotSetMessage_Text, TRAINER_ROXANNE_3, Debug_FlagsNotSetMessage_Text, TRAINER_ROXANNE_4, 0 end Debug_Script_2:: diff --git a/include/battle.h b/include/battle.h index 83b552e7e1..1ff9ed8cef 100644 --- a/include/battle.h +++ b/include/battle.h @@ -535,7 +535,7 @@ struct BattleStruct u8 dynamicMoveType; u8 wrappedBy[MAX_BATTLERS_COUNT]; u16 assistPossibleMoves[PARTY_SIZE * MAX_MON_MOVES]; // Each of mons can know max 4 moves. - u8 focusPunchBattlerId; + u8 focusPunchBattlers; // as bits u8 battlerPreventingSwitchout; u8 moneyMultiplier:6; u8 moneyMultiplierItem:1; @@ -656,6 +656,7 @@ struct BattleStruct u8 attackerBeforeBounce:2; u8 beatUpSlot:3; bool8 hitSwitchTargetFailed:1; + bool8 effectsBeforeUsingMoveDone:1; // Mega Evo and Focus Punch/Shell Trap effects. u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit. u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) bool8 allowedToChangeFormInWeather[PARTY_SIZE][2]; // For each party member and side, used by Ice Face. diff --git a/include/battle_util.h b/include/battle_util.h index 0661081e43..327ca35ac2 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -195,7 +195,6 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move); bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId); bool32 IsPartnerMonFromSameTrainer(u8 battlerId); u8 GetSplitBasedOnStats(u8 battlerId); -void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast); bool32 TestSheerForceFlag(u8 battler, u16 move); void TryRestoreStolenItems(void); bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item); diff --git a/src/battle_main.c b/src/battle_main.c index 9ea3b66446..4a9910e70e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4773,9 +4773,6 @@ static void SetActionsAndBattlersTurnOrder(void) turnOrderId++; } } - gBattleMainFunc = CheckMegaEvolutionBeforeTurn; - gBattleStruct->mega.battlerId = 0; - return; } else { @@ -4821,8 +4818,8 @@ static void SetActionsAndBattlersTurnOrder(void) } } } - gBattleMainFunc = CheckMegaEvolutionBeforeTurn; - gBattleStruct->mega.battlerId = 0; + gBattleMainFunc = CheckQuickClaw_CustapBerryActivation; + gBattleStruct->quickClawBattlerId = 0; } static void TurnValuesCleanUp(bool8 var0) @@ -4871,48 +4868,96 @@ void SpecialStatusesClear(void) memset(&gSpecialStatuses, 0, sizeof(gSpecialStatuses)); } -static void CheckMegaEvolutionBeforeTurn(void) +static void PopulateArrayWithBattlers(u8 *battlers) { - if (!(gHitMarker & HITMARKER_RUN)) - { - while (gBattleStruct->mega.battlerId < gBattlersCount) - { - gActiveBattler = gBattlerAttacker = gBattleStruct->mega.battlerId; - gBattleStruct->mega.battlerId++; - if (gBattleStruct->mega.toEvolve & gBitTable[gActiveBattler] - && !(gProtectStructs[gActiveBattler].noValidMoves)) - { - struct Pokemon *mon = GetBattlerPartyData(gActiveBattler); + u32 i; + for (i = 0; i < gBattlersCount; i++) + battlers[i] = i; +} +static bool32 TryDoMegaEvosBeforeMoves(void) +{ + if (!(gHitMarker & HITMARKER_RUN) && gBattleStruct->mega.toEvolve) + { + u32 i; + struct Pokemon *mon; + u8 megaOrder[MAX_BATTLERS_COUNT]; + + PopulateArrayWithBattlers(megaOrder); + SortBattlersBySpeed(megaOrder, FALSE); + for (i = 0; i < gBattlersCount; i++) + { + if (gBattleStruct->mega.toEvolve & gBitTable[megaOrder[i]] + && !(gProtectStructs[megaOrder[i]].noValidMoves)) + { + gActiveBattler = gBattlerAttacker = megaOrder[i]; gBattleStruct->mega.toEvolve &= ~(gBitTable[gActiveBattler]); gLastUsedItem = gBattleMons[gActiveBattler].item; + mon = GetBattlerPartyData(gActiveBattler); if (GetWishMegaEvolutionSpecies(GetMonData(mon, MON_DATA_SPECIES), GetMonData(mon, MON_DATA_MOVE1), GetMonData(mon, MON_DATA_MOVE2), GetMonData(mon, MON_DATA_MOVE3), GetMonData(mon, MON_DATA_MOVE4))) BattleScriptExecute(BattleScript_WishMegaEvolution); else BattleScriptExecute(BattleScript_MegaEvolution); - return; + return TRUE; } } } - #if B_MEGA_EVO_TURN_ORDER <= GEN_6 - gBattleMainFunc = CheckChosenMoveForEffectsBeforeTurnStarts; - gBattleStruct->focusPunchBattlerId = 0; - #else - gBattleMainFunc = TryChangeTurnOrder; // This will just do nothing if no mon has mega evolved + #if B_MEGA_EVO_TURN_ORDER >= GEN_7 + TryChangeTurnOrder(); // This will just do nothing if no mon has mega evolved. #endif + return FALSE; +} + +static bool32 TryDoMoveEffectsBeforeMoves(void) +{ + if (!(gHitMarker & HITMARKER_RUN)) + { + u32 i; + struct Pokemon *mon; + u8 battlers[MAX_BATTLERS_COUNT]; + + PopulateArrayWithBattlers(battlers); + SortBattlersBySpeed(battlers, FALSE); + for (i = 0; i < gBattlersCount; i++) + { + if (!(gBattleStruct->focusPunchBattlers & gBitTable[battlers[i]]) + && !(gBattleMons[battlers[i]].status1 & STATUS1_SLEEP) + && !(gDisableStructs[battlers[i]].truantCounter) + && !(gProtectStructs[battlers[i]].noValidMoves)) + { + gBattleStruct->focusPunchBattlers |= gBitTable[battlers[i]]; + gActiveBattler = gBattlerAttacker = battlers[i]; + switch (gChosenMoveByBattler[gActiveBattler]) + { + case MOVE_FOCUS_PUNCH: + BattleScriptExecute(BattleScript_FocusPunchSetUp); + return TRUE; + case MOVE_BEAK_BLAST: + BattleScriptExecute(BattleScript_BeakBlastSetUp); + return TRUE; + case MOVE_SHELL_TRAP: + BattleScriptExecute(BattleScript_ShellTrapSetUp); + return TRUE; + } + } + } + } + + return FALSE; } // In gen7, priority and speed are recalculated during the turn in which a pokemon mega evolves static void TryChangeTurnOrder(void) { - s32 i, j; + u32 i, j; for (i = 0; i < gBattlersCount - 1; i++) { for (j = i + 1; j < gBattlersCount; j++) { - u8 battler1 = gBattlerByTurnOrder[i]; - u8 battler2 = gBattlerByTurnOrder[j]; + u32 battler1 = gBattlerByTurnOrder[i]; + u32 battler2 = gBattlerByTurnOrder[j]; + if (gActionsByTurnOrder[i] == B_ACTION_USE_MOVE && gActionsByTurnOrder[j] == B_ACTION_USE_MOVE) { @@ -4921,42 +4966,6 @@ static void TryChangeTurnOrder(void) } } } - gBattleMainFunc = CheckChosenMoveForEffectsBeforeTurnStarts; - gBattleStruct->focusPunchBattlerId = 0; -} - -static void CheckChosenMoveForEffectsBeforeTurnStarts(void) -{ - u32 i; - - if (!(gHitMarker & HITMARKER_RUN)) - { - while (gBattleStruct->focusPunchBattlerId < gBattlersCount) - { - gActiveBattler = gBattlerAttacker = gBattleStruct->focusPunchBattlerId; - gBattleStruct->focusPunchBattlerId++; - if (!(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) - && !(gDisableStructs[gBattlerAttacker].truantCounter) - && !(gProtectStructs[gActiveBattler].noValidMoves)) - { - switch (gChosenMoveByBattler[gActiveBattler]) - { - case MOVE_FOCUS_PUNCH: - BattleScriptExecute(BattleScript_FocusPunchSetUp); - return; - case MOVE_BEAK_BLAST: - BattleScriptExecute(BattleScript_BeakBlastSetUp); - return; - case MOVE_SHELL_TRAP: - BattleScriptExecute(BattleScript_ShellTrapSetUp); - return; - } - } - } - } - - gBattleMainFunc = CheckQuickClaw_CustapBerryActivation; - gBattleStruct->quickClawBattlerId = 0; } static void CheckQuickClaw_CustapBerryActivation(void) @@ -5011,6 +5020,8 @@ static void CheckQuickClaw_CustapBerryActivation(void) gCurrentTurnActionNumber = 0; gCurrentActionFuncId = gActionsByTurnOrder[0]; gBattleStruct->dynamicMoveType = 0; + gBattleStruct->effectsBeforeUsingMoveDone = FALSE; + gBattleStruct->focusPunchBattlers = 0; for (i = 0; i < MAX_BATTLERS_COUNT; i++) { gBattleStruct->ateBoost[i] = FALSE; @@ -5029,6 +5040,16 @@ static void RunTurnActionsFunctions(void) if (gBattleOutcome != 0) gCurrentActionFuncId = B_ACTION_FINISHED; + // Mega Evolve / Focus Punch-like moves after switching, items, running, but before using a move. + if (gCurrentActionFuncId == B_ACTION_USE_MOVE && !gBattleStruct->effectsBeforeUsingMoveDone) + { + if (TryDoMegaEvosBeforeMoves()) + return; + else if (TryDoMoveEffectsBeforeMoves()) + return; + gBattleStruct->effectsBeforeUsingMoveDone = TRUE; + } + *(&gBattleStruct->savedTurnActionNumber) = gCurrentTurnActionNumber; sTurnActionsFuncsTable[gCurrentActionFuncId](); diff --git a/src/battle_util.c b/src/battle_util.c index 9520e761f7..e709733251 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1674,7 +1674,8 @@ void BattleScriptPushCursor(void) void BattleScriptPop(void) { - gBattlescriptCurrInstr = gBattleResources->battleScriptsStack->ptr[--gBattleResources->battleScriptsStack->size]; + if (gBattleResources->battleScriptsStack->size != 0) + gBattlescriptCurrInstr = gBattleResources->battleScriptsStack->ptr[--gBattleResources->battleScriptsStack->size]; } static bool32 IsGravityPreventingMove(u32 move) @@ -10567,7 +10568,7 @@ bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability) void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast) { int i, j, currSpeed, currBattler; - u16 speeds[4] = {0}; + u16 speeds[MAX_BATTLERS_COUNT] = {0}; for (i = 0; i < gBattlersCount; i++) speeds[i] = GetBattlerTotalSpeedStat(battlers[i]); diff --git a/src/data/trainer_parties.h b/src/data/trainer_parties.h index 1759120b7f..b4f6175799 100644 --- a/src/data/trainer_parties.h +++ b/src/data/trainer_parties.h @@ -10301,9 +10301,9 @@ static const struct TrainerMonNoItemDefaultMoves sParty_MayRustboroTorchic[] = { static const struct TrainerMonItemCustomMoves sParty_Roxanne2[] = { { .iv = 255, - .lvl = 32, - .species = SPECIES_GOLEM, - .heldItem = ITEM_NONE, + .lvl = 5, + .species = SPECIES_AMPHAROS, + .heldItem = ITEM_AMPHAROSITE, .moves = {MOVE_PROTECT, MOVE_ROLLOUT, MOVE_MAGNITUDE, MOVE_EXPLOSION} }, { @@ -10333,8 +10333,8 @@ static const struct TrainerMonItemCustomMoves sParty_Roxanne3[] = { { .iv = 255, .lvl = 37, - .species = SPECIES_OMANYTE, - .heldItem = ITEM_NONE, + .species = SPECIES_MANECTRIC, + .heldItem = ITEM_MANECTITE, .moves = {MOVE_PROTECT, MOVE_ICE_BEAM, MOVE_ROCK_SLIDE, MOVE_SURF} }, { @@ -10370,9 +10370,9 @@ static const struct TrainerMonItemCustomMoves sParty_Roxanne3[] = { static const struct TrainerMonItemCustomMoves sParty_Roxanne4[] = { { .iv = 255, - .lvl = 42, - .species = SPECIES_OMASTAR, - .heldItem = ITEM_NONE, + .lvl = 100, + .species = SPECIES_GARDEVOIR, + .heldItem = ITEM_GARDEVOIRITE, .moves = {MOVE_PROTECT, MOVE_ICE_BEAM, MOVE_ROCK_SLIDE, MOVE_SURF} }, { diff --git a/test/mega_evolution.c b/test/mega_evolution.c index 13e9cd5b22..49861daaa8 100644 --- a/test/mega_evolution.c +++ b/test/mega_evolution.c @@ -17,6 +17,44 @@ SINGLE_BATTLE_TEST("Venusaur can Mega Evolve holding Venusaurite") } } +DOUBLE_BATTLE_TEST("Mega Evolution's order is determined by Speed - opponent faster") +{ + GIVEN { + PLAYER(SPECIES_VENUSAUR) { Item(ITEM_VENUSAURITE); Speed(1); } + PLAYER(SPECIES_WOBBUFFET) { Speed(3);} + OPPONENT(SPECIES_GARDEVOIR) { Item(ITEM_GARDEVOIRITE); Speed(3);} + OPPONENT(SPECIES_WOBBUFFET) { Speed(4);} + } WHEN { + TURN { MOVE(opponentLeft, MOVE_CELEBRATE, megaEvolve: TRUE); MOVE(playerLeft, MOVE_CELEBRATE, megaEvolve: TRUE); } + } SCENE { + MESSAGE("Foe Gardevoir's Gardevoirite is reacting to 's Mega Ring!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, opponentLeft); + MESSAGE("Foe Gardevoir has Mega Evolved into Mega Gardevoir!"); + MESSAGE("Venusaur's Venusaurite is reacting to 1's Mega Ring!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, playerLeft); + MESSAGE("Venusaur has Mega Evolved into Mega Venusaur!"); + } +} + +DOUBLE_BATTLE_TEST("Mega Evolution's order is determined by Speed - player faster") +{ + GIVEN { + PLAYER(SPECIES_VENUSAUR) { Item(ITEM_VENUSAURITE); Speed(5); } + PLAYER(SPECIES_WOBBUFFET) { Speed(3);} + OPPONENT(SPECIES_GARDEVOIR) { Item(ITEM_GARDEVOIRITE); Speed(2);} + OPPONENT(SPECIES_WOBBUFFET) { Speed(4);} + } WHEN { + TURN { MOVE(opponentLeft, MOVE_CELEBRATE, megaEvolve: TRUE); MOVE(playerLeft, MOVE_CELEBRATE, megaEvolve: TRUE); } + } SCENE { + MESSAGE("Venusaur's Venusaurite is reacting to 1's Mega Ring!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, playerLeft); + MESSAGE("Venusaur has Mega Evolved into Mega Venusaur!"); + MESSAGE("Foe Gardevoir's Gardevoirite is reacting to 's Mega Ring!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, opponentLeft); + MESSAGE("Foe Gardevoir has Mega Evolved into Mega Gardevoir!"); + } +} + SINGLE_BATTLE_TEST("Rayquaza can Mega Evolve knowing Dragon Ascent") { GIVEN { From 51c8edd8255532727a57022ebc98a570815ed5fb Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 8 Mar 2023 13:22:53 +0100 Subject: [PATCH 05/24] Add tests for Mega Evo, Focus Punch, Beak Blast --- src/battle_message.c | 6 +- src/battle_script_commands.c | 3 + src/data/trainer_parties.h | 22 +++---- test/mega_evolution.c | 49 ++++++++++++++ test/move_effect_beak_blast.c | 113 +++++++++++++++++++++++++++++++++ test/move_effect_focus_punch.c | 76 ++++++++++++++++++++++ 6 files changed, 257 insertions(+), 12 deletions(-) create mode 100644 test/move_effect_beak_blast.c create mode 100644 test/move_effect_focus_punch.c diff --git a/src/battle_message.c b/src/battle_message.c index cf57247bf8..705fdc3264 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3027,7 +3027,11 @@ static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId) toCpy = gSaveBlock2Ptr->playerName; break; case B_POSITION_PLAYER_RIGHT: - if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_MULTI)) + if ((gBattleTypeFlags & BATTLE_TYPE_RECORDED) && !(gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER))) + { + toCpy = gLinkPlayers[0].name; + } + else if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_MULTI)) { toCpy = gLinkPlayers[2].name; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 126ca06fd1..caad6393c3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5464,6 +5464,9 @@ static void Cmd_moveend(void) { gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; gBattleMons[gBattlerAttacker].status1 = STATUS1_BURN; + gActiveBattler = gBattlerAttacker; + BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1); + MarkBattlerForControllerExec(gActiveBattler); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BeakBlastBurn; effect = 1; diff --git a/src/data/trainer_parties.h b/src/data/trainer_parties.h index b4f6175799..76c3b6ca43 100644 --- a/src/data/trainer_parties.h +++ b/src/data/trainer_parties.h @@ -10301,31 +10301,31 @@ static const struct TrainerMonNoItemDefaultMoves sParty_MayRustboroTorchic[] = { static const struct TrainerMonItemCustomMoves sParty_Roxanne2[] = { { .iv = 255, - .lvl = 5, - .species = SPECIES_AMPHAROS, - .heldItem = ITEM_AMPHAROSITE, - .moves = {MOVE_PROTECT, MOVE_ROLLOUT, MOVE_MAGNITUDE, MOVE_EXPLOSION} + .lvl = 100, + .species = SPECIES_BEEDRILL, + .heldItem = 0, + .moves = {MOVE_FLING} }, { .iv = 255, - .lvl = 35, + .lvl = 100, .species = SPECIES_KABUTO, .heldItem = ITEM_SITRUS_BERRY, .moves = {MOVE_SWORDS_DANCE, MOVE_ICE_BEAM, MOVE_SURF, MOVE_ROCK_SLIDE} }, { .iv = 255, - .lvl = 35, - .species = SPECIES_ONIX, + .lvl = 100, + .species = SPECIES_THUNDURUS, .heldItem = ITEM_NONE, - .moves = {MOVE_IRON_TAIL, MOVE_EXPLOSION, MOVE_ROAR, MOVE_ROCK_SLIDE} + .moves = {MOVE_THUNDER, MOVE_EXPLOSION, MOVE_ROAR, MOVE_ROCK_SLIDE} }, { .iv = 255, - .lvl = 37, - .species = SPECIES_NOSEPASS, + .lvl = 99, + .species = SPECIES_SABLEYE, .heldItem = ITEM_SITRUS_BERRY, - .moves = {MOVE_DOUBLE_TEAM, MOVE_EXPLOSION, MOVE_PROTECT, MOVE_ROCK_SLIDE} + .moves = {MOVE_DOUBLE_TEAM, MOVE_EXPLOSION, MOVE_DARK_PULSE, MOVE_IRON_HEAD} } }; diff --git a/test/mega_evolution.c b/test/mega_evolution.c index 49861daaa8..8d6af1d21d 100644 --- a/test/mega_evolution.c +++ b/test/mega_evolution.c @@ -104,3 +104,52 @@ SINGLE_BATTLE_TEST("Abilities replaced by Mega Evolution do not affect turn orde ASSUME(player->speed == 45); } } + +DOUBLE_BATTLE_TEST("Mega Evolution happens after switching, but before Focus Punch-like Moves") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_FOCUS_PUNCH].effect == EFFECT_FOCUS_PUNCH); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_VENUSAUR) { Item(ITEM_VENUSAURITE);} + OPPONENT(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { SWITCH(opponentRight, 2); MOVE(playerRight, MOVE_FOCUS_PUNCH, megaEvolve: TRUE, target:opponentLeft); MOVE(playerLeft, MOVE_FOCUS_PUNCH, target:opponentLeft); } + TURN {}; + } SCENE { + MESSAGE("2 withdrew Wobbuffet!"); + MESSAGE("2 sent out Wobbuffet!"); + + MESSAGE("Venusaur's Venusaurite is reacting to 1's Mega Ring!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, playerRight); + MESSAGE("Venusaur has Mega Evolved into Mega Venusaur!"); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerRight); + MESSAGE("Venusaur is tightening its focus!"); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerLeft); + MESSAGE("Wobbuffet is tightening its focus!"); + } +} + +SINGLE_BATTLE_TEST("Regular Mega Evolution and Fervent Wish Mega Evolution can happen on the same turn") +{ + GIVEN { + PLAYER(SPECIES_RAYQUAZA) { Moves(MOVE_DRAGON_ASCENT, MOVE_CELEBRATE); Speed(3);} + OPPONENT(SPECIES_GARDEVOIR) { Item(ITEM_GARDEVOIRITE); Speed(2);} + } WHEN { + TURN { MOVE(player, MOVE_CELEBRATE, megaEvolve: TRUE); MOVE(opponent, MOVE_CELEBRATE, megaEvolve: TRUE); } + } SCENE { + MESSAGE("1's fervent wish has reached Rayquaza!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, player); + MESSAGE("Rayquaza has Mega Evolved into Mega Rayquaza!"); + + MESSAGE("Foe Gardevoir's Gardevoirite is reacting to 's Mega Ring!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, opponent); + MESSAGE("Foe Gardevoir has Mega Evolved into Mega Gardevoir!"); + } THEN { + EXPECT_EQ(player->species, SPECIES_RAYQUAZA_MEGA); + EXPECT_EQ(opponent->species, SPECIES_GARDEVOIR_MEGA); + } +} diff --git a/test/move_effect_beak_blast.c b/test/move_effect_beak_blast.c new file mode 100644 index 0000000000..448eb6973f --- /dev/null +++ b/test/move_effect_beak_blast.c @@ -0,0 +1,113 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_BEAK_BLAST].effect == EFFECT_BEAK_BLAST); +} + +DOUBLE_BATTLE_TEST("Beak Blast's charging message is shown before other moves are used") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_BEAK_BLAST].priority < 0); + PLAYER(SPECIES_WYNAUT) {Speed(10); } + PLAYER(SPECIES_WOBBUFFET) {Speed(5); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(2); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(3); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_BEAK_BLAST, target:opponentLeft); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_BEAK_BLAST_SETUP, playerLeft); + MESSAGE("Wynaut started heating up its beak!"); + + MESSAGE("Wobbuffet used Celebrate!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, playerRight); + MESSAGE("Foe Wobbuffet used Celebrate!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponentRight); + MESSAGE("Foe Wobbuffet used Celebrate!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponentLeft); + + MESSAGE("Wynaut used Beak Blast!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_BEAK_BLAST, playerLeft); + HP_BAR(opponentLeft); + } +} + +DOUBLE_BATTLE_TEST("Beak Blast burns all who make contact with the pokemon") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_BEAK_BLAST].priority < 0); + ASSUME(gBattleMoves[MOVE_TACKLE].flags & FLAG_MAKES_CONTACT); + PLAYER(SPECIES_WYNAUT) {Speed(10); } + PLAYER(SPECIES_WOBBUFFET) {Speed(5); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(3); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(2); } + } WHEN { + TURN { MOVE(opponentLeft, MOVE_TACKLE, target:playerLeft); MOVE(opponentRight, MOVE_TACKLE, target:playerLeft); MOVE(playerLeft, MOVE_BEAK_BLAST, target:opponentLeft); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_BEAK_BLAST_SETUP, playerLeft); + MESSAGE("Wynaut started heating up its beak!"); + + MESSAGE("Wobbuffet used Celebrate!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, playerRight); + + MESSAGE("Foe Wobbuffet used Tackle!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft); + HP_BAR(playerLeft); + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponentLeft); + MESSAGE("Foe Wobbuffet was burned!"); + STATUS_ICON(opponentLeft, burn: TRUE); + + MESSAGE("Foe Wobbuffet used Tackle!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentRight); + HP_BAR(playerLeft); + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponentRight); + MESSAGE("Foe Wobbuffet was burned!"); + STATUS_ICON(opponentRight, burn: TRUE); + + MESSAGE("Wynaut used Beak Blast!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_BEAK_BLAST, playerLeft); + HP_BAR(opponentLeft); + } +} + +SINGLE_BATTLE_TEST("Beak Blast burns only when contact moves are used") +{ + u32 move; + bool32 burn; + PARAMETRIZE { move = MOVE_TACKLE; burn = TRUE; } + PARAMETRIZE { move = MOVE_WATER_GUN; burn = FALSE; } + PARAMETRIZE { move = MOVE_LEER; burn = FALSE; } + + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].flags & FLAG_MAKES_CONTACT); + ASSUME(!(gBattleMoves[MOVE_WATER_GUN].flags & FLAG_MAKES_CONTACT)); + ASSUME(!(gBattleMoves[MOVE_LEER].flags & FLAG_MAKES_CONTACT)); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_BEAK_BLAST); MOVE(opponent, move); } + TURN {} + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_BEAK_BLAST_SETUP, player); + MESSAGE("Wobbuffet started heating up its beak!"); + ANIMATION(ANIM_TYPE_MOVE, move, opponent); + + if (burn) { + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponent); + MESSAGE("Foe Wobbuffet was burned!"); + STATUS_ICON(opponent, burn: TRUE); + } + else { + NONE_OF { + ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponent); + MESSAGE("Foe Wobbuffet was burned!"); + STATUS_ICON(opponent, burn: TRUE); + } + } + + MESSAGE("Wobbuffet used Beak Blast!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_BEAK_BLAST, player); + HP_BAR(opponent); + } +} diff --git a/test/move_effect_focus_punch.c b/test/move_effect_focus_punch.c new file mode 100644 index 0000000000..62c5003001 --- /dev/null +++ b/test/move_effect_focus_punch.c @@ -0,0 +1,76 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_FOCUS_PUNCH].effect == EFFECT_FOCUS_PUNCH); +} + +SINGLE_BATTLE_TEST("Focus Punch activates only if not damaged") +{ + u32 move; + bool32 activate; + PARAMETRIZE { move = MOVE_TACKLE; activate = FALSE; } + PARAMETRIZE { move = MOVE_WATER_GUN; activate = FALSE; } + PARAMETRIZE { move = MOVE_LEER; activate = TRUE; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_FOCUS_PUNCH); MOVE(opponent, move); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, player); + MESSAGE("Wobbuffet is tightening its focus!"); + ANIMATION(ANIM_TYPE_MOVE, move, opponent); + + if (activate) { + MESSAGE("Wobbuffet used Focus Punch!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, player); + HP_BAR(opponent); + } else { + MESSAGE("Wobbuffet lost its focus and couldn't move!"); + NONE_OF { + MESSAGE("Wobbuffet used Focus Punch!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, player); + HP_BAR(opponent); + } + } + } +} + +DOUBLE_BATTLE_TEST("Focus Punch activation is based on Speed") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) {Speed(2) ;} + PLAYER(SPECIES_WYNAUT) {Speed(3) ;} + OPPONENT(SPECIES_WOBBUFFET) {Speed(1) ;} + OPPONENT(SPECIES_WYNAUT) {Speed(5) ;} + } WHEN { + TURN { MOVE(opponentRight, MOVE_FOCUS_PUNCH, target:playerLeft); MOVE(playerRight, MOVE_FOCUS_PUNCH, target:opponentLeft); MOVE(playerLeft, MOVE_FOCUS_PUNCH, target:opponentLeft); MOVE(opponentLeft, MOVE_FOCUS_PUNCH, target:playerLeft); } + } + SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, opponentRight); + MESSAGE("Foe Wynaut is tightening its focus!"); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerRight); + MESSAGE("Wynaut is tightening its focus!"); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerLeft); + MESSAGE("Wobbuffet is tightening its focus!"); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, opponentLeft); + MESSAGE("Foe Wobbuffet is tightening its focus!"); + + MESSAGE("Foe Wynaut used Focus Punch!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, opponentRight); + HP_BAR(playerLeft); + + MESSAGE("Wynaut used Focus Punch!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, playerRight); + HP_BAR(opponentLeft); + + MESSAGE("Wobbuffet lost its focus and couldn't move!"); + MESSAGE("Foe Wobbuffet lost its focus and couldn't move!"); + } +} From bf4735e87c613599b299986fc8e64b120e35a111 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 8 Mar 2023 13:41:08 +0100 Subject: [PATCH 06/24] remove test changes --- data/scripts/debug.inc | 1 - src/data/trainer_parties.h | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index a6f68b1f70..191fe69327 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -55,7 +55,6 @@ Debug_FlagsNotSetMessage_Text: .string "'include/constants/overworld{UNDERSCORE}config.h'!$" Debug_Script_1:: - multi_fixed_2_vs_2 TRAINER_ROXANNE_2, Debug_FlagsNotSetMessage_Text, TRAINER_ROXANNE_3, Debug_FlagsNotSetMessage_Text, TRAINER_ROXANNE_4, 0 end Debug_Script_2:: diff --git a/src/data/trainer_parties.h b/src/data/trainer_parties.h index 76c3b6ca43..1759120b7f 100644 --- a/src/data/trainer_parties.h +++ b/src/data/trainer_parties.h @@ -10301,31 +10301,31 @@ static const struct TrainerMonNoItemDefaultMoves sParty_MayRustboroTorchic[] = { static const struct TrainerMonItemCustomMoves sParty_Roxanne2[] = { { .iv = 255, - .lvl = 100, - .species = SPECIES_BEEDRILL, - .heldItem = 0, - .moves = {MOVE_FLING} + .lvl = 32, + .species = SPECIES_GOLEM, + .heldItem = ITEM_NONE, + .moves = {MOVE_PROTECT, MOVE_ROLLOUT, MOVE_MAGNITUDE, MOVE_EXPLOSION} }, { .iv = 255, - .lvl = 100, + .lvl = 35, .species = SPECIES_KABUTO, .heldItem = ITEM_SITRUS_BERRY, .moves = {MOVE_SWORDS_DANCE, MOVE_ICE_BEAM, MOVE_SURF, MOVE_ROCK_SLIDE} }, { .iv = 255, - .lvl = 100, - .species = SPECIES_THUNDURUS, + .lvl = 35, + .species = SPECIES_ONIX, .heldItem = ITEM_NONE, - .moves = {MOVE_THUNDER, MOVE_EXPLOSION, MOVE_ROAR, MOVE_ROCK_SLIDE} + .moves = {MOVE_IRON_TAIL, MOVE_EXPLOSION, MOVE_ROAR, MOVE_ROCK_SLIDE} }, { .iv = 255, - .lvl = 99, - .species = SPECIES_SABLEYE, + .lvl = 37, + .species = SPECIES_NOSEPASS, .heldItem = ITEM_SITRUS_BERRY, - .moves = {MOVE_DOUBLE_TEAM, MOVE_EXPLOSION, MOVE_DARK_PULSE, MOVE_IRON_HEAD} + .moves = {MOVE_DOUBLE_TEAM, MOVE_EXPLOSION, MOVE_PROTECT, MOVE_ROCK_SLIDE} } }; @@ -10333,8 +10333,8 @@ static const struct TrainerMonItemCustomMoves sParty_Roxanne3[] = { { .iv = 255, .lvl = 37, - .species = SPECIES_MANECTRIC, - .heldItem = ITEM_MANECTITE, + .species = SPECIES_OMANYTE, + .heldItem = ITEM_NONE, .moves = {MOVE_PROTECT, MOVE_ICE_BEAM, MOVE_ROCK_SLIDE, MOVE_SURF} }, { @@ -10370,9 +10370,9 @@ static const struct TrainerMonItemCustomMoves sParty_Roxanne3[] = { static const struct TrainerMonItemCustomMoves sParty_Roxanne4[] = { { .iv = 255, - .lvl = 100, - .species = SPECIES_GARDEVOIR, - .heldItem = ITEM_GARDEVOIRITE, + .lvl = 42, + .species = SPECIES_OMASTAR, + .heldItem = ITEM_NONE, .moves = {MOVE_PROTECT, MOVE_ICE_BEAM, MOVE_ROCK_SLIDE, MOVE_SURF} }, { From e83e08f21c2d05c8a844fce17a5da55abb96ccee Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 26 Apr 2023 12:32:43 -0400 Subject: [PATCH 07/24] Add time ranges to UpdateAmbientCry --- src/overworld.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/overworld.c b/src/overworld.c index 70b102fd28..3d46fc5005 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1260,23 +1260,34 @@ static void PlayAmbientCry(void) PlayCry_NormalNoDucking(sAmbientCrySpecies, pan, volume, CRY_PRIORITY_AMBIENT); } +// States for UpdateAmbientCry +enum { + AMB_CRY_INIT, + AMB_CRY_FIRST, + AMB_CRY_RESET, + AMB_CRY_WAIT, + AMB_CRY_IDLE, +}; + void UpdateAmbientCry(s16 *state, u16 *delayCounter) { u8 i, monsCount, divBy; switch (*state) { - case 0: + case AMB_CRY_INIT: + // This state will be revisited whenever ResetFieldTasksArgs is called (which happens on map transition) if (sAmbientCrySpecies == SPECIES_NONE) - *state = 4; + *state = AMB_CRY_IDLE; else - *state = 1; + *state = AMB_CRY_FIRST; break; - case 1: + case AMB_CRY_FIRST: + // It takes between 1200-3599 frames (~20-60 seconds) to play the first ambient cry after entering a map *delayCounter = (Random() % 2400) + 1200; - *state = 3; + *state = AMB_CRY_WAIT; break; - case 2: + case AMB_CRY_RESET: divBy = 1; monsCount = CalculatePlayerPartyCount(); for (i = 0; i < monsCount; i++) @@ -1288,18 +1299,20 @@ void UpdateAmbientCry(s16 *state, u16 *delayCounter) break; } } + // Ambient cries after the first one take between 1200-2399 frames (~20-40 seconds) + // If the player has a pokemon with the ability Swarm in their party, the time is halved to 600-1199 frames (~10-20 seconds) *delayCounter = ((Random() % 1200) + 1200) / divBy; - *state = 3; + *state = AMB_CRY_WAIT; break; - case 3: - (*delayCounter)--; - if (*delayCounter == 0) + case AMB_CRY_WAIT: + if (--(*delayCounter) == 0) { PlayAmbientCry(); - *state = 2; + *state = AMB_CRY_RESET; } break; - case 4: + case AMB_CRY_IDLE: + // No land/water pokemon on this map break; } } From 36e6981ac0df338f85cb49a3c1d56f4410dbe007 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 26 Apr 2023 16:12:00 -0400 Subject: [PATCH 08/24] Replace some & usage with % --- src/event_object_movement.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 3025e0849a..d4b89fbae1 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2575,7 +2575,7 @@ bool8 MovementType_WanderAround_Step2(struct ObjectEvent *objectEvent, struct Sp { if (!ObjectEventExecSingleMovementAction(objectEvent, sprite)) return FALSE; - SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]); sprite->sTypeFuncId = 3; return TRUE; } @@ -2855,7 +2855,7 @@ bool8 MovementType_LookAround_Step2(struct ObjectEvent *objectEvent, struct Spri { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -2907,7 +2907,7 @@ bool8 MovementType_WanderUpAndDown_Step2(struct ObjectEvent *objectEvent, struct if (!ObjectEventExecSingleMovementAction(objectEvent, sprite)) return FALSE; - SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]); sprite->sTypeFuncId = 3; return TRUE; } @@ -2975,7 +2975,7 @@ bool8 MovementType_WanderLeftAndRight_Step2(struct ObjectEvent *objectEvent, str if (!ObjectEventExecSingleMovementAction(objectEvent, sprite)) return FALSE; - SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]); sprite->sTypeFuncId = 3; return TRUE; } @@ -3195,7 +3195,7 @@ bool8 MovementType_FaceDownAndUp_Step2(struct ObjectEvent *objectEvent, struct S { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3245,7 +3245,7 @@ bool8 MovementType_FaceLeftAndRight_Step2(struct ObjectEvent *objectEvent, struc { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3295,7 +3295,7 @@ bool8 MovementType_FaceUpAndLeft_Step2(struct ObjectEvent *objectEvent, struct S { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3345,7 +3345,7 @@ bool8 MovementType_FaceUpAndRight_Step2(struct ObjectEvent *objectEvent, struct { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3395,7 +3395,7 @@ bool8 MovementType_FaceDownAndLeft_Step2(struct ObjectEvent *objectEvent, struct { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3445,7 +3445,7 @@ bool8 MovementType_FaceDownAndRight_Step2(struct ObjectEvent *objectEvent, struc { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3495,7 +3495,7 @@ bool8 MovementType_FaceDownUpAndLeft_Step2(struct ObjectEvent *objectEvent, stru { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3545,7 +3545,7 @@ bool8 MovementType_FaceDownUpAndRight_Step2(struct ObjectEvent *objectEvent, str { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3595,7 +3595,7 @@ bool8 MovementType_FaceUpLeftAndRight_Step2(struct ObjectEvent *objectEvent, str { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } @@ -3645,7 +3645,7 @@ bool8 MovementType_FaceDownLeftAndRight_Step2(struct ObjectEvent *objectEvent, s { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]); objectEvent->singleMovementActive = FALSE; sprite->sTypeFuncId = 3; } From c2dad5ac44960f6d7b762c5ebb8199b66c1090df Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 27 Apr 2023 13:59:09 -0400 Subject: [PATCH 09/24] Redefine TV_SHOWS_COUNT --- include/constants/global.h | 1 - include/constants/tv.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/global.h b/include/constants/global.h index 8e40e63786..04f1d548c4 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -46,7 +46,6 @@ #define OBJECT_EVENTS_COUNT 16 #define MAIL_COUNT (10 + PARTY_SIZE) #define SECRET_BASES_COUNT 20 -#define TV_SHOWS_COUNT 25 #define POKE_NEWS_COUNT 16 #define PC_ITEMS_COUNT 50 #define BAG_ITEMS_COUNT 30 diff --git a/include/constants/tv.h b/include/constants/tv.h index 87748a31de..13ec88ecdc 100644 --- a/include/constants/tv.h +++ b/include/constants/tv.h @@ -74,6 +74,7 @@ // for TV shows from TVGROUP_NORMAL. The remainder are for TV // shows from TVGROUP_RECORD_MIX. #define NUM_NORMAL_TVSHOW_SLOTS 5 +#define TV_SHOWS_COUNT (NUM_NORMAL_TVSHOW_SLOTS + 20) #define PLAYERS_HOUSE_TV_NONE 0 #define PLAYERS_HOUSE_TV_LATI 1 From 8e5347b450f4b655cc58a783de70e14b0fd115e1 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 21 Apr 2023 03:20:36 -0400 Subject: [PATCH 10/24] Fix mapjson misreporting errors when processing map_groups.json --- tools/mapjson/mapjson.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index cfe95c485a..e53ac7924d 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -75,6 +75,9 @@ string json_to_string(const Json &data, const string &field = "", bool silent = case Json::Type::BOOL: output = value.bool_value() ? "TRUE" : "FALSE"; break; + case Json::Type::NUL: + output = ""; + break; default:{ if (!silent) { string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field"; @@ -459,23 +462,24 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) { for (auto &group : groups_data["group_order"].array_items()) { string groupName = json_to_string(group); text << "// " << groupName << "\n"; - vector map_ids; + vector map_ids; size_t max_length = 0; for (auto &map_name : groups_data[groupName].array_items()) { - string header_filepath = file_dir + json_to_string(map_name) + dir_separator + "map.json"; + string map_filepath = file_dir + json_to_string(map_name) + dir_separator + "map.json"; string err_str; - Json map_data = Json::parse(read_text_file(header_filepath), err_str); - map_ids.push_back(map_data["id"]); - string id = json_to_string(map_data, "id"); + Json map_data = Json::parse(read_text_file(map_filepath), err_str); + if (map_data == Json()) + FATAL_ERROR("%s: %s\n", map_filepath.c_str(), err_str.c_str()); + string id = json_to_string(map_data, "id", true); + map_ids.push_back(id); if (id.length() > max_length) max_length = id.length(); } int map_id_num = 0; - for (Json map_id : map_ids) { - string id = json_to_string(map_id); - text << "#define " << id << string((max_length - id.length() + 1), ' ') + for (string map_id : map_ids) { + text << "#define " << map_id << string((max_length - map_id.length() + 1), ' ') << "(" << map_id_num++ << " | (" << group_num << " << 8))\n"; } text << "\n"; From ebc8edd5a65c92b1211aacb3ac4efdbeffd7d207 Mon Sep 17 00:00:00 2001 From: Ultimate Bob Date: Tue, 9 May 2023 00:58:38 +1000 Subject: [PATCH 11/24] Fix shiny animation not respecting illusion mon. --- src/battle_anim_throw.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index 3fc2000e4a..4a3cf7cf27 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -2484,9 +2484,14 @@ void TryShinyAnimation(u8 battler, struct Pokemon *mon) u32 otId, personality; u32 shinyValue; u8 taskCirc, taskDgnl; + struct Pokemon* illusionMon; isShiny = FALSE; gBattleSpritesDataPtr->healthBoxesData[battler].triedShinyMonAnim = TRUE; + illusionMon = GetIllusionMonPtr(battler); + if (illusionMon != NULL) + mon = illusionMon; + otId = GetMonData(mon, MON_DATA_OT_ID); personality = GetMonData(mon, MON_DATA_PERSONALITY); From f985eefaa139017c2d67b1ea1591bd3d36bb6af4 Mon Sep 17 00:00:00 2001 From: Ultimate Bob Date: Tue, 9 May 2023 01:40:28 +1000 Subject: [PATCH 12/24] Show Imposter abilty in popup instead of opponent's ability. --- data/battle_scripts_1.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index fdc7c8a3fd..b62eb465eb 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -9373,8 +9373,8 @@ BattleScript_FriskActivates:: end3 BattleScript_ImposterActivates:: - transformdataexecution call BattleScript_AbilityPopUp + transformdataexecution playmoveanimation BS_ATTACKER, MOVE_TRANSFORM waitanimation printstring STRINGID_IMPOSTERTRANSFORM From 64c2eb39c0f65632ed06b1b19bbf2fca4dc7b089 Mon Sep 17 00:00:00 2001 From: Ultimate Bob Date: Tue, 9 May 2023 02:33:12 +1000 Subject: [PATCH 13/24] Ignore Illusion if the pokemon is the last slot in the party. --- src/battle_util.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index cd65d58093..dd6e2bc06e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10398,12 +10398,19 @@ bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId) { struct Pokemon *party, *partnerMon; s32 i, id; + u8 side, partyCount; gBattleStruct->illusion[battlerId].set = 1; if (GetMonAbility(mon) != ABILITY_ILLUSION) return FALSE; party = GetBattlerParty(battlerId); + side = GetBattlerSide(battlerId); + partyCount = side == B_SIDE_PLAYER ? gPlayerPartyCount : gEnemyPartyCount; + + // If this pokemon is last in the party, ignore Illusion. + if (&party[partyCount - 1] == mon) + return FALSE; if (IsBattlerAlive(BATTLE_PARTNER(battlerId))) partnerMon = &party[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]]; From 8c537ccd727946b81a204c9fe0147ec06c4b4578 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 10 May 2023 00:33:43 -0400 Subject: [PATCH 14/24] Colorize bag select button --- graphics/bag/select_button.png | Bin 135 -> 195 bytes src/item_menu.c | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/bag/select_button.png b/graphics/bag/select_button.png index bded587fd1d071464de8d5b9032433a760c183cf..52cdc1ed5acb5ca9c9164e0db127cee7509eaa83 100644 GIT binary patch delta 162 zcmZo?Jj^&j(uJ9Uf#Dz5qGdqJAiyWYH7ThW$o&8R|JAE!_s)s>&%m%{%NC#r5WG9v z{Qv*iD2D2*S^vF&OrWwUTV54^+dENFIJk*j|L0V8xf8R(r!6z#np!2Sp19#G^J^gu zH?BPgwk+Uy>cPuBJy`F+_LMg7cU!~f{P9S=W@>l+*8F=9_P;pDYIxTptX1s_E65&C LS3j3^P6dXGLHcW-t6b~08)OQE{-7_GfVpn`3@LxF#k*mlRNPsKK0`R^C` Date: Fri, 12 May 2023 14:02:14 +0200 Subject: [PATCH 15/24] Fix ability select in debug givemon --- src/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index 3fb79d2e86..8fff84d57d 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2327,7 +2327,7 @@ static void DebugAction_Give_Pokemon_SelectNature(u8 taskId) } static void DebugAction_Give_Pokemon_SelectAbility(u8 taskId) { - u8 abilityId; + u16 abilityId; u8 abilityCount = NUM_ABILITY_SLOTS - 1; //-1 for proper iteration u8 i = 0; From a89288e30e958add69295c910eb8b8f041add5c5 Mon Sep 17 00:00:00 2001 From: AaghatIsLive <109757010+AaghatIsLive@users.noreply.github.com> Date: Fri, 12 May 2023 17:54:47 +0530 Subject: [PATCH 16/24] Fix Illumise pallete (#2995) --- graphics/pokemon/illumise/normal.pal | 242 +-------------------------- 1 file changed, 1 insertion(+), 241 deletions(-) diff --git a/graphics/pokemon/illumise/normal.pal b/graphics/pokemon/illumise/normal.pal index b1f415775a..71e5ab84d8 100644 --- a/graphics/pokemon/illumise/normal.pal +++ b/graphics/pokemon/illumise/normal.pal @@ -1,6 +1,6 @@ JASC-PAL 0100 -256 +16 152 208 160 152 128 80 224 176 72 @@ -17,243 +17,3 @@ JASC-PAL 0 88 208 56 56 56 120 120 120 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 From d09072fd0dc8da040956bf28cc94793100e56727 Mon Sep 17 00:00:00 2001 From: Frank DeBlasio <35279583+fdeblasio@users.noreply.github.com> Date: Sun, 14 May 2023 12:55:08 -0400 Subject: [PATCH 17/24] Updated Esper Wing's accuracy if B_UPDATED_MOVE_DATA is Gen9 (#3004) --- src/data/battle_moves.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index b30f62a684..ef6ad52a1c 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -12699,12 +12699,13 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = { #if B_UPDATED_MOVE_DATA >= GEN_9 .power = 80, + .accuracy = 100, #else .power = 75, + .accuracy = 90, #endif .effect = EFFECT_SPEED_UP_HIT, .type = TYPE_PSYCHIC, - .accuracy = 90, .pp = 10, .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, From f6f0e5fa33dfe3154195619da940642b2b3cb06c Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Mon, 15 May 2023 01:03:14 +0200 Subject: [PATCH 18/24] Fix for wrong mon position for scripted wild doubles (#2996) --- src/script_pokemon_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index 34f75ef8e5..bfe2e7581a 100755 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -172,12 +172,12 @@ void CreateScriptedDoubleWildMon(u16 species1, u8 level1, u16 item1, u16 species SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, heldItem1); } - CreateMon(&gEnemyParty[3], species2, level2, 32, 0, 0, OT_ID_PLAYER_ID, 0); + CreateMon(&gEnemyParty[1], species2, level2, 32, 0, 0, OT_ID_PLAYER_ID, 0); if (item2) { heldItem2[0] = item2; heldItem2[1] = item2 >> 8; - SetMonData(&gEnemyParty[3], MON_DATA_HELD_ITEM, heldItem2); + SetMonData(&gEnemyParty[1], MON_DATA_HELD_ITEM, heldItem2); } } From 2420134e4532d87f44768a919229fe908a685c63 Mon Sep 17 00:00:00 2001 From: Frank DeBlasio <35279583+fdeblasio@users.noreply.github.com> Date: Sun, 14 May 2023 19:30:30 -0400 Subject: [PATCH 19/24] Updated Ability Patch for Gen 9 functionality (#2989) --- src/party_menu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/party_menu.c b/src/party_menu.c index aa37b1c691..27f4e0da42 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4663,7 +4663,6 @@ void Task_AbilityPatch(u8 taskId) // Can't use. if (gSpeciesInfo[tSpecies].abilities[tAbilityNum] == 0 || !tSpecies - || GetMonData(&gPlayerParty[tMonId], MON_DATA_ABILITY_NUM, NULL) > 1 ) { gPartyMenuUseExitCallback = FALSE; @@ -4734,7 +4733,10 @@ void ItemUseCB_AbilityPatch(u8 taskId, TaskFunc task) tState = 0; tMonId = gPartyMenu.slotId; tSpecies = GetMonData(&gPlayerParty[tMonId], MON_DATA_SPECIES, NULL); - tAbilityNum = 2; + if (GetMonData(&gPlayerParty[tMonId], MON_DATA_ABILITY_NUM, NULL) == 2) + tAbilityNum = 0; + else + tAbilityNum = 2; SetWordTaskArg(taskId, tOldFunc, (uintptr_t)(gTasks[taskId].func)); gTasks[taskId].func = Task_AbilityPatch; } From 76379661d05525b3fef87f6a640f003744475515 Mon Sep 17 00:00:00 2001 From: Eclipse <115349505+SubzeroEclipse@users.noreply.github.com> Date: Mon, 15 May 2023 04:09:45 +0200 Subject: [PATCH 20/24] Fixed mons mot disobeying with Gen8 mechanics disabled (#2990) --- src/battle_util.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index e8c9b8d8cd..5aa2fc153f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8114,8 +8114,6 @@ u8 IsMonDisobedient(void) if (!IsOtherTrainer(gBattleMons[gBattlerAttacker].otId, gBattleMons[gBattlerAttacker].otName)) levelReferenced = gBattleMons[gBattlerAttacker].metLevel; else -#else - if (gBattleMons[gBattlerAttacker].level <= obedienceLevel) #endif levelReferenced = gBattleMons[gBattlerAttacker].level; From 6458cab70a2533263518a877013a230512dacd39 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 15 May 2023 15:07:09 -0400 Subject: [PATCH 21/24] use NATIVE_ARGS in various to callnative conversions --- src/battle_script_commands.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index eddf6d6e19..896b57ffcc 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8805,7 +8805,7 @@ static bool32 CanTeleport(u8 battlerId) { struct Pokemon *party = GetBattlerParty(battlerId); u32 species, count, i; - + for (i = 0; i < PARTY_SIZE; i++) { species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); @@ -16317,33 +16317,33 @@ static bool8 IsFinalStrikeEffect(u16 move) // 10 bytes long (callnative(5) + counter(1) + ptr(4)) void BS_CheckParentalBondCounter(void) { + NATIVE_ARGS(u8 counter, const u8 *jumpInstr); // Some effects should only happen on the first or second strike of Parental Bond, // so a way to check this in battle scripts is useful - u8 counter = T1_READ_8(gBattlescriptCurrInstr + 5); - if (gSpecialStatuses[gBattlerAttacker].parentalBondState == counter && gBattleMons[gBattlerTarget].hp != 0) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 6); + if (gSpecialStatuses[gBattlerAttacker].parentalBondState == cmd->counter && gBattleMons[gBattlerTarget].hp != 0) + gBattlescriptCurrInstr = cmd->jumpInstr; else - gBattlescriptCurrInstr += 10; + gBattlescriptCurrInstr = cmd->nextInstr; } // 6 bytes long (callnative(5) + battler(1)) void BS_GetBattlerSide(void) { - gBattleCommunication[0] = GetBattlerSide(gBattlescriptCurrInstr[5]); - gBattlescriptCurrInstr += 6; + NATIVE_ARGS(u8 battler); + gBattleCommunication[0] = GetBattlerSide(cmd->battler); + gBattlescriptCurrInstr = cmd->nextInstr; } -// 6 bytes long (callnative(5) + battler(1)) void BS_CanTeleport(void) { - u8 battler = gBattlescriptCurrInstr[5]; - gBattleCommunication[0] = CanTeleport(battler); - gBattlescriptCurrInstr += 6; + NATIVE_ARGS(u8 battler); + gBattleCommunication[0] = CanTeleport(cmd->battler); + gBattlescriptCurrInstr = cmd->nextInstr; } -// 5 bytes long void BS_TrySymbiosis(void) { + NATIVE_ARGS(); //called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem. gActiveBattler = gBattlerAttacker; if (SYMBIOSIS_CHECK(gBattlerAttacker, BATTLE_PARTNER(gActiveBattler))) @@ -16357,7 +16357,7 @@ void BS_TrySymbiosis(void) return; } - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; } void BS_SetZEffect(void) From eaa44cc8b5c62d70792868d8982ed1920f31f49e Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 15 May 2023 15:20:44 -0400 Subject: [PATCH 22/24] fix syntax --- src/battle_script_commands.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 896b57ffcc..88a76adff1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8805,7 +8805,7 @@ static bool32 CanTeleport(u8 battlerId) { struct Pokemon *party = GetBattlerParty(battlerId); u32 species, count, i; - + for (i = 0; i < PARTY_SIZE; i++) { species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); @@ -16314,7 +16314,6 @@ static bool8 IsFinalStrikeEffect(u16 move) return FALSE; } -// 10 bytes long (callnative(5) + counter(1) + ptr(4)) void BS_CheckParentalBondCounter(void) { NATIVE_ARGS(u8 counter, const u8 *jumpInstr); @@ -16326,7 +16325,6 @@ void BS_CheckParentalBondCounter(void) gBattlescriptCurrInstr = cmd->nextInstr; } -// 6 bytes long (callnative(5) + battler(1)) void BS_GetBattlerSide(void) { NATIVE_ARGS(u8 battler); From 49a9210e9dfafeb1e984a000c73cdd063e0db948 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 15 May 2023 16:45:30 -0300 Subject: [PATCH 23/24] Fixed typo in include/config/battle.h --- include/config/battle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config/battle.h b/include/config/battle.h index 6475f6664c..4a1bbdc2f9 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -191,7 +191,7 @@ // Other settings #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. -#define B_DOUBLE_WILD_REQUIRE_2_MONS FALSE // If set to TRUE, Wild Double Battles will default to Single Battles when the player only has 1 usuable Pokémon, ignoring B_DOUBLE_WILD_CHANCE and B_FLAG_FORCE_DOUBLE_WILD. +#define B_DOUBLE_WILD_REQUIRE_2_MONS FALSE // If set to TRUE, Wild Double Battles will default to Single Battles when the player only has 1 usable Pokémon, ignoring B_DOUBLE_WILD_CHANCE and B_FLAG_FORCE_DOUBLE_WILD. #define B_MULTI_BATTLE_WHITEOUT GEN_LATEST // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. #define B_EVOLUTION_AFTER_WHITEOUT GEN_LATEST // In Gen6+, Pokemon that qualify for evolution after battle will evolve even if the player loses. #define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper) From 37874fe5c167602960811919fc1ffcfffb6133c2 Mon Sep 17 00:00:00 2001 From: AgustinGDLV <103095241+AgustinGDLV@users.noreply.github.com> Date: Tue, 16 May 2023 16:21:05 -0700 Subject: [PATCH 24/24] fixed revival blessing failure still showing anim (#3010) --- data/battle_scripts_1.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index bcb1275e20..2fe9c74ee6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -435,9 +435,9 @@ BattleScript_EffectRevivalBlessing:: attackcanceler attackstring ppreduce + tryrevivalblessing BattleScript_ButItFailed attackanimation waitanimation - tryrevivalblessing BattleScript_ButItFailed printstring STRINGID_PKMNREVIVEDREADYTOFIGHT waitmessage B_WAIT_TIME_LONG jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_EffectRevivalBlessingSendOut