but it failed check for rototiller

This commit is contained in:
ghoulslash 2021-09-16 10:24:32 -04:00
parent 0cd7f3ffcd
commit 9c94eb6140
5 changed files with 83 additions and 15 deletions

View File

@ -1776,6 +1776,16 @@
.macro pickpocketsteal .macro pickpocketsteal
various 0, VARIOUS_PICKPOCKET various 0, VARIOUS_PICKPOCKET
.endm .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 @ helpful macros
.macro setstatchanger stat:req, stages:req, down:req .macro setstatchanger stat:req, stages:req, down:req

View File

@ -814,27 +814,28 @@ BattleScript_FlowerShieldMoveTargetEnd:
moveendto MOVEEND_NEXT_TARGET moveendto MOVEEND_NEXT_TARGET
jumpifnexttargetvalid BattleScript_FlowerShieldLoop jumpifnexttargetvalid BattleScript_FlowerShieldLoop
end end
BattleScript_RototillerRet::
return
BattleScript_EffectRototiller: BattleScript_EffectRototiller:
attackcanceler attackcanceler
attackstring attackstring
ppreduce ppreduce
selectfirstvalidtarget getrototillertargets BattleScript_ButItFailed
BattleScript_RototillerLoop: @ at least one battler is affected
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::
attackanimation attackanimation
waitanimation 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 setbyte sSTAT_ANIM_PLAYED, FALSE
playstatchangeanimation BS_TARGET, BIT_ATK | BIT_SPATK, 0 playstatchangeanimation BS_TARGET, BIT_ATK | BIT_SPATK, 0
setstatchanger STAT_ATK, 1, FALSE setstatchanger STAT_ATK, 1, FALSE
@ -850,13 +851,22 @@ BattleScript_RototillerTrySpAtk::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
BattleScript_RototillerMoveTargetEnd: BattleScript_RototillerMoveTargetEnd:
moveendto MOVEEND_NEXT_TARGET moveendto MOVEEND_NEXT_TARGET
jumpifnexttargetvalid BattleScript_RototillerLoop addbyte gBattlerTarget, 1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_RototillerLoop
end end
BattleScript_RototillerCantRaiseMultipleStats: BattleScript_RototillerCantRaiseMultipleStats:
copybyte gBattlerAttacker, gBattlerTarget
printstring STRINGID_STATSWONTINCREASE2 printstring STRINGID_STATSWONTINCREASE2
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_RototillerMoveTargetEnd goto BattleScript_RototillerMoveTargetEnd
BattleScript_RototillerNoEffect:
pause B_WAIT_TIME_SHORT
printstring STRINGID_NOEFFECTONTARGET
waitmessage B_WAIT_TIME_LONG
goto BattleScript_RototillerMoveTargetEnd
BattleScript_EffectBestow: BattleScript_EffectBestow:
attackcanceler attackcanceler
accuracycheck BattleScript_PrintMoveMissed, NO_ACC_CALC_CHECK_LOCK_ON accuracycheck BattleScript_PrintMoveMissed, NO_ACC_CALC_CHECK_LOCK_ON

View File

@ -169,6 +169,7 @@ struct SpecialStatus
u8 instructedChosenTarget:3; u8 instructedChosenTarget:3;
u8 berryReduced:1; u8 berryReduced:1;
u8 gemBoost:1; u8 gemBoost:1;
u8 rototillerAffected:1; // to be affected by rototiller
u8 gemParam; u8 gemParam;
u8 damagedMons:4; // Mons that have been damaged directly by using a move, includes substitute. u8 damagedMons:4; // Mons that have been damaged directly by using a move, includes substitute.
u8 dancerUsedMove:1; u8 dancerUsedMove:1;

View File

@ -174,6 +174,8 @@
#define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TOTEM_BOOST 103
#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104
#define VARIOUS_MOVEEND_ITEM_EFFECTS 105 #define VARIOUS_MOVEEND_ITEM_EFFECTS 105
#define VARIOUS_GET_ROTOTILLER_TARGETS 106
#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 107
// Cmd_manipulatedamage // Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0 #define DMG_CHANGE_SIGN 0

View File

@ -7246,6 +7246,21 @@ static u32 GetHighestStatId(u32 battlerId)
return highestId; 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) static void Cmd_various(void)
{ {
struct Pokemon *mon; struct Pokemon *mon;
@ -8498,6 +8513,36 @@ static void Cmd_various(void)
if (ItemBattleEffects(1, gActiveBattler, FALSE)) if (ItemBattleEffects(1, gActiveBattler, FALSE))
return; return;
break; 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; gBattlescriptCurrInstr += 3;