Merge pull request #2545 from acemod/commoncleanup9

common code cleanup part 9
This commit is contained in:
commy2 2015-09-21 09:24:41 +02:00
commit ef099861a3
54 changed files with 733 additions and 637 deletions

View File

@ -80,6 +80,7 @@ if (_eventType == "ACEc") then {
["ACEg", ACEg] call FUNC(_handleNetEvent); ["ACEg", ACEg] call FUNC(_handleNetEvent);
}; };
}; };
} forEach _eventTargets; false
} count _eventTargets;
}; };
}; };

View File

@ -21,6 +21,7 @@ params ["_client"];
_eventLog = _eventEntry select 1; _eventLog = _eventEntry select 1;
["SEH_s", _client, [_x, _eventLog]] call FUNC(targetEvent); ["SEH_s", _client, [_x, _eventLog]] call FUNC(targetEvent);
} forEach (GVAR(syncedEvents) select 0); false
} count (GVAR(syncedEvents) select 0);
true true

View File

@ -41,7 +41,8 @@ if (isServer) then {
{ {
_x params ["", "_eventArgs","_ttl"]; _x params ["", "_eventArgs","_ttl"];
[_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent); [_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent);
} forEach _eventLog; false
} count _eventLog;
ACE_LOGINFO_1("[%1] synchronized",_eventName); ACE_LOGINFO_1("[%1] synchronized",_eventName);
}; };

View File

