Running a combo on a timer or wait command...

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

Running a combo on a timer or wait command...

Postby antithesis » Fri Sep 01, 2017 5:40 am

Quick question - how do I run a combo for a pre-set period of time?

I used to do it on T1 by calling a combo in a combo, then using a wait command afterwards, which would repeat the combo for the duration of the wait, e.g

Code: Select all
 
combo RapidFire
{
    set_val(SHOOT, 100);
    wait(HoldTime);
    set_val(SHOOT, 0);
    wait(WaitTime);
    set_val(SHOOT, 0);
}
 
combo SemiBurst // Fires short bursts of rapid-fire. Intended for semi-auto weapons
{
    combo_run (RapidFire);
    wait (SemiHold); // Keep rapid-firing until semi-burst expires
    set_val (SHOOT, 0);
    wait (SemiWait)// Pause between semi-bursts
    set_val(SHOOT, 0);
}
 

That doesn't work on T2 :ashamed:

In this case, I want to run a rapid-fire combo to burst a semi-automatic weapon for XXXXms. That's different from running a full-auto burst, which is simply a longer wait time for an R2/RT button hold. I've got that covered, but am unsure of how to get rapid-fire to repeat the combo for the duration of a burst.

Any suggestions?
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: Running a combo on a timer or wait command...

Postby J2Kbr » Fri Sep 01, 2017 1:11 pm

I tried the code you posted and it worked for me, here is how I tested it:
Code: Select all
#define SHOOT       BUTTON_5
 
#define HoldTime    50
#define WaitTime    50
#define SemiHold    250
#define SemiWait    500
 
main {
    if(is_active(SHOOT)) {
        combo_run(SemiBurst);
    }
}
 
combo RapidFire {
    set_val(SHOOT, 100.0);
    wait(HoldTime);
    set_val(SHOOT, 0.0);
    wait(WaitTime);
    set_val(SHOOT, 0.0);
}
 
combo SemiBurst {
    combo_run(RapidFire);
    wait(SemiHold);
    set_val (SHOOT, 0.0);
    wait(SemiWait);
    set_val(SHOOT, 0.0);
}
 
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Running a combo on a timer or wait command...

Postby antithesis » Fri Sep 01, 2017 10:25 pm

Thanks J2K. It must be something else in my script preventing SemiBurst combo from running. I'll nut that out.

Is there a better way to do this, like running the combo on a timer (the same thing, really...), or counting iterations of RapidFire? It would probably be preferable to set a number of bullets per burst rather than running the combo for XXXXms.

Another question - what's the difference between get_val, event_active and is_active?

I'm hoping is_active allows for a combo to run or stop based on the script output rather than controller input - is that right?

For example, a tap might initiate a burst for multiple seconds. Get_val and event_active are only engaged while the button is physically pressed (input), but is is_active engaged for the duration of the burst length (output)?
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: Running a combo on a timer or wait command...

Postby antithesis » Sat Sep 02, 2017 6:36 am

I worked it out, an else condition was tripping up BurstFire :oops:
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: Running a combo on a timer or wait command...

Postby J2Kbr » Mon Sep 04, 2017 4:03 pm

antithesis wrote:I worked it out, an else condition was tripping up BurstFire :oops:

:smile0517:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 83 guests