Browse Source

Probably works

m3ales 4 years ago
parent
commit
12b57a5b40

+ 24 - 0
addons - Copy/RD501_Main/functions/init/deka_shield_init.sqf

@@ -0,0 +1,24 @@
+params ["_unit"];
+
+private _hitEH = _unit addEventHandler ["HitPart", { 
+	(_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];
+	[{
+		params["_unit"];
+		private _ehId = _unit getVariable ["rd501_dekashield_hitEH", -1];
+		if(alive _unit && _ehId != -1) then {
+			private _position = getPosATL _unit;
+			private _shield = "RD501_Squad_Shield" createVehicle _position;
+			_unit setVariable ["rd501_dekashield_attached", _shield, true];
+			_shield setPosATL _position;
+			_shield attachTo [_unit, [0,0,0]];
+			[{
+				params["_shield"];
+				deleteVehicle _shield;
+			}, [_shield], 60] call CBA_fnc_waitAndExecute;
+			_unit setVariable ["rd501_dekashield_hitEH", -1, true];
+			_unit removeEventHandler ["", _ehId];
+		};
+	}, [_target], 1] call CBA_fnc_waitAndExecute;
+}];
+
+_unit setVariable ["rd501_dekashield_hitEH", _hitEH, false];

+ 11 - 2
addons - Copy/RD501_Vehicles/land/droideka/config.cpp

@@ -59,6 +59,15 @@ class CfgVehicles
 			};
 		};
 	};
-
-
 };
+
+class Extended_Init_EventHandlers
+{
+	class macro_new_vehicle(droideka,base)
+	{
+		class rd501_deka_shield
+		{
+			init = "_this call rd501_fnc_droideka_shield_init.sqf";
+		};
+	};
+}