@ -17,11 +17,11 @@ params ["_conditionName", "_conditionFunc"];
_conditionName = toLower _conditionName; _conditionName = toLower _conditionName;
private "_conditions"; private ["_conditions", "_index"];
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]]; _conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
_conditions params ["_conditionNames", "_conditionFuncs"]; _conditions params ["_conditionNames", "_conditionFuncs"];
private "_index";
_index = _conditionNames find _conditionName; _index = _conditionNames find _conditionName;
if (_index == -1) then { if (_index == -1) then {

View File

@ -1,6 +1,5 @@
/* /*
* Author: commy2, idea by Falke * Author: commy2, idea by Falke
*
* Returns a brightness value depending on the sun and moon state. Ranges from 0 to 1 (dark ... bright). * Returns a brightness value depending on the sun and moon state. Ranges from 0 to 1 (dark ... bright).
* *
* Arguments: * Arguments:

View File

@ -9,10 +9,10 @@
* None * None
* *
* Example: * Example:
* [ACE_Player] call FUNC(applyForceWalkStatus) * [ACE_Player] call ace_common_fnc_applyForceWalkStatus
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit"]; params ["_unit"];

View File

@ -14,37 +14,40 @@
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_splittedList", "_nilCheckPassedList"];
params ["_list", "_variable", "_setting", "_global"]; params ["_list", "_variable", "_setting", "_global"];
if (typeName _list == "STRING") then { if (typeName _list == "STRING") then {
private ["_splittedList", "_nilCheckPassedList"];
_splittedList = [_list, ","] call BIS_fnc_splitString; _splittedList = [_list, ","] call BIS_fnc_splitString;
_nilCheckPassedList = ""; _nilCheckPassedList = "";
{ {
_x = [_x] call FUNC(stringRemoveWhiteSpace); _x = [_x] call FUNC(stringRemoveWhiteSpace);
if !(isnil _x) then { if !(isNil _x) then {
if (_nilCheckPassedList == "") then { if (_nilCheckPassedList == "") then {
_nilCheckPassedList = _x; _nilCheckPassedList = _x;
} else { } else {
_nilCheckPassedList = _nilCheckPassedList + ","+ _x; _nilCheckPassedList = _nilCheckPassedList + ","+ _x;
}; };
}; };
}foreach _splittedList; false
} count _splittedList;
_list = [] call compile format["[%1]",_nilCheckPassedList]; _list = [] call compile format["[%1]",_nilCheckPassedList];
}; };
{ {
if (!isnil "_x") then { if (!isNil "_x") then {
if (typeName _x == typeName objNull) then { if (typeName _x == typeName objNull) then {
if (local _x) then { if (local _x) then {
_x setvariable [_variable, _setting, _global]; _x setvariable [_variable, _setting, _global];
}; };
}; };
}; };
}foreach _list; false
} count _list;
true true

View File

@ -10,7 +10,6 @@
* *
* Public: Yes * Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};

View File

@ -1,6 +1,5 @@
/* /*
* Author: commy2 * Author: commy2
*
* Is the unit able to enter the vehicle in the given position? * Is the unit able to enter the vehicle in the given position?
* *
* Arguments: * Arguments:

View File

@ -10,6 +10,7 @@
* Return Value: * Return Value:
* None * None
* *
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"

View File

@ -1,6 +1,5 @@
/* /*
* Author: commy2 * Author: commy2
*
* Returns the current radio / chat / marker channel. * Returns the current radio / chat / marker channel.
* *
* Arguments: * Arguments:

View File

@ -1,5 +1,6 @@
/* /*
* Author: Glowbal * Author: Glowbal
* ?
* *
* Arguments: * Arguments:
* None * None
@ -9,7 +10,6 @@
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_entity"]; params ["_entity"];

View File

@ -5,23 +5,20 @@
* Arguments: * Arguments:
* 0: True to disable key inputs, false to re-enable them <BOOL> * 0: True to disable key inputs, false to re-enable them <BOOL>
* *
* Return value: * Return Value:
* Nothing * None
* *
* Public: Yes * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_dlg"]; params ["_state"];
PARAMS_1(_state);
if (_state) then { if (_state) then {
disableSerialization; disableSerialization;
if (!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])) exitWith {}; 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 // end TFAR and ACRE2 radio transmissions
call FUNC(endRadioTransmission); call FUNC(endRadioTransmission);
@ -34,19 +31,22 @@ if (_state) then {
closeDialog 0; closeDialog 0;
createDialog QGVAR(DisableMouse_Dialog); createDialog QGVAR(DisableMouse_Dialog);
private "_dlg";
_dlg = uiNamespace getVariable QGVAR(dlgDisableMouse); _dlg = uiNamespace getVariable QGVAR(dlgDisableMouse);
_dlg displayAddEventHandler ["KeyDown", { _dlg displayAddEventHandler ["KeyDown", {
private ["_key", "_dlg", "_ctrl", "_config", "_acc", "_index"]; params ["", "_key"];
_key = _this select 1;
if (_key == 1 && {alive player}) then { if (_key == 1 && {alive player}) then {
createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer); createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer);
disableSerialization; disableSerialization;
private ["_dlg", "_ctrl"];
_dlg = finddisplay 49; _dlg = finddisplay 49;
_dlg displayAddEventHandler ["KeyDown", { _dlg displayAddEventHandler ["KeyDown", {
_key = _this select 1; params ["", "_key"];
!(_key == 1) !(_key == 1)
}]; }];
@ -62,13 +62,15 @@ if (_state) then {
_ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer); _ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer);
_ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1; [false] call DFUNC(disableUserInput);)]; _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 ctrlSetText "RESPAWN";
_ctrl ctrlSetTooltip "Respawn."; _ctrl ctrlSetTooltip "Respawn.";
}; };
if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then { if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then {
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
private "_acc";
_acc = accTime; _acc = accTime;
teamSwitch; teamSwitch;
setAccTime _acc; setAccTime _acc;

View File

@ -1,25 +1,21 @@
/* /*
* Author: commy2, Glowbal * Author: commy2, Glowbal
*
* Display a structured text with image. * Display a structured text with image.
* *
* Argument: * Arguments:
* 0: Text <ANY> * 0: Text <ANY>
* 1: Image <STRING> * 1: Image <STRING>
* 2: Image color <ARRAY> <OPTIONAL> * 2: Image color (default: [0, 0, 0, 0]) <ARRAY>
* 3: Target Unit. Will only display if target is the player controlled object <OBJECT> <OPTIONAL> * 3: Target Unit. Will only display if target is the player controlled object (default: ACE_player) <OBJECT>
* *
* Return value: * Return Value:
* Nothing * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_imageColor", "_target"]; params ["_text", "_image", ["_imageColor", [1,1,1]], ["_target", ACE_player]];
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};
if (_target != ACE_player) exitWith {}; if (_target != ACE_player) exitWith {};
@ -28,16 +24,21 @@ if (typeName _text != "TEXT") then {
if (count _text > 0) then { if (count _text > 0) then {
{ {
if (typeName _x == "STRING" && {isLocalized _x}) 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; _text = format _text;
}; };
}; };
if (typeName _text == "STRING" && {isLocalized _text}) then { if (typeName _text == "STRING" && {isLocalized _text}) then {
_text = localize _text; _text = localize _text;
}; };
_text = parseText format ["<t align='center'>%1</t>", _text]; _text = parseText format ["<t align='center'>%1</t>", _text];
}; };
_text = composeText [parseText format ["<img size='2' align='center' color='%2' image='%1'/>", _image, _imageColor call BIS_fnc_colorRGBtoHTML], lineBreak, _text]; _text = composeText [parseText format ["<img size='2' align='center' color='%2' image='%1'/>", _image, _imageColor call BIS_fnc_colorRGBtoHTML], lineBreak, _text];
[_text, 2] call FUNC(displayTextStructured); [_text, 2] call FUNC(displayTextStructured);

View File

@ -1,23 +1,20 @@
/* /*
* Author: commy2, Glowbal * Author: commy2, Glowbal
*
* Display a structured text. * Display a structured text.
* *
* Argument: * Arguments:
* 0: Text <ANY> * 0: Text <ANY>
* 1: Size of the textbox <NUMBER> <OPTIONAL> * 1: Size of the textbox (default: 1.5) <NUMBER>
* 2: Target Unit. Will only display if target is the player controlled object <OBJECT> <OPTIONAL> * 2: Target Unit. Will only display if target is the player controlled object (default: ACE_player) <OBJECT>
* *
* Return value: * Return Value:
* Nothing * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_text", "_size", "_isShown", "_ctrlHint", "_yPos", "_xPos", "_wPos", "_hPos", "_position", "_target"]; params ["_text", ["_size", 1.5], ["_target", ACE_player]];
_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};
if (_target != ACE_player) exitWith {}; if (_target != ACE_player) exitWith {};
@ -38,6 +35,8 @@ if (typeName _text != "TEXT") then {
_text = composeText [lineBreak, parseText format ["<t align='center'>%1</t>", _text]]; _text = composeText [lineBreak, parseText format ["<t align='center'>%1</t>", _text]];
}; };
private ["_isShown", "_ctrlHint", "_xPos", "_yPos", "_wPos", "_hPos", "_position"];
_isShown = ctrlShown (uiNamespace getVariable ["ACE_ctrlHint", controlNull]); _isShown = ctrlShown (uiNamespace getVariable ["ACE_ctrlHint", controlNull]);
("ACE_RscHint" call BIS_fnc_rscLayer) cutRsc ["ACE_RscHint", "PLAIN", 0, true]; ("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)); _wPos = (10 *(((safezoneW / safezoneH) min 1.2) / 40));
_hPos = (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)); _hPos = (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25));
//Zeus Interface Open and Display would be under the "CREATE" list // Zeus Interface Open and Display would be under the "CREATE" list
if (!isnull curatorCamera) then { if (!isNull curatorCamera) then {
_xPos = _xPos min ((safezoneX + safezoneW - 12.5 * (((safezoneW / safezoneH) min 1.2) / 40)) - _wPos); _xPos = _xPos min ((safezoneX + safezoneW - 12.5 * (((safezoneW / safezoneH) min 1.2) / 40)) - _wPos);
}; };

View File

@ -3,35 +3,22 @@
* *
* Execute an animation. This is used to not break things like the unconsciousness animation. * Execute an animation. This is used to not break things like the unconsciousness animation.
* *
* Argument: * Arguments:
* 0: Unit (Object) * 0: Unit <OBJECT>
* 1: Animation (String) * 1: Animation <STRING>
* 2: Priority of the animation. (Number, optional default: 0) * 2: Priority of the animation. (default: 0) <NUMBER>
* 0: PlayMove * 0 = PlayMove
* 1: PlayMoveNow * 1 = PlayMoveNow
* 2: SwitchMove (no transitional animation, doesn't overwrite priority 1) * 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1)
* *
* Return value: * Return Value:
* Nothing * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_force"]; params ["_unit", "_animation", ["_priority", 0], ["_force", false]];
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;
};
// don't overwrite more important animations // don't overwrite more important animations
if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {}; if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {};
@ -47,7 +34,7 @@ if (_animation == "") then {
//if (_animation == animationState _unit) exitWith {}; //if (_animation == animationState _unit) exitWith {};
switch (_priority) do { switch (_priority) do {
case 0 : { case 0: {
if (_unit == vehicle _unit) then { if (_unit == vehicle _unit) then {
[_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc); [_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
} else { } else {
@ -55,7 +42,7 @@ switch (_priority) do {
[_unit, format ["{_this playMove '%1'}", _animation]] call FUNC(execRemoteFnc); [_unit, format ["{_this playMove '%1'}", _animation]] call FUNC(execRemoteFnc);
}; };
}; };
case 1 : { case 1: {
if (_unit == vehicle _unit) then { if (_unit == vehicle _unit) then {
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc); [_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
} else { } else {
@ -63,7 +50,7 @@ switch (_priority) do {
[_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc); [_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc);
}; };
}; };
case 2 : { case 2: {
// try playMoveNow first // try playMoveNow first
if (_unit == vehicle _unit) then { if (_unit == vehicle _unit) then {
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc); [_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
@ -80,5 +67,3 @@ switch (_priority) do {
}; };
default {}; default {};
}; };
["Anim", [_priority, _animation]] call FUNC(log);

View File

@ -1,30 +1,24 @@
/* /*
* Author: commy2 * Author: commy2
*
* Drops a backback. Also returns the ground wepaon holder object of the dropped backpack. * Drops a backback. Also returns the ground wepaon holder object of the dropped backpack.
* *
* Argument: * Arguments:
* 0: Unit that has a backpack (Object) * 0: Unit that has a backpack <OBJECT>
* *
* Return value: * Return value:
* Ground wepaon holder with backpack (Object) * Ground wepaon holder with backpack <OBJECT>
* *
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_unit); params ["_unit"];
private ["_backpackObject","_holder"]; private ["_backpackObject", "_holder"];
_backpackObject = backpackContainer _unit; _backpackObject = backpackContainer _unit;
_unit addBackpack "Bag_Base"; _unit addBackpack "Bag_Base";
removeBackpack _unit; removeBackpack _unit;
_holder = objNull;
{ objectParent _backpackObject // return
if (_backpackObject in everyBackpack _x) exitWith {
_holder = _x;
};
} forEach (position _unit nearObjects ["WeaponHolder", 5]);
_holder

View File

@ -1,10 +1,21 @@
//fnc_dumpArray.sqf /*
* Author: ?
* ?
*
* Arguments:
* 0: Array to be dumped <ARRAY>
* 1: Depth <NUMBER>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_pad", "_i", "_x"]; params ["_var", "_depth"];
PARAMS_2(_var,_depth);
private "_pad";
_pad = ""; _pad = "";
for "_i" from 0 to _depth do { for "_i" from 0 to _depth do {
@ -14,15 +25,18 @@ for "_i" from 0 to _depth do {
_depth = _depth + 1; _depth = _depth + 1;
if (IS_ARRAY(_var)) then { if (IS_ARRAY(_var)) then {
if ((count _var) > 0) then { if (_var isEqualTo []) then {
diag_log text format["%1[", _pad]; diag_log text format ["%1[],", _pad];
} else {
diag_log text format ["%1[", _pad];
{ {
[_x, _depth] call FUNC(dumpArray); [_x, _depth] call FUNC(dumpArray);
} forEach _var; false
diag_log text format["%1],", _pad]; } count _var;
} else {
diag_log text format["%1[],", _pad]; diag_log text format ["%1],", _pad];
}; };
} else { } else {
diag_log text format["%1%2", _pad, [_var] call FUNC(formatVar)]; diag_log text format ["%1%2", _pad, [_var] call FUNC(formatVar)];
}; };

View File

@ -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" #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 { if (!isNil "ACE_PFH_COUNTER") then {
{ {
private ["_isActive"];
_x params ["_pfh", "_parameters"]; _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) ]; private "_isActive";
} forEach ACE_PFH_COUNTER; _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 ["ACE COUNTER RESULTS"];
diag_log text format["-------------------------------------------"]; diag_log text format ["-------------------------------------------"];
{ {
private ["_counterEntry", "_iter", "_total", "_count", "_delta", "_averageResult"]; private ["_counterEntry", "_iter", "_total", "_count", "_averageResult", "_delta"];
_counterEntry = _x; _counterEntry = _x;
_iter = 0; _iter = 0;
_total = 0; _total = 0;
_count = 0; _count = 0;
_averageResult = 0; _averageResult = 0;
if( (count _counterEntry) > 3) then {
if (count _counterEntry > 3) then {
// calc // calc
{ {
if(_iter > 2) then { if (_iter > 2) then {
_count = _count + 1; _count = _count + 1;
_delta = (_x select 1) - (_x select 0); _delta = (_x select 1) - (_x select 0);
_total = _total + _delta; _total = _total + _delta;
}; };
_iter = _iter + 1; _iter = _iter + 1;
} forEach _counterEntry; false
} count _counterEntry;
// results // results
_averageResult = (_total / _count) * 1000; _averageResult = (_total / _count) * 1000;
// dump results // 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 { } 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 // Dump PFH Trackers

View File

@ -1,30 +1,40 @@
/** /*
* fn_getAllSetVariables.sqf * Author: Glowbal
* @Descr: Returns an 2d array of all variables that have been set on the object * Returns an 2d array of all variables that have been set on the object
* @Author: Glowbal
* *
* @Arguments: [unit OBJECT, category STRING (Optional. Only get the variables from the specified category. Default is "" == all)] * Arguments:
* @Return: ARRAY REturns an array with the format [ [name STRING, typeName STRING, value ANY, publicFlag BOOL, peristentFlag BOOL] ] * 0: Unit <OBJECT>
* @PublicAPI: true * 1: Limiting Category (default: "") <STRING>
*
* Return Value:
* Variable Data <ARRAY>
* 0: Name <STRING>
* 1: typeName <STRING>
* 2: value <ANY>
* 3: publicFlag <BOOL>
* 4: peristentFlag <BOOL>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_return", "_val", "_category"]; params ["_object", ["_category", ""]];
PARAMS_1(_object);
_category = if (count _this > 1) then { _this select 1 } else { "" };
if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith { if (isNil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith {[]};
[];
}; private ["_return", "_val"];
_return = []; _return = [];
{ {
_val = _object getvariable (_x select 0); _val = _object getvariable (_x select 0);
if (!isnil "_val") then {
if (!isNil "_val") then {
if (_category == "" || _category == _x select 3) 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); false
} count GVAR(OBJECT_VARIABLES_STORAGE);
_return _return

View File

@ -1,28 +1,38 @@
/* /*
* Author: bux578, commy2 * Author: bux578, commy2
*
* Returns an array containing all items of a given unit * Returns an array containing all items of a given unit
* *
* Argument: * Arguments:
* 0: Unit (Object) * 0: Unit <OBJECT>
* *
* Return value: * Return Value:
* Array with all the gear, format: * 0: Headgear <STRING>
* 0: headgear (String) * 1: Goggles <STRING>
* 1: goggles (String) * 2: Uniform <STRING>
* 2,3: uniform (String, Array) * 3: Uniform Items <ARRAY>
* 4,5: vest (String, Array) * 4: Vest <String>
* 6,7: backpack (String, Array) * 5: Vest Items <ARRAY>
* 8-10: rifle (String, Array, Array) * 6: Backback <STRING>
* 11-13: launcher (String, Array, Array) * 7: Backpack Items <ARRAY>
* 14-16: pistol (String, Array, Array) * 8: Rifle <STRING>
* 17: map, compass, watch, etc. (Array) * 9: Rifle Items <ARRAY>
* 18: binocluar (String) * 10: Rifle Magazines <ARRAY>
* 11: Launcher <STRING>
* 12: Launcher Items <ARRAY>
* 13: Launcher Magazines <ARRAY>
* 14: Handgun <STRING>
* 15: Handgun Items <ARRAY>
* 16: Handgun Magazines <ARRAY>
* 17: Assigned Items (map, compass, watch, etc.) <ARRAY>
* 18: Binoculars <STRING>
* *
* Public: Yes
*
* Note: Element 17 includes the Head Mounted Display (HMD)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_unit); params ["_unit"];
if (isNull _unit) exitWith {[ if (isNull _unit) exitWith {[
"", "",

View File

@ -1,25 +1,27 @@
/* /*
* Author: commy2 * Author: commy2
*
* Return the captivity status of an unit. * Return the captivity status of an unit.
* *
* Argument: * Arguments:
* 0: Unit (Object) * 0: Unit <OBJECT>
* *
* Return value: * Return Value:
* Reasons, why the unit is a captive. An empty array is returned if the unit is not a captive (Array of Strings) * Captivity Reasons, empty if not captive <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_captivityReasons", "_unitCaptivityStatus", "_unitCaptivityReasons"]; params ["_unit"];
PARAMS_1(_unit); private ["_captivityReasons", "_unitCaptivityStatus", "_unitCaptivityReasons"];
_captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []]; _captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []];
_unitCaptivityStatus = [captiveNum _unit, count _captivityReasons] call FUNC(binarizeNumber); _unitCaptivityStatus = [captiveNum _unit, count _captivityReasons] call FUNC(binarizeNumber);
_unitCaptivityReasons = []; _unitCaptivityReasons = [];
{ {
if (_unitCaptivityStatus select _forEachIndex) then { if (_unitCaptivityStatus select _forEachIndex) then {
_unitCaptivityReasons pushBack _x; _unitCaptivityReasons pushBack _x;

View File

@ -1,10 +1,20 @@
// by commy2 /*
* Author: commy2
* Obtain children of a config entry
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Parent Entry Class Children <ARRAY>
*
* Public: Yes
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_classes"]; params ["_name", "_cfgClass"];
PARAMS_2(_name,_cfgClass);
private "_classes";
_classes = format ["configName inheritsFrom _x == '%1'", _name] configClasses (configFile >> _cfgClass); _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

View File

@ -1,21 +1,22 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the commander config of a vehicles turret. * Get the commander config of a vehicles turret.
* *
* Argument: * Arguments:
* 0: vehicle (Object) * 0: vehicle <OBJECT>
* *
* Return value: * Return Value:
* Commander config (Config) * Commander config <CONFIG>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_config", "_turret"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_config", "_turret"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle; _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_turret = [_vehicle] call FUNC(getTurretCommander); _turret = [_vehicle] call FUNC(getTurretCommander);
[_config, _turret] call FUNC(getTurretConfigPath) [_config, _turret] call FUNC(getTurretConfigPath) // return

View File

@ -1,21 +1,22 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the gunner config of a vehicles turret. * Get the gunner config of a vehicles turret.
* *
* Argument: * Arguments:
* 0: vehicle (Object) * 0: vehicle <OBJECT>
* *
* Return value: * Return Value:
* Gunner config (Config) * Gunner config <CONFIG>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_config", "_turret"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_config", "_turret"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle; _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_turret = [_vehicle] call FUNC(getTurretGunner); _turret = [_vehicle] call FUNC(getTurretGunner);
[_config, _turret] call FUNC(getTurretConfigPath) [_config, _turret] call FUNC(getTurretConfigPath) // return

View File

@ -1,17 +1,18 @@
/* /*
* Author: commy2 * 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 <STRING>
* *
* Argument: * Return Value:
* 0: A item's classname. (String) * Config category ("CfgWeapons", "CfgMagazines", "CfgGlasses", "") <STRING>
* *
* Return value: * Public: Yes
* CfgWhatever (String)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_item); params ["_item"];
if (isClass (configFile >> "CfgWeapons" >> _item)) exitWith {"CfgWeapons"}; if (isClass (configFile >> "CfgWeapons" >> _item)) exitWith {"CfgWeapons"};

View File

@ -1,17 +1,18 @@
/* /*
* Author: commy2 * 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 <STRING>
* *
* Argument: * Return Value:
* 0: An object's classname. (String) * Config category ("CfgWeapons", "Cfgmagazines", "CfgGlasses", "") <STRING>
* *
* Return value: * Public: Yes
* CfgWhatever (String)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_object); params ["_object"];
if (isClass (configFile >> "CfgVehicles" >> _object)) exitWith {"CfgVehicles"}; if (isClass (configFile >> "CfgVehicles" >> _object)) exitWith {"CfgVehicles"};

View File

@ -9,35 +9,38 @@
* animation <STRING> * animation <STRING>
* *
* Example: * Example:
* [bob] call ace_common_fnc_getDeathAnim; * [bob] call ace_common_fnc_getDeathAnim
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #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 = ""; _returnAnimation = "";
_animationState = (animationState _unit); _animationState = animationState _unit;
_unitAnimationCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState); _unitAnimationCfg = configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState;
//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"))); //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); TRACE_2("Animation/Action", configName _unitAnimationCfg, configName _unitActionsCfg);
if ((vehicle _unit) != _unit) then { if (vehicle _unit != _unit) then {
_interpolateArray = getArray (_unitAnimationCfg >> "interpolateTo"); _interpolateArray = getArray (_unitAnimationCfg >> "interpolateTo");
for "_index" from 0 to (count _interpolateArray - 1) step 2 do { for "_index" from 0 to (count _interpolateArray - 1) step 2 do {
_indexAnimation = _interpolateArray select _index; _indexAnimation = _interpolateArray select _index;
//No guarentee that first animation will be right so scan for the first "terminal" animation //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}; //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; _returnAnimation = _indexAnimation;
}; };
}; };

View File

@ -1,19 +1,37 @@
// by commy2 /*
* Author: commy2
* Get the Defualt animation for the unit
*
* Arguments:
* 0: unit <OBJECT>
*
* Return Value:
* animation <STRING>
*
* Example:
* [bob] call ace_common_fnc_getDefaultAnim;
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit"];
private ["_anim", "_stance"]; private ["_anim", "_stance"];
PARAMS_1(_unit); _anim = toLower animationState _unit;
_anim = toLower (animationState _unit);
// stance is broken for some animations. // stance is broken for some animations.
_stance = stance _unit; _stance = stance _unit;
if (_anim find "ppne" == 4) then { if (_anim find "ppne" == 4) then {
_stance = "PRONE"; _stance = "PRONE";
}; };
if (_anim find "pknl" == 4) then { if (_anim find "pknl" == 4) then {
_stance = "CROUCH"; _stance = "CROUCH";
}; };
if (_anim find "perc" == 4) then { if (_anim find "perc" == 4) then {
_stance = "STAND"; _stance = "STAND";
}; };

View File

@ -1,33 +1,38 @@
/** /*
* fn_getVariable.sqf * Author: Glowbal
* @Descr: Grabs a variable. If variable has not been set, attempts to use default defined value * Grabs a variable. If variable has not been set, attempts to use default defined value
* @Author: Glowbal
* *
* @Arguments: [unit OBJECT, variableName STRING] * Arguments:
* @Return: ANY * 0: unit <OBJECT>
* @PublicAPI: true * 1: Variable Name <STRING>
*
* Return Value:
* Value of variable or default value, if the variable is undefined <ANY>
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
#define UNIT (_this select 0) params ["_unit", "_variable", "_defaultValue"];
#define VARIABLE (_this select 1)
private "_value"; private "_value";
_value = _unit getvariable _variable;
_value = UNIT getvariable VARIABLE; if (isNil "_value") then {
if (isnil "_value") then { if (!isNil "_defaultValue") then {
if (count _this >2) then { _value = _defaultValue;
_value = _this select 2;
} else { } else {
private "_definedVariable"; private "_definedVariable";
_definedVariable = ([VARIABLE] call FUNC(getDefinedVariableInfo)); _definedVariable = [_variable] call FUNC(getDefinedVariableInfo);
if (count _definedVariable > 1) then { if (count _definedVariable > 1) then {
_value = _definedVariable select 1; _value = _definedVariable select 1;
}; };
}; };
if (isnil "_value") then {
if (isNil "_value") then {
_value = 0; _value = 0;
}; };
}; };
_value _value

View File

@ -1,19 +1,24 @@
/** /*
* fn_getvariableDefault.sqf * Author: Glowbal
* @Descr: Get the variable default value * Get the variable default value
* @Author: Glowbal
* *
* @Arguments: [variableName STRING] * Arguments:
* @Return: ANY * 0: Variable Name <STRING>
* @PublicAPI: true *
* Return Value:
* Default value of variable <ANY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_varName"];
private "_variableDefinition"; private "_variableDefinition";
_variableDefinition = ([_this select 0] call FUNC(getDefinedVariableInfo)); _variableDefinition = [_varName] call FUNC(getDefinedVariableInfo);
if (count _variableDefinition > 0) exitwith {
if !(_variableDefinition isEqualTo []) exitwith {
_variableDefinition select 1; _variableDefinition select 1;
}; };
nil; nil

View File

@ -1,12 +1,17 @@
/** /*
* fn_getvariableInfo.sqf * Author: Glowbal
* @Descr: N/A * Get the variable Informations
* @Author: Glowbal
* *
* @Arguments: [] * Arguments:
* @Return: * 0: Variable Name <STRING>
* @PublicAPI: false *
* Return Value:
* Variable Metadata <ARRAY>
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
+(missionNamespace getvariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + (_this select 0),[]])
params ["_varName"];
+ (missionNamespace getVariable [format [QGVAR(OBJECT_VARIABLES_STORAGE_%1), _varName], []])

View File

@ -1,15 +1,31 @@
// by commy2 /*
* Author: commy2
* Get display classnames from config with given idd.
*
* Arguments:
* 0: Display ID (idd) <NUMBER>
*
* Return Value:
* Display Classnames <ARRAY>
*
* Public: Yes
*
* Note: Really slow due to iteration through whole config. Meant for debugging.
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_configName", "_index", "_config"]; params ["_idd"];
_configName = ""; private ["_configNames", "_config"];
_configNames = [];
for "_index" from 0 to (count configFile - 1) do { for "_index" from 0 to (count configFile - 1) do {
_config = configFile select _index; _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

View File

@ -1,19 +1,20 @@
/* /*
* Author: bux578 * Author: bux578
* Returns all turret indecies of door gunners.
* *
* Gets the turret index of door gunners * Arguments:
* 0: Vehicle <OBJECT>
* *
* Argument: * Return Value:
* 0: Vehicle (Object) * All turret indecies of the Vehicle <ARRAY>
* *
* Return value: * Public: Yes
* Turret indexes of the door gunner. Empty array means no gunner position. (Array)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_turrets", "_doorTurrets", "_config"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_turrets", "_doorTurrets", "_config"];
_turrets = allTurrets [_vehicle, true]; _turrets = allTurrets [_vehicle, true];
@ -21,11 +22,13 @@ _doorTurrets = [];
{ {
_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 >> "isCopilot") == 0) && count (getArray (_config >> "weapons")) > 0 ) then { if (getNumber (_config >> "isCopilot" == 0) && {count getArray (_config >> "weapons") > 0}) then {
_doorTurrets pushBack _x; _doorTurrets pushBack _x;
}; };
} forEach _turrets; false
} count _turrets;
_doorTurrets _doorTurrets

View File

@ -1,25 +1,23 @@
/* /*
Name: FUNC(getForceWalkStatus) * Author: PabstMirror, commy2
* Returns reasons why the unit is forceWalk-ing.
Author: Pabst Mirror (from captivity by commy2) *
* Arguments:
Description: * 0: unit <OBJECT>
Returns reasons why the unit is forceWalk-ing, empty if not forced. *
* Return Value:
Parameters: * Force Walk reasons <ARRAY>
0: OBJECT - Unit *
* Example:
Returns: * [ACE_Player] call ace_common_fnc_getForceWalkStatus
ARRAY(of strings) - Reason why the unit is force walking *
* Public: Yes
Example: */
[ACE_Player] call FUNC(getForceWalkStatus)
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_forceWalkReasons", "_unitForceWalkNumber", "_unitForceWalkStatus", "_unitForceWalkReasons"]; params ["_unit"];
PARAMS_1(_unit); private ["_forceWalkReasons", "_unitForceWalkNumber", "_unitForceWalkStatus", "_unitForceWalkReasons"];
_forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []];
@ -28,6 +26,7 @@ _unitForceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0];
_unitForceWalkStatus = [_unitForceWalkNumber, count _forceWalkReasons] call FUNC(binarizeNumber); _unitForceWalkStatus = [_unitForceWalkNumber, count _forceWalkReasons] call FUNC(binarizeNumber);
_unitForceWalkReasons = []; _unitForceWalkReasons = [];
{ {
if (_unitForceWalkStatus select _forEachIndex) then { if (_unitForceWalkStatus select _forEachIndex) then {
_unitForceWalkReasons pushBack _x; _unitForceWalkReasons pushBack _x;

View File

@ -1,20 +1,19 @@
/* /*
* Author: commy2 * 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 <OBJECT>
* 1: Weapon <STRING>
* *
* Argument: * Return Value:
* 0: The vehicle (Object) * Gunner <OBJECT>
* 1: weapon of the vehicle (String)
* *
* Return value: * Public: Yes
* The turret gunner with this weapon (Object)
*/ */
#include "script_component.hpp"
private ["_vehicle", "_weapon"]; params ["_vehicle", "_weapon"];
_vehicle = _this select 0;
_weapon = _this select 1;
// on foot // on foot
if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle || {toLower _weapon in ["throw", "put"]}}) exitWith {gunner _vehicle}; if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle || {toLower _weapon in ["throw", "put"]}}) exitWith {gunner _vehicle};
@ -27,7 +26,8 @@ _gunner = objNull;
if (_weapon in (_vehicle weaponsTurret _x)) exitWith { if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
_gunner = _vehicle turretUnit _x; _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 // ensure that at least the pilot is returned if there is no gunner
if (isManualFire _vehicle && {isNull _gunner}) then { if (isManualFire _vehicle && {isNull _gunner}) then {

View File

@ -1,31 +1,26 @@
/* /*
* Author: commy2 * Author: commy2
* * Move unit into given vehicle position or switch to that position if the unit is already inside the vehicle.
* Move unit into given vehicle position. Or switch to that position if the unit is already inside the vehicle.
* *
* Arguments: * Arguments:
* 0: Unit to enter the vehicle (Object) * 0: Unit <OBJECT>
* 1: The vehicle to be entered (Object) * 1: Vehicle <OBJECT>
* 2: Position. Can be "Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver" or "Cargo" (String) * 2: Position ("Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver", "Cargo") <STRING>
* 3: Index. "Turret", "FFV", "Codriver" and "Cargo" support this optional parameter. Which position should be taken. * 3: Index (only applies to "Turret", "FFV", "Codriver", "Cargo") (default: next free index) <NUMBER>
* Note: This index is diffrent from Armas "cargoIndex". (Number, optional default: next free index)
* *
* Return Value: * Return Value:
* Nothing * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
#define CANGETINDRIVER (isNull (driver _vehicle) || {!alive driver _vehicle}) && {!lockedDriver _vehicle} && {getNumber (_config >> "isUav") != 1} #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} #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 _position;
_position = toLower (_this select 2);
_index = _this select 3; // optional, please don't use
if (isNil "_index") then {_index = -1};
// general // general
if (!alive _vehicle || {locked _vehicle > 1}) exitWith {false}; if (!alive _vehicle || {locked _vehicle > 1}) exitWith {false};
@ -39,9 +34,11 @@ _isInside = vehicle _unit == _vehicle;
_script = {}; _script = {};
_enemiesInVehicle = false; //Possible Side Restriction _enemiesInVehicle = false; //Possible Side Restriction
{ {
if (side _unit getFriend side _x < 0.6) exitWith {_enemiesInVehicle = true}; if (side _unit getFriend side _x < 0.6) exitWith {_enemiesInVehicle = true};
} forEach crew _vehicle; false
} count crew _vehicle;
switch (_position) do { switch (_position) do {
case "driver" : { case "driver" : {

View File

@ -1,83 +1,78 @@
/* /*
* Author: commy2 * Author: commy2
* Returns item type of given classname.
* *
* What kind of item is given classname * Arguments:
* 0: Item <STRING>
* *
* Argument: * Return Value:
* 0: Classname of a item. (String) * 0: Type ("weapon", "item", "magazine", "") <STRING>
* * 1: Item Description <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)
* *
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_item); params ["_item"];
private ["_cfgType"]; private ["_cfgType", "_config", "_type", "_default"];
_cfgType = [_item] call FUNC(getConfigType); _cfgType = [_item] call FUNC(getConfigType);
if (_cfgType == "") exitWith {["",""]}; if (_cfgType == "") exitWith {["", ""]};
if (_cfgType == "CfgGlasses") exitWith {["item","glasses"]}; if (_cfgType == "CfgGlasses") exitWith {["item", "glasses"]};
private ["_config", "_type"];
_config = configFile >> _cfgType >> _item; _config = configFile >> _cfgType >> _item;
_type = getNumber (_config >> "type"); _type = getNumber (_config >> "type");
if (isNumber (_config >> "ItemInfo" >> "type")) then { if (isNumber (_config >> "ItemInfo" >> "type")) then {
_type = getNumber (_config >> "ItemInfo" >> "type"); _type = getNumber (_config >> "ItemInfo" >> "type");
}; };
private "_default";
_default = ["item", "magazine"] select (_cfgType == "CfgMagazines"); _default = ["item", "magazine"] select (_cfgType == "CfgMagazines");
switch (true) do { switch (true) do {
case (_type == 0): {[_default,"unknown"]}; case (_type == 0): {[_default, "unknown"]};
case (_type == 2^0): {["weapon","primary"]}; case (_type == 2^0): {["weapon", "primary"]};
case (_type == 2^1): {["weapon","handgun"]}; case (_type == 2^1): {["weapon", "handgun"]};
case (_type == 2^2): {["weapon","secondary"]}; case (_type == 2^2): {["weapon", "secondary"]};
case (_type < 2^4): {["weapon","unknown"]}; case (_type < 2^4): {["weapon", "unknown"]};
case (_type == 2^4): {["magazine","handgun"]}; // handgun case (_type == 2^4): {["magazine", "handgun"]}; // handgun
case (_type == 2^8): {["magazine","primary"]}; // rifle case (_type == 2^8): {["magazine", "primary"]}; // rifle
case (_type == 2^9): {["magazine","secondary"]}; // rpg, mg, mines case (_type == 2^9): {["magazine", "secondary"]}; // rpg, mg, mines
//case (_type < 2^11): {["magazine","unknown"]}; //case (_type < 2^11): {["magazine", "unknown"]};
case (_type == 101): {["item","muzzle"]}; case (_type == 101): {["item", "muzzle"]};
case (_type == 201): {["item","optics"]}; case (_type == 201): {["item", "optics"]};
case (_type == 301): {["item","flashlight"]}; case (_type == 301): {["item", "flashlight"]};
case (_type == 302): {["item","under"]}; // czech for bipod item case (_type == 302): {["item", "under"]}; // czech for bipod item
case (_type == 401): {["item","first_aid_kit"]}; case (_type == 401): {["item", "first_aid_kit"]};
case (_type == 501): {["item","fins"]}; // not implemented case (_type == 501): {["item", "fins"]}; // not implemented
case (_type == 601): {["item","breathing_bomb"]}; // not implemented case (_type == 601): {["item", "breathing_bomb"]}; // not implemented
case (_type == 603): {["item","goggles"]}; case (_type == 603): {["item", "goggles"]};
case (_type == 604): {["item","scuba"]}; // not implemented case (_type == 604): {["item", "scuba"]}; // not implemented
case (_type == 605): {["item","headgear"]}; case (_type == 605): {["item", "headgear"]};
case (_type == 611): {["item","radio"]}; case (_type == 611): {["item", "radio"]};
case (_type == 616): {["item","hmd"]}; case (_type == 616): {["item", "hmd"]};
case (_type == 617): {["item","binocular"]}; case (_type == 617): {["item", "binocular"]};
case (_type == 619): {["item","medikit"]}; case (_type == 619): {["item", "medikit"]};
case (_type == 620): {["item","toolkit"]}; case (_type == 620): {["item", "toolkit"]};
case (_type == 621): {["item","uav_terminal"]}; case (_type == 621): {["item", "uav_terminal"]};
case (_type == 701): {["item","vest"]}; case (_type == 701): {["item", "vest"]};
case (_type == 801): {["item","uniform"]}; case (_type == 801): {["item", "uniform"]};
case (_type == 2^12): { case (_type == 2^12): {
switch (toLower getText (_config >> "simulation")) do { switch (toLower getText (_config >> "simulation")) do {
case ("weapon"): {["weapon","binocular"]}; case ("weapon"): {["weapon", "binocular"]};
case ("binocular"): {["weapon","binocular"]}; case ("binocular"): {["weapon", "binocular"]};
case ("nvgoggles"): {["item","nvgoggles"]}; case ("nvgoggles"): {["item", "nvgoggles"]};
case ("itemminedetector"): {["item","minedetector"]}; case ("itemminedetector"): {["item", "minedetector"]};
default {[_default,"unknown"]}; default {[_default, "unknown"]};
}; };
}; };
case (_type == 2^16): {["weapon","vehicle"]}; case (_type == 2^16): {["weapon", "vehicle"]};
case (_type == 2^17): {[_default,"unknown"]}; // ??? case (_type == 2^17): {[_default, "unknown"]}; // ???
default {[_default,"unknown"]}; default {[_default, "unknown"]};
}; };

View File

@ -3,22 +3,26 @@
* Read properties of given vehicles light. * Read properties of given vehicles light.
* *
* Arguments: * Arguments:
* 0: Object with lights (Object) * 0: Object with lights <OBJECT>
* 1: Light classname (String) * 1: Light classname <STRING>
* *
* Return Value: * Return Value:
* Stuff from config (Array) * 0: Light intensity <NUMBER>
* 1: Light position <STRING>
* 2: Light direction <STRING>
* 3: Light inner angle <NUMBER>
* 4: Light outer angle <NUMBER>
* *
* Public: Yes
*/ */
#include "script_component.hpp" #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; _config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "Reflectors" >> _light;
private ["_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"];
_intensity = getNumber (_config >> "intensity"); _intensity = getNumber (_config >> "intensity");
_position = getText (_config >> "position"); _position = getText (_config >> "position");
_direction = getText (_config >> "direction"); _direction = getText (_config >> "direction");
@ -26,35 +30,3 @@ _innerAngle = getNumber (_config >> "innerAngle");
_outerAngle = getNumber (_config >> "outerAngle"); _outerAngle = getNumber (_config >> "outerAngle");
[_intensity, _position, _direction, _innerAngle, _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;
};
};
};
*/

View File

@ -1,23 +1,29 @@
/* /*
* Author: commy2 * Author: commy2
* Read properties of given flashlight. @todo, Can weapons themselves still have flashlights (no attachment)? * Read properties of given flashlight.
* *
* Arguments: * Arguments:
* 0: A flashlight (String) * 0: Flashlight <STRING>
* *
* Return Value: * Return Value:
* Stuff from config (Array) * 0: Light intensity <NUMBER>
* 1: Light position <STRING>
* 2: Light direction <STRING>
* 3: Light inner angle <NUMBER>
* 4: Light outer angle <NUMBER>
* *
* Public: Yes
*/ */
#include "script_component.hpp" #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"; _config = configFile >> "CfgWeapons" >> _weapon >> "ItemInfo" >> "FlashLight";
private ["_intensity", "_position", "_direction", "_innerAngle", "_outerAngle"];
_intensity = getNumber (_config >> "intensity"); _intensity = getNumber (_config >> "intensity");
_position = getText (_config >> "position"); _position = getText (_config >> "position");
_direction = getText (_config >> "direction"); _direction = getText (_config >> "direction");
@ -25,32 +31,3 @@ _innerAngle = getNumber (_config >> "innerAngle");
_outerAngle = getNumber (_config >> "outerAngle"); _outerAngle = getNumber (_config >> "outerAngle");
[_intensity, _position, _direction, _innerAngle, _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};
};
*/

