Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Voltorb and Raomers to Gen 3 static encounters #388

Merged
merged 10 commits into from
May 17, 2024

Conversation

Real96
Copy link
Collaborator

@Real96 Real96 commented May 6, 2024

Add what asked in #366

*
* @return Vector of computed states
*/
std::vector<GeneratorState> generate(u32 seed) const;
std::vector<GeneratorState> generate(u32 seed, const StaticTemplate &staticTemplate) const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary, it gets passed in with the constructor

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@@ -66,11 +66,24 @@ void StaticSearcher3::startSearch(const std::array<u8, 6> &min, const std::array
}
}

void buggedRoamerIVsMatcher(std::array<u8, 6> &ivs, const bool buggedRoamer)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this approach. It limits how many origin seeds we can search through. See how I handled similar situation for the e-readers in colo https://github.com/Admiral-Fish/PokeFinder/blob/master/Source/Core/Gen3/Searchers/GameCubeSearcher.cpp#L300-L307

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm misunderstanding, this essentially does what colo does. The IVs set but the function aren't passed to the LCRNG reverse function. These are only used for the results.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right I might to leave this comment in the other spot.

I still prefer the way I had it where it is a simple if statement instead of a function call

std::array<u8, 6> ivs;
if (staticTemplate->getRoamer())
{
    ivs = { hp, atk & 7, 0, 0, 0, 0 };
}
else
{
    ivs = { hp, atk, def, spa, spd, spe };
}

Copy link
Collaborator Author

@Real96 Real96 May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Had to do atk &= 7 outside the array, it was giving me error when it was put directly inside as you wrote above

@@ -44,12 +44,15 @@ std::vector<GeneratorState> StaticGenerator3::generate(u32 seed) const
u32 pid = go.nextUShort();
pid |= go.nextUShort() << 16;

u16 iv1 = go.nextUShort();
// Raikou/Entei/Suicune/Latias/Latios
bool buggedRoamer = ((staticTemplate.getSpecie() == 380 || staticTemplate.getSpecie() == 381) && (profile.getVersion() & Game::RS) != Game::None) ||
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to a field in a new class for StaticTemplate3 instead of checking the specie each time.

See StaticTemplate4, we would add a roamer field and initialize that in the constructor of the class

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
void startSearch(const std::array<u8, 6> &min, const std::array<u8, 6> &max, const StaticTemplate *staticTemplate);
void startSearch(const std::array<u8, 6> &min, const std::array<u8, 6> &max, const StaticTemplate *staticTemplate, const bool buggedRoamer);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't need to be passed in with the change I suggested

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

*
* @return Vector of computed states
*/
std::vector<SearcherState> search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, const StaticTemplate *staticTemplate) const;
std::vector<SearcherState> search(u8 hp, u8 atk, u8 def, u8 spa, u8 spd, u8 spe, const StaticTemplate *staticTemplate, const bool buggedRoamer) const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't need to be passed in with the change I suggested

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@@ -66,11 +66,24 @@ void StaticSearcher3::startSearch(const std::array<u8, 6> &min, const std::array
}
}

void buggedRoamerIVsMatcher(std::array<u8, 6> &ivs, const bool buggedRoamer)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right I might to leave this comment in the other spot.

I still prefer the way I had it where it is a simple if statement instead of a function call

std::array<u8, 6> ivs;
if (staticTemplate->getRoamer())
{
    ivs = { hp, atk & 7, 0, 0, 0, 0 };
}
else
{
    ivs = { hp, atk, def, spa, spd, spe };
}

