diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index c49c43d9c..282fbb306 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1921,14 +1921,8 @@ various BS_ATTACKER, VARIOUS_SHELL_SIDE_ARM_CHECK .endm - .macro jumpifflingfails battler:req, ptr:req - various \battler, VARIOUS_JUMP_IF_FLING_FAILS - .4byte \ptr - .endm - - .macro jumpifholdeffect battler:req, holdEffet:req, ptr:req - various \battler, VARIOUS_JUMP_IF_HOLD_EFFECT - .byte \holdEffet + .macro jumpifnoflingpower battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_NO_FLING_POWER .4byte \ptr .endm @@ -1940,6 +1934,29 @@ various \battler, VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES .endm + .macro jumpiflastuseditemberry ptr:req + various BS_ATTACKER, VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY + .4byte \ptr + .endm + + .macro jumpiflastuseditemholdeffect battler:req, holdEffect:req, ptr:req + various \battler, VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT + .byte \holdEffect + .4byte \ptr + .endm + + .macro savebattleritem battler:req + various \battler, VARIOUS_SAVE_BATTLER_ITEM + .endm + + .macro restorebattleritem battler:req + various \battler, VARIOUS_RESTORE_BATTLER_ITEM + .endm + + .macro battleritemtolastuseditem battler:req + various \battler, VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index dd90c9bf4..c395d9f7b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -405,15 +405,18 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHit @ EFFECT_BOLT_BEAK BattleScript_EffectFling: - jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MAGIC_ROOM, BattleScript_ButItFailed + jumpifnoflingpower BS_ATTACKER, BattleScript_ButItFailedAtkStringPpReduce + jumpifstatus3 BS_ATTACKER, STATUS3_EMBARGO, BattleScript_ButItFailedAtkStringPpReduce + jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_MAGIC_ROOM, BattleScript_ButItFailedAtkStringPpReduce +.if B_KLUTZ_FLING_INTERACTION >= GEN_5 jumpifability BS_ATTACKER, ABILITY_KLUTZ, BattleScript_ButItFailedAtkStringPpReduce - jumpifability BS_ATTACKER, ABILITY_UNNERVE, BattleScript_ButItFailedAtkStringPpReduce - jumpifflingfails BS_ATTACKER, BattleScript_ButItFailedAtkStringPpReduce +.endif + setlastuseditem BS_ATTACKER + removeitem BS_ATTACKER attackcanceler accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring pause B_WAIT_TIME_SHORT - setlastuseditem BS_ATTACKER printstring STRINGID_PKMNFLUNG waitmessage B_WAIT_TIME_SHORT ppreduce @@ -431,16 +434,27 @@ BattleScript_EffectFling: waitmessage B_WAIT_TIME_MED resultmessage waitmessage B_WAIT_TIME_MED -.if B_FLING_EMBARGO_ITEM <= GEN_4 - jumpifstatus3 BS_TARGET, STATUS3_EMBARGO, BattleScript_FlingEnd -.endif - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_FLAME_ORB, BattleScript_FlingFlameOrb - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_FLINCH, BattleScript_FlingFlinch - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_LIGHT_BALL, BattleScript_FlingLightBall - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_MENTAL_HERB, BattleScript_FlingMentalHerb - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_POISON_POWER, BattleScript_FlingPoisonBarb - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_TOXIC_ORB, BattleScript_FlingToxicOrb - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_RESTORE_STATS, BattleScript_FlingWhiteHerb + jumpiflastuseditemberry BattleScript_EffectFlingConsumeBerry + jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_FLAME_ORB, BattleScript_FlingFlameOrb + jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_FLINCH, BattleScript_FlingFlinch + jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_LIGHT_BALL, BattleScript_FlingLightBall + jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_MENTAL_HERB, BattleScript_FlingMentalHerb + jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_POISON_POWER, BattleScript_FlingPoisonBarb + jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_TOXIC_ORB, BattleScript_FlingToxicOrb + jumpiflastuseditemholdeffect BS_ATTACKER, HOLD_EFFECT_RESTORE_STATS, BattleScript_FlingWhiteHerb +BattleScript_EffectFlingConsumeBerry: + savebattleritem BS_TARGET + battleritemtolastuseditem BS_TARGET + setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries + orword gHitMarker, HITMARKER_NO_ANIMATIONS + consumeberry BS_TARGET + bicword gHitMarker, HITMARKER_NO_ANIMATIONS + setbyte sBERRY_OVERRIDE, FALSE + restorebattleritem BS_TARGET +BattleScript_FlingEnd: + tryfaintmon BS_TARGET, FALSE, NULL + goto BattleScript_MoveEnd + BattleScript_FlingFlameOrb: setmoveeffect MOVE_EFFECT_BURN seteffectprimary @@ -455,6 +469,13 @@ BattleScript_FlingLightBall: goto BattleScript_FlingEnd BattleScript_FlingMentalHerb: curecertainstatuses BS_TARGET + savetarget + copybyte gBattlerAttacker, gBattlerTarget + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + printfromtable gMentalHerbCureStringIds + waitmessage B_WAIT_TIME_LONG + updatestatusicon BS_ATTACKER + restoretarget goto BattleScript_FlingEnd BattleScript_FlingPoisonBarb: setmoveeffect MOVE_EFFECT_POISON @@ -471,10 +492,6 @@ BattleScript_FlingWhiteHerb: waitmessage B_WAIT_TIME_MED swapattackerwithtarget goto BattleScript_FlingEnd -BattleScript_FlingEnd: - tryfaintmon BS_TARGET, FALSE, NULL - removeitem BS_ATTACKER - goto BattleScript_MoveEnd BattleScript_EffectShellSideArm: shellsidearmcheck diff --git a/include/battle.h b/include/battle.h index f1262b128..5035aa5a0 100644 --- a/include/battle.h +++ b/include/battle.h @@ -302,6 +302,7 @@ struct BattleHistory u8 moveHistoryIndex[MAX_BATTLERS_COUNT]; u16 trainerItems[MAX_BATTLERS_COUNT]; u8 itemsNo; + u16 heldItems[MAX_BATTLERS_COUNT]; }; struct BattleScriptsStack diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 793bfacf7..310815d48 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -137,7 +137,7 @@ #define B_KINGS_SHIELD_LOWER_ATK GEN_7 // In Gen7+, it lowers Atk by 1 stage instead of 2 of oponents that hit it. #define B_SPEED_BUFFING_RAPID_SPIN GEN_8 // In Gen8, Rapid Spin raises the user's Speed by 1 stage. #define B_RECOIL_IF_MISS_DMG GEN_7 // In Gen5+, Jump Kick and High Jump Kick will always do half of the user's max HP when missing. -#define B_FLING_EMBARGO_ITEM GEN_7 // In Gen4, if a target is under the effects of Embargo, the user's item's hold effect doesn't activate. +#define B_KLUTZ_FLING_INTERACTION GEN_7 // In Gen5+, Pokémon with the Klutz ability can't use Fling. // Move accuracy settings #define B_TOXIC_NEVER_MISS GEN_7 // In Gen6+, if Toxic is used by a Poison-type Pokémon, it will never miss. diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 6ace7458e..e09fb0155 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -74,143 +74,148 @@ #define CMP_NO_COMMON_BITS 5 // Cmd_various -#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 -#define VARIOUS_SET_MAGIC_COAT_TARGET 1 -#define VARIOUS_IS_RUNNING_IMPOSSIBLE 2 -#define VARIOUS_GET_MOVE_TARGET 3 -#define VARIOUS_GET_BATTLER_FAINTED 4 -#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5 -#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 -#define VARIOUS_PALACE_FLAVOR_TEXT 8 -#define VARIOUS_ARENA_JUDGMENT_WINDOW 9 -#define VARIOUS_ARENA_OPPONENT_MON_LOST 10 -#define VARIOUS_ARENA_PLAYER_MON_LOST 11 -#define VARIOUS_ARENA_BOTH_MONS_LOST 12 -#define VARIOUS_EMIT_YESNOBOX 13 -#define VARIOUS_ARENA_JUDGMENT_STRING 16 -#define VARIOUS_ARENA_WAIT_STRING 17 -#define VARIOUS_WAIT_CRY 18 -#define VARIOUS_RETURN_OPPONENT_MON1 19 -#define VARIOUS_RETURN_OPPONENT_MON2 20 -#define VARIOUS_VOLUME_DOWN 21 -#define VARIOUS_VOLUME_UP 22 -#define VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT 23 -#define VARIOUS_SET_TELEPORT_OUTCOME 25 -#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 -#define VARIOUS_STAT_TEXT_BUFFER 27 -#define VARIOUS_SWITCHIN_ABILITIES 28 -#define VARIOUS_SAVE_TARGET 29 -#define VARIOUS_RESTORE_TARGET 30 -#define VARIOUS_INSTANT_HP_DROP 31 -#define VARIOUS_CLEAR_STATUS 32 -#define VARIOUS_RESTORE_PP 33 -#define VARIOUS_TRY_ACTIVATE_MOXIE 34 -#define VARIOUS_TRY_ACTIVATE_FELL_STINGER 35 -#define VARIOUS_PLAY_MOVE_ANIMATION 36 -#define VARIOUS_SET_LUCKY_CHANT 37 -#define VARIOUS_SUCKER_PUNCH_CHECK 38 -#define VARIOUS_SET_SIMPLE_BEAM 39 -#define VARIOUS_TRY_ENTRAINMENT 40 -#define VARIOUS_SET_LAST_USED_ABILITY 41 -#define VARIOUS_TRY_HEAL_PULSE 42 -#define VARIOUS_TRY_QUASH 43 -#define VARIOUS_INVERT_STAT_STAGES 44 -#define VARIOUS_SET_TERRAIN 45 -#define VARIOUS_TRY_ME_FIRST 46 -#define VARIOUS_JUMP_IF_BATTLE_END 47 -#define VARIOUS_TRY_ELECTRIFY 48 -#define VARIOUS_TRY_REFLECT_TYPE 49 -#define VARIOUS_TRY_SOAK 50 -#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 -#define VARIOUS_TRY_AUTOTOMIZE 55 -#define VARIOUS_TRY_COPYCAT 56 -#define VARIOUS_ABILITY_POPUP 57 -#define VARIOUS_DEFOG 58 -#define VARIOUS_JUMP_IF_TARGET_ALLY 59 -#define VARIOUS_TRY_SYNCHRONOISE 60 -#define VARIOUS_PSYCHO_SHIFT 61 -#define VARIOUS_CURE_STATUS 62 -#define VARIOUS_POWER_TRICK 63 -#define VARIOUS_AFTER_YOU 64 -#define VARIOUS_BESTOW 65 -#define VARIOUS_ARGUMENT_TO_MOVE_EFFECT 66 -#define VARIOUS_JUMP_IF_NOT_GROUNDED 67 -#define VARIOUS_HANDLE_TRAINER_SLIDE_MSG 68 -#define VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF 69 -#define VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON 70 -#define VARIOUS_SET_AURORA_VEIL 71 -#define VARIOUS_TRY_THIRD_TYPE 72 -#define VARIOUS_ACUPRESSURE 73 -#define VARIOUS_SET_POWDER 74 -#define VARIOUS_SPECTRAL_THIEF 75 -#define VARIOUS_GRAVITY_ON_AIRBORNE_MONS 76 -#define VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS 77 -#define VARIOUS_JUMP_IF_ROAR_FAILS 78 -#define VARIOUS_TRY_INSTRUCT 79 -#define VARIOUS_JUMP_IF_NOT_BERRY 80 -#define VARIOUS_TRACE_ABILITY 81 -#define VARIOUS_UPDATE_NICK 82 -#define VARIOUS_TRY_ILLUSION_OFF 83 -#define VARIOUS_SET_SPRITEIGNORE0HP 84 -#define VARIOUS_HANDLE_FORM_CHANGE 85 -#define VARIOUS_GET_STAT_VALUE 86 -#define VARIOUS_JUMP_IF_FULL_HP 87 -#define VARIOUS_LOSE_TYPE 88 -#define VARIOUS_TRY_ACTIVATE_SOULHEART 89 -#define VARIOUS_TRY_ACTIVATE_RECEIVER 90 -#define VARIOUS_TRY_ACTIVATE_BEAST_BOOST 91 -#define VARIOUS_TRY_FRISK 92 -#define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 93 -#define VARIOUS_TRY_FAIRY_LOCK 94 -#define VARIOUS_JUMP_IF_NO_ALLY 95 -#define VARIOUS_POISON_TYPE_IMMUNITY 96 -#define VARIOUS_JUMP_IF_NO_HOLD_EFFECT 97 -#define VARIOUS_INFATUATE_WITH_BATTLER 98 -#define VARIOUS_SET_LAST_USED_ITEM 99 -#define VARIOUS_PARALYZE_TYPE_IMMUNITY 100 -#define VARIOUS_JUMP_IF_ABSENT 101 -#define VARIOUS_DESTROY_ABILITY_POPUP 102 -#define VARIOUS_TOTEM_BOOST 103 -#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 -#define VARIOUS_MOVEEND_ITEM_EFFECTS 105 -#define VARIOUS_TERRAIN_SEED 106 -#define VARIOUS_MAKE_INVISIBLE 107 -#define VARIOUS_ROOM_SERVICE 108 -#define VARIOUS_JUMP_IF_TERRAIN_AFFECTED 109 -#define VARIOUS_EERIE_SPELL_PP_REDUCE 110 -#define VARIOUS_JUMP_IF_TEAM_HEALTHY 111 -#define VARIOUS_TRY_HEAL_QUARTER_HP 112 -#define VARIOUS_REMOVE_TERRAIN 113 -#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 -#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 -#define VARIOUS_GET_ROTOTILLER_TARGETS 116 -#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 117 -#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 118 -#define VARIOUS_CONSUME_BERRY 119 -#define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 120 -#define VARIOUS_HANDLE_PRIMAL_REVERSION 121 -#define VARIOUS_APPLY_PLASMA_FISTS 122 -#define VARIOUS_JUMP_IF_SPECIES 123 -#define VARIOUS_UPDATE_ABILITY_POPUP 124 -#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125 -#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126 -#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127 -#define VARIOUS_TRY_TO_APPLY_MIMICRY 128 -#define VARIOUS_PHOTON_GEYSER_CHECK 129 -#define VARIOUS_SHELL_SIDE_ARM_CHECK 130 -#define VARIOUS_TRY_NO_RETREAT 131 -#define VARIOUS_TRY_TAR_SHOT 132 -#define VARIOUS_CAN_TAR_SHOT_WORK 133 -#define VARIOUS_CHECK_POLTERGEIST 134 -#define VARIOUS_SET_OCTOLOCK 135 -#define VARIOUS_CUT_1_3_HP_RAISE_STATS 136 -#define VARIOUS_JUMP_IF_FLING_FAILS 137 -#define VARIOUS_JUMP_IF_HOLD_EFFECT 138 -#define VARIOUS_CURE_CERTAIN_STATUSES 139 -#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 140 +#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 +#define VARIOUS_SET_MAGIC_COAT_TARGET 1 +#define VARIOUS_IS_RUNNING_IMPOSSIBLE 2 +#define VARIOUS_GET_MOVE_TARGET 3 +#define VARIOUS_GET_BATTLER_FAINTED 4 +#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5 +#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 +#define VARIOUS_PALACE_FLAVOR_TEXT 8 +#define VARIOUS_ARENA_JUDGMENT_WINDOW 9 +#define VARIOUS_ARENA_OPPONENT_MON_LOST 10 +#define VARIOUS_ARENA_PLAYER_MON_LOST 11 +#define VARIOUS_ARENA_BOTH_MONS_LOST 12 +#define VARIOUS_EMIT_YESNOBOX 13 +#define VARIOUS_ARENA_JUDGMENT_STRING 16 +#define VARIOUS_ARENA_WAIT_STRING 17 +#define VARIOUS_WAIT_CRY 18 +#define VARIOUS_RETURN_OPPONENT_MON1 19 +#define VARIOUS_RETURN_OPPONENT_MON2 20 +#define VARIOUS_VOLUME_DOWN 21 +#define VARIOUS_VOLUME_UP 22 +#define VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT 23 +#define VARIOUS_SET_TELEPORT_OUTCOME 25 +#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 +#define VARIOUS_STAT_TEXT_BUFFER 27 +#define VARIOUS_SWITCHIN_ABILITIES 28 +#define VARIOUS_SAVE_TARGET 29 +#define VARIOUS_RESTORE_TARGET 30 +#define VARIOUS_INSTANT_HP_DROP 31 +#define VARIOUS_CLEAR_STATUS 32 +#define VARIOUS_RESTORE_PP 33 +#define VARIOUS_TRY_ACTIVATE_MOXIE 34 +#define VARIOUS_TRY_ACTIVATE_FELL_STINGER 35 +#define VARIOUS_PLAY_MOVE_ANIMATION 36 +#define VARIOUS_SET_LUCKY_CHANT 37 +#define VARIOUS_SUCKER_PUNCH_CHECK 38 +#define VARIOUS_SET_SIMPLE_BEAM 39 +#define VARIOUS_TRY_ENTRAINMENT 40 +#define VARIOUS_SET_LAST_USED_ABILITY 41 +#define VARIOUS_TRY_HEAL_PULSE 42 +#define VARIOUS_TRY_QUASH 43 +#define VARIOUS_INVERT_STAT_STAGES 44 +#define VARIOUS_SET_TERRAIN 45 +#define VARIOUS_TRY_ME_FIRST 46 +#define VARIOUS_JUMP_IF_BATTLE_END 47 +#define VARIOUS_TRY_ELECTRIFY 48 +#define VARIOUS_TRY_REFLECT_TYPE 49 +#define VARIOUS_TRY_SOAK 50 +#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 +#define VARIOUS_TRY_AUTOTOMIZE 55 +#define VARIOUS_TRY_COPYCAT 56 +#define VARIOUS_ABILITY_POPUP 57 +#define VARIOUS_DEFOG 58 +#define VARIOUS_JUMP_IF_TARGET_ALLY 59 +#define VARIOUS_TRY_SYNCHRONOISE 60 +#define VARIOUS_PSYCHO_SHIFT 61 +#define VARIOUS_CURE_STATUS 62 +#define VARIOUS_POWER_TRICK 63 +#define VARIOUS_AFTER_YOU 64 +#define VARIOUS_BESTOW 65 +#define VARIOUS_ARGUMENT_TO_MOVE_EFFECT 66 +#define VARIOUS_JUMP_IF_NOT_GROUNDED 67 +#define VARIOUS_HANDLE_TRAINER_SLIDE_MSG 68 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF 69 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON 70 +#define VARIOUS_SET_AURORA_VEIL 71 +#define VARIOUS_TRY_THIRD_TYPE 72 +#define VARIOUS_ACUPRESSURE 73 +#define VARIOUS_SET_POWDER 74 +#define VARIOUS_SPECTRAL_THIEF 75 +#define VARIOUS_GRAVITY_ON_AIRBORNE_MONS 76 +#define VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS 77 +#define VARIOUS_JUMP_IF_ROAR_FAILS 78 +#define VARIOUS_TRY_INSTRUCT 79 +#define VARIOUS_JUMP_IF_NOT_BERRY 80 +#define VARIOUS_TRACE_ABILITY 81 +#define VARIOUS_UPDATE_NICK 82 +#define VARIOUS_TRY_ILLUSION_OFF 83 +#define VARIOUS_SET_SPRITEIGNORE0HP 84 +#define VARIOUS_HANDLE_FORM_CHANGE 85 +#define VARIOUS_GET_STAT_VALUE 86 +#define VARIOUS_JUMP_IF_FULL_HP 87 +#define VARIOUS_LOSE_TYPE 88 +#define VARIOUS_TRY_ACTIVATE_SOULHEART 89 +#define VARIOUS_TRY_ACTIVATE_RECEIVER 90 +#define VARIOUS_TRY_ACTIVATE_BEAST_BOOST 91 +#define VARIOUS_TRY_FRISK 92 +#define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 93 +#define VARIOUS_TRY_FAIRY_LOCK 94 +#define VARIOUS_JUMP_IF_NO_ALLY 95 +#define VARIOUS_POISON_TYPE_IMMUNITY 96 +#define VARIOUS_JUMP_IF_NO_HOLD_EFFECT 97 +#define VARIOUS_INFATUATE_WITH_BATTLER 98 +#define VARIOUS_SET_LAST_USED_ITEM 99 +#define VARIOUS_PARALYZE_TYPE_IMMUNITY 100 +#define VARIOUS_JUMP_IF_ABSENT 101 +#define VARIOUS_DESTROY_ABILITY_POPUP 102 +#define VARIOUS_TOTEM_BOOST 103 +#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 +#define VARIOUS_MOVEEND_ITEM_EFFECTS 105 +#define VARIOUS_TERRAIN_SEED 106 +#define VARIOUS_MAKE_INVISIBLE 107 +#define VARIOUS_ROOM_SERVICE 108 +#define VARIOUS_JUMP_IF_TERRAIN_AFFECTED 109 +#define VARIOUS_EERIE_SPELL_PP_REDUCE 110 +#define VARIOUS_JUMP_IF_TEAM_HEALTHY 111 +#define VARIOUS_TRY_HEAL_QUARTER_HP 112 +#define VARIOUS_REMOVE_TERRAIN 113 +#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 +#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 +#define VARIOUS_GET_ROTOTILLER_TARGETS 116 +#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 117 +#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 118 +#define VARIOUS_CONSUME_BERRY 119 +#define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 120 +#define VARIOUS_HANDLE_PRIMAL_REVERSION 121 +#define VARIOUS_APPLY_PLASMA_FISTS 122 +#define VARIOUS_JUMP_IF_SPECIES 123 +#define VARIOUS_UPDATE_ABILITY_POPUP 124 +#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125 +#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126 +#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127 +#define VARIOUS_TRY_TO_APPLY_MIMICRY 128 +#define VARIOUS_PHOTON_GEYSER_CHECK 129 +#define VARIOUS_SHELL_SIDE_ARM_CHECK 130 +#define VARIOUS_TRY_NO_RETREAT 131 +#define VARIOUS_TRY_TAR_SHOT 132 +#define VARIOUS_CAN_TAR_SHOT_WORK 133 +#define VARIOUS_CHECK_POLTERGEIST 134 +#define VARIOUS_SET_OCTOLOCK 135 +#define VARIOUS_CUT_1_3_HP_RAISE_STATS 136 +#define VARIOUS_JUMP_IF_NO_FLING_POWER 137 +#define VARIOUS_JUMP_IF_HOLD_EFFECT 138 +#define VARIOUS_CURE_CERTAIN_STATUSES 139 +#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 140 +#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 141 +#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 142 +#define VARIOUS_SAVE_BATTLER_ITEM 143 +#define VARIOUS_RESTORE_BATTLER_ITEM 144 +#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 145 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 88c3af2f0..83daafb29 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1414,6 +1414,19 @@ static void Cmd_attackcanceler(void) GET_MOVE_TYPE(gCurrentMove, moveType); + // Unnerve prevents a Pokémon holding a Berry from using Fling. + if (gCurrentMove == MOVE_FLING + && GetBattlerAbility(gBattlerAttacker) == ABILITY_UNNERVE + && ItemId_GetPocket(gLastUsedItem) == POCKET_BERRIES) + { + // Fling removes the item just before attackcanceler kicks in. + // This is done to work around an opponent using Protect/Detect. + gBattleMons[gBattlerAttacker].item = gLastUsedItem; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_ButItFailedAtkStringPpReduce; + return; + } + if (moveType == TYPE_FIRE && (gBattleWeather & WEATHER_RAIN_PRIMAL) && WEATHER_HAS_EFFECT @@ -9287,98 +9300,56 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; return; } - case VARIOUS_JUMP_IF_FLING_FAILS: + case VARIOUS_JUMP_IF_NO_FLING_POWER: #ifdef ITEM_EXPANSION if (!ItemId_GetFlingPower(gBattleMons[gActiveBattler].item)) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); - else if (!CanBattlerGetOrLoseItem(gActiveBattler, gBattleMons[gActiveBattler].item)) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); - #else - if (!CanBattlerGetOrLoseItem(gActiveBattler, gBattleMons[gActiveBattler].item)) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); - #endif else + #endif gBattlescriptCurrInstr += 7; return; - case VARIOUS_JUMP_IF_HOLD_EFFECT: - if (GetBattlerHoldEffect(gActiveBattler, TRUE) == gBattlescriptCurrInstr[3]) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4); - else - gBattlescriptCurrInstr += 8; - return; case VARIOUS_CURE_CERTAIN_STATUSES: + // Check infatuation if (gBattleMons[gActiveBattler].status2 & STATUS2_INFATUATION) { gBattleMons[gActiveBattler].status2 &= ~(STATUS2_INFATUATION); - gBattleMons[gActiveBattler].status2 = 0; - BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status2); - MarkBattlerForControllerExec(gActiveBattler); - PrepareStringBattle(STRINGID_TARGETGOTOVERINFATUATION, gActiveBattler); - gBattleCommunication[MSG_DISPLAY] = 1; + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_INFATUATION; // STRINGID_TARGETGOTOVERINFATUATION + StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); } - else if (gBattleMons[gActiveBattler].status2 & STATUS2_TORMENT) + // Check taunt + if (gDisableStructs[gActiveBattler].tauntTimer != 0) { - gBattleMons[gActiveBattler].status2 &= ~(STATUS2_TORMENT); - gBattleMons[gActiveBattler].status2 = 0; - BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status2); - MarkBattlerForControllerExec(gActiveBattler); - // Swap gBattlerTarget and gBattlerAttacker so STRINGID_BUFFERENDS works correctly - gActiveBattler = gBattlerAttacker; - gBattlerAttacker = gBattlerTarget; - gBattlerTarget = gActiveBattler; - gHitMarker |= HITMARKER_SWAP_ATTACKER_TARGET; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TORMENT); - PrepareStringBattle(STRINGID_BUFFERENDS, gActiveBattler); - gBattleCommunication[MSG_DISPLAY] = 1; - // Swap gBattlerTarget and gBattlerAttacker back - if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET) - gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET); - } - else if (gDisableStructs[gActiveBattler].tauntTimer != 0) - { - gDisableStructs[gActiveBattler].tauntTimer = 0; - // Swap gBattlerTarget and gBattlerAttacker so STRINGID_BUFFERENDS works correctly - gActiveBattler = gBattlerAttacker; - gBattlerAttacker = gBattlerTarget; - gBattlerTarget = gActiveBattler; - gHitMarker |= HITMARKER_SWAP_ATTACKER_TARGET; + gDisableStructs[gActiveBattler].tauntTimer = gDisableStructs[gActiveBattler].tauntTimer2 = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TAUNT; PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT); - PrepareStringBattle(STRINGID_BUFFERENDS, gActiveBattler); - gBattleCommunication[MSG_DISPLAY] = 1; - // Swap gBattlerTarget and gBattlerAttacker back - if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET) - gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET); } - else if (gDisableStructs[gActiveBattler].encoreTimer) + // Check encore + if (gDisableStructs[gActiveBattler].encoreTimer != 0) { gDisableStructs[gActiveBattler].encoredMove = 0; - gDisableStructs[gActiveBattler].encoreTimer = 0; - // Swap gBattlerTarget and gBattlerAttacker so STRINGID_BUFFERENDS works correctly - gActiveBattler = gBattlerAttacker; - gBattlerAttacker = gBattlerTarget; - gBattlerTarget = gActiveBattler; - gHitMarker |= HITMARKER_SWAP_ATTACKER_TARGET; - PrepareStringBattle(STRINGID_PKMNENCOREENDED, gActiveBattler); - gBattleCommunication[MSG_DISPLAY] = 1; - // Swap gBattlerTarget and gBattlerAttacker back - if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET) - gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET); + gDisableStructs[gActiveBattler].encoreTimerStartValue = gDisableStructs[gActiveBattler].encoreTimer = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_ENCORE; // STRINGID_PKMNENCOREENDED } - else if (gDisableStructs[gActiveBattler].disableTimer) + // Check torment + if (gBattleMons[gActiveBattler].status2 & STATUS2_TORMENT) { - gDisableStructs[gActiveBattler].disabledMove = 0; - // Swap gBattlerTarget and gBattlerAttacker so STRINGID_BUFFERENDS works correctly - gActiveBattler = gBattlerAttacker; - gBattlerAttacker = gBattlerTarget; - gBattlerTarget = gActiveBattler; - gHitMarker |= HITMARKER_SWAP_ATTACKER_TARGET; - PrepareStringBattle(STRINGID_PKMNMOVEDISABLEDNOMORE, gBattlerTarget); - gBattleCommunication[MSG_DISPLAY] = 1; - // Swap gBattlerTarget and gBattlerAttacker back - if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET) - gHitMarker &= ~(HITMARKER_SWAP_ATTACKER_TARGET); + gBattleMons[gActiveBattler].status2 &= ~(STATUS2_TORMENT); + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_TORMENT; } - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 7); + // Check heal block + if (gStatuses3[gActiveBattler] & STATUS3_HEAL_BLOCK) + { + gStatuses3[gActiveBattler] &= ~(STATUS3_HEAL_BLOCK); + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_HEALBLOCK; + } + // Check disable + if (gDisableStructs[gActiveBattler].disableTimer != 0) + { + gDisableStructs[gActiveBattler].disableTimer = gDisableStructs[gActiveBattler].disableTimerStartValue = 0; + gDisableStructs[gActiveBattler].disabledMove = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_MENTALHERBCURE_DISABLE; + } + gBattlescriptCurrInstr += 3; return; case VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES: gActiveBattler = gBattlerTarget; @@ -9387,6 +9358,27 @@ static void Cmd_various(void) gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE; gBattlescriptCurrInstr += 3; return; + case VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY: + if (ItemId_GetPocket(gLastUsedItem) == POCKET_BERRIES) + gBattlescriptCurrInstr += 7; + else + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + return; + case VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT: + if (ItemId_GetHoldEffect(gLastUsedItem) == gBattlescriptCurrInstr[3]) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4); + else + gBattlescriptCurrInstr += 8; + return; + case VARIOUS_SAVE_BATTLER_ITEM: + gBattleResources->battleHistory->heldItems[gActiveBattler] = gBattleMons[gActiveBattler].item; + break; + case VARIOUS_RESTORE_BATTLER_ITEM: + gBattleMons[gActiveBattler].item = gBattleResources->battleHistory->heldItems[gActiveBattler]; + break; + case VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM: + gBattleMons[gActiveBattler].item = gLastUsedItem; + break; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3;