diff --git a/addons/common/functions/fnc_setForceWalkStatus.sqf b/addons/common/functions/fnc_setForceWalkStatus.sqf index 9935f4ad21..aaa594b9a9 100644 --- a/addons/common/functions/fnc_setForceWalkStatus.sqf +++ b/addons/common/functions/fnc_setForceWalkStatus.sqf @@ -1,36 +1,34 @@ /* -Name: FUNC(setForceWalkStatus) - -Author: Pabst Mirror (from captivity by commy2) - -Description: - Sets the forceWalk status of an unit. This allows the handling of more than one reason to set forceWalk. - Unit will force walk until all reasons are removed. - -Parameters: - 0: OBJECT - Unit - 1: STRING - Reason for forcing walking - 2: BOOL - Is the reason still valid. True to force walk, false to remove restriction. - -Returns: - None - -Example: - [ACE_Player, "BrokenLeg", true] call FUNC(setForceWalkStatus) + * Author: Pabst Mirror (from captivity by commy2) + * Sets the forceWalk status of an unit. This allows the handling of more than one reason to set forceWalk. + * Unit will force walk until all reasons are removed. + * + * Arguments: + * 0: Unit + * 1: Reason for forcing walking + * 2: Is the reason still valid. True to force walk, false to remove restriction. + * + * Returns: + * None + * + * Example: + * [ACE_Player, "BrokenLeg", true] call FUNC(setForceWalkStatus) + * + * Public: No */ #include "script_component.hpp" -private ["_forceWalkReasons", "_unitForceWalkReasons", "_forceWalkReasonsBooleans", "_bitmaskNumber"]; +params ["_unit", "_reason", "_status"]; -PARAMS_3(_unit,_reason,_status); +private ["_forceWalkReasons", "_unitForceWalkReasons", "_forceWalkReasonsBooleans", "_bitmaskNumber"]; _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; // register new reason (these reasons are shared publicly, since units can change ownership, but keep their forceWalk status) if !(_reason in _forceWalkReasons) then { - _forceWalkReasons pushBack _reason; - ACE_forceWalkReasons = _forceWalkReasons; - publicVariable "ACE_forceWalkReasons"; + _forceWalkReasons pushBack _reason; + ACE_forceWalkReasons = _forceWalkReasons; + publicVariable "ACE_forceWalkReasons"; }; // get reasons why the unit is forceWalking already and update to the new status @@ -38,7 +36,7 @@ _unitForceWalkReasons = [_unit] call FUNC(getForceWalkStatus); _forceWalkReasonsBooleans = []; { - _forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons]; + _forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons]; } forEach _forceWalkReasons; _forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status]; @@ -48,4 +46,4 @@ _bitmaskNumber = _forceWalkReasonsBooleans call FUNC(toBitmask); _unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true]; // actually apply the forceWalk command globaly -[[_unit], QUOTE(FUNC(applyForceWalkStatus)), 2] call FUNC(execRemoteFnc); +[[_unit], QFUNC(applyForceWalkStatus), 2] call FUNC(execRemoteFnc); diff --git a/addons/common/functions/fnc_setHearingCapability.sqf b/addons/common/functions/fnc_setHearingCapability.sqf index 3e2939d29b..9dea992e3e 100644 --- a/addons/common/functions/fnc_setHearingCapability.sqf +++ b/addons/common/functions/fnc_setHearingCapability.sqf @@ -1,23 +1,22 @@ -/** - * fn_setHearingCapability.sqf - * @Descr: Handle set volume calls. Will use the lowest available volume setting. - * @Author: Glowbal +/* + * Author: Glowbal + * Handle set volume calls. Will use the lowest available volume setting. * - * @Arguments: [id STRING, settings NUMBER, add BOOL (Optional. True will add, false will remove. Default value is true)] - * @Return: nil - * @PublicAPI: true + * Arguments: + * 0: id + * 1: settings + * 2: add (default: true) + * + * Return Value: + * None + * + * Public: Yes */ - #include "script_component.hpp" -private ["_add", "_exists", "_map", "_lowestVolume"]; +params ["_id", "_settings", ["_add", true]]; -PARAMS_2(_id,_settings); - -_add = true; -if (count _this > 2) then { - _add = _this select 2; -}; +private ["_map", "_exists", "_lowestVolume"]; _map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]]; @@ -44,7 +43,8 @@ missionNamespace setVariable [QGVAR(setHearingCapabilityMap), _map]; _lowestVolume = 1; { _lowestVolume = (_x select 1) min _lowestVolume; -} forEach _map; + false +} count _map; // in game sounds 0 fadeSound _lowestVolume; diff --git a/addons/common/functions/fnc_setParameter.sqf b/addons/common/functions/fnc_setParameter.sqf index d7a4573935..6a1345479b 100644 --- a/addons/common/functions/fnc_setParameter.sqf +++ b/addons/common/functions/fnc_setParameter.sqf @@ -4,19 +4,23 @@ * Sets the value of an ACE_Parameter and makes it public. * * Arguments: - * 0: Parameter name (string) + * 0: Parameter name * 1: Value * * Return Value: * None + * + * Public: Yes + * + * Deprecated *@todo commy */ #include "script_component.hpp" -PARAMS_2(_name,_value); +params ["_name", "_value"]; // Hack to keep backward compatibility for the moment -if ((typeName (missionNamespace getVariable _name)) == "BOOL") then { - if ((typeName _value) == "SCALAR") then { +if (typeName (missionNamespace getVariable _name) == "BOOL") then { + if (typeName _value == "SCALAR") then { _value = _value > 0; }; }; diff --git a/addons/common/functions/fnc_setPitchBankYaw.sqf b/addons/common/functions/fnc_setPitchBankYaw.sqf index f5d13eb6fe..ea7f27a906 100644 --- a/addons/common/functions/fnc_setPitchBankYaw.sqf +++ b/addons/common/functions/fnc_setPitchBankYaw.sqf @@ -1,26 +1,25 @@ /* - * Taken From: - * https://community.bistudio.com/wiki/BIS_fnc_setPitchBank - * Edited By: - * KoffeinFlummi + * Author: Bohemia Interactive edit by KoffeinFlummi + * Sets the value of an ACE_Parameter and makes it public. * * Arguments: - * 0: Unit/Vehicle - * 1: Pitch (degrees) - * 2: Yaw (degrees) - * 3: Bank (degrees) + * 0: Unit/Vehicle + * 1: Pitch + * 2: Yaw + * 3: Bank * * Return Value: * None + * + * Public: Yes */ #include "script_component.hpp" -private ["_object", "_aroundX", "_aroundY", "_aroundZ", "_dirX", "_dirY", "_dirZ", "_upX", "_upY", "_upZ", "_dir", "_up", "_dirXTemp", "_upXTemp"]; +params ["_object", "_aroundX", "_aroundY", "_aroundZ"]; -_object = _this select 0; -_aroundX = _this select 1; -_aroundY = _this select 2; -_aroundZ = (360 - (_this select 3)) - 360; +_aroundZ = - _aroundZ; + +private ["_dirX", "_dirY", "_dirZ", "_upX", "_upY", "_upZ", "_dir", "_up"]; _dirX = 0; _dirY = 1; @@ -28,28 +27,34 @@ _dirZ = 0; _upX = 0; _upY = 0; _upZ = 1; + if (_aroundX != 0) then { - _dirY = cos _aroundX; - _dirZ = sin _aroundX; - _upY = -sin _aroundX; - _upZ = cos _aroundX; -}; -if (_aroundY != 0) then { - _dirX = _dirZ * sin _aroundY; - _dirZ = _dirZ * cos _aroundY; - _upX = _upZ * sin _aroundY; - _upZ = _upZ * cos _aroundY; -}; -if (_aroundZ != 0) then { - _dirXTemp = _dirX; - _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ); - _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ); - _upXTemp = _upX; - _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ); - _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ); + _dirY = cos _aroundX; + _dirZ = sin _aroundX; + _upY = -sin _aroundX; + _upZ = cos _aroundX; }; -_dir = [_dirX,_dirY,_dirZ]; -_up = [_upX,_upY,_upZ]; +if (_aroundY != 0) then { + _dirX = _dirZ * sin _aroundY; + _dirZ = _dirZ * cos _aroundY; + _upX = _upZ * sin _aroundY; + _upZ = _upZ * cos _aroundY; +}; + +if (_aroundZ != 0) then { + private ["_dirXTemp", "_upXTemp"]; + + _dirXTemp = _dirX; + _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ); + _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ); + + _upXTemp = _upX; + _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ); + _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ); +}; + +_dir = [_dirX, _dirY, _dirZ]; +_up = [_upX, _upY, _upZ]; _object setVectorDirAndUp [_dir,_up];