From 743324807d212a67a8ae15cf95c8cbda018fd0a4 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Thu, 4 Jan 2018 01:09:12 +0300 Subject: [PATCH 1/5] Add Flip and Push actions to Quad Bike --- addons/interaction/CfgVehicles.hpp | 18 ++++++++++++++++++ addons/interaction/XEH_postInit.sqf | 7 +++++++ addons/interaction/stringtable.xml | 6 +++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 9bd70a00dac..b41212d2bef 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -368,6 +368,24 @@ class CfgVehicles { }; }; + class Car_F: Car{}; + class Quadbike_01_base_F: Car_F { + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + class GVAR(flip) { + displayName = CSTRING(Flip); + condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target}); + statement = QUOTE([ARR_3(QQGVAR(flip),_target,_target)] call CBA_fnc_targetEvent); + }; + class GVAR(push) { + displayName = CSTRING(Push); + condition = QUOTE(_target call FUNC(canPush)); + statement = QUOTE(call FUNC(push)); + }; + }; + }; + }; + class Tank: LandVehicle { class ACE_Actions { class ACE_MainActions { diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf index 5d2b49f9b16..bccdbbef878 100644 --- a/addons/interaction/XEH_postInit.sqf +++ b/addons/interaction/XEH_postInit.sqf @@ -28,6 +28,13 @@ ACE_Modifier = 0; {_lamp setHit [_x select 0, (_x select 1) max _disabledLampDMG];nil} count _hitPointsDamage; }] call CBA_fnc_addEventHandler; +[QGVAR(flip), { + params ["_vehicle"]; + private _position = getPosATL _vehicle; + _vehicle setVectorUp surfaceNormal _position; + _vehicle setPosATL _position; +}] call CBA_fnc_addEventHandler; + // Zeus action events [QGVAR(zeusStance),{ { _x setUnitPos (_this select 0); } forEach (_this select 1); diff --git a/addons/interaction/stringtable.xml b/addons/interaction/stringtable.xml index f1aa5944d0e..ad80d95389e 100644 --- a/addons/interaction/stringtable.xml +++ b/addons/interaction/stringtable.xml @@ -831,7 +831,7 @@ Pchnij Tlačit Tolás - Толкать + Толкнуть Empurrar Spingere 押す @@ -839,6 +839,10 @@ + + Flip + Перевернуть + Interact Interagir From 96ba017cc734cecaf60f60ea288f071cd145f243 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Fri, 5 Jan 2018 13:56:16 +0300 Subject: [PATCH 2/5] Add actions to karts and static weapons --- addons/interaction/CfgVehicles.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index b41212d2bef..7f1edff2e4f 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -385,6 +385,22 @@ class CfgVehicles { }; }; }; + class Kart_01_Base_F: Car_F { + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + class GVAR(flip) { + displayName = CSTRING(Flip); + condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target}); + statement = QUOTE([ARR_3(QQGVAR(flip),_target,_target)] call CBA_fnc_targetEvent); + }; + class GVAR(push) { + displayName = CSTRING(Push); + condition = QUOTE(_target call FUNC(canPush)); + statement = QUOTE(call FUNC(push)); + }; + }; + }; + }; class Tank: LandVehicle { class ACE_Actions { @@ -563,6 +579,11 @@ class CfgVehicles { exceptions[] = {"isNotSwimming"}; insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); }; + class GVAR(flip) { + displayName = CSTRING(Flip); + condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target || {isAutonomous _target}} && {getMass _target <= 2000}); + statement = QUOTE([ARR_3(QQGVAR(flip),_target,_target)] call CBA_fnc_targetEvent); + }; }; }; From bddb8dc0cdc7098f20b02f1307b5fbe31d93c7b0 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 6 Jan 2018 02:31:52 +0300 Subject: [PATCH 3/5] Move magic number to macro --- addons/interaction/CfgVehicles.hpp | 2 +- addons/interaction/script_component.hpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 7f1edff2e4f..f01f4758442 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -581,7 +581,7 @@ class CfgVehicles { }; class GVAR(flip) { displayName = CSTRING(Flip); - condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target || {isAutonomous _target}} && {getMass _target <= 2000}); + condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target || {isAutonomous _target}} && {getMass _target <= FLIP_MAX_STATICWEAPON_MASS}); statement = QUOTE([ARR_3(QQGVAR(flip),_target,_target)] call CBA_fnc_targetEvent); }; }; diff --git a/addons/interaction/script_component.hpp b/addons/interaction/script_component.hpp index bd5484992f5..33e60bc29a2 100644 --- a/addons/interaction/script_component.hpp +++ b/addons/interaction/script_component.hpp @@ -17,3 +17,6 @@ #include "\z\ace\addons\main\script_macros.hpp" #define MACRO_DOOR_REACH_DISTANCE (AGLToASL positionCameraToWorld [0,0,0] vectorDistance AGLToASL (ACE_player modelToWorld (ACE_player selectionPosition "Head"))) + 2 + +// here is most suitable mass for all vanilla, CUP and RHS statics ATM (ZU-23 suits, D-30 and M119 don't suit) +#define FLIP_MAX_STATICWEAPON_MASS 2000 From 4817defc3a055e3ee92caa359c8316e9db9d7054 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 6 Jan 2018 02:36:26 +0300 Subject: [PATCH 4/5] Ditch here is --- addons/interaction/script_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/interaction/script_component.hpp b/addons/interaction/script_component.hpp index 33e60bc29a2..c638795883c 100644 --- a/addons/interaction/script_component.hpp +++ b/addons/interaction/script_component.hpp @@ -18,5 +18,5 @@ #define MACRO_DOOR_REACH_DISTANCE (AGLToASL positionCameraToWorld [0,0,0] vectorDistance AGLToASL (ACE_player modelToWorld (ACE_player selectionPosition "Head"))) + 2 -// here is most suitable mass for all vanilla, CUP and RHS statics ATM (ZU-23 suits, D-30 and M119 don't suit) +// most suitable mass for all vanilla, CUP and RHS statics ATM (ZU-23 suits, D-30 and M119 don't suit) #define FLIP_MAX_STATICWEAPON_MASS 2000 From d2757b355d76a7aa41034057b25ccdfb9b862030 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Tue, 23 Jan 2018 15:49:44 +0300 Subject: [PATCH 5/5] Move condition to function --- addons/interaction/CfgVehicles.hpp | 6 ++--- addons/interaction/XEH_PREP.hpp | 1 + addons/interaction/functions/fnc_canFlip.sqf | 25 ++++++++++++++++++++ addons/interaction/script_component.hpp | 3 --- 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 addons/interaction/functions/fnc_canFlip.sqf diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index f01f4758442..45581d8c10e 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -374,7 +374,7 @@ class CfgVehicles { class ACE_MainActions: ACE_MainActions { class GVAR(flip) { displayName = CSTRING(Flip); - condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target}); + condition = QUOTE(call DFUNC(canFlip)); statement = QUOTE([ARR_3(QQGVAR(flip),_target,_target)] call CBA_fnc_targetEvent); }; class GVAR(push) { @@ -390,7 +390,7 @@ class CfgVehicles { class ACE_MainActions: ACE_MainActions { class GVAR(flip) { displayName = CSTRING(Flip); - condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target}); + condition = QUOTE(call DFUNC(canFlip)); statement = QUOTE([ARR_3(QQGVAR(flip),_target,_target)] call CBA_fnc_targetEvent); }; class GVAR(push) { @@ -581,7 +581,7 @@ class CfgVehicles { }; class GVAR(flip) { displayName = CSTRING(Flip); - condition = QUOTE(1 < (vectorUp _target) vectorDistance (surfaceNormal getPosATL _target) && {0 == {alive _x} count crew _target || {isAutonomous _target}} && {getMass _target <= FLIP_MAX_STATICWEAPON_MASS}); + condition = QUOTE(call DFUNC(canFlip)); statement = QUOTE([ARR_3(QQGVAR(flip),_target,_target)] call CBA_fnc_targetEvent); }; }; diff --git a/addons/interaction/XEH_PREP.hpp b/addons/interaction/XEH_PREP.hpp index 1a70de88315..06dd7acbe0f 100644 --- a/addons/interaction/XEH_PREP.hpp +++ b/addons/interaction/XEH_PREP.hpp @@ -42,4 +42,5 @@ PREP(openDoor); PREP(canPush); PREP(push); +PREP(canFlip); PREP(switchLamp); diff --git a/addons/interaction/functions/fnc_canFlip.sqf b/addons/interaction/functions/fnc_canFlip.sqf new file mode 100644 index 00000000000..70c004920c9 --- /dev/null +++ b/addons/interaction/functions/fnc_canFlip.sqf @@ -0,0 +1,25 @@ +/* + * Author: Dystopian + * Checks if vehicle can be flipped. + * + * Arguments: + * 0: Vehicle + * + * Return Value: + * Can Flip + * + * Example: + * [cursorObject] call ace_interaction_fnc_canFlip + * + * Public: No + */ +#include "script_component.hpp" + +params ["_vehicle"]; + +// most suitable mass for all vanilla, CUP and RHS statics ATM (ZU-23 suits, D-30 and M119 don't suit) +#define FLIP_MAX_STATICWEAPON_MASS 2000 + +1 < (vectorUp _vehicle) vectorDistance (surfaceNormal getPosATL _vehicle) +&& {0 == {alive _x} count crew _vehicle || {isAutonomous _vehicle}} +&& {getMass _vehicle <= FLIP_MAX_STATICWEAPON_MASS} diff --git a/addons/interaction/script_component.hpp b/addons/interaction/script_component.hpp index c638795883c..bd5484992f5 100644 --- a/addons/interaction/script_component.hpp +++ b/addons/interaction/script_component.hpp @@ -17,6 +17,3 @@ #include "\z\ace\addons\main\script_macros.hpp" #define MACRO_DOOR_REACH_DISTANCE (AGLToASL positionCameraToWorld [0,0,0] vectorDistance AGLToASL (ACE_player modelToWorld (ACE_player selectionPosition "Head"))) + 2 - -// most suitable mass for all vanilla, CUP and RHS statics ATM (ZU-23 suits, D-30 and M119 don't suit) -#define FLIP_MAX_STATICWEAPON_MASS 2000