How to interrupt a Void function? XIM Turn Function
3 posts
• Page 1 of 1
How to interrupt a Void function? XIM Turn Function
Hi, i´ve written a small Auto Turn Helper for XIM users. This works fine for me, but i want to interrupt the fuction when i go into shooting or ADS mode, therefore i use the AutoTurnFlag with True or False condition.
If the condition is met and RS is triggered, the combo will start the funtion
But, as long as RS is triggered, the function will be executed, even when the AutoTurnFlag condition changes through shooting or ADS.
I use the same method for an AutoRun combo which runs fine, can someone tell what is wrong in the code?
- Code: Select all
if(get_val(BUTTON_5) || get_val(BUTTON_8)) {
AutoSprintFlag = FALSE;
AutoTurnFlag = FALSE;
combo_stop(autosprint);
combo_stop(AutoTurnHelper);
} else if(event_release(BUTTON_5) || event_release(BUTTON_8)) AutoSprintFlag = TRUE; AutoTurnFlag = TRUE;
If the condition is met and RS is triggered, the combo will start the funtion
- Code: Select all
if(get_val(BUTTON_6) && (AutoTurnFlag == TRUE)) {
combo_run (AutoTurnHelper);
} else combo_stop(AutoTurnHelper);
// combo AutoTurnHelper
combo AutoTurnHelper {
Autoturn(STICK_1_X);
}
[code=gpc2]
[/code]
// AutoTurn
void Autoturn(uint8 axis) {
if(AutoTurnFlag == TRUE) {
fix32 Out;
fix32 boost = 2.0;
Out = (get_actual(axis) * (boost));
if (Out > 95.0){Out = 100.0;}
else Out = clamp(Out,-100.00,100.00);
set_val(axis,Out);
}
return;
}
But, as long as RS is triggered, the function will be executed, even when the AutoTurnFlag condition changes through shooting or ADS.
I use the same method for an AutoRun combo which runs fine, can someone tell what is wrong in the code?
-
monty34 - Command Sergeant Major
- Posts: 165
- Joined: Wed Jun 28, 2017 7:25 pm
Re: How to interrupt a Void function? XIM Turn Function
I think if you change the first part to
it should work as expected.
- Code: Select all
if(get_val(BUTTON_5) || get_val(BUTTON_8)) {
AutoSprintFlag = FALSE;
AutoTurnFlag = FALSE;
combo_stop(autosprint);
combo_stop(AutoTurnHelper);
} else {
AutoSprintFlag = TRUE;
AutoTurnFlag = TRUE;
}
it should work as expected.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: How to interrupt a Void function? XIM Turn Function
Thanks, now it works.
If anyone need the function, feel free to use it:
You can change the boost values separately for running and while walking, 1.5 works fine for me for running with XIM mouse use in Destiny, as well 2.0 for walking or quick turning. The boost will stopped if you ADS or shoot.
If anyone need the function, feel free to use it:
You can change the boost values separately for running and while walking, 1.5 works fine for me for running with XIM mouse use in Destiny, as well 2.0 for walking or quick turning. The boost will stopped if you ADS or shoot.
- Code: Select all
fix32 boost;
bool AutoSprintFlag;
bool AutoTurnFlag;
init{
AutoSprintFlag = TRUE;
AutoTurnFlag == TRUE;
}
main{
// -------------------------------------------------------------------------- //
// | Auto Sprint & AutoTurn Cancel When Shooting or ADS | //
// -------------------------------------------------------------------------- //
if(get_val(BUTTON_5) || get_val(BUTTON_8)) {
AutoSprintFlag = FALSE;
AutoTurnFlag = FALSE;
combo_stop(autosprint);
} else {
AutoSprintFlag = TRUE;
AutoTurnFlag = TRUE;
}
// -------------------------------------------------------------------------- //
// | Autosprint with higher Mouse sensivity | //
// -------------------------------------------------------------------------- //
if(get_val(STICK_2_Y)<-90.0 && AutoSprintFlag == TRUE) {
boost = 1.5;
Autoturn(STICK_1_X);
combo_run(autosprint);
} else combo_stop(autosprint);
// -------------------------------------------------------------------------- //
// | Auto Turn Helper -- Hold RS | //
// -------------------------------------------------------------------------- //
if(get_val(BUTTON_6) && AutoTurnFlag == TRUE) {
boost = 2.0;
Autoturn(STICK_1_X);
}
}
// combo autosprint
combo autosprint {
set_val(BUTTON_9, 100.0);
wait(60);
set_val(BUTTON_9, 0.0);
wait(60);
}
// AutoTurn
void Autoturn(uint8 axis) {
fix32 Out;
Out = (get_actual(axis) * (boost));
if (Out > 95.0){Out = 100.0;}
else Out = clamp(Out,-100.00,100.00);
set_val(axis,Out);
return;
}
-
monty34 - Command Sergeant Major
- Posts: 165
- Joined: Wed Jun 28, 2017 7:25 pm
3 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: Google [Bot], proxy342 and 128 guests