Check for instance on press and return ? possible?

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

Check for instance on press and return ? possible?

Postby Derivates » Sat Feb 16, 2019 12:23 am

So I''m running a Crouch/Tea-Bag script which basically spams the (o)) button whenever I'm ADS''ing + Firing. It''s amazing and I love it, the only thing I don't like is that sometimes I may start the script on the (standing) position and sometimes I end crouching and not in the same position I started the script.... Not sure if it's possible but pretty much,, if I start the script o crouch...the the script eds crouching too....If I start the script o the standing position thee I end i the standing position..

Hopefully this is possible, here's my code:

Code: Select all
 
#include <keyboard.gph>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DEFINES
#define CROUCH_SPAM_KEY    KEY_F3             // F3        "         Crouch-Spam //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TOGGLES
bool CrouchSpam = FALSE;
    bool key_f3_event; // F3
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// VARIABLES & DEFINES [SETTINGS]
#define CROUCH_SPAM_TIME  20        // Adjust Crouch-Spam delay //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                                                    // Crouch-Spam
main {
    if(key_status(CROUCH_SPAM_KEY)) {
        if(!key_f3_event) {
            key_f3_event = TRUE;
            CrouchSpam = !CrouchSpam;
        }
    } else key_f3_event = FALSE;
  if (CrouchSpam) {
  if (get_actual(BUTTON_8) && get_actual(BUTTON_5)) combo_run(cCrouchSpam);
      if (event_release(BUTTON_5)) combo_stop(cCrouchSpam)
}
}
 
 
combo cCrouchSpam {
  set_val(BUTTON_15,100);
  wait(CROUCH_SPAM_TIME);
  set_val(BUTTON_15,0);
  wait(CROUCH_SPAM_TIME);
}
 


Hep is always greatly appreciated :joia:
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Check for instance on press and return ? possible?

Postby Sillyasskid » Sat Feb 16, 2019 12:36 am

You have not specified which game this is for.
So its hard to say.

Other than the actual crouch button, Is there any alternate way to leave the crouch position?

Like for example, does pressing the sprint button while moving forward take you out crouch mode? I know most games do this, but some don't, such as pubg.
.
User avatar
Sillyasskid
Captain
Captain
 
Posts: 574
Joined: Sat May 14, 2016 3:07 am

Re: Check for instance on press and return ? possible?

Postby Derivates » Sat Feb 16, 2019 12:43 am

Sillyasskid wrote:You have not specified which game this is for.
So its hard to say.

Other than the actual crouch button, Is there any alternate way to leave the crouch position?

Like for example, does pressing the sprint button while moving forward take you out crouch mode? I know most games do this, but some don't, such as pubg.
.

My bad comrade, Rainbow Six Siege.

The only time it does it is when you're sprinting yes, also when you're vaulting (you don't jump in this game so it's fine)
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Check for instance on press and return ? possible?

Postby Sillyasskid » Sat Feb 16, 2019 10:12 am

Code: Select all
#include <keyboard.gph>
////////////////////////////////////////////////////////////////////////////////
// DEFINES
#define CROUCH_SPAM_KEY   (KEY_F3)
 
////////////////////////////////////////////////////////////////////////////////
 
// TOGGLES
bool CrouchSpam;
bool key_f3_event;
 
////////////////////////////////////////////////////////////////////////////////
// VARIABLES/CONSTANT'S   [SETTINGS]
// Adjust Crouch-Spam delay
const uint8 CROUCH_SPAM_DELAY = 20; // 1 - 255
 
////////////////////////////////////////////////////////////////////////////////
// Crouch-Spam
 
