Browse Source

Merge pull request #73 from 501st-Aux-Mod-Team/fix-restricitons-z1000

Fix restricitons z1000
Erliens 4 years ago
parent
commit
47d0b776e9

+ 2 - 1
.gitignore

@@ -2,4 +2,5 @@
 *.pbo
 *.bak
 *.bisign
-.idea
+.idea
+*.code-workspace

+ 5 - 2
addons - Copy/RD501_Main/XEH_postinit.sqf

@@ -12,5 +12,8 @@ call macro_fnc_name(nightvision);
 
 // Drone Recharge
 RD501_DRONE_BATTERY = "lightsaberG_swing";
-RD501_FORCE_WALK_WEAPONS = [macro_quote(macro_new_weapon_nofam(Z1000))];
-["weapon", macro_fnc_name(heavyWeaponHandlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler;
+RD501_FORCE_WALK_WEAPONS = [macro_quote(macro_new_weapon_nofam(z1000))];
+["weapon", macro_fnc_name(heavyWeaponHandlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler;
+
+RD501_AUTO_RELOAD_ON_EQUIP = [macro_quote(macro_new_weapon_nofam(z1000))];
+["weapon", macro_fnc_name(reloadWeaponOnFirstSelected)] call CBA_fnc_addPlayerEventHandler;

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

@@ -92,4 +92,7 @@ macro_prep_xeh(infantry_uav\fnc_getRefuelMagazine.sqf,getRefuelMagazine)
 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(heavy_weapon\fnc_heavyWeaponHandlePlayerWeaponChanged.sqf,heavyWeaponHandlePlayerWeaponChanged)
+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_onWeaponFiredSwapToEmpty.sqf,onWeaponFiredSwapToEmpty)

+ 4 - 2
addons - Copy/RD501_Main/functions/heavy_weapon/fnc_heavyWeaponHandlePlayerWeaponChanged.sqf

@@ -1,6 +1,7 @@
 params ["_unit", "_weapon"];
 diag_log "Handling Weapon Swap";
 if(_weapon == "" && !isForcedWalk _unit) exitWith { diag_log "No Weapon"; };
+diag_log format["%1 :: %2",_weapon, _unit];
 
 private _fn_unForceWalk = {
 	params["_target"];
@@ -8,9 +9,9 @@ private _fn_unForceWalk = {
 	_target setVariable ["RD501_FORCE_WALK", false];
 	_target forceWalk false;
 };
-
 private _forceWalk = _unit getVariable ["RD501_FORCE_WALK", false];
 
+diag_log format["Checking _forceWalk :: %1", _forceWalk];
 if(_weapon == "" && _forceWalk) exitWith {
 	_unit call _fn_unForceWalk;
 };
@@ -22,7 +23,8 @@ private _fn_forceWalk = {
 	_target forceWalk true;
 };
 
-if(_weapon in RD501_FORCE_WALK_WEAPONS ) exitWith 
+diag_log format["Weapon in array :: %1", (_weapon in RD501_FORCE_WALK_WEAPONS)];
+if(_weapon in RD501_FORCE_WALK_WEAPONS) exitWith 
 {
 	if(!isForcedWalk _unit) then{
 		_unit call _fn_forceWalk;

+ 8 - 0
addons - Copy/RD501_Main/functions/reload_on_select/fnc_onWeaponFiredSwapToEmpty.sqf

@@ -0,0 +1,8 @@
+#include "../../config_macros.hpp"
+params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo"];
+if(_unit ammo _muzzle > 0) exitWith
+{
+	diag_log format["fired skipped for %1", _muzzle];
+};
+diag_log format["Mag %1",_magazine];
+[_unit, _weapon] call macro_fnc_name(swapToEmptyWeapon);

+ 14 - 0
addons - Copy/RD501_Main/functions/reload_on_select/fnc_reloadWeaponOnFirstSelected.sqf

@@ -0,0 +1,14 @@
+params ["_unit", "_weapon"];
+diag_log "Handling Disposable Reload";
+if(_weapon in RD501_AUTO_RELOAD_ON_EQUIP) then
+{
+	diag_log "Weapon in list";
+	if(count (secondaryWeaponMagazine _unit) == 0) then {
+		diag_log "Weapon in list";
+		_magazineName = getArray(configFile >> "CfgWeapons" >> currentWeapon _unit >> "magazines") select 0; // TODO: Cache in postInit
+		diag_log format["AutoReloading with %1", _magazineName]; 
+		_unit removeMagazines _magazineName;
+		_unit addMagazine _magazineName;
+		_unit removeSecondaryWeaponItem _magazineName;
+	};
+};

+ 4 - 0
addons - Copy/RD501_Main/functions/reload_on_select/fnc_swapToEmptyWeapon.sqf

@@ -0,0 +1,4 @@
+params["_unit", "_weapon"];
+ 
+_unit removeWeaponGlobal _weapon;
+_unit addWeaponGlobal getText(configFile >> "CfgWeapons" >> _weapon >> "RD501_Empty_Weapon"); // TODO: Cache during postInit

BIN
addons - Copy/RD501_Weapons/Z6/chaingun_icon.paa


+ 7 - 1
addons - Copy/RD501_Weapons/Z6/config.cpp

@@ -146,16 +146,22 @@ class cfgWeapons
         scopeArsenal=2;
 		recoil="recoil_mmg_01";
         displayName="Republic Z1000 Chaingun";
+		picture = "\RD501_Weapons\Z6\chaingun_icon.paa";
+		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(onWeaponFiredSwapToEmpty));
+		};
     };
 	class macro_new_weapon_nofam(z1000u): 3AS_Chaingun
     {
         scope=1;
         scopeArsenal=1;
-        displayName="Z1000 Chaingun(Used)";
+        displayName="Z1000 Chaingun (Used)";
+		picture = "\RD501_Weapons\Z6\chaingun_icon.paa";
         _generalMacro="launch_RPG32_F";
 		magazines[]=
 		{

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

@@ -477,7 +477,7 @@ class CfgMagazines
 		ammo = macro_new_ammo(z1000)
 		displayName="3000Rnd Z1000 Chaingun Drum";
 		initSpeed=860;
-		weight=400;
+		weight=1;
 		scope=1;
 	};