summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgarak <garakmon@gmail.com>2019-09-30 19:18:06 -0400
committerhuderlem <huderlem@gmail.com>2019-10-16 20:09:49 -0500
commitfc2926aa469de176403d0ccaba3ad503c65ff98e (patch)
treefdd891289107eaeef5a03af1ae18ac8db831ba24 /src
parent943005316b673252329aae214280790b15caa910 (diff)
add fishing rod groups to encounter json
Diffstat (limited to 'src')
-rw-r--r--src/data/wild_encounters.json16
-rw-r--r--src/data/wild_encounters.json.txt14
-rw-r--r--src/wild_encounter.c21
3 files changed, 36 insertions, 15 deletions
diff --git a/src/data/wild_encounters.json b/src/data/wild_encounters.json
index 9adbc28de..37cffbca9 100644
--- a/src/data/wild_encounters.json
+++ b/src/data/wild_encounters.json
@@ -8,25 +8,33 @@
"type": "land_mons",
"encounter_rates": [
20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1
- ]
+ ],
+ "groups": {}
},
{
"type": "water_mons",
"encounter_rates": [
60, 30, 5, 4, 1
- ]
+ ],
+ "groups": {}
},
{
"type": "rock_smash_mons",
"encounter_rates": [
60, 30, 5, 4, 1
- ]
+ ],
+ "groups": {}
},
{
"type": "fishing_mons",
"encounter_rates": [
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]
+ }
}
],
"encounters": [
diff --git a/src/data/wild_encounters.json.txt b/src/data/wild_encounters.json.txt
index de8396dd6..5e0286b61 100644
--- a/src/data/wild_encounters.json.txt
+++ b/src/data/wild_encounters.json.txt
@@ -3,14 +3,26 @@
## for wild_encounter_group in wild_encounter_groups
{% if wild_encounter_group.for_maps %}
## for wild_encounter_field in wild_encounter_group.fields
+{% if isEmpty(wild_encounter_field.groups) %}
## for encounter_rate in wild_encounter_field.encounter_rates
-{% if trackVar(encounter_rate, 100) %}
+{% if loop.index == 0 %}
#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) }})
+{% else %}
+## for field_subgroup_key, field_subgroup_subarray in wild_encounter_field.groups
+## for field_subgroup_index in field_subgroup_subarray
+{% if loop.index == 0 %}
+#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_{{ upper(field_subgroup_key) }}_SLOT_{{ field_subgroup_index }} {{ at(wild_encounter_field.encounter_rates, field_subgroup_index) }} {% else %}#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_{{ upper(field_subgroup_key) }}_SLOT_{{ field_subgroup_index }} ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_{{ upper(field_subgroup_key) }}_SLOT_{{ getVar("previous_slot") }} + {{ at(wild_encounter_field.encounter_rates, field_subgroup_index) }}{% endif %}{{ setVarInt(concat(wild_encounter_field.type, field_subgroup_key), field_subgroup_index) }}{{ setVarInt("previous_slot", field_subgroup_index) }}
+## endfor
+#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_{{ upper(field_subgroup_key) }}_TOTAL (ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_{{ upper(field_subgroup_key) }}_SLOT_{{ getVar(concat(wild_encounter_field.type, field_subgroup_key)) }})
+## endfor
+{% endif %}
## endfor
{% endif %}
+
+
## for encounter in wild_encounter_group.encounters
{% if contains(encounter.base_label, "Sapphire") %}#ifdef SAPPHIRE
{% else if contains(encounter.base_label, "Ruby") %}#ifdef RUBY{% endif %}
diff --git a/src/wild_encounter.c b/src/wild_encounter.c
index 0680570fc..47eb81541 100644
--- a/src/wild_encounter.c
+++ b/src/wild_encounter.c
@@ -203,34 +203,35 @@ enum
static u8 ChooseWildMonIndex_Fishing(u8 rod)
{
u8 wildMonIndex = 0;
- u8 rand = Random() % 100;
+ u8 rand = Random() % max(max(ENCOUNTER_CHANCE_FISHING_MONS_OLD_ROD_TOTAL, ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_TOTAL),
+ ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_TOTAL);;
switch (rod)
{
case OLD_ROD:
- if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_0)
+ if (rand < ENCOUNTER_CHANCE_FISHING_MONS_OLD_ROD_SLOT_0)
wildMonIndex = 0;
else
wildMonIndex = 1;
break;
case GOOD_ROD:
- if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_2)
+ if (rand < ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_2)
wildMonIndex = 2;
- if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_2 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_3)
+ if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_2 && rand < ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_3)
wildMonIndex = 3;
- if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_3 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_4)
+ if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_3 && rand < ENCOUNTER_CHANCE_FISHING_MONS_GOOD_ROD_SLOT_4)
wildMonIndex = 4;
break;
case SUPER_ROD:
- if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_5)
+ if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_5)
wildMonIndex = 5;
- if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_5 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_6)
+ if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_5 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_6)
wildMonIndex = 6;
- if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_6 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_7)
+ if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_6 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_7)
wildMonIndex = 7;
- if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SLOT_7 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_8)
+ if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_7 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8)
wildMonIndex = 8;
- if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SLOT_8)
+ if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8)
wildMonIndex = 9;
break;
}