main {
  /* This will turn off CrouchSpam if you are rappelling. */
  // if(check_active(BUTTON_16, 920)) CrouchSpam = FALSE;
 
  if(key_status(CROUCH_SPAM_KEY)) {
    if(!key_f3_event) {
      key_f3_event = TRUE;
      CrouchSpam = !CrouchSpam;
    }
  } else key_f3_event = FALSE;
 
  if (CrouchSpam) {
    if (is_active(BUTTON_8) && is_active(BUTTON_5)){
      if(event_active(BUTTON_5)||event_active(BUTTON_8))
        combo_run(cCrouchSpam);
    }
  }
 
  if(cCrouchSpam) {
    set_val(BUTTON_15, 0);
  }
}
 
combo cCrouchSpam {
  wait(CROUCH_SPAM_DELAY);
  set_val(BUTTON_15, 100);
  wait(30);
  wait(CROUCH_SPAM_DELAY);
  set_val(BUTTON_15, 100);
  wait(30);
  wait(CROUCH_SPAM_DELAY-1);
  if(is_active(BUTTON_8) && is_active(BUTTON_5))
    combo_restart(cCrouchSpam);
  wait(0);
}
User avatar
Sillyasskid
Captain
Captain
 
Posts: 574
Joined: Sat May 14, 2016 3:07 am

Re: Check for instance on press and return ? possible?

Postby Derivates » Sat Feb 16, 2019 3:42 pm

Sillyasskid wrote:
Code: Select all
#include <keyboard.gph>
////////////////////////////////////////////////////////////////////////////////
// DEFINES
#define CROUCH_SPAM_KEY   (KEY_F3)
 
////////////////////////////////////////////////////////////////////////////////
 
// TOGGLES
bool CrouchSpam;
bool key_f3_event;
 
////////////////////////////////////////////////////////////////////////////////
// VARIABLES/CONSTANT'S   [SETTINGS]
// Adjust Crouch-Spam delay
const uint8 CROUCH_SPAM_DELAY = 20; // 1 - 255
 
////////////////////////////////////////////////////////////////////////////////
// Crouch-Spam
 
main {
  /* This will turn off CrouchSpam if you are rappelling. */
  // if(check_active(BUTTON_16, 920)) CrouchSpam = FALSE;
 
  if(key_status(CROUCH_SPAM_KEY)) {
    if(!key_f3_event) {
      key_f3_event = TRUE;
      CrouchSpam = !CrouchSpam;
    }
  } else key_f3_event = FALSE;
 
  if (CrouchSpam) {
    if (is_active(BUTTON_8) && is_active(BUTTON_5)){
      if(event_active(BUTTON_5)||event_active(BUTTON_8))
        combo_run(cCrouchSpam);
    }
  }
 
  if(cCrouchSpam) {
    set_val(BUTTON_15, 0);
  }
}
 
combo cCrouchSpam {
  wait(CROUCH_SPAM_DELAY);
  set_val(BUTTON_15, 100);
  wait(30);
  wait(CROUCH_SPAM_DELAY);
  set_val(BUTTON_15, 100);
  wait(30);
  wait(CROUCH_SPAM_DELAY-1);
  if(is_active(BUTTON_8) && is_active(BUTTON_5))
    combo_restart(cCrouchSpam);
  wait(0);
}

Thanks a lot, has been working flawlessly for the past 10 minutes I ran it; I have a few questions tho, why did you change get_val to is_active? seems to execute the same task and of course it works but why the change?
I also set the bool on top as =True/False because I'm looking forward to made separate profiles and have them enabled on specific profiles.
Is it okay if I modify the (30ms) you put? do those 30ms stack up with the value I set for crouch spam? (20)
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Check for instance on press and return ? possible?

Postby Sillyasskid » Sat Feb 16, 2019 6:41 pm

Derivates wrote:I have a few questions tho, why did you change get_val to is_active? seems to execute the same task and of course it works but why the change?

Yes you are correct, they both do preform the same task, but instead of using get_val() I'd recommend using either get_actual() or is_active() as a safer alternative.

Using get_val() will also return true, if it is programmatically set by set_val()
If you intend for the condition to only be true if the IO is physically pressed, your best off not using get_val().

