Procházet zdrojové kódy

Ensure turrets are disabled

m3ales před 2 roky
rodič
revize
cff4f4060c

+ 14 - 4
addons - Copy/RD501_Main/functions/emp_vehicle/fnc_emp_disableVehicle.sqf

@@ -1,6 +1,6 @@
 params["_vehicle"];
 
-if!(local _vehicle) exitWith { };
+if!(local _vehicle) exitWith { diag_log "[RD501][Vehicle EMP] Exiting disable because not local"; };
 diag_log format["[RD501][Vehicle EMP] Disabling Vehicle '%1'", _vehicle];
 
 _vehicle allowCrewInImmobile true;
@@ -17,6 +17,17 @@ _vehicle lock 2;
 
 (getAllHitPointsDamage _vehicle) params [["_allHitPoints", []]];
 
+_fnc_matchesAnyTurret = {
+	params["_hitpoint"];
+	private _found = false;
+	{
+		if(_hitpoint find _x != -1) exitWith {
+			_found = true;
+		};
+	} forEach ["turret","Turret","vez","Vez","zbran","Zbran","gun","Gun"];
+	_found
+};
+
 {
 	private _isEngineLower = (_x find "engine") != -1;
 	private _isEngineUpper = (_x find "Engine") != -1;
@@ -25,9 +36,8 @@ _vehicle lock 2;
 		diag_log format["[RD501][Vehicle EMP] Damaging %1", _x];
 	};
 
-	private _isTurretLower = (_x find "turret") != -1;
-	private _isTurretUpper = (_x find "Turret") != -1;
-	if(_isEngineLower || _isEngineUpper) then {
+	private _isTurret = [_x] call _fnc_matchesAnyTurret;
+	if(_isTurret) then {
 		_vehicle setHitPointDamage [_x, 1, true];
 		diag_log format["[RD501][Vehicle EMP] Damaging %1", _x];
 	};

+ 15 - 5
addons - Copy/RD501_Main/functions/emp_vehicle/fnc_emp_enableVehicle.sqf

@@ -1,6 +1,6 @@
 params["_vehicle"];
 
-if!(local _vehicle) exitWith { };
+if!(local _vehicle) exitWith {  diag_log "[RD501][Vehicle EMP] Exiting enable because not local";  };
 diag_log format["[RD501][Vehicle EMP] Enabling Vehicle '%1'", _vehicle];
 
 _vehicle allowCrewInImmobile false;
@@ -17,6 +17,17 @@ _vehicle lock 0;
 
 (getAllHitPointsDamage _vehicle) params [["_allHitPoints", []]];
 
+_fnc_matchesAnyTurret = {
+	params["_hitpoint"];
+	private _found = false;
+	{
+		if(_hitpoint find _x != -1) exitWith {
+			_found = true;
+		};
+	} forEach ["turret","Turret","vez","Vez","zbran","Zbran","gun","Gun"];
+	_found
+};
+
 {
 	private _isEngineLower = (_x find "engine") != -1;
 	private _isEngineUpper = (_x find "Engine") != -1;
@@ -25,12 +36,11 @@ _vehicle lock 0;
 		diag_log format["[RD501][Vehicle EMP] Repairing %1", _x];
 	};
 
-	private _isTurretLower = (_x find "turret") != -1;
-	private _isTurretUpper = (_x find "Turret") != -1;
-	if(_isEngineLower || _isEngineUpper) then {
+	private _isTurret = [_x] call _fnc_matchesAnyTurret;
+	if(_isTurret) then {
 		_vehicle setHitPointDamage [_x, 0];
 		diag_log format["[RD501][Vehicle EMP] Repairing %1", _x];
 	};
 } forEach _allHitPoints;
 
-_vehicle engineOn true;
+_vehicle engineOn true;