Comment on lines 41 to 49
for (u8 atk = min[1]; atk <= max[1]; atk++)
for (u8 atk = buggedRoamer ? min[1] & 7 : min[1]; atk <= (buggedRoamer ? max[1] & 7 : max[1]); atk++)
{
for (u8 def = min[2]; def <= max[2]; def++)
for (u8 def = buggedRoamer ? 0 : min[2]; def <= (buggedRoamer ? 31 : max[2]); def++)
{
for (u8 spa = min[3]; spa <= max[3]; spa++)
for (u8 spa = buggedRoamer ? 0 : min[3]; spa <= (buggedRoamer ? 31 : max[3]); spa++)
{
for (u8 spd = min[4]; spd <= max[4]; spd++)
for (u8 spd = buggedRoamer ? 0 : min[4]; spd <= (buggedRoamer ? 31 : max[4]); spd++)
{
for (u8 spe = min[5]; spe <= max[5]; spe++)
for (u8 spe = buggedRoamer ? 0 : min[5]; spe <= (buggedRoamer ? 31 : max[5]); spe++)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this approach. It limits how many origin seeds we can search through. See how I handled similar situation for the e-readers in colo https://github.com/Admiral-Fish/PokeFinder/blob/master/Source/Core/Gen3/Searchers/GameCubeSearcher.cpp#L300-L307

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

Comment on lines 75 to 76
atk &= 7;
ivs = { hp, atk, 0, 0, 0, 0 };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ivs = { hp, atk & 7, 0, 0, 0, 0 };

Copy link
Collaborator Author

@Real96 Real96 May 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this error:

image

StaticSearcher3.cpp:76:21: Non-constant-expression cannot be narrowed from type 'int' to 'unsigned char' in initializer list (fix available)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_cast<u8>(atk & 7)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Source/Core/Gen3/StaticTemplate3.hpp Show resolved Hide resolved
@@ -28,8 +28,8 @@ def embed_encounters3():

string += f"ShadowTemplate({encounter['version']}, {encounter['specie']}, {encounter.get('shiny', 'Shiny::Random')}, {encounter['level']}, {locks}, {len(encounter['locks'])}, {encounter['type']})"
else:
string += f"StaticTemplate({encounter['version']}, {encounter['specie']}, {encounter.get('form', 0)}, {encounter.get('shiny', 'Shiny::Random')}, 255, 255, 0, {encounter['level']})"

string += f"StaticTemplate3({encounter['version']}, {encounter['specie']}, {encounter.get('form', 0)}, {encounter.get('shiny', 'Shiny::Random')}, 255, 255, 0, {encounter['level']}, {str(encounter['buggedRoamer']).lower()})"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this here, just have it handled in the constructor of StaticTemplate3

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

* @param buggedRoamer FRLG/RS roamer
*/
constexpr StaticTemplate3(Game version, u16 specie, u8 form, Shiny shiny, u8 ability, u8 gender, u8 ivCount, u8 level, bool buggedRoamer) :
StaticTemplate(version, specie, form, shiny, ability, gender, ivCount, level), buggedRoamer(buggedRoamer)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roamer(specie == X || specie == X)

I don't know the specie numbers off hand

Copy link
Collaborator Author

@Real96 Real96 May 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, i don't think you can handle it this way. Emerald roamers are not bugged, only FRLG/RS roamers. Emerald has both Latios and Latias, Ruby has Latios, Sapphire has latias.

Copy link
Collaborator Author

@Real96 Real96 May 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like something like this?

roamer(((specie == 380 || specie == 381) && (version & Game::RS) != Game::None) || (specie >= 243 && specie <= 245))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that works

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -153,14 +153,15 @@ void Static3::generatorCategoryIndexChanged(int index)
QVariant::fromValue(i));
}
}
ui->comboBoxGeneratorMethod->setItemHidden(1, templates[ui->comboBoxGeneratorPokemon->getCurrentInt()].getBuggedRoamer());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Collaborator Author

@Real96 Real96 May 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It removes Method 4 from Method selection when a bugged roamer is selected. Method 4 never happens, cause the rng call for ivs2 is not considered at all

Copy link
Owner

@Admiral-Fish Admiral-Fish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last change then I will merge it

Source/Core/Gen3/StaticTemplate3.hpp Outdated Show resolved Hide resolved
Source/Core/Gen3/StaticTemplate3.hpp Outdated Show resolved Hide resolved
Source/Core/Gen3/StaticTemplate3.hpp Outdated Show resolved Hide resolved
Source/Core/Resources/Embed/embed_gen3.py Outdated Show resolved Hide resolved
@Admiral-Fish Admiral-Fish merged commit 3ddfb23 into master May 17, 2024
0 of 2 checks passed
@Admiral-Fish Admiral-Fish deleted the gen3_static_update branch May 17, 2024 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants