-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fly from Pokenav #5679
base: upcoming
Are you sure you want to change the base?
Fly from Pokenav #5679
Conversation
Could you also make it work with the Town Map item? |
Currently, you can use the PokeNav to fly while indoors (and I'm assuming other areas where flying is usually not possible). |
include/config/overworld.h
Outdated
#define OW_FLAG_PAUSE_TIME 0 // If this flag is set and OW_USE_FAKE_RTC is enabled, seconds on the in-game clock will not advance. | ||
#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. | ||
#define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. | ||
#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. | ||
#define OW_FLAG_POKE_RIDER 0 // If this flag is set, the player will be able to use fly from the Pokenav Region Map section by pressing 'R' on a city/location they have been to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define OW_FLAG_PAUSE_TIME 0 // If this flag is set and OW_USE_FAKE_RTC is enabled, seconds on the in-game clock will not advance. | |
#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. | |
#define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. | |
#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. | |
#define OW_FLAG_POKE_RIDER 0 // If this flag is set, the player will be able to use fly from the Pokenav Region Map section by pressing 'R' on a city/location they have been to. | |
#define OW_FLAG_PAUSE_TIME 0 // If this flag is set and OW_USE_FAKE_RTC is enabled, seconds on the in-game clock will not advance. | |
#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. | |
#define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. | |
#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. | |
#define OW_FLAG_POKE_RIDER 0 // If this flag is set, the player will be able to use fly from the Pokenav Region Map section by pressing 'R' on a city/location they have been to. |
Match previous alignment
src/pokenav_region_map.c
Outdated
{ | ||
struct RegionMap* regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); | ||
|
||
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) | |
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) |
Handling for prevention of flying indoors etc.
src/pokenav_region_map.c
Outdated
@@ -215,6 +222,9 @@ static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state) | |||
case MAP_INPUT_B_BUTTON: | |||
state->callback = GetExitRegionMapMenuId; | |||
return POKENAV_MAP_FUNC_EXIT; | |||
case MAP_INPUT_R_BUTTON: | |||
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) | |
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) |
addressed @hedara90's comments, looking into the town map item functionality now! |
…kenav_region_map.c
added the prompt for flying from the town map. it replaces |
src/field_region_map.c
Outdated
u8 hoennOffset; | ||
u8 flyOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this outside of a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i figured it'd be better to set them when the FieldUpdateRegionMap() is called rather than every time the PrintTitleWindowText() function is called to speed up text display
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass them as arguments into PrintTitleWindowText()
instead then. We don't define variables outside of functions unless they are globals and those don't need to be globals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the function FieldUpdateRegionMap
is rerun each case which means that they are calculated each time regardless so you aren't gaining any speed improvement with this which means you could just calc it in PrintTitleWindowText
which will be better for speed because you aren't recalcing each time FieldUpdateRegionMap
is run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to know! i thought it was a big loop inside FieldUpdateRegionMap
lol
src/field_region_map.c
Outdated
@@ -45,6 +49,12 @@ static void VBCB_FieldUpdateRegionMap(void); | |||
static void MCB2_FieldUpdateRegionMap(void); | |||
static void FieldUpdateRegionMap(void); | |||
static void PrintRegionMapSecName(void); | |||
static void PrintTitleWindowText(void); | |||
|
|||
static const u8* const FlyPromptText = COMPOUND_STRING("{R_BUTTON}FLY"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be just a normal text string. We don't use compound strings like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually straight from the strings used in the pokenav helpbar, though there it's an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use Compound Strings for non duplicate strings, so single use strings. If you want this to use multiply times it should be a normal string so
static const u8 sFlyPropmtText[] = _("{R_BUTTON}FLY");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is technically a single use string- should it stay a compound string then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You use it twice right?
The reason we use compound strings is because they make code more readable and additionally save a little bit of space so in your case it should be moved where it is needed in the first place. Though iirc we've decided to keep using normal strings for function arguments so you would need to convert it either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, i see, yeah it's used once in the file, but twice in the function. fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm in this case should it be defined in the PrintTitleWindowText
func? since it's only used there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && FlagGet(OW_FLAG_POKE_RIDER) && | ||
Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && FlagGet(OW_FLAG_POKE_RIDER) && | |
Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) | |
if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && FlagGet(OW_FLAG_POKE_RIDER) | |
&& Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more things. I'll test ingame after that and should be ready for a merge
src/field_region_map.c
Outdated
AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, gText_Hoenn, hoennOffset, 1, 0, NULL); | ||
CopyWindowToVram(WIN_TITLE, COPYWIN_FULL); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
src/field_region_map.c
Outdated
if (sFieldRegionMapHandler->regionMap.mapSecType == MAPSECTYPE_CITY_CANFLY && | ||
FlagGet(OW_FLAG_POKE_RIDER) && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (sFieldRegionMapHandler->regionMap.mapSecType == MAPSECTYPE_CITY_CANFLY && | |
FlagGet(OW_FLAG_POKE_RIDER) && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) | |
if (sFieldRegionMapHandler->regionMap.mapSecType == MAPSECTYPE_CITY_CANFLY | |
&& FlagGet(OW_FLAG_POKE_RIDER) && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) |
src/region_map.c
Outdated
|
||
void SetFlyDestination(struct RegionMap* regionMap) | ||
{ | ||
u8 flyDestination = FilterFlyDestination(regionMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u8 flyDestination = FilterFlyDestination(regionMap); | |
u32 flyDestination = FilterFlyDestination(regionMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this one need to be a u8? void SetWarpDestinationToHealLocation(u8 healLocationId);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't. The compiler wastes an instruction and turns it into a u32 anyways so technically it would be better to change the healLocationId argument to a u32.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah rad- will adjust! ty!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should healLocationId
-> u32 be included in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, since you haven't touched the function I wouldn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
src/field_region_map.c
Outdated
u8 hoennOffset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38); | ||
u8 flyOffset = GetStringCenterAlignXOffset(FONT_NORMAL, FlyPromptText, 0x38); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u8 hoennOffset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38); | |
u8 flyOffset = GetStringCenterAlignXOffset(FONT_NORMAL, FlyPromptText, 0x38); | |
u32 hoennOffset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38); | |
u32 flyOffset = GetStringCenterAlignXOffset(FONT_NORMAL, FlyPromptText, 0x38); |
Lets the player press 'R' over locations they have visited to fly to them from the PokeNav Region Map.
Description
CB_ExitFlyMap()
to allow setting the fly destination correctly from other filesOW_FLAG_POKE_RIDER
to allow this feature to be disabledgSkipShowMonAnim
as an EWRAM variable to control whether the ShowMon animation plays or notpokenav_region_map.c
to handle flyingUpdateRegionMapHelpBarText()
so the HelpBarText can be easily synced with cursor movement and loading the map from the menuProcessRegionMapInput_*
functions#includes
and changed some static functions to non-static so they could be declared in the header filesremade the branch and manually copy-pasted the correct changes. cleaned, compiled, tested.
Feature(s) this PR does NOT handle:
Adding other interactions in the overworld to handle other HM moves, this is specifically for
Fly
Discord contact info
@khbsd