mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
bfd5d13de8
commit
6b96c7fd7c
@ -1,13 +1,18 @@
|
|||||||
/**
|
/*
|
||||||
* fn_hasItem.sqf
|
* Author: Glowbal
|
||||||
* @Descr: Check if unit has item
|
* Check if unit has item
|
||||||
* @Author: Glowbal
|
|
||||||
*
|
*
|
||||||
* @Arguments: [unit OBJECT, item STRING (Classname of item)]
|
* Arguments:
|
||||||
* @Return: BOOL
|
* 0: Unit <OBJECT>
|
||||||
* @PublicAPI: true
|
* 1: Item Classname <STRING>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* has Item <BOOL>
|
||||||
|
*
|
||||||
|
* Public: yes
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
// item classname in items unit
|
params ["_unit", "_item"];
|
||||||
((_this select 1) in items (_this select 0));
|
|
||||||
|
_item in items _unit // return
|
||||||
|
@ -1,22 +1,18 @@
|
|||||||
/**
|
/*
|
||||||
* fn_hasMagazine.sqf
|
* Author: Glowbal
|
||||||
* @Descr: Check if given unit has a magazine of given classname
|
* Check if given unit has a magazine of given classname
|
||||||
* @Author: Glowbal
|
|
||||||
*
|
*
|
||||||
* @Arguments: [unit OBJECT, magazine STRING]
|
* Arguments:
|
||||||
* @Return: BOOL True if unith as given magazine
|
* 0: Unit <OBJECT>
|
||||||
* @PublicAPI: true
|
* 1: Magazine Classname <STRING>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* has Magazine <BOOL>
|
||||||
|
*
|
||||||
|
* Public: yes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_return"];
|
params ["_unit", "_magazine"];
|
||||||
PARAMS_2(_unit,_magazine);
|
|
||||||
|
|
||||||
if (_magazine != "") then {
|
_magazine in magazines _unit // return
|
||||||
_return = (_magazine in magazines _unit);
|
|
||||||
} else {
|
|
||||||
_return = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
_return
|
|
||||||
|
@ -34,7 +34,7 @@ titleCut ["", "BLACK"];
|
|||||||
_dummy = createVehicle ["ACE_Headbug_Fix", _pos, [], 0, "NONE"];
|
_dummy = createVehicle ["ACE_Headbug_Fix", _pos, [], 0, "NONE"];
|
||||||
_dummy setDir _dir;
|
_dummy setDir _dir;
|
||||||
_unit moveInAny _dummy;
|
_unit moveInAny _dummy;
|
||||||
sleep 0.1;
|
sleep 0.1; // @todo
|
||||||
|
|
||||||
unassignVehicle _unit;
|
unassignVehicle _unit;
|
||||||
_unit action ["Eject", vehicle _unit];
|
_unit action ["Eject", vehicle _unit];
|
||||||
|
@ -12,4 +12,4 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "looped") == 0
|
getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "looped") == 0 // return
|
||||||
|
@ -1,25 +1,36 @@
|
|||||||
/**
|
/*
|
||||||
* fn_inheritsFrom.sqf
|
* Author: Ruthberg
|
||||||
* @Descr: Checks whether a given configuration name appears in the inheritance tree of a specific configuration entry.
|
* Checks whether a given configuration name appears in the inheritance tree of a specific configuration entry.
|
||||||
* @Author: Ruthberg
|
|
||||||
*
|
*
|
||||||
* @Arguments: [configEntry CONFIG, configname STRING]
|
* Arguments:
|
||||||
* @Return: BOOL
|
* 0: configEntry (CONFIG)
|
||||||
* @PublicAPI: true
|
* 1: configname (STING)
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* BOOLEAN
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*
|
||||||
|
* Note: Not to be confused with the inheritsFrom scripting command.
|
||||||
|
*
|
||||||
|
* Deprecated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_match"];
|
params ["_configEntry", "_configMatch"];
|
||||||
PARAMS_2(_configEntry,_configMatch);
|
|
||||||
|
|
||||||
if (configName _configEntry == _configMatch) exitWith { true };
|
if (configName _configEntry == _configMatch) exitWith {true};
|
||||||
if (configName _configEntry == ",") exitWith { false };
|
if (configName _configEntry == ",") exitWith {false};
|
||||||
|
|
||||||
|
private "_match";
|
||||||
_match = false;
|
_match = false;
|
||||||
|
|
||||||
while {configName _configEntry != ""} do {
|
while {configName _configEntry != ""} do {
|
||||||
if (configName _configEntry == _configMatch) exitWith { _match = true };
|
if (configName _configEntry == _configMatch) exitWith {
|
||||||
_configEntry = inheritsFrom(_configEntry);
|
_match = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
_configEntry = inheritsFrom _configEntry;
|
||||||
};
|
};
|
||||||
|
|
||||||
_match
|
_match
|
||||||
|
@ -1,34 +1,38 @@
|
|||||||
/**
|
/*
|
||||||
* fn_insertionSort.sqf
|
* Author: Ruthberg
|
||||||
* @Descr: Sorts an array of numbers
|
* Sorts an array of numbers
|
||||||
* @Author: Ruthberg
|
|
||||||
*
|
*
|
||||||
* @Arguments: [array ARRAY, (optional) ascending BOOL]
|
* Arguments:
|
||||||
* @Return: sortedArray ARRAY
|
* 0: array <ARRAY>
|
||||||
* @PublicAPI: true
|
* 1: ascending (optional) <BOOL>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* sortedArray (ARRAY)
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_list", "_ascending", "_tmp", "_i", "_j"];
|
params ["_list", ["_ascending", true]];
|
||||||
_list = +(_this select 0);
|
|
||||||
_ascending = true;
|
|
||||||
if (count _this > 1) then {
|
|
||||||
_ascending = _this select 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
for "_i" from 1 to (count _list) - 1 do {
|
_list = + _list; // copy array to not alter the original one
|
||||||
|
|
||||||
|
private "_tmp";
|
||||||
|
|
||||||
|
for "_i" from 1 to (count _list - 1) do {
|
||||||
_tmp = _list select _i;
|
_tmp = _list select _i;
|
||||||
_j = _i;
|
_j = _i;
|
||||||
|
|
||||||
while {_j >= 1 && {_tmp < _list select (_j - 1)}} do {
|
while {_j >= 1 && {_tmp < _list select (_j - 1)}} do {
|
||||||
_list set [_j, _list select (_j - 1)];
|
_list set [_j, _list select (_j - 1)];
|
||||||
_j = _j - 1;
|
_j = _j - 1;
|
||||||
};
|
};
|
||||||
_list set[_j, _tmp];
|
|
||||||
|
_list set [_j, _tmp];
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!_ascending) then {
|
if (!_ascending) then {
|
||||||
reverse _list;
|
reverse _list;
|
||||||
};
|
};
|
||||||
|
|
||||||
_list
|
_list
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
// by commy2
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
* Interpolates between two set points in a curve.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: List of numbers to interpolate from <ARRAY>
|
||||||
|
* 1: Value / index <NUMBER>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Interpolation result <NUMBER>
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_min", "_max"];
|
params ["_array", "_value"];
|
||||||
|
|
||||||
PARAMS_2(_array,_value);
|
private ["_min", "_max"];
|
||||||
|
|
||||||
_min = _array select floor _value;
|
_min = _array select floor _value;
|
||||||
_max = _array select ceil _value;
|
_max = _array select ceil _value;
|
||||||
|
|
||||||
_min + (_max - _min) * (_value % 1)
|
_min + (_max - _min) * (_value % 1) // return
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Author: commy2
|
* Author: commy2
|
||||||
*
|
|
||||||
* Check if wind is set on auto.
|
* Check if wind is set on auto.
|
||||||
*
|
*
|
||||||
* Argument:
|
* Arguments
|
||||||
* None.
|
* None
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return Value:
|
||||||
* This mission has automatic wind? (Bool)
|
* This mission has automatic wind? <BOOL>
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
["Mission", "Intel", "windForced"] call FUNC(getNumberFromMissionSQM) != 1
|
["Mission", "Intel", "windForced"] call FUNC(getNumberFromMissionSQM) != 1 // return
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
/**
|
/*
|
||||||
* fn_isAwake.sqf
|
* Author: Glowbal
|
||||||
* @Descr: Check if unit is awake. Will be false when death or unit is unconscious.
|
|
||||||
* @Author: Glowbal
|
|
||||||
*
|
*
|
||||||
* @Arguments: [unit OBJECT]
|
* Check if unit is awake. Will be false when death or unit is unconscious.
|
||||||
* @Return: BOOL True if unit is awake
|
*
|
||||||
* @PublicAPI: true
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* if unit is awake <BOOL>
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
PARAMS_1(_unit);
|
params ["_unit"];
|
||||||
|
|
||||||
(!(_unit getvariable ["ACE_isUnconscious",false]) && alive _unit && !(_unit getvariable ["ACE_isDead",false]));
|
!(_unit getvariable ["ACE_isUnconscious", false]) && alive _unit && !(_unit getvariable ["ACE_isDead", false]);
|
||||||
|
@ -20,4 +20,4 @@
|
|||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
_unit getVariable ["ACE_isEOD", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "canDeactivateMines") == 1]
|
_unit getVariable ["ACE_isEOD", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "canDeactivateMines") == 1] // return
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
|
|
||||||
params ["_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] // return
|
||||||
|
@ -19,9 +19,8 @@
|
|||||||
* Example:
|
* Example:
|
||||||
* [] call ace_common_fnc_isFeatureCameraActive
|
* [] call ace_common_fnc_isFeatureCameraActive
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
!(
|
!(
|
||||||
@ -32,4 +31,4 @@
|
|||||||
{isNull (GETMVAR(BIS_fnc_camera_cam, objNull))} && // Splendid camera
|
{isNull (GETMVAR(BIS_fnc_camera_cam, objNull))} && // Splendid camera
|
||||||
{isNull (GETUVAR(BIS_fnc_animViewer_cam, objNull))} && // Animation viewer camera
|
{isNull (GETUVAR(BIS_fnc_animViewer_cam, objNull))} && // Animation viewer camera
|
||||||
{isNull (GETMVAR(BIS_DEBUG_CAM, objNull))} // Classic camera
|
{isNull (GETMVAR(BIS_DEBUG_CAM, objNull))} // Classic camera
|
||||||
)
|
) // return
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
*
|
*
|
||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
isClass (configFile >> "cfgPatches" >> _this select 0)
|
isClass (configFile >> "cfgPatches" >> _this select 0) // return
|
||||||
|
@ -16,4 +16,4 @@
|
|||||||
|
|
||||||
params ["_unit", ["_excludeRemoteControlled", false]];
|
params ["_unit", ["_excludeRemoteControlled", false]];
|
||||||
|
|
||||||
isPlayer _unit || (!_excludeRemoteControlled && {_unit == call FUNC(player)})
|
isPlayer _unit || (!_excludeRemoteControlled && {_unit == call FUNC(player)}) // return
|
||||||
|
Loading…
Reference in New Issue
Block a user