Skip to content

Commit

Permalink
Add Infinite Repel
Browse files Browse the repository at this point in the history
  • Loading branch information
Beartime234 committed Mar 16, 2024
1 parent 4aaaa1c commit c1363ab
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 77 deletions.
8 changes: 8 additions & 0 deletions data/maps/LittlerootTown/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@
"elevation": 3,
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "LittlerootTown_EventScript_MaysHouseSign"
},
{
"type": "hidden_item",
"x": 16,
"y": 13,
"elevation": 0,
"item": "ITEM_INFINITE_REPEL",
"flag": "FLAG_TEMP_1"
}
]
}
67 changes: 0 additions & 67 deletions data/maps/map_groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -620,72 +620,5 @@
],
"gMapGroup_IndoorRoute124": [
"Route124_DivingTreasureHuntersHouse"
],
"connections_include_order": [
"LittlerootTown",
"OldaleTown",
"DewfordTown",
"LavaridgeTown",
"FallarborTown",
"VerdanturfTown",
"PacifidlogTown",
"PetalburgCity",
"SlateportCity",
"MauvilleCity",
"RustboroCity",
"FortreeCity",
"LilycoveCity",
"MossdeepCity",
"SootopolisCity",
"EverGrandeCity",
"Route101",
"Route102",
"Route103",
"Route104",
"Route105",
"Route106",
"Route107",
"Route108",
"Route109",
"Route110",
"Route111",
"Route112",
"Route113",
"Route114",
"Route115",
"Route116",
"Route117",
"Route118",
"Route119",
"Route120",
"Route121",
"Route122",
"Route123",
"Route124",
"Route125",
"Route126",
"Route127",
"Route128",
"Route129",
"Route130",
"Route131",
"Route132",
"Route133",
"Route134",
"Underwater_Route105",
"Underwater_Route124",
"Underwater_Route125",
"Underwater_Route126",
"Underwater_Route127",
"Underwater_Route128",
"Underwater_Route129",
"SafariZone_Northwest",
"SafariZone_North",
"SafariZone_Southwest",
"SafariZone_South",
"SafariZone_Northeast",
"SafariZone_Southeast",
"BattleFrontier_OutsideWest",
"BattleFrontier_OutsideEast"
]
}
2 changes: 1 addition & 1 deletion include/config/overworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// Overworld flags
// 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.
#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled.
#define OW_FLAG_NO_ENCOUNTER 0x20 // 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.

Expand Down
2 changes: 1 addition & 1 deletion include/constants/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define TEMP_FLAGS_END FLAG_TEMP_1F
#define NUM_TEMP_FLAGS (TEMP_FLAGS_END - TEMP_FLAGS_START + 1)

#define FLAG_UNUSED_0x020 0x20 // Unused Flag
#define FLAG_UNUSED_0x020 0x20 // Infinite Repel Flag
#define FLAG_UNUSED_0x021 0x21 // Unused Flag
#define FLAG_UNUSED_0x022 0x22 // Unused Flag
#define FLAG_UNUSED_0x023 0x23 // Unused Flag
Expand Down
5 changes: 4 additions & 1 deletion include/constants/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,10 @@
#define ITEM_814 814 // TWV0YWwgQWxsb3k=
#define ITEM_815 815 // U3RlbGxhciBUZXJhIFNoYXJk

#define ITEMS_COUNT 816
// Custom Items
#define ITEM_INFINITE_REPEL 816

#define ITEMS_COUNT 817
#define ITEM_FIELD_ARROW ITEMS_COUNT

// A special item id associated with "Cancel"/"Exit" etc. in a list of items or decorations
Expand Down
3 changes: 3 additions & 0 deletions include/item_use.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ enum {

bool32 CanThrowBall(void);

// Custom Items
void ItemUseOutOfBattle_InfiniteRepel(u8);

#endif // GUARD_ITEM_USE_H
4 changes: 4 additions & 0 deletions include/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3055,4 +3055,8 @@ extern const u8 gText_ExpShareOff[];

extern const u8 gText_BasePointsResetToZero[];

// Custom Strings
extern const u8 gText_InfiniteRepelOn[];
extern const u8 gText_InfiniteRepelOff[];

#endif // GUARD_STRINGS_H
4 changes: 4 additions & 0 deletions src/data/item_icon_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,10 @@ const u32 *const gItemIconTable[ITEMS_COUNT + 1][2] =
[ITEM_SWIFT_MOCHI] = {gItemIcon_Mochi, gItemIconPalette_SwiftMochi},
[ITEM_FRESH_START_MOCHI] = {gItemIcon_Mochi, gItemIconPalette_FreshStartMochi},
[ITEM_GLIMMERING_CHARM] = {gItemIcon_GlimmeringCharm, gItemIconPalette_GlimmeringCharm},

// Custom Items
[ITEM_INFINITE_REPEL] = {gItemIcon_Repel, gItemIconPalette_MaxRepel},

// Return to field arrow
[ITEMS_COUNT] = {gItemIcon_ReturnToFieldArrow, gItemIconPalette_ReturnToFieldArrow},
};
12 changes: 12 additions & 0 deletions src/data/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -9814,4 +9814,16 @@ const struct Item gItems[] =
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
},