Derivates wrote:
Code: Select all
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TOGGLES
bool CrouchSpam = FALSE;
    bool key_f3_event; // F3
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I also set the bool on top as =True/False because I'm looking forward to made separate profiles and have them enabled on specific profiles.
Sorry when I was debugging the script I had set it to TRUE; So I would not have to press f3. Then when I had finished debugging it I simply removed the = TRUE. I forgot that you had specifically set it to FALSE. :oops:

Derivates wrote:Is it okay if I modify the (30m) you put? do those 30ms stack up with the value I set for crouch spam? (20)
You can tweak this value if you like. However increasing this value too much, will cause you to go into the prone position. Reducing the value too much may throw the combo out of sync.

Frame drops happen frequently in this game, which can have a negative effect on the the combo. In order for the combo to work as intended, the game must be able to register every event in the combo. So to accommodate for these I increased the value to 30 this will insure the button press is always registered.

The value you should really be interested in changing is the CROUCH_SPAM_DELAY increasing this value will slow the crouch spam down, but it will not throw the combo out of sync. Although reducing this value will throw the combo out of sync.
User avatar
Sillyasskid
Captain
Captain
 
Posts: 574
Joined: Sat May 14, 2016 3:07 am

Re: Check for instance on press and return ? possible?

Postby Derivates » Sat Feb 16, 2019 8:52 pm

Sillyasskid wrote:
Derivates wrote:I have a few questions tho, why did you change get_val to is_active? seems to execute the same task and of course it works but why the change?

Yes you are correct, they both do preform the same task, but instead of using get_val() I'd recommend using either get_actual() or is_active() as a safer alternative.

Using get_val() will also return true, if it is programmatically set by set_val()
If you intend for the condition to only be true if the IO is physically pressed, your best off not using get_val().

Derivates wrote:
Code: Select all
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TOGGLES
bool CrouchSpam = FALSE;
    bool key_f3_event; // F3
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I also set the bool on top as =True/False because I'm looking forward to made separate profiles and have them enabled on specific profiles.
Sorry when I was debugging the script I had set it to TRUE; So I would not have to press f3. Then when I had finished debugging it I simply removed the = TRUE. I forgot that you had specifically set it to FALSE. :oops:

Derivates wrote:Is it okay if I modify the (30m) you put? do those 30ms stack up with the value I set for crouch spam? (20)
You can tweak this value if you like. However increasing this value too much, will cause you to go into the prone position. Reducing the value too much may throw the combo out of sync.

Frame drops happen frequently in this game, which can have a negative effect on the the combo. In order for the combo to work as intended, the game must be able to register every event in the combo. So to accommodate for these I increased the value to 30 this will insure the button press is always registered.

The value you should really be interested in changing is the CROUCH_SPAM_DELAY increasing this value will slow the crouch spam down, but it will not throw the combo out of sync. Although reducing this value will throw the combo out of sync.

Thanks for the detailed response, I really like knowing exactly what has changed to I have an idea of what's going on. If you have some spare time (sorry if I'm bothering too much) I'd appreciate if you could check my other threadbecause I'm facing a tiny issue with antithesis anti Recoil script.. Quick question: is antithesis anti Recoil the best you can find? I'm looking forward to tweak specific operators with different Recoil values of course and I think antithesis' is one of the best if not the best out there? (do you have a better recommendation?
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Check for instance on press and return ? possible?

Postby bonefisher » Sat Feb 16, 2019 9:17 pm

Try my R6 Special in online resources!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: Check for instance on press and return ? possible?

Postby Derivates » Sun Feb 17, 2019 3:39 pm

bonefisher wrote:Try my R6 Special in online resources!

The thing is that I'm trying to make my own specific so I have specific Recoil values for different ops!
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Check for instance on press and return ? possible?

Postby bonefisher » Sun Feb 17, 2019 7:11 pm

I can put one click configurations in the so you could save the settings for each weapon like my Battlefield Five script!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Next

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 136 guests