Skip to content

Commit

Permalink
Adds Dexnav (#4818)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bassoonian authored Jan 3, 2025
2 parents ec1876b + 9707d09 commit 9199b6f
Show file tree
Hide file tree
Showing 57 changed files with 3,180 additions and 75 deletions.
1 change: 1 addition & 0 deletions data/event_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -1151,3 +1151,4 @@ EventScript_VsSeekerChargingDone::
.include "data/scripts/follower.inc"
.include "data/text/save.inc"
.include "data/text/birch_speech.inc"
.include "data/scripts/dexnav.inc"
21 changes: 13 additions & 8 deletions data/field_effect_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ gFieldEffectScriptPointers::
.4byte gFieldEffectScript_JumpSmallSplash @ FLDEFF_JUMP_SMALL_SPLASH
.4byte gFieldEffectScript_LongGrass @ FLDEFF_LONG_GRASS
.4byte gFieldEffectScript_JumpLongGrass @ FLDEFF_JUMP_LONG_GRASS
.4byte gFieldEffectScript_UnusedGrass @ FLDEFF_UNUSED_GRASS
.4byte gFieldEffectScript_UnusedGrass2 @ FLDEFF_UNUSED_GRASS_2
.4byte gFieldEffectScript_UnusedSand @ FLDEFF_UNUSED_SAND
.4byte gFieldEffectScript_ShakingGrass @ FLDEFF_SHAKING_GRASS
.4byte gFieldEffectScript_ShakingGrass2 @ FLDEFF_SHAKING_LONG_GRASS
.4byte gFieldEffectScript_UnusedSand @ FLDEFF_SAND_HOLE
.4byte gFieldEffectScript_WaterSurfacing @ FLDEFF_WATER_SURFACING
.4byte gFieldEffectScript_BerryTreeGrowthSparkle @ FLDEFF_BERRY_TREE_GROWTH_SPARKLE
.4byte gFieldEffectScript_DeepSandFootprints @ FLDEFF_DEEP_SAND_FOOTPRINTS
Expand Down Expand Up @@ -79,7 +79,8 @@ gFieldEffectScriptPointers::
.4byte gFieldEffectScript_TracksSlither @ FLDEFF_TRACKS_SLITHER
.4byte gFieldEffectScript_TracksBug @ FLDEFF_TRACKS_BUG
.4byte gFieldEffectScript_TracksSpot @ FLDEFF_TRACKS_SPOT

.4byte gFieldEffectScript_CaveDust @ FLDEFF_CAVE_DUST

gFieldEffectScript_ExclamationMarkIcon1::
field_eff_callnative FldEff_ExclamationMarkIcon
field_eff_end
Expand Down Expand Up @@ -156,12 +157,12 @@ gFieldEffectScript_JumpLongGrass::
field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_JumpLongGrass
field_eff_end

gFieldEffectScript_UnusedGrass::
field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_UnusedGrass
gFieldEffectScript_ShakingGrass::
field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_ShakingGrass
field_eff_end

gFieldEffectScript_UnusedGrass2::
field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_UnusedGrass2
gFieldEffectScript_ShakingGrass2::
field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect1, FldEff_ShakingGrass2
field_eff_end

gFieldEffectScript_UnusedSand::
Expand Down Expand Up @@ -374,3 +375,7 @@ gFieldEffectScript_TracksSpot::
gFieldEffectScript_TracksSlither::
field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_TracksSlither
field_eff_end

gFieldEffectScript_CaveDust::
field_eff_loadfadedpal_callnative gSpritePalette_CaveDust FldEff_CaveDust
field_eff_end
47 changes: 47 additions & 0 deletions data/scripts/dexnav.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
EventScript_StartDexNavBattle::
lock
playse SE_PIN
applymovement OBJ_EVENT_ID_PLAYER Common_Movement_ExclamationMark
waitmovement 0
waitse
dowildbattle
release
end

EventScript_NotFoundNearby::
msgbox sText_NotFoundNearby, MSGBOX_SIGN
end

EventScript_MovedTooFast::
msgbox sText_TryMovingSlower, MSGBOX_SIGN
end

EventScript_PokemonGotAway::
msgbox sText_PokemonGotAway, MSGBOX_SIGN
end

EventScript_LostSignal::
msgbox sText_LostSignal, MSGBOX_SIGN
end

EventScript_TooDark::
msgbox sText_TooDark, MSGBOX_SIGN
end

sText_NotFoundNearby:
.string "It couldn't be found nearby.\n"
.string "Try looking in a different area!$"

sText_TryMovingSlower:
.string "The Pokémon got away!\n"
.string "Try moving more slowly.$"

sText_PokemonGotAway:
.string "The Pokémon got away!$"

sText_LostSignal:
.string "There is no reaction.\n"
.string "The signal was lost!$"

sText_TooDark:
.string "It's too dark to search\nfor a Pokémon!$"
Binary file added graphics/dexnav/captured_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/dexnav/cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions graphics/dexnav/gui.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
JASC-PAL
0100
16
0 0 0
255 255 255
217 73 73
4 4 4
1 81 113
1 121 193
119 177 75
93 97 101
91 179 211
153 32 32
111 141 81
173 173 173
187 217 167
75 147 189
177 219 235
105 22 22
Binary file added graphics/dexnav/gui_tilemap.bin
Binary file not shown.
Binary file added graphics/dexnav/gui_tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/dexnav/hidden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/dexnav/hidden_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/dexnav/no_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/dexnav/owned_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/dexnav/star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/dexnav/vision.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions graphics/field_effects/palettes/cave_dust.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
JASC-PAL
0100
16
255 1 255
159 122 85
207 189 157
199 181 149
114 88 61
132 101 70
199 173 141
225 209 193
189 165 133
181 149 115
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
Binary file added graphics/field_effects/pics/cave_dust.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions graphics/text_window/dexnav_pal.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
JASC-PAL
0100
16
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 6
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
46 46 46
0 0 0
255 255 255
72 changes: 72 additions & 0 deletions include/config/dexnav.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#ifndef GUARD_CONFIG_DEXNAV_H
#define GUARD_CONFIG_DEXNAV_H

#define DEXNAV_ENABLED FALSE // Whether or not DexNav is enabled. If TRUE, flags/vars below must all be non-zero
#define USE_DEXNAV_SEARCH_LEVELS FALSE /* WARNING: POSSIBLY EXCEEDS SAVEBLOCK SPACE! REQUIRES 1 BYTE PER SPECIES */

// Flag/var defines
#define FLAG_SYS_DEXNAV_SEARCH 0 // Searching for mon
#define FLAG_SYS_DEXNAV_GET 0 // DexNav shows in start menu
#define FLAG_SYS_DETECTOR_MODE 0 // Allow player to find hidden mons
#define VAR_DEXNAV_SPECIES 0 // Registered DexNav species
#define VAR_DEXNAV_STEP_COUNTER 0 // Steps for finding hidden pokemon

// Search parameters
#define DEXNAV_TIMEOUT 15 // 15 seconds is the time out. Max of 1092 seconds allowed
#define SNEAKING_PROXIMITY 4 // Tile amount
#define CREEPING_PROXIMITY 2
#define MAX_PROXIMITY 20

#define DEXNAV_CHAIN_MAX 100 // maximum chain value

// hidden pokemon options - an approximation of values to due to lack of available data
#define HIDDEN_MON_STEP_COUNT 100 // Look for hidden pokemon every x steps
#define HIDDEN_MON_SEARCH_RATE 25 // x% chance of finding hidden pokemon every x steps
#define HIDDEN_MON_PROBABILTY 15 // x% chance of finding hidden mon compared to regular encounter data

//// SEARCH PROBABILITIES
// See https://bulbapedia.bulbagarden.net/wiki/DexNav#Benefits
// Chance of encountering egg move at search levels
#define SEARCHLEVEL0_MOVECHANCE 0
#define SEARCHLEVEL5_MOVECHANCE 21
#define SEARCHLEVEL10_MOVECHANCE 46
#define SEARCHLEVEL25_MOVECHANCE 58
#define SEARCHLEVEL50_MOVECHANCE 63
#define SEARCHLEVEL100_MOVECHANCE 83
// Chance of encountering Hidden Abilities at search levels
#define SEARCHLEVEL0_ABILITYCHANCE 0
#define SEARCHLEVEL5_ABILITYCHANCE 0
#define SEARCHLEVEL10_ABILITYCHANCE 5
#define SEARCHLEVEL25_ABILITYCHANCE 15
#define SEARCHLEVEL50_ABILITYCHANCE 20
#define SEARCHLEVEL100_ABILITYCHANCE 23
// Chance of encountering held item
#define SEARCHLEVEL0_ITEM 0
#define SEARCHLEVEL5_ITEM 0
#define SEARCHLEVEL10_ITEM 1
#define SEARCHLEVEL25_ITEM 7
#define SEARCHLEVEL50_ITEM 6
#define SEARCHLEVEL100_ITEM 12
// Chance of encountering one star potential
#define SEARCHLEVEL0_ONESTAR 0
#define SEARCHLEVEL5_ONESTAR 14
#define SEARCHLEVEL10_ONESTAR 17
#define SEARCHLEVEL25_ONESTAR 17
#define SEARCHLEVEL50_ONESTAR 15
#define SEARCHLEVEL100_ONESTAR 8
// Chance of encountering two star potential
#define SEARCHLEVEL0_TWOSTAR 0
#define SEARCHLEVEL5_TWOSTAR 1
#define SEARCHLEVEL10_TWOSTAR 9
#define SEARCHLEVEL25_TWOSTAR 16
#define SEARCHLEVEL50_TWOSTAR 17
#define SEARCHLEVEL100_TWOSTAR 24
// Chance of encountering three star potential
#define SEARCHLEVEL0_THREESTAR 0
#define SEARCHLEVEL5_THREESTAR 0
#define SEARCHLEVEL10_THREESTAR 1
#define SEARCHLEVEL25_THREESTAR 7
#define SEARCHLEVEL50_THREESTAR 6
#define SEARCHLEVEL100_THREESTAR 12

#endif // GUARD_CONFIG_DEXNAV_H
9 changes: 6 additions & 3 deletions include/constants/field_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#define FLDEFF_JUMP_SMALL_SPLASH 16
#define FLDEFF_LONG_GRASS 17
#define FLDEFF_JUMP_LONG_GRASS 18
#define FLDEFF_UNUSED_GRASS 19
#define FLDEFF_UNUSED_GRASS_2 20
#define FLDEFF_UNUSED_SAND 21
#define FLDEFF_SHAKING_GRASS 19
#define FLDEFF_SHAKING_LONG_GRASS 20
#define FLDEFF_SAND_HOLE 21
#define FLDEFF_WATER_SURFACING 22
#define FLDEFF_BERRY_TREE_GROWTH_SPARKLE 23
#define FLDEFF_DEEP_SAND_FOOTPRINTS 24
Expand Down Expand Up @@ -75,6 +75,7 @@
#define FLDEFF_TRACKS_SLITHER 70
#define FLDEFF_TRACKS_SPOT 71
#define FLDEFF_TRACKS_BUG 72
#define FLDEFF_CAVE_DUST 73

#define FLDEFFOBJ_SHADOW_S 0
#define FLDEFFOBJ_SHADOW_M 1
Expand Down Expand Up @@ -116,6 +117,7 @@
#define FLDEFFOBJ_TRACKS_SLITHER 37
#define FLDEFFOBJ_TRACKS_SPOT 38
#define FLDEFFOBJ_TRACKS_BUG 39
#define FLDEFFOBJ_CAVE_DUST 40

#define FLDEFF_PAL_TAG_CUT_GRASS 0x1000
#define FLDEFF_PAL_TAG_SECRET_POWER_TREE 0x1003
Expand All @@ -129,5 +131,6 @@
#define FLDEFF_PAL_TAG_SMALL_SPARKLE 0x100F
#define FLDEFF_PAL_TAG_HOF_MONITOR 0x1010
#define FLDEFF_PAL_TAG_UNKNOWN 0x1011
#define FLDEFF_PAL_TAG_CAVE_DUST 0x1012

#endif // GUARD_FIELD_EFFECT_CONSTANTS_H
3 changes: 2 additions & 1 deletion include/constants/game_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
#define GAME_STAT_ENTERED_HOT_SPRINGS 49
#define GAME_STAT_NUM_UNION_ROOM_BATTLES 50
#define GAME_STAT_PLAYED_BERRY_CRUSH 51
#define GAME_STAT_DEXNAV_SCANNED 52

#define NUM_USED_GAME_STATS 52
#define NUM_USED_GAME_STATS 53
#define NUM_GAME_STATS 64

#endif // GUARD_CONSTANTS_GAME_STAT_H
1 change: 1 addition & 0 deletions include/constants/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "config/caps.h"
#include "config/pokemon.h"
#include "config/overworld.h"
#include "config/dexnav.h"

// Invalid Versions show as "----------" in Gen 4 and Gen 5's summary screen.
// In Gens 6 and 7, invalid versions instead show "a distant land" in the summary screen.
Expand Down
1 change: 1 addition & 0 deletions include/constants/wild_encounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define WATER_WILD_COUNT 5
#define ROCK_WILD_COUNT 5
#define FISH_WILD_COUNT 10
#define HIDDEN_WILD_COUNT 3

#define NUM_ALTERING_CAVE_TABLES 9

Expand Down
1 change: 1 addition & 0 deletions include/daycare.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ void ShowDaycareLevelMenu(void);
void ChooseSendDaycareMon(void);
u8 GetEggMovesBySpecies(u16 species, u16 *eggMoves);
bool8 SpeciesCanLearnEggMove(u16 species, u16 move);
u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves);

#endif // GUARD_DAYCARE_H
77 changes: 77 additions & 0 deletions include/dexnav.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#ifndef GUARD_DEXNAV_H
#define GUARD_DEXNAV_H

#include "config/dexnav.h"

// GUI Info
#define ROW_WATER 0
#define ROW_LAND_TOP 1
#define ROW_LAND_BOT 2
#define ROW_HIDDEN 3
#define ROWS_COUNT 4

#define ROW_WATER_ICON_X 30
#define ROW_WATER_ICON_Y 35

#define ROW_LAND_ICON_X 20
#define ROW_LAND_TOP_ICON_Y 72
#define ROW_LAND_BOT_ICON_Y (ROW_LAND_TOP_ICON_Y + 28)

#define ROW_HIDDEN_ICON_X 52
#define ROW_HIDDEN_ICON_Y 138

#define ENCOUNTER_TYPE_LAND 0
#define ENCOUNTER_TYPE_WATER 1
#define ENCOUNTER_TYPE_HIDDEN 2 // Get from species

#define COL_WATER_COUNT 5
#define COL_LAND_COUNT 6
#define COL_HIDDEN_COUNT 3

#define COL_WATER_MAX (COL_WATER_COUNT - 1)
#define COL_LAND_MAX (COL_LAND_COUNT - 1)
#define COL_HIDDEN_MAX (COL_HIDDEN_COUNT - 1)

// SEARCH INFO
#define SCANSTART_X 0
#define SCANSTART_Y 0
#define SCANSIZE_X 12
#define SCANSIZE_Y 12

#define SPECIES_INFO_Y 5
#define TYPE_ICONS_Y (SPECIES_INFO_Y + 24)
#define SEARCH_LEVEL_Y (TYPE_ICONS_Y + 24)
#define HA_INFO_Y (SEARCH_LEVEL_Y + 24)
#define CHAIN_BONUS_Y (HA_INFO_Y + 24)

#define MON_LEVEL_NONEXISTENT 255 // If mon not in area GetEncounterLevel returns this to exit the search

// GUI tags
#define ICON_PAL_TAG 56000
#define ICON_GFX_TAG 55130
#define SELECTION_CURSOR_TAG 0x4005
#define CAPTURED_ALL_TAG 0x4002

// Search tags
#define OWNED_ICON_TAG 0x4003
#define HIDDEN_SEARCH_TAG SELECTION_CURSOR_TAG
#define HIDDEN_MON_ICON_TAG 0x4006
#define LIT_STAR_TILE_TAG 0x4010
#define HELD_ITEM_TAG 0xd750

// DexNav search variable
#define DEXNAV_MASK_SPECIES 0x3FFF // First 14 bits
#define DEXNAV_MASK_ENVIRONMENT 0xC000 // Last two bit

void EndDexNavSearch(u8 taskId);
void Task_OpenDexNavFromStartMenu(u8 taskId);
bool8 TryStartDexNavSearch(void);
void TryIncrementSpeciesSearchLevel(u16 dexNum);
void ResetDexNavSearch(void);
bool8 TryFindHiddenPokemon(void);
u32 CalculateDexNavShinyRolls(void);
void IncrementDexNavChain(void);

extern bool8 gDexNavBattle;

#endif // GUARD_DEXNAV_H
1 change: 1 addition & 0 deletions include/event_object_movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ u8 GetJumpMovementAction(u32);
u8 GetJump2MovementAction(u32);
u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority);
u8 CreateCopySpriteAt(struct Sprite *sprite, s16 x, s16 y, u8 subpriority);
bool8 IsElevationMismatchAt(u8, s16, s16);

u8 MovementType_WanderAround_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_WanderAround_Step1(struct ObjectEvent *, struct Sprite *);
Expand Down
Loading

0 comments on commit 9199b6f

Please sign in to comment.