From 9c94eb6140a0752d5bef391c3679c68af14d5404 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 16 Sep 2021 10:24:32 -0400 Subject: [PATCH] but it failed check for rototiller --- asm/macros/battle_script.inc | 10 +++++ data/battle_scripts_1.s | 40 +++++++++++-------- include/battle.h | 1 + include/constants/battle_script_commands.h | 2 + src/battle_script_commands.c | 45 ++++++++++++++++++++++ 5 files changed, 83 insertions(+), 15 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 662bfbf2f..a2d940737 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1776,6 +1776,16 @@ .macro pickpocketsteal various 0, VARIOUS_PICKPOCKET .endm + + .macro getrototillertargets ptr:req + various BS_ATTACKER, VARIOUS_GET_ROTOTILLER_TARGETS + .4byte \ptr + .endm + + .macro jumpifnotrototilleraffected battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED + .4byte \ptr + .endm @ helpful macros .macro setstatchanger stat:req, stages:req, down:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 2d6db5a28..177c657ce 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -814,27 +814,28 @@ BattleScript_FlowerShieldMoveTargetEnd: moveendto MOVEEND_NEXT_TARGET jumpifnexttargetvalid BattleScript_FlowerShieldLoop end + +BattleScript_RototillerRet:: + + return BattleScript_EffectRototiller: attackcanceler attackstring ppreduce - selectfirstvalidtarget -BattleScript_RototillerLoop: - movevaluescleanup - jumpifnotgrounded BS_TARGET, BattleScript_RototillerNoEffect - jumpiftype BS_TARGET, TYPE_GRASS, BattleScript_RototillerLoop2 -BattleScript_RototillerNoEffect: - pause B_WAIT_TIME_SHORT - printstring STRINGID_NOEFFECTONTARGET - waitmessage B_WAIT_TIME_LONG - goto BattleScript_RototillerMoveTargetEnd -BattleScript_RototillerLoop2: - jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_RototillerDoMoveAnim - jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPATK, MAX_STAT_STAGE, BattleScript_RototillerCantRaiseMultipleStats -BattleScript_RototillerDoMoveAnim:: + getrototillertargets BattleScript_ButItFailed + @ at least one battler is affected attackanimation waitanimation + savetarget + setbyte gBattlerTarget, 0 +BattleScript_RototillerLoop: + movevaluescleanup + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_RototillerCheckAffected + jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPATK, MAX_STAT_STAGE, BattleScript_RototillerCantRaiseMultipleStats +BattleScript_RototillerCheckAffected: + jumpifnotrototilleraffected BS_TARGET, BattleScript_RototillerNoEffect +BattleScript_RototillerAffected: setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_TARGET, BIT_ATK | BIT_SPATK, 0 setstatchanger STAT_ATK, 1, FALSE @@ -850,13 +851,22 @@ BattleScript_RototillerTrySpAtk:: waitmessage B_WAIT_TIME_LONG BattleScript_RototillerMoveTargetEnd: moveendto MOVEEND_NEXT_TARGET - jumpifnexttargetvalid BattleScript_RototillerLoop + addbyte gBattlerTarget, 1 + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_RototillerLoop end + BattleScript_RototillerCantRaiseMultipleStats: + copybyte gBattlerAttacker, gBattlerTarget printstring STRINGID_STATSWONTINCREASE2 waitmessage B_WAIT_TIME_LONG goto BattleScript_RototillerMoveTargetEnd +BattleScript_RototillerNoEffect: + pause B_WAIT_TIME_SHORT + printstring STRINGID_NOEFFECTONTARGET + waitmessage B_WAIT_TIME_LONG + goto BattleScript_RototillerMoveTargetEnd + BattleScript_EffectBestow: attackcanceler accuracycheck BattleScript_PrintMoveMissed, NO_ACC_CALC_CHECK_LOCK_ON diff --git a/include/battle.h b/include/battle.h index 3fbefe55b..576884d81 100644 --- a/include/battle.h +++ b/include/battle.h @@ -169,6 +169,7 @@ struct SpecialStatus u8 instructedChosenTarget:3; u8 berryReduced:1; u8 gemBoost:1; + u8 rototillerAffected:1; // to be affected by rototiller u8 gemParam; u8 damagedMons:4; // Mons that have been damaged directly by using a move, includes substitute. u8 dancerUsedMove:1; diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 7e7bb6ca9..6c5e3872a 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -174,6 +174,8 @@ #define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 #define VARIOUS_MOVEEND_ITEM_EFFECTS 105 +#define VARIOUS_GET_ROTOTILLER_TARGETS 106 +#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 107 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 05702aec6..a719db550 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7246,6 +7246,21 @@ static u32 GetHighestStatId(u32 battlerId) return highestId; } +static bool32 IsRototillerAffected(u32 battlerId) +{ + if (!IsBattlerAlive(battlerId)) + return FALSE; + if (!IsBattlerGrounded(battlerId)) + return FALSE; // Only grounded battlers affected + if (!IS_BATTLER_OF_TYPE(battlerId, TYPE_GRASS)) + return FALSE; // Only grass types affected + if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE) + return FALSE; // Rototiller doesn't affected semi-invulnerable battlers + //if (!CompareStat(battlerId, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN) && !CompareStat(battlerId, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN)) + //return FALSE; // Battler unaffected if atk and spatk are maxed + return TRUE; +} + static void Cmd_various(void) { struct Pokemon *mon; @@ -8498,6 +8513,36 @@ static void Cmd_various(void) if (ItemBattleEffects(1, gActiveBattler, FALSE)) return; break; + case VARIOUS_GET_ROTOTILLER_TARGETS: + // Gets the battlers to be affected by rototiller. If there are none, print 'But it failed!' + { + u32 count = 0; + for (i = 0; i < gBattlersCount; i++) + { + if (IsRototillerAffected(i)) + { + gSpecialStatuses[i].rototillerAffected = 1; + count++; + } + } + + if (count == 0) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); // Rototiller fails + else + gBattlescriptCurrInstr += 7; + } + return; + case VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED: + if (gSpecialStatuses[gActiveBattler].rototillerAffected) + { + gSpecialStatuses[gActiveBattler].rototillerAffected = 0; + gBattlescriptCurrInstr += 7; + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); // Unaffected by rototiller - print STRINGID_NOEFFECTONTARGET + } + return; } gBattlescriptCurrInstr += 3;