Moved FRIES equipping into seperate function

This commit is contained in:
BaerMitUmlaut 2016-02-22 14:40:04 +01:00
parent ea92424d15
commit af834838ef
3 changed files with 42 additions and 21 deletions

View File

@ -8,6 +8,7 @@ PREP(canFastRope);
PREP(canPrepareFRIES);
PREP(cutRopes);
PREP(deployRopes);
PREP(equipFRIES);
PREP(fastRope);
PREP(fastRopeLocalPFH);
PREP(fastRopeServerPFH);

View File

@ -0,0 +1,39 @@
/*
* Author: BaerMitUmlaut
* Equips the given helicopter with a FRIES.
*
* Arguments:
* 0: The helicopter <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_vehicle] call ace_fastroping_fnc_equipFRIES
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
private ["_config", "_fries"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
if !(isNumber (_config >> QGVAR(enabled))) then {
["%1 has not been configured for ACE_Fastroping.", getText (_config >> "DisplayName")] call BIS_fnc_error;
} else {
if (getNumber (_config >> QGVAR(enabled)) == 2) then {
_fries = (getText (_config >> QGVAR(friesType))) createVehicle [0, 0, 0];
_fries attachTo [_vehicle, (getArray (_config >> QGVAR(friesAttachmentPoint)))];
_vehicle setVariable [QGVAR(FRIES), _fries, true];
_vehicle addEventHandler ["Killed", {
params ["_vehicle"];
deleteVehicle (_vehicle getVariable [QGVAR(FRIES), objNull]);
_vehicle setVariable [QGVAR(FRIES), nil, true];
if !((_vehicle getVariable [QGVAR(deployedRopes), []] isEqualTo [])) then {
[_vehicle] call FUNC(cutRopes);
};
}];
};
};

View File

@ -16,31 +16,12 @@
#include "script_component.hpp"
params ["_module"];
private ["_synchedUnits", "_config", "_fries"];
_synchedUnits = synchronizedObjects _module;
private _synchedUnits = synchronizedObjects _module;
{
if (_x isKindOf "CAManBase") then {
_x = vehicle _x;
};
_config = configFile >> "CfgVehicles" >> typeOf _x;
if !(isNumber (_config >> QGVAR(enabled))) then {
["%1 has not been configured for ACE_Fastroping.", getText (_config >> "DisplayName")] call BIS_fnc_error;
} else {
if (getNumber (_config >> QGVAR(enabled)) == 2) then {
_fries = (getText (_config >> QGVAR(friesType))) createVehicle [0, 0, 0];
_fries attachTo [_x, (getArray (_config >> QGVAR(friesAttachmentPoint)))];
_x setVariable [QGVAR(FRIES), _fries, true];
_x addEventHandler ["Killed", {
params ["_vehicle"];
deleteVehicle (_vehicle getVariable [QGVAR(FRIES), objNull]);
_vehicle setVariable [QGVAR(FRIES), nil, true];
if !((_vehicle getVariable [QGVAR(deployedRopes), []] isEqualTo [])) then {
[_vehicle] call FUNC(cutRopes);
};
}];
};
};
[_x] call FUNC(equipFRIES);
false
} count _synchedUnits;