Parcourir la source

Add fired event handler, isn't working

m3ales il y a 4 ans
Parent
commit
00275adb4f

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

@@ -93,4 +93,6 @@ macro_prep_xeh(infantry_uav\fnc_refuelUAVDrone.sqf,refuelUAVDrone)
 macro_prep_xeh(infantry_uav\fnc_canRefuel.sqf,canRefuel)
 
 macro_prep_xeh(heavy_weapon\fnc_heavyWeaponHandlePlayerWeaponChanged.sqf,heavyWeaponHandlePlayerWeaponChanged)
-macro_prep_xeh(reload_on_select\fnc_reloadWeaponOnFirstSelected.sqf,reloadWeaponOnFirstSelected)
+macro_prep_xeh(reload_on_select\fnc_reloadWeaponOnFirstSelected.sqf,reloadWeaponOnFirstSelected)
+macro_prep_xeh(reload_on_select\fnc_swapToEmptyWeapon.sqf,swapToEmptyWeapon)
+macro_prep_xeh(reload_on_select\fnc_onWeaponFiredSwap.sqf,onWeaponFiredSwap)

+ 7 - 0
addons - Copy/RD501_Main/functions/reload_on_select/fnc_onWeaponFiredSwap.sqf

@@ -0,0 +1,7 @@
+params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo"];
+if(_unit ammo _muzzle > 0) exitWith
+{
+	systemChat format["fired skipped for %1", _muzzle];
+};
+systemChat format["Mag %1",_magazine];
+[_unit, _weapon] call macro_fnc_name(swapToEmptyWeapon);

+ 1 - 1
addons - Copy/RD501_Main/functions/reload_on_select/fnc_reloadWeaponOnFirstSelected.sqf

@@ -5,7 +5,7 @@ if(_weapon in RD501_AUTO_RELOAD_ON_EQUIP) then
 	systemChat "Weapon in list";
 	if(count (secondaryWeaponMagazine _unit) == 0) then {
 		systemChat "Weapon in list";
-		_magazineName = getArray(configFile >> "cfgWeapons" >> currentWeapon _unit >> "magazines") select 0;
+		_magazineName = getArray(configFile >> "CfgWeapons" >> currentWeapon _unit >> "magazines") select 0; // TODO: Cache in postInit
 		systemChat format["AutoReloading with %1", _magazineName]; 
 		_unit removeMagazines _magazineName;
 		_unit addMagazine _magazineName;

+ 3 - 17
addons - Copy/RD501_Main/functions/reload_on_select/fnc_swapToEmptyWeapon.sqf

@@ -1,18 +1,4 @@
-
-
 params["_unit", "_weapon"];
-private _emptyWeapon = getText(configFile >> "CfgWeapons" >> _weapon >> "RD501_Empty_Weapon");
-switch (true) do {
-	case (_weapon in uniformItems _unit): {
-		_unit removeItemFromUniform _weapon;
-		_unit addItemToUniform _emptyWeapon;
-	};
-	case (_weapon in vestItems _unit): {
-		_unit removeItemFromVest _weapon;
-		_unit addItemToVest _emptyWeapon;
-	};
-	case (_weapon in backpackItems _unit): {
-		_unit removeItemFromBackpack _weapon;
-		_unit addItemToBackpack _emptyWeapon;
-	};
-};
+ 
+_unit removeWeaponGlobal _weapon;
+_unit addWeaponGlobal getText(configFile >> "CfgWeapons" >> _weapon >> "RD501_Empty_Weapon"); // TODO: Cache during postInit

+ 4 - 0
addons - Copy/RD501_Weapons/Z6/config.cpp

@@ -146,10 +146,14 @@ class cfgWeapons
         scopeArsenal=2;
 		recoil="recoil_mmg_01";
         displayName="Republic Z1000 Chaingun";
+		RD501_Empty_Weapon = macro_quote(macro_new_weapon_nofam(z1000u));
 		magazines[]=
 		{
 			macro_new_mag(z1000,3000)
 		};
+		class EventHandlers {
+			fired = macro_quote(_this call macro_fnc_name(onWeaponFiredSwap));
+		};
     };
 	class macro_new_weapon_nofam(z1000u): 3AS_Chaingun
     {