diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 59d98a6c1..94f9bb433 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1449,6 +1449,11 @@ .4byte \ptr .endm + .macro trymefirst ptr + various BS_ATTACKER, VARIOUS_TRY_ME_FIRST + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat, stages, down setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 484fbb96b..df1935093 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -290,6 +290,17 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectAttackSpAttackUp .4byte BattleScript_EffectHurricane .4byte BattleScript_EffectTwoTypedMove + .4byte BattleScript_EffectMeFirst + +BattleScript_EffectMeFirst: + attackcanceler + attackstring + trymefirst BattleScript_ButItFailedPpReduce + attackanimation + waitanimation + setbyte sB_ANIM_TURN, 0x0 + setbyte sB_ANIM_TARGETS_HIT, 0x0 + jumptorandomattack TRUE BattleScript_EffectAttackSpAttackUp: attackcanceler diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 37f79c14e..8bc7acad6 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -279,5 +279,6 @@ #define EFFECT_ATTACK_SPATK_UP 273 #define EFFECT_HURRICANE 274 #define EFFECT_TWO_TYPED_MOVE 275 +#define EFFECT_ME_FIRST 276 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d301a7660..bfff72ea8 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -92,6 +92,7 @@ #define VARIOUS_TRY_QUASH 43 #define VARIOUS_INVERT_STAT_STAGES 44 #define VARIOUS_SET_TERRAIN 45 +#define VARIOUS_TRY_ME_FIRST 46 // atk80, dmg manipulation #define ATK80_DMG_CHANGE_SIGN 0 diff --git a/include/data/battle_moves.h b/include/data/battle_moves.h index bfeaa8ca8..3f826c00c 100644 --- a/include/data/battle_moves.h +++ b/include/data/battle_moves.h @@ -4588,7 +4588,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_GEN6] = .split = SPLIT_STATUS, }, { // MOVE_ME_FIRST - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_ME_FIRST, .power = 0, .type = TYPE_NORMAL, .accuracy = 0, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index dcdb39c3a..1b0e7d327 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4265,6 +4265,7 @@ static void atk49_moveend(void) case 17: // Clear bits active just while using a move. gProtectStructs[gBattlerAttacker].usesBouncedMove = 0; gBattleStruct->ateBoost[gBattlerAttacker] = 0; + gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST); gBattleScripting.atk49_state++; break; case ATK49_LAST_CASE: @@ -6480,6 +6481,37 @@ static void atk76_various(void) case VARIOUS_SET_TERRAIN: HandleTerrainMove(gBattleMoves[gCurrentMove].effect); return; + case VARIOUS_TRY_ME_FIRST: + if (GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else if (gBattleMoves[gBattleMons[gBattlerTarget].moves[gBattleStruct->chosenMovePositions[gBattlerTarget]]].power == 0) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + { + u16 move = gBattleMons[gBattlerTarget].moves[gBattleStruct->chosenMovePositions[gBattlerTarget]]; + switch (move) + { + case MOVE_STRUGGLE: + case MOVE_CHATTER: + case MOVE_FOCUS_PUNCH: + case MOVE_THIEF: + case MOVE_COVET: + case MOVE_COUNTER: + case MOVE_MIRROR_COAT: + case MOVE_METAL_BURST: + case MOVE_ME_FIRST: + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + break; + default: + gRandomMove = move; + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gBattlerTarget = GetMoveTarget(gRandomMove, 0); + gStatuses3[gBattlerAttacker] |= STATUS3_ME_FIRST; + gBattlescriptCurrInstr += 7; + break; + } + } + return; } gBattlescriptCurrInstr += 3;