Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopard20 committed Jul 11, 2020
1 parent 03008dd commit 55012af
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 27 deletions.
39 changes: 20 additions & 19 deletions addons/AntiBounceSystem/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,37 @@
#include "\a3\editor_f\Data\Scripts\dikCodes.h"

["ABS_enableMod", "CHECKBOX", ["Enable Anti-Bounce System", "Master switch for all vehicles. Requires mission restart."], "Anti-Bounce System" ,true, 1, {}, true] call CBA_Settings_fnc_init;
["ABS_AssistUnflip", "CHECKBOX", ["Enable automatic unflip assistant", "Gives vehicles a small boost to help them unflip."], "Anti-Bounce System" ,true, 1, {}, true] call CBA_Settings_fnc_init;
["ABS_NoAutoUnflipPlayer", "CHECKBOX", ["Disable automatic unflip assistant for player vehicles", "Players can use manual unflip. See the mod's CBA keybinding section. Use this to avoid conflicts."], "Anti-Bounce System" ,true, 1, {}, true] call CBA_Settings_fnc_init;
["ABS_AssistUnflip", "CHECKBOX", ["Enable automatic unflip assistant", "Gives vehicles a small boost to help them unflip."], "Anti-Bounce System" ,true, 1, {}, false] call CBA_Settings_fnc_init;
["ABS_NoAutoUnflipPlayer", "CHECKBOX", ["Disable automatic unflipping for player vehicles", "Players can use manual unflip. See the mod's CBA keybinding section. Use this to avoid conflicts."], "Anti-Bounce System" ,true, 1, {}, false] call CBA_Settings_fnc_init;
["ABS_minAngle", "SLIDER", ["Minimum angle to use manual unflipping", "0 means vehicle is perfectly upright, 90 means on the side, etc."], "Anti-Bounce System" ,[45, 90, 60, 0], 1] call CBA_Settings_fnc_init;
["ABS_perFrameKey", "LIST", ["Manual unflip: Key press mode (Hold is recommended)", "Hold mode fires every frame when the key is down, even if not in vehicle (waste of performance, but minimal). It looks better."], "Anti-Bounce System" ,[[true, false], ["Hold", "Tap"], 0], 0, {
["ABS_perFrameKey", "LIST", ["Manual unflip: Key press mode", "Hold mode fires every frame when the key is down, even if not in vehicle (waste of performance, but minimal). It looks better and is recommended."], "Anti-Bounce System" ,[[true, false], ["Hold", "Tap"], 0], 0, {
if !(ABS_enableMod) exitWith {};

if (ABS_perFrameKey) then {
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_W, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[0,1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_A, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[0,-1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_D, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[-1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_S, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[0,1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_W, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[-1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_A, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_D, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[0,-1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_S, [false, false, false]], true] call CBA_fnc_addKeybind;
} else {
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[1,0] call ABS_fnc_manualUnflip}, "", [DIK_W, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[0,1] call ABS_fnc_manualUnflip}, "", [DIK_A, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[0,-1] call ABS_fnc_manualUnflip}, "", [DIK_D, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[-1,0] call ABS_fnc_manualUnflip}, "", [DIK_S, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[0,1] call ABS_fnc_manualUnflip}, "", [DIK_W, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[-1,0] call ABS_fnc_manualUnflip}, "", [DIK_A, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[1,0] call ABS_fnc_manualUnflip}, "", [DIK_D, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[0,-1] call ABS_fnc_manualUnflip}, "", [DIK_S, [false, false, false]], false] call CBA_fnc_addKeybind;
};
}] call CBA_Settings_fnc_init;

/*
if !(ABS_enableMod) exitWith {};
if (ABS_perFrameKey) then {
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_W, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[0,1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_A, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[0,-1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_D, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[-1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_S, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[0,1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_W, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[-1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_A, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[1,0] call ABS_fnc_manualUnflip_Hold}, "", [DIK_D, [false, false, false]], true] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[0,-1] call ABS_fnc_manualUnflip_Hold}, "", [DIK_S, [false, false, false]], true] call CBA_fnc_addKeybind;
} else {
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[1,0] call ABS_fnc_manualUnflip}, "", [DIK_W, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[0,1] call ABS_fnc_manualUnflip}, "", [DIK_A, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[0,-1] call ABS_fnc_manualUnflip}, "", [DIK_D, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[-1,0] call ABS_fnc_manualUnflip}, "", [DIK_S, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveUpKey", "Unflip - Forward boost", {[0,1] call ABS_fnc_manualUnflip}, "", [DIK_W, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveLeftKey", "Unflip - Leftward boost", {[-1,0] call ABS_fnc_manualUnflip}, "", [DIK_A, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveRightKey", "Unflip - Rightward boost", {[1,0] call ABS_fnc_manualUnflip}, "", [DIK_D, [false, false, false]], false] call CBA_fnc_addKeybind;
["Anti-Bounce System","ABS_MoveBackKey", "Unflip - Backward boost", {[0,-1] call ABS_fnc_manualUnflip}, "", [DIK_S, [false, false, false]], false] call CBA_fnc_addKeybind;
};
*/
16 changes: 12 additions & 4 deletions addons/AntiBounceSystem/functions/fn_manualUnflip.sqf
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
//abc_fnc_manualunflip={
//abc_fnc_manualunflip_hold={
_veh = objectParent player;
private ["_VUP", "_cos"];
if (!isNull _veh && { //in veh
_VUP = vectorUp _veh;
_cos = _VUP vectorCos [0,0,1];
_cos <= cos ABS_minAngle && { //flipped
abs (velocity _veh select 2) < 1 && {
vectorMagnitude velocity _veh < 2 && {
_veh isKindOf "CAR" || {_veh isKindOf "TANK" || {_veh isKindOf "MOTORCYCLE"}}
}
}
}) then {
params ["_xx", "_yy"];
_force = 2*getMass _veh*(1-_cos);
_veh addTorque (_veh vectorModelToWorld [_force*_xx,_force*_yy,0]);
(boundingBoxReal _veh) params ["_c1", "_c2", "_size"];
_c1 params ["_x1", "_y1", "_z1"];
_c2 params ["_x2", "_y2"];
_xc = (_x1 + _x2)/2;
_yc = (_y1 + _y2)/2;
_x = abs(_x1 - _x2)/2;
_y = abs(_y1 - _y2)/2;

_force = 0.5*(1-_cos)*getMass _veh*(1 - 0.65*abs _yy);
_veh addForce [_veh vectorModelToWorld [0,0,-_force], [_xx*_x + _xc, _yy*_y + _yc, getCenterOfMass _veh select 2]];
};
//}
16 changes: 12 additions & 4 deletions addons/AntiBounceSystem/functions/fn_manualUnflip_Hold.sqf
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
//abc_fnc_manualunflip={
//abc_fnc_manualunflip_hold={
_veh = objectParent player;
private ["_VUP", "_cos"];
if (!isNull _veh && { //in veh
_VUP = vectorUp _veh;
_cos = _VUP vectorCos [0,0,1];
_cos <= cos ABS_minAngle && { //flipped
abs (velocity _veh select 2) < 1 && {
vectorMagnitude velocity _veh < 2 && {
_veh isKindOf "CAR" || {_veh isKindOf "TANK" || {_veh isKindOf "MOTORCYCLE"}}
}
}
}) then {
params ["_xx", "_yy"];
_force = 0.25*getMass _veh*(1-_cos);
_veh addTorque (_veh vectorModelToWorld [_force*_xx,_force*_yy,0]);
(boundingBoxReal _veh) params ["_c1", "_c2", "_size"];
_c1 params ["_x1", "_y1", "_z1"];
_c2 params ["_x2", "_y2"];
_xc = (_x1 + _x2)/2;
_yc = (_y1 + _y2)/2;
_x = abs(_x1 - _x2)/2;
_y = abs(_y1 - _y2)/2;

_force = 0.075*(1-_cos)*getMass _veh*(1 - 0.65*abs _yy);
_veh addForce [_veh vectorModelToWorld [0,0,-_force], [_xx*_x + _xc, _yy*_y + _yc, getCenterOfMass _veh select 2]];
};
//}

0 comments on commit 55012af

Please sign in to comment.