From b203cf4ca4a36c6767b0ab6f5b1db8c3ce9344f9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 21 Jul 2018 16:34:43 +0200 Subject: [PATCH] Add a couple of gen4 moves battlescripts --- asm/macros/battle_script.inc | 17 ++-- data/battle_scripts_1.s | 120 +++++++++++++++++++++- include/battle.h | 1 + include/battle_scripts.h | 1 + include/constants/battle_move_effects.h | 6 ++ include/data/battle_moves.h | 12 +-- src/battle_script_commands.c | 126 +++++++++++++++++++----- src/battle_util.c | 10 ++ 8 files changed, 257 insertions(+), 36 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 03f0196d76..e79afe0cd0 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -356,7 +356,7 @@ .4byte \param0 .endm - .macro nop_42 + .macro setroost .byte 0x42 .endm @@ -558,8 +558,9 @@ .byte 0x68 .endm - .macro nop_69 + .macro setgravity ptr .byte 0x69 + .word \ptr .endm .macro removeitem bank @@ -676,8 +677,9 @@ .4byte \param0 .endm - .macro nop + .macro setmiracleeye ptr .byte 0x83 + .4byte \ptr .endm .macro jumpifcantmakeasleep param0 @@ -860,8 +862,9 @@ .byte 0xab .endm - .macro nop_AC + .macro settailwind ptr .byte 0xac + .word \ptr .endm .macro tryspiteppreduce param0 @@ -906,8 +909,9 @@ .byte 0xb5 .endm - .macro nop_B6 + .macro setembargo ptr .byte 0xb6 + .word \ptr .endm .macro presentdamagecalculation @@ -1052,8 +1056,9 @@ .4byte \param0 .endm - .macro nop_D6 + .macro setaquaring ptr .byte 0xd6 + .word \ptr .endm .macro setyawn param0 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 52fe703a3f..669e27f8f0 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -228,6 +228,96 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectCalmMind .4byte BattleScript_EffectDragonDance .4byte BattleScript_EffectCamouflage + .4byte BattleScript_EffectPledge + .4byte BattleScript_EffectFling + .4byte BattleScript_EffectNaturalGift + .4byte BattleScript_EffectWakeUpSlap + .4byte BattleScript_EffectWringOut + .4byte BattleScript_EffectHex + .4byte BattleScript_EffectAssurance + .4byte BattleScript_EffectTrump_card + .4byte BattleScript_EffectAcrobatics + .4byte BattleScript_EffectHeat_crash + .4byte BattleScript_EffectPunishment + .4byte BattleScript_EffectStoredPower + .4byte BattleScript_EffectElectroBall + .4byte BattleScript_EffectGyroBall + .4byte BattleScript_EffectEchoedVoice + .4byte BattleScript_EffectPayback + .4byte BattleScript_EffectRound + .4byte BattleScript_EffectBrine + .4byte BattleScript_EffectVenoshock + .4byte BattleScript_EffectRetalitate + .4byte BattleScript_EffectBulldoze + .4byte BattleScript_EffectFoulPlay + .4byte BattleScript_EffectPsyshock + .4byte BattleScript_EffectRoost + .4byte BattleScript_EffectGravity + .4byte BattleScript_EffectMircleEye + .4byte BattleScript_EffectTailwind + .4byte BattleScript_EffectEmbargo + .4byte BattleScript_EffectAquaRing + +BattleScript_EffectAquaRing: + attackcanceler + attackstring + ppreduce + setaquaring BattleScript_ButItFailed + attackanimation + waitanimation + printstring STRINGID_PKMNSURROUNDEDWITHVEILOFWATER + waitmessage 0x40 + goto BattleScript_MoveEnd + +BattleScript_EffectEmbargo: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + setembargo BattleScript_ButItFailed + attackanimation + waitanimation + printstring STRINGID_PKMNIDENTIFIED + waitmessage 0x40 + goto BattleScript_MoveEnd + +BattleScript_EffectTailwind: + attackcanceler + attackstring + ppreduce + settailwind BattleScript_ButItFailed + attackanimation + waitanimation + printstring STRINGID_TAILWINDBLEW + waitmessage 0x40 + goto BattleScript_MoveEnd + +BattleScript_EffectMircleEye: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + setmiracleeye BattleScript_ButItFailed + goto BattleScript_IdentifiedFoe + +BattleScript_EffectGravity: + attackcanceler + attackstring + ppreduce + setgravity BattleScript_ButItFailed + attackanimation + waitanimation + printstring STRINGID_GRAVITYINTENSIFIED + waitmessage 0x40 + goto BattleScript_MoveEnd + +BattleScript_EffectRoost: + attackcanceler + attackstring + ppreduce + tryhealhalfhealth BattleScript_AlreadyAtFullHp, BS_TARGET + setroost + goto BattleScript_PresentHealTarget BattleScript_EffectSpeedUp: BattleScript_EffectSpecialDefenseUp: @@ -261,6 +351,29 @@ BattleScript_EffectRevenge: BattleScript_EffectReturn: BattleScript_EffectFrustration: BattleScript_EffectEruption: +BattleScript_EffectPledge: +BattleScript_EffectFling: +BattleScript_EffectNaturalGift: +BattleScript_EffectWakeUpSlap: +BattleScript_EffectWringOut: +BattleScript_EffectHex: +BattleScript_EffectAssurance: +BattleScript_EffectTrump_card: +BattleScript_EffectAcrobatics: +BattleScript_EffectHeat_crash: +BattleScript_EffectPunishment: +BattleScript_EffectStoredPower: +BattleScript_EffectElectroBall: +BattleScript_EffectGyroBall: +BattleScript_EffectEchoedVoice: +BattleScript_EffectPayback: +BattleScript_EffectRound: +BattleScript_EffectBrine: +BattleScript_EffectVenoshock: +BattleScript_EffectRetalitate: +BattleScript_EffectBulldoze: +BattleScript_EffectFoulPlay: +BattleScript_EffectPsyshock: jumpifnotmove MOVE_SURF, BattleScript_HitFromAtkCanceler jumpifnostatus3 BS_TARGET, STATUS3_UNDERWATER, BattleScript_HitFromAtkCanceler orword gHitMarker, HITMARKER_IGNORE_UNDERWATER @@ -1581,6 +1694,7 @@ BattleScript_EffectForesight:: attackstring ppreduce setforesight +BattleScript_IdentifiedFoe: attackanimation waitanimation printstring STRINGID_PKMNIDENTIFIED @@ -2086,7 +2200,6 @@ BattleScript_EffectUproar:: jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_UproarHit ppreduce BattleScript_UproarHit:: - nop goto BattleScript_HitFromCritCalc BattleScript_EffectStockpile:: @@ -3283,6 +3396,11 @@ BattleScript_WaterSportEnds:: printstring STRINGID_WATERSPORTENDS waitmessage 0x40 end2 + +BattleScript_GravityEnds:: + printstring STRINGID_GRAVITYENDS + waitmessage 0x40 + end2 BattleScript_SafeguardProtected:: pause 0x20 diff --git a/include/battle.h b/include/battle.h index 2ff032cef2..c534d6745c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -275,6 +275,7 @@ struct FieldTimer u8 electricTerrainTimer; u8 psychicTerrainTimer; u8 echoVoiceCounter; + u8 gravityTimer; }; struct WishFutureKnock diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 1bd00027da..a8789c0a17 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -304,5 +304,6 @@ extern const u8 BattleScript_PsychicTerrainEnds[]; extern const u8 BattleScript_MudSportEnds[]; extern const u8 BattleScript_WaterSportEnds[]; extern const u8 BattleScript_SturdiedMsg[]; +extern const u8 BattleScript_GravityEnds[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 9a8ed60fc2..d1fbe40791 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -240,5 +240,11 @@ #define EFFECT_BULLDOZE 234 #define EFFECT_FOUL_PLAY 235 #define EFFECT_PSYSHOCK 236 +#define EFFECT_ROOST 237 +#define EFFECT_GRAVITY 238 +#define EFFECT_MIRACLE_EYE 239 +#define EFFECT_TAILWIND 240 +#define EFFECT_EMBARGO 241 +#define EFFECT_AQUA_RING 242 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/data/battle_moves.h b/include/data/battle_moves.h index 13cc3ccc91..c70e246153 100644 --- a/include/data/battle_moves.h +++ b/include/data/battle_moves.h @@ -4264,7 +4264,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_SPECIAL, }, { // MOVE_ROOST - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_ROOST, .power = 0, .type = TYPE_FLYING, .accuracy = 0, @@ -4276,7 +4276,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_STATUS, }, { // MOVE_GRAVITY - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_GRAVITY, .power = 0, .type = TYPE_PSYCHIC, .accuracy = 0, @@ -4288,7 +4288,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_STATUS, }, { // MOVE_MIRACLE_EYE - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_MIRACLE_EYE, .power = 0, .type = TYPE_PSYCHIC, .accuracy = 0, @@ -4396,7 +4396,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_PHYSICAL, }, { // MOVE_TAILWIND - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_TAILWIND, .power = 0, .type = TYPE_FLYING, .accuracy = 0, @@ -4480,7 +4480,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_PHYSICAL, }, { // MOVE_EMBARGO - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_EMBARGO, .power = 0, .type = TYPE_DARK, .accuracy = 100, @@ -4708,7 +4708,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_STATUS, }, { // MOVE_AQUA_RING - .effect = EFFECT_PLACEHOLDER_209, + .effect = EFFECT_AQUA_RING, .power = 0, .type = TYPE_WATER, .accuracy = 0, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 20476282f7..a798600fb3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -157,7 +157,7 @@ static void atk3E_end2(void); static void atk3F_end3(void); static void atk40_jumpifaffectedbyprotect(void); static void atk41_call(void); -static void atk42_nop(void); +static void atk42_setroost(void); static void atk43_jumpifabilitypresent(void); static void atk44_endselectionscript(void); static void atk45_playanimation(void); @@ -196,7 +196,7 @@ static void atk65_status2animation(void); static void atk66_chosenstatusanimation(void); static void atk67_yesnobox(void); static void atk68_cancelallactions(void); -static void atk69_nop(void); +static void atk69_setgravity(void); static void atk6A_removeitem(void); static void atk6B_atknameinbuff1(void); static void atk6C_drawlvlupbox(void); @@ -222,7 +222,7 @@ static void atk7F_setseeded(void); static void atk80_manipulatedamage(void); static void atk81_trysetrest(void); static void atk82_jumpifnotfirstturn(void); -static void atk83_nop(void); +static void atk83_setmiracleeye(void); static void atk84_jumpifcantmakeasleep(void); static void atk85_stockpile(void); static void atk86_stockpiletobasedamage(void); @@ -263,7 +263,7 @@ static void atkA8_copymovepermanently(void); static void atkA9_trychoosesleeptalkmove(void); static void atkAA_setdestinybond(void); static void atkAB_trysetdestinybondtohappen(void); -static void atkAC_nop(void); +static void atkAC_settailwind(void); static void atkAD_tryspiteppreduce(void); static void atkAE_healpartystatus(void); static void atkAF_cursetarget(void); @@ -273,7 +273,7 @@ static void atkB2_trysetperishsong(void); static void atkB3_handlerollout(void); static void atkB4_jumpifconfusedandstatmaxed(void); static void atkB5_handlefurycutter(void); -static void atkB6_nop(void); +static void atkB6_setembargo(void); static void atkB7_presentdamagecalculation(void); static void atkB8_setsafeguard(void); static void atkB9_magnitudedamagecalculation(void); @@ -305,7 +305,7 @@ static void atkD2_tryswapitems(void); static void atkD3_trycopyability(void); static void atkD4_trywish(void); static void atkD5_trysetroots(void); -static void atkD6_nop(void); +static void atkD6_setaquaring(void); static void atkD7_setyawn(void); static void atkD8_setdamagetohealthdifference(void); static void atkD9_nop(void); @@ -409,7 +409,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk3F_end3, atk40_jumpifaffectedbyprotect, atk41_call, - atk42_nop, + atk42_setroost, atk43_jumpifabilitypresent, atk44_endselectionscript, atk45_playanimation, @@ -448,7 +448,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk66_chosenstatusanimation, atk67_yesnobox, atk68_cancelallactions, - atk69_nop, + atk69_setgravity, atk6A_removeitem, atk6B_atknameinbuff1, atk6C_drawlvlupbox, @@ -474,7 +474,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk80_manipulatedamage, atk81_trysetrest, atk82_jumpifnotfirstturn, - atk83_nop, + atk83_setmiracleeye, atk84_jumpifcantmakeasleep, atk85_stockpile, atk86_stockpiletobasedamage, @@ -515,7 +515,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkA9_trychoosesleeptalkmove, atkAA_setdestinybond, atkAB_trysetdestinybondtohappen, - atkAC_nop, + atkAC_settailwind, atkAD_tryspiteppreduce, atkAE_healpartystatus, atkAF_cursetarget, @@ -525,7 +525,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkB3_handlerollout, atkB4_jumpifconfusedandstatmaxed, atkB5_handlefurycutter, - atkB6_nop, + atkB6_setembargo, atkB7_presentdamagecalculation, atkB8_setsafeguard, atkB9_magnitudedamagecalculation, @@ -557,7 +557,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkD3_trycopyability, atkD4_trywish, atkD5_trysetroots, - atkD6_nop, + atkD6_setaquaring, atkD7_setyawn, atkD8_setdamagetohealthdifference, atkD9_nop, @@ -3975,8 +3975,36 @@ static void atk41_call(void) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } -static void atk42_nop(void) +static void atk42_setroost(void) { + gBattleResources->flags->flags[gBattlerAttacker] |= RESOURCE_FLAG_ROOST; + + // Pure flying type. + if (gBattleMons[gBattlerAttacker].type1 == TYPE_FLYING && gBattleMons[gBattlerAttacker].type2 == TYPE_FLYING) + { + gBattleStruct->roostTypes[gBattlerAttacker][0] = TYPE_FLYING; + gBattleStruct->roostTypes[gBattlerAttacker][1] = TYPE_FLYING; + gBattleStruct->roostTypes[gBattlerAttacker][2] = TYPE_FLYING; + SET_BATTLER_TYPE(gBattlerAttacker, TYPE_NORMAL); + } + // Dual Type with Flying Type. + else if ((gBattleMons[gBattlerAttacker].type1 == TYPE_FLYING && gBattleMons[gBattlerAttacker].type2 != TYPE_FLYING) + ||(gBattleMons[gBattlerAttacker].type2 == TYPE_FLYING && gBattleMons[gBattlerAttacker].type1 != TYPE_FLYING)) + { + gBattleStruct->roostTypes[gBattlerAttacker][0] = gBattleMons[gBattlerAttacker].type1; + gBattleStruct->roostTypes[gBattlerAttacker][1] = gBattleMons[gBattlerAttacker].type2; + if (gBattleMons[gBattlerAttacker].type1 == TYPE_FLYING) + gBattleMons[gBattlerAttacker].type1 = TYPE_MYSTERY; + if (gBattleMons[gBattlerAttacker].type2 == TYPE_FLYING) + gBattleMons[gBattlerAttacker].type2 = TYPE_MYSTERY; + } + // Non-flying type. + else if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_FLYING)) + { + gBattleStruct->roostTypes[gBattlerAttacker][0] = gBattleMons[gBattlerAttacker].type1; + gBattleStruct->roostTypes[gBattlerAttacker][1] = gBattleMons[gBattlerAttacker].type2; + } + gBattlescriptCurrInstr++; } @@ -5849,9 +5877,24 @@ static void atk68_cancelallactions(void) gBattlescriptCurrInstr++; } -static void atk69_nop(void) +static void atk69_setgravity(void) { - gBattlescriptCurrInstr++; + if (gFieldStatuses & STATUS_FIELD_GRAVITY) + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + } + else + { + u32 i; + + gFieldStatuses |= STATUS_FIELD_GRAVITY; + gFieldTimers.gravityTimer = 5; + + for (i = 0; i < MAX_BATTLERS_COUNT; i++) + gStatuses3[i] &= ~(STATUS3_MAGNET_RISE | STATUS3_TELEKINESIS | STATUS3_ON_AIR); + + gBattlescriptCurrInstr += 5; + } } static void atk6A_removeitem(void) @@ -6728,9 +6771,17 @@ static void atk82_jumpifnotfirstturn(void) gBattlescriptCurrInstr = failJump; } -static void atk83_nop(void) +static void atk83_setmiracleeye(void) { - gBattlescriptCurrInstr++; + if (!(gStatuses3[gBattlerTarget] & STATUS3_MIRACLE_EYED)) + { + gStatuses3[gBattlerTarget] |= STATUS3_MIRACLE_EYED; + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + } } bool8 UproarWakeUpCheck(u8 battlerId) @@ -8175,9 +8226,21 @@ static void atkAB_trysetdestinybondtohappen(void) gBattlescriptCurrInstr++; } -static void atkAC_nop(void) +static void atkAC_settailwind(void) { - gBattlescriptCurrInstr++; + u8 side = GetBattlerSide(gBattlerAttacker); + + if (!(gSideStatuses[side] & SIDE_STATUS_TAILWIND)) + { + gSideStatuses[side] |= SIDE_STATUS_TAILWIND; + gSideTimers[side].tailwindBattlerId = gBattlerAttacker; + gSideTimers[side].tailwindTimer = 3; + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + } } static void atkAD_tryspiteppreduce(void) @@ -8445,9 +8508,18 @@ static void atkB5_handlefurycutter(void) } } -static void atkB6_nop(void) +static void atkB6_setembargo(void) { - gBattlescriptCurrInstr++; + if (gStatuses3[gBattlerTarget] & STATUS3_EMBARGO) + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + } + else + { + gStatuses3[gBattlerTarget] |= STATUS3_EMBARGO; + gDisableStructs[gBattlerTarget].embargoTimer = 5; + gBattlescriptCurrInstr += 5; + } } static void atkB7_presentdamagecalculation(void) @@ -9147,9 +9219,17 @@ static void atkD5_trysetroots(void) // ingrain } } -static void atkD6_nop(void) +static void atkD6_setaquaring(void) { - gBattlescriptCurrInstr++; + if (gStatuses3[gBattlerAttacker] & STATUS3_AQUA_RING) + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + } + else + { + gStatuses3[gBattlerAttacker] |= STATUS3_AQUA_RING; + gBattlescriptCurrInstr += 5; + } } static void atkD7_setyawn(void) diff --git a/src/battle_util.c b/src/battle_util.c index 995ccf5b1c..841325cf39 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -758,6 +758,7 @@ enum ENDTURN_SANDSTORM, ENDTURN_SUN, ENDTURN_HAIL, + ENDTURN_GRAVITY, ENDTURN_WATER_SPORT, ENDTURN_MUD_SPORT, ENDTURN_TRICK_ROOM, @@ -1167,6 +1168,15 @@ u8 DoFieldEndTurnEffects(void) } gBattleStruct->turnCountersTracker++; break; + case ENDTURN_GRAVITY: + if (gFieldStatuses & STATUS_FIELD_GRAVITY && --gFieldTimers.gravityTimer == 0) + { + gFieldStatuses &= ~(STATUS_FIELD_GRAVITY); + BattleScriptExecute(BattleScript_GravityEnds); + effect++; + } + gBattleStruct->turnCountersTracker++; + break; case ENDTURN_FIELD_COUNT: effect++; break;