Browse Source

eventhandler stuff;

thefloff 4 years ago
parent
commit
aaa12df1be

+ 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);

+ 0 - 1
addons - Copy/RD501_Main/config.cpp

@@ -679,7 +679,6 @@ class CfgVehicles
 			killed="(_this select 0) setVariable ['GEARF_HelmetAttached', false]; (_this select 0) setVariable ['GEARF_HelmetAttachedClass','']; (_this select 0) setVariable ['GEARF_HelmetAdditionalClass',''];";
 			getInMan="[(_this select 0), true] call GEARF_fnc_hideSlungHelmet";
 			getOutMan="[(_this select 0), false] call GEARF_fnc_hideSlungHelmet;";
-			hit="[(_this select 0), (_this select 1), (_this select 3)] call RD501_fnc_stun";
 		};
 	};
 };

+ 16 - 12
addons - Copy/RD501_Main/functions/stun/stun.sqf

@@ -1,16 +1,20 @@
-params ["_unit", "_source", "_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;
+_onHit = {
+	params ["_unit", "_source", "_damage", "_instigator"];
 
-	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;
+		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;
 
-	};
-} remoteExec ['call', _instigator];
+		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;