Fix Defog and Prevent Escape effects (#3668)

* Fix Defog and Prevent Escape effects

* pain split / mirror coat interaction

* remove unused various define

* use pain split effect

* remove test
This commit is contained in:
Alex 2023-12-10 00:26:03 +01:00 committed by GitHub
parent 57ce85207e
commit d5f3df6f08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 139 additions and 132 deletions

View file

@ -1466,6 +1466,12 @@
.4byte \failInstr
.endm
.macro trydefog clear:req, failInstr:req
callnative BS_TryDefog
.byte \clear
.4byte \failInstr
.endm
@ various command changed to more readable macros
.macro cancelmultiturnmoves battler:req
various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES
@ -1738,12 +1744,6 @@
various \battler, VARIOUS_UPDATE_ABILITY_POPUP
.endm
.macro defogclear battler:req, clear:req, failInstr:req
various \battler, VARIOUS_DEFOG
.byte \clear
.4byte \failInstr
.endm
.macro jumpiftargetally jumpInstr:req
various BS_ATTACKER, VARIOUS_JUMP_IF_TARGET_ALLY
.4byte \jumpInstr

View file

@ -1997,7 +1997,7 @@ BattleScript_EffectDefog:
jumpifsubstituteblocks BattleScript_DefogIfCanClearHazards
jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_EVASION, MIN_STAT_STAGE, BattleScript_DefogWorks
BattleScript_DefogIfCanClearHazards:
defogclear BS_ATTACKER, FALSE, BattleScript_FailedFromAtkString
trydefog FALSE, BattleScript_FailedFromAtkString
BattleScript_DefogWorks:
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
@ -2017,7 +2017,7 @@ BattleScript_DefogPrintString::
waitmessage B_WAIT_TIME_LONG
BattleScript_DefogTryHazards::
copybyte gEffectBattler, gBattlerAttacker
defogclear BS_ATTACKER, TRUE, NULL
trydefog TRUE, NULL
copybyte gBattlerAttacker, gEffectBattler
goto BattleScript_MoveEnd
BattleScript_DefogTryHazardsWithAnim:
@ -4690,8 +4690,11 @@ BattleScript_EffectThief::
goto BattleScript_EffectHit
BattleScript_EffectHitPreventEscape:
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
setmoveeffect MOVE_EFFECT_PREVENT_ESCAPE
goto BattleScript_EffectHit
seteffectprimary
goto BattleScript_HitFromAtkString
BattleScript_EffectMeanLook::
attackcanceler

View file

@ -145,108 +145,107 @@
#define VARIOUS_TRY_AUTOTOMIZE 53
#define VARIOUS_TRY_COPYCAT 54
#define VARIOUS_ABILITY_POPUP 55
#define VARIOUS_DEFOG 56
#define VARIOUS_JUMP_IF_TARGET_ALLY 57
#define VARIOUS_TRY_SYNCHRONOISE 58
#define VARIOUS_PSYCHO_SHIFT 59
#define VARIOUS_CURE_STATUS 60
#define VARIOUS_POWER_TRICK 61
#define VARIOUS_AFTER_YOU 62
#define VARIOUS_BESTOW 63
#define VARIOUS_ARGUMENT_TO_MOVE_EFFECT 64
#define VARIOUS_JUMP_IF_NOT_GROUNDED 65
#define VARIOUS_HANDLE_TRAINER_SLIDE_MSG 66
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF 67
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON 68
#define VARIOUS_SET_AURORA_VEIL 69
#define VARIOUS_TRY_THIRD_TYPE 70
#define VARIOUS_ACUPRESSURE 71
#define VARIOUS_SET_POWDER 72
#define VARIOUS_SPECTRAL_THIEF 73
#define VARIOUS_GRAVITY_ON_AIRBORNE_MONS 74
#define VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS 75
#define VARIOUS_JUMP_IF_ROAR_FAILS 76
#define VARIOUS_TRY_INSTRUCT 77
#define VARIOUS_JUMP_IF_NOT_BERRY 78
#define VARIOUS_TRACE_ABILITY 79
#define VARIOUS_UPDATE_NICK 80
#define VARIOUS_TRY_ILLUSION_OFF 81
#define VARIOUS_SET_SPRITEIGNORE0HP 82
#define VARIOUS_HANDLE_FORM_CHANGE 83
#define VARIOUS_GET_STAT_VALUE 84
#define VARIOUS_JUMP_IF_FULL_HP 85
#define VARIOUS_LOSE_TYPE 86
#define VARIOUS_TRY_ACTIVATE_SOULHEART 87
#define VARIOUS_TRY_ACTIVATE_RECEIVER 88
#define VARIOUS_TRY_ACTIVATE_BEAST_BOOST 89
#define VARIOUS_TRY_FRISK 90
#define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 91
#define VARIOUS_TRY_FAIRY_LOCK 92
#define VARIOUS_JUMP_IF_NO_ALLY 93
#define VARIOUS_POISON_TYPE_IMMUNITY 94
#define VARIOUS_JUMP_IF_NO_HOLD_EFFECT 95
#define VARIOUS_INFATUATE_WITH_BATTLER 96
#define VARIOUS_SET_LAST_USED_ITEM 97
#define VARIOUS_PARALYZE_TYPE_IMMUNITY 98
#define VARIOUS_JUMP_IF_ABSENT 99
#define VARIOUS_DESTROY_ABILITY_POPUP 100
#define VARIOUS_TOTEM_BOOST 101
#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 102
#define VARIOUS_MOVEEND_ITEM_EFFECTS 103
#define VARIOUS_TERRAIN_SEED 104
#define VARIOUS_MAKE_INVISIBLE 105
#define VARIOUS_ROOM_SERVICE 106
#define VARIOUS_EERIE_SPELL_PP_REDUCE 107
#define VARIOUS_JUMP_IF_TEAM_HEALTHY 108
#define VARIOUS_TRY_HEAL_QUARTER_HP 109
#define VARIOUS_REMOVE_TERRAIN 110
#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 111
#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 112
#define VARIOUS_GET_ROTOTILLER_TARGETS 113
#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 114
#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 115
#define VARIOUS_CONSUME_BERRY 116
#define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 117
#define VARIOUS_APPLY_PLASMA_FISTS 118
#define VARIOUS_JUMP_IF_SPECIES 119
#define VARIOUS_UPDATE_ABILITY_POPUP 120
#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 121
#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 122
#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 123
#define VARIOUS_PHOTON_GEYSER_CHECK 124
#define VARIOUS_SHELL_SIDE_ARM_CHECK 125
#define VARIOUS_TRY_NO_RETREAT 126
#define VARIOUS_TRY_TAR_SHOT 127
#define VARIOUS_CAN_TAR_SHOT_WORK 128
#define VARIOUS_CHECK_POLTERGEIST 129
#define VARIOUS_SET_OCTOLOCK 130
#define VARIOUS_CUT_1_3_HP_RAISE_STATS 131
#define VARIOUS_TRY_END_NEUTRALIZING_GAS 132
#define VARIOUS_JUMP_IF_UNDER_200 133
#define VARIOUS_SET_SKY_DROP 134
#define VARIOUS_CLEAR_SKY_DROP 135
#define VARIOUS_SKY_DROP_YAWN 136
#define VARIOUS_JUMP_IF_HOLD_EFFECT 137
#define VARIOUS_CURE_CERTAIN_STATUSES 138
#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 139
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 140
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 141
#define VARIOUS_SAVE_BATTLER_ITEM 142
#define VARIOUS_RESTORE_BATTLER_ITEM 143
#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 144
#define VARIOUS_SET_BEAK_BLAST 145
#define VARIOUS_SWAP_SIDE_STATUSES 146
#define VARIOUS_SWAP_STATS 147
#define VARIOUS_TEATIME_INVUL 148
#define VARIOUS_TEATIME_TARGETS 149
#define VARIOUS_TRY_WIND_RIDER_POWER 150
#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 151
#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 152
#define VARIOUS_STORE_HEALING_WISH 153
#define VARIOUS_HIT_SWITCH_TARGET_FAILED 154
#define VARIOUS_TRY_REVIVAL_BLESSING 155
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 156
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 157
#define VARIOUS_JUMP_IF_TARGET_ALLY 56
#define VARIOUS_TRY_SYNCHRONOISE 57
#define VARIOUS_PSYCHO_SHIFT 58
#define VARIOUS_CURE_STATUS 59
#define VARIOUS_POWER_TRICK 60
#define VARIOUS_AFTER_YOU 61
#define VARIOUS_BESTOW 62
#define VARIOUS_ARGUMENT_TO_MOVE_EFFECT 63
#define VARIOUS_JUMP_IF_NOT_GROUNDED 64
#define VARIOUS_HANDLE_TRAINER_SLIDE_MSG 65
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF 66
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON 67
#define VARIOUS_SET_AURORA_VEIL 68
#define VARIOUS_TRY_THIRD_TYPE 69
#define VARIOUS_ACUPRESSURE 70
#define VARIOUS_SET_POWDER 71
#define VARIOUS_SPECTRAL_THIEF 72
#define VARIOUS_GRAVITY_ON_AIRBORNE_MONS 73
#define VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS 74
#define VARIOUS_JUMP_IF_ROAR_FAILS 75
#define VARIOUS_TRY_INSTRUCT 76
#define VARIOUS_JUMP_IF_NOT_BERRY 77
#define VARIOUS_TRACE_ABILITY 78
#define VARIOUS_UPDATE_NICK 79
#define VARIOUS_TRY_ILLUSION_OFF 80
#define VARIOUS_SET_SPRITEIGNORE0HP 81
#define VARIOUS_HANDLE_FORM_CHANGE 82
#define VARIOUS_GET_STAT_VALUE 83
#define VARIOUS_JUMP_IF_FULL_HP 84
#define VARIOUS_LOSE_TYPE 85
#define VARIOUS_TRY_ACTIVATE_SOULHEART 86
#define VARIOUS_TRY_ACTIVATE_RECEIVER 87
#define VARIOUS_TRY_ACTIVATE_BEAST_BOOST 88
#define VARIOUS_TRY_FRISK 89
#define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 90
#define VARIOUS_TRY_FAIRY_LOCK 91
#define VARIOUS_JUMP_IF_NO_ALLY 92
#define VARIOUS_POISON_TYPE_IMMUNITY 93
#define VARIOUS_JUMP_IF_NO_HOLD_EFFECT 94
#define VARIOUS_INFATUATE_WITH_BATTLER 95
#define VARIOUS_SET_LAST_USED_ITEM 96
#define VARIOUS_PARALYZE_TYPE_IMMUNITY 97
#define VARIOUS_JUMP_IF_ABSENT 98
#define VARIOUS_DESTROY_ABILITY_POPUP 99
#define VARIOUS_TOTEM_BOOST 100
#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 101
#define VARIOUS_MOVEEND_ITEM_EFFECTS 102
#define VARIOUS_TERRAIN_SEED 103
#define VARIOUS_MAKE_INVISIBLE 104
#define VARIOUS_ROOM_SERVICE 105
#define VARIOUS_EERIE_SPELL_PP_REDUCE 106
#define VARIOUS_JUMP_IF_TEAM_HEALTHY 107
#define VARIOUS_TRY_HEAL_QUARTER_HP 108
#define VARIOUS_REMOVE_TERRAIN 109
#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 110
#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 111
#define VARIOUS_GET_ROTOTILLER_TARGETS 112
#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 113
#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 114
#define VARIOUS_CONSUME_BERRY 115
#define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 116
#define VARIOUS_APPLY_PLASMA_FISTS 117
#define VARIOUS_JUMP_IF_SPECIES 118
#define VARIOUS_UPDATE_ABILITY_POPUP 119
#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 120
#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 121
#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 122
#define VARIOUS_PHOTON_GEYSER_CHECK 123
#define VARIOUS_SHELL_SIDE_ARM_CHECK 124
#define VARIOUS_TRY_NO_RETREAT 125
#define VARIOUS_TRY_TAR_SHOT 126
#define VARIOUS_CAN_TAR_SHOT_WORK 127
#define VARIOUS_CHECK_POLTERGEIST 128
#define VARIOUS_SET_OCTOLOCK 129
#define VARIOUS_CUT_1_3_HP_RAISE_STATS 130
#define VARIOUS_TRY_END_NEUTRALIZING_GAS 131
#define VARIOUS_JUMP_IF_UNDER_200 132
#define VARIOUS_SET_SKY_DROP 133
#define VARIOUS_CLEAR_SKY_DROP 134
#define VARIOUS_SKY_DROP_YAWN 135
#define VARIOUS_JUMP_IF_HOLD_EFFECT 136
#define VARIOUS_CURE_CERTAIN_STATUSES 137
#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 138
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 139
#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 140
#define VARIOUS_SAVE_BATTLER_ITEM 141
#define VARIOUS_RESTORE_BATTLER_ITEM 142
#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 143
#define VARIOUS_SET_BEAK_BLAST 144
#define VARIOUS_SWAP_SIDE_STATUSES 145
#define VARIOUS_SWAP_STATS 146
#define VARIOUS_TEATIME_INVUL 147
#define VARIOUS_TEATIME_TARGETS 148
#define VARIOUS_TRY_WIND_RIDER_POWER 149
#define VARIOUS_ACTIVATE_WEATHER_CHANGE_ABILITIES 150
#define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 151
#define VARIOUS_STORE_HEALING_WISH 152
#define VARIOUS_HIT_SWITCH_TARGET_FAILED 153
#define VARIOUS_TRY_REVIVAL_BLESSING 154
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 155
#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 156
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View file

@ -2375,7 +2375,7 @@ static void Cmd_datahpupdate(void)
if (!gSpecialStatuses[battler].dmg && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE))
gSpecialStatuses[battler].dmg = gHpDealt;
if (IS_MOVE_PHYSICAL(gCurrentMove) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE) && gCurrentMove != MOVE_PAIN_SPLIT)
if (IS_MOVE_PHYSICAL(gCurrentMove) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE) && gBattleMoves[gCurrentMove].effect != EFFECT_PAIN_SPLIT)
{
gProtectStructs[battler].physicalDmg = gHpDealt;
gSpecialStatuses[battler].physicalDmg = gHpDealt;
@ -2390,7 +2390,7 @@ static void Cmd_datahpupdate(void)
gSpecialStatuses[battler].physicalBattlerId = gBattlerTarget;
}
}
else if (!IS_MOVE_PHYSICAL(gCurrentMove) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE))
else if (!IS_MOVE_PHYSICAL(gCurrentMove) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE) && gBattleMoves[gCurrentMove].effect != EFFECT_PAIN_SPLIT)
{
gProtectStructs[battler].specialDmg = gHpDealt;
gSpecialStatuses[battler].specialDmg = gHpDealt;
@ -8180,6 +8180,8 @@ static void RemoveAllTerrains(void)
static bool32 TryDefogClear(u32 battlerAtk, bool32 clear)
{
s32 i;
u8 saveBattler = gBattlerAttacker;
for (i = 0; i < 2; i++)
{
struct SideTimer *sideTimer = &gSideTimers[i];
@ -8209,6 +8211,8 @@ static bool32 TryDefogClear(u32 battlerAtk, bool32 clear)
#endif // B_DEFOG_CLEARS_TERRAIN
}
gBattlerAttacker = saveBattler;
return FALSE;
}
@ -9576,25 +9580,6 @@ static void Cmd_various(void)
UpdateAbilityPopup(battler);
break;
}
case VARIOUS_DEFOG:
{
VARIOUS_ARGS(bool8 clear, const u8 *failInstr);
if (cmd->clear) // Clear
{
if (TryDefogClear(gEffectBattler, TRUE))
return;
else
gBattlescriptCurrInstr = cmd->nextInstr;
}
else
{
if (TryDefogClear(battler, FALSE))
gBattlescriptCurrInstr = cmd->nextInstr;
else
gBattlescriptCurrInstr = cmd->failInstr;
}
return;
}
case VARIOUS_JUMP_IF_TARGET_ALLY:
{
VARIOUS_ARGS(const u8 *jumpInstr);
@ -16352,3 +16337,23 @@ void BS_TryHealPulse(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}
}
void BS_TryDefog(void)
{
NATIVE_ARGS(u8 clear, const u8 *failInstr);
if (cmd->clear)
{
if (TryDefogClear(gEffectBattler, TRUE))
return;
else
gBattlescriptCurrInstr = cmd->nextInstr;
}
else
{
if (TryDefogClear(gBattlerAttacker, FALSE))
gBattlescriptCurrInstr = cmd->nextInstr;
else
gBattlescriptCurrInstr = cmd->failInstr;
}
}