more common code cleanup

This commit is contained in:
commy2 2015-09-18 21:12:40 +02:00
parent a53d158a89
commit 5d0a7ed062
11 changed files with 106 additions and 107 deletions

View File

@ -3,12 +3,14 @@
* Converts some keys to an Arma Dik Code.
*
* Arguments:
* 0: Key <CODE, STRING>
* 0: Key <STRING>
*
* Return Value:
* Dik Code <STRING>
* Dik Code <NUMBER>
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"

View File

@ -1,25 +1,23 @@
/*
Name: FUNC(isEOD)
Author: Garth de Wet (LH)
Description:
Checks whether the passed unit is an explosive specialist.
Either through config entry: "canDeactivateMines"
or
unit setVariable ["ACE_isEOD", true]
Parameters:
0: OBJECT - Unit to check if is a specialist
Returns:
BOOLEAN
Example:
isSpecialist = [player] call FUNC(isEOD);
*/
* Author: Garth de Wet (LH)
* Checks whether the passed unit is an explosive specialist.
* Either through config entry: "canDeactivateMines"
* or
* unit setVariable ["ACE_isEOD", true]
*
* Arguments:
* 0: Unit to check if is a specialist <OBJECT>
*
* Return Value:
* is the unit an EOD <BOOL>
*
* Example:
* isSpecialist = [player] call FUNC(isEOD);
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
_unit getVariable ["ACE_isEOD", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "canDeactivateMines") == 1]

View File

