Merge pull request #735 from garakmon/encounter_json
Add Different Field Info to Wild Encounters JSON
This commit is contained in:
@@ -3,6 +3,32 @@
|
|||||||
{
|
{
|
||||||
"label": "gWildMonHeaders",
|
"label": "gWildMonHeaders",
|
||||||
"for_maps": true,
|
"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": [
|
"encounters": [
|
||||||
{
|
{
|
||||||
"map": "MAP_ROUTE101",
|
"map": "MAP_ROUTE101",
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
{{ doNotModifyHeader }}
|
{{ doNotModifyHeader }}
|
||||||
|
|
||||||
## for wild_encounter_group in wild_encounter_groups
|
## 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
|
## for encounter in wild_encounter_group.encounters
|
||||||
{% if existsIn(encounter, "land_mons") %}
|
{% if existsIn(encounter, "land_mons") %}
|
||||||
const struct WildPokemon {{ encounter.base_label }}_LandMons[] =
|
const struct WildPokemon {{ encounter.base_label }}_LandMons[] =
|
||||||
|
|||||||
+30
-30
@@ -143,47 +143,47 @@ static void FeebasSeedRng(u16 seed)
|
|||||||
|
|
||||||
static u8 ChooseWildMonIndex_Land(void)
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
return 9;
|
||||||
else if (rand == 98) // 1% chance
|
else if (rand == ENCOUNTER_CHANCE_LAND_MONS_SLOT_9)
|
||||||
return 10;
|
return 10;
|
||||||
else // 1% chance
|
else
|
||||||
return 11;
|
return 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 ChooseWildMonIndex_WaterRock(void)
|
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;
|
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;
|
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;
|
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;
|
return 3;
|
||||||
else // 1% chance
|
else
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,34 +197,34 @@ enum
|
|||||||
static u8 ChooseWildMonIndex_Fishing(u8 rod)
|
static u8 ChooseWildMonIndex_Fishing(u8 rod)
|
||||||
{
|
{
|
||||||
u8 wildMonIndex = 0;
|
u8 wildMonIndex = 0;
|
||||||
u8 rand = Random() % 100;
|
u8 rand = Random() % ENCOUNTER_CHANCE_FISHING_MONS_TOTAL;
|
||||||
|
|
||||||
switch (rod)
|
switch (rod)
|
||||||
{
|
{
|
||||||
case OLD_ROD:
|
case OLD_ROD:
|
||||||
if (rand < 70) // 70% chance
|
if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_0)
|
||||||
wildMonIndex = 0;
|
wildMonIndex = 0;
|
||||||
else // 30% chance
|
else
|
||||||
wildMonIndex = 1;
|
wildMonIndex = 1;
|
||||||
break;
|
break;
|
||||||
case GOOD_ROD:
|
case GOOD_ROD:
|
||||||
if (rand < 60) // 60% chance
|
if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_2)
|
||||||
wildMonIndex = 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;
|
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;
|
wildMonIndex = 4;
|
||||||
break;
|
break;
|
||||||
case SUPER_ROD:
|
case SUPER_ROD:
|
||||||
if (rand < 40) // 40% chance
|
if (rand < ENCOUNTER_CHANCE_FISHING_MONS_SLOT_5)
|
||||||
wildMonIndex = 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;
|
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;
|
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;
|
wildMonIndex = 8;
|
||||||
if (rand == 99) // 1% chance
|
if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SLOT_8)
|
||||||
wildMonIndex = 9;
|
wildMonIndex = 9;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using std::string;
|
using std::string; using std::to_string;
|
||||||
|
|
||||||
#include <inja.hpp>
|
#include <inja.hpp>
|
||||||
using namespace inja;
|
using namespace inja;
|
||||||
@@ -36,7 +36,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Add custom command callbacks.
|
// Add custom command callbacks.
|
||||||
env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
|
env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
|
||||||
return "//\n// DO NOT MODIFY THIS FILE! IT IS AUTO-GENERATED FROM " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
|
return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
env.add_callback("subtract", 2, [](Arguments& args) {
|
||||||
|
int minuend = args.at(0)->get<int>();
|
||||||
|
int subtrahend = args.at(1)->get<int>();
|
||||||
|
|
||||||
|
return minuend - subtrahend;
|
||||||
});
|
});
|
||||||
|
|
||||||
env.add_callback("setVar", 2, [=](Arguments& args) {
|
env.add_callback("setVar", 2, [=](Arguments& args) {
|
||||||
@@ -46,11 +53,33 @@ int main(int argc, char *argv[])
|
|||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
env.add_callback("setVarInt", 2, [=](Arguments& args) {
|
||||||
|
string key = args.at(0)->get<string>();
|
||||||
|
string value = to_string(args.at(1)->get<int>());
|
||||||
|
set_custom_var(key, value);
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
|
||||||
env.add_callback("getVar", 1, [=](Arguments& args) {
|
env.add_callback("getVar", 1, [=](Arguments& args) {
|
||||||
string key = args.at(0)->get<string>();
|
string key = args.at(0)->get<string>();
|
||||||
return get_custom_var(key);
|
return get_custom_var(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
env.add_callback("trackVar", 2, [](Arguments& args) {
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
int addValue = args.at(0)->get<int>();
|
||||||
|
int checkValue = args.at(1)->get<int>();
|
||||||
|
|
||||||
|
bool over = false;
|
||||||
|
|
||||||
|
counter = (counter + addValue) % (checkValue + 1);
|
||||||
|
|
||||||
|
if (counter <= addValue) over = true;
|
||||||
|
|
||||||
|
return over;
|
||||||
|
});
|
||||||
|
|
||||||
env.add_callback("concat", 2, [](Arguments& args) {
|
env.add_callback("concat", 2, [](Arguments& args) {
|
||||||
string first = args.at(0)->get<string>();
|
string first = args.at(0)->get<string>();
|
||||||
string second = args.at(1)->get<string>();
|
string second = args.at(1)->get<string>();
|
||||||
@@ -67,7 +96,6 @@ int main(int argc, char *argv[])
|
|||||||
return rawValue.erase(0, prefix.length());
|
return rawValue.erase(0, prefix.length());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add custom command callbacks.
|
|
||||||
env.add_callback("removeSuffix", 2, [](Arguments& args) {
|
env.add_callback("removeSuffix", 2, [](Arguments& args) {
|
||||||
string rawValue = args.at(0)->get<string>();
|
string rawValue = args.at(0)->get<string>();
|
||||||
string suffix = args.at(1)->get<string>();
|
string suffix = args.at(1)->get<string>();
|
||||||
|
|||||||
Reference in New Issue
Block a user