diff --git a/addons/common/functions/fnc__handleNetEvent.sqf b/addons/common/functions/fnc__handleNetEvent.sqf index 90cf95ac77..e409afe6a3 100644 --- a/addons/common/functions/fnc__handleNetEvent.sqf +++ b/addons/common/functions/fnc__handleNetEvent.sqf @@ -80,6 +80,7 @@ if (_eventType == "ACEc") then { ["ACEg", ACEg] call FUNC(_handleNetEvent); }; }; - } forEach _eventTargets; + false + } count _eventTargets; }; }; diff --git a/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf b/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf index fbaeb60e4f..4e755562b5 100644 --- a/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf +++ b/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf @@ -21,6 +21,7 @@ params ["_client"]; _eventLog = _eventEntry select 1; ["SEH_s", _client, [_x, _eventLog]] call FUNC(targetEvent); -} forEach (GVAR(syncedEvents) select 0); + false +} count (GVAR(syncedEvents) select 0); true diff --git a/addons/common/functions/fnc__handleRequestSyncedEvent.sqf b/addons/common/functions/fnc__handleRequestSyncedEvent.sqf index 96cd7a51f5..d4d9b2cf76 100644 --- a/addons/common/functions/fnc__handleRequestSyncedEvent.sqf +++ b/addons/common/functions/fnc__handleRequestSyncedEvent.sqf @@ -41,7 +41,8 @@ if (isServer) then { { _x params ["", "_eventArgs","_ttl"]; [_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent); - } forEach _eventLog; + false + } count _eventLog; ACE_LOGINFO_1("[%1] synchronized",_eventName); }; diff --git a/addons/common/functions/fnc_addCanInteractWithCondition.sqf b/addons/common/functions/fnc_addCanInteractWithCondition.sqf index 11213accd6..740fa9bb9f 100644 --- a/addons/common/functions/fnc_addCanInteractWithCondition.sqf +++ b/addons/common/functions/fnc_addCanInteractWithCondition.sqf @@ -17,11 +17,11 @@ params ["_conditionName", "_conditionFunc"]; _conditionName = toLower _conditionName; -private "_conditions"; +private ["_conditions", "_index"]; + _conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]]; _conditions params ["_conditionNames", "_conditionFuncs"]; -private "_index"; _index = _conditionNames find _conditionName; if (_index == -1) then { diff --git a/addons/common/functions/fnc_ambientBrightness.sqf b/addons/common/functions/fnc_ambientBrightness.sqf index 86aef99b0c..4ec2840e47 100644 --- a/addons/common/functions/fnc_ambientBrightness.sqf +++ b/addons/common/functions/fnc_ambientBrightness.sqf @@ -1,6 +1,5 @@ /* * Author: commy2, idea by Falke - * * Returns a brightness value depending on the sun and moon state. Ranges from 0 to 1 (dark ... bright). * * Arguments: diff --git a/addons/common/functions/fnc_applyForceWalkStatus.sqf b/addons/common/functions/fnc_applyForceWalkStatus.sqf index 82fbd9da3a..d3b58a25a4 100644 --- a/addons/common/functions/fnc_applyForceWalkStatus.sqf +++ b/addons/common/functions/fnc_applyForceWalkStatus.sqf @@ -9,10 +9,10 @@ * None * * Example: - * [ACE_Player] call FUNC(applyForceWalkStatus) + * [ACE_Player] call ace_common_fnc_applyForceWalkStatus * * Public: No -*/ + */ #include "script_component.hpp" params ["_unit"]; diff --git a/addons/common/functions/fnc_assignObjectsInList.sqf b/addons/common/functions/fnc_assignObjectsInList.sqf index 0d10066d01..6bbb31d2dc 100644 --- a/addons/common/functions/fnc_assignObjectsInList.sqf +++ b/addons/common/functions/fnc_assignObjectsInList.sqf @@ -14,37 +14,40 @@ * * Public: No */ - #include "script_component.hpp" -private ["_splittedList", "_nilCheckPassedList"]; params ["_list", "_variable", "_setting", "_global"]; if (typeName _list == "STRING") then { + private ["_splittedList", "_nilCheckPassedList"]; + _splittedList = [_list, ","] call BIS_fnc_splitString; _nilCheckPassedList = ""; + { _x = [_x] call FUNC(stringRemoveWhiteSpace); - if !(isnil _x) then { + if !(isNil _x) then { if (_nilCheckPassedList == "") then { _nilCheckPassedList = _x; } else { _nilCheckPassedList = _nilCheckPassedList + ","+ _x; }; }; - }foreach _splittedList; + false + } count _splittedList; _list = [] call compile format["[%1]",_nilCheckPassedList]; }; { - if (!isnil "_x") then { + if (!isNil "_x") then { if (typeName _x == typeName objNull) then { if (local _x) then { _x setvariable [_variable, _setting, _global]; }; }; }; -}foreach _list; + false +} count _list; true diff --git a/addons/common/functions/fnc_blurScreen.sqf b/addons/common/functions/fnc_blurScreen.sqf index 8136d1476c..a3394a1fbf 100644 --- a/addons/common/functions/fnc_blurScreen.sqf +++ b/addons/common/functions/fnc_blurScreen.sqf @@ -10,7 +10,6 @@ * * Public: Yes */ - #include "script_component.hpp" if (!hasInterface) exitWith {}; diff --git a/addons/common/functions/fnc_canGetInPosition.sqf b/addons/common/functions/fnc_canGetInPosition.sqf index 40724569d0..45a2642655 100644 --- a/addons/common/functions/fnc_canGetInPosition.sqf +++ b/addons/common/functions/fnc_canGetInPosition.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Is the unit able to enter the vehicle in the given position? * * Arguments: diff --git a/addons/common/functions/fnc_claim.sqf b/addons/common/functions/fnc_claim.sqf index 9a5b373fa5..ac89a80172 100644 --- a/addons/common/functions/fnc_claim.sqf +++ b/addons/common/functions/fnc_claim.sqf @@ -10,6 +10,7 @@ * Return Value: * None * + * Public: No */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_currentChannel.sqf b/addons/common/functions/fnc_currentChannel.sqf index 52aed1f4ce..82dd66b485 100644 --- a/addons/common/functions/fnc_currentChannel.sqf +++ b/addons/common/functions/fnc_currentChannel.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 - * * Returns the current radio / chat / marker channel. * * Arguments: diff --git a/addons/common/functions/fnc_debugModule.sqf b/addons/common/functions/fnc_debugModule.sqf index d313244e52..4f3da4d7cb 100644 --- a/addons/common/functions/fnc_debugModule.sqf +++ b/addons/common/functions/fnc_debugModule.sqf @@ -1,5 +1,6 @@ /* * Author: Glowbal + * ? * * Arguments: * None @@ -9,7 +10,6 @@ * * Public: No */ - #include "script_component.hpp" params ["_entity"]; diff --git a/addons/common/functions/fnc_disableUserInput.sqf b/addons/common/functions/fnc_disableUserInput.sqf index d9485b11e7..ffa6d8e28f 100644 --- a/addons/common/functions/fnc_disableUserInput.sqf +++ b/addons/common/functions/fnc_disableUserInput.sqf @@ -5,23 +5,20 @@ * Arguments: * 0: True to disable key inputs, false to re-enable them * - * Return value: - * Nothing + * Return Value: + * None * - * Public: Yes + * Public: No */ - #include "script_component.hpp" -private ["_dlg"]; - -PARAMS_1(_state); +params ["_state"]; if (_state) then { disableSerialization; if (!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])) exitWith {}; - if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) exitWith {}; + if (!isNil QGVAR(disableInputPFH)) exitWith {}; // end TFAR and ACRE2 radio transmissions call FUNC(endRadioTransmission); @@ -34,19 +31,22 @@ if (_state) then { closeDialog 0; createDialog QGVAR(DisableMouse_Dialog); + private "_dlg"; _dlg = uiNamespace getVariable QGVAR(dlgDisableMouse); _dlg displayAddEventHandler ["KeyDown", { - private ["_key", "_dlg", "_ctrl", "_config", "_acc", "_index"]; - _key = _this select 1; + params ["", "_key"]; if (_key == 1 && {alive player}) then { createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer); disableSerialization; + + private ["_dlg", "_ctrl"]; + _dlg = finddisplay 49; _dlg displayAddEventHandler ["KeyDown", { - _key = _this select 1; + params ["", "_key"]; !(_key == 1) }]; @@ -62,19 +62,21 @@ if (_state) then { _ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer); _ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1; [false] call DFUNC(disableUserInput);)]; - _ctrl ctrlEnable (call {_config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}}); + _ctrl ctrlEnable (call {private "_config"; _config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}}); _ctrl ctrlSetText "RESPAWN"; _ctrl ctrlSetTooltip "Respawn."; }; if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then { (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; + + private "_acc"; _acc = accTime; teamSwitch; setAccTime _acc; }; - if (_key in actionKeys "CuratorInterface" && {getAssignedCuratorLogic player in allCurators}) then { + if (_key in actionKeys "CuratorInterface" && {getAssignedCuratorLogic player in allCurators}) then { (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; openCuratorInterface; }; diff --git a/addons/common/functions/fnc_displayTextPicture.sqf b/addons/common/functions/fnc_displayTextPicture.sqf index 93d4d38df7..3bdf908d16 100644 --- a/addons/common/functions/fnc_displayTextPicture.sqf +++ b/addons/common/functions/fnc_displayTextPicture.sqf @@ -1,25 +1,21 @@ /* * Author: commy2, Glowbal - * * Display a structured text with image. * - * Argument: + * Arguments: * 0: Text * 1: Image - * 2: Image color - * 3: Target Unit. Will only display if target is the player controlled object + * 2: Image color (default: [0, 0, 0, 0]) + * 3: Target Unit. Will only display if target is the player controlled object (default: ACE_player) * - * Return value: - * Nothing + * Return Value: + * None + * + * Public: Yes */ - #include "script_component.hpp" -private ["_imageColor", "_target"]; -PARAMS_2(_text,_image); -_imageColor = if (count _this > 2) then {_this select 2} else {[1,1,1]}; -_imageColor resize 3; -_target = if (count _this > 3) then {_this select 3} else {ACE_player}; +params ["_text", "_image", ["_imageColor", [1,1,1]], ["_target", ACE_player]]; if (_target != ACE_player) exitWith {}; @@ -28,16 +24,21 @@ if (typeName _text != "TEXT") then { if (count _text > 0) then { { if (typeName _x == "STRING" && {isLocalized _x}) then { - _text set [_foreachIndex, localize _x]; + _text set [_forEachIndex, localize _x]; }; - }foreach _text; + } forEach _text; + _text = format _text; }; }; + if (typeName _text == "STRING" && {isLocalized _text}) then { _text = localize _text; }; + _text = parseText format ["%1", _text]; }; + _text = composeText [parseText format ["", _image, _imageColor call BIS_fnc_colorRGBtoHTML], lineBreak, _text]; + [_text, 2] call FUNC(displayTextStructured); diff --git a/addons/common/functions/fnc_displayTextStructured.sqf b/addons/common/functions/fnc_displayTextStructured.sqf index cfe2feb3cb..255a014b6f 100644 --- a/addons/common/functions/fnc_displayTextStructured.sqf +++ b/addons/common/functions/fnc_displayTextStructured.sqf @@ -1,23 +1,20 @@ /* * Author: commy2, Glowbal - * * Display a structured text. * - * Argument: + * Arguments: * 0: Text - * 1: Size of the textbox - * 2: Target Unit. Will only display if target is the player controlled object + * 1: Size of the textbox (default: 1.5) + * 2: Target Unit. Will only display if target is the player controlled object (default: ACE_player) * - * Return value: - * Nothing + * Return Value: + * None + * + * Public: Yes */ - #include "script_component.hpp" -private ["_text", "_size", "_isShown", "_ctrlHint", "_yPos", "_xPos", "_wPos", "_hPos", "_position", "_target"]; -_text = _this select 0; -_size = if (count _this > 1) then {_this select 1} else {1.5;}; -_target = if (count _this > 2) then {_this select 2} else {ACE_player}; +params ["_text", ["_size", 1.5], ["_target", ACE_player]]; if (_target != ACE_player) exitWith {}; @@ -38,6 +35,8 @@ if (typeName _text != "TEXT") then { _text = composeText [lineBreak, parseText format ["%1", _text]]; }; +private ["_isShown", "_ctrlHint", "_xPos", "_yPos", "_wPos", "_hPos", "_position"]; + _isShown = ctrlShown (uiNamespace getVariable ["ACE_ctrlHint", controlNull]); ("ACE_RscHint" call BIS_fnc_rscLayer) cutRsc ["ACE_RscHint", "PLAIN", 0, true]; @@ -60,8 +59,8 @@ _yPos = safeZoneY + 0.175 * safezoneH; _wPos = (10 *(((safezoneW / safezoneH) min 1.2) / 40)); _hPos = (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)); -//Zeus Interface Open and Display would be under the "CREATE" list -if (!isnull curatorCamera) then { +// Zeus Interface Open and Display would be under the "CREATE" list +if (!isNull curatorCamera) then { _xPos = _xPos min ((safezoneX + safezoneW - 12.5 * (((safezoneW / safezoneH) min 1.2) / 40)) - _wPos); }; diff --git a/addons/common/functions/fnc_doAnimation.sqf b/addons/common/functions/fnc_doAnimation.sqf index 5b7a1ed1bf..42d59f0b72 100644 --- a/addons/common/functions/fnc_doAnimation.sqf +++ b/addons/common/functions/fnc_doAnimation.sqf @@ -3,35 +3,22 @@ * * Execute an animation. This is used to not break things like the unconsciousness animation. * - * Argument: - * 0: Unit (Object) - * 1: Animation (String) - * 2: Priority of the animation. (Number, optional default: 0) - * 0: PlayMove - * 1: PlayMoveNow - * 2: SwitchMove (no transitional animation, doesn't overwrite priority 1) + * Arguments: + * 0: Unit + * 1: Animation + * 2: Priority of the animation. (default: 0) + * 0 = PlayMove + * 1 = PlayMoveNow + * 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1) * - * Return value: - * Nothing + * Return Value: + * None + * + * Public: Yes */ #include "script_component.hpp" -private ["_force"]; - -PARAMS_3(_unit,_animation,_priority); -_force = False; - -// no animation given -if (isNil "_animation") exitWith { - ACE_LOGERROR_1("No animation specified in %1.",_fnc_scriptNameParent); -}; - -if (isNil "_priority") then { - _priority = 0; -}; -if (count _this > 3) then { - _force = _this select 3; -}; +params ["_unit", "_animation", ["_priority", 0], ["_force", false]]; // don't overwrite more important animations if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {}; @@ -47,7 +34,7 @@ if (_animation == "") then { //if (_animation == animationState _unit) exitWith {}; switch (_priority) do { - case 0 : { + case 0: { if (_unit == vehicle _unit) then { [_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc); } else { @@ -55,7 +42,7 @@ switch (_priority) do { [_unit, format ["{_this playMove '%1'}", _animation]] call FUNC(execRemoteFnc); }; }; - case 1 : { + case 1: { if (_unit == vehicle _unit) then { [_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc); } else { @@ -63,7 +50,7 @@ switch (_priority) do { [_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc); }; }; - case 2 : { + case 2: { // try playMoveNow first if (_unit == vehicle _unit) then { [_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc); @@ -80,5 +67,3 @@ switch (_priority) do { }; default {}; }; - -["Anim", [_priority, _animation]] call FUNC(log); diff --git a/addons/common/functions/fnc_dropBackpack.sqf b/addons/common/functions/fnc_dropBackpack.sqf index 05ee3ab750..fc2b0bba64 100644 --- a/addons/common/functions/fnc_dropBackpack.sqf +++ b/addons/common/functions/fnc_dropBackpack.sqf @@ -1,30 +1,24 @@ /* * Author: commy2 - * * Drops a backback. Also returns the ground wepaon holder object of the dropped backpack. * - * Argument: - * 0: Unit that has a backpack (Object) + * Arguments: + * 0: Unit that has a backpack * * Return value: - * Ground wepaon holder with backpack (Object) + * Ground wepaon holder with backpack * + * Public: Yes */ #include "script_component.hpp" -PARAMS_1(_unit); +params ["_unit"]; -private ["_backpackObject","_holder"]; +private ["_backpackObject", "_holder"]; _backpackObject = backpackContainer _unit; + _unit addBackpack "Bag_Base"; removeBackpack _unit; -_holder = objNull; -{ - if (_backpackObject in everyBackpack _x) exitWith { - _holder = _x; - }; -} forEach (position _unit nearObjects ["WeaponHolder", 5]); - -_holder +objectParent _backpackObject // return diff --git a/addons/common/functions/fnc_dumpArray.sqf b/addons/common/functions/fnc_dumpArray.sqf index 8572aaf134..182c542df2 100644 --- a/addons/common/functions/fnc_dumpArray.sqf +++ b/addons/common/functions/fnc_dumpArray.sqf @@ -1,10 +1,21 @@ -//fnc_dumpArray.sqf +/* + * Author: ? + * ? + * + * Arguments: + * 0: Array to be dumped + * 1: Depth + * + * Return Value: + * None + * + * Public: No + */ #include "script_component.hpp" -private ["_pad", "_i", "_x"]; - -PARAMS_2(_var,_depth); +params ["_var", "_depth"]; +private "_pad"; _pad = ""; for "_i" from 0 to _depth do { @@ -14,15 +25,18 @@ for "_i" from 0 to _depth do { _depth = _depth + 1; if (IS_ARRAY(_var)) then { - if ((count _var) > 0) then { - diag_log text format["%1[", _pad]; + if (_var isEqualTo []) then { + diag_log text format ["%1[],", _pad]; + } else { + diag_log text format ["%1[", _pad]; + { [_x, _depth] call FUNC(dumpArray); - } forEach _var; - diag_log text format["%1],", _pad]; - } else { - diag_log text format["%1[],", _pad]; + false + } count _var; + + diag_log text format ["%1],", _pad]; }; } else { - diag_log text format["%1%2", _pad, [_var] call FUNC(formatVar)]; + diag_log text format ["%1%2", _pad, [_var] call FUNC(formatVar)]; }; diff --git a/addons/common/functions/fnc_dumpPerformanceCounters.sqf b/addons/common/functions/fnc_dumpPerformanceCounters.sqf index 0c3d6c8e78..e076831c6f 100644 --- a/addons/common/functions/fnc_dumpPerformanceCounters.sqf +++ b/addons/common/functions/fnc_dumpPerformanceCounters.sqf @@ -1,49 +1,68 @@ -//fnc_dumpPerformanceCounters.sqf -#define DEBUG_MODE_FULL +/* + * Author: ? + * Dumps performance counter statistics into Logs. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ #include "script_component.hpp" +diag_log text format ["REGISTERED ACE PFH HANDLERS"]; +diag_log text format ["-------------------------------------------"]; -diag_log text format["REGISTERED ACE PFH HANDLERS"]; -diag_log text format["-------------------------------------------"]; if (!isNil "ACE_PFH_COUNTER") then { { - private ["_isActive"]; _x params ["_pfh", "_parameters"]; - _isActive = if (!isNil {cba_common_PFHhandles select (_pfh select 0)}) then {"ACTIVE"} else {"REMOVED"}; - diag_log text format["Registered PFH: id=%1 [%2, delay %3], %4:%5", (_pfh select 0), (_isActive), (_parameters select 1), (_pfh select 1), (_pfh select 2) ]; - } forEach ACE_PFH_COUNTER; + + private "_isActive"; + _isActive = ["ACTIVE", "REMOVED"] select isNil {CBA_common_PFHhandles select (_pfh select 0)}; + + diag_log text format ["Registered PFH: id=%1 [%2, delay %3], %4:%5", _pfh select 0, _isActive, _parameters select 1, _pfh select 1, _pfh select 2]; + false + } count ACE_PFH_COUNTER; }; -diag_log text format["ACE COUNTER RESULTS"]; -diag_log text format["-------------------------------------------"]; +diag_log text format ["ACE COUNTER RESULTS"]; +diag_log text format ["-------------------------------------------"]; + { - private ["_counterEntry", "_iter", "_total", "_count", "_delta", "_averageResult"]; + private ["_counterEntry", "_iter", "_total", "_count", "_averageResult", "_delta"]; + _counterEntry = _x; _iter = 0; _total = 0; _count = 0; _averageResult = 0; - if( (count _counterEntry) > 3) then { + + if (count _counterEntry > 3) then { // calc { - if(_iter > 2) then { + if (_iter > 2) then { _count = _count + 1; _delta = (_x select 1) - (_x select 0); _total = _total + _delta; }; + _iter = _iter + 1; - } forEach _counterEntry; - + false + } count _counterEntry; + // results _averageResult = (_total / _count) * 1000; - + // dump results - diag_log text format["%1: Average: %2s / %3 = %4ms", (_counterEntry select 0), _total, _count, _averageResult]; + diag_log text format ["%1: Average: %2s / %3 = %4ms", _counterEntry select 0, _total, _count, _averageResult]; } else { - diag_log text format["%1: No results", (_counterEntry select 0) ]; + diag_log text format ["%1: No results", _counterEntry select 0]; }; -} forEach ACE_COUNTERS; + false +} count ACE_COUNTERS; /* // Dump PFH Trackers @@ -71,4 +90,4 @@ diag_log text format["-------------------------------------------"]; // //} forEach ACRE_EXCESSIVE_FRAME_TRACKER; -*/ \ No newline at end of file +*/ diff --git a/addons/common/functions/fnc_getAllDefinedSetVariables.sqf b/addons/common/functions/fnc_getAllDefinedSetVariables.sqf index 2163accae2..18c8a18c72 100644 --- a/addons/common/functions/fnc_getAllDefinedSetVariables.sqf +++ b/addons/common/functions/fnc_getAllDefinedSetVariables.sqf @@ -1,30 +1,40 @@ -/** - * fn_getAllSetVariables.sqf - * @Descr: Returns an 2d array of all variables that have been set on the object - * @Author: Glowbal +/* + * Author: Glowbal + * Returns an 2d array of all variables that have been set on the object * - * @Arguments: [unit OBJECT, category STRING (Optional. Only get the variables from the specified category. Default is "" == all)] - * @Return: ARRAY REturns an array with the format [ [name STRING, typeName STRING, value ANY, publicFlag BOOL, peristentFlag BOOL] ] - * @PublicAPI: true + * Arguments: + * 0: Unit + * 1: Limiting Category (default: "") + * + * Return Value: + * Variable Data + * 0: Name + * 1: typeName + * 2: value + * 3: publicFlag + * 4: peristentFlag + * + * Public: Yes */ - #include "script_component.hpp" -private ["_return", "_val", "_category"]; -PARAMS_1(_object); -_category = if (count _this > 1) then { _this select 1 } else { "" }; +params ["_object", ["_category", ""]]; -if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith { - []; -}; +if (isNil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith {[]}; + +private ["_return", "_val"]; _return = []; + { _val = _object getvariable (_x select 0); - if (!isnil "_val") then { + + if (!isNil "_val") then { if (_category == "" || _category == _x select 3) then { - _return pushback [_x select 0, typeName _val, _val, _x select 2, _x select 5]; + _return pushBack [_x select 0, typeName _val, _val, _x select 2, _x select 5]; }; }; -}foreach GVAR(OBJECT_VARIABLES_STORAGE); -_return \ No newline at end of file + false +} count GVAR(OBJECT_VARIABLES_STORAGE); + +_return diff --git a/addons/common/functions/fnc_getAllGear.sqf b/addons/common/functions/fnc_getAllGear.sqf index aa2289309e..97b28fddd6 100644 --- a/addons/common/functions/fnc_getAllGear.sqf +++ b/addons/common/functions/fnc_getAllGear.sqf @@ -1,28 +1,38 @@ /* * Author: bux578, commy2 - * * Returns an array containing all items of a given unit * - * Argument: - * 0: Unit (Object) + * Arguments: + * 0: Unit * - * Return value: - * Array with all the gear, format: - * 0: headgear (String) - * 1: goggles (String) - * 2,3: uniform (String, Array) - * 4,5: vest (String, Array) - * 6,7: backpack (String, Array) - * 8-10: rifle (String, Array, Array) - * 11-13: launcher (String, Array, Array) - * 14-16: pistol (String, Array, Array) - * 17: map, compass, watch, etc. (Array) - * 18: binocluar (String) + * Return Value: + * 0: Headgear + * 1: Goggles + * 2: Uniform + * 3: Uniform Items + * 4: Vest + * 5: Vest Items + * 6: Backback + * 7: Backpack Items + * 8: Rifle + * 9: Rifle Items + * 10: Rifle Magazines + * 11: Launcher + * 12: Launcher Items + * 13: Launcher Magazines + * 14: Handgun + * 15: Handgun Items + * 16: Handgun Magazines + * 17: Assigned Items (map, compass, watch, etc.) + * 18: Binoculars * + * Public: Yes + * + * Note: Element 17 includes the Head Mounted Display (HMD) */ #include "script_component.hpp" -PARAMS_1(_unit); +params ["_unit"]; if (isNull _unit) exitWith {[ "", diff --git a/addons/common/functions/fnc_getCaptivityStatus.sqf b/addons/common/functions/fnc_getCaptivityStatus.sqf index 50aeeced3a..36bf0ff183 100644 --- a/addons/common/functions/fnc_getCaptivityStatus.sqf +++ b/addons/common/functions/fnc_getCaptivityStatus.sqf @@ -1,25 +1,27 @@ /* * Author: commy2 - * * Return the captivity status of an unit. * - * Argument: - * 0: Unit (Object) + * Arguments: + * 0: Unit * - * Return value: - * Reasons, why the unit is a captive. An empty array is returned if the unit is not a captive (Array of Strings) + * Return Value: + * Captivity Reasons, empty if not captive + * + * Public: Yes */ #include "script_component.hpp" -private ["_captivityReasons", "_unitCaptivityStatus", "_unitCaptivityReasons"]; +params ["_unit"]; -PARAMS_1(_unit); +private ["_captivityReasons", "_unitCaptivityStatus", "_unitCaptivityReasons"]; _captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []]; _unitCaptivityStatus = [captiveNum _unit, count _captivityReasons] call FUNC(binarizeNumber); _unitCaptivityReasons = []; + { if (_unitCaptivityStatus select _forEachIndex) then { _unitCaptivityReasons pushBack _x; diff --git a/addons/common/functions/fnc_getChildren.sqf b/addons/common/functions/fnc_getChildren.sqf index d28ba7cb70..d5212dd9a5 100644 --- a/addons/common/functions/fnc_getChildren.sqf +++ b/addons/common/functions/fnc_getChildren.sqf @@ -1,10 +1,20 @@ -// by commy2 +/* + * Author: commy2 + * Obtain children of a config entry + * + * Arguments: + * 0: Unit + * + * Return Value: + * Parent Entry Class Children + * + * Public: Yes + */ #include "script_component.hpp" -private ["_classes"]; - -PARAMS_2(_name,_cfgClass); +params ["_name", "_cfgClass"]; +private "_classes"; _classes = format ["configName inheritsFrom _x == '%1'", _name] configClasses (configFile >> _cfgClass); -_classes = [_classes, {configName _this}] call FUNC(map); -_classes + +[_classes, {configName _this}] call FUNC(map) // return diff --git a/addons/common/functions/fnc_getConfigCommander.sqf b/addons/common/functions/fnc_getConfigCommander.sqf index 44f02cbeb1..bfa5fbc379 100644 --- a/addons/common/functions/fnc_getConfigCommander.sqf +++ b/addons/common/functions/fnc_getConfigCommander.sqf @@ -1,21 +1,22 @@ /* * Author: commy2 - * * Get the commander config of a vehicles turret. * - * Argument: - * 0: vehicle (Object) + * Arguments: + * 0: vehicle * - * Return value: - * Commander config (Config) + * Return Value: + * Commander config + * + * Public: Yes */ #include "script_component.hpp" -private ["_config", "_turret"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_config", "_turret"]; _config = configFile >> "CfgVehicles" >> typeOf _vehicle; _turret = [_vehicle] call FUNC(getTurretCommander); -[_config, _turret] call FUNC(getTurretConfigPath) +[_config, _turret] call FUNC(getTurretConfigPath) // return diff --git a/addons/common/functions/fnc_getConfigGunner.sqf b/addons/common/functions/fnc_getConfigGunner.sqf index a28491bfff..bc3131d798 100644 --- a/addons/common/functions/fnc_getConfigGunner.sqf +++ b/addons/common/functions/fnc_getConfigGunner.sqf @@ -1,21 +1,22 @@ /* * Author: commy2 - * * Get the gunner config of a vehicles turret. * - * Argument: - * 0: vehicle (Object) + * Arguments: + * 0: vehicle * - * Return value: - * Gunner config (Config) + * Return Value: + * Gunner config + * + * Public: Yes */ #include "script_component.hpp" -private ["_config", "_turret"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_config", "_turret"]; _config = configFile >> "CfgVehicles" >> typeOf _vehicle; _turret = [_vehicle] call FUNC(getTurretGunner); -[_config, _turret] call FUNC(getTurretConfigPath) +[_config, _turret] call FUNC(getTurretConfigPath) // return diff --git a/addons/common/functions/fnc_getConfigType.sqf b/addons/common/functions/fnc_getConfigType.sqf index b2d601c121..1496cfa2b9 100644 --- a/addons/common/functions/fnc_getConfigType.sqf +++ b/addons/common/functions/fnc_getConfigType.sqf @@ -1,17 +1,18 @@ /* * Author: commy2 + * Determins type of item. Can be CfgMagaines, CfgWeapons or CfgGlasses. * - * What kind of Cfg is the item. Works for CfgMagaines, CfgWeapons and CfgGlasses + * Arguments: + * 0: Item Classname * - * Argument: - * 0: A item's classname. (String) + * Return Value: + * Config category ("CfgWeapons", "CfgMagazines", "CfgGlasses", "") * - * Return value: - * CfgWhatever (String) + * Public: Yes */ #include "script_component.hpp" -PARAMS_1(_item); +params ["_item"]; if (isClass (configFile >> "CfgWeapons" >> _item)) exitWith {"CfgWeapons"}; diff --git a/addons/common/functions/fnc_getConfigTypeObject.sqf b/addons/common/functions/fnc_getConfigTypeObject.sqf index ef39ce22c7..6186ad6bff 100644 --- a/addons/common/functions/fnc_getConfigTypeObject.sqf +++ b/addons/common/functions/fnc_getConfigTypeObject.sqf @@ -1,17 +1,18 @@ /* * Author: commy2 + * Determins type of object. Can be CfgVehicles or CfgAmmo. * - * What kind of Cfg is the object. Works for CfgVehicles and CfgAmmo + * Arguments: + * 0: Object classname * - * Argument: - * 0: An object's classname. (String) + * Return Value: + * Config category ("CfgWeapons", "Cfgmagazines", "CfgGlasses", "") * - * Return value: - * CfgWhatever (String) + * Public: Yes */ #include "script_component.hpp" -PARAMS_1(_object); +params ["_object"]; if (isClass (configFile >> "CfgVehicles" >> _object)) exitWith {"CfgVehicles"}; diff --git a/addons/common/functions/fnc_getDeathAnim.sqf b/addons/common/functions/fnc_getDeathAnim.sqf index 539c8d2616..c88f89d35f 100644 --- a/addons/common/functions/fnc_getDeathAnim.sqf +++ b/addons/common/functions/fnc_getDeathAnim.sqf @@ -9,35 +9,38 @@ * animation * * Example: - * [bob] call ace_common_fnc_getDeathAnim; + * [bob] call ace_common_fnc_getDeathAnim * * Public: No */ #include "script_component.hpp" -PARAMS_1(_unit); +params ["_unit"]; -private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation", "_index"]; +private ["_returnAnimation", "_animationState", "_unitAnimationCfg", "_unitActionsCfg", "_interpolateArray", "_indexAnimation"]; _returnAnimation = ""; -_animationState = (animationState _unit); -_unitAnimationCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState); -//If we're already in a terminal animation just return current -if ((getNumber (_unitAnimationCfg >> "terminal")) == 1) exitWith {_animationState}; +_animationState = animationState _unit; +_unitAnimationCfg = configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState; -_unitActionsCfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimationCfg >> "actions"))); +//If we're already in a terminal animation just return current +if (getNumber (_unitAnimationCfg >> "terminal") == 1) exitWith {_animationState}; + +_unitActionsCfg = configFile >> "CfgMovesBasic" >> "Actions" >> getText (_unitAnimationCfg >> "actions"); TRACE_2("Animation/Action", configName _unitAnimationCfg, configName _unitActionsCfg); -if ((vehicle _unit) != _unit) then { +if (vehicle _unit != _unit) then { _interpolateArray = getArray (_unitAnimationCfg >> "interpolateTo"); + for "_index" from 0 to (count _interpolateArray - 1) step 2 do { _indexAnimation = _interpolateArray select _index; + //No guarentee that first animation will be right so scan for the first "terminal" animation //E.G.: interpolateTo[] = {"passenger_apc_generic04still",1,"KIA_passenger_apc_generic04",1}; - if ((getNumber ((configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation) >> "terminal")) == 1) exitWith { + if (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _indexAnimation >> "terminal") == 1) exitWith { _returnAnimation = _indexAnimation; }; }; diff --git a/addons/common/functions/fnc_getDefaultAnim.sqf b/addons/common/functions/fnc_getDefaultAnim.sqf index fbcca2712e..372a2424eb 100644 --- a/addons/common/functions/fnc_getDefaultAnim.sqf +++ b/addons/common/functions/fnc_getDefaultAnim.sqf @@ -1,29 +1,47 @@ -// by commy2 +/* + * Author: commy2 + * Get the Defualt animation for the unit + * + * Arguments: + * 0: unit + * + * Return Value: + * animation + * + * Example: + * [bob] call ace_common_fnc_getDefaultAnim; + * + * Public: No + */ #include "script_component.hpp" +params ["_unit"]; + private ["_anim", "_stance"]; -PARAMS_1(_unit); -_anim = toLower (animationState _unit); +_anim = toLower animationState _unit; // stance is broken for some animations. _stance = stance _unit; + if (_anim find "ppne" == 4) then { - _stance = "PRONE"; + _stance = "PRONE"; }; + if (_anim find "pknl" == 4) then { - _stance = "CROUCH"; + _stance = "CROUCH"; }; + if (_anim find "perc" == 4) then { - _stance = "STAND"; + _stance = "STAND"; }; _anim = format ["AmovP%1M%2S%3W%4D%5", - ["erc", "knl", "pne"] select (["STAND", "CROUCH", "PRONE"] find _stance) max 0, - ["stp", "run"] select (vectorMagnitude velocity _unit > 1), - [["ras", "low"] select weaponLowered _unit, "non"] select (currentWeapon _unit == ""), - ["non", "rfl", "lnr", "pst", "bin"] select (["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] find currentWeapon _unit) max 0, - ["non", _anim select [count _anim - 1, 1]] select (_anim select [count _anim - 2, 2] in ["df", "db", "dl", "dr"]) + ["erc", "knl", "pne"] select (["STAND", "CROUCH", "PRONE"] find _stance) max 0, + ["stp", "run"] select (vectorMagnitude velocity _unit > 1), + [["ras", "low"] select weaponLowered _unit, "non"] select (currentWeapon _unit == ""), + ["non", "rfl", "lnr", "pst", "bin"] select (["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] find currentWeapon _unit) max 0, + ["non", _anim select [count _anim - 1, 1]] select (_anim select [count _anim - 2, 2] in ["df", "db", "dl", "dr"]) ]; ["", _anim] select isClass (configFile >> "CfgMovesMaleSdr" >> "States" >> _anim) diff --git a/addons/common/functions/fnc_getDefinedVariable.sqf b/addons/common/functions/fnc_getDefinedVariable.sqf index 6c10c4f682..c0d7ce8d83 100644 --- a/addons/common/functions/fnc_getDefinedVariable.sqf +++ b/addons/common/functions/fnc_getDefinedVariable.sqf @@ -1,33 +1,38 @@ -/** - * fn_getVariable.sqf - * @Descr: Grabs a variable. If variable has not been set, attempts to use default defined value - * @Author: Glowbal +/* + * Author: Glowbal + * Grabs a variable. If variable has not been set, attempts to use default defined value * - * @Arguments: [unit OBJECT, variableName STRING] - * @Return: ANY - * @PublicAPI: true + * Arguments: + * 0: unit + * 1: Variable Name + * + * Return Value: + * Value of variable or default value, if the variable is undefined + * + * Public: No */ - #include "script_component.hpp" -#define UNIT (_this select 0) -#define VARIABLE (_this select 1) +params ["_unit", "_variable", "_defaultValue"]; private "_value"; +_value = _unit getvariable _variable; -_value = UNIT getvariable VARIABLE; -if (isnil "_value") then { - if (count _this >2) then { - _value = _this select 2; +if (isNil "_value") then { + if (!isNil "_defaultValue") then { + _value = _defaultValue; } else { private "_definedVariable"; - _definedVariable = ([VARIABLE] call FUNC(getDefinedVariableInfo)); + _definedVariable = [_variable] call FUNC(getDefinedVariableInfo); + if (count _definedVariable > 1) then { _value = _definedVariable select 1; }; }; - if (isnil "_value") then { + + if (isNil "_value") then { _value = 0; }; }; -_value \ No newline at end of file + +_value diff --git a/addons/common/functions/fnc_getDefinedVariableDefault.sqf b/addons/common/functions/fnc_getDefinedVariableDefault.sqf index cd4e4f08f2..4bb4b12253 100644 --- a/addons/common/functions/fnc_getDefinedVariableDefault.sqf +++ b/addons/common/functions/fnc_getDefinedVariableDefault.sqf @@ -1,19 +1,24 @@ -/** - * fn_getvariableDefault.sqf - * @Descr: Get the variable default value - * @Author: Glowbal +/* + * Author: Glowbal + * Get the variable default value * - * @Arguments: [variableName STRING] - * @Return: ANY - * @PublicAPI: true + * Arguments: + * 0: Variable Name + * + * Return Value: + * Default value of variable + * + * Public: Yes */ - #include "script_component.hpp" +params ["_varName"]; + private "_variableDefinition"; -_variableDefinition = ([_this select 0] call FUNC(getDefinedVariableInfo)); -if (count _variableDefinition > 0) exitwith { +_variableDefinition = [_varName] call FUNC(getDefinedVariableInfo); + +if !(_variableDefinition isEqualTo []) exitwith { _variableDefinition select 1; }; -nil; \ No newline at end of file +nil diff --git a/addons/common/functions/fnc_getDefinedVariableInfo.sqf b/addons/common/functions/fnc_getDefinedVariableInfo.sqf index 03b50b0649..adcb70c6ee 100644 --- a/addons/common/functions/fnc_getDefinedVariableInfo.sqf +++ b/addons/common/functions/fnc_getDefinedVariableInfo.sqf @@ -1,12 +1,17 @@ -/** - * fn_getvariableInfo.sqf - * @Descr: N/A - * @Author: Glowbal +/* + * Author: Glowbal + * Get the variable Informations * - * @Arguments: [] - * @Return: - * @PublicAPI: false + * Arguments: + * 0: Variable Name + * + * Return Value: + * Variable Metadata + * + * Public: No */ - #include "script_component.hpp" -+(missionNamespace getvariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + (_this select 0),[]]) + +params ["_varName"]; + ++ (missionNamespace getVariable [format [QGVAR(OBJECT_VARIABLES_STORAGE_%1), _varName], []]) diff --git a/addons/common/functions/fnc_getDisplayConfigName.sqf b/addons/common/functions/fnc_getDisplayConfigName.sqf index 92b6700238..7a0d9ffa95 100644 --- a/addons/common/functions/fnc_getDisplayConfigName.sqf +++ b/addons/common/functions/fnc_getDisplayConfigName.sqf @@ -1,15 +1,31 @@ -// by commy2 +/* + * Author: commy2 + * Get display classnames from config with given idd. + * + * Arguments: + * 0: Display ID (idd) + * + * Return Value: + * Display Classnames + * + * Public: Yes + * + * Note: Really slow due to iteration through whole config. Meant for debugging. + */ #include "script_component.hpp" -private ["_configName", "_index", "_config"]; +params ["_idd"]; -_configName = ""; +private ["_configNames", "_config"]; + +_configNames = []; for "_index" from 0 to (count configFile - 1) do { _config = configFile select _index; - if (isClass _config && {isNumber (_config >> "idd")} && {getNumber (_config >> "idd") == _this}) exitWith { - _configName = configName _config; + + if (isClass _config && {isNumber (_config >> "idd")} && {getNumber (_config >> "idd") == _idd}) then { + _configNames pushBack configName _config; }; }; -_configName +_configNames diff --git a/addons/common/functions/fnc_getDoorTurrets.sqf b/addons/common/functions/fnc_getDoorTurrets.sqf index f304c1714c..cab259a214 100644 --- a/addons/common/functions/fnc_getDoorTurrets.sqf +++ b/addons/common/functions/fnc_getDoorTurrets.sqf @@ -1,19 +1,20 @@ /* * Author: bux578 + * Returns all turret indecies of door gunners. * - * Gets the turret index of door gunners + * Arguments: + * 0: Vehicle * - * Argument: - * 0: Vehicle (Object) + * Return Value: + * All turret indecies of the Vehicle * - * Return value: - * Turret indexes of the door gunner. Empty array means no gunner position. (Array) + * Public: Yes */ #include "script_component.hpp" -private ["_turrets", "_doorTurrets", "_config"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_turrets", "_doorTurrets", "_config"]; _turrets = allTurrets [_vehicle, true]; @@ -21,11 +22,13 @@ _doorTurrets = []; { _config = configFile >> "CfgVehicles" >> typeOf _vehicle; + _config = [_config, _x] call FUNC(getTurretConfigPath); - if ((getNumber (_config >> "isCopilot") == 0) && count (getArray (_config >> "weapons")) > 0 ) then { + if (getNumber (_config >> "isCopilot" == 0) && {count getArray (_config >> "weapons") > 0}) then { _doorTurrets pushBack _x; }; -} forEach _turrets; + false +} count _turrets; _doorTurrets diff --git a/addons/common/functions/fnc_getForceWalkStatus.sqf b/addons/common/functions/fnc_getForceWalkStatus.sqf index dbab640d86..acdc2f1a05 100644 --- a/addons/common/functions/fnc_getForceWalkStatus.sqf +++ b/addons/common/functions/fnc_getForceWalkStatus.sqf @@ -1,25 +1,23 @@ /* -Name: FUNC(getForceWalkStatus) - -Author: Pabst Mirror (from captivity by commy2) - -Description: - Returns reasons why the unit is forceWalk-ing, empty if not forced. - -Parameters: - 0: OBJECT - Unit - -Returns: - ARRAY(of strings) - Reason why the unit is force walking - -Example: - [ACE_Player] call FUNC(getForceWalkStatus) -*/ + * Author: PabstMirror, commy2 + * Returns reasons why the unit is forceWalk-ing. + * + * Arguments: + * 0: unit + * + * Return Value: + * Force Walk reasons + * + * Example: + * [ACE_Player] call ace_common_fnc_getForceWalkStatus + * + * Public: Yes + */ #include "script_component.hpp" -private ["_forceWalkReasons", "_unitForceWalkNumber", "_unitForceWalkStatus", "_unitForceWalkReasons"]; +params ["_unit"]; -PARAMS_1(_unit); +private ["_forceWalkReasons", "_unitForceWalkNumber", "_unitForceWalkStatus", "_unitForceWalkReasons"]; _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; @@ -28,6 +26,7 @@ _unitForceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0]; _unitForceWalkStatus = [_unitForceWalkNumber, count _forceWalkReasons] call FUNC(binarizeNumber); _unitForceWalkReasons = []; + { if (_unitForceWalkStatus select _forEachIndex) then { _unitForceWalkReasons pushBack _x; diff --git a/addons/common/functions/fnc_getGunner.sqf b/addons/common/functions/fnc_getGunner.sqf index ce73019f70..dac42ce535 100644 --- a/addons/common/functions/fnc_getGunner.sqf +++ b/addons/common/functions/fnc_getGunner.sqf @@ -1,20 +1,19 @@ /* * Author: commy2 + * Returns gunner using specified weapon type in vehicle. Only works if all turrets have different weapons. * - * Get the gunner of a vehicle who uses the given weapon type. Requires every turret to have a different weapon. + * Arguments: + * 0: Vehicle + * 1: Weapon * - * Argument: - * 0: The vehicle (Object) - * 1: weapon of the vehicle (String) + * Return Value: + * Gunner * - * Return value: - * The turret gunner with this weapon (Object) + * Public: Yes */ +#include "script_component.hpp" -private ["_vehicle", "_weapon"]; - -_vehicle = _this select 0; -_weapon = _this select 1; +params ["_vehicle", "_weapon"]; // on foot if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle || {toLower _weapon in ["throw", "put"]}}) exitWith {gunner _vehicle}; @@ -27,11 +26,12 @@ _gunner = objNull; if (_weapon in (_vehicle weaponsTurret _x)) exitWith { _gunner = _vehicle turretUnit _x; }; -} forEach allTurrets [_vehicle, true]; + false +} count allTurrets [_vehicle, true]; // ensure that at least the pilot is returned if there is no gunner if (isManualFire _vehicle && {isNull _gunner}) then { - _gunner = driver _vehicle; + _gunner = driver _vehicle; }; -_gunner \ No newline at end of file +_gunner diff --git a/addons/common/functions/fnc_getInPosition.sqf b/addons/common/functions/fnc_getInPosition.sqf index d80c387b5d..dc3ad38cde 100644 --- a/addons/common/functions/fnc_getInPosition.sqf +++ b/addons/common/functions/fnc_getInPosition.sqf @@ -1,31 +1,26 @@ /* * Author: commy2 + * Move unit into given vehicle position or switch to that position if the unit is already inside the vehicle. + * + * Arguments: + * 0: Unit + * 1: Vehicle + * 2: Position ("Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver", "Cargo") + * 3: Index (only applies to "Turret", "FFV", "Codriver", "Cargo") (default: next free index) + * + * Return Value: + * None * - * Move unit into given vehicle position. Or switch to that position if the unit is already inside the vehicle. - * - * Arguments: - * 0: Unit to enter the vehicle (Object) - * 1: The vehicle to be entered (Object) - * 2: Position. Can be "Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver" or "Cargo" (String) - * 3: Index. "Turret", "FFV", "Codriver" and "Cargo" support this optional parameter. Which position should be taken. - * Note: This index is diffrent from Armas "cargoIndex". (Number, optional default: next free index) - * - * Return Value: - * Nothing + * Public: Yes */ #include "script_component.hpp" #define CANGETINDRIVER (isNull (driver _vehicle) || {!alive driver _vehicle}) && {!lockedDriver _vehicle} && {getNumber (_config >> "isUav") != 1} #define CANGETINTURRETINDEX (isNull (_vehicle turretUnit _turret) || {!alive (_vehicle turretUnit _turret)}) && {!(_vehicle lockedTurret _turret)} && {getNumber (_config >> "isUav") != 1} -private ["_position", "_index"]; +params ["_unit", "_vehicle", "_position", ["_index", -1]]; -PARAMS_2(_unit,_vehicle); - -_position = toLower (_this select 2); -_index = _this select 3; // optional, please don't use - -if (isNil "_index") then {_index = -1}; +_position = toLower _position; // general if (!alive _vehicle || {locked _vehicle > 1}) exitWith {false}; @@ -39,27 +34,29 @@ _isInside = vehicle _unit == _vehicle; _script = {}; _enemiesInVehicle = false; //Possible Side Restriction + { if (side _unit getFriend side _x < 0.6) exitWith {_enemiesInVehicle = true}; -} forEach crew _vehicle; + false +} count crew _vehicle; switch (_position) do { case "driver" : { if (CANGETINDRIVER) then { - _script = [ - {_unit action [["GetInDriver", "MoveToDriver"] select _isInside, _vehicle];}, - {if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;} - ] select _enemiesInVehicle; + _script = [ + {_unit action [["GetInDriver", "MoveToDriver"] select _isInside, _vehicle];}, + {if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;} + ] select _enemiesInVehicle; }; }; case "pilot" : { if (CANGETINDRIVER) then { - _script = [ - {_unit action [["GetInPilot", "MoveToPilot"] select _isInside, _vehicle];}, - {if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;} - ] select _enemiesInVehicle; - _position = "driver"; + _script = [ + {_unit action [["GetInPilot", "MoveToPilot"] select _isInside, _vehicle];}, + {if (_isInside) then {moveOut _unit}; _unit moveInDriver _vehicle; call _fnc_getInEH;} + ] select _enemiesInVehicle; + _position = "driver"; }; }; @@ -67,10 +64,10 @@ switch (_position) do { _turret = [_vehicle] call FUNC(getTurretGunner); if (CANGETINTURRETINDEX) then { - _script = [ - {_unit action [["GetInGunner", "MoveToGunner"] select _isInside, _vehicle];}, - {if (_isInside) then {moveOut _unit}; _unit moveInGunner _vehicle; call _fnc_getInEH;} - ] select _enemiesInVehicle; + _script = [ + {_unit action [["GetInGunner", "MoveToGunner"] select _isInside, _vehicle];}, + {if (_isInside) then {moveOut _unit}; _unit moveInGunner _vehicle; call _fnc_getInEH;} + ] select _enemiesInVehicle; }; }; @@ -78,10 +75,10 @@ switch (_position) do { _turret = [_vehicle] call FUNC(getTurretCommander); if (CANGETINTURRETINDEX) then { - _script = [ - {_unit action [["GetInCommander", "MoveToCommander"] select _isInside, _vehicle];}, - {if (_isInside) then {moveOut _unit}; _unit moveInCommander _vehicle; call _fnc_getInEH;} - ] select _enemiesInVehicle; + _script = [ + {_unit action [["GetInCommander", "MoveToCommander"] select _isInside, _vehicle];}, + {if (_isInside) then {moveOut _unit}; _unit moveInCommander _vehicle; call _fnc_getInEH;} + ] select _enemiesInVehicle; }; }; @@ -89,12 +86,12 @@ switch (_position) do { _turret = [_vehicle] call FUNC(getTurretCopilot); if (CANGETINTURRETINDEX) then { - _script = [ - {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, - {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} - ] select _enemiesInVehicle; + _script = [ + {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, + {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} + ] select _enemiesInVehicle; - _position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner" + _position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner" }; }; @@ -104,8 +101,8 @@ switch (_position) do { if (_index != -1 && {_turret = _turrets select _index; CANGETINTURRETINDEX}) then { _script = [ - {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, - {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} + {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, + {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} ] select _enemiesInVehicle; _position = "gunner"; @@ -114,13 +111,13 @@ switch (_position) do { _turret = _turrets select _index; if (CANGETINTURRETINDEX) exitWith { _script = [ - {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, - {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} + {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, + {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} ] select _enemiesInVehicle; _position = "gunner"; }; - }; + }; }; }; @@ -130,22 +127,22 @@ switch (_position) do { if (_index != -1 && {_turret = _turrets select _index; CANGETINTURRETINDEX}) then { _script = [ - {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, - {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} + {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, + {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} ] select _enemiesInVehicle; _position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner" } else { for "_index" from 0 to (count _turrets - 1) do { - _turret = _turrets select _index; - if (CANGETINTURRETINDEX) exitWith { - _script = [ - {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, - {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} - ] select _enemiesInVehicle; + _turret = _turrets select _index; + if (CANGETINTURRETINDEX) exitWith { + _script = [ + {_unit action [["GetInTurret", "moveToTurret"] select _isInside, _vehicle, _turret];}, + {if (_isInside) then {moveOut _unit}; _unit moveInTurret [_vehicle, _turret]; call _fnc_getInEH;} + ] select _enemiesInVehicle; - _position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner" - }; + _position = "gunner"; // I think. It's a turret after all and turrets supposedly return "gunner" + }; }; }; }; @@ -160,8 +157,8 @@ switch (_position) do { if (_index != -1 && {_index in _positions}) then { _script = [ - {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, - {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} + {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, + {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} ] select _enemiesInVehicle; _position = "cargo"; @@ -169,8 +166,8 @@ switch (_position) do { _index = _positions select 0; if (!isNil "_index") then { _script = [ - {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, - {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} + {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, + {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} ] select _enemiesInVehicle; _position = "cargo"; @@ -188,8 +185,8 @@ switch (_position) do { if (_index != -1 && {_index in _positions}) then { _script = [ - {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, - {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} + {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, + {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} ] select _enemiesInVehicle; _position = "cargo"; @@ -197,8 +194,8 @@ switch (_position) do { _index = _positions select 0; if (!isNil "_index") then { _script = [ - {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, - {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} + {_unit action [["GetInCargo", "MoveToCargo"] select _isInside, _vehicle, _index];}, + {if (_isInside) then {moveOut _unit}; _unit moveInCargo [_vehicle, _index]; call _fnc_getInEH;} ] select _enemiesInVehicle; _position = "cargo"; diff --git a/addons/common/functions/fnc_getItemType.sqf b/addons/common/functions/fnc_getItemType.sqf index 4de2bfa862..4d6ee932fa 100644 --- a/addons/common/functions/fnc_getItemType.sqf +++ b/addons/common/functions/fnc_getItemType.sqf @@ -1,83 +1,78 @@ /* * Author: commy2 + * Returns item type of given classname. * - * What kind of item is given classname + * Arguments: + * 0: Item * - * Argument: - * 0: Classname of a item. (String) - * - * Return value: - * Item type. (Array) - * 0: "weapon", "item", "magazine" or "" (String) - * 1: A description of the item (e.g. "primary" for a weapon or "vest" for a vest item) + * Return Value: + * 0: Type ("weapon", "item", "magazine", "") + * 1: Item Description * + * Public: Yes */ #include "script_component.hpp" -PARAMS_1(_item); +params ["_item"]; -private ["_cfgType"]; +private ["_cfgType", "_config", "_type", "_default"]; _cfgType = [_item] call FUNC(getConfigType); -if (_cfgType == "") exitWith {["",""]}; +if (_cfgType == "") exitWith {["", ""]}; -if (_cfgType == "CfgGlasses") exitWith {["item","glasses"]}; - -private ["_config", "_type"]; +if (_cfgType == "CfgGlasses") exitWith {["item", "glasses"]}; _config = configFile >> _cfgType >> _item; - _type = getNumber (_config >> "type"); if (isNumber (_config >> "ItemInfo" >> "type")) then { _type = getNumber (_config >> "ItemInfo" >> "type"); }; -private "_default"; _default = ["item", "magazine"] select (_cfgType == "CfgMagazines"); switch (true) do { - case (_type == 0): {[_default,"unknown"]}; - case (_type == 2^0): {["weapon","primary"]}; - case (_type == 2^1): {["weapon","handgun"]}; - case (_type == 2^2): {["weapon","secondary"]}; - case (_type < 2^4): {["weapon","unknown"]}; - case (_type == 2^4): {["magazine","handgun"]}; // handgun - case (_type == 2^8): {["magazine","primary"]}; // rifle - case (_type == 2^9): {["magazine","secondary"]}; // rpg, mg, mines - //case (_type < 2^11): {["magazine","unknown"]}; + case (_type == 0): {[_default, "unknown"]}; + case (_type == 2^0): {["weapon", "primary"]}; + case (_type == 2^1): {["weapon", "handgun"]}; + case (_type == 2^2): {["weapon", "secondary"]}; + case (_type < 2^4): {["weapon", "unknown"]}; + case (_type == 2^4): {["magazine", "handgun"]}; // handgun + case (_type == 2^8): {["magazine", "primary"]}; // rifle + case (_type == 2^9): {["magazine", "secondary"]}; // rpg, mg, mines + //case (_type < 2^11): {["magazine", "unknown"]}; - case (_type == 101): {["item","muzzle"]}; - case (_type == 201): {["item","optics"]}; - case (_type == 301): {["item","flashlight"]}; - case (_type == 302): {["item","under"]}; // czech for bipod item - case (_type == 401): {["item","first_aid_kit"]}; - case (_type == 501): {["item","fins"]}; // not implemented - case (_type == 601): {["item","breathing_bomb"]}; // not implemented - case (_type == 603): {["item","goggles"]}; - case (_type == 604): {["item","scuba"]}; // not implemented - case (_type == 605): {["item","headgear"]}; - case (_type == 611): {["item","radio"]}; - case (_type == 616): {["item","hmd"]}; - case (_type == 617): {["item","binocular"]}; - case (_type == 619): {["item","medikit"]}; - case (_type == 620): {["item","toolkit"]}; - case (_type == 621): {["item","uav_terminal"]}; - case (_type == 701): {["item","vest"]}; - case (_type == 801): {["item","uniform"]}; + case (_type == 101): {["item", "muzzle"]}; + case (_type == 201): {["item", "optics"]}; + case (_type == 301): {["item", "flashlight"]}; + case (_type == 302): {["item", "under"]}; // czech for bipod item + case (_type == 401): {["item", "first_aid_kit"]}; + case (_type == 501): {["item", "fins"]}; // not implemented + case (_type == 601): {["item", "breathing_bomb"]}; // not implemented + case (_type == 603): {["item", "goggles"]}; + case (_type == 604): {["item", "scuba"]}; // not implemented + case (_type == 605): {["item", "headgear"]}; + case (_type == 611): {["item", "radio"]}; + case (_type == 616): {["item", "hmd"]}; + case (_type == 617): {["item", "binocular"]}; + case (_type == 619): {["item", "medikit"]}; + case (_type == 620): {["item", "toolkit"]}; + case (_type == 621): {["item", "uav_terminal"]}; + case (_type == 701): {["item", "vest"]}; + case (_type == 801): {["item", "uniform"]}; case (_type == 2^12): { switch (toLower getText (_config >> "simulation")) do { - case ("weapon"): {["weapon","binocular"]}; - case ("binocular"): {["weapon","binocular"]}; - case ("nvgoggles"): {["item","nvgoggles"]}; - case ("itemminedetector"): {["item","minedetector"]}; - default {[_default,"unknown"]}; + case ("weapon"): {["weapon", "binocular"]}; + case ("binocular"): {["weapon", "binocular"]}; + case ("nvgoggles"): {["item", "nvgoggles"]}; + case ("itemminedetector"): {["item", "minedetector"]}; + default {[_default, "unknown"]}; }; }; - case (_type == 2^16): {["weapon","vehicle"]}; - case (_type == 2^17): {[_default,"unknown"]}; // ??? - default {[_default,"unknown"]}; + case (_type == 2^16): {["weapon", "vehicle"]}; + case (_type == 2^17): {[_default, "unknown"]}; // ??? + default {[_default, "unknown"]}; }; diff --git a/addons/common/functions/fnc_getLightProperties.sqf b/addons/common/functions/fnc_getLightProperties.sqf index 456084c3f9..bbaf955a8b 100644 --- a/addons/common/functions/fnc_getLightProperties.sqf +++ b/addons/common/functions/fnc_getLightProperties.sqf @@ -3,22 +3,26 @@ * Read properties of given vehicles light. * * Arguments: - * 0: Object with lights (Object) - * 1: Light classname (String) + * 0: Object with lights + * 1: Light classname * * Return Value: - * Stuff from config (Array) + * 0: Light intensity + * 1: Light position + * 2: Light direction + * 3: Light inner angle + * 4: Light outer angle * + * Public: Yes */ #include "script_component.hpp" -PARAMS_2(_vehicle,_light); +params ["_vehicle", "_light"]; + +private ["_config", "_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"]; -private "_config"; _config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "Reflectors" >> _light; -private ["_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"]; - _intensity = getNumber (_config >> "intensity"); _position = getText (_config >> "position"); _direction = getText (_config >> "direction"); @@ -26,35 +30,3 @@ _innerAngle = getNumber (_config >> "innerAngle"); _outerAngle = getNumber (_config >> "outerAngle"); [_intensity, _position, _direction, _innerAngle, _outerAngle] - -/* -class Reflectors -{ - class Light_1 - { - color[] = {1000,1000,1100}; - ambient[] = {10,10,11}; - intensity = 5; - size = 1; - innerAngle = 90; - outerAngle = 130; - coneFadeCoef = 2; - position = "Light_1_pos"; - direction = "Light_1_dir"; - hitpoint = "Light_1_hitpoint"; - selection = "Light_1_hide"; - useFlare = 1; - flareSize = 0.9; - flareMaxDistance = 85; - class Attenuation - { - start = 0; - constant = 0; - linear = 0; - quadratic = 0.9; - hardLimitStart = 40; - hardLimitEnd = 60; - }; - }; -}; -*/ diff --git a/addons/common/functions/fnc_getLightPropertiesWeapon.sqf b/addons/common/functions/fnc_getLightPropertiesWeapon.sqf index 03c6753a76..01567fee58 100644 --- a/addons/common/functions/fnc_getLightPropertiesWeapon.sqf +++ b/addons/common/functions/fnc_getLightPropertiesWeapon.sqf @@ -1,23 +1,29 @@ /* * Author: commy2 - * Read properties of given flashlight. @todo, Can weapons themselves still have flashlights (no attachment)? + * Read properties of given flashlight. * * Arguments: - * 0: A flashlight (String) + * 0: Flashlight * * Return Value: - * Stuff from config (Array) + * 0: Light intensity + * 1: Light position + * 2: Light direction + * 3: Light inner angle + * 4: Light outer angle * + * Public: Yes */ #include "script_component.hpp" -PARAMS_1(_weapon); +params ["_weapon"]; + +// @todo: Can weapons themselves still have flashlights (no attachment)? + +private ["_config", "_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"]; -private "_config"; _config = configFile >> "CfgWeapons" >> _weapon >> "ItemInfo" >> "FlashLight"; -private ["_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"]; - _intensity = getNumber (_config >> "intensity"); _position = getText (_config >> "position"); _direction = getText (_config >> "direction"); @@ -25,32 +31,3 @@ _innerAngle = getNumber (_config >> "innerAngle"); _outerAngle = getNumber (_config >> "outerAngle"); [_intensity, _position, _direction, _innerAngle, _outerAngle] - -/* -class FlashLight -{ - color[] = {180,156,120}; - ambient[] = {0.9,0.78,0.6}; - intensity = 20; - size = 1; - innerAngle = 20; - outerAngle = 80; - coneFadeCoef = 5; - position = "flash dir"; - direction = "flash"; - useFlare = 1; - flareSize = 1.4; - flareMaxDistance = "100.0f"; - dayLight = 0; - class Attenuation - { - start = 0.5; - constant = 0; - linear = 0; - quadratic = 1.1; - hardLimitStart = 20; - hardLimitEnd = 30; - }; - scale[] = {0}; -}; -*/ diff --git a/addons/common/functions/fnc_getName.sqf b/addons/common/functions/fnc_getName.sqf index 1da59534f0..a7facd2c6d 100644 --- a/addons/common/functions/fnc_getName.sqf +++ b/addons/common/functions/fnc_getName.sqf @@ -1,25 +1,21 @@ /* * Author: commy2 - * * Returns the name of the object. Used to prevent issues with the name command. * - * Argument: - * 0: Object (Object) - * 1: Show effective commander name? (Bool, optinal default: false) + * Arguments: + * 0: Object + * 1: Use effective commander name when used on vehicles (default: false) * - * Return value: - * The name. + * Return Value: + * Object Name + * + * Public: Yes */ #include "script_component.hpp" -private ["_name"]; - -PARAMS_2(_unit,_showEffective); - -if (isNil "_showEffective") then { - _showEffective = false; -}; +params ["_unit", ["_showEffective", false]]; +private "_name"; _name = ""; if (_unit isKindOf "CAManBase") then { diff --git a/addons/common/functions/fnc_getPitchBankYaw.sqf b/addons/common/functions/fnc_getPitchBankYaw.sqf index 2a9b0bacd1..74eac376fc 100644 --- a/addons/common/functions/fnc_getPitchBankYaw.sqf +++ b/addons/common/functions/fnc_getPitchBankYaw.sqf @@ -1,14 +1,19 @@ /* * Author: KoffeinFlummi - * - * Returns [pitch, bank, yaw] for given vehicle in degrees. + * Returns pitch, bank, yaw for given vehicle in degrees. * * Arguments: - * 0: Unit/Vehicle + * 0: Unit/Vehicle * * Return Value: - * [pitch, bank, yaw] + * 0: pitch + * 1: bank + * 2: yaw + * + * Public: Yes */ #include "script_component.hpp" -((_this select 0) call BIS_fnc_getPitchBank) + [getDir (_this select 0)] +private ["_vehicle"]; + +(_vehicle call BIS_fnc_getPitchBank) + [getDir _vehicle] diff --git a/addons/common/functions/fnc_getTurretCommander.sqf b/addons/common/functions/fnc_getTurretCommander.sqf index 99665d03e3..e045c2d46f 100644 --- a/addons/common/functions/fnc_getTurretCommander.sqf +++ b/addons/common/functions/fnc_getTurretCommander.sqf @@ -1,30 +1,34 @@ /* * Author: commy2 - * * Get the turret index of a vehicles commander. * - * Argument: - * 0: Vehicle (Object) + * Arguments: + * 0: Vehicle * - * Return value: - * Turret index of the vehicles commander. Empty array means no observer position. (Array) + * Return Value: + * Vehicle commander turrent indecies + * + * Public: Yes */ #include "script_component.hpp" -private ["_turrets", "_turret", "_config"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_turrets", "_turret", "_config"]; _turrets = allTurrets [_vehicle, true]; _turret = []; + { - _config = configFile >> "CfgVehicles" >> typeOf _vehicle; + _config = configFile >> "CfgVehicles" >> typeOf _vehicle; - _config = [_config, _x] call FUNC(getTurretConfigPath); + _config = [_config, _x] call FUNC(getTurretConfigPath); + + if (getNumber (_config >> "primaryObserver") == 1) exitWith { + _turret = _x; + }; + false +} count _turrets; - if (getNumber (_config >> "primaryObserver") == 1) exitWith { - _turret = _x; - }; -} forEach _turrets; _turret diff --git a/addons/common/functions/fnc_getTurretConfigPath.sqf b/addons/common/functions/fnc_getTurretConfigPath.sqf index 1fca65eaac..07d7ac4e0c 100644 --- a/addons/common/functions/fnc_getTurretConfigPath.sqf +++ b/addons/common/functions/fnc_getTurretConfigPath.sqf @@ -1,28 +1,29 @@ /* * Author: commy2 - * * Get the config path of a vehicles turret. * - * Argument: - * 0: vehicles config (Config) - * 1: Turret index (Array) + * Arguments: + * 0: Vehicle Config + * 1: Turret indecies * - * Return value: - * Turret config (Config) + * Return Value: + * Turret config + * + * Public: Yes */ #include "script_component.hpp" -private ["_index", "_offset", "_config2", "_foundClasses", "_a"]; +params ["_config", "_turretIndex"]; -PARAMS_2(_config,_turretIndex); +private ["_offset", "_config2", "_foundClasses"]; for "_index" from 0 to (count _turretIndex - 1) do { _config = _config >> "Turrets"; _offset = 0; _config2 = _config select 0; - _foundClasses = 0; + for "_a" from 0 to (count _config - 1) do { if (isClass _config2) then { _foundClasses = _foundClasses + 1; @@ -33,6 +34,8 @@ for "_index" from 0 to (count _turretIndex - 1) do { if (_foundClasses == _turretIndex select _index) exitWith {}; }; + _config = _config2; }; + _config diff --git a/addons/common/functions/fnc_getTurretCopilot.sqf b/addons/common/functions/fnc_getTurretCopilot.sqf index d496051558..94a30b7697 100644 --- a/addons/common/functions/fnc_getTurretCopilot.sqf +++ b/addons/common/functions/fnc_getTurretCopilot.sqf @@ -1,23 +1,25 @@ /* * Author: commy2 - * * Get the turret index of a vehicles copilot. * - * Argument: - * 0: Vehicle (Object) + * Arguments: + * 0: Vehicle * - * Return value: - * Turret index of the vehicles gunner. Empty array means no copilot position. (Array) + * Return Value: + * Vehicle Copilot Turret indecies + * + * Public: Yes */ #include "script_component.hpp" -private ["_turrets", "_turret", "_config"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_turrets", "_turret", "_config"]; _turrets = allTurrets [_vehicle, true]; _turret = []; + { _config = configFile >> "CfgVehicles" >> typeOf _vehicle; @@ -26,6 +28,7 @@ _turret = []; if (getNumber (_config >> "isCopilot") == 1 && {getNumber (_config >> "primaryGunner") != 1} && {getNumber (_config >> "primaryObserver") != 1}) exitWith { _turret = _x; }; -} forEach _turrets; + false +} count _turrets; _turret diff --git a/addons/common/functions/fnc_getTurretDirection.sqf b/addons/common/functions/fnc_getTurretDirection.sqf index 31b68ccabc..ced29a9a85 100644 --- a/addons/common/functions/fnc_getTurretDirection.sqf +++ b/addons/common/functions/fnc_getTurretDirection.sqf @@ -1,37 +1,47 @@ /* * Author: jaynus - * * Get the absolute turret direction for FOV/PIP turret. * - * Argument: - * 0: Vehicle (Object) - * 1: Turret Position + * Arguments: + * 0: Vehicle + * 1: Turret Position * - * Return value: - * [position, direction] + * Return Value: + * 0: Position ASL + * 1: Direction + * + * Public: Yes */ #include "script_component.hpp" -PARAMS_2(_vehicle,_position); -private ["_turret", "_povPos", "_povDir", "_gunBeginPos", "_gunEndPos", "_pov", "_gunBeg", "_gunEnd", "_pipDir"]; +params ["_vehicle", "_position"]; + +private ["_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir"]; _turret = [_vehicle, _position] call CBA_fnc_getTurret; + _pov = getText (_turret >> "memoryPointGunnerOptics"); _gunBeg = getText (_turret >> "gunBeg"); -_gunEnd = getText (_turret >> "gunEnd"); +_gunEnd = getText (_turret >> "gunEnd"); + TRACE_3("", _pov, _gunBeg, _gunEnd); // Pull the PIP pov or barrel direction, depending on how the model is set up -_povPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _pov ) ); +_povPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _pov)); //@todo AGLToASL ? _povDir = [0,0,0]; if (_pov == "pip0_pos") then { - _pipDir = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir" ) ); + private "_pipDir"; + _pipDir = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir")); + _povDir = _pipDir vectorDiff _povPos; } else { - _gunBeginPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg ) ); - _gunEndPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd ) ); + private ["_gunBeginPos", "_gunEndPos"]; + + _gunBeginPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg)); + _gunEndPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd)); + _povDir = _gunBeginPos vectorDiff _gunEndPos; }; -[_povPos, _povDir] \ No newline at end of file +[_povPos, _povDir] diff --git a/addons/common/functions/fnc_getTurretGunner.sqf b/addons/common/functions/fnc_getTurretGunner.sqf index a4bcca54dd..9a71d292bd 100644 --- a/addons/common/functions/fnc_getTurretGunner.sqf +++ b/addons/common/functions/fnc_getTurretGunner.sqf @@ -1,23 +1,25 @@ /* * Author: commy2 - * * Get the turret index of a vehicles gunner. * - * Argument: - * 0: Vehicle (Object) + * Arguments: + * 0: Vehicle * - * Return value: - * Turret index of the vehicles gunner. Empty array means no gunner position. (Array) + * Return Value: + * Vehicle Gunner Turret indecies + * + * Public: Yes */ #include "script_component.hpp" -private ["_turrets", "_turret", "_config"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_turrets", "_turret", "_config"]; _turrets = allTurrets [_vehicle, true]; _turret = []; + { _config = configFile >> "CfgVehicles" >> typeOf _vehicle; @@ -26,6 +28,7 @@ _turret = []; if (getNumber (_config >> "primaryGunner") == 1) exitWith { _turret = _x; }; -} forEach _turrets; + false +} count _turrets; _turret diff --git a/addons/common/functions/fnc_getTurretIndex.sqf b/addons/common/functions/fnc_getTurretIndex.sqf index bfb96b4665..b2f28c5f90 100644 --- a/addons/common/functions/fnc_getTurretIndex.sqf +++ b/addons/common/functions/fnc_getTurretIndex.sqf @@ -1,19 +1,21 @@ /* * Author: commy2 - * * Get the turret index of a units current turret. * - * Argument: - * 0: Unit, not the vehicle (as in not a car but the player) (Object) + * Arguments: + * 0: Unit * - * Return value: - * Turret index array or config path. E.g: [0] for gunner or [0,0] for commander. Returns empty array if unit is not in a turret. (Array) + * Return Value: + * Turret Index + * + * Public: Yes */ #include "script_component.hpp" +params ["_unit"]; + private ["_vehicle", "_turrets", "_units", "_index"]; -PARAMS_1(_unit); _vehicle = vehicle _unit; if (_unit == _vehicle) exitWith {[]}; @@ -21,9 +23,11 @@ if (_unit == _vehicle) exitWith {[]}; _turrets = allTurrets [_vehicle, true]; _units = []; + { - _units pushBack (_vehicle turretUnit _x); -} forEach _turrets; + _units pushBack (_vehicle turretUnit _x); + false +} count _turrets; _index = _units find _unit; diff --git a/addons/common/functions/fnc_getTurrets.sqf b/addons/common/functions/fnc_getTurrets.sqf index ea656941e4..9a1a48e2bd 100644 --- a/addons/common/functions/fnc_getTurrets.sqf +++ b/addons/common/functions/fnc_getTurrets.sqf @@ -1,37 +1,45 @@ /* * Author: commy2 + * Get all turret indicies of a vehicle type. * - * Get all turret indicies of a vehicle. + * Arguments: + * 0: Vehicle type * - * Argument: - * 0: Vehicle type (String) + * Return Value: + * Turret Indecies * - * Return value: - * All turret index arrays of the vehicle. E.g: [[0], [0,0]] (Array) + * Public: Yes + * + * Note: It's advised to use allTurrets [_vehicle, true] instead whenever possible */ #include "script_component.hpp" -private ["_config", "_turrets", "_fnc_addTurret", "_varName"]; +params ["_type"]; -PARAMS_1(_type); +private ["_varName", "_turrets"]; -_varName = format ["ACE_CachedTurrets_%1", _type]; +_varName = format [QGVAR(CachedTurrets_%1), _type]; _turrets = + (uiNamespace getVariable _varName); if (!isNil "_turrets") exitWith {_turrets}; +private ["_config", "_fnc_addTurret"]; + _config = configFile >> "CfgVehicles" >> _type; _turrets = []; -_fnc_addTurret = { - private ["_count", "_offset", "_index", "_path2", "_config2"]; - PARAMS_2(_config,_path); +_fnc_addTurret = { + params ["_config", "_path"]; _config = _config >> "Turrets"; + + private ["_count", "_offset", "_path2", "_config2"]; + _count = count _config; _offset = 0; + for "_index" from 0 to (_count - 1) do { _path2 = _path + [_index - _offset]; _config2 = _config select _index; diff --git a/addons/common/functions/fnc_getTurretsFFV.sqf b/addons/common/functions/fnc_getTurretsFFV.sqf index 2eaa8807b0..ff7726d1be 100644 --- a/addons/common/functions/fnc_getTurretsFFV.sqf +++ b/addons/common/functions/fnc_getTurretsFFV.sqf @@ -1,23 +1,25 @@ /* * Author: commy2 - * * Get the turret indices of ffv turrets. * - * Argument: - * 0: Vehicle (Object) + * Arguments: + * 0: Vehicle * - * Return value: - * Turret index of the vehicles gunner. Empty array means no ffv turrets. (Array) + * Return Value: + * Vehicle FFV Turret indecies + * + * Public: Yes */ #include "script_component.hpp" -private ["_turrets", "_turret", "_config"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_turrets", "_turret", "_config"]; _turrets = allTurrets [_vehicle, true]; _turret = []; + { _config = configFile >> "CfgVehicles" >> typeOf _vehicle; @@ -26,5 +28,7 @@ _turret = []; if (getNumber (_config >> "isPersonTurret") == 1) then { _turret pushBack _x; }; -} forEach _turrets; + false +} count _turrets; + _turret diff --git a/addons/common/functions/fnc_getTurretsOther.sqf b/addons/common/functions/fnc_getTurretsOther.sqf index 5f373f7c9c..93ab3f2321 100644 --- a/addons/common/functions/fnc_getTurretsOther.sqf +++ b/addons/common/functions/fnc_getTurretsOther.sqf @@ -1,23 +1,25 @@ /* * Author: commy2 - * * Get the turret indices of other turrets (not gunner, commander, copilot or ffv). * - * Argument: - * 0: Vehicle (Object) + * Arguments: + * 0: Vehicle * - * Return value: - * Turret index of the vehicles gunner. Empty array means no other turrets. (Array) + * Return Value: + * Vehicle Other Turret indecies + * + * Public: Yes */ #include "script_component.hpp" -private ["_turrets", "_turret", "_config"]; +params ["_vehicle"]; -PARAMS_1(_vehicle); +private ["_turrets", "_turret", "_config"]; _turrets = allTurrets [_vehicle, true]; _turret = []; + { _config = configFile >> "CfgVehicles" >> typeOf _vehicle; @@ -30,5 +32,7 @@ _turret = []; ) then { _turret pushBack _x; }; -} forEach _turrets; + false +} count _turrets; + _turret diff --git a/addons/common/functions/fnc_getWindDirection.sqf b/addons/common/functions/fnc_getWindDirection.sqf index d93023bfe4..7341ea9c1d 100644 --- a/addons/common/functions/fnc_getWindDirection.sqf +++ b/addons/common/functions/fnc_getWindDirection.sqf @@ -1,31 +1,33 @@ /* * Author: commy2 - * * Get the compass direction the wind is blowing from. * - * Argument: - * None. + * Arguments: + * None * - * Return value: - * Wind direction. (String) + * Return Value: + * Wind cardinal direction + * + * Public: Yes */ #include "script_component.hpp" -switch (round (windDir / 360 * 16)) do { - case 1 : {localize QUOTE(DOUBLES(STR,GVAR(SSW)))}; - case 2 : {localize QUOTE(DOUBLES(STR,GVAR(SW)))}; - case 3 : {localize QUOTE(DOUBLES(STR,GVAR(WSW)))}; - case 4 : {localize QUOTE(DOUBLES(STR,GVAR(W)))}; - case 5 : {localize QUOTE(DOUBLES(STR,GVAR(WNW)))}; - case 6 : {localize QUOTE(DOUBLES(STR,GVAR(NW)))}; - case 7 : {localize QUOTE(DOUBLES(STR,GVAR(NNW)))}; - case 8 : {localize QUOTE(DOUBLES(STR,GVAR(N)))}; - case 9 : {localize QUOTE(DOUBLES(STR,GVAR(NNE)))}; - case 10 : {localize QUOTE(DOUBLES(STR,GVAR(NE)))}; - case 11 : {localize QUOTE(DOUBLES(STR,GVAR(ENE)))}; - case 12 : {localize QUOTE(DOUBLES(STR,GVAR(E)))}; - case 13 : {localize QUOTE(DOUBLES(STR,GVAR(ESE)))}; - case 14 : {localize QUOTE(DOUBLES(STR,GVAR(SE)))}; - case 15 : {localize QUOTE(DOUBLES(STR,GVAR(SSE)))}; - default {localize QUOTE(DOUBLES(STR,GVAR(S)))}; -}; +localize ([ + LSTRING(S), + LSTRING(SSW), + LSTRING(SW), + LSTRING(WSW), + LSTRING(W), + LSTRING(WNW), + LSTRING(NW), + LSTRING(NNW), + LSTRING(N), + LSTRING(NNE), + LSTRING(NE), + LSTRING(ENE), + LSTRING(E), + LSTRING(ESE), + LSTRING(SE), + LSTRING(SSE), + LSTRING(S) +] select (round (windDir / 360 * 16))) // return diff --git a/addons/common/functions/fnc_getZoom.sqf b/addons/common/functions/fnc_getZoom.sqf index 1f319ac768..f4113198a7 100644 --- a/addons/common/functions/fnc_getZoom.sqf +++ b/addons/common/functions/fnc_getZoom.sqf @@ -1,14 +1,17 @@ /* * Author: commy2 - * * Returns a value depending on current zoom level. * - * Argument: - * None. + * Arguments: + * None * - * Return value: - * Zoom. (Number) + * Return Value: + * Zoom + * + * Public: Yes */ #include "script_component.hpp" -(0.5 - ((worldToScreen positionCameraToWorld [0,1,1]) select 1)) * (getResolution select 5) +if (!hasInterface) exitWith {0}; + +(0.5 - ((worldToScreen positionCameraToWorld [0, 1, 1]) select 1)) * (getResolution select 5) diff --git a/addons/common/functions/fnc_globalEvent.sqf b/addons/common/functions/fnc_globalEvent.sqf index 9928bc3468..126419b553 100644 --- a/addons/common/functions/fnc_globalEvent.sqf +++ b/addons/common/functions/fnc_globalEvent.sqf @@ -1,6 +1,5 @@ /* * Author: Nou - * * Execute a global event on all clients, including self. * * Arguments: