cleanup common

This commit is contained in:
commy2 2015-09-17 18:25:02 +02:00
parent 067b08611e
commit 36a279012c
20 changed files with 225 additions and 150 deletions

View File

@ -3,9 +3,9 @@
* Converts ASL to Arma "Position"
*
* Arguments:
* 0: position x <Number>
* 1: position y <Number>
* 2: position z <Number>
* 0: position x <NUMBER>
* 1: position y <NUMBER>
* 2: position z <NUMBER>
*
* Return Value:
* None

View File

@ -1,11 +1,22 @@
// by commy2
/*
* Author: commy2
*
* hint retun value of given function every frame
*
* Argument:
* <CODE>
*
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
terminate (missionNamespace getVariable [QGVAR(MonitorFnc), scriptNull]);
GVAR(MonitorFnc) = _this spawn {
waitUntil {
hintSilent str (call _this);
false
};
if (!isNil QGVAR(MonitorFnc)) then {
[GVAR(MonitorFnc)] call CBA_fnc_removePerFrameHandler;
};
GVAR(MonitorFnc) = [{
hintSilent str (call (_this select 0));
}, 0, _this] call CBA_fnc_addPerFrameHandler;

View File

@ -3,23 +3,23 @@
*
* Transforms a number to an array of the correspondending digits.
*
* Argument:
* 0: Number to 'digitize' (Number)
* 1: Set the minimal length of the returned array. Useful for getting left hand zeroes. (Number, optional)
* Arguments:
* 0: Number to 'digitize' <NUMBER>
* 1: Set the minimal length of the returned array. Useful for getting left hand zeroes. <NUMBER>, optional
*
* Return value:
* Return Value:
* Digits. The maximum count is six digits. (Array)
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_length", "_digits"];
PARAMS_2(_number,_minLength);
params ["_number", "_minLength"];
_number = _number min 999999;
_number = str _number;
private "_length";
_length = count _number;
if (isNil "_minLength") then {_minLength = _length};
@ -31,7 +31,9 @@ while {_length < _minLength} do {
_length = _length + 1;
};
private "_digits";
_digits = [];
for "_x" from 0 to (_length - 1) do {
_digits pushBack parseNumber (_number select [_x, 1]);
};

View File

@ -3,23 +3,23 @@
*
* Transforms a number to an string of the correspondending digits.
*
* Argument:
* 0: Number to 'digitize' (Number)
* Arguments:
* 0: Number to 'digitize' <NUMBER>
* 1: Set the minimal length of the returned string. Useful for getting left hand zeroes. (Number, optional)
*
* Return value:
* Return Value:
* Digits. The maximum length is six digits. (String)
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_length"];
PARAMS_2(_number,_minLength);
params ["_number", "_minLength"];
_number = _number min 999999;
_number = str _number;
private "_length";
_length = count _number;
if (isNil "_minLength") then {_minLength = _length};

View File

@ -3,23 +3,24 @@
*
* Converts a number to a string without losing as much precission as str or format.
*
* Argument:
* 0: A number (Number)
* Arguments:
* 0: A number <NUMBER>
*
* Return value:
* Return Value:
* The number as string (String)
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_decimals"];
params ["_number"];
PARAMS_1(_number);
_decimals = str (abs(_number) mod 1);
private "_decimals";
_decimals = str (abs _number mod 1);
_decimals = toArray _decimals;
_decimals deleteAt 0;
if (_number < 0) exitWith {
format ["-%1%2", floor abs(_number), toString _decimals];
format ["-%1%2", floor abs _number, toString _decimals];
};
format ["%1%2", floor _number, toString _decimals];

View File

@ -4,14 +4,15 @@
* Counterpart of ace_common_fnc_claim. Check if the given object is claimed by another unit.
*
* Arguments:
* 0: Any object. (Object)
* 0: Any object. <OBJECT>
*
* Return Value:
* Is this object claimed by someone?
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_target);
params ["_target"];
!isNull (_target getVariable [QGVAR(owner), objNull])

View File

@ -8,7 +8,9 @@
* NONE.
*
* Return Value:
* Player controlled unit (object)
* Player controlled unit <OBJECT>
*
* Public: Yes
*/
#include "script_component.hpp"

