diff options
author | PikalaxALT <PikalaxALT@users.noreply.github.com> | 2019-09-04 16:50:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-04 16:50:39 -0400 |
commit | 36723a235ad5ee101264549611a31cf05f2aff72 (patch) | |
tree | abb571e8e399ecb6089d2872a2052829a9c88093 /src | |
parent | a4270cfdae82c96a20ed60ca1daa30ff6845c08c (diff) | |
parent | 08a3ff77dd845a7b1d6debfeb7bd8408aacd12f4 (diff) |
Merge pull request #735 from garakmon/encounter_json
Add Different Field Info to Wild Encounters JSON
Diffstat (limited to 'src')
-rwxr-xr-x | src/data/wild_encounters.json | 26 | ||||
-rwxr-xr-x | src/data/wild_encounters.json.txt | 11 | ||||
-rw-r--r-- | src/wild_encounter.c | 60 |
3 files changed, 67 insertions, 30 deletions
diff --git a/src/data/wild_encounters.json b/src/data/wild_encounters.json index 6dd24bfed..ea555bd32 100755 --- a/src/data/wild_encounters.json +++ b/src/data/wild_encounters.json @@ -3,6 +3,32 @@ { "label": "gWildMonHeaders", "for_maps": true, + "fields": [ + { + "type": "land_mons", + "encounter_rates": [ + 20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1 + ] + }, + { + "type": "water_mons", + "encounter_rates": [ + 60, 30, 5, 4, 1 + ] + }, + { + "type": "rock_smash_mons", + "encounter_rates": [ + 60, 30, 5, 4, 1 + ] + }, + { + "type": "fishing_mons", + "encounter_rates": [ + 70, 30, 60, 20, 20, 40, 40, 15, 4, 1 + ] + } + ], "encounters": [ { "map": "MAP_ROUTE101", diff --git a/src/data/wild_encounters.json.txt b/src/data/wild_encounters.json.txt index 8f88cc587..85755ddec 100755 --- a/src/data/wild_encounters.json.txt +++ b/src/data/wild_encounters.json.txt @@ -1,5 +1,16 @@ {{ doNotModifyHeader }} + ## for wild_encounter_group in wild_encounter_groups +{% if wild_encounter_group.for_maps %} +## for wild_encounter_field in wild_encounter_group.fields +## for encounter_rate in wild_encounter_field.encounter_rates +{% if trackVar(encounter_rate, 100) %} +#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_SLOT_{{ loop.index }} {{ encounter_rate }} {% else %}#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_SLOT_{{ loop.index }} ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_SLOT_{{ subtract(loop.index, 1) }} + {{ encounter_rate }}{% endif %} {{ setVarInt(wild_encounter_field.type, loop.index) }} +## endfor +#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_TOTAL (ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_SLOT_{{ getVar(wild_encounter_field.type) }}) +## endfor +{% endif %} + ## for encounter in wild_encounter_group.encounters {% if existsIn(encounter, "land_mons") %} const struct WildPokemon {{ encounter.base_label }}_LandMons[] = diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 84275526e..332bbfb99 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -143,47 +143,47 @@ static void FeebasSeedRng(u16 seed) static u8 ChooseWildMonIndex_Land(void) { - u8 rand = Random() % 100; + u8 rand = Random() % ENCOUNTER_CHANCE_LAND_MONS_TOTAL; - if (rand < 20) // 20% chance + if (rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_0) return 0; - else if (rand >= 20 && rand < 40) // 20% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_0 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_1) return 1; - else if (rand >= 40 && rand < 50) // 10% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_1 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_2) return 2; - else if (rand >= 50 && rand < 60) // 10% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_3) return 3; - else if (rand >= 60 && rand < 70) // 10% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_3 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_4) return 4; - else if (rand >= 70 && rand < 80) // 10% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_4 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_5) return 5; - else if (rand >= 80 && rand < 85) // 5% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_5 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_6) return 6; - else if (rand >= 85 && rand < 90) // 5% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_6 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_7) return 7; - else if (rand >= 90 && rand < 94) // 4% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_7 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_8) return 8; - else if (rand >= 94 && rand < 98) // 4% chance + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_8 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) return 9; - else if (rand == 98) // 1% chance + else if (rand == ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) return 10; - else // 1% chance + else return 11; } static u8 ChooseWildMonIndex_WaterRock(void) { - u8 rand = Random() % 100; + u8 rand = Random() % ENCOUNTER_CHANCE_WATER_MONS_TOTAL; - if (rand < 60) // 60% chance + if (rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_0) return 0; - else if (rand >= 60 && rand < 90) // 30% chance + else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_0 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_1) return 1; - else if (rand >= 90 && rand < 95) // 5% chance + else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_1 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_2) return 2; - else if (rand >= 95 && rand < 99) // 4% chance + else if (rand >= ENCOUNTER_CHANCE_WATER_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_WATER_MONS_SLOT_3) return 3; - else // 1% chance + else return 4; } @@ -197,34 +197,34 @@ enum static u8 ChooseWildMonIndex_Fishing(u8 rod) { u8 wildMonIndex = 0; - u8 rand = Random() % 100; + u8 rand = Random() % ENCOUNTER_CHANCE_FISHING_MONS_TOTAL; switch (rod) { case OLD_ROD: - if (rand < 70) // 70% chance + if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_0) wildMonIndex = 0; - else // 30% chance + else wildMonIndex = 1; break; case GOOD_ROD: - if (rand < 60) // 60% chance + if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_2) wildMonIndex = 2; - if (rand >= 60 && rand < 80) // 20% chance + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_3) wildMonIndex = 3; - if (rand >= 80 && rand < 100) // 20% chance + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_3 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_4) wildMonIndex = 4; break; case SUPER_ROD: - if (rand < 40) // 40% chance + if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_5) wildMonIndex = 5; - if (rand >= 40 && rand < 80) // 40% chance + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_5 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_6) wildMonIndex = 6; - if (rand >= 80 && rand < 95) // 15% chance + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_6 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_7) wildMonIndex = 7; - if (rand >= 95 && rand < 99) // 4% chance + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_7 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_8) wildMonIndex = 8; - if (rand == 99) // 1% chance + if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SLOT_8) wildMonIndex = 9; break; } |