diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 96c2c761d..21be0ee21 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -724,37 +724,39 @@ .byte \mode .endm - .macro trysetrest param0:req + .macro trysetrest failInstr:req .byte 0x81 - .4byte \param0 + .4byte \failInstr .endm - .macro jumpifnotfirstturn ptr:req + .macro jumpifnotfirstturn jumpInstr:req .byte 0x82 - .4byte \ptr + .4byte \jumpInstr .endm - .macro nop + .macro setmiracleeye failInstr:req .byte 0x83 + .4byte \failInstr .endm - .macro jumpifcantmakeasleep param0:req + .macro jumpifuproarwakes jumpInstr:req .byte 0x84 - .4byte \param0 + .4byte \jumpInstr .endm - .macro stockpile + .macro stockpile id:req .byte 0x85 + .byte \id .endm - .macro stockpiletobasedamage param0:req + .macro stockpiletobasedamage failInstr:req .byte 0x86 - .4byte \param0 + .4byte \failInstr .endm - .macro stockpiletohpheal param0:req + .macro stockpiletohpheal failInstr:req .byte 0x87 - .4byte \param0 + .4byte \failInstr .endm .macro negativedamage @@ -1907,6 +1909,11 @@ various \battler, VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES .endm + .macro jumpifleafguardprotected battler:req, jumpInstr:req + various \battler, VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED + .4byte \jumpInstr + .endm + @ various remaining from pokefirered .macro getbattlersforrecall various BS_ATTACKER, VARIOUS_GET_BATTLERS_FOR_RECALL @@ -2096,6 +2103,12 @@ jumpifbyte CMP_EQUAL, gBattleCommunication, \value, \ptr .endm + .macro jumpifflowerveil jumpInstr:req + jumpifnottype BS_TARGET, TYPE_GRASS, 1f + jumpifability BS_TARGET_SIDE, ABILITY_FLOWER_VEIL, \jumpInstr + 1: + .endm + .macro jumpifflowerveilattacker jumpInstr:req jumpifnottype BS_ATTACKER, TYPE_GRASS, 1f jumpifability BS_ATTACKER_SIDE, ABILITY_FLOWER_VEIL, \jumpInstr @@ -2119,4 +2132,17 @@ .byte \case .endm + .macro jumpifterrainaffected battler:req, terrainFlags:req, jumpInstr:req + callnative BS_JumpIfTerrainAffected + .byte \battler + .4byte \terrainFlags + .4byte \jumpInstr + .endm + + .macro checkparentalbondcounter counter:req, ptr:req + callnative BS_CheckParentalBondCounter + .byte \counter + .4byte \ptr + .endm + diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 7a73682af..0157abce3 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -75,16 +75,25 @@ BattleScript_EffectSleep:: attackcanceler attackstring ppreduce - jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed + jumpifsubstituteblocks BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_SLEEP, BattleScript_AlreadyAsleep - jumpifcantmakeasleep BattleScript_CantMakeAsleep + jumpifuproarwakes BattleScript_CantMakeAsleep + jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_InsomniaProtects + jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_InsomniaProtects + jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_AbilityProtectsDoesntAffect + jumpifability BS_TARGET, ABILITY_PURIFYING_SALT, BattleScript_AbilityProtectsDoesntAffect + jumpifflowerveil BattleScript_FlowerVeilProtects + jumpifability BS_TARGET_SIDE, ABILITY_SWEET_VEIL, BattleScript_SweetVeilProtects + jumpifleafguardprotected BS_TARGET, BattleScript_AbilityProtectsDoesntAffect + jumpifshieldsdown BS_TARGET, BattleScript_AbilityProtectsDoesntAffect jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed + jumpifterrainaffected BS_TARGET, STATUS_FIELD_ELECTRIC_TERRAIN, BattleScript_ElectricTerrainPrevents + jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE - jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected + jumpifsafeguard BattleScript_SafeguardProtected attackanimation waitanimation - setmoveeffect MOVE_EFFECT_SLEEP - seteffectprimary + seteffectprimary MOVE_EFFECT_SLEEP goto BattleScript_MoveEnd BattleScript_AlreadyAsleep:: @@ -526,7 +535,14 @@ BattleScript_EffectRest:: attackstring ppreduce jumpifstatus BS_ATTACKER, STATUS1_SLEEP, BattleScript_RestIsAlreadyAsleep - jumpifcantmakeasleep BattleScript_RestCantSleep + jumpifability BS_ATTACKER, ABILITY_COMATOSE, BattleScript_RestIsAlreadyAsleep + jumpifuproarwakes BattleScript_RestCantSleep + jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_InsomniaProtects + jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_InsomniaProtects + jumpifability BS_ATTACKER, ABILITY_PURIFYING_SALT, BattleScript_InsomniaProtects +.if B_LEAF_GUARD_PREVENTS_REST >= GEN_5 + jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardPreventsRest +.endif trysetrest BattleScript_AlreadyAtFullHp pause B_WAIT_TIME_SHORT printfromtable gRestUsedStringIds @@ -1715,23 +1731,43 @@ BattleScript_NotAffected:: BattleScript_EffectUproar:: attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE - setmoveeffect MOVE_EFFECT_UPROAR | MOVE_EFFECT_AFFECTS_USER attackstring jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_UproarHit ppreduce BattleScript_UproarHit:: - nop goto BattleScript_HitFromCritCalc BattleScript_EffectStockpile:: attackcanceler attackstring ppreduce - stockpile + stockpile 0 attackanimation waitanimation printfromtable gStockpileUsedStringIds waitmessage B_WAIT_TIME_LONG + .if B_STOCKPILE_RAISES_DEFS < GEN_4 + goto BattleScript_EffectStockpileEnd + .endif + jumpifmovehadnoeffect BattleScript_EffectStockpileEnd + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_DEF, MAX_STAT_STAGE, BattleScript_EffectStockpileDef + jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_EffectStockpileEnd +BattleScript_EffectStockpileDef: + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, 0 + setstatchanger STAT_DEF, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_EffectStockpileSpDef + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_EffectStockpileSpDef + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_EffectStockpileSpDef:: + setstatchanger STAT_SPDEF, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_EffectStockpileEnd + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_EffectStockpileEnd + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_EffectStockpileEnd: + stockpile 1 goto BattleScript_MoveEnd BattleScript_EffectSpitUp:: @@ -1740,14 +1776,17 @@ BattleScript_EffectSpitUp:: attackstring ppreduce accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE - stockpiletobasedamage BattleScript_SpitUpFail - typecalc + setbyte gIsCriticalHit, FALSE + damagecalc adjustdamage + stockpiletobasedamage BattleScript_SpitUpFail goto BattleScript_HitFromAtkAnimation BattleScript_SpitUpFail:: + checkparentalbondcounter 2, BattleScript_SpitUpEnd pause B_WAIT_TIME_SHORT printstring STRINGID_FAILEDTOSPITUP waitmessage B_WAIT_TIME_LONG +BattleScript_SpitUpEnd: goto BattleScript_MoveEnd BattleScript_SpitUpFailProtect:: @@ -6220,3 +6259,67 @@ BattleScript_ScriptingAbilityStatRaise:: copybyte gBattlerAttacker, sSAVED_DMG return +BattleScript_ElectricTerrainPrevents:: + pause B_WAIT_TIME_SHORT + printstring STRINGID_ELECTRICTERRAINPREVENTS + waitmessage B_WAIT_TIME_LONG + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED + goto BattleScript_MoveEnd + +BattleScript_MistyTerrainPrevents:: + pause B_WAIT_TIME_SHORT + printstring STRINGID_MISTYTERRAINPREVENTS + waitmessage B_WAIT_TIME_LONG + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED + goto BattleScript_MoveEnd + +BattleScript_InsomniaProtects: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_PKMNSTAYEDAWAKEUSING + waitmessage B_WAIT_TIME_LONG + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED + goto BattleScript_MoveEnd + +BattleScript_AbilityProtectsDoesntAffectRet:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_ITDOESNTAFFECT + waitmessage B_WAIT_TIME_LONG + return + +BattleScript_AbilityProtectsDoesntAffect: + call BattleScript_AbilityProtectsDoesntAffectRet + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED + goto BattleScript_MoveEnd + +BattleScript_FlowerVeilProtectsRet:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_FLOWERVEILPROTECTED + waitmessage B_WAIT_TIME_LONG + return + +BattleScript_FlowerVeilProtects: + call BattleScript_FlowerVeilProtectsRet + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED + goto BattleScript_MoveEnd + +BattleScript_SweetVeilProtectsRet:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + printstring STRINGID_FLOWERVEILPROTECTED + waitmessage B_WAIT_TIME_LONG + return + +BattleScript_SweetVeilProtects: + call BattleScript_SweetVeilProtectsRet + orhalfword gMoveResultFlags, MOVE_RESULT_FAILED + goto BattleScript_MoveEnd + +BattleScript_LeafGuardPreventsRest:: + pause B_WAIT_TIME_SHORT + printstring STRINGID_BUTITFAILED + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd + diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 23c89fbdb..fef26fd71 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -392,7 +392,6 @@ extern const u8 BattleScript_EffectSoftboiled[]; extern const u8 BattleScript_EffectFakeOut[]; extern const u8 BattleScript_EffectUproar[]; extern const u8 BattleScript_EffectStockpile[]; -extern const u8 BattleScript_EffectSpitUp[]; extern const u8 BattleScript_EffectSwallow[]; extern const u8 BattleScript_EffectHit[]; extern const u8 BattleScript_EffectHail[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 4a323def7..430df8102 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -559,8 +559,12 @@ #define STRINGID_ATTACKERBECAMEFULLYCHARGED 556 #define STRINGID_ATTACKERBECAMEASHSPECIES 557 #define STRINGID_PROTECTEDTEAM 558 +#define STRINGID_ELECTRICTERRAINPREVENTS 559 +#define STRINGID_MISTYTERRAINPREVENTS 560 +#define STRINGID_PSYCHICTERRAINPREVENTS 561 +#define STRINGID_FLOWERVEILPROTECTED 562 -#define BATTLESTRINGS_COUNT 559 +#define BATTLESTRINGS_COUNT 563 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, @@ -797,6 +801,11 @@ #define B_MSG_MENTALHERBCURE_HEALBLOCK 4 #define B_MSG_MENTALHERBCURE_DISABLE 5 +// gTerrainPreventsStringIds +#define B_MSG_TERRAINPREVENTS_MISTY 0 +#define B_MSG_TERRAINPREVENTS_ELECTRIC 1 +#define B_MSG_TERRAINPREVENTS_PSYCHIC 2 + // gTerrainStringIds #define B_MSG_TERRAIN_SET_MISTY 0 #define B_MSG_TERRAIN_SET_ELECTRIC 1 diff --git a/src/battle_message.c b/src/battle_message.c index f2ab33358..6e69f593e 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -688,6 +688,10 @@ static const u8 sText_NeutralizingGasOver[] = _("The effects of Neutralizing\nGa static const u8 sText_AttackerBecameFullyCharged[] = _("{B_ATK_NAME_WITH_PREFIX} became fully charged\ndue to its bond with its trainer!\p"); static const u8 sText_AttackerBecameAshSpecies[] = _("{B_ATK_NAME_WITH_PREFIX} became Ash-{B_BUFF1}!\p"); static const u8 sText_ProtectedTeam[] =_("{B_CURRENT_MOVE} protected\n{B_ATK_TEAM2} team!"); +static const u8 sText_ElectricTerrainPreventsSleep[] = _("{B_DEF_NAME_WITH_PREFIX} surrounds itself\nwith electrified terrain!"); +static const u8 sText_MistyTerrainPreventsStatus[] = _("{B_DEF_NAME_WITH_PREFIX} surrounds itself\nwith a protective mist!"); +static const u8 sText_PsychicTerrainPreventsPriority[] = _("{B_DEF_NAME_WITH_PREFIX} surrounds itself\nwith psychic terrain!"); +static const u8 sText_FlowerVeilProtected[] = _("{B_DEF_NAME_WITH_PREFIX} surrounded itself\nwith a veil of petals!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT - BATTLESTRINGS_TABLE_START] = { @@ -1238,6 +1242,10 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT - BATTLESTRINGS_TABLE_ST [STRINGID_ATTACKERBECAMEFULLYCHARGED - BATTLESTRINGS_TABLE_START] = sText_AttackerBecameFullyCharged, [STRINGID_ATTACKERBECAMEASHSPECIES - BATTLESTRINGS_TABLE_START] = sText_AttackerBecameAshSpecies, [STRINGID_PROTECTEDTEAM - BATTLESTRINGS_TABLE_START] = sText_ProtectedTeam, + [STRINGID_ELECTRICTERRAINPREVENTS - BATTLESTRINGS_TABLE_START] = sText_ElectricTerrainPreventsSleep, + [STRINGID_MISTYTERRAINPREVENTS - BATTLESTRINGS_TABLE_START] = sText_MistyTerrainPreventsStatus, + [STRINGID_PSYCHICTERRAINPREVENTS - BATTLESTRINGS_TABLE_START] = sText_PsychicTerrainPreventsPriority, + [STRINGID_FLOWERVEILPROTECTED - BATTLESTRINGS_TABLE_START] = sText_FlowerVeilProtected, }; const u16 gTrainerUsedItemStringIds[] = @@ -1291,6 +1299,13 @@ const u16 gTerrainStringIds[B_MSG_TERRAIN_COUNT] = [B_MSG_TERRAIN_END_GRASSY] = STRINGID_GRASSYTERRAINENDS, }; +const u16 gTerrainPreventsStringIds[] = +{ + [B_MSG_TERRAINPREVENTS_MISTY] = STRINGID_MISTYTERRAINPREVENTS, + [B_MSG_TERRAINPREVENTS_ELECTRIC] = STRINGID_ELECTRICTERRAINPREVENTS, + [B_MSG_TERRAINPREVENTS_PSYCHIC] = STRINGID_PSYCHICTERRAINPREVENTS +}; + const u16 gMagicCoatBounceStringIds[] = { STRINGID_PKMNMOVEBOUNCED, STRINGID_PKMNMOVEBOUNCEDABILITY diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 086fef103..287c8a70d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -472,8 +472,8 @@ static void Cmd_setseeded(void); static void Cmd_manipulatedamage(void); static void Cmd_trysetrest(void); static void Cmd_jumpifnotfirstturn(void); -static void Cmd_nop(void); -static void Cmd_jumpifcantmakeasleep(void); +static void Cmd_setmiracleeye(void); +static void Cmd_jumpifuproarwakes(void); static void Cmd_stockpile(void); static void Cmd_stockpiletobasedamage(void); static void Cmd_stockpiletohpheal(void); @@ -724,11 +724,11 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_manipulatedamage, //0x80 // done Cmd_trysetrest, //0x81 // done Cmd_jumpifnotfirstturn, //0x82 // done - Cmd_nop, //0x83 - Cmd_jumpifcantmakeasleep, //0x84 - Cmd_stockpile, //0x85 - Cmd_stockpiletobasedamage, //0x86 - Cmd_stockpiletohpheal, //0x87 + Cmd_setmiracleeye, //0x83 // done + Cmd_jumpifuproarwakes, //0x84 // done + Cmd_stockpile, //0x85 // done + Cmd_stockpiletobasedamage, //0x86 // done + Cmd_stockpiletohpheal, //0x87 // done Cmd_negativedamage, //0x88 Cmd_statbuffchange, //0x89 Cmd_normalisebuffs, //0x8A @@ -11544,18 +11544,28 @@ static void Cmd_jumpifnotfirstturn(void) gBattlescriptCurrInstr = jumpInstr; } -static void Cmd_nop(void) +static void Cmd_setmiracleeye(void) { - gBattlescriptCurrInstr++; + CMD_ARGS(const u8 *failInstr); + + if (!(gStatuses3[gBattlerTarget] & STATUS3_MIRACLE_EYED)) + { + gStatuses3[gBattlerTarget] |= STATUS3_MIRACLE_EYED; + gBattlescriptCurrInstr = cmd->nextInstr; + } + else + { + gBattlescriptCurrInstr = cmd->failInstr; + } } -bool8 UproarWakeUpCheck(u8 battlerId) +bool8 UproarWakeUpCheck(u8 battler) { s32 i; for (i = 0; i < gBattlersCount; i++) { - if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || gBattleMons[battlerId].ability == ABILITY_SOUNDPROOF) + if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || (GetBattlerAbility(battler) == ABILITY_SOUNDPROOF && B_UPROAR_IGNORE_SOUNDPROOF < GEN_5)) continue; gBattleScripting.battler = i; @@ -11576,100 +11586,106 @@ bool8 UproarWakeUpCheck(u8 battlerId) return TRUE; } -static void Cmd_jumpifcantmakeasleep(void) +static void Cmd_jumpifuproarwakes(void) { - const u8 *jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + CMD_ARGS(const u8 *jumpInstr); if (UproarWakeUpCheck(gBattlerTarget)) - { - gBattlescriptCurrInstr = jumpPtr; - } - else if (gBattleMons[gBattlerTarget].ability == ABILITY_INSOMNIA - || gBattleMons[gBattlerTarget].ability == ABILITY_VITAL_SPIRIT) - { - gLastUsedAbility = gBattleMons[gBattlerTarget].ability; - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STAYED_AWAKE_USING; - gBattlescriptCurrInstr = jumpPtr; - RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); - } + gBattlescriptCurrInstr = cmd->jumpInstr; else - { - gBattlescriptCurrInstr += 5; - } + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_stockpile(void) { - if (gDisableStructs[gBattlerAttacker].stockpileCounter == 3) - { - gMoveResultFlags |= MOVE_RESULT_MISSED; - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_STOCKPILE; - } - else - { - gDisableStructs[gBattlerAttacker].stockpileCounter++; + CMD_ARGS(u8 id); - PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBattlerAttacker].stockpileCounter) - - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STOCKPILED; + switch (cmd->id) + { + case 0: + if (gDisableStructs[gBattlerAttacker].stockpileCounter >= 3) + { + gMoveResultFlags |= MOVE_RESULT_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_STOCKPILE; + } + else + { + gDisableStructs[gBattlerAttacker].stockpileCounter++; + gDisableStructs[gBattlerAttacker].stockpileBeforeDef = gBattleMons[gBattlerAttacker].statStages[STAT_DEF]; + gDisableStructs[gBattlerAttacker].stockpileBeforeSpDef = gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF]; + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBattlerAttacker].stockpileCounter); + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STOCKPILED; + } + break; + case 1: // Save def/sp def stats. + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) + { + gDisableStructs[gBattlerAttacker].stockpileDef += gBattleMons[gBattlerAttacker].statStages[STAT_DEF] - gDisableStructs[gBattlerAttacker].stockpileBeforeDef; + gDisableStructs[gBattlerAttacker].stockpileSpDef += gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] - gDisableStructs[gBattlerAttacker].stockpileBeforeSpDef; + } + break; } - gBattlescriptCurrInstr++; + + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_stockpiletobasedamage(void) { - const u8 *jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + CMD_ARGS(const u8 *failInstr); + + const u8 *failInstr = cmd->failInstr; if (gDisableStructs[gBattlerAttacker].stockpileCounter == 0) { - gBattlescriptCurrInstr = jumpPtr; + gBattlescriptCurrInstr = failInstr; } else { if (gBattleCommunication[MISS_TYPE] != B_MSG_PROTECTED) - { - gBattleMoveDamage = CalculateBaseDamageOld(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, - gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)], 0, - 0, gBattlerAttacker, gBattlerTarget) - * gDisableStructs[gBattlerAttacker].stockpileCounter; gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; - if (gProtectStructs[gBattlerAttacker].helpingHand) - gBattleMoveDamage = gBattleMoveDamage * 15 / 10; + if (!(gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_1ST_HIT && gBattleMons[gBattlerTarget].hp != 0)) + { + gBattleStruct->moveEffect2 = MOVE_EFFECT_STOCKPILE_WORE_OFF; } - - gDisableStructs[gBattlerAttacker].stockpileCounter = 0; - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; } } static void Cmd_stockpiletohpheal(void) { - const u8 *jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + CMD_ARGS(const u8 *failInstr); + + const u8 *failInstr = cmd->failInstr; if (gDisableStructs[gBattlerAttacker].stockpileCounter == 0) { - gBattlescriptCurrInstr = jumpPtr; + gBattlescriptCurrInstr = failInstr; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWALLOW_FAILED; } - else if (gBattleMons[gBattlerAttacker].maxHP == gBattleMons[gBattlerAttacker].hp) - { - gDisableStructs[gBattlerAttacker].stockpileCounter = 0; - gBattlescriptCurrInstr = jumpPtr; - gBattlerTarget = gBattlerAttacker; - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWALLOW_FULL_HP; - } else { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / (1 << (3 - gDisableStructs[gBattlerAttacker].stockpileCounter)); + if (gBattleMons[gBattlerAttacker].maxHP == gBattleMons[gBattlerAttacker].hp) + { + gDisableStructs[gBattlerAttacker].stockpileCounter = 0; + gBattlescriptCurrInstr = failInstr; + gBattlerTarget = gBattlerAttacker; + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWALLOW_FULL_HP; + } + else + { + // TODO: Dynamax + // gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / (1 << (3 - gDisableStructs[gBattlerAttacker].stockpileCounter)); + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / (1 << (3 - gDisableStructs[gBattlerAttacker].stockpileCounter)); - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; - gBattleMoveDamage *= -1; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; - gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; - gDisableStructs[gBattlerAttacker].stockpileCounter = 0; - gBattlescriptCurrInstr += 5; - gBattlerTarget = gBattlerAttacker; + gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; + gBattleStruct->moveEffect2 = MOVE_EFFECT_STOCKPILE_WORE_OFF; + gBattlescriptCurrInstr = cmd->nextInstr; + gBattlerTarget = gBattlerAttacker; + } } } @@ -15455,3 +15471,25 @@ void BS_HandlePrimalReversion(void) gBattlescriptCurrInstr = cmd->nextInstr; } +void BS_JumpIfTerrainAffected(void) +{ + NATIVE_ARGS(u8 battler, u32 flags, const u8 *jumpInstr); + u32 battler = GetBattlerForBattleScript(cmd->battler); + + if (IsBattlerTerrainAffected(battler, cmd->flags)) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} + +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 + if (gSpecialStatuses[gBattlerAttacker].parentalBondState == cmd->counter && gBattleMons[gBattlerTarget].hp != 0) + gBattlescriptCurrInstr = cmd->jumpInstr; + else + gBattlescriptCurrInstr = cmd->nextInstr; +} + diff --git a/src/data/pokemon/species_info/gen_1.h b/src/data/pokemon/species_info/gen_1.h index e6fb73e20..dd2608a19 100644 --- a/src/data/pokemon/species_info/gen_1.h +++ b/src/data/pokemon/species_info/gen_1.h @@ -21,7 +21,7 @@ const struct SpeciesInfo gSpeciesInfoGen1[] = .friendship = STANDARD_FRIENDSHIP, .growthRate = GROWTH_MEDIUM_SLOW, .eggGroups = { EGG_GROUP_MONSTER, EGG_GROUP_GRASS }, - .abilities = { ABILITY_CHEEK_POUCH, ABILITY_NONE, ABILITY_CHLOROPHYLL }, + .abilities = { ABILITY_OVERGROW, ABILITY_NONE, ABILITY_CHLOROPHYLL }, .bodyColor = BODY_COLOR_GREEN, .speciesName = _("Bulbasaur"), .cryId = CRY_BULBASAUR,