View File

@ -1,4 +1,16 @@
// by commy2
/*
* Author: commy2
*
* Return the current side of the player
*
* Arguments:
* None
*
* Return Value:
* current local side (Side)
*
* Public: Yes
*/
#include "script_component.hpp"
side group ACE_player

View File

@ -3,23 +3,23 @@
*
* Sets the name variable of the object. Used to prevent issues with the name command.
*
* Argument:
* 0: Object (Object)
* Arguments:
* 0: Object <OBJECT>
*
* Return value:
* Nothing.
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_name"];
PARAMS_1(_unit);
params ["_unit"];
if (isNull _unit || {!alive _unit}) exitWith {};
if (_unit isKindOf "CAManBase") then {
_name = [name _unit, true] call FUNC(sanitizeString);
//if (_name != _unit getVariable ["ACE_Name", ""]) then {
_unit setVariable ["ACE_Name", _name, true];
//};

View File

@ -1,8 +1,22 @@
// by commy2
/*
* Author: commy2
*
* hint the Variable ACE_isUsedBy from the input Object every frame
*
* Argument:
* <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
GVAR(Debug_Object) = _this select 0;
onEachFrame {
hintSilent str (GVAR(Debug_Object) getVariable ["ACE_isUsedBy", objNull]);
if (!isNil QGVAR(showUserPFH)) then {
[GVAR(showUserPFH)] call CBA_fnc_removePerFrameHandler;
};
GVAR(showUserPFH) = [{
hintSilent str ((_this select 0) getVariable ["ACE_isUsedBy", objNull]);
}, 0, _this] call CBA_fnc_addPerFrameHandler;

View File

@ -3,26 +3,27 @@
*
* Create a centered, colored text.
*
* Argument:
* 0: Text (Anything)
* 2: Color (Array)
* Arguments:
* 0: Text <ANY>
* 1: Color <ARRAY>
*
* Return value:
* Text
* Return Value:
* Text <STRING>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_string", "_color"];
params ["_string", "_color"];
_string = format ["%1", _this select 0];
_color = _this select 1;
_string = format ["%1", _string];
_color = (
[255 * (_color select 0), 2] call FUNC(toHex)
[255 * (_color select 0), 2] call FUNC(toHex)
) + (
[255 * (_color select 1), 2] call FUNC(toHex)
[255 * (_color select 1), 2] call FUNC(toHex)
) + (
[255 * (_color select 2), 2] call FUNC(toHex)
[255 * (_color select 2), 2] call FUNC(toHex)
);
parseText format ["<t align='center' color='#%2' >%1</t>", _string, _color];
parseText format ["<t align='center' color='#%2' >%1</t>", _string, _color]

View File

@ -1,23 +1,22 @@
/*
Author: commy2
Description:
Converts number to binary number
Arguments:
A number
Return Value:
A binary number, String
*/
* Author: commy2
*
* Converts number to binary number
*
* Arguments:
* A number
*
* Return Value:
* A binary number, String
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_number", ["_minLength", 1]];
private ["_sign", "_bin", "_rest"];
PARAMS_2(_number,_minLength);
if (isNil "_minLength") then {_minLength = 1};
_sign = ["", "-"] select (_number < 0);
_number = round abs _number;

View File

@ -3,11 +3,13 @@
*
* Convert an array of booleans into a number.
*
* Argument:
* 0: Booleans (Array of Booleans)
* Arguments:
* N: Booleans <ARRAY of Booleans>
*
* Return value:
* Return Value:
* Bitmask (Number)
*
* Public: Yes
*/
#include "script_component.hpp"

View File

@ -1,15 +1,16 @@
/*
Author: commy2, esteldunedain
Description:
Converts number to hexadecimal number
Arguments:
A number between 0 and 255 <NUMBER>
Return Value:
A hexadecimal number, String
*/
* Author: commy2, esteldunedain
*
* Converts number to hexadecimal number
*
* Arguments:
* A number between 0 and 255 <NUMBER>
*
* Return Value:
* A hexadecimal number, <STRING>
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_number"];

View File

@ -1,5 +1,6 @@
/*
* Author: SilentSpike (based on unmuteUnit)
*
* Globally unhides a unit. Only unhides if the last reason was removed.
*
* Arguments:
@ -7,17 +8,16 @@
* 1: Reason to unhide the unit <STRING>
*
* Return Value:
* nil
* None
*
* Example:
* [ACE_Player, "SpectatorMode"] call ace_common_fnc_unhideUnit
*
* Public: No
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_2(_unit,_reason);
params ["_unit", "_reason"];
if (isNull _unit) exitWith {};

View File

@ -3,16 +3,18 @@
*
* Unmutes the unit. Only unmutes if the last reason was removed.
*
* Argument:
* 0: Unit (Object)
* 1: Reason to unmute the unit. (String)
* Arguments:
* 0: Unit <OBJECT>
* 1: Reason to unmute the unit. <STRING>
*
* Return value:
* Nothing
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
PARAMS_2(_unit,_reason);
params ["_unit", "_reason"];
if (isNull _unit) exitWith {};

View File

@ -3,12 +3,12 @@
*
* Executes a code once with a given game ACE_time delay, using a PFH
*
* Argument:
* 0: Code to execute (Code)
* 1: Parameters to run the code with (Array)
* 2: Delay in seconds before executing the code (Number)
* Arguments:
* 0: Code to execute <CODE>
* 1: Parameters to run the code with <ARRAY>
* 2: Delay in seconds before executing the code <NUMBER>
*
* Return value:
* Return Value:
* None
*
* Example:
@ -18,7 +18,7 @@
*/
#include "script_component.hpp"
PARAMS_3(_func,_params,_delay);
params ["_func", "_params", "_delay"];
GVAR(waitAndExecArray) pushBack [(ACE_time + _delay), _func, _params];
GVAR(waitAndExecArray) sort true;

View File

@ -9,12 +9,16 @@
* Return Value:
* Wave height in meters
*
*
* Public: No
*/
#include "script_component.hpp"
if(isNil QGVAR(waveHeightLogic)) then {
params ["_position"];
if (isNil QGVAR(waveHeightLogic)) then {
GVAR(waveHeightLogic) = "Logic" createVehicleLocal [0,0,0];
};
GVAR(waveHeightLogic) setPosASL (_this select 0);
GVAR(waveHeightLogic) setPosASL _position;
(((getPosASLW GVAR(waveHeightLogic)) select 2) - ((getPosASL GVAR(waveHeightLogic)) select 2))
(getPosASLW GVAR(waveHeightLogic) select 2) - (getPosASL GVAR(waveHeightLogic) select 2)

View File

@ -1,53 +1,76 @@
// (c) zGuba 2011
// Function helper for framing objects on screen.
// Input: [_object,_margins3D,_offset3D] (object, 3 * float array, 3 * float array)
// Output: [_minX,_minY,_minY,_maxY] (4 * float)
/*
* Author: zGuba 2011
*
* Function helper for framing objects on screen.
*
* Arguments:
* 0: object <OBJECT>
* 1: margins 3D <ARRAY>
* 0: X <NUMBER>
* 1: Y <NUMBER>
* 2: Z <NUMBER>
* 2: offset 3D <ARRAY>
* 0: X <NUMBER>
* 1: Y <NUMBER>
* 2: Z <NUMBER>
*
* Return Value:
* 0: Minimal X <NUMMBER>
* 1: Minimal Y <NUMMBER>
* 2: Maximal X <NUMMBER>
* 3: Maximal Y <NUMMBER>
*
* Public: No
*/
#include "script_component.hpp"
private ["_minX","_minY","_maxX","_maxY", "_bounds", "_boundsCorners", "_boundsMax", "_boundsMaxX", "_boundsMaxY", "_boundsMaxZ", "_boundsMin", "_boundsMinX", "_boundsMinY", "_boundsMinZ"];
params ["_object", "_margins", "_offsets"];
PARAMS_3(_object,_margins,_offsets);
private ["_minX", "_minY", "_maxX", "_maxY", "_bounds", "_boundsCorners"];
_minX = 10;
_minY = 10;
_maxX = -10;
_maxY = -10;
if (true) then {
_bounds = boundingBox _object;
_bounds = boundingBox _object;
_margins params ["_marginsX", "_marginsY", "_marginsZ"];
_offsets params ["_offsetsX", "_offsetsY", "_offsetsZ"];
_boundsMin = _bounds select 0;
_boundsMinX = (_boundsMin select 0) - (_margins select 0) + (_offsets select 0);
_boundsMinY = (_boundsMin select 1) - (_margins select 1) + (_offsets select 1);
_boundsMinZ = (_boundsMin select 2) - (_margins select 2) + (_offsets select 2);
_boundsMax = _bounds select 1;
_boundsMaxX = (_boundsMax select 0) + (_margins select 0) + (_offsets select 0);
_boundsMaxY = (_boundsMax select 1) + (_margins select 1) + (_offsets select 1);
_boundsMaxZ = (_boundsMax select 2) + (_margins select 2) + (_offsets select 2);
_bounds params ["_boundsMin", "_boundsMax"];
_boundsMin params ["_boundsMinX", "_boundsMinY", "_boundsMinZ"];
_boundsMax params ["_boundsMaxX", "_boundsMaxY", "_boundsMaxZ"];
_boundsCorners = [
[_boundsMinX,_boundsMinY,_boundsMinZ],
[_boundsMinX,_boundsMinY,_boundsMaxZ],
[_boundsMinX,_boundsMaxY,_boundsMinZ],
[_boundsMinX,_boundsMaxY,_boundsMaxZ],
[_boundsMaxX,_boundsMinY,_boundsMinZ],
[_boundsMaxX,_boundsMinY,_boundsMaxZ],
[_boundsMaxX,_boundsMaxY,_boundsMinZ],
[_boundsMaxX,_boundsMaxY,_boundsMaxZ]
];
_boundsMinX = _boundsMinX - _marginsX + _offsetsX;
_boundsMinY = _boundsMinY - _marginsY + _offsetsY;
_boundsMinZ = _boundsMinZ - _marginsZ + _offsetsZ;
_boundsMaxX = _boundsMaxX + _marginsX + _offsetsX;
_boundsMaxY = _boundsMaxY + _marginsY + _offsetsY;
_boundsMaxZ = _boundsMaxZ + _marginsZ + _offsetsZ;
{
_ppos = worldToScreen (_object modelToWorld _x);
if (count _ppos >= 2) then {
EXPLODE_2_PVT(_ppos,_pposX,_pposY);
if (_pposX < _minX) then {_minX = _pposX};
if (_pposX > _maxX) then {_maxX = _pposX};
if (_pposY < _minY) then {_minY = _pposY};
if (_pposY > _maxY) then {_maxY = _pposY};
}; //else - what to do if it is offscreen?
} forEach _boundsCorners;
};
_boundsCorners = [
[_boundsMinX,_boundsMinY,_boundsMinZ],
[_boundsMinX,_boundsMinY,_boundsMaxZ],
[_boundsMinX,_boundsMaxY,_boundsMinZ],
[_boundsMinX,_boundsMaxY,_boundsMaxZ],
[_boundsMaxX,_boundsMinY,_boundsMinZ],
[_boundsMaxX,_boundsMinY,_boundsMaxZ],
[_boundsMaxX,_boundsMaxY,_boundsMinZ],
[_boundsMaxX,_boundsMaxY,_boundsMaxZ]
];
{
private "_ppos";
_ppos = worldToScreen (_object modelToWorld _x);
if (count _ppos >= 2) then {
_ppos params ["_pposX", "_pposY"];
if (_pposX < _minX) then {_minX = _pposX};
if (_pposX > _maxX) then {_maxX = _pposX};
if (_pposY < _minY) then {_minY = _pposY};
if (_pposY > _maxY) then {_maxY = _pposY};
}; //else - what to do if it is offscreen?
false
} count _boundsCorners;
[_minX,_minY,_maxX,_maxY]

View File

@ -10,4 +10,4 @@
if((count _this) > c) then {\
_callFrom = _this select c;\
_lineNo = _this select c+1;\
};
};