Explorar o código

Merge pull request #139 from 501st-Aux-Mod-Team/surrender_stun

Surrender stun
Erliens %!s(int64=4) %!d(string=hai) anos
pai
achega
eb89895062

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

@@ -43,4 +43,7 @@ rd501_flip_vehicle_validBackpacks = ["RD501_JLTS_Clone_Flip_backpack"];
 ["rd501_external_reload", { _this call rd501_fnc_onReloadExternalHandler }, []] call CBA_fnc_addEventHandlerArgs;
 
 // Fortify Tool Adjustments
-call macro_fnc_name(fortify_tool);
+call macro_fnc_name(fortify_tool);
+
+// Surrender stun
+call macro_fnc_name(stun);

+ 4 - 1
addons - Copy/RD501_Main/XEH_preInit.sqf

@@ -116,4 +116,7 @@ macro_prep_xeh(external_reload\fnc_reloadExternal.sqf,reloadExternal)
 macro_prep_xeh(external_reload\fnc_onReloadExternalHandler.sqf,onReloadExternalHandler)
 
 // Heal Nearby
-macro_prep_xeh(heal_nearby\fnc_healAllNearby.sqf,healAllNearby)
+macro_prep_xeh(heal_nearby\fnc_healAllNearby.sqf,healAllNearby)
+
+// stun
+macro_prep_xeh(stun\stun.sqf,stun)

+ 14 - 0
addons - Copy/RD501_Main/functions/stun/readme.md

@@ -0,0 +1,14 @@
+RD501 Surrender Stun Mod
+======
+
+Explanation
+------
+This system makes it possible to create ammo that 'stuns' the target for a given amount of time. The 'stun' is simulated by making the target surrender for that period.
+
+Config
+------
+ammo can be set to be stun ammo using the following value:<br>
+
+**RD501_stunDuration**<br>
+*float*<br>
+number of seconds the stun should last for

+ 20 - 0
addons - Copy/RD501_Main/functions/stun/stun.sqf

@@ -0,0 +1,20 @@
+
+_onHit = {
+	params ["_unit", "_source", "_damage", "_instigator"];
+
+	{
+		private _mag = currentMagazine _source;
+		private _ammo = (configFile >> "CfgMagazines" >> _mag >> "ammo") call BIS_fnc_getCfgData;
+		private _stunDuration = (configFile >> "CfgAmmo" >> _ammo >> "RD501_stunDuration") call BIS_fnc_getCfgData;
+
+		if (_stunDuration > 0.0) then
+		{
+			["ace_captives_setSurrendered" ,[_unit, true]] call CBA_fnc_globalEvent;
+			[{
+				["ace_captives_setSurrendered", [_this select 0, false]] call CBA_fnc_globalEvent;
+			}, [_unit], _stunDuration] call CBA_fnc_waitAndExecute;
+
+		};
+	} remoteExec ['call', _instigator];
+};
+_handler = ["CAManBase", "Hit", _onHit] call CBA_fnc_addClassEventHandler;

+ 11 - 0
addons - Copy/RD501_Weapons/_ammo/config.cpp

@@ -32,6 +32,17 @@ class CfgAmmo
 	class B_12Gauge_Pellets_Submunition;
 	class  B_12Gauge_Pellets_Submunition_Deploy;
 	class FlareBase;
+	class JLTS_bullet_stun;
+	class macro_new_ammo(surrender_stun): JLTS_bullet_stun
+	{
+		model="\MRC\JLTS\weapons\Core\effects\stun.p3d";
+		hit=0.0099999998;
+		JLTS_isStunAmmo=0;
+		typicalSpeed=30;
+		timetolive=3;
+		aiAmmoUsageFlags=0;
+		RD501_stunDuration=30;
+	};
 	class macro_new_ammo(2mw):3AS_EC20_BluePlasma
 	{
 		hit=4;

+ 1 - 0
addons - Copy/RD501_Weapons/_mag/config.cpp

@@ -196,6 +196,7 @@ class CfgMagazines
 		displayNameShort = "5 Round Stun Cell";
 		count=5;
 		picture="\MRC\JLTS\weapons\Core\data\ui\stun_mag_ui_ca";
+		ammo=macro_new_ammo(surrender_stun)
 	};
 
 	////////////////////////////////////////////////////