From 0329175f06fbf8745a88d9a7d9adca81fe3b08fd Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 30 Nov 2018 21:21:43 +0100 Subject: [PATCH] Add Protean --- data/battle_scripts_1.s | 6 ++++++ include/battle_scripts.h | 1 + src/battle_main.c | 18 +++++++++--------- src/battle_script_commands.c | 16 ++++++++++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 2f899daca..0f6d7c766 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5997,6 +5997,12 @@ BattleScript_ColorChangeActivates:: waitmessage 0x40 return +BattleScript_ProteanActivates:: + call BattleScript_AbilityPopUp + printstring STRINGID_PKMNCHANGEDTYPE + waitmessage 0x40 + return + BattleScript_CursedBodyActivates:: call BattleScript_AbilityPopUp printstring STRINGID_CUSEDBODYDISABLED diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 1a3ef5ed7..42079436b 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -283,5 +283,6 @@ extern const u8 BattleScript_MoveEffectFlameBurst[]; extern const u8 BattleScript_TrainerSlideMsgRet[]; extern const u8 BattleScript_TrainerSlideMsgEnd2[]; extern const u8 BattleScript_MoveEffectFeint[]; +extern const u8 BattleScript_ProteanActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_main.c b/src/battle_main.c index bde173256..0deb7f063 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5467,8 +5467,7 @@ static void HandleAction_UseMove(void) { u8 side; u8 var = 4; - u32 attackerAbility; - u32 ateType, moveType; + u32 moveType; gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; @@ -5535,6 +5534,10 @@ static void HandleAction_UseMove(void) gBattleResults.lastUsedMoveOpponent = gCurrentMove; } + // Set dynamic move type. + SetTypeBeforeUsingMove(gChosenMove, gBattlerAttacker); + GET_MOVE_TYPE(gChosenMove, moveType); + // choose target side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer != 0 @@ -5547,8 +5550,8 @@ static void HandleAction_UseMove(void) else if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gSideTimers[side].followmeTimer == 0 && (gBattleMoves[gCurrentMove].power != 0 || gBattleMoves[gCurrentMove].target != MOVE_TARGET_USER) - && ((gBattleMons[*(gBattleStruct->moveTarget + gBattlerAttacker)].ability != ABILITY_LIGHTNING_ROD && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) - || (gBattleMons[*(gBattleStruct->moveTarget + gBattlerAttacker)].ability != ABILITY_STORM_DRAIN && gBattleMoves[gCurrentMove].type == TYPE_WATER) + && ((gBattleMons[*(gBattleStruct->moveTarget + gBattlerAttacker)].ability != ABILITY_LIGHTNING_ROD && moveType == TYPE_ELECTRIC) + || (gBattleMons[*(gBattleStruct->moveTarget + gBattlerAttacker)].ability != ABILITY_STORM_DRAIN && moveType == TYPE_WATER) ) ) { @@ -5557,8 +5560,8 @@ static void HandleAction_UseMove(void) { if (side != GetBattlerSide(gActiveBattler) && *(gBattleStruct->moveTarget + gBattlerAttacker) != gActiveBattler - && ((gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) - || (gBattleMons[gActiveBattler].ability == ABILITY_STORM_DRAIN && gBattleMoves[gCurrentMove].type == TYPE_WATER) + && ((gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD && moveType == TYPE_ELECTRIC) + || (gBattleMons[gActiveBattler].ability == ABILITY_STORM_DRAIN && moveType == TYPE_WATER) ) && GetBattlerTurnOrderNum(gActiveBattler) < var) { @@ -5692,9 +5695,6 @@ static void HandleAction_UseMove(void) if (gBattleTypeFlags & BATTLE_TYPE_ARENA) BattleArena_AddMindPoints(gBattlerAttacker); - // Set dynamic move type. - SetTypeBeforeUsingMove(gChosenMove, gBattlerAttacker); - gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 00c899158..f9847fca4 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -949,6 +949,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) static void atk00_attackcanceler(void) { s32 i; + u32 moveType; if (gBattleOutcome != 0) { @@ -963,6 +964,21 @@ static void atk00_attackcanceler(void) } if (AtkCanceller_UnableToUseMove()) return; + + // Check Protean activation. + GET_MOVE_TYPE(gCurrentMove, moveType); + if (GetBattlerAbility(gBattlerAttacker) == ABILITY_PROTEAN + && (gBattleMons[gBattlerAttacker].type1 != moveType || gBattleMons[gBattlerAttacker].type2 != moveType || + (gBattleMons[gBattlerAttacker].type3 != moveType && gBattleMons[gBattlerAttacker].type3 != TYPE_MYSTERY)) + && gCurrentMove != MOVE_STRUGGLE) + { + PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType); + SET_BATTLER_TYPE(gBattlerAttacker, moveType); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_ProteanActivates; + return; + } + if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBattlerTarget, 0, 0, 0)) return; if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & 0x800200)