Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ void move_from_pokecenter_to_ansha(SingleSwitchProgramEnvironment& env, ProContr
context.wait_for(100ms); // extra 0.1 sec to let game give player control
env.log("Detected overworld. Fast traveled from Pokecenter to Hotel Zone");

ret = run_towards_gate_with_A_button(env.console, context, 128, 0, Seconds(5));
ret = run_towards_gate_with_A_button(env.console, context, 0, +1, Seconds(5));
if (ret == 1){ // day night change happens during running
// As day night change has ended, try running towards door again
if (run_towards_gate_with_A_button(env.console, context, 128, 0, Seconds(5)) != 0){
if (run_towards_gate_with_A_button(env.console, context, 0, +1, Seconds(5)) != 0){
stats.errors++;
env.update_stats();
OperationFailedException::fire(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ bool leave_zone_gate(ConsoleHandle& console, ProControllerContext& context){

int run_towards_gate_with_A_button(
ConsoleHandle& console, ProControllerContext& context,
uint8_t run_direction_x, uint8_t run_direction_y,
double run_direction_x, double run_direction_y,
PokemonAutomation::Milliseconds run_time
){
const ImageFloatBox button_A_box{0.3, 0.2, 0.4, 0.7};
Expand All @@ -555,7 +555,7 @@ int run_towards_gate_with_A_button(
[&](ProControllerContext& context){
// running back
ssf_press_button(context, BUTTON_B, 0ms, run_time, 0ms);
pbf_move_left_joystick_old(context, run_direction_x, run_direction_y, run_time, 0ms);
pbf_move_left_joystick(context, {run_direction_x, run_direction_y}, run_time, 0ms);
},
{{buttonA, overworld_gone}}
);
Expand All @@ -577,15 +577,15 @@ int run_towards_gate_with_A_button(

int run_a_straight_path_in_overworld(
ConsoleHandle& console, ProControllerContext& context,
uint8_t direction_x, uint8_t direction_y,
double direction_x, double direction_y,
PokemonAutomation::Milliseconds duration
){
OverworldPartySelectionOverWatcher overworld_gone(COLOR_WHITE, &console.overlay(), std::chrono::milliseconds(400));
int ret = run_until<ProControllerContext>(
console, context,
[&](ProControllerContext& context){
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
pbf_move_left_joystick_old(context, direction_x, direction_y, duration, 0ms);
pbf_move_left_joystick(context, {direction_x, direction_y}, duration, 0ms);
},
{{overworld_gone}}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool leave_zone_gate(ConsoleHandle& console, ProControllerContext& context);
// or get stuck by terrain or obstacle on the way
int run_towards_gate_with_A_button(
ConsoleHandle& console, ProControllerContext& context,
uint8_t run_direction_x, uint8_t run_direction_y,
double run_direction_x, double run_direction_y,
Milliseconds run_time
);

Expand All @@ -138,7 +138,7 @@ int run_towards_gate_with_A_button(
// - -1 it ran for full *duration* without a day/night change
int run_a_straight_path_in_overworld(
ConsoleHandle& console, ProControllerContext& context,
uint8_t direction_x, uint8_t direction_y,
double direction_x, double direction_y,
PokemonAutomation::Milliseconds duration
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void route_wild_zone_19(
ProControllerContext& context,
ShinyHunt_FlySpotReset_Descriptor::Stats& stats,
bool to_zoom_to_max){
if (run_a_straight_path_in_overworld(env.console, context, 0, 80, 6500ms) == 0) {
if (run_a_straight_path_in_overworld(env.console, context, -1, 0.375, 6500ms) == 0) {
open_map(env.console, context, to_zoom_to_max);
pbf_move_left_joystick(context, {-0.375, -1}, 100ms, 100ms);
if (fly_from_map(env.console, context) == FastTravelState::NOT_AT_FLY_SPOT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ void do_one_cafe_trip(
env.console.overlay().add_log("Escaping to Entrance");
const double starting_direction = get_facing_direction(env.console, context);

uint8_t move_x = 0, move_y = 0;
double move_x = -1, move_y = +1;
switch(cafe){
case WildZoneCafe::CAFE_BATAILLE:
env.log("Move to zone gate from Cafe Bataille");
move_x = 255; move_y = 160;
move_x = +1; move_y = -0.25;
break;
case WildZoneCafe::CAFE_ULTIMO:
env.log("Move to zone gate from Cafe Ultimo");
move_x = 128; move_y = 255;
move_x = 0; move_y = -1;
break;
}

Expand All @@ -190,7 +190,7 @@ void do_one_cafe_trip(

if (direction_change > 30){
// we are already facing the gate
move_x = 128; move_y = 0;
move_x = 0; move_y = +1;
env.log("Running forward");
env.console.overlay().add_log("Running Forward");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,23 @@ void go_to_entrance(
WildZone wildzone
){
double starting_direction = 0;
uint8_t joystick_x = 128;
double joystick_x = 0;
if (wildzone == WildZone::WILD_ZONE_1){
// The fast travel point of Wild Zone 1 does not face the zone entrance directly. We need
// to turn a little bit to the right
starting_direction = get_facing_direction(env.console, context);
joystick_x = 145;
joystick_x = 0.133;
}
int ret = run_towards_gate_with_A_button(env.console, context, joystick_x, 0, 10s);
int ret = run_towards_gate_with_A_button(env.console, context, joystick_x, +1, 10s);
switch(ret){
case 0: // detected button A. Reached gate
break;
case 1: // day/night change happened.
if (wildzone == WildZone::WILD_ZONE_1 &&
get_angle_between_facing_directions(starting_direction, get_facing_direction(env.console, context)) > 2.5){
joystick_x = 128; // we've already turned. Just need to go forward to enter the zone
joystick_x = 0; // we've already turned. Just need to go forward to enter the zone
}
ret = run_towards_gate_with_A_button(env.console, context, joystick_x, 0, 10s);
ret = run_towards_gate_with_A_button(env.console, context, joystick_x, +1, 10s);
if (ret != 0){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand Down Expand Up @@ -321,7 +321,7 @@ void leave_zone_and_reset_spawns(

const double starting_direction = get_facing_direction(env.console, context);

int ret = run_towards_gate_with_A_button(env.console, context, 128, 255, walk_time_in_zone);
int ret = run_towards_gate_with_A_button(env.console, context, 0, -1, walk_time_in_zone);
switch (ret){
case 0: // Found button A. Reached the gate.
break;
Expand All @@ -332,17 +332,17 @@ void leave_zone_and_reset_spawns(
env.log("Facing direction difference after day/night change: " + tostr_fixed(direction_change, 0) + " deg, from "
+ tostr_fixed(starting_direction, 0) + " to " + tostr_fixed(cur_direction, 0) + " deg");

uint8_t joystick_y = 0;
double joystick_y = +1;
if (direction_change > 150.0){
// we are facing towards the gate
env.log("Running forward");
env.console.overlay().add_log("Running Forward");
joystick_y = 0;
joystick_y = +1;
}else if(direction_change < 30.0){
// we are facing away from the gate
env.log("Running back");
env.console.overlay().add_log("Running Back");
joystick_y = 255;
joystick_y = -1;
}else{
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
Expand All @@ -352,7 +352,7 @@ void leave_zone_and_reset_spawns(
}

// Running forward or backward depends on character facing to go back to zone entrance
ret = run_towards_gate_with_A_button(env.console, context, 128, joystick_y, walk_time_in_zone);
ret = run_towards_gate_with_A_button(env.console, context, 0, joystick_y, walk_time_in_zone);
if (ret != 0){
stats.errors++;
env.update_stats();
Expand Down