From c1f90329896401f7d0aa1f121131efd6391688d0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 16 Feb 2019 12:54:11 +0100 Subject: [PATCH] Defiant and Competitive --- data/battle_scripts_1.s | 10 ++++++++++ include/battle_scripts.h | 1 + src/battle_script_commands.c | 6 +++--- src/battle_util.c | 16 +++++++++++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 081b92c52..fe5dd7dd3 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5803,6 +5803,16 @@ BattleScript_DrizzleActivates:: call BattleScript_WeatherFormChanges end3 +BattleScript_DefiantActivates:: + pause 0x20 + call BattleScript_AbilityPopUp + statbuffchange 0, NULL + setgraphicalstatchangevalues + playanimation BS_ABILITY_BATTLER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printstring STRINGID_PKMNSSTATCHANGED2 + waitmessage 0x40 + return + BattleScript_AbilityPopUp: showabilitypopup BS_ABILITY_BATTLER recordability BS_ABILITY_BATTLER diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 94574f965..b9378cb32 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -295,5 +295,6 @@ extern const u8 BattleScript_MistySurgeActivates[]; extern const u8 BattleScript_ElectricSurgeActivates[]; extern const u8 BattleScript_SpectralThiefSteal[]; extern const u8 BattleScript_StatUpMsg[]; +extern const u8 BattleScript_DefiantActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 94799a6bf..adc13bae6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1893,8 +1893,9 @@ static void atk10_printstring(void) if (gBattleControllerExecFlags == 0) { u16 var = T2_READ_16(gBattlescriptCurrInstr + 1); - PrepareStringBattle(var, gBattlerAttacker); + gBattlescriptCurrInstr += 3; + PrepareStringBattle(var, gBattlerAttacker); gBattleCommunication[MSG_DISPLAY] = 1; } } @@ -1938,9 +1939,8 @@ static void atk13_printfromtable(void) const u16 *ptr = (const u16*) T1_READ_PTR(gBattlescriptCurrInstr + 1); ptr += gBattleCommunication[MULTISTRING_CHOOSER]; - PrepareStringBattle(*ptr, gBattlerAttacker); - gBattlescriptCurrInstr += 5; + PrepareStringBattle(*ptr, gBattlerAttacker); gBattleCommunication[MSG_DISPLAY] = 1; } } diff --git a/src/battle_util.c b/src/battle_util.c index 5ba6788c8..3024652b2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -483,11 +483,25 @@ void PrepareStringBattle(u16 stringId, u8 battler) else if (stringId == STRINGID_STATSWONTINCREASE && gBattleScripting.statChanger & STAT_BUFF_NEGATIVE) stringId = STRINGID_STATSWONTDECREASE; - if (stringId == STRINGID_STATSWONTDECREASE2 && GetBattlerAbility(battler) == ABILITY_CONTRARY) + else if (stringId == STRINGID_STATSWONTDECREASE2 && GetBattlerAbility(battler) == ABILITY_CONTRARY) stringId = STRINGID_STATSWONTINCREASE2; else if (stringId == STRINGID_STATSWONTINCREASE2 && GetBattlerAbility(battler) == ABILITY_CONTRARY) stringId = STRINGID_STATSWONTDECREASE2; + // Check Defiant and Competitive stat raise whenever a stat is lowered. + else if (((GetBattlerAbility(gBattlerTarget) == ABILITY_DEFIANT && gBattleMons[gBattlerTarget].statStages[STAT_ATK] != 12) + || (GetBattlerAbility(gBattlerTarget) == ABILITY_COMPETITIVE && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] != 12)) + && stringId == STRINGID_PKMNSSTATCHANGED4) + { + gBattlerAbility = gBattlerTarget; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_DefiantActivates; + if (GetBattlerAbility(gBattlerTarget) == ABILITY_DEFIANT) + SET_STATCHANGER(STAT_ATK, 2, FALSE); + else + SET_STATCHANGER(STAT_SPATK, 2, FALSE); + } + gActiveBattler = battler; BtlController_EmitPrintString(0, stringId); MarkBattlerForControllerExec(gActiveBattler);