Browse Source

magclamp system done

thefloff 4 years ago
parent
commit
bca279f387

+ 3 - 3
addons - Copy/RD501_Main/functions/jumppack/jumppack.sqf

@@ -501,16 +501,16 @@ macro_grp_fnc_name(jumppack,memeify_test) = {
 
 
 //add keybinds
-["RD501 Jumppack Mod","Jump",["Jump","Press to Jump"],{ 
+["RD501 Jumppack","Jump",["Jump","Press to Jump"],{
 	[player] spawn macro_grp_fnc_name(jumppack,decide_jump);
 },"",[DIK_Y, [false, true, false]],false] call cba_fnc_addKeybind;
 
-["RD501 Jumppack Mod","Cycle jump type left",["Cycle jump type left","Cycle jump type left"],{
+["RD501 Jumppack","Cycle jump type left",["Cycle jump type left","Cycle jump type left"],{
 	[player, -1] spawn  macro_grp_fnc_name(jumppack,set_jumptype);
 
 },"",[DIK_G, [false, true, false]],false] call cba_fnc_addKeybind;
 
-["RD501 Jumppack Mod","Cycle jump type right",["Cycle jump type right","Cycle jump type right"],{
+["RD501 Jumppack","Cycle jump type right",["Cycle jump type right","Cycle jump type right"],{
 	[player, 1] spawn  macro_grp_fnc_name(jumppack,set_jumptype);
 
 },"",[DIK_J, [false, true, false]],false] call cba_fnc_addKeybind;

+ 84 - 23
addons - Copy/RD501_Main/functions/magclamp/magclamp.sqf

@@ -2,40 +2,101 @@
 #include "../../config_macros.hpp"
 
 
-//handle button press
-macro_grp_fnc_name(magclamp,handle_left_pressed) = {
+macro_grp_fnc_name(magclamp,handle_universal) = {
+    params ["_mc_pos", "_attached_var", "_forbid_param", "_offset_param"];
+
+    _vehicle = vehicle player;
+    _position = (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> _mc_pos) call BIS_fnc_getCfgDataArray;
+    _attached = _vehicle getVariable[_attached_var,objNull];
+
+    if(isNull _attached) then {
+    	_objects = nearestObjects [player, ["Car","Tank","Motorcycle","StaticWeapon","Air","Ship","Object"], 20];
+
+    	_target_index = 0;
+	    _target = _objects select _target_index;
+	    _is_attached = _target getVariable["RD501_mc_is_attached",false];
+	    _cant_be_clamped = (configFile >> "CfgVehicles" >> (typeOf _target) >> _forbid_param) call BIS_fnc_getCfgDataBool;
+
+	    while {_target isKindOf "Man" || isPlayer _target || _is_attached || _cant_be_clamped} do {
+	        _target_index = _target_index + 1;
+	        _target = _objects select _target_index;
+	        _is_attached = _target getVariable["RD501_mc_is_attached",false];
+	        _cant_be_clamped = (configFile >> "CfgVehicles" >> (typeOf _target) >> _forbid_param) call BIS_fnc_getCfgDataBool;
+        };
+
+	    _offset = (configFile >> "CfgVehicles" >> (typeOf _target) >> _offset_param) call BIS_fnc_getCfgDataArray;
+	    if (count _offset == 3) then {
+	        _position = [(_position select 0) + (_offset select 0), (_position select 1) + (_offset select 1), (_position select 2) + (_offset select 2)];
+	    };
+
+	    _target attachTo [_vehicle, _position];
+	    _vehicle setVariable[_attached_var,_target,true];
+	    _target setVariable["RD501_mc_is_attached",true,true];
+	} else {
+	    detach _attached;
+	    _vehicle setVariable[_attached_var,objNull,true];
+	    _attached setVariable["RD501_mc_is_attached",false,true];
+	};
+};
+
+macro_grp_fnc_name(magclamp,handle_small_1_pressed) = {
+    if(isNull vehicle player) exitWith {};
+    ["RD501_magclamp_small_1",
+     "RD501_mc_attached_small_1",
+     "RD501_magclamp_small_forbidden",
+     "RD501_magclamp_small_offset"] call macro_grp_fnc_name(magclamp,handle_universal);
+};
+
+macro_grp_fnc_name(magclamp,handle_large_pressed) = {
     if(isNull vehicle player) exitWith {};
-    systemChat "left clamp";
+    ["RD501_magclamp_large",
+     "RD501_mc_attached_large",
+     "RD501_magclamp_large_forbidden",
+     "RD501_magclamp_large_offset"] call macro_grp_fnc_name(magclamp,handle_universal);
 };
 
-macro_grp_fnc_name(magclamp,handle_center_pressed) = {
+macro_grp_fnc_name(magclamp,handle_small_2_pressed) = {
     if(isNull vehicle player) exitWith {};
-    systemChat "center clamp";
+    ["RD501_magclamp_small_2",
+     "RD501_mc_attached_small_2",
+     "RD501_magclamp_small_forbidden",
+     "RD501_magclamp_small_offset"] call macro_grp_fnc_name(magclamp,handle_universal);
 };
 
-macro_grp_fnc_name(magclamp,handle_right_pressed) = {
+macro_grp_fnc_name(magclamp,handle_drop_all) = {
+    if(isNull vehicle player) exitWith {};
     _vehicle = vehicle player;
-    if(isNull _vehicle) exitWith {};
-    _attached = _vehicle getVariable["RD501_mc_attached_right",objNull];
-    if(isNull _attached) then {
-    	_objects = nearestObjects [player, ["Car","Tank","Air","Ship","Object"], 20];
-	    _target = _objects select 1;
-	    _target attachTo [_vehicle, [7,-2,-2.5]];
-	    _vehicle setVariable["RD501_mc_attached_right",_target,true];
-	} else {
+    _attached = _vehicle getVariable["RD501_mc_attached_small_1",objNull];
+    if(isNull _attached) then {} else {
+	    detach _attached;
+	    _vehicle setVariable["RD501_mc_attached_small_1",objNull,true];
+	    _attached setVariable["RD501_mc_is_attached",false,true];
+    };
+    _attached = _vehicle getVariable["RD501_mc_attached_large",objNull];
+    if(isNull _attached) then {} else {
+	    detach _attached;
+	    _vehicle setVariable["RD501_mc_attached_large",objNull,true];
+	    _attached setVariable["RD501_mc_is_attached",false,true];
+    };
+    _attached = _vehicle getVariable["RD501_mc_attached_small_2",objNull];
+    if(isNull _attached) then {} else {
 	    detach _attached;
-	    _vehicle setVariable["RD501_mc_attached_right",objNull,true];
-	}
+	    _vehicle setVariable["RD501_mc_attached_small_2",objNull,true];
+	    _attached setVariable["RD501_mc_is_attached",false,true];
+    };
 };
 
 
 //add keybinds
-["RD501 Magclamp","Left Clamp",["Left","Activate/Deactivate left magclamp"],{
-    [player] call macro_grp_fnc_name(magclamp,handle_left_pressed);
+["RD501 Magclamp","small_1",["Laat/C Left    -    Laat/I","Activate/Deactivate left Magclamp on Laat/C or main Magclamp on Laat/I"],{
+    [player] call macro_grp_fnc_name(magclamp,handle_small_1_pressed);
 },"",[DIK_7,[false,false,false]],false] call cba_fnc_addKeybind;
-["RD501 Magclamp","Center Clamp",["Center","Activate/Deactivate center magclamp"],{
-    [player] call macro_grp_fnc_name(magclamp,handle_center_pressed);
+["RD501 Magclamp","large",["Laat/C Center","Activate/Deactivate center Magclamp on Laat/C"],{
+    [player] call macro_grp_fnc_name(magclamp,handle_large_pressed);
 },"",[DIK_8,[false,false,false]],false] call cba_fnc_addKeybind;
-["RD501 Magclamp","Right Clamp",["Right","Activate/Deactivate right magclamp"],{
-    [player] call macro_grp_fnc_name(magclamp,handle_right_pressed);
-},"",[DIK_9,[false,false,false]],false] call cba_fnc_addKeybind;
+["RD501 Magclamp","small_2",["Laat/C Right","Activate/Deactivate right Magclamp on Laat/C"],{
+    [player] call macro_grp_fnc_name(magclamp,handle_small_2_pressed);
+},"",[DIK_9,[false,false,false]],false] call cba_fnc_addKeybind;
+["RD501 Magclamp","detach_all",["Detach All","Detach all clamped vehicles"],{
+    [player] call macro_grp_fnc_name(magclamp,handle_drop_all);
+},"",[DIK_0,[false,false,false]],false] call cba_fnc_addKeybind;

+ 49 - 0
addons - Copy/RD501_Main/functions/magclamp/readme.md

@@ -0,0 +1,49 @@
+RD501 Magclamp Mod
+======
+
+Explanation
+------
+
+Any vehicle can be configured to carry other nearby vehicles via magclamps.
+For or this two small and one large clamp can be defined.
+If any clamp is not defined, it is unused.
+By default any vehicle can be clamped and will be carried at the clamps position.
+Individual unit classes can be set to be unclampable for small and large clamps.
+It is also possible to change the default clamp position via a offset to fit vehicles better to a carrier.
+
+
+
+Config for Carrier
+------
+
+**RD501_magclamp_small_1**<br>
+*[float, float, float]*<br>
+Clamping position for first small Magclamp. Clamp is disabled if this property is not set.
+
+**RD501_magclamp_small_2**<br>
+*[float, float, float]*<br>
+Clamping position for second small Magclamp. Clamp is disabled if this property is not set.
+
+**RD501_magclamp_large**<br>
+*[float, float, float]*<br>
+Clamping position for large Magclamp. Clamp is disabled if this property is not set.
+
+
+Config for Cargo
+------
+
+**RD501_magclamp_small_offset**<br>
+*[float, float, float]*<br>
+Moves position of cargo when clamped with a small clamp.
+
+**RD501_magclamp_large_offset**<br>
+*[float, float, float]*<br>
+Moves position of cargo when clamped with a large clamp.
+
+**RD501_magclamp_small_forbidden**<br>
+*[0, 1]*<br>
+If set, disallowes this unit being clamped with a small clamp.
+
+**RD501_magclamp_large_forbidden**<br>
+*[0, 1]*<br>
+If set, disallowes this unit being clamped with a large clamp.

+ 1 - 1
addons - Copy/RD501_Main/functions/nightvision.sqf

@@ -41,6 +41,6 @@ macro_grp_fnc_name(nightvision,handle_switch) = {
 ["loadout", macro_grp_fnc_name(nightvision,handle_change)] call CBA_fnc_addPlayerEventHandler;
 
 //add keybinds
-["RD501 Nightvision Mod","Cycle",["Cycle","Press to Cycle"],{
+["RD501 Nightvision","Cycle",["Cycle","Switch Nightvision on/off"],{
     [player] call macro_grp_fnc_name(nightvision,handle_switch);
 },"",[DIK_N,[false,true,false]],false] call cba_fnc_addKeybind;

+ 7 - 0
addons - Copy/RD501_Vehicles/air/LAAT/config.cpp

@@ -87,6 +87,7 @@ class CfgVehicles
 		#include "flight_model.hpp"
 		#include "common_stuff.hpp"
 
+		RD501_magclamp_small_1[] = {0.0,1.0,-4.5};
 	
 		class UserActions
 		{
@@ -145,6 +146,8 @@ class CfgVehicles
 		#include "flight_model.hpp"
 		#include "common_stuff.hpp"
 
+		RD501_magclamp_small_1[] = {0.0,-2.0,-2.5};
+
 		class UserActions
 		{
 			#include "user_action.hpp"
@@ -228,6 +231,10 @@ class CfgVehicles
 
 		#include "ace_stuff.hpp"
 
+		RD501_magclamp_small_1[] = {-7.0,-2.0,-2.5};
+		RD501_magclamp_large[] = {0.0,-2.0,-2.0};
+		RD501_magclamp_small_2[] = {7.0,-2.0,-2.5};
+
 		class ACE_SelfActions
 		{		
 			

+ 3 - 0
addons - Copy/RD501_Vehicles/land/artillery/config.cpp

@@ -88,6 +88,9 @@ class CfgVehicles
 		displayName="AV-76";
 		side=1;
 
+		RD501_magclamp_small_forbidden = 1;
+		RD501_magclamp_large_offset[] = {0.0,-6.0,-9.5};
+
 		faction = macro_republic_faction
 		editorSubcategory = macro_editor_cat(arty)
 		vehicleClass = macro_editor_cat(arty)