Looping only one of several combos

GPC1 script programming for Titan One. Code examples, questions, requests.

Looping only one of several combos

Postby ssrat5 » Thu Jan 02, 2020 8:54 pm

I have been working on my first script (hatching Pokemon eggs) and really got stuck on trying to loop a certain combo. Basically my original plan was to have three combos, first combo to setup a new egg, second combo to loop through moving in tight circles and a third combo to finish the transaction to be able to lead to the first combo again. No matter how I tried to loop the second combo I would run into issues. I tried to do it by calling from the first combo but received error that the wait could only occur on the top level. I tried to do it from Main through several different iterations but it always gave unexpected results, like it was running both combos at the same time. So I ended up brute forcing my way through by not looping at all and just calling the combo many many times. What am I missing? I commented out my last iteration and the below code is working, just not ideal. Also would gladly accept any feedback on my Spin combo, it results in the avatar drifting and is not as tight as I would like. What I am trying to accomplish is in this video, mine is working but just not as clean as I want it: https://www.youtube.com/watch?v=2Z0TjO8l6YE

Code: Select all
/* *
* Pokemon Sword and Shield ShinyHunt V0.21
* ssRat5
* Requirements
* 1. Have Oval Charm (Increased Egg Spawn rate)
* 2. Have Shiny Charm (Increased Shiny chance)
* 3. Have 1st slot Pokemon with flame body ability (Like Coalossal)(Descreases Egg hatch time)
* 4. Equip Rotom Bike
* 5. Able to replace 2nd slot Pokemon
* 6. Town Map highlighted on Menu
* 7. Egg ready at Wild Area Nursery (NOT Route 5 Nursery)(Use Masuda Method)
* 8. Be at Wild Area Nursery
* 9. Adjust EggHatchTime if needed
* *********************************************************** */

define WaitTimeShort=100;
define OneSec=1000;
define TwoSec=2000;
define ThreeSec=3000;
define FourSec=4000;
define circle=95;
 
int toggle;
//int counter;
 
main {
  // LT + Dpad UP to toggle on/off
    if(get_val(SWITCH_L) && event_press(SWITCH_UP)) toggle=!toggle;
//    /*Uglyway
    if(toggle) {
    combo_run(HatchEgg);
    }
//    Ugly way*/
 
/*    Not working.......
    if(toggle) {
    combo_run(HatchEgg);
    } else if(combo_running(HatchEgg)) {
        combo_stop(HatchEgg);
    } else if(toggle && !combo_running(HatchEgg)) {
        counter = 0
        while (counter < 100) {
            combo_run(Spin);
            counter = counter +1;
        }
    }
not working  */

}
 
combo HatchEgg {
set_val(SWITCH_X, 100); //Menu
wait(WaitTimeShort);
set_val(SWITCH_X, 0);
wait(OneSec);
set_val(SWITCH_A, 100); //Select Town Map
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(ThreeSec);
set_val(SWITCH_A, 100); //Select Nursery
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(OneSec);
set_val(SWITCH_A, 100); //Confirm
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(FourSec);
set_val(SWITCH_LY, 100); //Move to Nursery
wait(700);
set_val(SWITCH_LX, 100);
wait(300);
set_val(SWITCH_A, 100); //Start dialog
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(OneSec);
set_val(SWITCH_A, 100); //Accept egg
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(FourSec);
set_val(SWITCH_A, 100); //Message advance
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(ThreeSec);
set_val(SWITCH_A, 100); //Add to party
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(OneSec);
set_val(SWITCH_A, 100); //Message advance
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(TwoSec);
set_val(SWITCH_LY, 100); //Move to 2nd slot
wait(WaitTimeShort);
set_val(SWITCH_A, 100); //Select Pokemon
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(FourSec);
set_val(SWITCH_A, 100); //Message advance
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(FourSec);
set_val(SWITCH_A, 100); //Message advance
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(TwoSec);
set_val(SWITCH_LY, -100); //Move to safe area
wait(500);
set_val(SWITCH_LX, 100);
wait(500);
wait(OneSec);
//*Ugly for now
// 15EggCycle = x < 49  | 20EggCycle = 62 < x < 80
call(Spin12);
call(Spin12);
call(Spin12);
call(Spin12);
call(Spin12);
call(Spin12);
//Ugly*/
set_val(SWITCH_A, 100); //Egg hatching
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(FourSec);
wait(FourSec);
wait(FourSec);
wait(FourSec);
set_val(SWITCH_A, 100); //Message advance
wait(WaitTimeShort);
set_val(SWITCH_A, 0);
wait(FourSec);
}
 
