From acb9c31bd4d7747656531e7f5230ed12f0ec1cd1 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 3 Dec 2022 01:17:22 -0300 Subject: [PATCH] Implemented Anger Shell's effect --- data/battle_scripts_1.s | 44 ++++++++++++++++++++++++++++++++++++++++ include/battle.h | 1 + include/battle_scripts.h | 1 + src/battle_util.c | 14 +++++++++++++ 4 files changed, 60 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d807f5610..964a6d8a3 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7032,6 +7032,50 @@ BattleScript_SeedSowerActivates:: call BattleScript_TerrainSeedLoop return +BattleScript_AngerShellActivates:: + call BattleScript_AbilityPopUp + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_SPEED, MAX_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_GREATER_THAN, STAT_DEF, MIN_STAT_STAGE, BattleScript_AngerShellTryDef + jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPDEF, MIN_STAT_STAGE, BattleScript_ButItFailed +BattleScript_AngerShellTryDef:: + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_TARGET, BIT_DEF | BIT_SPDEF, STAT_CHANGE_NEGATIVE | STAT_CHANGE_CANT_PREVENT + setstatchanger STAT_DEF, 1, TRUE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTrySpDef + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpDef + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTrySpDef: + setstatchanger STAT_SPDEF, 1, TRUE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR | MOVE_EFFECT_CERTAIN, BattleScript_AngerShellTryAttack + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTryAttack + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTryAttack: + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_TARGET, BIT_SPATK | BIT_ATK | BIT_SPEED, STAT_CHANGE_BY_TWO + setstatchanger STAT_ATK, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpAtk + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpAtk + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTrySpAtk: + setstatchanger STAT_SPATK, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellTrySpeed + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellTrySpeed + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellTrySpeed: + setstatchanger STAT_SPEED, 1, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AngerShellRet + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_AngerShellRet + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_AngerShellRet: + return + BattleScript_PerishSongCountGoesDown:: printstring STRINGID_PKMNPERISHCOUNTFELL waitmessage B_WAIT_TIME_LONG diff --git a/include/battle.h b/include/battle.h index ebc8be057..14037b72c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -652,6 +652,7 @@ struct BattleStruct u8 attackerBeforeBounce:2; u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit. u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) + bool8 endturnAbilityDone[PARTY_SIZE][2]; // For some reason, adding a switchInAbilityDone equivalent in SpecialStatus didn't work. }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index d9dafe5df..462da38db 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -434,6 +434,7 @@ extern const u8 BattleScript_MultiHitPrintStrings[]; extern const u8 BattleScript_BurnUpRemoveType[]; extern const u8 BattleScript_TargetAbilityStatRaiseRet[]; extern const u8 BattleScript_SeedSowerActivates[]; +extern const u8 BattleScript_AngerShellActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/src/battle_util.c b/src/battle_util.c index d3275be0d..ed425dd49 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5749,6 +5749,20 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; + case ABILITY_ANGER_SHELL: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && TARGET_TURN_DAMAGED + && (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerTarget].maxHP / 2) + && !gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)]) + { + gBattleStruct->endturnAbilityDone[gBattlerPartyIndexes[gBattlerTarget]][GetBattlerSide(gBattlerTarget)] = TRUE; + gBattlerAttacker = gBattlerTarget; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_AngerShellActivates; + effect++; + } + break; } break; case ABILITYEFFECT_MOVE_END_ATTACKER: // Same as above, but for attacker