View File

@ -1,25 +1,21 @@
/* /*
* Author: commy2 * Author: commy2
*
* Returns the name of the object. Used to prevent issues with the name command. * Returns the name of the object. Used to prevent issues with the name command.
* *
* Argument: * Arguments:
* 0: Object (Object) * 0: Object <OBJECT>
* 1: Show effective commander name? (Bool, optinal default: false) * 1: Use effective commander name when used on vehicles (default: false) <BOOL>
* *
* Return value: * Return Value:
* The name. * Object Name <STRING>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_name"]; params ["_unit", ["_showEffective", false]];
PARAMS_2(_unit,_showEffective);
if (isNil "_showEffective") then {
_showEffective = false;
};
private "_name";
_name = ""; _name = "";
if (_unit isKindOf "CAManBase") then { if (_unit isKindOf "CAManBase") then {

View File

@ -1,14 +1,19 @@
/* /*
* Author: KoffeinFlummi * Author: KoffeinFlummi
* * Returns pitch, bank, yaw for given vehicle in degrees.
* Returns [pitch, bank, yaw] for given vehicle in degrees.
* *
* Arguments: * Arguments:
* 0: Unit/Vehicle * 0: Unit/Vehicle <OBJECT>
* *
* Return Value: * Return Value:
* [pitch, bank, yaw] * 0: pitch <NUMBER>
* 1: bank <NUMBER>
* 2: yaw <NUMBER>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
((_this select 0) call BIS_fnc_getPitchBank) + [getDir (_this select 0)] private ["_vehicle"];
(_vehicle call BIS_fnc_getPitchBank) + [getDir _vehicle]

View File

@ -1,23 +1,25 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the turret index of a vehicles commander. * Get the turret index of a vehicles commander.
* *
* Argument: * Arguments:
* 0: Vehicle (Object) * 0: Vehicle <OBJECT>
* *
* Return value: * Return Value:
* Turret index of the vehicles commander. Empty array means no observer position. (Array) * Vehicle commander turrent indecies <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_turrets", "_turret", "_config"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_turrets", "_turret", "_config"];
_turrets = allTurrets [_vehicle, true]; _turrets = allTurrets [_vehicle, true];
_turret = []; _turret = [];
{ {
_config = configFile >> "CfgVehicles" >> typeOf _vehicle; _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
@ -26,5 +28,7 @@ _turret = [];
if (getNumber (_config >> "primaryObserver") == 1) exitWith { if (getNumber (_config >> "primaryObserver") == 1) exitWith {
_turret = _x; _turret = _x;
}; };
} forEach _turrets; false
} count _turrets;
_turret _turret

View File

@ -1,28 +1,29 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the config path of a vehicles turret. * Get the config path of a vehicles turret.
* *
* Argument: * Arguments:
* 0: vehicles config (Config) * 0: Vehicle Config <CONFIG>
* 1: Turret index (Array) * 1: Turret indecies <ARRAY>
* *
* Return value: * Return Value:
* Turret config (Config) * Turret config <CONFIG>
*
* Public: Yes
*/ */
#include "script_component.hpp" #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 { for "_index" from 0 to (count _turretIndex - 1) do {
_config = _config >> "Turrets"; _config = _config >> "Turrets";
_offset = 0; _offset = 0;
_config2 = _config select 0; _config2 = _config select 0;
_foundClasses = 0; _foundClasses = 0;
for "_a" from 0 to (count _config - 1) do { for "_a" from 0 to (count _config - 1) do {
if (isClass _config2) then { if (isClass _config2) then {
_foundClasses = _foundClasses + 1; _foundClasses = _foundClasses + 1;
@ -33,6 +34,8 @@ for "_index" from 0 to (count _turretIndex - 1) do {
if (_foundClasses == _turretIndex select _index) exitWith {}; if (_foundClasses == _turretIndex select _index) exitWith {};
}; };
_config = _config2; _config = _config2;
}; };
_config _config

View File

@ -1,23 +1,25 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the turret index of a vehicles copilot. * Get the turret index of a vehicles copilot.
* *
* Argument: * Arguments:
* 0: Vehicle (Object) * 0: Vehicle <OBJECT>
* *
* Return value: * Return Value:
* Turret index of the vehicles gunner. Empty array means no copilot position. (Array) * Vehicle Copilot Turret indecies <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_turrets", "_turret", "_config"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_turrets", "_turret", "_config"];
_turrets = allTurrets [_vehicle, true]; _turrets = allTurrets [_vehicle, true];
_turret = []; _turret = [];
{ {
_config = configFile >> "CfgVehicles" >> typeOf _vehicle; _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
@ -26,6 +28,7 @@ _turret = [];
if (getNumber (_config >> "isCopilot") == 1 && {getNumber (_config >> "primaryGunner") != 1} && {getNumber (_config >> "primaryObserver") != 1}) exitWith { if (getNumber (_config >> "isCopilot") == 1 && {getNumber (_config >> "primaryGunner") != 1} && {getNumber (_config >> "primaryObserver") != 1}) exitWith {
_turret = _x; _turret = _x;
}; };
} forEach _turrets; false
} count _turrets;
_turret _turret

