Help with current script please!

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

Help with current script please!

Postby Gorphius » Wed Dec 29, 2021 5:20 pm

Hello I’m using the Rapid Fire Toggle script pasted below does anybody know if I can paste this script in a second time and delete the hold part to get the function I’m going for, what I’m trying to achieve is have rapid fire turn off temporarily after selecting a non rapid fire weapon(LB) and back on when either the trigger is released or LB is pressed again. Thanks for the help everyone
Code: Select all
// toggle - rapid fire
bool bRapid=FALSE;
 
main {
// toggle
if (get_actual(BUTTON_8) && event_active(BUTTON_10)) bRapid = !bRapid;
 
// run rapid fire only when it is enabled and you press BUTTON_5
if (bRapid) {
if (is_active(BUTTON_5)) combo_run(cRapidFire);
if (event_release(BUTTON_5)) combo_stop(cRapidFire);
}
}
 
combo cRapidFire {
set_val(BUTTON_5,100); // press button 5
wait(40); // (press) for 40ms
set_val(BUTTON_5,0); // release button 5
wait(40); // (release) for 40ms
}
User avatar
Gorphius
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Tue Nov 13, 2018 7:54 pm

Re: Help with current script please!

Postby Mad » Wed Dec 29, 2021 9:02 pm

Code: Select all
// toggle - rapid fire
bool bRapid=FALSE;
bool LB;
main {
    if(event_active(BUTTON_7)) LB = !LB;
    // toggle
    if (get_actual(BUTTON_8) && event_active(BUTTON_10)) bRapid = !bRapid;
 
    // run rapid fire only when it is enabled and you press BUTTON_5
    if (bRapid && !LB) {
        if (is_active(BUTTON_5)) combo_run(cRapidFire);
        if (event_release(BUTTON_5)) combo_stop(cRapidFire);
    }
}
 