// Custom Items
[ITEM_INFINITE_REPEL] =
{
.name = _("InfiniteRepel"),
.price = 0,
.importance = 1,
.description = sInfiniteRepelDesc,
.pocket = POCKET_KEY_ITEMS,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_InfiniteRepel,
},
};
5 changes: 5 additions & 0 deletions src/data/text/item_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3993,3 +3993,8 @@ static const u8 sGlimmeringCharmDesc[] = _(
"A charm that will\n"
"raise the shards\n"
"from Tera Raids.");

static const u8 sInfiniteRepelDesc[] = _(
"Repels wild Pokémon\n"
"for an infinite\n"
"number of steps.");
55 changes: 48 additions & 7 deletions src/data/wild_encounters.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,71 @@
{
"type": "land_mons",
"encounter_rates": [
20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1
20,
20,
10,
10,
10,
10,
5,
5,
4,
4,
1,
1
]
},
{
"type": "water_mons",
"encounter_rates": [
60, 30, 5, 4, 1
60,
30,
5,
4,
1
]
},
{
"type": "rock_smash_mons",
"encounter_rates": [
60, 30, 5, 4, 1
60,
30,
5,
4,
1
]
},
{
"type": "fishing_mons",
"encounter_rates": [
70, 30, 60, 20, 20, 40, 40, 15, 4, 1
70,
30,
60,
20,
20,
40,
40,
15,
4,
1
],
"groups": {
"old_rod": [0, 1],
"good_rod": [2, 3, 4],
"super_rod": [5, 6, 7, 8, 9]
"old_rod": [
0,
1
],
"good_rod": [
2,
3,
4
],
"super_rod": [
5,
6,
7,
8,
9
]
}
}
],
Expand Down
30 changes: 30 additions & 0 deletions src/item_use.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,4 +1447,34 @@ void Task_ItemUse_CloseMessageBoxAndReturnToField_VsSeeker(u8 taskId)
Task_CloseCantUseKeyItemMessage(taskId);
}

// Custom Items

void ItemUseOutOfBattle_InfiniteRepel(u8 taskId)
{
bool8 infiniteRepelOn = FlagGet(OW_FLAG_NO_ENCOUNTER);
if (!infiniteRepelOn)
{
FlagToggle(OW_FLAG_NO_ENCOUNTER);
PlaySE(SE_REPEL);
if(gTasks[taskId].tUsingRegisteredKeyItem){
DisplayItemMessageOnField(taskId, gText_InfiniteRepelOn, Task_CloseCantUseKeyItemMessage);
}
else{
DisplayItemMessage(taskId, 1, gText_InfiniteRepelOn, CloseItemMessage);
}
}
else
{
FlagToggle(OW_FLAG_NO_ENCOUNTER);
PlaySE(SE_PC_OFF);
if (gTasks[taskId].tUsingRegisteredKeyItem){
DisplayItemMessageOnField(taskId, gText_InfiniteRepelOff, Task_CloseCantUseKeyItemMessage);
}
else{
DisplayItemMessage(taskId, 1, gText_InfiniteRepelOn, CloseItemMessage);
}
}
}


#undef tUsingRegisteredKeyItem
4 changes: 4 additions & 0 deletions src/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1843,3 +1843,7 @@ const u8 gText_Berries[] = _("BERRIES");
const u8 gText_ExpShareOn[] = _("The Exp. Share has been turned on.{PAUSE_UNTIL_PRESS}");
const u8 gText_ExpShareOff[] = _("The Exp. Share has been turned off.{PAUSE_UNTIL_PRESS}");
const u8 gText_BasePointsResetToZero[] = _("{STR_VAR_1}'s base points\nwere all reset to zero!{PAUSE_UNTIL_PRESS}");

// Custom Strings
const u8 gText_InfiniteRepelOn[] = _("The Infinite Repel is now on.");
const u8 gText_InfiniteRepelOff[] = _("The Infinite Repel is now off.");

0 comments on commit c1363ab

Please sign in to comment.