From 6e134bb7dc0b5650946318a28cbe72a2e5743e24 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 17 Feb 2023 12:52:43 -0300 Subject: [PATCH 01/17] Removed pointless IsBattlerHpLow function --- src/battle_message.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/battle_message.c b/src/battle_message.c index 2b8005f64..9c8a1b702 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3899,14 +3899,6 @@ static u32 GetEnemyMonCount(bool32 onlyAlive) return count; } -static bool32 IsBattlerHpLow(u32 battler) -{ - if ((gBattleMons[battler].hp * 100) / gBattleMons[battler].maxHP < 25) - return TRUE; - else - return FALSE; -} - bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which) { s32 i; @@ -3931,7 +3923,7 @@ bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which) case TRAINER_SLIDE_LAST_LOW_HP: if (sTrainerSlides[i].msgLastLowHp != NULL && GetEnemyMonCount(TRUE) == 1 - && IsBattlerHpLow(battlerId) + && gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / 4) && !gBattleStruct->trainerSlideLowHpMsgDone) { gBattleStruct->trainerSlideLowHpMsgDone = TRUE; From 3a91a5c930d8c06de95882b5ca0ce90d017cbbc9 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 17 Feb 2023 12:53:24 -0300 Subject: [PATCH 02/17] =?UTF-8?q?Added=20new=20trainer=20slide-in=20msg=20?= =?UTF-8?q?conditions=20Now=20they=20can=20say=20something:=20-When=20thei?= =?UTF-8?q?r=20last=20Pok=C3=A9mon's=20HP=20is=20between=2025%=20and=2050%?= =?UTF-8?q?.=20-When=20a=20critical=20hit=20is=20dealt=20to=20their=20firs?= =?UTF-8?q?t=20Pok=C3=A9mon=20for=20the=20first=20time.=20-When=20a=20supe?= =?UTF-8?q?r=20effective=20hit=20is=20dealt=20to=20their=20first=20Pok?= =?UTF-8?q?=C3=A9mon=20for=20the=20first=20time.=20-When=20a=20STAB=20move?= =?UTF-8?q?=20is=20used=20against=20(but=20doesn't=20faint)=20the=20oppone?= =?UTF-8?q?nt's=20Pok=C3=A9mon.=20-When=20the=20Player's=20Pok=C3=A9mon's?= =?UTF-8?q?=20move=20doesn't=20affect=20the=20opponent's=20Pok=C3=A9mon.?= =?UTF-8?q?=20-When=20they're=20about=20to=20trigger=20a=20Mega=20Evolutio?= =?UTF-8?q?n.=20-When=20they're=20about=20to=20trigger=20a=20Z-Move.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Misc. changes: -Split GetEnemyMonCount for readability's sake. -Optimized the size allocated to trainerSlideLowHpMsgDone. --- asm/macros/battle_script.inc | 8 + data/battle_scripts_1.s | 8 + include/battle.h | 9 +- include/battle_message.h | 7 + include/constants/battle_script_commands.h | 338 +++++++++++---------- src/battle_main.c | 10 + src/battle_message.c | 109 ++++++- src/battle_script_commands.c | 35 +++ src/battle_util.c | 10 + 9 files changed, 356 insertions(+), 178 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4f11fc78b..e24e20e6e 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2049,6 +2049,14 @@ .4byte \jumpInstr .endm + .macro trytrainerslidezmovemsg battler:req + various \battler, VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE + .endm + + .macro trytrainerslidemegaevolutionmsg battler:req + various \battler, VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ae92aba7c..c6c962638 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7763,6 +7763,8 @@ BattleScript_FocusPunchSetUp:: end2 BattleScript_MegaEvolution:: + printstring STRINGID_EMPTYSTRING3 + trytrainerslidemegaevolutionmsg BS_ATTACKER printstring STRINGID_MEGAEVOREACTING waitmessage B_WAIT_TIME_LONG setbyte gIsCriticalHit, 0 @@ -7777,6 +7779,8 @@ BattleScript_MegaEvolution:: end2 BattleScript_WishMegaEvolution:: + printstring STRINGID_EMPTYSTRING3 + trytrainerslidemegaevolutionmsg BS_ATTACKER printstring STRINGID_FERVENTWISHREACHED waitmessage B_WAIT_TIME_LONG setbyte gIsCriticalHit, 0 @@ -9989,6 +9993,8 @@ BattleScript_JabocaRowapBerryActivate_Dmg: @ z moves / effects BattleScript_ZMoveActivateDamaging:: + printstring STRINGID_EMPTYSTRING3 + trytrainerslidezmovemsg BS_ATTACKER printstring STRINGID_ZPOWERSURROUNDS playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL printstring STRINGID_ZMOVEUNLEASHED @@ -9996,6 +10002,8 @@ BattleScript_ZMoveActivateDamaging:: return BattleScript_ZMoveActivateStatus:: + printstring STRINGID_EMPTYSTRING3 + trytrainerslidezmovemsg BS_ATTACKER savetarget printstring STRINGID_ZPOWERSURROUNDS playanimation BS_ATTACKER, B_ANIM_ZMOVE_ACTIVATE, NULL diff --git a/include/battle.h b/include/battle.h index 8be922384..f4b10c813 100644 --- a/include/battle.h +++ b/include/battle.h @@ -620,7 +620,7 @@ struct BattleStruct struct MegaEvolutionData mega; struct ZMoveData zmove; const u8 *trainerSlideMsg; - bool8 trainerSlideLowHpMsgDone; + bool8 trainerSlideLowHpMsgDone:1; u8 introState; u8 ateBerry[2]; // array id determined by side, each party pokemon as bit u8 stolenStats[NUM_BATTLE_STATS]; // hp byte is used for which stats to raise, other inform about by how many stages @@ -655,6 +655,13 @@ struct BattleStruct u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) bool8 allowedToChangeFormInWeather[PARTY_SIZE][2]; // For each party member and side, used by Ice Face. u8 battleBondTransformed[NUM_BATTLE_SIDES]; // Bitfield for each party. + bool8 trainerSlideHalfHpMsgDone:1; + u8 trainerSlideFirstCriticalHitMsgState:2; + u8 trainerSlideFirstSuperEffectiveHitMsgState:2; + u8 trainerSlideFirstSTABMoveMsgState:2; + u8 trainerSlidePlayerMonUnaffectedMsgState:2; + bool8 trainerSlideMegaEvolutionMsgDone:1; + bool8 trainerSlideZMoveMsgDone:1; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_message.h b/include/battle_message.h index 9f6905abd..57c6c21c2 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -229,6 +229,13 @@ enum TRAINER_SLIDE_LAST_SWITCHIN, TRAINER_SLIDE_LAST_LOW_HP, TRAINER_SLIDE_FIRST_DOWN, + TRAINER_SLIDE_LAST_HALF_HP, + TRAINER_SLIDE_FIRST_CRITICAL_HIT, + TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT, + TRAINER_SLIDE_FIRST_STAB_MOVE, + TRAINER_SLIDE_PLAYER_MON_UNAFFECTED, + TRAINER_SLIDE_MEGA_EVOLUTION, + TRAINER_SLIDE_Z_MOVE, }; void BufferStringBattle(u16 stringID); diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 68e927d75..f55628315 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -89,174 +89,176 @@ #define CMP_NO_COMMON_BITS 5 // Cmd_various -#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 -#define VARIOUS_SET_MAGIC_COAT_TARGET 1 -#define VARIOUS_IS_RUNNING_IMPOSSIBLE 2 -#define VARIOUS_GET_MOVE_TARGET 3 -#define VARIOUS_GET_BATTLER_FAINTED 4 -#define VARIOUS_RESET_SWITCH_IN_ABILITY_BITS 5 -#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 -#define VARIOUS_RESET_PLAYER_FAINTED 7 -#define VARIOUS_PALACE_FLAVOR_TEXT 8 -#define VARIOUS_ARENA_JUDGMENT_WINDOW 9 -#define VARIOUS_ARENA_OPPONENT_MON_LOST 10 -#define VARIOUS_ARENA_PLAYER_MON_LOST 11 -#define VARIOUS_ARENA_BOTH_MONS_LOST 12 -#define VARIOUS_EMIT_YESNOBOX 13 -#define VARIOUS_DRAW_ARENA_REF_TEXT_BOX 14 -#define VARIOUS_ERASE_ARENA_REF_TEXT_BOX 15 -#define VARIOUS_ARENA_JUDGMENT_STRING 16 -#define VARIOUS_ARENA_WAIT_STRING 17 -#define VARIOUS_WAIT_CRY 18 -#define VARIOUS_RETURN_OPPONENT_MON1 19 -#define VARIOUS_RETURN_OPPONENT_MON2 20 -#define VARIOUS_VOLUME_DOWN 21 -#define VARIOUS_VOLUME_UP 22 -#define VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT 23 -#define VARIOUS_PALACE_TRY_ESCAPE_STATUS 24 -#define VARIOUS_SET_TELEPORT_OUTCOME 25 -#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 -#define VARIOUS_STAT_TEXT_BUFFER 27 -#define VARIOUS_SWITCHIN_ABILITIES 28 -#define VARIOUS_SAVE_TARGET 29 -#define VARIOUS_RESTORE_TARGET 30 -#define VARIOUS_INSTANT_HP_DROP 31 -#define VARIOUS_CLEAR_STATUS 32 -#define VARIOUS_RESTORE_PP 33 -#define VARIOUS_TRY_ACTIVATE_MOXIE 34 -#define VARIOUS_TRY_ACTIVATE_FELL_STINGER 35 -#define VARIOUS_PLAY_MOVE_ANIMATION 36 -#define VARIOUS_SET_LUCKY_CHANT 37 -#define VARIOUS_SUCKER_PUNCH_CHECK 38 -#define VARIOUS_SET_SIMPLE_BEAM 39 -#define VARIOUS_TRY_ENTRAINMENT 40 -#define VARIOUS_SET_LAST_USED_ABILITY 41 -#define VARIOUS_TRY_HEAL_PULSE 42 -#define VARIOUS_TRY_QUASH 43 -#define VARIOUS_INVERT_STAT_STAGES 44 -#define VARIOUS_SET_TERRAIN 45 -#define VARIOUS_TRY_ME_FIRST 46 -#define VARIOUS_JUMP_IF_BATTLE_END 47 -#define VARIOUS_TRY_ELECTRIFY 48 -#define VARIOUS_TRY_REFLECT_TYPE 49 -#define VARIOUS_TRY_SOAK 50 -#define VARIOUS_HANDLE_MEGA_EVO 51 -#define VARIOUS_TRY_LAST_RESORT 52 -#define VARIOUS_ARGUMENT_STATUS_EFFECT 53 -#define VARIOUS_TRY_HIT_SWITCH_TARGET 54 -#define VARIOUS_TRY_AUTOTOMIZE 55 -#define VARIOUS_TRY_COPYCAT 56 -#define VARIOUS_ABILITY_POPUP 57 -#define VARIOUS_DEFOG 58 -#define VARIOUS_JUMP_IF_TARGET_ALLY 59 -#define VARIOUS_TRY_SYNCHRONOISE 60 -#define VARIOUS_PSYCHO_SHIFT 61 -#define VARIOUS_CURE_STATUS 62 -#define VARIOUS_POWER_TRICK 63 -#define VARIOUS_AFTER_YOU 64 -#define VARIOUS_BESTOW 65 -#define VARIOUS_ARGUMENT_TO_MOVE_EFFECT 66 -#define VARIOUS_JUMP_IF_NOT_GROUNDED 67 -#define VARIOUS_HANDLE_TRAINER_SLIDE_MSG 68 -#define VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF 69 -#define VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON 70 -#define VARIOUS_SET_AURORA_VEIL 71 -#define VARIOUS_TRY_THIRD_TYPE 72 -#define VARIOUS_ACUPRESSURE 73 -#define VARIOUS_SET_POWDER 74 -#define VARIOUS_SPECTRAL_THIEF 75 -#define VARIOUS_GRAVITY_ON_AIRBORNE_MONS 76 -#define VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS 77 -#define VARIOUS_JUMP_IF_ROAR_FAILS 78 -#define VARIOUS_TRY_INSTRUCT 79 -#define VARIOUS_JUMP_IF_NOT_BERRY 80 -#define VARIOUS_TRACE_ABILITY 81 -#define VARIOUS_UPDATE_NICK 82 -#define VARIOUS_TRY_ILLUSION_OFF 83 -#define VARIOUS_SET_SPRITEIGNORE0HP 84 -#define VARIOUS_HANDLE_FORM_CHANGE 85 -#define VARIOUS_GET_STAT_VALUE 86 -#define VARIOUS_JUMP_IF_FULL_HP 87 -#define VARIOUS_LOSE_TYPE 88 -#define VARIOUS_TRY_ACTIVATE_SOULHEART 89 -#define VARIOUS_TRY_ACTIVATE_RECEIVER 90 -#define VARIOUS_TRY_ACTIVATE_BEAST_BOOST 91 -#define VARIOUS_TRY_FRISK 92 -#define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 93 -#define VARIOUS_TRY_FAIRY_LOCK 94 -#define VARIOUS_JUMP_IF_NO_ALLY 95 -#define VARIOUS_POISON_TYPE_IMMUNITY 96 -#define VARIOUS_JUMP_IF_NO_HOLD_EFFECT 97 -#define VARIOUS_INFATUATE_WITH_BATTLER 98 -#define VARIOUS_SET_LAST_USED_ITEM 99 -#define VARIOUS_PARALYZE_TYPE_IMMUNITY 100 -#define VARIOUS_JUMP_IF_ABSENT 101 -#define VARIOUS_DESTROY_ABILITY_POPUP 102 -#define VARIOUS_TOTEM_BOOST 103 -#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 -#define VARIOUS_MOVEEND_ITEM_EFFECTS 105 -#define VARIOUS_TERRAIN_SEED 106 -#define VARIOUS_MAKE_INVISIBLE 107 -#define VARIOUS_ROOM_SERVICE 108 -#define VARIOUS_JUMP_IF_TERRAIN_AFFECTED 109 -#define VARIOUS_EERIE_SPELL_PP_REDUCE 110 -#define VARIOUS_JUMP_IF_TEAM_HEALTHY 111 -#define VARIOUS_TRY_HEAL_QUARTER_HP 112 -#define VARIOUS_REMOVE_TERRAIN 113 -#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 -#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 -#define VARIOUS_GET_ROTOTILLER_TARGETS 116 -#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 117 -#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 118 -#define VARIOUS_CONSUME_BERRY 119 -#define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 120 -#define VARIOUS_HANDLE_PRIMAL_REVERSION 121 -#define VARIOUS_APPLY_PLASMA_FISTS 122 -#define VARIOUS_JUMP_IF_SPECIES 123 -#define VARIOUS_UPDATE_ABILITY_POPUP 124 -#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125 -#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126 -#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127 -#define VARIOUS_PHOTON_GEYSER_CHECK 128 -#define VARIOUS_SHELL_SIDE_ARM_CHECK 129 -#define VARIOUS_TRY_NO_RETREAT 130 -#define VARIOUS_TRY_TAR_SHOT 131 -#define VARIOUS_CAN_TAR_SHOT_WORK 132 -#define VARIOUS_CHECK_POLTERGEIST 133 -#define VARIOUS_SET_OCTOLOCK 134 -#define VARIOUS_CUT_1_3_HP_RAISE_STATS 135 -#define VARIOUS_TRY_END_NEUTRALIZING_GAS 136 -#define VARIOUS_JUMP_IF_UNDER_200 137 -#define VARIOUS_SET_SKY_DROP 138 -#define VARIOUS_CLEAR_SKY_DROP 139 -#define VARIOUS_SKY_DROP_YAWN 140 -#define VARIOUS_JUMP_IF_CANT_FLING 141 -#define VARIOUS_JUMP_IF_HOLD_EFFECT 142 -#define VARIOUS_CURE_CERTAIN_STATUSES 143 -#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 144 -#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 145 -#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 146 -#define VARIOUS_SAVE_BATTLER_ITEM 147 -#define VARIOUS_RESTORE_BATTLER_ITEM 148 -#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 149 -#define VARIOUS_SET_BEAK_BLAST 150 -#define VARIOUS_SWAP_SIDE_STATUSES 151 -#define VARIOUS_SET_Z_EFFECT 152 -#define VARIOUS_TRY_SYMBIOSIS 153 -#define VARIOUS_CAN_TELEPORT 154 -#define VARIOUS_GET_BATTLER_SIDE 155 -#define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 156 -#define VARIOUS_SWAP_STATS 157 -#define VARIOUS_JUMP_IF_ROD 158 -#define VARIOUS_JUMP_IF_ABSORB 159 -#define VARIOUS_JUMP_IF_MOTOR 160 -#define VARIOUS_TEATIME_INVUL 161 -#define VARIOUS_TEATIME_TARGETS 162 -#define VARIOUS_TRY_WIND_RIDER_POWER 163 -#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 +#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 +#define VARIOUS_SET_MAGIC_COAT_TARGET 1 +#define VARIOUS_IS_RUNNING_IMPOSSIBLE 2 +#define VARIOUS_GET_MOVE_TARGET 3 +#define VARIOUS_GET_BATTLER_FAINTED 4 +#define VARIOUS_RESET_SWITCH_IN_ABILITY_BITS 5 +#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 +#define VARIOUS_RESET_PLAYER_FAINTED 7 +#define VARIOUS_PALACE_FLAVOR_TEXT 8 +#define VARIOUS_ARENA_JUDGMENT_WINDOW 9 +#define VARIOUS_ARENA_OPPONENT_MON_LOST 10 +#define VARIOUS_ARENA_PLAYER_MON_LOST 11 +#define VARIOUS_ARENA_BOTH_MONS_LOST 12 +#define VARIOUS_EMIT_YESNOBOX 13 +#define VARIOUS_DRAW_ARENA_REF_TEXT_BOX 14 +#define VARIOUS_ERASE_ARENA_REF_TEXT_BOX 15 +#define VARIOUS_ARENA_JUDGMENT_STRING 16 +#define VARIOUS_ARENA_WAIT_STRING 17 +#define VARIOUS_WAIT_CRY 18 +#define VARIOUS_RETURN_OPPONENT_MON1 19 +#define VARIOUS_RETURN_OPPONENT_MON2 20 +#define VARIOUS_VOLUME_DOWN 21 +#define VARIOUS_VOLUME_UP 22 +#define VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT 23 +#define VARIOUS_PALACE_TRY_ESCAPE_STATUS 24 +#define VARIOUS_SET_TELEPORT_OUTCOME 25 +#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 +#define VARIOUS_STAT_TEXT_BUFFER 27 +#define VARIOUS_SWITCHIN_ABILITIES 28 +#define VARIOUS_SAVE_TARGET 29 +#define VARIOUS_RESTORE_TARGET 30 +#define VARIOUS_INSTANT_HP_DROP 31 +#define VARIOUS_CLEAR_STATUS 32 +#define VARIOUS_RESTORE_PP 33 +#define VARIOUS_TRY_ACTIVATE_MOXIE 34 +#define VARIOUS_TRY_ACTIVATE_FELL_STINGER 35 +#define VARIOUS_PLAY_MOVE_ANIMATION 36 +#define VARIOUS_SET_LUCKY_CHANT 37 +#define VARIOUS_SUCKER_PUNCH_CHECK 38 +#define VARIOUS_SET_SIMPLE_BEAM 39 +#define VARIOUS_TRY_ENTRAINMENT 40 +#define VARIOUS_SET_LAST_USED_ABILITY 41 +#define VARIOUS_TRY_HEAL_PULSE 42 +#define VARIOUS_TRY_QUASH 43 +#define VARIOUS_INVERT_STAT_STAGES 44 +#define VARIOUS_SET_TERRAIN 45 +#define VARIOUS_TRY_ME_FIRST 46 +#define VARIOUS_JUMP_IF_BATTLE_END 47 +#define VARIOUS_TRY_ELECTRIFY 48 +#define VARIOUS_TRY_REFLECT_TYPE 49 +#define VARIOUS_TRY_SOAK 50 +#define VARIOUS_HANDLE_MEGA_EVO 51 +#define VARIOUS_TRY_LAST_RESORT 52 +#define VARIOUS_ARGUMENT_STATUS_EFFECT 53 +#define VARIOUS_TRY_HIT_SWITCH_TARGET 54 +#define VARIOUS_TRY_AUTOTOMIZE 55 +#define VARIOUS_TRY_COPYCAT 56 +#define VARIOUS_ABILITY_POPUP 57 +#define VARIOUS_DEFOG 58 +#define VARIOUS_JUMP_IF_TARGET_ALLY 59 +#define VARIOUS_TRY_SYNCHRONOISE 60 +#define VARIOUS_PSYCHO_SHIFT 61 +#define VARIOUS_CURE_STATUS 62 +#define VARIOUS_POWER_TRICK 63 +#define VARIOUS_AFTER_YOU 64 +#define VARIOUS_BESTOW 65 +#define VARIOUS_ARGUMENT_TO_MOVE_EFFECT 66 +#define VARIOUS_JUMP_IF_NOT_GROUNDED 67 +#define VARIOUS_HANDLE_TRAINER_SLIDE_MSG 68 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_FIRST_OFF 69 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_LAST_ON 70 +#define VARIOUS_SET_AURORA_VEIL 71 +#define VARIOUS_TRY_THIRD_TYPE 72 +#define VARIOUS_ACUPRESSURE 73 +#define VARIOUS_SET_POWDER 74 +#define VARIOUS_SPECTRAL_THIEF 75 +#define VARIOUS_GRAVITY_ON_AIRBORNE_MONS 76 +#define VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS 77 +#define VARIOUS_JUMP_IF_ROAR_FAILS 78 +#define VARIOUS_TRY_INSTRUCT 79 +#define VARIOUS_JUMP_IF_NOT_BERRY 80 +#define VARIOUS_TRACE_ABILITY 81 +#define VARIOUS_UPDATE_NICK 82 +#define VARIOUS_TRY_ILLUSION_OFF 83 +#define VARIOUS_SET_SPRITEIGNORE0HP 84 +#define VARIOUS_HANDLE_FORM_CHANGE 85 +#define VARIOUS_GET_STAT_VALUE 86 +#define VARIOUS_JUMP_IF_FULL_HP 87 +#define VARIOUS_LOSE_TYPE 88 +#define VARIOUS_TRY_ACTIVATE_SOULHEART 89 +#define VARIOUS_TRY_ACTIVATE_RECEIVER 90 +#define VARIOUS_TRY_ACTIVATE_BEAST_BOOST 91 +#define VARIOUS_TRY_FRISK 92 +#define VARIOUS_JUMP_IF_SHIELDS_DOWN_PROTECTED 93 +#define VARIOUS_TRY_FAIRY_LOCK 94 +#define VARIOUS_JUMP_IF_NO_ALLY 95 +#define VARIOUS_POISON_TYPE_IMMUNITY 96 +#define VARIOUS_JUMP_IF_NO_HOLD_EFFECT 97 +#define VARIOUS_INFATUATE_WITH_BATTLER 98 +#define VARIOUS_SET_LAST_USED_ITEM 99 +#define VARIOUS_PARALYZE_TYPE_IMMUNITY 100 +#define VARIOUS_JUMP_IF_ABSENT 101 +#define VARIOUS_DESTROY_ABILITY_POPUP 102 +#define VARIOUS_TOTEM_BOOST 103 +#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 +#define VARIOUS_MOVEEND_ITEM_EFFECTS 105 +#define VARIOUS_TERRAIN_SEED 106 +#define VARIOUS_MAKE_INVISIBLE 107 +#define VARIOUS_ROOM_SERVICE 108 +#define VARIOUS_JUMP_IF_TERRAIN_AFFECTED 109 +#define VARIOUS_EERIE_SPELL_PP_REDUCE 110 +#define VARIOUS_JUMP_IF_TEAM_HEALTHY 111 +#define VARIOUS_TRY_HEAL_QUARTER_HP 112 +#define VARIOUS_REMOVE_TERRAIN 113 +#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 +#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 +#define VARIOUS_GET_ROTOTILLER_TARGETS 116 +#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 117 +#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 118 +#define VARIOUS_CONSUME_BERRY 119 +#define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 120 +#define VARIOUS_HANDLE_PRIMAL_REVERSION 121 +#define VARIOUS_APPLY_PLASMA_FISTS 122 +#define VARIOUS_JUMP_IF_SPECIES 123 +#define VARIOUS_UPDATE_ABILITY_POPUP 124 +#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125 +#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126 +#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127 +#define VARIOUS_PHOTON_GEYSER_CHECK 128 +#define VARIOUS_SHELL_SIDE_ARM_CHECK 129 +#define VARIOUS_TRY_NO_RETREAT 130 +#define VARIOUS_TRY_TAR_SHOT 131 +#define VARIOUS_CAN_TAR_SHOT_WORK 132 +#define VARIOUS_CHECK_POLTERGEIST 133 +#define VARIOUS_SET_OCTOLOCK 134 +#define VARIOUS_CUT_1_3_HP_RAISE_STATS 135 +#define VARIOUS_TRY_END_NEUTRALIZING_GAS 136 +#define VARIOUS_JUMP_IF_UNDER_200 137 +#define VARIOUS_SET_SKY_DROP 138 +#define VARIOUS_CLEAR_SKY_DROP 139 +#define VARIOUS_SKY_DROP_YAWN 140 +#define VARIOUS_JUMP_IF_CANT_FLING 141 +#define VARIOUS_JUMP_IF_HOLD_EFFECT 142 +#define VARIOUS_CURE_CERTAIN_STATUSES 143 +#define VARIOUS_TRY_RESET_NEGATIVE_STAT_STAGES 144 +#define VARIOUS_JUMP_IF_LAST_USED_ITEM_BERRY 145 +#define VARIOUS_JUMP_IF_LAST_USED_ITEM_HOLD_EFFECT 146 +#define VARIOUS_SAVE_BATTLER_ITEM 147 +#define VARIOUS_RESTORE_BATTLER_ITEM 148 +#define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 149 +#define VARIOUS_SET_BEAK_BLAST 150 +#define VARIOUS_SWAP_SIDE_STATUSES 151 +#define VARIOUS_SET_Z_EFFECT 152 +#define VARIOUS_TRY_SYMBIOSIS 153 +#define VARIOUS_CAN_TELEPORT 154 +#define VARIOUS_GET_BATTLER_SIDE 155 +#define VARIOUS_CHECK_PARENTAL_BOND_COUNTER 156 +#define VARIOUS_SWAP_STATS 157 +#define VARIOUS_JUMP_IF_ROD 158 +#define VARIOUS_JUMP_IF_ABSORB 159 +#define VARIOUS_JUMP_IF_MOTOR 160 +#define VARIOUS_TEATIME_INVUL 161 +#define VARIOUS_TEATIME_TARGETS 162 +#define VARIOUS_TRY_WIND_RIDER_POWER 163 +#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 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE 168 +#define VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION 169 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_main.c b/src/battle_main.c index b23d8af55..5ec0937f0 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3868,6 +3868,16 @@ void BattleTurnPassed(void) BattleScriptExecute(BattleScript_ArenaTurnBeginning); else if (ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), gTrainerBattleOpponent_A, TRAINER_SLIDE_LAST_LOW_HP)) BattleScriptExecute(BattleScript_TrainerSlideMsgEnd2); + else if (ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), gTrainerBattleOpponent_A, TRAINER_SLIDE_LAST_HALF_HP)) + BattleScriptExecute(BattleScript_TrainerSlideMsgEnd2); + else if (ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), gTrainerBattleOpponent_A, TRAINER_SLIDE_FIRST_CRITICAL_HIT)) + BattleScriptExecute(BattleScript_TrainerSlideMsgEnd2); + else if (ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), gTrainerBattleOpponent_A, TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT)) + BattleScriptExecute(BattleScript_TrainerSlideMsgEnd2); + else if (ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), gTrainerBattleOpponent_A, TRAINER_SLIDE_FIRST_STAB_MOVE)) + BattleScriptExecute(BattleScript_TrainerSlideMsgEnd2); + else if (ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), gTrainerBattleOpponent_A, TRAINER_SLIDE_PLAYER_MON_UNAFFECTED)) + BattleScriptExecute(BattleScript_TrainerSlideMsgEnd2); } u8 IsRunningFromBattleImpossible(void) diff --git a/src/battle_message.c b/src/battle_message.c index 9c8a1b702..6a301d9ee 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3868,6 +3868,13 @@ struct TrainerSlide const u8 *msgLastSwitchIn; const u8 *msgLastLowHp; const u8 *msgFirstDown; + const u8 *msgLastHalfHp; + const u8 *msgFirstCriticalHit; + const u8 *msgFirstSuperEffectiveHit; + const u8 *msgFirstSTABMove; + const u8 *msgPlayerMonUnaffected; + const u8 *msgMegaEvolution; + const u8 *msgZMove; }; static const struct TrainerSlide sTrainerSlides[] = @@ -3879,20 +3886,39 @@ static const struct TrainerSlide sTrainerSlides[] = .msgLastSwitchIn = sText_AarghAlmostHadIt, .msgLastLowHp = sText_BoxIsFull, .msgFirstDown = sText_123Poof, + .msgLastHalfHp = sText_ShootSoClose, + .msgFirstCriticalHit = sText_CriticalHit, + .msgFirstSuperEffectiveHit = sText_SuperEffective, + .msgFirstSTABMove = sText_ABoosted, + .msgPlayerMonUnaffected = sText_ButNoEffect, + .msgMegaEvolution = sText_PowderExplodes, + .msgZMove = sText_Electromagnetism, }, */ }; -static u32 GetEnemyMonCount(bool32 onlyAlive) +static u32 GetAliveEnemyMonCount(void) { u32 i, count = 0; for (i = 0; i < PARTY_SIZE; i++) { u32 species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2, NULL); - if (species != SPECIES_NONE - && species != SPECIES_EGG - && (!onlyAlive || GetMonData(&gEnemyParty[i], MON_DATA_HP, NULL))) + if (species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&gEnemyParty[i], MON_DATA_HP, NULL)) + count++; + } + + return count; +} + +static u32 GetTotalEnemyMonCount(void) +{ + u32 i, count = 0; + + for (i = 0; i < PARTY_SIZE; i++) + { + u32 species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2, NULL); + if (species != SPECIES_NONE && species != SPECIES_EGG) count++; } @@ -3914,7 +3940,7 @@ bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which) switch (which) { case TRAINER_SLIDE_LAST_SWITCHIN: - if (sTrainerSlides[i].msgLastSwitchIn != NULL && GetEnemyMonCount(TRUE) == 1) + if (sTrainerSlides[i].msgLastSwitchIn != NULL && GetAliveEnemyMonCount() == 1) { gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastSwitchIn; return TRUE; @@ -3922,9 +3948,9 @@ bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which) break; case TRAINER_SLIDE_LAST_LOW_HP: if (sTrainerSlides[i].msgLastLowHp != NULL - && GetEnemyMonCount(TRUE) == 1 - && gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / 4) - && !gBattleStruct->trainerSlideLowHpMsgDone) + && GetAliveEnemyMonCount() == 1 + && gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / 4) + && !gBattleStruct->trainerSlideLowHpMsgDone) { gBattleStruct->trainerSlideLowHpMsgDone = TRUE; gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastLowHp; @@ -3932,12 +3958,77 @@ bool32 ShouldDoTrainerSlide(u32 battlerId, u32 trainerId, u32 which) } break; case TRAINER_SLIDE_FIRST_DOWN: - if (sTrainerSlides[i].msgFirstDown != NULL && GetEnemyMonCount(TRUE) == GetEnemyMonCount(FALSE) - 1) + if (sTrainerSlides[i].msgFirstDown != NULL && GetAliveEnemyMonCount() == GetTotalEnemyMonCount() - 1) { gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstDown; return TRUE; } break; + case TRAINER_SLIDE_LAST_HALF_HP: + if (sTrainerSlides[i].msgLastHalfHp != NULL + && GetAliveEnemyMonCount() == 1 + && (gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / 2) && gBattleMons[battlerId].hp > (gBattleMons[battlerId].maxHP / 4)) + && !gBattleStruct->trainerSlideHalfHpMsgDone) + { + gBattleStruct->trainerSlideHalfHpMsgDone = TRUE; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgLastHalfHp; + return TRUE; + } + break; + case TRAINER_SLIDE_FIRST_CRITICAL_HIT: + if (sTrainerSlides[i].msgFirstCriticalHit != NULL && gBattleStruct->trainerSlideFirstCriticalHitMsgState == 1) + { + gBattleStruct->trainerSlideFirstCriticalHitMsgState = 2; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstCriticalHit; + return TRUE; + } + break; + case TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT: + if (sTrainerSlides[i].msgFirstSuperEffectiveHit != NULL + && gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState == 1 + && gBattleMons[battlerId].hp) + { + gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState = 2; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstSuperEffectiveHit; + return TRUE; + } + break; + case TRAINER_SLIDE_FIRST_STAB_MOVE: + if (sTrainerSlides[i].msgFirstSTABMove != NULL + && gBattleStruct->trainerSlideFirstSTABMoveMsgState == 1 + && GetAliveEnemyMonCount() == GetTotalEnemyMonCount()) + { + gBattleStruct->trainerSlideFirstSTABMoveMsgState = 2; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgFirstSTABMove; + return TRUE; + } + break; + case TRAINER_SLIDE_PLAYER_MON_UNAFFECTED: + if (sTrainerSlides[i].msgPlayerMonUnaffected != NULL + && gBattleStruct->trainerSlidePlayerMonUnaffectedMsgState == 1 + && GetAliveEnemyMonCount() == GetTotalEnemyMonCount()) + { + gBattleStruct->trainerSlidePlayerMonUnaffectedMsgState = 2; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgPlayerMonUnaffected; + return TRUE; + } + break; + case TRAINER_SLIDE_MEGA_EVOLUTION: + if (sTrainerSlides[i].msgMegaEvolution != NULL && !gBattleStruct->trainerSlideMegaEvolutionMsgDone) + { + gBattleStruct->trainerSlideMegaEvolutionMsgDone = TRUE; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgMegaEvolution; + return TRUE; + } + break; + case TRAINER_SLIDE_Z_MOVE: + if (sTrainerSlides[i].msgZMove != NULL && !gBattleStruct->trainerSlideZMoveMsgDone) + { + gBattleStruct->trainerSlideZMoveMsgDone = TRUE; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgZMove; + return TRUE; + } + break; } break; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 87feb5627..683a979bd 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2540,6 +2540,11 @@ static void Cmd_critmessage(void) if (gIsCriticalHit == TRUE && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { PrepareStringBattle(STRINGID_CRITICALHIT, gBattlerAttacker); + + // Signal for the trainer slide-in system. + if (GetBattlerSide(gBattlerTarget) != B_SIDE_PLAYER && gBattleStruct->trainerSlideFirstCriticalHitMsgState != 2) + gBattleStruct->trainerSlideFirstCriticalHitMsgState = 1; + gBattleCommunication[MSG_DISPLAY] = 1; } gBattlescriptCurrInstr = cmd->nextInstr; @@ -2619,7 +2624,13 @@ static void Cmd_resultmessage(void) { case MOVE_RESULT_SUPER_EFFECTIVE: if (!gMultiHitCounter) // Don't print effectiveness on each hit in a multi hit attack + { + // Signal for the trainer slide-in system. + if (GetBattlerSide(gBattlerTarget) != B_SIDE_PLAYER && gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState != 2) + gBattleStruct->trainerSlideFirstSuperEffectiveHitMsgState = 1; + stringId = STRINGID_SUPEREFFECTIVE; + } break; case MOVE_RESULT_NOT_VERY_EFFECTIVE: if (!gMultiHitCounter) @@ -11040,6 +11051,30 @@ static void Cmd_various(void) gBattlescriptCurrInstr = cmd->nextInstr; return; } + case VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE: + { + VARIOUS_ARGS(); + if (ShouldDoTrainerSlide(gActiveBattler, gTrainerBattleOpponent_A, TRAINER_SLIDE_Z_MOVE)) + { + gBattleScripting.battler = gActiveBattler; + BattleScriptPush(cmd->nextInstr); + gBattlescriptCurrInstr = BattleScript_TrainerSlideMsgRet; + return; + } + break; + } + case VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION: + { + VARIOUS_ARGS(); + if (ShouldDoTrainerSlide(gActiveBattler, gTrainerBattleOpponent_A, TRAINER_SLIDE_MEGA_EVOLUTION)) + { + gBattleScripting.battler = gActiveBattler; + BattleScriptPush(cmd->nextInstr); + gBattlescriptCurrInstr = BattleScript_TrainerSlideMsgRet; + return; + } + break; + } } // End of switch (cmd->id) gBattlescriptCurrInstr = cmd->nextInstr; diff --git a/src/battle_util.c b/src/battle_util.c index 46f8d3a3d..18ac8fa54 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1607,6 +1607,12 @@ void PrepareStringBattle(u16 stringId, u8 battler) } #endif + // Signal for the trainer slide-in system. + if ((stringId == STRINGID_ITDOESNTAFFECT || stringId == STRINGID_PKMNWASNTAFFECTED || stringId == STRINGID_PKMNUNAFFECTED) + && GetBattlerSide(gBattlerTarget) == B_SIDE_OPPONENT + && gBattleStruct->trainerSlidePlayerMonUnaffectedMsgState != 2) + gBattleStruct->trainerSlidePlayerMonUnaffectedMsgState = 1; + gActiveBattler = battler; BtlController_EmitPrintString(BUFFER_A, stringId); MarkBattlerForControllerExec(gActiveBattler); @@ -9884,6 +9890,10 @@ static u16 CalcTypeEffectivenessMultiplierInternal(u16 move, u8 moveType, u8 bat } } + // Signal for the trainer slide-in system. + if (GetBattlerSide(battlerDef) != B_SIDE_PLAYER && modifier && gBattleStruct->trainerSlideFirstSTABMoveMsgState != 2) + gBattleStruct->trainerSlideFirstSTABMoveMsgState = 1; + return modifier; } From 8a036e6007cdc8152a89b3ef211cb51fb759091e Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 27 Feb 2023 07:45:01 -0300 Subject: [PATCH 03/17] Made this build again --- src/battle_main.c | 10 +++++----- src/battle_message.c | 2 +- src/battle_script_commands.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 0f841a89b..d144590d5 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3868,15 +3868,15 @@ void BattleTurnPassed(void) BattleScriptExecute(BattleScript_ArenaTurnBeginning); else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_LAST_LOW_HP))) BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); - else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_LAST_HALF_HP)) + else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_LAST_HALF_HP))) BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); - else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_FIRST_CRITICAL_HIT)) + else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_FIRST_CRITICAL_HIT))) BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); - else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT)) + else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_FIRST_SUPER_EFFECTIVE_HIT))) BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); - else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_FIRST_STAB_MOVE)) + else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_FIRST_STAB_MOVE))) BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); - else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_PLAYER_MON_UNAFFECTED)) + else if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_PLAYER_MON_UNAFFECTED))) BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); } diff --git a/src/battle_message.c b/src/battle_message.c index a9536d5a1..f321da46c 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3964,7 +3964,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which) case TRAINER_SLIDE_LAST_LOW_HP: if (sTrainerSlides[i].msgLastLowHp != NULL && GetEnemyMonCount(firstId, lastId, TRUE) == 1 - && IsBattlerHpLow(battlerId) + && gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / 4) && !gBattleStruct->trainerSlideLowHpMsgDone) { gBattleStruct->trainerSlideLowHpMsgDone = TRUE; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e50aed242..21e1d4d9c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11170,11 +11170,11 @@ static void Cmd_various(void) case VARIOUS_TRY_TRAINER_SLIDE_MSG_Z_MOVE: { VARIOUS_ARGS(); - if (ShouldDoTrainerSlide(gActiveBattler, gTrainerBattleOpponent_A, TRAINER_SLIDE_Z_MOVE)) + if ((i = ShouldDoTrainerSlide(gActiveBattler, TRAINER_SLIDE_Z_MOVE))) { gBattleScripting.battler = gActiveBattler; BattleScriptPush(cmd->nextInstr); - gBattlescriptCurrInstr = BattleScript_TrainerSlideMsgRet; + gBattlescriptCurrInstr = (i == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet); return; } break; @@ -11182,11 +11182,11 @@ static void Cmd_various(void) case VARIOUS_TRY_TRAINER_SLIDE_MSG_MEGA_EVOLUTION: { VARIOUS_ARGS(); - if (ShouldDoTrainerSlide(gActiveBattler, gTrainerBattleOpponent_A, TRAINER_SLIDE_MEGA_EVOLUTION)) + if ((i = ShouldDoTrainerSlide(gActiveBattler, TRAINER_SLIDE_MEGA_EVOLUTION))) { gBattleScripting.battler = gActiveBattler; BattleScriptPush(cmd->nextInstr); - gBattlescriptCurrInstr = BattleScript_TrainerSlideMsgRet; + gBattlescriptCurrInstr = (i == 1 ? BattleScript_TrainerASlideMsgRet : BattleScript_TrainerBSlideMsgRet); return; } break; From ff15856820bd30e9820e8fb5a46b093e39f47a0d Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 2 Mar 2023 06:14:42 -0300 Subject: [PATCH 04/17] Added yet another trainer slide condition Now a trainer NPC can also say something before the first turn of a battle starts for good. --- include/battle.h | 1 + include/battle_message.h | 1 + src/battle_main.c | 3 +++ src/battle_message.c | 10 ++++++++++ 4 files changed, 15 insertions(+) diff --git a/include/battle.h b/include/battle.h index 3c2b6ed19..f3b788037 100644 --- a/include/battle.h +++ b/include/battle.h @@ -669,6 +669,7 @@ struct BattleStruct u8 trainerSlidePlayerMonUnaffectedMsgState:2; bool8 trainerSlideMegaEvolutionMsgDone:1; bool8 trainerSlideZMoveMsgDone:1; + bool8 trainerSlideBeforeFirstTurnMsgDone:1; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_message.h b/include/battle_message.h index de60d6d02..93bb63022 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -236,6 +236,7 @@ enum TRAINER_SLIDE_PLAYER_MON_UNAFFECTED, TRAINER_SLIDE_MEGA_EVOLUTION, TRAINER_SLIDE_Z_MOVE, + TRAINER_SLIDE_BEFORE_FIRST_TURN, }; void BufferStringBattle(u16 stringID); diff --git a/src/battle_main.c b/src/battle_main.c index d144590d5..a93bef7ac 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3776,6 +3776,9 @@ static void TryDoEventsBeforeFirstTurn(void) StopCryAndClearCrySongs(); BattleScriptExecute(BattleScript_ArenaTurnBeginning); } + + if ((i = ShouldDoTrainerSlide(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), TRAINER_SLIDE_BEFORE_FIRST_TURN))) + BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2); } static void HandleEndTurn_ContinueBattle(void) diff --git a/src/battle_message.c b/src/battle_message.c index f321da46c..ed430e9f8 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3881,6 +3881,7 @@ struct TrainerSlide const u8 *msgPlayerMonUnaffected; const u8 *msgMegaEvolution; const u8 *msgZMove; + const u8 *msgBeforeFirstTurn; }; static const struct TrainerSlide sTrainerSlides[] = @@ -3899,6 +3900,7 @@ static const struct TrainerSlide sTrainerSlides[] = .msgPlayerMonUnaffected = sText_ButNoEffect, .msgMegaEvolution = sText_PowderExplodes, .msgZMove = sText_Electromagnetism, + .msgBeforeFirstTurn = sText_GravityIntensified, }, */ }; @@ -4044,6 +4046,14 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which) return TRUE; } break; + case TRAINER_SLIDE_BEFORE_FIRST_TURN: + if (sTrainerSlides[i].msgBeforeFirstTurn != NULL && !gBattleStruct->trainerSlideBeforeFirstTurnMsgDone) + { + gBattleStruct->trainerSlideBeforeFirstTurnMsgDone = TRUE; + gBattleStruct->trainerSlideMsg = sTrainerSlides[i].msgBeforeFirstTurn; + return TRUE; + } + break; } break; } From 686d42709a6281c5baed0e5a6d8aad34b6b642a5 Mon Sep 17 00:00:00 2001 From: PSF Date: Tue, 28 Mar 2023 15:50:58 -0700 Subject: [PATCH 05/17] Added documentation on resetting battle flags and vars Added Overworld_ResetBattleFlagsAndVars to Overworld_ResetStateAfterWhiteOut --- include/config/battle.h | 2 ++ src/overworld.c | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 4a3d6382f..c6bca6de8 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -143,6 +143,7 @@ // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. +// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water. #define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles. #define B_SMART_WILD_AI_FLAG 0 // If not 0, you can set this flag in a script to enable smart wild pokemon @@ -152,6 +153,7 @@ // Var Settings // To use the following features in scripting, replace the 0s with the var ID you're assigning it to. // Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature. +// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active #define B_VAR_WILD_AI_FLAGS 0 // If not 0, you can use this var to add to default wild AI flags. NOT usable with flags above (1 << 15) diff --git a/src/overworld.c b/src/overworld.c index 6b63a60d5..9fabe3ed9 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -401,6 +401,23 @@ void Overworld_ResetStateAfterDigEscRope(void) FlagClear(FLAG_SYS_USE_FLASH); } +void Overworld_ResetBattleFlagsAndVars(void) +{ +#if VAR_TERRAIN != 0 + VarSet(VAR_TERRAIN, 0); +#endif + +#if B_VAR_WILD_AI_FLAGS != 0 + VarSet(B_VAR_WILD_AI_FLAGS,0); +#endif + + FlagClear(B_FLAG_INVERSE_BATTLE); + FlagClear(B_FLAG_FORCE_DOUBLE_WILD); + FlagClear(B_SMART_WILD_AI_FLAG); + FlagClear(B_FLAG_NO_BAG_USE); + FlagClear(B_FLAG_NO_CATCHING); +} + static void Overworld_ResetStateAfterWhiteOut(void) { ResetInitialPlayerAvatarState(); @@ -409,9 +426,7 @@ static void Overworld_ResetStateAfterWhiteOut(void) FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_USE_STRENGTH); FlagClear(FLAG_SYS_USE_FLASH); -#if VAR_TERRAIN != 0 - VarSet(VAR_TERRAIN, 0); -#endif + Overworld_ResetBattleFlagsAndVars(); // If you were defeated by Kyogre/Groudon and the step counter has // maxed out, end the abnormal weather. if (VarGet(VAR_SHOULD_END_ABNORMAL_WEATHER) == 1) From 24df9823e8f1c20e723b2b9b8b2ab01ee84db379 Mon Sep 17 00:00:00 2001 From: PSF Date: Thu, 30 Mar 2023 06:35:38 -0700 Subject: [PATCH 06/17] In response to PR discussion, added new preproc config for developers to toggle Overworld_ResetBattleFlagsAndVars --- include/config/battle.h | 5 +++-- src/overworld.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index c6bca6de8..77e0e0f4d 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -143,7 +143,6 @@ // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. -// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water. #define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles. #define B_SMART_WILD_AI_FLAG 0 // If not 0, you can set this flag in a script to enable smart wild pokemon @@ -153,10 +152,12 @@ // Var Settings // To use the following features in scripting, replace the 0s with the var ID you're assigning it to. // Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature. -// Once these features are turned on within the game, they will remain on until they are explcitily turned off or until the player whites out. This can be turned off by disabling Overworld_ResetBattleFlagsAndVars. #define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active #define B_VAR_WILD_AI_FLAGS 0 // If not 0, you can use this var to add to default wild AI flags. NOT usable with flags above (1 << 15) +//Flag and Var settings +#define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If set to TRUE, Flag and Var settings (B_FLAG_INVERSE_BATTLE,B_FLAG_FORCE_DOUBLE_WILD,B_SMART_WILD_AI_FLAG,B_FLAG_NO_BAG_USE,B_FLAG_NO_CATCHING,B_VAR_WILD_AI_FLAGS, and VAR_TERRAIN) will be reset when the player whites out. + // Terrain settings #define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. #define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. diff --git a/src/overworld.c b/src/overworld.c index 9fabe3ed9..3af1cfd6d 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -401,15 +401,16 @@ void Overworld_ResetStateAfterDigEscRope(void) FlagClear(FLAG_SYS_USE_FLASH); } -void Overworld_ResetBattleFlagsAndVars(void) +#if B_RESET_FLAGS_VARS_AFTER_WHITEOUT == TRUE + void Overworld_ResetBattleFlagsAndVars(void) { -#if VAR_TERRAIN != 0 - VarSet(VAR_TERRAIN, 0); -#endif + #if VAR_TERRAIN != 0 + VarSet(VAR_TERRAIN, 0); + #endif -#if B_VAR_WILD_AI_FLAGS != 0 - VarSet(B_VAR_WILD_AI_FLAGS,0); -#endif + #if B_VAR_WILD_AI_FLAGS != 0 + VarSet(B_VAR_WILD_AI_FLAGS,0); + #endif FlagClear(B_FLAG_INVERSE_BATTLE); FlagClear(B_FLAG_FORCE_DOUBLE_WILD); @@ -417,6 +418,7 @@ void Overworld_ResetBattleFlagsAndVars(void) FlagClear(B_FLAG_NO_BAG_USE); FlagClear(B_FLAG_NO_CATCHING); } +#endif static void Overworld_ResetStateAfterWhiteOut(void) { @@ -426,7 +428,9 @@ static void Overworld_ResetStateAfterWhiteOut(void) FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_USE_STRENGTH); FlagClear(FLAG_SYS_USE_FLASH); +#if B_RESET_FLAGS_VARS_AFTER_WHITEOUT == TRUE Overworld_ResetBattleFlagsAndVars(); +#endif // If you were defeated by Kyogre/Groudon and the step counter has // maxed out, end the abnormal weather. if (VarGet(VAR_SHOULD_END_ABNORMAL_WEATHER) == 1) From 59dfc7c3ad513ee2bc05b43e80eedf7dfccb43ee Mon Sep 17 00:00:00 2001 From: psf <77138753+pkmnsnfrn@users.noreply.github.com> Date: Fri, 7 Apr 2023 06:07:12 -0700 Subject: [PATCH 07/17] Update include/config/battle.h Took suggestions from https://github.com/rh-hideout/pokeemerald-expansion/pull/2875#discussion_r1160574308 Co-authored-by: LOuroboros --- include/config/battle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index 77e0e0f4d..790ad78cc 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -155,8 +155,8 @@ #define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active #define B_VAR_WILD_AI_FLAGS 0 // If not 0, you can use this var to add to default wild AI flags. NOT usable with flags above (1 << 15) -//Flag and Var settings -#define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If set to TRUE, Flag and Var settings (B_FLAG_INVERSE_BATTLE,B_FLAG_FORCE_DOUBLE_WILD,B_SMART_WILD_AI_FLAG,B_FLAG_NO_BAG_USE,B_FLAG_NO_CATCHING,B_VAR_WILD_AI_FLAGS, and VAR_TERRAIN) will be reset when the player whites out. +// Flag and Var settings +#define B_RESET_FLAGS_VARS_AFTER_WHITEOUT TRUE // If TRUE, Overworld_ResetBattleFlagsAndVars will reset battle-related Flags and Vars when the player whites out. // Terrain settings #define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. From 82dc1e3e93810f74f7abd377f76c2f4ceab70976 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sat, 15 Apr 2023 09:27:28 -0700 Subject: [PATCH 08/17] fixed dupe strings in battle item use --- data/battle_scripts_2.s | 12 ++++++------ src/item_use.c | 5 +++-- src/party_menu.c | 8 +------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index dee482d1d..71d88ae84 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -49,14 +49,13 @@ BattleScript_UseItemMessage: BattleScript_ItemRestoreHP:: call BattleScript_UseItemMessage itemrestorehp - printstring STRINGID_ITEMRESTOREDSPECIESHEALTH - waitmessage B_WAIT_TIME_LONG jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_ItemRestoreHP_SendOutRevivedBattler bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER - updatestatusicon BS_ATTACKER + printstring STRINGID_ITEMRESTOREDSPECIESHEALTH + waitmessage B_WAIT_TIME_LONG end BattleScript_ItemRestoreHP_SendOutRevivedBattler: @@ -68,22 +67,22 @@ BattleScript_ItemRestoreHP_SendOutRevivedBattler: BattleScript_ItemCureStatus:: call BattleScript_UseItemMessage itemcurestatus + updatestatusicon BS_ATTACKER printstring STRINGID_ITEMCUREDSPECIESSTATUS waitmessage B_WAIT_TIME_LONG - updatestatusicon BS_ATTACKER end BattleScript_ItemHealAndCureStatus:: call BattleScript_UseItemMessage itemrestorehp curestatus BS_ATTACKER - printstring STRINGID_ITEMRESTOREDSPECIESHEALTH - waitmessage B_WAIT_TIME_LONG bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER updatestatusicon BS_ATTACKER + printstring STRINGID_ITEMRESTOREDSPECIESHEALTH + waitmessage B_WAIT_TIME_LONG end BattleScript_ItemIncreaseStat:: @@ -256,3 +255,4 @@ BattleScript_TrainerBSlideMsgRet:: BattleScript_TrainerBSlideMsgEnd2:: call BattleScript_TrainerBSlideMsgRet end2 + end2 diff --git a/src/item_use.c b/src/item_use.c index 8bcadfb2e..26b48ac80 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -1229,10 +1229,11 @@ void ItemUseInBattle_BagMenu(u8 taskId) { PlaySE(SE_SELECT); RemoveUsedItem(); + ScheduleBgCopyTilemapToVram(2); if (!InBattlePyramid()) - DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, Task_FadeAndCloseBagMenu); + gTasks[taskId].func = Task_FadeAndCloseBagMenu; else - DisplayItemMessageInBattlePyramid(taskId, gStringVar4, CloseBattlePyramidBag); + gTasks[taskId].func = CloseBattlePyramidBag; } } diff --git a/src/party_menu.c b/src/party_menu.c index dd46b1063..95d64e546 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4470,11 +4470,8 @@ void ItemUseCB_BattleScript(u8 taskId, TaskFunc task) gBattleStruct->itemPartyIndex[gBattlerInMenuId] = GetPartyIdFromBattleSlot(gPartyMenu.slotId); gPartyMenuUseExitCallback = TRUE; PlaySE(SE_SELECT); - CopyItemName(gSpecialVar_ItemId, gStringVar2); - StringExpandPlaceholders(gStringVar4, gText_PlayerUsedVar2); - DisplayPartyMenuMessage(gStringVar4, TRUE); - ScheduleBgCopyTilemapToVram(2); RemoveBagItem(gSpecialVar_ItemId, 1); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; } } @@ -4943,9 +4940,6 @@ static void TryUseItemOnMove(u8 taskId) gChosenMovePos = ptr->data1; gPartyMenuUseExitCallback = TRUE; RemoveBagItem(gSpecialVar_ItemId, 1); - CopyItemName(gSpecialVar_ItemId, gStringVar2); - StringExpandPlaceholders(gStringVar4, gText_PlayerUsedVar2); - DisplayPartyMenuMessage(gStringVar4, TRUE); ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_ClosePartyMenuAfterText; } From d3a090020bb062d88c0c162bc62292e4debfcd95 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sat, 15 Apr 2023 15:30:07 -0700 Subject: [PATCH 09/17] added code review --- data/battle_scripts_2.s | 1 - src/battle_message.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index 71d88ae84..9ffad7d84 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -255,4 +255,3 @@ BattleScript_TrainerBSlideMsgRet:: BattleScript_TrainerBSlideMsgEnd2:: call BattleScript_TrainerBSlideMsgRet end2 - end2 diff --git a/src/battle_message.c b/src/battle_message.c index 7d10b19f1..640e7900d 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -465,7 +465,7 @@ const u8 *const gPokeblockWasTooXStringTable[FLAVOR_COUNT] = [FLAVOR_SOUR] = sText_PokeblockWasTooSour }; -static const u8 sText_PlayerUsedItem[] = _("{B_PLAYER_NAME} used\n{B_LAST_ITEM}!"); +static const u8 sText_PlayerUsedItem[] = _("You used\n{B_LAST_ITEM}!"); static const u8 sText_WallyUsedItem[] = _("WALLY used\n{B_LAST_ITEM}!"); static const u8 sText_Trainer1UsedItem[] = _("{B_ATK_TRAINER_CLASS} {B_ATK_TRAINER_NAME}\nused {B_LAST_ITEM}!"); static const u8 sText_TrainerBlockedBall[] = _("The TRAINER blocked the BALL!"); @@ -783,9 +783,9 @@ static const u8 sText_ShellTrapDidntWork[] = _("{B_ATK_NAME_WITH_PREFIX}'s shell static const u8 sText_CouldntFullyProtect[] = _("{B_DEF_NAME_WITH_PREFIX} couldn't fully protect\nitself and got hurt!"); static const u8 sText_StockpiledEffectWoreOff[] = _("{B_ATK_NAME_WITH_PREFIX}'s stockpiled\neffect wore off!"); static const u8 sText_PkmnRevivedReadyToFight[] = _("{B_BUFF1} was revived and\nis ready to fight again!"); -static const u8 sText_ItemRestoredSpeciesHealth[] = _("{B_LAST_ITEM} restored\n{B_BUFF1}'s health!"); -static const u8 sText_ItemCuredSpeciesStatus[] = _("{B_LAST_ITEM} cured\n{B_BUFF1}'s status!"); -static const u8 sText_ItemRestoredSpeciesPP[] = _("{B_LAST_ITEM} restored\n{B_BUFF1}'s PP!"); +static const u8 sText_ItemRestoredSpeciesHealth[] = _("{B_BUFF1} had its\nHP restored!"); +static const u8 sText_ItemCuredSpeciesStatus[] = _("{B_BUFF1} had\nits status healed!"); +static const u8 sText_ItemRestoredSpeciesPP[] = _("{B_BUFF1} had its\nPP restored!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { From d3fed5639b4b56836221ccf6232387e2d63a3eed Mon Sep 17 00:00:00 2001 From: psf <77138753+pkmnsnfrn@users.noreply.github.com> Date: Wed, 19 Apr 2023 15:54:57 -0700 Subject: [PATCH 10/17] Added config to enable NEW_ROCKS_PARTICLE (#2929) Co-authored-by: LOuroboros --- include/config/battle.h | 1 + src/data/battle_anim.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/config/battle.h b/include/config/battle.h index ad3162162..3e9ec9b9a 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -195,6 +195,7 @@ #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. #define B_NEW_LEECH_SEED_PARTICLE FALSE // If set to TRUE, it updates Leech Seed's animation particle. #define B_NEW_HORN_ATTACK_PARTICLE FALSE // If set to TRUE, it updates Horn Attack's horn particle. +#define B_NEW_ROCKS_PARTICLE TRUE // If set to TRUE, it updates rock particles. #define B_NEW_LEAF_PARTICLE FALSE // If set to TRUE, it updates leaf particle. #define B_NEW_EMBER_PARTICLES FALSE // If set to TRUE, it updates Ember's fire particle. #define B_NEW_MEAN_LOOK_PARTICLE FALSE // If set to TRUE, it updates Mean Look's eye particle. diff --git a/src/data/battle_anim.h b/src/data/battle_anim.h index b1f158310..46293e3a0 100644 --- a/src/data/battle_anim.h +++ b/src/data/battle_anim.h @@ -1079,7 +1079,7 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] = {gBattleAnimSpriteGfx_RedFist, 0x0200, ANIM_TAG_RED_FIST}, {gBattleAnimSpriteGfx_SlamHit, 0x1000, ANIM_TAG_SLAM_HIT}, {gBattleAnimSpriteGfx_Ring, 0x0180, ANIM_TAG_RING}, -#if NEW_ROCKS_PARTICLE +#if B_NEW_ROCKS_PARTICLE == TRUE {gBattleAnimSpriteGfx_NewRocks, 0x0C00, ANIM_TAG_ROCKS}, #else {gBattleAnimSpriteGfx_Rocks, 0x0C00, ANIM_TAG_ROCKS}, @@ -1529,7 +1529,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] = {gBattleAnimSpritePal_HumanoidFoot, ANIM_TAG_RED_FIST}, {gBattleAnimSpritePal_SlamHit, ANIM_TAG_SLAM_HIT}, {gBattleAnimSpritePal_Ring, ANIM_TAG_RING}, -#if NEW_ROCKS_PARTICLE +#if B_NEW_ROCKS_PARTICLE == TRUE {gBattleAnimSpritePal_NewRocks, ANIM_TAG_ROCKS}, #else {gBattleAnimSpritePal_Rocks, ANIM_TAG_ROCKS}, From 3aec63b8cfb23b0983b92ba03e89c31db84b20a1 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 20 Apr 2023 15:08:42 +0200 Subject: [PATCH 11/17] new define to restore items after battle --- include/battle.h | 4 ++-- include/battle_util.h | 2 +- include/config/battle.h | 1 + src/battle_main.c | 6 +++--- src/battle_script_commands.c | 14 +++++++------- src/battle_util.c | 18 ++++++++++-------- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/include/battle.h b/include/battle.h index 46975bec3..f86a5c975 100644 --- a/include/battle.h +++ b/include/battle.h @@ -517,7 +517,7 @@ struct ZMoveData u8 splits[MAX_BATTLERS_COUNT]; }; -struct StolenItem +struct LostItem { u16 originalItem:15; u16 stolen:1; @@ -640,7 +640,7 @@ struct BattleStruct u16 moveEffect2; // For Knock Off u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. u8 quickClawBattlerId; - struct StolenItem itemStolen[PARTY_SIZE]; // Player's team that had items stolen (two bytes per party member) + struct LostItem itemLost[PARTY_SIZE]; // Player's team that had items consumed or stolen (two bytes per party member) u8 blunderPolicy:1; // should blunder policy activate u8 swapDamageCategory:1; // Photon Geyser, Shell Side Arm, Light That Burns the Sky u8 forcedSwitch:4; // For each battler diff --git a/include/battle_util.h b/include/battle_util.h index 0661081e4..b83209a69 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -197,7 +197,7 @@ bool32 IsPartnerMonFromSameTrainer(u8 battlerId); u8 GetSplitBasedOnStats(u8 battlerId); void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast); bool32 TestSheerForceFlag(u8 battler, u16 move); -void TryRestoreStolenItems(void); +void TryRestoreHeldItems(void); bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item); void TrySaveExchangedItem(u8 battlerId, u16 stolenItem); bool32 IsPartnerMonFromSameTrainer(u8 battlerId); diff --git a/include/config/battle.h b/include/config/battle.h index 3e9ec9b9a..4bead3ae8 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -126,6 +126,7 @@ #define B_X_ITEMS_BUFF GEN_LATEST // In Gen7+, the X Items raise a stat by 2 stages instead of 1. #define B_MENTAL_HERB GEN_LATEST // In Gen5+, the Mental Herb cures Taunt, Encore, Torment, Heal Block, and Disable in addition to Infatuation from before. #define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items. +#define B_RESTORE_HELD_BATTLE_ITEMS TRUE // In Gen9 all non berry items are restored after battle. #define B_SOUL_DEW_BOOST GEN_LATEST // In Gens3-6, Soul Dew boosts Lati@s' Sp. Atk and Sp. Def. In Gen7+ it boosts the power of their Psychic and Dragon type moves instead. #define B_NET_BALL_MODIFIER GEN_LATEST // In Gen7+, Net Ball's catch multiplier is x5 instead of x3. #define B_DIVE_BALL_MODIFIER GEN_LATEST // In Gen4+, Dive Ball's effectiveness increases by when Surfing or Fishing. diff --git a/src/battle_main.c b/src/battle_main.c index a5a9b5bbf..01d79db3e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3189,7 +3189,7 @@ static void BattleStartClearSetData(void) { gBattleStruct->usedHeldItems[i][B_SIDE_PLAYER] = 0; gBattleStruct->usedHeldItems[i][B_SIDE_OPPONENT] = 0; - gBattleStruct->itemStolen[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + gBattleStruct->itemLost[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); gPartyCriticalHits[i] = 0; gBattleStruct->allowedToChangeFormInWeather[i][B_SIDE_PLAYER] = FALSE; gBattleStruct->allowedToChangeFormInWeather[i][B_SIDE_OPPONENT] = FALSE; @@ -5387,9 +5387,9 @@ static void HandleEndTurn_FinishBattle(void) TestRunner_Battle_AfterLastTurn(); BeginFastPaletteFade(3); FadeOutMapMusic(5); - #if B_TRAINERS_KNOCK_OFF_ITEMS == TRUE + #if B_TRAINERS_KNOCK_OFF_ITEMS == TRUE || B_RESTORE_HELD_BATTLE_ITEMS == TRUE if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) - TryRestoreStolenItems(); + TryRestoreHeldItems(); #endif for (i = 0; i < PARTY_SIZE; i++) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4e1494ce3..228cbb812 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7892,7 +7892,7 @@ static void BestowItem(u32 battlerAtk, u32 battlerDef) // Called by Cmd_removeitem. itemId represents the item that was removed, not being given. static bool32 TrySymbiosis(u32 battler, u32 itemId) { - if (!gBattleStruct->itemStolen[gBattlerPartyIndexes[battler]].stolen + if (!gBattleStruct->itemLost[gBattlerPartyIndexes[battler]].stolen && gBattleStruct->changedItems[battler] == ITEM_NONE && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_EJECT_BUTTON && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_EJECT_PACK @@ -11264,7 +11264,7 @@ static void Cmd_various(void) // Open party menu, wait to go to next instruction. else - { + { BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_FAINTED_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gBattlerAttacker]); MarkBattlerForControllerExec(gBattlerAttacker); } @@ -16469,7 +16469,7 @@ void BS_ItemRestoreHP(void) { } if (hp + healAmount > maxHP) healAmount = maxHP - hp; - + // Heal is applied as move damage if battler is active. if (battlerId != MAX_BATTLERS_COUNT && hp != 0) { @@ -16494,10 +16494,10 @@ void BS_ItemRestoreHP(void) { void BS_ItemCureStatus(void) { NATIVE_ARGS(); struct Pokemon *party = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; - + // Heal Status1 conditions. HealStatusConditions(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], gBattleStruct->itemPartyIndex[gBattlerAttacker], GetItemStatus1Mask(gLastUsedItem), gBattlerAttacker); - + // Heal Status2 conditions if battler is active. if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) { @@ -16506,10 +16506,10 @@ void BS_ItemCureStatus(void) { else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)]) { - gBattleMons[gBattlerAttacker].status2 &= ~GetItemStatus2Mask(gLastUsedItem); + gBattleMons[gBattlerAttacker].status2 &= ~GetItemStatus2Mask(gLastUsedItem); gBattlerTarget = BATTLE_PARTNER(gBattlerAttacker); } - + if (GetItemStatus1Mask(gLastUsedItem) & STATUS1_SLEEP) gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; diff --git a/src/battle_util.c b/src/battle_util.c index ac274bf0f..e057b78dc 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10536,18 +10536,20 @@ void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast) } } -void TryRestoreStolenItems(void) +void TryRestoreHeldItems(void) { u32 i; - u16 stolenItem = ITEM_NONE; + u16 lostItem = ITEM_NONE; for (i = 0; i < PARTY_SIZE; i++) { - if (gBattleStruct->itemStolen[i].stolen) + #if B_RESTORE_HELD_BATTLE_ITEMS == FALSE + if (gBattleStruct->itemLost[i].stolen) + #endif { - stolenItem = gBattleStruct->itemStolen[i].originalItem; - if (stolenItem != ITEM_NONE && ItemId_GetPocket(stolenItem) != POCKET_BERRIES) - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &stolenItem); // Restore stolen non-berry items + lostItem = gBattleStruct->itemLost[i].originalItem; + if (lostItem != ITEM_NONE && ItemId_GetPocket(lostItem) != POCKET_BERRIES) + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &lostItem); // Restore stolen non-berry items } } } @@ -10601,8 +10603,8 @@ void TrySaveExchangedItem(u8 battlerId, u16 stolenItem) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && GetBattlerSide(battlerId) == B_SIDE_PLAYER - && stolenItem == gBattleStruct->itemStolen[gBattlerPartyIndexes[battlerId]].originalItem) - gBattleStruct->itemStolen[gBattlerPartyIndexes[battlerId]].stolen = TRUE; + && stolenItem == gBattleStruct->itemLost[gBattlerPartyIndexes[battlerId]].originalItem) + gBattleStruct->itemLost[gBattlerPartyIndexes[battlerId]].stolen = TRUE; #endif } From 6c7f5881e453631a1f336618b7e0120c33b7f140 Mon Sep 17 00:00:00 2001 From: citrusbolt <32605812+citrusbolt@users.noreply.github.com> Date: Thu, 20 Apr 2023 08:05:32 -0600 Subject: [PATCH 12/17] Add two EV-related configs (#2825) --- include/config/item.h | 13 +++++++------ include/config/pokemon.h | 1 + include/constants/pokemon.h | 4 ++++ src/pokemon.c | 12 ++++++++++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/include/config/item.h b/include/config/item.h index f707b7a54..09008d0f2 100644 --- a/include/config/item.h +++ b/include/config/item.h @@ -2,12 +2,13 @@ #define GUARD_CONFIG_ITEM_H // Item config -#define I_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. -#define I_KEY_FOSSILS GEN_LATEST // In Gen4+, all Gen 3 fossils became regular items. -#define I_KEY_ESCAPE_ROPE GEN_LATEST // In Gen8, Escape Rope became a Key Item. Keep in mind, this will make it free to buy in marts. -#define I_HEALTH_RECOVERY GEN_LATEST // In Gen7+, certain healing items recover a different amount of HP than they used to. -#define I_SITRUS_BERRY_HEAL GEN_LATEST // In Gen4+, Sitrus Berry was changed from healing 30 HP to healing 25% of Max HP. -#define I_VITAMIN_EV_CAP GEN_LATEST // In Gen8, the Vitamins no longer have a cap of 100 EV per stat. +#define I_SHINY_CHARM_REROLLS 3 // Amount of re-rolls if the player has the Shiny Charm. Set to 0 to disable Shiny Charm's effects. +#define I_KEY_FOSSILS GEN_LATEST // In Gen4+, all Gen 3 fossils became regular items. +#define I_KEY_ESCAPE_ROPE GEN_LATEST // In Gen8, Escape Rope became a Key Item. Keep in mind, this will make it free to buy in marts. +#define I_HEALTH_RECOVERY GEN_LATEST // In Gen7+, certain healing items recover a different amount of HP than they used to. +#define I_SITRUS_BERRY_HEAL GEN_LATEST // In Gen4+, Sitrus Berry was changed from healing 30 HP to healing 25% of Max HP. +#define I_VITAMIN_EV_CAP GEN_LATEST // In Gen8+, the Vitamins no longer have a cap of 100 EV per stat. +#define I_BERRY_EV_JUMP GEN_LATEST // In Gen4 only, EV-lowering Berries lower a stat's EV to 100 if it is above 100. // TM config #define I_REUSABLE_TMS FALSE // In Gen5-8, TMs are reusable. Setting this to TRUE will make all vanilla TMs reusable, though they can also be cherry-picked by setting their importance to 1. diff --git a/include/config/pokemon.h b/include/config/pokemon.h index ce5faf2a6..1cde573c9 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -21,6 +21,7 @@ // Other settings #define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs. +#define P_EV_CAP GEN_LATEST // Since Gen 6, the max EVs per stat is 252 instead of 255. // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index cf6cc8751..ddf879854 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -201,7 +201,11 @@ #define MAX_PER_STAT_IVS 31 #define MAX_IV_MASK 31 #define USE_RANDOM_IVS (MAX_PER_STAT_IVS + 1) +#if P_EV_CAP >= GEN_6 +#define MAX_PER_STAT_EVS 252 +#else #define MAX_PER_STAT_EVS 255 +#endif #define MAX_TOTAL_EVS 510 #if I_VITAMIN_EV_CAP >= GEN_8 #define EV_ITEM_RAISE_LIMIT MAX_PER_STAT_EVS diff --git a/src/pokemon.c b/src/pokemon.c index 46eca90b2..e82cb98c3 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5854,7 +5854,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if (itemEffect[10] & ITEM10_IS_VITAMIN) evCap = EV_ITEM_RAISE_LIMIT; else - evCap = 252; + evCap = MAX_PER_STAT_EVS; if (dataSigned >= evCap) break; @@ -5880,6 +5880,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov break; } dataSigned += evChange; + #if I_EV_LOWERING_BERRY_JUMP == GEN_4 + if (dataSigned > 100) + dataSigned = 100; + #endif if (dataSigned < 0) dataSigned = 0; } @@ -6030,7 +6034,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if (itemEffect[10] & ITEM10_IS_VITAMIN) evCap = EV_ITEM_RAISE_LIMIT; else - evCap = 252; + evCap = MAX_PER_STAT_EVS; if (dataSigned >= evCap) break; @@ -6056,6 +6060,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov break; } dataSigned += evChange; + #if I_BERRY_EV_JUMP == GEN_4 + if (dataSigned > 100) + dataSigned = 100; + #endif if (dataSigned < 0) dataSigned = 0; } From ae80d545c5b4f2f86baf702d4527d88c11b935b0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 20 Apr 2023 16:12:11 +0200 Subject: [PATCH 13/17] Support for multi battles where Trainer has only one mon (#2670) --- src/battle_controller_opponent.c | 12 +++++++----- src/battle_interface.c | 5 +++++ src/battle_main.c | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index cb0499ac8..4eda81b09 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -228,9 +228,11 @@ static void Intro_DelayAndEnd(void) } } -static bool32 TwoIntroMons(u32 battlerId) // Double battle with both player pokemon active. +static bool32 TwoIntroMons(u32 battlerId) // Double battle with both opponent pokemon active. { - return (IsDoubleBattle() && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]])); + return (IsDoubleBattle() + && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[battlerId]]) + && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]])); } static void Intro_WaitForShinyAnimAndHealthbox(void) @@ -1969,7 +1971,7 @@ static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite) static void Task_StartSendOutAnim(u8 taskId) { - u8 savedActiveBank = gActiveBattler; + u8 savedActiveBattler = gActiveBattler; gActiveBattler = gTasks[taskId].data[0]; if ((!TwoIntroMons(gActiveBattler) || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !BATTLE_TWO_VS_ONE_OPPONENT) @@ -1977,7 +1979,7 @@ static void Task_StartSendOutAnim(u8 taskId) gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; StartSendOutAnim(gActiveBattler, FALSE); } - else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) + else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) || (BATTLE_TWO_VS_ONE_OPPONENT && !TwoIntroMons(gActiveBattler))) { gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; StartSendOutAnim(gActiveBattler, FALSE); @@ -1992,7 +1994,7 @@ static void Task_StartSendOutAnim(u8 taskId) gActiveBattler ^= BIT_FLANK; } gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox; - gActiveBattler = savedActiveBank; + gActiveBattler = savedActiveBattler; DestroyTask(taskId); } diff --git a/src/battle_interface.c b/src/battle_interface.c index 7f7e1d20f..bbe61a372 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -690,12 +690,17 @@ static void InitLastUsedBallAssets(void) } // This function is here to cover a specific case - one player's mon in a 2 vs 1 double battle. In this scenario - display singles layout. +// The same goes for a 2 vs 1 where opponent has only one pokemon. u32 WhichBattleCoords(u32 battlerId) // 0 - singles, 1 - doubles { if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT && gPlayerPartyCount == 1 && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) return 0; + else if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT + && gEnemyPartyCount == 1 + && !(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) + return 0; else return IsDoubleBattle(); } diff --git a/src/battle_main.c b/src/battle_main.c index a5a9b5bbf..2eecda65b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -594,6 +594,7 @@ static void CB2_InitBattleInternal(void) if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && !BATTLE_TWO_VS_ONE_OPPONENT) CreateNPCTrainerParty(&gEnemyParty[PARTY_SIZE / 2], gTrainerBattleOpponent_B, FALSE); SetWildMonHeldItem(); + CalculateEnemyPartyCount(); } gMain.inBattle = TRUE; From 4a08ede2c49ba55ac9d358d95ee240b238325192 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 21 Apr 2023 20:13:30 +0200 Subject: [PATCH 14/17] Add GetMovesArray in GetMovesArray --- src/battle_ai_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 05e7aec58..53b5ebed6 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -477,7 +477,7 @@ bool32 IsAiBattlerAware(u32 battlerId) { if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_OMNISCIENT) return TRUE; - + return BattlerHasAi(battlerId); } @@ -1129,7 +1129,7 @@ bool32 CanTargetFaintAi(u8 battlerDef, u8 battlerAtk) { s32 i, dmg; u32 unusable = AI_DATA->moveLimitations[battlerDef]; - u16 *moves = gBattleResources->battleHistory->usedMoves[battlerDef]; + u16 *moves = GetMovesArray(battlerDef); for (i = 0; i < MAX_MON_MOVES; i++) { From 30204e99533bf826486c3cd535a04a2c97dc5e09 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 21 Apr 2023 20:59:54 +0200 Subject: [PATCH 15/17] fix wrong z-move ususage --- src/battle_z_move.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/battle_z_move.c b/src/battle_z_move.c index 104a44daa..f435253c7 100644 --- a/src/battle_z_move.c +++ b/src/battle_z_move.c @@ -215,11 +215,7 @@ bool32 IsViableZMove(u8 battlerId, u16 move) if (move != MOVE_NONE && zMove != MOVE_Z_STATUS && gBattleMoves[move].type == ItemId_GetSecondaryId(item)) { - if (IS_MOVE_STATUS(move)) - gBattleStruct->zmove.chosenZMove = move; - else - gBattleStruct->zmove.chosenZMove = GetTypeBasedZMove(move, battlerId); - + gBattleStruct->zmove.chosenZMove = GetTypeBasedZMove(move, battlerId); return TRUE; } } From 330e85ba64b1b23d602a83ad3bef16f93a05b73c Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 24 Apr 2023 09:34:11 -0300 Subject: [PATCH 16/17] Updates -Undeclared size for certain trainer slide-in variables at struct BattleStruct for reasons. -Added a BattlerHPPercentage function to make HP threshold checks in ShouldDoTrainerSlide a bit more readable. --- include/battle.h | 10 +++++----- src/battle_message.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/battle.h b/include/battle.h index 44aa063c9..2b72d4836 100644 --- a/include/battle.h +++ b/include/battle.h @@ -622,7 +622,7 @@ struct BattleStruct struct MegaEvolutionData mega; struct ZMoveData zmove; const u8 *trainerSlideMsg; - bool8 trainerSlideLowHpMsgDone:1; + bool8 trainerSlideLowHpMsgDone; u8 introState; u8 ateBerry[2]; // array id determined by side, each party pokemon as bit u8 stolenStats[NUM_BATTLE_STATS]; // hp byte is used for which stats to raise, other inform about by how many stages @@ -663,14 +663,14 @@ struct BattleStruct u8 storedHealingWish:4; // Each battler as a bit. u8 storedLunarDance:4; // Each battler as a bit. u16 supremeOverlordModifier[MAX_BATTLERS_COUNT]; - bool8 trainerSlideHalfHpMsgDone:1; + bool8 trainerSlideHalfHpMsgDone; u8 trainerSlideFirstCriticalHitMsgState:2; u8 trainerSlideFirstSuperEffectiveHitMsgState:2; u8 trainerSlideFirstSTABMoveMsgState:2; u8 trainerSlidePlayerMonUnaffectedMsgState:2; - bool8 trainerSlideMegaEvolutionMsgDone:1; - bool8 trainerSlideZMoveMsgDone:1; - bool8 trainerSlideBeforeFirstTurnMsgDone:1; + bool8 trainerSlideMegaEvolutionMsgDone; + bool8 trainerSlideZMoveMsgDone; + bool8 trainerSlideBeforeFirstTurnMsgDone; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/src/battle_message.c b/src/battle_message.c index fab65a46b..dd6390d28 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3934,6 +3934,37 @@ static u32 GetEnemyMonCount(u32 firstId, u32 lastId, bool32 onlyAlive) return count; } +enum +{ + LESS_THAN, + EQUAL, + GREATER_THAN, + LESS_THAN_OR_EQUAL, + GREATER_THAN_OR_EQUAL, + NOT_EQUAL, +}; + +u32 BattlerHPPercentage(u32 battlerId, u32 operation, u32 threshold) +{ + switch (operation) + { + case LESS_THAN: + return gBattleMons[battlerId].hp < (gBattleMons[battlerId].maxHP / threshold); + case EQUAL: + return gBattleMons[battlerId].hp == (gBattleMons[battlerId].maxHP / threshold); + case GREATER_THAN: + return gBattleMons[battlerId].hp > (gBattleMons[battlerId].maxHP / threshold); + case LESS_THAN_OR_EQUAL: + return gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / threshold); + case GREATER_THAN_OR_EQUAL: + return gBattleMons[battlerId].hp >= (gBattleMons[battlerId].maxHP / threshold); + case NOT_EQUAL: + return gBattleMons[battlerId].hp != (gBattleMons[battlerId].maxHP / threshold); + default: + break; + } +} + u32 ShouldDoTrainerSlide(u32 battlerId, u32 which) { u32 i, firstId, lastId, trainerId, retValue = 1; @@ -3979,7 +4010,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which) case TRAINER_SLIDE_LAST_LOW_HP: if (sTrainerSlides[i].msgLastLowHp != NULL && GetEnemyMonCount(firstId, lastId, TRUE) == 1 - && gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / 4) + && BattlerHPPercentage(battlerId, GREATER_THAN_OR_EQUAL, 4) && !gBattleStruct->trainerSlideLowHpMsgDone) { gBattleStruct->trainerSlideLowHpMsgDone = TRUE; @@ -3997,7 +4028,7 @@ u32 ShouldDoTrainerSlide(u32 battlerId, u32 which) case TRAINER_SLIDE_LAST_HALF_HP: if (sTrainerSlides[i].msgLastHalfHp != NULL && GetEnemyMonCount(firstId, lastId, TRUE) == GetEnemyMonCount(firstId, lastId, FALSE) - 1 - && (gBattleMons[battlerId].hp <= (gBattleMons[battlerId].maxHP / 2) && gBattleMons[battlerId].hp > (gBattleMons[battlerId].maxHP / 4)) + && BattlerHPPercentage(battlerId, LESS_THAN_OR_EQUAL, 2) && BattlerHPPercentage(battlerId, GREATER_THAN, 4) && !gBattleStruct->trainerSlideHalfHpMsgDone) { gBattleStruct->trainerSlideHalfHpMsgDone = TRUE; From 868838a87d8af109ee90835d6c33bd7d8928328c Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Mon, 24 Apr 2023 14:35:42 -0400 Subject: [PATCH 17/17] Add thunder cage case to trap anim IDs (#2941) --- data/battle_anim_scripts.s | 5 +++++ include/constants/battle_anim.h | 1 + include/constants/battle_string_ids.h | 24 +++++++++++--------- src/battle_anim_throw.c | 32 +++++++++++++++++++-------- src/battle_message.c | 3 +++ 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index cca8706cb..adcb88c88 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -24463,6 +24463,7 @@ General_TurnTrap: jumpargeq 0, TRAP_ANIM_MAGMA_STORM, Status_MagmaStorm jumpargeq 0, TRAP_ANIM_INFESTATION, Status_Infestation jumpargeq 0, TRAP_ANIM_SNAP_TRAP, Status_Snap_Trap + jumpargeq 0, TRAP_ANIM_THUNDER_CAGE, Status_Thunder_Cage goto Status_BindWrap Status_BindWrap: loadspritegfx ANIM_TAG_TENDRILS @@ -24549,6 +24550,10 @@ Status_Clamp: waitforvisualfinish end +Status_Thunder_Cage: + @ TODO + goto Move_THUNDER_CAGE + Status_Snap_Trap: @ placeholder goto Move_BITE diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 4316191a2..46e229a31 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -583,6 +583,7 @@ #define TRAP_ANIM_MAGMA_STORM 5 #define TRAP_ANIM_INFESTATION 6 #define TRAP_ANIM_SNAP_TRAP 7 +#define TRAP_ANIM_THUNDER_CAGE 8 // Weather defines for battle animation scripts. #define ANIM_WEATHER_NONE 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index e55207753..f4fd589db 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -651,8 +651,9 @@ #define STRINGID_ITEMRESTOREDSPECIESHEALTH 649 #define STRINGID_ITEMCUREDSPECIESSTATUS 650 #define STRINGID_ITEMRESTOREDSPECIESPP 651 +#define STRINGID_THUNDERCAGETRAPPED 652 -#define BATTLESTRINGS_COUNT 652 +#define BATTLESTRINGS_COUNT 653 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, @@ -917,16 +918,17 @@ #define B_MSG_TERRAINENDS_COUNT 4 // gWrappedStringIds -#define B_MSG_WRAPPED_BIND 0 -#define B_MSG_WRAPPED_WRAP 1 -#define B_MSG_WRAPPED_FIRE_SPIN 2 -#define B_MSG_WRAPPED_CLAMP 3 -#define B_MSG_WRAPPED_WHIRLPOOL 4 -#define B_MSG_WRAPPED_SAND_TOMB 5 -#define B_MSG_WRAPPED_MAGMA_STORM 6 -#define B_MSG_WRAPPED_INFESTATION 7 -#define B_MSG_WRAPPED_SNAP_TRAP 8 -#define NUM_TRAPPING_MOVES 9 +#define B_MSG_WRAPPED_BIND 0 +#define B_MSG_WRAPPED_WRAP 1 +#define B_MSG_WRAPPED_FIRE_SPIN 2 +#define B_MSG_WRAPPED_CLAMP 3 +#define B_MSG_WRAPPED_WHIRLPOOL 4 +#define B_MSG_WRAPPED_SAND_TOMB 5 +#define B_MSG_WRAPPED_MAGMA_STORM 6 +#define B_MSG_WRAPPED_INFESTATION 7 +#define B_MSG_WRAPPED_SNAP_TRAP 8 +#define B_MSG_WRAPPED_THUNDER_CAGE 9 +#define NUM_TRAPPING_MOVES 10 // z effects #define B_MSG_Z_RESET_STATS 0 diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index a3197d447..3fc2000e4 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -2736,23 +2736,37 @@ void AnimTask_SetAttackerTargetLeftPos(u8 taskId) void AnimTask_GetTrappedMoveAnimId(u8 taskId) { - if (gBattleSpritesDataPtr->animationData->animArg == MOVE_FIRE_SPIN) + switch (gBattleSpritesDataPtr->animationData->animArg) + { + case MOVE_FIRE_SPIN: gBattleAnimArgs[0] = TRAP_ANIM_FIRE_SPIN; - else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_WHIRLPOOL) + break; + case MOVE_WHIRLPOOL: gBattleAnimArgs[0] = TRAP_ANIM_WHIRLPOOL; - else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_CLAMP) + break; + case MOVE_CLAMP: gBattleAnimArgs[0] = TRAP_ANIM_CLAMP; - else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_SAND_TOMB) + break; + case MOVE_SAND_TOMB: gBattleAnimArgs[0] = TRAP_ANIM_SAND_TOMB; - else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_MAGMA_STORM) + break; + case MOVE_MAGMA_STORM: gBattleAnimArgs[0] = TRAP_ANIM_MAGMA_STORM; - else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_INFESTATION) + break; + case MOVE_INFESTATION: gBattleAnimArgs[0] = TRAP_ANIM_INFESTATION; - else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_SNAP_TRAP) + break; + case MOVE_SNAP_TRAP: gBattleAnimArgs[0] = TRAP_ANIM_SNAP_TRAP; - else + break; + case MOVE_THUNDER_CAGE: + gBattleAnimArgs[0] = TRAP_ANIM_THUNDER_CAGE; + break; + default: gBattleAnimArgs[0] = TRAP_ANIM_BIND; - + break; + } + DestroyAnimVisualTask(taskId); } diff --git a/src/battle_message.c b/src/battle_message.c index e1122c7aa..21f7098f8 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -786,9 +786,11 @@ static const u8 sText_PkmnRevivedReadyToFight[] = _("{B_BUFF1} was revived and\n static const u8 sText_ItemRestoredSpeciesHealth[] = _("{B_BUFF1} had its\nHP restored!"); static const u8 sText_ItemCuredSpeciesStatus[] = _("{B_BUFF1} had\nits status healed!"); static const u8 sText_ItemRestoredSpeciesPP[] = _("{B_BUFF1} had its\nPP restored!"); +static const u8 sText_AtkTrappedDef[] = _("{B_ATK_NAME_WITH_PREFIX} trapped\nthe {B_DEF_NAME_WITH_PREFIX}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_THUNDERCAGETRAPPED - BATTLESTRINGS_TABLE_START] = sText_AtkTrappedDef, [STRINGID_ITEMRESTOREDSPECIESHEALTH - BATTLESTRINGS_TABLE_START] = sText_ItemRestoredSpeciesHealth, [STRINGID_ITEMCUREDSPECIESSTATUS - BATTLESTRINGS_TABLE_START] = sText_ItemCuredSpeciesStatus, [STRINGID_ITEMRESTOREDSPECIESPP - BATTLESTRINGS_TABLE_START] = sText_ItemRestoredSpeciesPP, @@ -1679,6 +1681,7 @@ const u16 gWrappedStringIds[NUM_TRAPPING_MOVES] = [B_MSG_WRAPPED_MAGMA_STORM] = STRINGID_TRAPPEDBYSWIRLINGMAGMA, // MOVE_MAGMA_STORM [B_MSG_WRAPPED_INFESTATION] = STRINGID_INFESTATION, // MOVE_INFESTATION [B_MSG_WRAPPED_SNAP_TRAP] = STRINGID_PKMNINSNAPTRAP, // MOVE_SNAP_TRAP + [B_MSG_WRAPPED_THUNDER_CAGE]= STRINGID_THUNDERCAGETRAPPED, // MOVE_THUNDER_CAGE }; const u16 gMistUsedStringIds[] =