combo cRapidFire {
    set_val(BUTTON_5,100); // press button 5
    wait(40); // (press) for 40ms
    set_val(BUTTON_5,0); // release button 5
    wait(40); // (release) for 40ms
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Help with current script please!

Postby Gorphius » Sat Jan 01, 2022 7:05 pm

Thanks Mad I gave it a few tries and it’s showing some syntax error codes, do I delete my rapid fire script or a section of it?
User avatar
Gorphius
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Tue Nov 13, 2018 7:54 pm

Re: Help with current script please!

Postby Mad » Sat Jan 01, 2022 9:03 pm

Gorphius wrote:Thanks Mad I gave it a few tries and it’s showing some syntax error codes, do I delete my rapid fire script or a section of it?

The code compiles fine, not sure what you're doing wrong.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Help with current script please!

Postby Gorphius » Sun Jan 02, 2022 6:23 pm

I added it to my current script I’m using below not sure why it’s not working, does it need to be pasted in a specific spot?
Code: Select all
#pragma METAINFO("<Script>", 1, 0, "")
 
#define JUMP (BUTTON_15)
#define MaxTimePressed 200
//If the button lasted pressed less than MaxTimePressed it will Double Jump
//If the button lasted pressed MORE than MaxTimePressed it will single Jump
main {
    if(event_release(JUMP) && (time_active(JUMP) <= MaxTimePressed)) combo_run(cDoubleJump);
}   
 
combo cDoubleJump {
    wait(0);
    set_val(JUMP, 100.0);
    wait(0);
    set_val(JUMP, 0.0);
    wait(0);
}
 
main {
    if (get_actual(STICK_2_Y) ==  -100.0) set_val(BUTTON_9,100);
}
// toggle - rapid fire
bool bRapid=FALSE;
main {
  // toggle
  if (get_actual(BUTTON_8) && event_active(BUTTON_10)) bRapid = !bRapid;
  // run rapid fire only when it is enabled and you press BUTTON_5
  if (bRapid) {
      if (is_active(BUTTON_5)) combo_run(cRapidFire);
      if (event_release(BUTTON_5)) combo_stop(cRapidFire);
  }
}
combo cRapidFire {
  set_val(BUTTON_5,100); // press button 5
  wait(0);              // (press) for 0ms
  set_val(BUTTON_5,0);   // release button 5
  wait(0);              // (release) for 0ms
}
#pragma METAINFO("AntiRecoil", 1, 0, "AryanXbonefisher")
/* Special credits goes out to AryanX and Bonefisher*/
// AntiRecoil Float values 0.0
#define StickNoise            0.0
#define MinARecoilPercent     20.0
#define ARecoil_H             0.0
#define ARecoil_V_ADS         20.0
#define ARecoil_V_HIP         0.0
// AntiRecoil Delay
#define ARecoilDelay         0
//Anti Recoil toggle
bool tAntiRecoil = FALSE;
main {
    if(get_actual(BUTTON_8)){ // ANTIRECOIL ON/OFF: HOLD L2/LT, PRESS Ps/XB1, RELEASE L2/LT
        set_val(BUTTON_10, 0.0);
        if(event_active(BUTTON_10)) tAntiRecoil = !tAntiRecoil;
    }
    if (tAntiRecoil){
        if (check_active(BUTTON_5, ARecoilDelay)){
            if (abs(get_actual(STICK_1_X)) < StickNoise) set_val(STICK_1_X, 0.0);
            if (abs(get_actual(STICK_1_Y)) < StickNoise) set_val(STICK_1_Y, 0.0);
            if (abs(get_actual(STICK_2_X)) < StickNoise) set_val(STICK_2_X, 0.0);
            if (abs(get_actual(STICK_2_Y)) < StickNoise) set_val(STICK_2_Y, 0.0);
            if (is_active(BUTTON_5) && (is_active(BUTTON_8))){ // ADS AntiRecoil
                AntiRecoil(STICK_1_X, ARecoil_H);
                AntiRecoil(STICK_1_Y, ARecoil_V_ADS);
            }
            else
                if (is_active(BUTTON_5) && (!is_active(BUTTON_8))){ // HIP AntiRecoil
                    AntiRecoil(STICK_1_X, ARecoil_H);
                    AntiRecoil(STICK_1_Y, ARecoil_V_HIP);
                }
        }
    }
}
void AntiRecoil(uint8 AxisToApply, fix32 ARecoilToApply){
    fix32 CurrentX = get_val(STICK_1_X);
    fix32 CurrentY = get_val(STICK_1_Y);
    fix32 MinARecoilFactor = MinARecoilPercent / 100.0;
    fix32 MinARecoilToApply = MinARecoilFactor * ARecoilToApply;
    //This sets the ARecoil to be dependent on both X and Y axis movement. With more emphasis on Y
    fix32 MovementARecoilToApply = (1.0 - MinARecoilFactor) * ((ARecoilToApply * (100.0 - sqrt(CurrentX*CurrentX + CurrentY*CurrentY))) / (100.0 + abs(CurrentX) + (CurrentY*CurrentY*0.5)));
    set_val(AxisToApply, clamp((MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply)), -100.00, (100.00 - MinARecoilToApply)));
}
#define LOOP     100 // loop 100 times
uint8      iLoop;
main {
  if (event_active(BUTTON_13)) iLoop = LOOP; // initiate loop
  if (iLoop) { // iLoop is not 0
    if (!cLoop) { // combo is not running at the moment
      iLoop--; // iLoop - 1
      printf("starting combo cLoop, loops left: %d",iLoop); // write text to the Output Panel
      combo_run(cLoop);
    }
  }
}
combo cLoop {
  set_val(BUTTON_17,100);   // press button 17
  wait(0);              // (press) for 0ms
  set_val(BUTTON_17,0); // release button 17
  wait(0);              // (release) for 0ms
}
 
 
 
 
 
 
}
User avatar
Gorphius
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Tue Nov 13, 2018 7:54 pm

Re: Help with current script please!

Postby Mad » Sun Jan 02, 2022 9:05 pm

Remove the closing bracket at the very bottom } and it'll compile.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Help with current script please!

Postby Gorphius » Mon Jan 03, 2022 9:13 pm

I deleted the bracket at the bottom and still getting 5 syntax error codes that aren't allowing it to be transferred to a slot. And I'm pasting the rapid fire toggle script right on top, could I be missing something else?

Invalid symboGPC error: TV.gpc(26): Declaration syntax error 'combo'
GPC error: TV.gpc(38): Invalid symbol redefinition 'bRapid'
GPC error: TV.gpc(51): Declaration syntax error 'combo'
GPC error: TV.gpc(100): Declaration syntax error '('
GPC error: TV.gpc(124): Declaration syntax error 'combo'
GPC: GPC Build ABORTED with 0 warning(s) and 5 error(s).l redefinition
User avatar
Gorphius
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Tue Nov 13, 2018 7:54 pm

Re: Help with current script please!

Postby Mad » Mon Jan 03, 2022 10:06 pm

Then you did something else wrong. I just removed the last closing bracket and it compiles.
Code: Select all
#pragma METAINFO("<Script>", 1, 0, "")
 
#define JUMP (BUTTON_15)
#define MaxTimePressed 200
//If the button lasted pressed less than MaxTimePressed it will Double Jump
//If the button lasted pressed MORE than MaxTimePressed it will single Jump
main {
    if(event_release(JUMP) && (time_active(JUMP) <= MaxTimePressed)) combo_run(cDoubleJump);
}   
 