@ -1,16 +1,17 @@
/*
* Author: marc_book, edited by commy2
*
* Checks if a unit is an engineer.
*
* Arguments:
* 0: unit to be checked (object)
* 0: unit to be checked <OBJECT>
*
* Return Value:
* Bool: is the unit an engineer?
* is the unit an engineer <BOOL>
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
_unit getVariable ["ACE_IsEngineer", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") == 1]
_unit getVariable ["ACE_isEngineer", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") == 1]

View File

@ -1,45 +1,44 @@
/*
* Author: commy2
*
* Check if the unit is in a building. Will return true if the unit is sitting in a bush.
*
* Argument:
* 0: Unit (Object)
* Arguments:
* 0: Unit <OBJECT>
*
* Return value:
* Is the unit in a building? (Bool)
* Is the unit in a building? <BOOL>
*
* Public: Yes
*/
#include "script_component.hpp"
#define DISTANCE 10
#define CHECK_DISTANCE 10
private ["_position", "_positionX", "_positionY", "_positionZ", "_intersections"];
params ["_unit"];
PARAMS_1(_unit);
private ["_position", "_intersections"];
_position = eyePos _unit;
_positionX = _position select 0;
_positionY = _position select 1;
_positionZ = _position select 2;
_intersections = 0;
if (lineIntersects [_position, [_positionX, _positionY, _positionZ + DISTANCE]]) then {
if (lineIntersects [_position, _position vectorAdd [0, 0, +CHECK_DISTANCE]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX + DISTANCE, _positionY, _positionZ]]) then {
if (lineIntersects [_position, _position vectorAdd [+CHECK_DISTANCE, 0, 0]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX - DISTANCE, _positionY, _positionZ]]) then {
if (lineIntersects [_position, _position vectorAdd [-CHECK_DISTANCE, 0, 0]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX, _positionY + DISTANCE, _positionZ]]) then {
if (lineIntersects [_position, _position vectorAdd [0, +CHECK_DISTANCE, 0]]) then {
_intersections = _intersections + 1;
};
if (lineIntersects [_position, [_positionX, _positionY - DISTANCE, _positionZ]]) then {
if (lineIntersects [_position, _position vectorAdd [0, -CHECK_DISTANCE, 0]]) then {
_intersections = _intersections + 1;
};

View File

@ -1,13 +1,16 @@
/**
* fn_isModLoaded_f.sqf
* Descr: Check in cfgPatches if modification is loaded
/*
* Author: Glowbal
* Check in cfgPatches if modification is loaded
*
* Arguments: [modName STRING (Classname of the mod in cfgPatches)]
* Return: BOOL true if modification is loaded
* PublicAPI: true
* Arguments:
* 0: Mod Name or Classname of the mod in cfgPatches <STRING>
*
* Return Value:
* if modification is loaded <BOOL>
*
* Public: Yes
*/
#include "script_component.hpp"
(isClass (configFile >> "cfgPatches" >> (_this select 0)))
isClass (configFile >> "cfgPatches" >> _this select 0)

View File

@ -1,21 +1,19 @@
/*
* Author: bux578, commy2, akalegman
*
* Checks if a unit is a player / curator controlled unit.
* Currently returns false for non-local remote controlled zeus units. (Remotes from another zeus machine)
*
* Arguments:
* 0: unit to be checked (object)
* 1: exclude remote controlled units (boolean)
* 0: unit to be checked <OBJECT>
* 1: exclude remote controlled units <BOOL>
*
* Return Value:
* Bool: is unit a player?
* Is unit a player? <BOOL>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_unit", "_excludeRemoteControlled"];
_unit = _this select 0;
_excludeRemoteControlled = if (count _this > 1) then {_this select 1} else {false};
params ["_unit", ["_excludeRemoteControlled", false]];
isPlayer _unit || (!_excludeRemoteControlled && {_unit == call FUNC(player)})

View File

@ -1,39 +1,19 @@
/*
* Author: commy2
*
* Check if the unit is in a vehicle and turned out.
*
* Argument:
* 0: Unit, not the vehicle (Object)
* Arguments:
* 0: Unit, not the vehicle <OBJECT>
*
* Return value:
* Is the unit turned out or not? Will return false if there is no option to turn out in the first place. (Bool)
* Return Value:
* Is the unit turned out or not? Will return false if there is no option to turn out in the first place. <BOOL>
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
private ["_vehicle", "_config", "_animation", "_action", "_inAction", "_turretIndex"];
params ["_unit"];
PARAMS_1(_unit);
_vehicle = vehicle _unit;
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_animation = animationState _unit;
if (_unit == driver _vehicle) then {
_action = getText (_config >> "driverAction");
_inAction = getText (_config >> "driverInAction");
} else {
_turretIndex = [_unit] call FUNC(getTurretIndex);
_config = [_config, _turretIndex] call FUNC(getTurretConfigPath);
_action = getText (_config >> "gunnerAction");
_inAction = getText (_config >> "gunnerInAction");
};
if (_action == "" || {_inAction == ""} || {_action == _inAction}) exitWith {false};
_animation = toArray _animation;
_animation resize (count toArray _action);
_animation = toString _animation;
_animation == _action
isTurnedOut _unit // return

View File

@ -1,4 +1,17 @@
// by commy2
/*
* Author: commy2
* Converts some Arma Dik Codes to a key.
*
* Arguments:
* 0: Dik Code <NUMBER>
*
* Return Value:
* Key <STRING>
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
[-1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 44, 21] select (["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] find toUpper (_this select 0)) + 1

View File

@ -3,18 +3,19 @@
* Calculate light intensity object 1 recieves from object 2
*
* Arguments:
* 0: Object that recieves light (Object)
* 1: Object that emits light (Object)
* 0: Object that recieves light <OBJECT>
* 1: Object that emits light <OBJECT>
*
* Return Value:
* Brightest light level
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_unitPos","_lightLevel"];
params ["_unit", "_lightSource"];
PARAMS_2(_unit,_lightSource);
private ["_unitPos", "_lightLevel"];
_unitPos = _unit modelToWorld (_unit selectionPosition "spine3");
_lightLevel = 0;

View File

@ -13,7 +13,7 @@
*/
#include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
#define GROUP_SWITCH_ID QFUNC(loadPerson)
params ["_caller", "_unit"];

View File

@ -12,39 +12,43 @@
*/
#include "script_component.hpp"
private ["_parseConfigForDisplayNames", "_name"];
private ["_fnc_parseConfigForDisplayNames", "_name"];
_fnc_parseConfigForDisplayNames = {
params ["_optionEntry"];
_parseConfigForDisplayNames = {
private ["_optionEntry", "_values", "_text"];
_optionEntry = _this select 0;
if !(isClass _optionEntry) exitwith {false};
private "_values";
_values = getArray (_optionEntry >> "values");
_x set [3, getText (_optionEntry >> "displayName")];
_x set [4, getText (_optionEntry >> "description")];
_x set [5, _values];
_x set [8, getText (_optionEntry >> "category")];
{
private "_text";
_text = _x;
if (((typeName _text) == "STRING") && {(count _text) > 1} && {(_text select [0,1]) == "$"}) then {
_text = localize (_text select [1, ((count _text) - 1)]); //chop off the leading $
if (typeName _text == "STRING" && {count _text > 1} && {_text select [0, 1] == "$"}) then {
_text = localize (_text select [1]); //chop off the leading $
_values set [_forEachIndex, _text];
};
} forEach _values;
true;
true
};
// Iterate through settings
{
_name = _x select 0;
_x params ["_name"];
if !([configFile >> "ACE_Settings" >> _name] call _parseConfigForDisplayNames) then {
if !([configFile >> "ACE_ServerSettings" >> _name] call _parseConfigForDisplayNames) then {
if !([missionConfigFile >> "ACE_Settings" >> _name] call _parseConfigForDisplayNames) then {
if !([configFile >> "ACE_Settings" >> _name] call _fnc_parseConfigForDisplayNames) then {
if !([configFile >> "ACE_ServerSettings" >> _name] call _fnc_parseConfigForDisplayNames) then {
if !([missionConfigFile >> "ACE_Settings" >> _name] call _fnc_parseConfigForDisplayNames) then {
ACE_LOGWARNING_1("Setting found, but couldn't localize [%1] (server has but we don't?)",_name);
};
};
};
} forEach GVAR(settings);
false
} count GVAR(settings);