request for adding a killswitch
2 posts
• Page 1 of 1
request for adding a killswitch
Hello, i need someone to add a killswitch for turning on/off the aim assist for driving vehicles. it is (BUTTON_8) (left trigger). Much appreciated.
- Code: Select all
#pragma METAINFO("try 1", 1, 0, "DontAtMe")
fix32 _COSINE_(fix32 a, bool b) {/*^ */
if ((a = mod(a + 6.28319, 6.28319)) < 0.0) a = mod(a += 6.28319, 6.28319);
if (a > 0.785522 && a < 3.92761) return b ? sin(1.5708 - a) : cos(1.5708 - a);
return b ? cos(a) : sin(a);
}
#define sin(a) (_COSINE_(a))
#define cos(a) (_COSINE_(a, 1))
const fix32 radius = 12.50;
const fix32 speed = 1.0;
//speed and radius when moving the stick.
const fix32 movement_speed = 4.00;
const fix32 movement_radius = 5.00;
fix32 angle;
main {
fix32 x = get_actual(STICK_1_X);
fix32 y = get_actual(STICK_1_Y);
fix32 m = sqrt(sq(x)+sq(y));
// Left Trigger to activate.
if(is_active(BUTTON_8)){
angle = mod(angle += (m > radius ? movement_speed : speed), 360.00);
set_polar(STICK_1_X, STICK_1_Y, angle, (m > radius ? movement_radius : radius));
}
}
void set_polar(uint8 X, uint8 Y, fix32 ANGLE, fix32 RADIUS){
fix32 angle = rad2deg(mod(deg2rad(ANGLE) + 6.28319, 6.28319));
fix32 x_Out = cos(deg2rad(angle));
fix32 y_Out = sin(deg2rad(angle));
offset(X, clamp(x_Out * RADIUS, -100.00, 100.00));
offset(Y, clamp(y_Out * RADIUS, -100.00, 100.00));
}
void offset(uint8 axis, fix32 offset_val) {
set_val(axis, clamp(offset_val * (100f - abs(get_actual(axis))) / 100f + get_actual(axis), -100f, 100f));
return;
}
main {
if(get_actual(STICK_2_Y) <= -60f && event_release(BUTTON_15)) combo_run(Macro2Combo); {
}
}
main {
if (event_release(BUTTON_9)) combo_run(yyCombo);
}
main {
if (get_val(BUTTON_5)) set_val(BUTTON_5,100);
}
combo Macro2Combo {
wait(55);
set_val(BUTTON_15, 100);
wait(100);
set_val(BUTTON_15, 100);
set_val(BUTTON_16, 100);
wait(65);
set_val(BUTTON_15, 0.00);
set_val(BUTTON_16, 100);
wait(35);
set_val(BUTTON_16, 0.00);
}
combo yyCombo {
set_val(BUTTON_14, 0.00);
wait(70);
set_val(BUTTON_14, 100.00);
wait(80);
set_val(BUTTON_14, 0.00);
wait(65);
set_val(BUTTON_14, 100.00);
wait(80);
set_val(BUTTON_14, 0.00);
wait(40);
}
-
bigKrill878 - Sergeant
- Posts: 6
- Joined: Mon Oct 04, 2021 5:46 pm
Re: request for adding a killswitch
left trigger + dpad down
- Code: Select all
#pragma METAINFO("try 1", 1, 0, "DontAtMe")
fix32 _COSINE_(fix32 a, bool b) {/*^ */
if ((a = mod(a + 6.28319, 6.28319)) < 0.0) a = mod(a += 6.28319, 6.28319);
if (a > 0.785522 && a < 3.92761) return b ? sin(1.5708 - a) : cos(1.5708 - a);
return b ? cos(a) : sin(a);
}
#define sin(a) (_COSINE_(a))
#define cos(a) (_COSINE_(a, 1))
const fix32 radius = 12.50;
const fix32 speed = 1.0;
//speed and radius when moving the stick.
const fix32 movement_speed = 4.00;
const fix32 movement_radius = 5.00;
fix32 angle;
bool AA = 1;
main {
fix32 x = get_actual(STICK_1_X);
fix32 y = get_actual(STICK_1_Y);
fix32 m = sqrt(sq(x)+sq(y));
// Left Trigger to activate.
if(is_active(BUTTON_8)){
if(event_active(BUTTON_11)) AA = !AA;
if(AA) {
angle = mod(angle += (m > radius ? movement_speed : speed), 360.00);
set_polar(STICK_1_X, STICK_1_Y, angle, (m > radius ? movement_radius : radius));
}
}
}
void set_polar(uint8 X, uint8 Y, fix32 ANGLE, fix32 RADIUS){
fix32 angle = rad2deg(mod(deg2rad(ANGLE) + 6.28319, 6.28319));
fix32 x_Out = cos(deg2rad(angle));
fix32 y_Out = sin(deg2rad(angle));
offset(X, clamp(x_Out * RADIUS, -100.00, 100.00));
offset(Y, clamp(y_Out * RADIUS, -100.00, 100.00));
}
void offset(uint8 axis, fix32 offset_val) {
set_val(axis, clamp(offset_val * (100f - abs(get_actual(axis))) / 100f + get_actual(axis), -100f, 100f));
return;
}
main {
if(get_actual(STICK_2_Y) <= -60f && event_release(BUTTON_15)) combo_run(Macro2Combo); {
}
}
main {
if (event_release(BUTTON_9)) combo_run(yyCombo);
}
main {
if (get_val(BUTTON_5)) set_val(BUTTON_5,100);
}
combo Macro2Combo {
wait(55);
set_val(BUTTON_15, 100);
wait(100);
set_val(BUTTON_15, 100);
set_val(BUTTON_16, 100);
wait(65);
set_val(BUTTON_15, 0.00);
set_val(BUTTON_16, 100);
wait(35);
set_val(BUTTON_16, 0.00);
}
combo yyCombo {
set_val(BUTTON_14, 0.00);
wait(70);
set_val(BUTTON_14, 100.00);
wait(80);
set_val(BUTTON_14, 0.00);
wait(65);
set_val(BUTTON_14, 100.00);
wait(80);
set_val(BUTTON_14, 0.00);
wait(40);
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
- Mad
- Major General
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
2 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 236 guests