run in circles script

GPC2 script programming for Titan Two. Code examples, questions, requests.

run in circles script

Postby KnightSpartan » Mon Nov 25, 2019 4:53 am

I'm looking for a script to automatically run in circles for me to hatch pokemon eggs. I searched for awhile and found one that didn't work and another that waited long between circles. I tried to edit it myself but I had no idea what I was doing. If anyone could help that'd be cool.
User avatar
KnightSpartan
Private First Class
Private First Class
 
Posts: 3
Joined: Mon Nov 25, 2019 4:42 am

Re: run in circles script

Postby Mad » Mon Nov 25, 2019 4:59 am

Post the one that worked and we can adjust the timing.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: run in circles script

Postby KnightSpartan » Mon Nov 25, 2019 5:10 am

viewtopic.php?f=26&t=7449

This was it. I tried to make it constant by changing the wait times myself but it wasn't making perfect circles so it was wondering around.
User avatar
KnightSpartan
Private First Class
Private First Class
 
Posts: 3
Joined: Mon Nov 25, 2019 4:42 am

Re: run in circles script

Postby Mad » Mon Nov 25, 2019 7:25 am

Code: Select all
fix32 angle;
 
fix32 circle_size = 0.0040; // Lower the value for bigger circles
 
bool toggle;
main {
  // Hold ZL and tap Dpad UP to toggle on/off
  if(is_active(7) && event_active(9)) toggle=!toggle;
 
  if(toggle) {
    set_val(STICK_2_X, sin(angle) * 100.0);
    set_val(STICK_2_Y, cos(angle) * 100.0);
    angle += circle_size; if(angle >= 2.0 * PI) angle = 0.0;
  }
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: run in circles script

Postby KnightSpartan » Mon Nov 25, 2019 8:28 pm

Awesome! Thanks for the help
User avatar
KnightSpartan
Private First Class
Private First Class
 
Posts: 3
Joined: Mon Nov 25, 2019 4:42 am

Re: run in circles script

Postby DontAtMe » Mon Nov 25, 2019 8:57 pm

Code: Select all
#define SPEED 100 // <- Increase value to decrease speed.
 
#define SIZE 100 // <- 100 max size.
 
main {
  fix32 a, m;
  bool x, y, toggle;
 
  // Hold ZL and tap Dpad UP to toggle on/off
  if(is_active(7) && event_active(9)) toggle=!toggle;
 
  if(toggle) {
    a += (fix32)elapsed_time();
 
    set_val(STICK_2_X, clamp(cos((a/(fix32)SPEED)+m)*(fix32)SIZE, -100f, 100f));
    set_val(STICK_2_Y, clamp(sin((a/(fix32)SPEED)+m)*(fix32)SIZE, -100f, 100f));
 
    if(get_val(STICK_2_X) < 0.00) {
      if(!x) m += 0.131226; x = 1;
    } else x = 0;
 
 
    if(get_val(STICK_2_Y) < 0.00) {
      if(!y) m += 0.131256; y = 1;
    } else y = 0;
  }
 
}
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 117 guests