Browse Source

Add squad shield throwable script

m3ales 4 years ago
parent
commit
9899584a9a
1 changed files with 47 additions and 1 deletions
  1. 47 1
      addons - Copy/RD501_Main/XEH_postinit.sqf

+ 47 - 1
addons - Copy/RD501_Main/XEH_postinit.sqf

@@ -79,4 +79,50 @@ call macro_fnc_name(stun);
 	[{
 		_this call rd501_fnc_jammersServerPFH
 	}, 1] call CBA_fnc_addPerFrameHandler;
-}] call CBA_fnc_addEventHandler;
+}] call CBA_fnc_addEventHandler;
+
+// Grenade Deployables
+["ace_firedPlayer", {
+	params["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
+
+	if (isNull _projectile) then {
+		systemChat "Empty projectile, fixing...";
+		_projectile = nearestObject [_unit, _ammo];
+	};
+	private _config = configFile >> "CfgAmmo" >> _ammo;
+	if (getNumber (_config >> "rd501_grenade_deployable") == 1) then {
+		private _deployable = getText (_config >> "rd501_grenade_deployable_object");
+		private _ttl = getNumber (_config >> "rd501_grenade_deployable_timeToLive");
+		if(isNil "_ttl") then {
+			_ttl = -1;
+		};
+		systemChat str _ttl;
+		[
+			{
+				params["_projectile", "_deployable"];
+				private _speed = vectorMagnitude (velocity _projectile);
+				_speed <= 0.1
+			}, 
+			{
+				params["_projectile", "_deployable", "_timeToLive"];
+				private _position = getPosATL _projectile;
+				systemChat format["Deploying at %1", _position];
+				private _deployed = _deployable createVehicle _position;
+				if(_timeToLive > -1) then {
+					[
+						{
+							params["_deployed"];
+							systemChat "Destroying";
+							deleteVehicle _deployed;
+						},
+						[_deployed],
+						_timeToLive
+					] call CBA_fnc_waitAndExecute;
+				};
+			},
+			[_projectile, _deployable, _ttl],
+			10, 
+			{ systemChat "Give grenade back to person, something went wrong"; }
+		] call CBA_fnc_waitUntilAndExecute;
+	};
+}] call CBA_fnc_addEventHandler;