combo cDoubleJump {
    wait(0);
    set_val(JUMP, 100.0);
    wait(0);
    set_val(JUMP, 0.0);
    wait(0);
}
 
main {
    if (get_actual(STICK_2_Y) ==  -100.0) set_val(BUTTON_9,100);
}
// toggle - rapid fire
bool bRapid=FALSE;
main {
  // toggle
  if (get_actual(BUTTON_8) && event_active(BUTTON_10)) bRapid = !bRapid;
  // run rapid fire only when it is enabled and you press BUTTON_5
  if (bRapid) {
      if (is_active(BUTTON_5)) combo_run(cRapidFire);
      if (event_release(BUTTON_5)) combo_stop(cRapidFire);
  }
}
combo cRapidFire {
  set_val(BUTTON_5,100); // press button 5
  wait(0);              // (press) for 0ms
  set_val(BUTTON_5,0);   // release button 5
  wait(0);              // (release) for 0ms
}
#pragma METAINFO("AntiRecoil", 1, 0, "AryanXbonefisher")
/* Special credits goes out to AryanX and Bonefisher*/
// AntiRecoil Float values 0.0
#define StickNoise            0.0
#define MinARecoilPercent     20.0
#define ARecoil_H             0.0
#define ARecoil_V_ADS         20.0
#define ARecoil_V_HIP         0.0
// AntiRecoil Delay
#define ARecoilDelay         0
//Anti Recoil toggle
bool tAntiRecoil = FALSE;
main {
    if(get_actual(BUTTON_8)){ // ANTIRECOIL ON/OFF: HOLD L2/LT, PRESS Ps/XB1, RELEASE L2/LT
        set_val(BUTTON_10, 0.0);
        if(event_active(BUTTON_10)) tAntiRecoil = !tAntiRecoil;
    }
    if (tAntiRecoil){
        if (check_active(BUTTON_5, ARecoilDelay)){
            if (abs(get_actual(STICK_1_X)) < StickNoise) set_val(STICK_1_X, 0.0);
            if (abs(get_actual(STICK_1_Y)) < StickNoise) set_val(STICK_1_Y, 0.0);
            if (abs(get_actual(STICK_2_X)) < StickNoise) set_val(STICK_2_X, 0.0);
            if (abs(get_actual(STICK_2_Y)) < StickNoise) set_val(STICK_2_Y, 0.0);
            if (is_active(BUTTON_5) && (is_active(BUTTON_8))){ // ADS AntiRecoil
                AntiRecoil(STICK_1_X, ARecoil_H);
                AntiRecoil(STICK_1_Y, ARecoil_V_ADS);
            }
            else
                if (is_active(BUTTON_5) && (!is_active(BUTTON_8))){ // HIP AntiRecoil
                    AntiRecoil(STICK_1_X, ARecoil_H);
                    AntiRecoil(STICK_1_Y, ARecoil_V_HIP);
                }
        }
    }
}
void AntiRecoil(uint8 AxisToApply, fix32 ARecoilToApply){
    fix32 CurrentX = get_val(STICK_1_X);
    fix32 CurrentY = get_val(STICK_1_Y);
    fix32 MinARecoilFactor = MinARecoilPercent / 100.0;
    fix32 MinARecoilToApply = MinARecoilFactor * ARecoilToApply;
    //This sets the ARecoil to be dependent on both X and Y axis movement. With more emphasis on Y
    fix32 MovementARecoilToApply = (1.0 - MinARecoilFactor) * ((ARecoilToApply * (100.0 - sqrt(CurrentX*CurrentX + CurrentY*CurrentY))) / (100.0 + abs(CurrentX) + (CurrentY*CurrentY*0.5)));
    set_val(AxisToApply, clamp((MinARecoilToApply + MovementARecoilToApply + get_val(AxisToApply)), -100.00, (100.00 - MinARecoilToApply)));
}
#define LOOP     100 // loop 100 times
uint8      iLoop;
main {
  if (event_active(BUTTON_13)) iLoop = LOOP; // initiate loop
  if (iLoop) { // iLoop is not 0
    if (!cLoop) { // combo is not running at the moment
      iLoop--; // iLoop - 1
      printf("starting combo cLoop, loops left: %d",iLoop); // write text to the Output Panel
      combo_run(cLoop);
    }
  }
}
combo cLoop {
  set_val(BUTTON_17,100);   // press button 17
  wait(0);              // (press) for 0ms
  set_val(BUTTON_17,0); // release button 17
  wait(0);              // (release) for 0ms
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 37 guests