mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 04:04:17 +01:00
Updated Triple Arrows' effect's code and tests yet again
Also added a function to get a move's secondaryEffectChance, meant to handle abilities, side statuses and the like that modify it.
This commit is contained in:
parent
787c0a159a
commit
b09ab5a3ee
@ -1553,11 +1553,12 @@ BattleScript_DefDown_Ret:
|
|||||||
return
|
return
|
||||||
|
|
||||||
BattleScript_ReduceDefenseAndFlinch::
|
BattleScript_ReduceDefenseAndFlinch::
|
||||||
modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDown_Ret, ANIM_ON
|
modifybattlerstatstage BS_TARGET, STAT_DEF, DECREASE, 1, BattleScript_DefDownAndFlinch_Ret, ANIM_ON
|
||||||
jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_FlinchPrevention
|
jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_DefDownAndFlinch_Ret
|
||||||
setmoveeffect MOVE_EFFECT_FLINCH
|
setmoveeffect MOVE_EFFECT_FLINCH
|
||||||
seteffectprimary
|
seteffectprimary
|
||||||
goto BattleScript_MoveEnd
|
BattleScript_DefDownAndFlinch_Ret:
|
||||||
|
return
|
||||||
|
|
||||||
BattleScript_EffectPurify:
|
BattleScript_EffectPurify:
|
||||||
attackcanceler
|
attackcanceler
|
||||||
|
@ -234,5 +234,6 @@ u32 GetBattlerFriendshipScore(u8 battlerId);
|
|||||||
u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc);
|
u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc);
|
||||||
bool32 IsMyceliumMightOnField(void);
|
bool32 IsMyceliumMightOnField(void);
|
||||||
bool8 ChangeTypeBasedOnTerrain(u8 battlerId);
|
bool8 ChangeTypeBasedOnTerrain(u8 battlerId);
|
||||||
|
u32 GetMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance);
|
||||||
|
|
||||||
#endif // GUARD_BATTLE_UTIL_H
|
#endif // GUARD_BATTLE_UTIL_H
|
||||||
|
@ -3803,50 +3803,25 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
break;
|
break;
|
||||||
case MOVE_EFFECT_TRIPLE_ARROWS:
|
case MOVE_EFFECT_TRIPLE_ARROWS:
|
||||||
{
|
{
|
||||||
u8 randomLowerDefenseChance;
|
u8 randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, GetMoveSecondaryEffectChance(gBattlerAttacker, 50));
|
||||||
u8 randomFlinchChance;
|
u8 randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, GetMoveSecondaryEffectChance(gBattlerAttacker, 30));
|
||||||
|
|
||||||
if (GetBattlerAbility(gBattlerAttacker) == ABILITY_SERENE_GRACE)
|
|
||||||
{
|
|
||||||
randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, 100);
|
|
||||||
randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, 60);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
randomLowerDefenseChance = RandomPercentage(RNG_TRIPLE_ARROWS_DEFENSE_DOWN, 50);
|
|
||||||
randomFlinchChance = RandomPercentage(RNG_TRIPLE_ARROWS_FLINCH, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (randomLowerDefenseChance && randomFlinchChance)
|
if (randomLowerDefenseChance && randomFlinchChance)
|
||||||
{
|
{
|
||||||
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
||||||
gBattlescriptCurrInstr = BattleScript_ReduceDefenseAndFlinch;
|
gBattlescriptCurrInstr = BattleScript_ReduceDefenseAndFlinch;
|
||||||
}
|
}
|
||||||
else
|
else if (randomLowerDefenseChance)
|
||||||
{
|
|
||||||
if (randomLowerDefenseChance)
|
|
||||||
{
|
{
|
||||||
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
||||||
gBattlescriptCurrInstr = BattleScript_DefDown;
|
gBattlescriptCurrInstr = BattleScript_DefDown;
|
||||||
}
|
}
|
||||||
else if (randomFlinchChance)
|
else if (randomFlinchChance && battlerAbility != ABILITY_INNER_FOCUS && GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber)
|
||||||
{
|
{
|
||||||
if (battlerAbility == ABILITY_INNER_FOCUS)
|
|
||||||
{
|
|
||||||
gLastUsedAbility = ABILITY_INNER_FOCUS;
|
|
||||||
gBattlerAbility = gEffectBattler;
|
|
||||||
RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS);
|
|
||||||
gBattlescriptCurrInstr = BattleScript_FlinchPrevention;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber)
|
|
||||||
gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH];
|
gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[MOVE_EFFECT_FLINCH];
|
||||||
gBattlescriptCurrInstr++;
|
gBattlescriptCurrInstr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3859,12 +3834,7 @@ static void Cmd_seteffectwithchance(void)
|
|||||||
{
|
{
|
||||||
CMD_ARGS();
|
CMD_ARGS();
|
||||||
|
|
||||||
u32 percentChance;
|
u32 percentChance = GetMoveSecondaryEffectChance(gBattlerAttacker, gBattleMoves[gCurrentMove].secondaryEffectChance);
|
||||||
|
|
||||||
if (GetBattlerAbility(gBattlerAttacker) == ABILITY_SERENE_GRACE)
|
|
||||||
percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance * 2;
|
|
||||||
else
|
|
||||||
percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance;
|
|
||||||
|
|
||||||
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
|
||||||
&& gBattleScripting.moveEffect)
|
&& gBattleScripting.moveEffect)
|
||||||
|
@ -10859,3 +10859,11 @@ static void SetRandomMultiHitCounter()
|
|||||||
gMultiHitCounter = 5 - (Random() & 1);
|
gMultiHitCounter = 5 - (Random() & 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 GetMoveSecondaryEffectChance(u8 battlerId, u8 secondaryEffectChance)
|
||||||
|
{
|
||||||
|
if (GetBattlerAbility(battlerId) == ABILITY_SERENE_GRACE)
|
||||||
|
return (secondaryEffectChance * 2);
|
||||||
|
|
||||||
|
return secondaryEffectChance;
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@ ASSUMPTIONS
|
|||||||
ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].effect == EFFECT_TRIPLE_ARROWS);
|
ASSUME(gBattleMoves[MOVE_TRIPLE_ARROWS].effect == EFFECT_TRIPLE_ARROWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage")
|
SINGLE_BATTLE_TEST("Triple Arrows lowers Defense by one stage")
|
||||||
{
|
{
|
||||||
u32 ability;
|
u32 ability;
|
||||||
u32 chance;
|
u32 chance;
|
||||||
@ -25,7 +25,7 @@ SINGLE_BATTLE_TEST("Triple Arrows lower's defense by one stage")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SINGLE_BATTLE_TEST("Triple Arrows flinch 30% of the time")
|
SINGLE_BATTLE_TEST("Triple Arrows make the foe flinch 30% of the time")
|
||||||
{
|
{
|
||||||
u32 ability;
|
u32 ability;
|
||||||
u32 chance;
|
u32 chance;
|
||||||
@ -58,3 +58,34 @@ SINGLE_BATTLE_TEST("Triple Arrows lands a critical hit")
|
|||||||
MESSAGE("A critical hit!");
|
MESSAGE("A critical hit!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SINGLE_BATTLE_TEST("Triple Arrows can lower Defense and cause flinch at the time")
|
||||||
|
{
|
||||||
|
GIVEN {
|
||||||
|
PLAYER(SPECIES_WOBBUFFET);
|
||||||
|
OPPONENT(SPECIES_WOBBUFFET);
|
||||||
|
} WHEN {
|
||||||
|
TURN { MOVE(player, MOVE_TRIPLE_ARROWS); }
|
||||||
|
} SCENE {
|
||||||
|
ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player);
|
||||||
|
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent);
|
||||||
|
MESSAGE("Foe Wobbuffet's defense fell!");
|
||||||
|
MESSAGE("Foe Wobbuffet flinched!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SINGLE_BATTLE_TEST("Triple Arrows's flinching is prevented by Inner Focus")
|
||||||
|
{
|
||||||
|
GIVEN {
|
||||||
|
PLAYER(SPECIES_WOBBUFFET);
|
||||||
|
OPPONENT(SPECIES_RIOLU) { Ability(ABILITY_INNER_FOCUS); }
|
||||||
|
} WHEN {
|
||||||
|
TURN { MOVE(player, MOVE_TRIPLE_ARROWS);
|
||||||
|
MOVE(opponent, MOVE_TACKLE);
|
||||||
|
}
|
||||||
|
} SCENE {
|
||||||
|
ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_ARROWS, player);
|
||||||
|
NONE_OF { MESSAGE("Foe Wobbuffet flinched!"); }
|
||||||
|
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user