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

Update EggHatcher_Core.c #438

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 49 additions & 36 deletions NativePrograms/PokemonSV/Programs/EggHatcher_Core.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,73 @@

void fly_to_gate(void) {
pbf_press_button(BUTTON_A, 20, 500);
pbf_press_button(BUTTON_Y, 20, 800);
pbf_press_button(BUTTON_Y, 20, 1000);
pbf_move_left_joystick(STICK_MAX, STICK_MAX, 6, 500);
pbf_mash_button(BUTTON_A, 1000);
};

void move_to_location(void) {
pbf_move_left_joystick(STICK_MIN, STICK_CENTER, 190, 0);
pbf_press_button(BUTTON_L, 20, 0);
pbf_move_left_joystick(STICK_CENTER, STICK_MIN, 150, 100);
pbf_press_button(BUTTON_L, 20, 200);
pbf_move_left_joystick(STICK_CENTER, STICK_MIN, 175, 200);
pbf_move_left_joystick(STICK_CENTER, STICK_MAX, 20, 0);
pbf_press_button(BUTTON_L, 20, 300);
};

void open_box(void) {
pbf_press_button(BUTTON_A, 20, 500);
pbf_press_button(BUTTON_X, 20, 200);
pbf_press_button(BUTTON_A, 20, 500);
pbf_press_button(BUTTON_A, 20, 700);
pbf_press_button(BUTTON_X, 20, 400);
pbf_press_button(BUTTON_A, 20, 700);
};

void get_egg(int boxCol) {
pbf_press_dpad(DPAD_RIGHT, 20, 100);
pbf_press_button(BUTTON_MINUS, 20, 100);
for (int i = 0; i < 40; i++) {
pbf_press_dpad(DPAD_RIGHT, 20, 400);
pbf_press_button(BUTTON_MINUS, 20, 800);
for (int i = 0; i < 60; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

It was there before but I do not get what this is doing. Why not multiply 5 by 60? Wouldn't it do the same ? And also allow to merge the wait at the end?

Copy link
Author

Choose a reason for hiding this comment

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

Honestly same, I just saw that it was used to select the row of pokemon and it was working pretty well so didn't want to touch anything...I just increased its duration because in some instances 40 wasn't cutting it. I can try to just put the timer as 300 in the press dpad function. Though my hunch is they wanted to repeatedly press it instead of holding due to some weird interaction with the game.

pbf_press_dpad(DPAD_DOWN, 5, 0);
};
pbf_wait(100);
pbf_press_button(BUTTON_A, 20, 100);
pbf_wait(500);
pbf_press_button(BUTTON_A, 20, 400);
for (int curCol = 0; curCol < boxCol + 1; curCol++) {
pbf_press_dpad(DPAD_LEFT, 20, 100);
pbf_press_dpad(DPAD_LEFT, 20, 250);
};
pbf_press_dpad(DPAD_DOWN, 20, 100);
pbf_press_button(BUTTON_A, 20, 100);
pbf_press_button(BUTTON_B, 20, 200);
pbf_press_button(BUTTON_B, 20, 800);
pbf_press_dpad(DPAD_DOWN, 20, 400);
pbf_press_button(BUTTON_A, 20, 600);
pbf_mash_button(BUTTON_B,600);

};

void deposit_pokemon(int boxCol) {
pbf_press_dpad(DPAD_LEFT, 20, 100);
pbf_press_dpad(DPAD_DOWN, 20, 100);
pbf_press_dpad(DPAD_LEFT, 20, 400);
pbf_press_dpad(DPAD_DOWN, 20, 400);
if (HAS_CLONED_RIDER) {
pbf_press_dpad(DPAD_DOWN, 20, 100);
};
pbf_press_button(BUTTON_MINUS, 20, 100);
for (int i = 0; i < 40; i++) {
pbf_press_button(BUTTON_MINUS, 20, 300);
for (int i = 0; i < 60; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here for the if and wait

pbf_press_dpad(DPAD_DOWN, 5, 0);
};
pbf_wait(100);
pbf_press_button(BUTTON_A, 20, 100);
for (int curCol = 0; curCol < boxCol + 1; curCol++) {
pbf_press_dpad(DPAD_RIGHT, 20, 100);
pbf_wait(400);
pbf_press_button(BUTTON_A, 20, 400);
for (int curCol = 0; curCol < boxCol; curCol++) {
pbf_press_dpad(DPAD_RIGHT, 20, 300);
};
pbf_press_dpad(DPAD_UP, 20, 100);
pbf_press_button(BUTTON_A, 20, 100);
pbf_press_dpad(DPAD_UP, 20, 400);
pbf_press_button(BUTTON_A, 20, 400);
};

void ride_hatch(void) {
pbf_press_button(BUTTON_PLUS, 20, 400);
pbf_press_button(BUTTON_PLUS, 20, 500);
// hatch the first egg at full speed, sometimes the speed boost can fail %point for optimizing%
pbf_move_left_joystick(STICK_MAX, STICK_CENTER, 50, 0);
pbf_press_button(BUTTON_LCLICK, 5, 0);
pbf_move_left_joystick(STICK_MAX, STICK_CENTER, STEPS_TO_HATCH * SAFETY_COEFF, 0);
pbf_move_left_joystick(STICK_MAX, STICK_CENTER, STEPS_TO_HATCH * 1.9 * SAFETY_COEFF , 0);
// hatch the remaining 4 eggs, not speed boosted to reduce error due to random positioning
for (int checkEggLoop = 0; checkEggLoop < 80; checkEggLoop++) {
for (int checkEggLoop = 0; checkEggLoop < 90; checkEggLoop++) {
pbf_move_left_joystick(STICK_MAX, STICK_CENTER, 220, 0);
pbf_press_button(BUTTON_A, 5, 0);
};
pbf_mash_button(BUTTON_A, 1250);
};

int main(void) {
Expand All @@ -90,31 +91,43 @@ int main(void) {

for(int curBox = 0; curBox < BOXES_TO_HATCH; curBox++) {
// ########## Intial loop setup ##########
fly_to_gate();
move_to_location();
open_box();
pbf_press_dpad(DPAD_LEFT, 20, 200);
if (HAS_CLONED_RIDER) {
pbf_press_dpad(DPAD_DOWN, 20, 100);
};
pbf_wait(500);
get_egg(0);
pbf_wait(100);
ride_hatch();

// ########## Main hatching loop ##########
for(int boxCol = 0; boxCol < 6; boxCol++) {
get_egg(boxCol);
move_to_location();
ride_hatch();
for(int boxCol = 1; boxCol < 7; boxCol++) {

fly_to_gate();
move_to_location();
open_box();
pbf_wait(500);
deposit_pokemon(boxCol);
if (boxCol < 6) {
pbf_wait(500);
get_egg(boxCol);
pbf_wait(100);
ride_hatch();
}
};

// ########## End loop setup ##########
pbf_wait(200);
pbf_press_button(BUTTON_R, 20, 200);
pbf_press_button(BUTTON_B, 20, 200);
pbf_press_button(BUTTON_B, 20, 800);
pbf_mash_button(BUTTON_B,600);
pbf_wait(500);
};

// ########## End idling in home ##########
pbf_press_button(BUTTON_HOME, 20, 100);
end_program_callback();
end_program_loop();
};
};