Merge pull request #2605 from mrgriffin/rhh-battle-tests-fixes

Rhh battle tests fixes
This commit is contained in:
Eduardo Quezada D'Ottone 2023-01-27 19:24:13 -03:00 committed by GitHub
commit 53e41a2b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 10 deletions

View File

@ -2237,3 +2237,8 @@
.endif
waitmessage B_WAIT_TIME_LONG
.endm
.macro jumpifemergencyexited battler:req, ptr:req
various \battler, VARIOUS_JUMP_IF_EMERGENCY_EXITED
.4byte \ptr
.endm

View File

@ -3055,6 +3055,7 @@ BattleScript_EffectHitEscape:
jumpifbyte CMP_NOT_EQUAL gBattleOutcome 0, BattleScript_HitEscapeEnd
jumpifbattletype BATTLE_TYPE_ARENA, BattleScript_HitEscapeEnd
jumpifcantswitch SWITCH_IGNORE_ESCAPE_PREVENTION | BS_ATTACKER, BattleScript_HitEscapeEnd
jumpifemergencyexited BS_TARGET, BattleScript_HitEscapeEnd
openpartyscreen BS_ATTACKER, BattleScript_HitEscapeEnd
switchoutabilities BS_ATTACKER
waitstate

View File

@ -195,6 +195,7 @@ struct SpecialStatus
// End of byte
u8 weatherAbilityDone:1;
u8 terrainAbilityDone:1;
u8 emergencyExited:1;
};
struct SideTimer

View File

@ -255,6 +255,7 @@
#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 164
#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 165
#define VARIOUS_JUMP_IF_NO_VALID_TARGETS 166
#define VARIOUS_JUMP_IF_EMERGENCY_EXITED 167
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -834,7 +834,7 @@ static bool8 DoesAbilityPreventStatus(struct Pokemon *mon, u32 status)
ret = TRUE;
break;
case STATUS1_TOXIC_POISON:
if (ability == ABILITY_IMMUNITY)
if (ability == ABILITY_IMMUNITY || ability == ABILITY_PASTEL_VEIL)
ret = TRUE;
break;
}

View File

@ -2880,11 +2880,11 @@ void SetMoveEffect(bool32 primary, u32 certain)
statusChanged = TRUE;
break;
case STATUS1_POISON:
if (battlerAbility == ABILITY_IMMUNITY
if ((battlerAbility == ABILITY_IMMUNITY || battlerAbility == ABILITY_PASTEL_VEIL)
&& (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
gLastUsedAbility = ABILITY_IMMUNITY;
RecordAbilityBattle(gEffectBattler, ABILITY_IMMUNITY);
gLastUsedAbility = battlerAbility;
RecordAbilityBattle(gEffectBattler, battlerAbility);
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_PSNPrevention;
@ -3004,10 +3004,11 @@ void SetMoveEffect(bool32 primary, u32 certain)
statusChanged = TRUE;
break;
case STATUS1_TOXIC_POISON:
if (battlerAbility == ABILITY_IMMUNITY && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
if ((battlerAbility == ABILITY_IMMUNITY || battlerAbility == ABILITY_PASTEL_VEIL)
&& (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
gLastUsedAbility = ABILITY_IMMUNITY;
RecordAbilityBattle(gEffectBattler, ABILITY_IMMUNITY);
gLastUsedAbility = battlerAbility;
RecordAbilityBattle(gEffectBattler, battlerAbility);
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_PSNPrevention;
@ -5922,6 +5923,7 @@ static void Cmd_moveend(void)
if (gBattleResources->flags->flags[i] & RESOURCE_FLAG_EMERGENCY_EXIT)
{
gBattleResources->flags->flags[i] &= ~RESOURCE_FLAG_EMERGENCY_EXIT;
gSpecialStatuses[i].emergencyExited = TRUE;
gBattlerTarget = gBattlerAbility = i;
BattleScriptPushCursor();
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER || GetBattlerSide(i) == B_SIDE_PLAYER)
@ -6764,6 +6766,7 @@ static void Cmd_switchineffects(void)
if (!(gBattleMons[gActiveBattler].status1 & STATUS1_ANY)
&& !IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL)
&& GetBattlerAbility(gActiveBattler) != ABILITY_IMMUNITY
&& !IsAbilityOnSide(gActiveBattler, ABILITY_PASTEL_VEIL)
&& !(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SAFEGUARD)
&& !(gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN))
{
@ -10269,6 +10272,12 @@ static void Cmd_various(void)
gBattlescriptCurrInstr += 7;
}
return;
case VARIOUS_JUMP_IF_EMERGENCY_EXITED:
if (gSpecialStatuses[gActiveBattler].emergencyExited)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
else
gBattlescriptCurrInstr += 7;
return;
} // End of switch (gBattlescriptCurrInstr[2])
gBattlescriptCurrInstr += 3;
@ -12113,7 +12122,9 @@ static void Cmd_trysetencore(void)
break;
}
if (gLastMoves[gBattlerTarget] == MOVE_STRUGGLE
if (gLastMoves[gBattlerTarget] == MOVE_NONE
|| gLastMoves[gBattlerTarget] == MOVE_UNAVAILABLE
|| gLastMoves[gBattlerTarget] == MOVE_STRUGGLE
|| gLastMoves[gBattlerTarget] == MOVE_ENCORE
|| gLastMoves[gBattlerTarget] == MOVE_MIRROR_MOVE
|| gLastMoves[gBattlerTarget] == MOVE_SHELL_TRAP)

View File

@ -515,9 +515,11 @@ void HandleAction_UseMove(void)
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
BattleArena_AddMindPoints(gBattlerAttacker);
// Record HP of each battler
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
gBattleStruct->hpBefore[i] = gBattleMons[i].hp;
gSpecialStatuses[i].emergencyExited = FALSE;
}
gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT;
}
@ -5623,7 +5625,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED
&& CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& CanBePoisoned(gBattlerTarget, gBattlerAttacker)
&& IsMoveMakingContact(move, gBattlerAttacker)
&& (Random() % 3) == 0)
{
@ -5954,6 +5956,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
switch (GetBattlerAbility(battler))
{
case ABILITY_IMMUNITY:
case ABILITY_PASTEL_VEIL:
if (gBattleMons[battler].status1 & (STATUS1_POISON | STATUS1_TOXIC_POISON | STATUS1_TOXIC_COUNTER))
{
StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn);