From f8b40754c70679bb3ec4c0611613a0658f679225 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 18 Nov 2017 12:27:10 +0100 Subject: [PATCH] wild encounter done --- asm/wild_encounter.s | 9 --------- include/wild_encounter.h | 7 ++++++- ld_script.txt | 1 - src/wild_encounter.c | 39 +++++++++++++++++---------------------- 4 files changed, 23 insertions(+), 33 deletions(-) delete mode 100644 asm/wild_encounter.s diff --git a/asm/wild_encounter.s b/asm/wild_encounter.s deleted file mode 100644 index da4dca0ed4..0000000000 --- a/asm/wild_encounter.s +++ /dev/null @@ -1,9 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - .align 2, 0 @ Don't pad with nop. diff --git a/include/wild_encounter.h b/include/wild_encounter.h index c9d7c3fa1f..55bbaa7dde 100644 --- a/include/wild_encounter.h +++ b/include/wild_encounter.h @@ -1,6 +1,11 @@ #ifndef GUARD_WILD_ENCOUNTER_H #define GUARD_WILD_ENCOUNTER_H +#define LAND_WILD_COUNT 12 +#define WATER_WILD_COUNT 5 +#define ROCK_WILD_COUNT 5 +#define FISH_WILD_COUNT 10 + struct WildPokemon { u8 minLevel; @@ -27,7 +32,7 @@ struct WildPokemonHeader extern const struct WildPokemonHeader gWildMonHeaders[]; void DisableWildEncounters(bool8 disabled); -bool8 StandardWildEncounter(u16 a, u16 b); +bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavior); void ScrSpecial_RockSmashWildEncounter(void); bool8 SweetScentWildEncounter(void); bool8 DoesCurrentMapHaveFishingMons(void); diff --git a/ld_script.txt b/ld_script.txt index b04f2f9afe..7526cd4ea0 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -125,7 +125,6 @@ SECTIONS { asm/cable_club.o(.text); asm/trainer_see.o(.text); src/wild_encounter.o(.text); - asm/wild_encounter.o(.text); asm/field_effect.o(.text); asm/unknown_task.o(.text); asm/option_menu.o(.text); diff --git a/src/wild_encounter.c b/src/wild_encounter.c index d92f9daf3e..b4095aa176 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -23,11 +23,6 @@ extern const u8 EventScript_RepelWoreOff[]; #define NUM_FEEBAS_SPOTS 6 -#define LAND_WILD_COUNT 12 -#define WATER_WILD_COUNT 5 -#define ROCK_WILD_COUNT 5 -#define FISH_WILD_COUNT 10 - extern const u16 gRoute119WaterTileData[]; extern const struct WildPokemonHeader gBattlePikeWildMonHeaders[]; extern const struct WildPokemonHeader gBattlePyramidWildMonHeaders[]; @@ -56,7 +51,7 @@ void DisableWildEncounters(bool8 disabled) sWildEncountersDisabled = disabled; } -u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section) +static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section) { u16 xCur; u16 yCur; @@ -80,7 +75,7 @@ u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section) return tileNum + 1; } -bool8 CheckFeebas(void) +static bool8 CheckFeebas(void) { u8 i; u16 feebasSpots[NUM_FEEBAS_SPOTS]; @@ -144,7 +139,7 @@ static void FeebasSeedRng(u16 seed) sFeebasRngValue = seed; } -u8 ChooseWildMonIndex_Land(void) +static u8 ChooseWildMonIndex_Land(void) { u8 rand = Random() % 100; @@ -174,7 +169,7 @@ u8 ChooseWildMonIndex_Land(void) return 11; } -u8 ChooseWildMonIndex_WaterRock(void) +static u8 ChooseWildMonIndex_WaterRock(void) { u8 rand = Random() % 100; @@ -197,7 +192,7 @@ enum SUPER_ROD }; -u8 ChooseWildMonIndex_Fishing(u8 rod) +static u8 ChooseWildMonIndex_Fishing(u8 rod) { u8 wildMonIndex = 0; u8 rand = Random() % 100; @@ -234,7 +229,7 @@ u8 ChooseWildMonIndex_Fishing(u8 rod) return wildMonIndex; } -u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon) +static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon) { u8 min; u8 max; @@ -272,7 +267,7 @@ u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon) return min + rand; } -u16 GetCurrentMapWildMonHeaderId(void) +static u16 GetCurrentMapWildMonHeaderId(void) { u16 i; @@ -302,7 +297,7 @@ u16 GetCurrentMapWildMonHeaderId(void) return -1; } -u8 PickWildMonNature(void) +static u8 PickWildMonNature(void) { u8 i; u8 j; @@ -348,7 +343,7 @@ u8 PickWildMonNature(void) return Random() % 25; } -void CreateWildMon(u16 species, u8 level) +static void CreateWildMon(u16 species, u8 level) { bool32 checkCuteCharm; @@ -397,7 +392,7 @@ enum #define WILD_CHECK_REPEL 0x1 #define WILD_CHECK_KEEN_EYE 0x2 -bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags) +static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags) { u8 wildMonIndex = 0; u8 level; @@ -433,7 +428,7 @@ bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 return TRUE; } -u16 GenerateFishingWildMon(const struct WildPokemonInfo *wildMonInfo, u8 rod) +static u16 GenerateFishingWildMon(const struct WildPokemonInfo *wildMonInfo, u8 rod) { u8 wildMonIndex = ChooseWildMonIndex_Fishing(rod); u8 level = ChooseWildMonLevel(&wildMonInfo->wildPokemon[wildMonIndex]); @@ -442,7 +437,7 @@ u16 GenerateFishingWildMon(const struct WildPokemonInfo *wildMonInfo, u8 rod) return wildMonInfo->wildPokemon[wildMonIndex].species; } -bool8 SetUpMassOutbreakEncounter(u8 flags) +static bool8 SetUpMassOutbreakEncounter(u8 flags) { u16 i; @@ -456,7 +451,7 @@ bool8 SetUpMassOutbreakEncounter(u8 flags) return TRUE; } -bool8 DoMassOutbreakEncounterTest(void) +static bool8 DoMassOutbreakEncounterTest(void) { if (gSaveBlock1Ptr->outbreakPokemonSpecies != 0 && gSaveBlock1Ptr->location.mapNum == gSaveBlock1Ptr->outbreakLocationMapNum @@ -468,7 +463,7 @@ bool8 DoMassOutbreakEncounterTest(void) return FALSE; } -bool8 DoWildEncounterRateDiceRoll(u16 encounterRate) +static bool8 DoWildEncounterRateDiceRoll(u16 encounterRate) { if (Random() % 2880 < encounterRate) return TRUE; @@ -476,7 +471,7 @@ bool8 DoWildEncounterRateDiceRoll(u16 encounterRate) return FALSE; } -bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility) +static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility) { encounterRate *= 16; if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) @@ -505,7 +500,7 @@ bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility) return DoWildEncounterRateDiceRoll(encounterRate); } -bool8 DoGlobalWildEncounterDiceRoll(void) +static bool8 DoGlobalWildEncounterDiceRoll(void) { if (Random() % 100 >= 60) return FALSE; @@ -513,7 +508,7 @@ bool8 DoGlobalWildEncounterDiceRoll(void) return TRUE; } -bool8 AreLegendariesInSootopolisPreventingEncounters(void) +static bool8 AreLegendariesInSootopolisPreventingEncounters(void) { if (gSaveBlock1Ptr->location.mapGroup != MAP_GROUP_SOOTOPOLIS_CITY || gSaveBlock1Ptr->location.mapNum != MAP_ID_SOOTOPOLIS_CITY)