By devolov
If you find a bug, message me in Discord (devolov#4853).
Goal: Make it so all HMs can be used without a Pokemon knowing them.
If a Pokemon in your party knows the move, then the game will behave as normal.
If not, then the game will check if the player has that HM in their item pocket. If so, it'll pretend the first Pokemon in your party does and continue.
Any Pokemon can Use Field Move so Long as HM is in Bag
Only Pokemon that can Learn HM can Use Field Move so Long as HM is in Bag
Pokemon who can Learn Fly and Flash Can Use it if the HM is in the Bag
Using Flash automatically
Any Pokemon can Use Field Move so Long as HM is in Bag
------------------------------- src/party_menu.c -------------------------------
index 984d965f2..9e74f20fa 100644
@@ -4695,8 +4695,51 @@ bool8 MonKnowsMove(struct Pokemon *mon, u16 move)
}
return FALSE;
}
+bool8 PlayerHasMove(u16 move)
+{
+ u16 item;
+ switch (move)
+ {
+ case MOVE_SECRET_POWER:
+ item = ITEM_TM43;
+ break;
+ case MOVE_CUT:
+ item = ITEM_HM01;
+ break;
+ case MOVE_FLY:
+ item = ITEM_HM02;
+ break;
+ case MOVE_SURF:
+ item = ITEM_HM03;
+ break;
+ case MOVE_STRENGTH:
+ item = ITEM_HM04;
+ break;
+ case MOVE_FLASH:
+ item = ITEM_HM05;
+ break;
+ case MOVE_ROCK_SMASH:
+ item = ITEM_HM06;
+ break;
+ case MOVE_WATERFALL:
+ item = ITEM_HM07;
+ break;
+ case MOVE_DIVE:
+ item = ITEM_HM08;
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+ return CheckBagHasItem(item, 1);
+}
+
static void DisplayLearnMoveMessage(const u8 *str)
{
StringExpandPlaceholders(gStringVar4, str);
DisplayPartyMenuMessage(gStringVar4, TRUE);
----------------------------- include/party_menu.h -----------------------------
index b53bcb5c3..b49e44b90 100644
@@ -54,8 +54,9 @@ void ItemUseCB_PPRecovery(u8 taskId, TaskFunc task);
void ItemUseCB_PPUp(u8 taskId, TaskFunc task);
u16 ItemIdToBattleMoveId(u16 item);
bool8 IsMoveHm(u16 move);
bool8 MonKnowsMove(struct Pokemon *mon, u16 move);
+bool8 PlayerHasMove(u16 move);
void ItemUseCB_TMHM(u8 taskId, TaskFunc task);
void ItemUseCB_RareCandy(u8 taskId, TaskFunc task);
void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task);
void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task);
--------------------------------- src/scrcmd.c ---------------------------------
index f36987570..048853f11 100644
@@ -1756,8 +1757,12 @@ bool8 ScrCmd_checkpartymove(struct ScriptContext *ctx)
gSpecialVar_0x8004 = species;
break;
}
}
+ if (gSpecialVar_Result == PARTY_SIZE && PlayerHasMove(moveId)){ // If no mon have the move, but the player has the HM in bag, use the first mon
+ gSpecialVar_Result = 0;
+ gSpecialVar_0x8004 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL);
+ }
return FALSE;
}
bool8 ScrCmd_addmoney(struct ScriptContext *ctx)
-------------------------- src/field_control_avatar.c --------------------------
index 3fb9be576..6b7ee9e35 100644
@@ -34,8 +34,9 @@
#include "constants/field_poison.h"
#include "constants/map_types.h"
#include "constants/songs.h"
#include "constants/trainer_hill.h"
+#include "constants/items.h"
static EWRAM_DATA u8 sWildEncounterImmunitySteps = 0;
static EWRAM_DATA u16 sPrevMetatileBehavior = 0;
@@ -470,9 +471,9 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me
}
static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metatileBehavior, u8 direction)
{
- if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE)
+ if (FlagGet(FLAG_BADGE05_GET) == TRUE && (PartyHasMonWithSurf() == TRUE || CheckBagHasItem(ITEM_HM03 ,1)) && IsPlayerFacingSurfableFishableWater() == TRUE)
if (MetatileBehavior_IsWaterfall(metatileBehavior) == TRUE)
Only Pokemon that can Learn HM can Use Field Move so Long as HM is in Bag
------------------------------- src/party_menu.c -------------------------------
index 984d965f2..c180c93dc 100644
@@ -4695,8 +4695,51 @@ bool8 MonKnowsMove(struct Pokemon *mon, u16 move)
}
return FALSE;
}
+int MoveToHM(u16 move)
+{
+ u8 i;
+ int item;
+ switch (move)
+ {
+ case MOVE_SECRET_POWER:
+ item = ITEM_TM43;
+ break;
+ case MOVE_CUT:
+ item = ITEM_HM01;
+ break;
+ case MOVE_FLY:
+ item = ITEM_HM02;
+ break;
+ case MOVE_SURF:
+ item = ITEM_HM03;
+ break;
+ case MOVE_STRENGTH:
+ item = ITEM_HM04;
+ break;
+ case MOVE_FLASH:
+ item = ITEM_HM05;
+ break;
+ case MOVE_ROCK_SMASH:
+ item = ITEM_HM06;
+ break;
+ case MOVE_WATERFALL:
+ item = ITEM_HM07;
+ break;
+ case MOVE_DIVE:
+ item = ITEM_HM08;
+ break;
+ default:
+ item = 0;
+ break;
+ }
+ return item;
+}
+
static void DisplayLearnMoveMessage(const u8 *str)
{
StringExpandPlaceholders(gStringVar4, str);
DisplayPartyMenuMessage(gStringVar4, TRUE);
----------------------------- include/party_menu.h -----------------------------
index b53bcb5c3..1ae49e1da 100644
@@ -54,8 +54,9 @@ void ItemUseCB_PPRecovery(u8 taskId, TaskFunc task);
void ItemUseCB_PPUp(u8 taskId, TaskFunc task);
u16 ItemIdToBattleMoveId(u16 item);
bool8 IsMoveHm(u16 move);
bool8 MonKnowsMove(struct Pokemon *mon, u16 move);
+int MoveToHM(u16 move);
void ItemUseCB_TMHM(u8 taskId, TaskFunc task);
void ItemUseCB_RareCandy(u8 taskId, TaskFunc task);
void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task);
void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task);
--------------------------------- src/scrcmd.c ---------------------------------
index f36987570..5ed43b140 100644
@@ -51,8 +51,9 @@
#include "tv.h"
#include "window.h"
#include "constants/event_objects.h"
#include "constants/text.h"
+#include "constants/items.h"
typedef u16 (*SpecialFunc)(void);
typedef void (*NativeFunc)(void);
@@ -1756,8 +1757,23 @@ bool8 ScrCmd_checkpartymove(struct ScriptContext *ctx)
gSpecialVar_0x8004 = species;
break;
}
}
+ if (gSpecialVar_Result == PARTY_SIZE && (CheckBagHasItem(MoveToHM(moveId), 1))){
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL);
+ if (!species)
+ break;
+ if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && CanMonLearnTMHM(&gPlayerParty[i], MoveToHM(moveId) - ITEM_TM01))
+ {
+ gSpecialVar_Result = i;
+ gSpecialVar_0x8004 = species;
+ break;
+ }
+ }
+ }
return FALSE;
}
bool8 ScrCmd_addmoney(struct ScriptContext *ctx)
-------------------------- src/field_control_avatar.c --------------------------
index 3fb9be576..6b7ee9e35 100644
@@ -34,8 +34,9 @@
#include "constants/field_poison.h"
#include "constants/map_types.h"
#include "constants/songs.h"
#include "constants/trainer_hill.h"
+#include "constants/items.h"
static EWRAM_DATA u8 sWildEncounterImmunitySteps = 0;
static EWRAM_DATA u16 sPrevMetatileBehavior = 0;
@@ -470,9 +471,9 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me
}
static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metatileBehavior, u8 direction)
{
- if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE)
+ if ((FlagGet(FLAG_BADGE05_GET) == TRUE || PartyHasMonWithSurf() == TRUE || CheckBagHasItem(ITEM_HM03 ,1)) && IsPlayerFacingSurfableFishableWater() == TRUE)
if (MetatileBehavior_IsWaterfall(metatileBehavior) == TRUE)
------------------------------- src/overworld.c -------------------------------
index d43a1f964..20199397e 100644
@@ -70,8 +70,10 @@
#include "constants/region_map_sections.h"
#include "constants/songs.h"
#include "constants/trainer_hill.h"
#include "constants/weather.h"
+#include "item.h"
+#include "constants/items.h"
struct CableClubPlayer
{
u8 playerId;
@@ -177,8 +179,9 @@ static void FieldClearVBlankHBlankCallbacks(void);
static void TransitionMapMusic(void);
static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *, u16, u8);
static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *, u8, u16, u8);
static u16 GetCenterScreenMetatileBehavior(void);
+static bool8 CanLearnFlashInParty(void);
void InitMapView(void);
// IWRAM bss vars
static void *sUnusedOverworldCallback;
@@ -1067,13 +1070,25 @@ bool32 Overworld_IsBikingAllowed(void)
else
return TRUE;
}
+static bool8 CanLearnFlashInParty(void)
+{
+ u8 i;
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (!GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL))
+ break;
+ if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && CanMonLearnTMHM(&gPlayerParty[i], ITEM_HM05 - ITEM_TM01))
+ return TRUE;
+ }
+ return FALSE;
+}
+
Fly Still Needs to be Added in.
Also, Flash needs to be used on Registeel's tomb.
For those, I followed this tutorial that ScyrousFX did a great job making. But the tutorial doesn't include an HM checking the bag, so I added it.
------------------------------- src/party_menu.c -------------------------------
index eef081849..920f672a8 100755
@@ -2613,14 +2613,24 @@ static void SetPartyMonFieldSelectionActions(struct Pokemon *mons, u8 slotId)
for (j = 0; sFieldMoves[j] != FIELD_MOVES_COUNT; j++)
{
if (GetMonData(&mons[slotId], i + MON_DATA_MOVE1) == sFieldMoves[j])
{
- AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, j + MENU_FIELD_MOVES);
+ // If Mon already knows FLY and the HM is in the bag, prevent it from being added to action list
+ if (sFieldMoves[j] != MOVE_FLY || !CheckBagHasItem(ITEM_HM02_FLY, 1)){
+ // If Mon already knows FLASH and the HM is in the bag, prevent it from being added to action list
+ if (sFieldMoves[j] != MOVE_FLASH || !CheckBagHasItem(ITEM_HM05_FLASH, 1)){
+ AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, j + MENU_FIELD_MOVES);
+ }
+ }
break;
}
}
}
+ // If Mon can learn HM02 and action list consists of < 4 moves, add FLY to action list
+ if (sPartyMenuInternal->numActions < 5 && CanMonLearnTMHM(&mons[slotId], ITEM_HM02 - ITEM_TM01) && CheckBagHasItem(ITEM_HM02_FLY, 1))
+ AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, 5 + MENU_FIELD_MOVES);
+ // If Mon can learn HM05 and action list consists of < 4 moves, add FLASH to action list
+ if (sPartyMenuInternal->numActions < 5 && CanMonLearnTMHM(&mons[slotId], ITEM_HM05 - ITEM_TM01) && CheckBagHasItem(ITEM_HM05_FLASH, 1))
+ AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, 1 + MENU_FIELD_MOVES);
if (!InBattlePike())
{
if (GetMonData(&mons[1], MON_DATA_SPECIES) != SPECIES_NONE)
AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, MENU_SWITCH);
Using Flash automatically
You can set the game to use Flash automatically after entering a cave with this change to src/overworld.c
.
If you were using Any Pokemon can Use Field Move so Long as HM is in Bag, use this one.
------------------------------- src/overworld.c -------------------------------
index d59417232..326f9073a 100644
@@ -65,8 +65,10 @@
#include "constants/region_map_sections.h"
#include "constants/songs.h"
#include "constants/trainer_hill.h"
#include "constants/weather.h"
+#include "item.h"
+#include "constants/items.h"
struct CableClubPlayer
{
u8 playerId;
@@ -972,8 +974,10 @@ bool32 Overworld_IsBikingAllowed(void)
// Flash level of 7 is the smallest flash radius
// Flash level of 8 is fully black
void SetDefaultFlashLevel(void)
{
+ if (CheckBagHasItem(ITEM_HM05_FLASH ,1))
+ FlagSet(FLAG_SYS_USE_FLASH);
if (!gMapHeader.cave)
gSaveBlock1Ptr->flashLevel = 0;
else if (FlagGet(FLAG_SYS_USE_FLASH))
gSaveBlock1Ptr->flashLevel = 1;
If you were using Only Pokemon that can Learn HM can Use Field Move so Long as HM is in Bag, use this one.
------------------------------- src/overworld.c -------------------------------
index d59417232..326f9073a 100644
@@ -65,8 +65,10 @@
#include "constants/region_map_sections.h"
#include "constants/songs.h"
#include "constants/trainer_hill.h"
#include "constants/weather.h"
+#include "item.h"
+#include "constants/items.h"
struct CableClubPlayer
{
u8 playerId;
@@ -972,8 +974,10 @@ bool32 Overworld_IsBikingAllowed(void)
// Flash level of 7 is the smallest flash radius
// Flash level of 8 is fully black
void SetDefaultFlashLevel(void)
{
+ if (CheckBagHasItem(ITEM_HM05_FLASH ,1) && CanLearnFlashInParty())
+ FlagSet(FLAG_SYS_USE_FLASH);
if (!gMapHeader.cave)
gSaveBlock1Ptr->flashLevel = 0;
else if (FlagGet(FLAG_SYS_USE_FLASH))
gSaveBlock1Ptr->flashLevel = 1;