View File

@ -1,36 +1,46 @@
/* /*
* Author: jaynus * Author: jaynus
*
* Get the absolute turret direction for FOV/PIP turret. * Get the absolute turret direction for FOV/PIP turret.
* *
* Argument: * Arguments:
* 0: Vehicle (Object) * 0: Vehicle <OBJECT>
* 1: Turret Position * 1: Turret Position <ARRAY>
* *
* Return value: * Return Value:
* [position, direction] * 0: Position ASL <ARRAY>
* 1: Direction <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_vehicle,_position); params ["_vehicle", "_position"];
private ["_turret", "_povPos", "_povDir", "_gunBeginPos", "_gunEndPos", "_pov", "_gunBeg", "_gunEnd", "_pipDir"];
private ["_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir"];
_turret = [_vehicle, _position] call CBA_fnc_getTurret; _turret = [_vehicle, _position] call CBA_fnc_getTurret;
_pov = getText (_turret >> "memoryPointGunnerOptics"); _pov = getText (_turret >> "memoryPointGunnerOptics");
_gunBeg = getText (_turret >> "gunBeg"); _gunBeg = getText (_turret >> "gunBeg");
_gunEnd = getText (_turret >> "gunEnd"); _gunEnd = getText (_turret >> "gunEnd");
TRACE_3("", _pov, _gunBeg, _gunEnd); TRACE_3("", _pov, _gunBeg, _gunEnd);
// Pull the PIP pov or barrel direction, depending on how the model is set up // 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]; _povDir = [0,0,0];
if (_pov == "pip0_pos") then { 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; _povDir = _pipDir vectorDiff _povPos;
} else { } else {
_gunBeginPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg ) ); private ["_gunBeginPos", "_gunEndPos"];
_gunEndPos = ATLtoASL ( _vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd ) );
_gunBeginPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg));
_gunEndPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd));
_povDir = _gunBeginPos vectorDiff _gunEndPos; _povDir = _gunBeginPos vectorDiff _gunEndPos;
}; };

View File

@ -1,23 +1,25 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the turret index of a vehicles gunner. * Get the turret index of a vehicles gunner.
* *
* Argument: * Arguments:
* 0: Vehicle (Object) * 0: Vehicle <OBJECT>
* *
* Return value: * Return Value:
* Turret index of the vehicles gunner. Empty array means no gunner position. (Array) * Vehicle Gunner Turret indecies <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_turrets", "_turret", "_config"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_turrets", "_turret", "_config"];
_turrets = allTurrets [_vehicle, true]; _turrets = allTurrets [_vehicle, true];
_turret = []; _turret = [];
{ {
_config = configFile >> "CfgVehicles" >> typeOf _vehicle; _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
@ -26,6 +28,7 @@ _turret = [];
if (getNumber (_config >> "primaryGunner") == 1) exitWith { if (getNumber (_config >> "primaryGunner") == 1) exitWith {
_turret = _x; _turret = _x;
}; };
} forEach _turrets; false
} count _turrets;
_turret _turret

View File

@ -1,19 +1,21 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the turret index of a units current turret. * Get the turret index of a units current turret.
* *
* Argument: * Arguments:
* 0: Unit, not the vehicle (as in not a car but the player) (Object) * 0: Unit <OBJECT>
* *
* Return value: * 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) * Turret Index <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit"];
private ["_vehicle", "_turrets", "_units", "_index"]; private ["_vehicle", "_turrets", "_units", "_index"];
PARAMS_1(_unit);
_vehicle = vehicle _unit; _vehicle = vehicle _unit;
if (_unit == _vehicle) exitWith {[]}; if (_unit == _vehicle) exitWith {[]};
@ -21,9 +23,11 @@ if (_unit == _vehicle) exitWith {[]};
_turrets = allTurrets [_vehicle, true]; _turrets = allTurrets [_vehicle, true];
_units = []; _units = [];
{ {
_units pushBack (_vehicle turretUnit _x); _units pushBack (_vehicle turretUnit _x);
} forEach _turrets; false
} count _turrets;
_index = _units find _unit; _index = _units find _unit;

View File

@ -1,37 +1,45 @@
/* /*
* Author: commy2 * Author: commy2
* Get all turret indicies of a vehicle type.
* *
* Get all turret indicies of a vehicle. * Arguments:
* 0: Vehicle type <STRING>
* *
* Argument: * Return Value:
* 0: Vehicle type (String) * Turret Indecies <ARRAY>
* *
* Return value: * Public: Yes
* All turret index arrays of the vehicle. E.g: [[0], [0,0]] (Array) *
* Note: It's advised to use allTurrets [_vehicle, true] instead whenever possible
*/ */
#include "script_component.hpp" #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); _turrets = + (uiNamespace getVariable _varName);
if (!isNil "_turrets") exitWith {_turrets}; if (!isNil "_turrets") exitWith {_turrets};
private ["_config", "_fnc_addTurret"];
_config = configFile >> "CfgVehicles" >> _type; _config = configFile >> "CfgVehicles" >> _type;
_turrets = []; _turrets = [];
_fnc_addTurret = {
private ["_count", "_offset", "_index", "_path2", "_config2"];
PARAMS_2(_config,_path); _fnc_addTurret = {
params ["_config", "_path"];
_config = _config >> "Turrets"; _config = _config >> "Turrets";
private ["_count", "_offset", "_path2", "_config2"];
_count = count _config; _count = count _config;
_offset = 0; _offset = 0;
for "_index" from 0 to (_count - 1) do { for "_index" from 0 to (_count - 1) do {
_path2 = _path + [_index - _offset]; _path2 = _path + [_index - _offset];
_config2 = _config select _index; _config2 = _config select _index;

View File

@ -1,23 +1,25 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the turret indices of ffv turrets. * Get the turret indices of ffv turrets.
* *
* Argument: * Arguments:
* 0: Vehicle (Object) * 0: Vehicle <OBJECT>
* *
* Return value: * Return Value:
* Turret index of the vehicles gunner. Empty array means no ffv turrets. (Array) * Vehicle FFV Turret indecies <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_turrets", "_turret", "_config"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_turrets", "_turret", "_config"];
_turrets = allTurrets [_vehicle, true]; _turrets = allTurrets [_vehicle, true];
_turret = []; _turret = [];
{ {
_config = configFile >> "CfgVehicles" >> typeOf _vehicle; _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
@ -26,5 +28,7 @@ _turret = [];
if (getNumber (_config >> "isPersonTurret") == 1) then { if (getNumber (_config >> "isPersonTurret") == 1) then {
_turret pushBack _x; _turret pushBack _x;
}; };
} forEach _turrets; false
} count _turrets;
_turret _turret

View File

@ -1,23 +1,25 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the turret indices of other turrets (not gunner, commander, copilot or ffv). * Get the turret indices of other turrets (not gunner, commander, copilot or ffv).
* *
* Argument: * Arguments:
* 0: Vehicle (Object) * 0: Vehicle <OBJECT>
* *
* Return value: * Return Value:
* Turret index of the vehicles gunner. Empty array means no other turrets. (Array) * Vehicle Other Turret indecies <ARRAY>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_turrets", "_turret", "_config"]; params ["_vehicle"];
PARAMS_1(_vehicle); private ["_turrets", "_turret", "_config"];
_turrets = allTurrets [_vehicle, true]; _turrets = allTurrets [_vehicle, true];
_turret = []; _turret = [];
{ {
_config = configFile >> "CfgVehicles" >> typeOf _vehicle; _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
@ -30,5 +32,7 @@ _turret = [];
) then { ) then {
_turret pushBack _x; _turret pushBack _x;
}; };
} forEach _turrets; false
} count _turrets;
_turret _turret

View File

@ -1,31 +1,33 @@
/* /*
* Author: commy2 * Author: commy2
*
* Get the compass direction the wind is blowing from. * Get the compass direction the wind is blowing from.
* *
* Argument: * Arguments:
* None. * None
* *
* Return value: * Return Value:
* Wind direction. (String) * Wind cardinal direction <STRING>
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
switch (round (windDir / 360 * 16)) do { localize ([
case 1 : {localize QUOTE(DOUBLES(STR,GVAR(SSW)))}; LSTRING(S),
case 2 : {localize QUOTE(DOUBLES(STR,GVAR(SW)))}; LSTRING(SSW),
case 3 : {localize QUOTE(DOUBLES(STR,GVAR(WSW)))}; LSTRING(SW),
case 4 : {localize QUOTE(DOUBLES(STR,GVAR(W)))}; LSTRING(WSW),
case 5 : {localize QUOTE(DOUBLES(STR,GVAR(WNW)))}; LSTRING(W),
case 6 : {localize QUOTE(DOUBLES(STR,GVAR(NW)))}; LSTRING(WNW),
case 7 : {localize QUOTE(DOUBLES(STR,GVAR(NNW)))}; LSTRING(NW),
case 8 : {localize QUOTE(DOUBLES(STR,GVAR(N)))}; LSTRING(NNW),
case 9 : {localize QUOTE(DOUBLES(STR,GVAR(NNE)))}; LSTRING(N),
case 10 : {localize QUOTE(DOUBLES(STR,GVAR(NE)))}; LSTRING(NNE),
case 11 : {localize QUOTE(DOUBLES(STR,GVAR(ENE)))}; LSTRING(NE),
case 12 : {localize QUOTE(DOUBLES(STR,GVAR(E)))}; LSTRING(ENE),
case 13 : {localize QUOTE(DOUBLES(STR,GVAR(ESE)))}; LSTRING(E),
case 14 : {localize QUOTE(DOUBLES(STR,GVAR(SE)))}; LSTRING(ESE),
case 15 : {localize QUOTE(DOUBLES(STR,GVAR(SSE)))}; LSTRING(SE),
default {localize QUOTE(DOUBLES(STR,GVAR(S)))}; LSTRING(SSE),
}; LSTRING(S)
] select (round (windDir / 360 * 16))) // return

View File

@ -1,14 +1,17 @@
/* /*
* Author: commy2 * Author: commy2
*
* Returns a value depending on current zoom level. * Returns a value depending on current zoom level.
* *
* Argument: * Arguments:
* None. * None
* *
* Return value: * Return Value:
* Zoom. (Number) * Zoom <NUMBER>
*
* Public: Yes
*/ */
#include "script_component.hpp" #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)

View File

@ -1,6 +1,5 @@
/* /*
* Author: Nou * Author: Nou
*
* Execute a global event on all clients, including self. * Execute a global event on all clients, including self.
* *
* Arguments: * Arguments: