diff --git a/cScripts/CfgFunctions.hpp b/cScripts/CfgFunctions.hpp index e63297b46..64bbd4821 100644 --- a/cScripts/CfgFunctions.hpp +++ b/cScripts/CfgFunctions.hpp @@ -167,6 +167,7 @@ class cScripts { class vehicle_getPylon {}; // Other + class vehicle_reset {}; class vehicle_addFlagAction {}; }; class modules { diff --git a/cScripts/functions/mission/fn_addGetOutHelo.sqf b/cScripts/functions/mission/fn_addGetOutHelo.sqf index f9a32dc84..ae9ae328c 100644 --- a/cScripts/functions/mission/fn_addGetOutHelo.sqf +++ b/cScripts/functions/mission/fn_addGetOutHelo.sqf @@ -29,18 +29,18 @@ if (_useColor) then { _rightSide = "Get out Right Side"; }; -_vehicle addAction [ +private _actionIDL = _vehicle addAction [ _leftSide, {[_this select 0, true] call FUNC(doGetOutHeloSide)}, 0, 1.5, true, true, "User12", "(_target getCargoIndex _this) != -1" ]; -_vehicle addAction [ +private _actionIDR = _vehicle addAction [ _rightSide, {[_this select 0, false] call FUNC(doGetOutHeloSide)}, 0, 1.5, true, true, "User13", "(_target getCargoIndex _this) != -1" ]; -_vehicle setVariable [QEGVAR(Vehicle,doGetOutHeloSide),"true"]; +_vehicle setVariable [QEGVAR(Vehicle,GetOutRightLeft), [_vehicle, [_actionIDL, _actionIDR]], true]; diff --git a/cScripts/functions/mission/fn_addHaloJump.sqf b/cScripts/functions/mission/fn_addHaloJump.sqf index 08cd84871..351d615d4 100644 --- a/cScripts/functions/mission/fn_addHaloJump.sqf +++ b/cScripts/functions/mission/fn_addHaloJump.sqf @@ -27,7 +27,7 @@ if (!isNil {_vehicle getVariable QEGVAR(Vehicle,Halo)}) exitWith {[format["Aircr private _conditionHoldAction = format ["((_target getCargoIndex player) != -1) && ((_target animationPhase 'ramp_bottom' > 0.64) or (_target animationPhase 'door_2_1' == 1) or (_target animationPhase 'door_2_2' == 1) or (_target animationPhase 'jumpdoor_1' == 1) or (_target animationPhase 'jumpdoor_2' == 1) or (_target animationPhase 'back_ramp_switch' == 1) or (_target animationPhase 'back_ramp_half_switch' == 1) or (_target doorPhase 'RearDoors' > 0.5) or (_target doorPhase 'Door_1_source' > 0.5) or (_target animationSourcePhase 'ramp_anim' > 0.5)) && ((getPosVisual _target) select 2 >= %1)", _minAltetude]; // Add hold action for jump -[ +private _actionID = [ _vehicle, "HALO Jump", "cScripts\Data\Icon\icon_02.paa", @@ -48,4 +48,4 @@ private _conditionHoldAction = format ["((_target getCargoIndex player) != -1) & false ] call BIS_fnc_holdActionAdd; -_vehicle setVariable [QEGVAR(Vehicle,Halo), [_vehicle, _minAltetude, _chuteBackpackClass]]; +_vehicle setVariable [QEGVAR(Vehicle,Halo), [_vehicle, _actionID, _minAltetude, _chuteBackpackClass], true]; diff --git a/cScripts/functions/mission/fn_addLineJump.sqf b/cScripts/functions/mission/fn_addLineJump.sqf index a58116d2c..11d0bb575 100644 --- a/cScripts/functions/mission/fn_addLineJump.sqf +++ b/cScripts/functions/mission/fn_addLineJump.sqf @@ -32,7 +32,7 @@ if (!isNil {_vehicle getVariable QEGVAR(Vehicle,Jump)}) exitWith {[format["Aircr private _conditionHoldAction = format ["((_target getCargoIndex player) != -1) && ((_target animationPhase 'ramp_bottom' > 0.64) or (_target animationPhase 'door_2_1' == 1) or (_target animationPhase 'door_2_2' == 1) or (_target animationPhase 'jumpdoor_1' == 1) or (_target animationPhase 'jumpdoor_2' == 1) or (_target animationPhase 'back_ramp_switch' == 1) or (_target animationPhase 'back_ramp_half_switch' == 1) or (_target doorPhase 'RearDoors' > 0.5) or (_target doorPhase 'Door_1_source' > 0.5) or (_target animationSourcePhase 'ramp_anim' > 0.5)) && ((getPosVisual _target) select 2 >= %1) && ((getPosVisual _target) select 2 <= %2) && (speed _target <= %3)", _minAltetude, _maxAltetude, _maxSpeed]; // Add hold action for jump -[ +private _actionID = [ _vehicle, "Jump", "cScripts\Data\Icon\icon_02.paa", @@ -53,4 +53,4 @@ private _conditionHoldAction = format ["((_target getCargoIndex player) != -1) & false ] call BIS_fnc_holdActionAdd; -_vehicle setVariable [QEGVAR(Vehicle,Jump),[_vehicle, _minAltetude, _maxAltetude, _maxSpeed, _chuteVehicleClass]]; +_vehicle setVariable [QEGVAR(Vehicle,Jump), [_vehicle, _actionID, _minAltetude, _maxAltetude, _maxSpeed, _chuteVehicleClass], true]; diff --git a/cScripts/functions/vehicle/fn_vehicle_reset.sqf b/cScripts/functions/vehicle/fn_vehicle_reset.sqf new file mode 100644 index 000000000..caf49a664 --- /dev/null +++ b/cScripts/functions/vehicle/fn_vehicle_reset.sqf @@ -0,0 +1,68 @@ +#include "..\script_component.hpp"; +/* + * Author: CPL.Brostrom.A + * This function clears all function variables as well as its attachments + * + * Arguments: + * 0: Vehicle + * + * Example: + * ["vic"] call cScripts_fnc_vehicle_reset; + * + * Public: No + */ + +params [["_vehicle", objNull, [objNull]]]; +if (!isServer) exitWith {}; +if (_vehicle iskindOf "man") exitWith {}; + +// Clear cosmetics and labels +private _labels = _vehicle getVariable [QEGVAR(Vehicle,Labels), []]; +if (count _labels != 0) then {{deleteVehicle _x} forEach _labels;}; +_vehicle getVariable [QEGVAR(Vehicle,Labels), nil]; +_vehicle setVariable [QEGVAR(Vehicle,Cosmetics), nil, true]; + +_vehicle setVariable [QEGVAR(Vehicle,Callsign), nil, true]; +_vehicle setVariable [QEGVAR(Vehicle,Name), nil, true]; + + +// Clear pylon +_vehicle setVariable [QEGVAR(vehicle,Pylon), nil, true]; +_vehicle setVariable [QEGVAR(Vehicle,PylonApplyed), nil, true]; + + +// Clear Functions variable and vehicle type +_vehicle setVariable [QEGVAR(Vehicle,Type), nil, true]; // Clear type in case of +_vehicle setVariable [QEGVAR(Vehicle,Functions), nil, true]; + + +// Clear and remove helicopter Get Out or Jump actions +private _getOutActionIDs = _vehicle getVariable [QEGVAR(Vehicle,GetOutRightLeft), [_vehicle, [_actionIDL, _actionIDR]]]; +if (!isNil {_vehicle getVariable QEGVAR(Vehicle,GetOutRightLeft)}) then { + {_vehicle removeAction _x} forEach _getOutActionIDs select 1; +}; +private _jumpActionID = _vehicle getVariable [QEGVAR(Vehicle,Jump), [_vehicle, _actionID, _minAltetude, _maxAltetude, _maxSpeed, _chuteVehicleClass]]; +if (!isNil {_vehicle getVariable QEGVAR(Vehicle,Jump)}) then { + [_vehicle, _jumpActionID select 1] call BIS_fnc_holdActionRemove +}; +private _heloActionID = _vehicle getVariable [QEGVAR(Vehicle,Halo), [_vehicle, _actionID, _minAltetude, _chuteBackpackClass]]; +if (!isNil {_vehicle getVariable QEGVAR(Vehicle,Halo)}) then { + [_vehicle, _heloActionID select 1] call BIS_fnc_holdActionRemove +}; + + +// Reset vehicle inventory variable +_vehicle setVariable [QEGVAR(Vehicle,Inventory), nil, true]; + + +// Clear radio +_vehicle setVariable [QEGVAR(Vehicle,Radio), nil, true]; + + +// Reset ACE Medical Vehicle +_vehicle setVariable ["ace_medical_isMedicalVehicle", nil, true]; + + +// Remove any other random stuff +_vehicle setPlateNumber ""; +_vehicle forceFlagTexture ""; \ No newline at end of file