From 9474254e4d9b0d36c52ffdbf772d0c2e0fbe386f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 22 Sep 2018 16:15:00 +0200 Subject: [PATCH] Final Gambit, Dragon Tail --- asm/macros/battle_script.inc | 9 ++ data/battle_scripts_1.s | 107 ++++++++++++++++++++- include/battle_scripts.h | 2 + include/constants/battle.h | 2 +- include/constants/battle_move_effects.h | 4 + include/constants/battle_script_commands.h | 2 + src/battle_message.c | 2 +- src/battle_script_commands.c | 41 ++++++-- src/data/battle_moves.h | 12 +-- 9 files changed, 161 insertions(+), 20 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 69f382046f..a1b1d326c9 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1486,6 +1486,11 @@ various BS_ATTACKER, VARIOUS_ARGUMENT_STATUS_EFFECT .endm + .macro tryhitswitchtarget ptr + various BS_ATTACKER, VARIOUS_TRY_HIT_SWITCH_TARGET + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat, stages, down setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7 @@ -1574,3 +1579,7 @@ .macro dmgtomaxattackerhp manipulatedamage ATK80_FULL_ATTACKER_HP .endm + + .macro dmgtocurrattackerhp + manipulatedamage ATK80_CURR_ATTACKER_HP + .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index fbff3f0e73..172bf97458 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -308,15 +308,108 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectShiftGear .4byte BattleScript_EffectDefenseUp3 .4byte BattleScript_EffectNobleRoar - .4byte BattleScript_EffectvVenomDrench + .4byte BattleScript_EffectVenomDrench + .4byte BattleScript_EffectToxicThread + .4byte BattleScript_EffectClearSmog + .4byte BattleScript_EffectHitSwitchTarget + .4byte BattleScript_EffectFinalGambit -BattleScript_EffectvVenomDrench: +BattleScript_EffectFinalGambit: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + typecalc + bichalfword gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE + dmgtocurrattackerhp + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage 0x40 + resultmessage + waitmessage 0x40 + seteffectwithchance + tryfaintmon BS_TARGET, FALSE, NULL + jumpifmovehadnoeffect BattleScript_MoveEnd + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + tryfaintmon BS_ATTACKER, FALSE, NULL + goto BattleScript_MoveEnd + +BattleScript_EffectHitSwitchTarget: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage 0x40 + resultmessage + waitmessage 0x40 + tryfaintmon BS_TARGET, FALSE, NULL + jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut + jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted + tryhitswitchtarget BattleScript_EffectHitSwitchTargetMoveEnd +BattleScript_EffectHitSwitchTargetMoveEnd: + setbyte sMOVEEND_STATE, 0x0 + moveend 0x0, 0x0 + end + +BattleScript_EffectClearSmog: + setmoveeffect MOVE_EFFECT_CLEAR_SMOG + goto BattleScript_EffectHit + +BattleScript_EffectToxicThread: + setstatchanger STAT_SPEED, 2, TRUE + attackcanceler + jumpifsubstituteblocks BattleScript_ButItFailedAtkStringPpReduce + jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_SPEED, 0x0, BattleScript_ToxicThreadWorks + jumpifstatus BS_TARGET, STATUS1_PSN_ANY, BattleScript_ButItFailedAtkStringPpReduce +BattleScript_ToxicThreadWorks: + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + statbuffchange 0x1, BattleScript_ToxicThreadTryPsn + jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, 0x2, BattleScript_ToxicThreadDoAnim + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_ToxicThreadTryPsn + pause 0x20 + goto BattleScript_ToxicThreadPrintString +BattleScript_ToxicThreadDoAnim:: + attackanimation + waitanimation + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 +BattleScript_ToxicThreadPrintString:: + printfromtable gStatDownStringIds + waitmessage 0x40 +BattleScript_ToxicThreadTryPsn:: + setmoveeffect MOVE_EFFECT_POISON + seteffectprimary + goto BattleScript_MoveEnd + +BattleScript_EffectVenomDrench: attackcanceler attackstring ppreduce - jumpifstatus BS_TARGET, STATUS1_PSN_ANY, BattleScript_EffectvVenomDrenchCanBeUsed + jumpifstatus BS_TARGET, STATUS1_PSN_ANY, BattleScript_EffectVenomDrenchCanBeUsed goto BattleScript_ButItFailed -BattleScript_EffectvVenomDrenchCanBeUsed: +BattleScript_EffectVenomDrenchCanBeUsed: jumpifstat BS_TARGET, CMP_GREATER_THAN, STAT_ATK, 0x0, BattleScript_VenomDrenchDoMoveAnim jumpifstat BS_TARGET, CMP_GREATER_THAN, STAT_SPATK, 0x0, BattleScript_VenomDrenchDoMoveAnim jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPEED, 0x0, BattleScript_CantLowerMultipleStats @@ -1559,6 +1652,7 @@ BattleScript_EffectRoar:: accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON accuracycheck BattleScript_MoveMissedPause, ACC_CURR_MOVE jumpifbattletype BATTLE_TYPE_ARENA, BattleScript_ButItFailed +BattleScript_ForceRandomSwitch:: forcerandomswitch BattleScript_ButItFailed BattleScript_EffectMultiHit:: @@ -4862,6 +4956,11 @@ BattleScript_SAtkDown2:: waitmessage 0x40 BattleScript_SAtkDown2End:: return + +BattleScript_MoveEffectClearSmog:: + printstring STRINGID_RESETSTARGETSSTATLEVELS + waitmessage 0x40 + return BattleScript_FocusPunchSetUp:: printstring STRINGID_EMPTYSTRING3 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 70733b41a3..91e0a8df62 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -275,5 +275,7 @@ extern const u8 BattleScript_StealthRockFree[]; extern const u8 BattleScript_MegaEvolution[]; extern const u8 BattleScript_MoveEffectRecoilWithStatus[]; extern const u8 BattleScript_EffectWithChance[]; +extern const u8 BattleScript_MoveEffectClearSmog[]; +extern const u8 BattleScript_ForceRandomSwitch[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle.h b/include/constants/battle.h index 89f548cc7c..a583da05ca 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -312,7 +312,7 @@ #define MOVE_EFFECT_DEF_SPDEF_DOWN 0x37 #define MOVE_EFFECT_RECOIL_33_STATUS 0x38 #define MOVE_EFFECT_RECOIL_50 0x39 -#define MOVE_EFFECT_NOTHING_3A 0x3A +#define MOVE_EFFECT_CLEAR_SMOG 0x3A #define MOVE_EFFECT_SP_ATK_TWO_DOWN 0x3B #define MOVE_EFFECT_NOTHING_3C 0x3C #define MOVE_EFFECT_NOTHING_3D 0x3D diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 78d2c56285..a93cb2a0ec 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -298,5 +298,9 @@ #define EFFECT_DEFENSE_UP_3 292 #define EFFECT_NOBLE_ROAR 293 // Atk and Sp atk down by 1 #define EFFECT_VENOM_DRENCH 294 +#define EFFECT_TOXIC_THREAD 295 +#define EFFECT_CLEAR_SMOG 296 +#define EFFECT_HIT_SWITCH_TARGET 297 +#define EFFECT_FINAL_GAMBIT 298 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 830c2a7d57..67d434964c 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -103,6 +103,7 @@ #define VARIOUS_HANDLE_MEGA_EVO 51 #define VARIOUS_TRY_LAST_RESORT 52 #define VARIOUS_ARGUMENT_STATUS_EFFECT 53 +#define VARIOUS_TRY_HIT_SWITCH_TARGET 54 // atk80, dmg manipulation #define ATK80_DMG_CHANGE_SIGN 0 @@ -110,6 +111,7 @@ #define ATK80_DMG_DOUBLED 2 #define ATK80_1_8_TARGET_HP 3 #define ATK80_FULL_ATTACKER_HP 4 +#define ATK80_CURR_ATTACKER_HP 5 // atk4F, a flag used for the jumpifcantswitch command #define ATK4F_DONT_CHECK_STATUSES 0x80 diff --git a/src/battle_message.c b/src/battle_message.c index a2c8003142..d5bbbebcc8 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -564,7 +564,7 @@ static const u8 sText_FellStraightDown[] =_("{B_DEF_NAME_WITH_PREFIX} fell\nstra static const u8 sText_TransformedIntoWaterType[] =_("{B_DEF_NAME_WITH_PREFIX} transformed\ninto the water type!"); static const u8 sText_PkmnAcquiredSimple[] =_("{B_DEF_NAME_WITH_PREFIX} acquired\nSimple!"); static const u8 sText_KindOffer[] =_("{B_DEF_NAME_WITH_PREFIX}\ntook the kind offer!"); -static const u8 sText_ResetsTargetsStatLevels[] =_("{B_DEF_NAME_WITH_PREFIX} stat changes\nwere removed!"); +static const u8 sText_ResetsTargetsStatLevels[] =_("{B_DEF_NAME_WITH_PREFIX}’s stat changes\nwere removed!"); static const u8 sText_ProtectsTeamFromPriority[] =_("Quick Guard protected your team!"); static const u8 sText_AllySwitchPosition[] =_("{B_ATK_NAME_WITH_PREFIX} and\n{B_SCR_ACTIVE_NAME_WITH_PREFIX} switched places!"); static const u8 sText_RestoreTargetsHealth[] =_("{B_DEF_NAME_WITH_PREFIX}’s HP was restored!"); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 003bfa80ef..47ac3cc9b9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1975,6 +1975,7 @@ u8 GetBattlerTurnOrderNum(u8 battlerId) void SetMoveEffect(bool8 primary, u8 certain) { + s32 i; bool32 statusChanged = FALSE; u8 affectsUser = 0; // 0x40 otherwise bool32 noSunCanFreeze = TRUE; @@ -2676,6 +2677,20 @@ void SetMoveEffect(bool8 primary, u8 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_SAtkDown2; break; + case MOVE_EFFECT_CLEAR_SMOG: + for (i = 0; i < BATTLE_STATS_NO; i++) + { + if (gBattleMons[gEffectBattler].statStages[i] != 6) + break; + } + if ((gSpecialStatuses[gEffectBattler].physicalDmg || gSpecialStatuses[gEffectBattler].specialDmg) && i != BATTLE_STATS_NO) + { + for (i = 0; i < BATTLE_STATS_NO; i++) + gBattleMons[gEffectBattler].statStages[i] = 6; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_MoveEffectClearSmog; + } + break; } } } @@ -6707,6 +6722,19 @@ static void atk76_various(void) return; } break; + case VARIOUS_TRY_HIT_SWITCH_TARGET: + if (IsBattlerAlive(gBattlerAttacker) + && IsBattlerAlive(gBattlerTarget) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED) + { + gBattlescriptCurrInstr = BattleScript_ForceRandomSwitch; + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + } + return; } gBattlescriptCurrInstr += 3; @@ -6970,6 +6998,9 @@ static void atk80_manipulatedamage(void) case ATK80_FULL_ATTACKER_HP: gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP; break; + case ATK80_CURR_ATTACKER_HP: + gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp; + break; } gBattlescriptCurrInstr += 2; @@ -7428,16 +7459,10 @@ static void atk8F_forcerandomswitch(void) s32 i; s32 battler1PartyId = 0; s32 battler2PartyId = 0; - - #ifdef NONMATCHING - s32 lastMonId = 0; // + 1 - #else - register s32 lastMonId asm("r8") = 0; // + 1 - #endif // NONMATCHING - + s32 lastMonId = 0; // + 1 s32 firstMonId = 0; s32 monsCount = 0; - struct Pokemon* party = NULL; + struct Pokemon *party = NULL; s32 validMons = 0; s32 minNeeded = 0; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 714d8fe253..d335c49ea7 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -5997,12 +5997,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_PHYSICAL, }, { // MOVE_CLEAR_SMOG - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect (Always bypasses accuracy, but same as Haze) + .effect = EFFECT_CLEAR_SMOG, .power = 50, .type = TYPE_POISON, .accuracy = 0, .pp = 15, - .secondaryEffectChance = 0, + .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGSROCK_AFFECTED, @@ -6117,7 +6117,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_STATUS, }, { // MOVE_CIRCLE_THROW - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect (similar to whirlwind, but different) + .effect = EFFECT_HIT_SWITCH_TARGET, .power = 60, .type = TYPE_FIGHTING, .accuracy = 90, @@ -6189,7 +6189,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_PHYSICAL, }, { // MOVE_FINAL_GAMBIT - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_FINAL_GAMBIT, .power = 1, .type = TYPE_FIGHTING, .accuracy = 100, @@ -6309,7 +6309,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_SPECIAL, }, { // MOVE_DRAGON_TAIL - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_HIT_SWITCH_TARGET, .power = 60, .type = TYPE_DRAGON, .accuracy = 90, @@ -7632,7 +7632,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_PHYSICAL, }, { // MOVE_TOXIC_THREAD - .effect = EFFECT_PLACEHOLDER, + .effect = EFFECT_TOXIC_THREAD, .power = 0, .type = TYPE_MYSTERY, .accuracy = 0,