combo Spin {
    // RIGHT
    set_val(SWITCH_LX100);
    set_val(SWITCH_LY,    0);
    wait(circle);
 
    // RIGHT-DOWN
    set_val(SWITCH_LX100);
    set_val(SWITCH_LY100);
    wait(circle);
 
    // DOWN
    set_val(SWITCH_LX,    0);
    set_val(SWITCH_LY100);
    wait(circle);
 
    // DOWN-LEFT
    set_val(SWITCH_LX, -100);
    set_val(SWITCH_LY100);
    wait(circle);
 
    // LEFT
    set_val(SWITCH_LX, -100);
    set_val(SWITCH_LY,    0);
    wait(circle);
 
    // LEFT-UP
    set_val(SWITCH_LX, -100);
    set_val(SWITCH_LY, -100);
    wait(circle);
 
    // UP
    set_val(SWITCH_LX,    0);
    set_val(SWITCH_LY, -100);
    wait(circle);
 
    // UP-RIGHT
    set_val(SWITCH_LX100);
    set_val(SWITCH_LY, -100);
    wait(circle);
 
    // RIGHT
    set_val(SWITCH_LX100);
    set_val(SWITCH_LY,    0);
    wait(circle);
}
 
combo Spin12 {
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
    call(Spin);
}


Thanks!!!

Michael
User avatar
ssrat5
Corporal
Corporal
 
Posts: 4
Joined: Thu Jan 02, 2020 8:28 pm

Re: Looping only one of several combos

Postby DontAtMe » Fri Jan 03, 2020 12:16 am

May help by structuring your combos a bit differently, Try this.
Code: Select all
define circle = 10;
int combo_track;
int counter;
main {
 
  if(get_val(SWITCH_L) && event_press(SWITCH_UP)) { combo_track =! combo_track; }
 
  if(combo_track){
    if(combo_track == 1) { combo_run(first_combo); counter = 0; }
    else if(combo_track == 2) { combo_run(Spin); }
    else if(combo_track == 3) { combo_run(third_combo); }
  }
  else {
    combo_stop(first_combo);
    combo_stop(Spin);
    combo_stop(third_combo);
  }
}
 
combo first_combo {
  .
  .
  .
  combo_track = 2;
  wait(10);
}
 
 
combo Spin {
  // RIGHT
  set_val(SWITCH_LX100);
  set_val(SWITCH_LY,    0);
  wait(circle);
 
  // RIGHT-DOWN
  set_val(SWITCH_LX100);
  set_val(SWITCH_LY100);
  wait(circle);
 
  // DOWN
  set_val(SWITCH_LX,    0);
  set_val(SWITCH_LY100);
  wait(circle);
 
  // DOWN-LEFT
  set_val(SWITCH_LX, -100);
  set_val(SWITCH_LY100);
  wait(circle);
 
  // LEFT
  set_val(SWITCH_LX, -100);
  set_val(SWITCH_LY,    0);
  wait(circle);
 
  // LEFT-UP
  set_val(SWITCH_LX, -100);
  set_val(SWITCH_LY, -100);
  wait(circle);
 
  // UP
  set_val(SWITCH_LX,    0);
  set_val(SWITCH_LY, -100);
  wait(circle);
 
  // UP-RIGHT
  set_val(SWITCH_LX100);
  set_val(SWITCH_LY, -100);
  wait(circle);
 
  // RIGHT
  set_val(SWITCH_LX100);
  set_val(SWITCH_LY,    0);
  wait(circle);
 
  if(counter >=- 72) {
    combo_track = 3;
  }
  wait(10);
}
 
combo third_combo {
  .
  .
  .
  combo_track = 1;
  wait(10);
}
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 90 guests