How do I chain combo on based on time
7 posts
• Page 1 of 1
How do I chain combo on based on time
Hello I was wondering how do I chain combos when certain time passes lets say 2 seconds to then switch to next combo, Ill try to show what I mean.
each combo to constantly being going, so something like combo 1,1,1,1,1,1 after 2 seconds combo 2,2,2 repeating. not sure if it makes sense. Basically I want to master the art of recoil for a gun on modern warfare, trying to make it to shoot laser beam
- Code: Select all
#define R_BUMPER BUTTON_4
#define FIRE_BUTTON BUTTON_5
#define RS_TAP BUTTON_6
#define L_BUMPER BUTTON_7
#define ADS_BUTTON BUTTON_8
#define SPRINT_BUTTON BUTTON_9
#define DUP BUTTON_10
#define DDOWN BUTTON_11
#define DLEFT BUTTON_12
#define DRIGHT BUTTON_13
#define Y_BUTTON BUTTON_14
#define B_BUTTON BUTTON_15
#define JUMP_BUTTON BUTTON_16
#define X_BUTTON BUTTON_17
#define L_STICK_X STICK_2_X
#define L_STICK_Y STICK_2_Y
#define R_STICK_X STICK_1_X
#define R_STICK_Y STICK_1_Y
main {
//RECOIL
if(is_active(ADS_BUTTON) && is_active(FIRE_BUTTON)) {
combo_run(recoilone);
combo_run(recoiltwo);
combo_run(recoilthree);
combo_run(recoilfour);
}
}
combo recoilone {
set_val(R_STICK_Y, 40.0);// FAL
set_val(R_STICK_X, -10.0);
wait(40);
wait(20);
}
combo recoiltwo {
wait(2000);
combo_stop(recoilone);
set_val(R_STICK_Y, -20.0);// FAL
set_val(R_STICK_X, 5.0);
wait(40);
wait(20);
}
combo recoilthree {
wait(2000);
//...
}
combo recoilfour {
wait(2000);
//...
}
each combo to constantly being going, so something like combo 1,1,1,1,1,1 after 2 seconds combo 2,2,2 repeating. not sure if it makes sense. Basically I want to master the art of recoil for a gun on modern warfare, trying to make it to shoot laser beam
-
alencroat - Lieutenant
- Posts: 320
- Joined: Sun Oct 15, 2017 5:58 pm
Re: How do I chain combo on based on time
You could use elapsed_time()
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
- Mad
- Major General
- Posts: 4533
- Joined: Wed May 22, 2019 5:39 am
Re: How do I chain combo on based on time
oh shoot could you give me a rough code then I can edit it
thanks
thanks
-
alencroat - Lieutenant
- Posts: 320
- Joined: Sun Oct 15, 2017 5:58 pm
Re: How do I chain combo on based on time
Why not using existing stuff and modify it for multiple values ?
- Code: Select all
#define MinARecoilPercent 15f
// these need to have the same number of entries. If T[] has 3 values, AX[] and AY[] also needs to have 3 values.
uint32 T[]= {0,400,600}; // time in ms the button has to be pressed down for the values to be used
int8 AX[]= {0 ,10, -5 }; // x anti recoil when time reached
int8 AY[]= {10,25,15}; // y anti recoil when time reached
uint8 ARidx; // currently used anti recoil value by index, gets set by the script
init {
}
main {
if (get_val(BUTTON_5)) AROverTime(); // when fire button is active use anti recoil
}
void AROverTime() {
uint32 ta = time_active(BUTTON_5);
if (event_active(BUTTON_5)) ARidx = 0;
else {
if (elapsed_time() && ARidx+1 < (sizeof(T)/4) && ta >= T[ARidx+1]) ARidx++; // next value
}
static int last=0; // for information in the output panel
if (ARidx != last) { last=ARidx; printf("active entry %d, time %ld, applying x: %d, y: %d",ARidx,T[ARidx],AX[ARidx],AY[ARidx]); }; // for information in the output panel
AntiRecoil(STICK_1_X,(fix32)AX[ARidx]); // apply the X anti recoil value
AntiRecoil(STICK_1_Y,(fix32)AY[ARidx]); // apply the y anti recoil value
}
// Aryanx Anti Recoil
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;
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));
}
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: How do I chain combo on based on time
oh nice thank you, I didn't find this one when I searched, so if I want to make more values I could go
something like that will do it?
- Code: Select all
uint32 T[]= {0,200,400,600,800};
int8 AX[]= {0 ,10, -5, -5, -5 };
int8 AY[]= {10,25,15,15,15};
something like that will do it?
-
alencroat - Lieutenant
- Posts: 320
- Joined: Sun Oct 15, 2017 5:58 pm
Re: How do I chain combo on based on time
Yes,
Also, if you don't plan on modifying any of the values in the array, you can declare them constants to save space.
Also, if you don't plan on modifying any of the values in the array, you can declare them constants to save space.
- Code: Select all
const uint32 T[]= {0,200,400,600,800};
const int8 AX[]= {0 ,10, -5, -5, -5};
const int8 AY[]= {10, 25, 15, 15, 15};
-
DontAtMe - Captain
- Posts: 502
- Joined: Tue Oct 02, 2018 4:49 am
Re: How do I chain combo on based on time
ok gotcha thanks
-
alencroat - Lieutenant
- Posts: 320
- Joined: Sun Oct 15, 2017 5:58 pm
7 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 127 guests