mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2499 from acemod/commoncleanup3
common code cleanup part 3
This commit is contained in:
commit
4211d71a32
@ -26,7 +26,6 @@ PREP(changeProjectileDirection);
|
||||
PREP(checkFiles);
|
||||
PREP(checkPBOs);
|
||||
PREP(claim);
|
||||
PREP(closeDialogIfTargetMoves);
|
||||
PREP(codeToLetter);
|
||||
PREP(codeToString);
|
||||
PREP(convertKeyCode);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: esteldunedain and Jaynus
|
||||
* Author: esteldunedain, Jaynus
|
||||
* Returns the result of the function and caches it up to a given ACE_time or event
|
||||
*
|
||||
* Arguments:
|
||||
@ -8,7 +8,7 @@
|
||||
* 2: Namespace to store the cache on <NAMESPACE>
|
||||
* 3: Cache uid <STRING>
|
||||
* 4: Max duration of the cache <NUMBER>
|
||||
* 5: Event that clears the cache <STRING> (Optional)
|
||||
* 5: Event that clears the cache (default: nil) <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Result of the function <ANY>
|
||||
@ -17,33 +17,31 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_5(_params,_function,_namespace,_uid,_duration);
|
||||
params ["_params", "_function", "_namespace", "_uid", "_duration", "_event"];
|
||||
|
||||
//IGNORE_PRIVATE_WARNING("_eventName");
|
||||
|
||||
if (((_namespace getVariable [_uid, [-99999]]) select 0) < ACE_diagTime) then {
|
||||
if ((_namespace getVariable [_uid, [-99999]]) select 0 < ACE_diagTime) then {
|
||||
_namespace setVariable [_uid, [ACE_diagTime + _duration, _params call _function]];
|
||||
|
||||
// Does the cache needs to be cleared on an event?
|
||||
if (count _this > 5) then {
|
||||
private ["_event","_varName","_cacheList"];
|
||||
_event = _this select 5;
|
||||
_varName = format [QGVAR(clearCache_%1),_event];
|
||||
if (!isNil "_event") then {
|
||||
private ["_varName", "_cacheList"];
|
||||
|
||||
_varName = format [QGVAR(clearCache_%1), _event];
|
||||
_cacheList = missionNamespace getVariable _varName;
|
||||
|
||||
// If there was no EH to clear these caches, add one
|
||||
if (isNil {_cacheList}) then {
|
||||
if (isNil "_cacheList") then {
|
||||
_cacheList = [];
|
||||
missionNamespace setVariable [_varName, _cacheList];
|
||||
|
||||
[_event, {
|
||||
private ["_varName","_cacheList"];
|
||||
private ["_varName", "_cacheList"];
|
||||
// _eventName is defined on the function that calls the event
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
ACE_LOGINFO_1("Clear cached variables on event: %1",_eventName);
|
||||
#endif
|
||||
// Get the list of caches to clear
|
||||
_varName = format [QGVAR(clearCache_%1),_eventName];
|
||||
_varName = format [QGVAR(clearCache_%1), _eventName];
|
||||
_cacheList = missionNamespace getVariable [_varName, []];
|
||||
// Erase all the cached results
|
||||
{
|
||||
@ -57,11 +55,13 @@ if (((_namespace getVariable [_uid, [-99999]]) select 0) < ACE_diagTime) then {
|
||||
// Add this cache to the list of the event
|
||||
_cacheList pushBack [_namespace, _uid];
|
||||
};
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
ACE_LOGINFO_2("Calculated result: %1 %2",_namespace,_uid);
|
||||
} else {
|
||||
ACE_LOGINFO_2("Cached result: %1 %2",_namespace,_uid);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
(_namespace getVariable _uid) select 1
|
||||
|
@ -4,32 +4,26 @@
|
||||
* Is the unit able to enter the vehicle in the given position?
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit to enter the vehicle (Object)
|
||||
* 1: The vehicle to be entered (Object)
|
||||
* 2: Position. Can be "Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver" or "Cargo" (String)
|
||||
* 3: Check current distance to vehicles memory point? (Bool, optional default: false)
|
||||
* 0: Unit to enter the vehicle <OBJECT>
|
||||
* 1: The vehicle to be entered <OBJECT>
|
||||
* 2: Position. Can be "Driver", "Pilot", "Gunner", "Commander", "Copilot", "Turret", "FFV", "Codriver" or "Cargo" <STRING>
|
||||
* 3: Check current distance to vehicles memory point? (default: false) <BOOL>
|
||||
* 4: Index. "Turret", "FFV", "Codriver" and "Cargo" support this optional parameter. Which position should be taken.
|
||||
* Note: This index is diffrent from Armas "cargoIndex". (Number, optional default: next free index)
|
||||
* Note: This index is diffrent from Armas "cargoIndex". (default: next free index) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define CANGETINDRIVER (isNull (driver _vehicle) || {!alive driver _vehicle}) && {!lockedDriver _vehicle} && {getNumber (_config >> "isUav") != 1}
|
||||
#define CANGETINTURRETINDEX (isNull (_vehicle turretUnit _turret) || {!alive (_vehicle turretUnit _turret)}) && {!(_vehicle lockedTurret _turret)} && {getNumber (_config >> "isUav") != 1}
|
||||
|
||||
private ["_position", "_checkDistance", "_index"];
|
||||
params ["_unit", "_vehicle", "_position", ["_checkDistance", false], ["_index", -1]];
|
||||
|
||||
_this resize 5;
|
||||
|
||||
PARAMS_2(_unit,_vehicle);
|
||||
_position = toLower (_this select 2);
|
||||
_checkDistance = _this select 3;
|
||||
_index = _this select 4; // optional, please don't use
|
||||
|
||||
if (isNil "_checkDistance") then {_checkDistance = false};
|
||||
if (isNil "_index") then {_index = -1};
|
||||
_position = toLower _position;
|
||||
|
||||
// general
|
||||
if (!alive _vehicle || {locked _vehicle > 1}) exitWith {false};
|
||||
|
@ -1,14 +1,19 @@
|
||||
/**
|
||||
* fn_canInteract.sqf
|
||||
* @Descr: Check if unit can interact with enviroment. Unit has to be awake and not be in arrested state.
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Check if unit can interact with enviroment. Unit has to be awake and not be in arrested state.
|
||||
*
|
||||
* @Arguments: [unit OBJECT]
|
||||
* @Return: BOOL True if unit can interact with enviroment.
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Unit that try to Interact <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can interact with enviroment <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*
|
||||
* Deprecated
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
(((_unit getvariable [QGVAR(canInteract),0]) < 1) && ([_unit] call FUNC(isAwake)) && !([_unit] call FUNC(isArrested)))
|
||||
(_unit getvariable [QGVAR(canInteract),0]) < 1 && [_unit] call FUNC(isAwake) && !([_unit] call FUNC(isArrested))
|
||||
|
@ -5,45 +5,33 @@
|
||||
* Arguments:
|
||||
* 0: The player. <OBJECT>
|
||||
* 1: The interaction target. objNull to ignore. <OBJECT>
|
||||
* 2: Exceptions. What general conditions are to skip? <ARRAY> (Optional)
|
||||
* 2: Exceptions. What general conditions are to skip? (default: []) <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Unit can interact?
|
||||
*
|
||||
* Public: No
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_exceptions"];
|
||||
|
||||
PARAMS_2(_unit,_target);
|
||||
|
||||
_exceptions = if (count _this > 2) then {
|
||||
_this select 2;
|
||||
} else {
|
||||
[];
|
||||
};
|
||||
params ["_unit", "_target", ["_exceptions", []]];
|
||||
|
||||
_exceptions = [_exceptions, {toLower _this}] call FUNC(map);
|
||||
|
||||
// exit if the target is not free to interact
|
||||
private "_owner";
|
||||
_owner = _target getVariable [QGVAR(owner), objNull];
|
||||
|
||||
// exit if the target is not free to interact
|
||||
if (!isNull _owner && {_unit != _owner}) exitWith {false};
|
||||
|
||||
// check general conditions
|
||||
|
||||
private ["_conditions", "_conditionNames", "_conditionFuncs"];
|
||||
private ["_conditions", "_canInteract"];
|
||||
|
||||
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
||||
|
||||
_conditionNames = _conditions select 0;
|
||||
_conditionFuncs = _conditions select 1;
|
||||
_conditions params ["_conditionNames", "_conditionFuncs"];
|
||||
|
||||
private "_canInteract";
|
||||
_canInteract = true;
|
||||
|
||||
{
|
||||
if (!(_x in _exceptions) && {!([_unit, _target] call (_conditionFuncs select _forEachIndex))}) exitWith {
|
||||
_canInteract = false;
|
||||
|
@ -1,14 +1,23 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
* Check if the unit can use a Weapon.
|
||||
* Returns true if the unit is on foot or in a FFV position.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can the Unit use Weapons <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
// returns true if the unit is on foot or in a ffv position
|
||||
|
||||
private ["_config"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit == vehicle _unit) exitWith {true};
|
||||
|
||||
private "_config";
|
||||
_config = configFile >> "CfgMovesMaleSdr" >> "States" >> animationState _unit;
|
||||
|
||||
isClass _config
|
||||
|
@ -1,30 +1,25 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Adjust a projectiles velocity and dir + up vector.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Projectile (Object, CfgAmmo)
|
||||
* 1: Adjust azimuth this much. (Number)
|
||||
* 2: Adjust inclination this much. (Number)
|
||||
* 3: Adjust projectile speed this much. In m/s. (Number, optional default: 0 m/s)
|
||||
* Arguments:
|
||||
* 0: Projectile <OBJECT>
|
||||
* 1: Adjust azimuth this much. <NUMBER>
|
||||
* 2: Adjust inclination this much. <NUMBER>
|
||||
* 3: Adjust projectile speed this much. In m/s. (optional: 0) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_adjustSpeed", "_vdir", "_dir", "_up", "_vup", "_vel", "_vlat"];
|
||||
params ["_projectile", "_adjustDir", "_adjustUp", ["_adjustSpeed",0]];
|
||||
|
||||
PARAMS_3(_projectile,_adjustDir,_adjustUp);
|
||||
//["CPD", [_fnc_scriptNameParent, _adjustDir, _adjustUp, _adjustSpeed], nil, false] call FUNC(log);
|
||||
|
||||
_adjustSpeed = if (count _this > 3) then {
|
||||
_this select 3
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
["CPD", [_fnc_scriptNameParent, _adjustDir, _adjustUp, _adjustSpeed], nil, false] call FUNC(log);
|
||||
private ["_vdir", "_dir", "_up", "_vlat", "_vup", "_vel"];
|
||||
|
||||
// get old direction vector
|
||||
_vdir = vectorNormalized velocity _projectile;
|
||||
|
@ -1,13 +1,14 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Compares version numbers of PBOs and DLLs.
|
||||
*
|
||||
* Argument:
|
||||
* None.
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
@ -36,13 +37,17 @@ _addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter);
|
||||
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
|
||||
};
|
||||
};
|
||||
} forEach _addons;
|
||||
false
|
||||
} count _addons;
|
||||
|
||||
///////////////
|
||||
// check dlls
|
||||
///////////////
|
||||
{
|
||||
if (_x callExtension "version" == "") then {
|
||||
private "_versionEx";
|
||||
_versionEx = _x callExtension "version";
|
||||
|
||||
if (_versionEx == "") then {
|
||||
private "_errorMsg";
|
||||
_errorMsg = format ["Extension %1.dll not installed.", _x];
|
||||
|
||||
@ -53,9 +58,10 @@ _addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter);
|
||||
};
|
||||
} else {
|
||||
// Print the current extension version
|
||||
ACE_LOGINFO_2("Extension version: %1: %2",_x,(_x callExtension "version"));
|
||||
ACE_LOGINFO_2("Extension version: %1: %2",_x,_versionEx);
|
||||
};
|
||||
} forEach getArray (configFile >> "ACE_Extensions" >> "extensions");
|
||||
false
|
||||
} count getArray (configFile >> "ACE_Extensions" >> "extensions");
|
||||
|
||||
///////////////
|
||||
// check server version/addons
|
||||
@ -75,9 +81,7 @@ if (isMultiplayer) then {
|
||||
[{
|
||||
if (isNil QGVAR(ServerVersion) || isNil QGVAR(ServerAddons)) exitWith {};
|
||||
|
||||
private ["_version","_addons"];
|
||||
_version = (_this select 0) select 0;
|
||||
_addons = (_this select 0) select 1;
|
||||
(_this select 0) params ["_version", "_addons"];
|
||||
|
||||
if (_version != GVAR(ServerVersion)) then {
|
||||
private "_errorMsg";
|
||||
|
@ -5,22 +5,20 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Mode <NUMBER>
|
||||
* 0: Warn once
|
||||
* 1: Warn permanently
|
||||
* 2: Kick
|
||||
* 1: Check all PBOs? <BOOL> (Optional - default: false)
|
||||
* 2: Whitelist <STRING> (Optinal - default: "[]")
|
||||
* 0 = Warn once
|
||||
* 1 = Warn permanently
|
||||
* 2 = Kick
|
||||
* 1: Check all PBOs? (default: false) <BOOL>
|
||||
* 2: Whitelist (default: "[]") <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_mode", "_checkAll", "_whitelist"];
|
||||
|
||||
_mode = _this select 0;
|
||||
_checkAll = if (count _this > 1) then {_this select 1} else {false};
|
||||
_whitelist = if (count _this > 2) then {_this select 2} else {"[]"};
|
||||
params ["_mode", ["_checkAll", false], ["_whitelist", "[]"]];
|
||||
|
||||
_whitelist = [_whitelist, {toLower _this}] call FUNC(map);
|
||||
|
||||
@ -30,22 +28,17 @@ ACE_Version_Whitelist = _whitelist;
|
||||
if (!_checkAll) exitWith {}; //ACE is checked by FUNC(checkFiles)
|
||||
|
||||
if (!isServer) then {
|
||||
[_mode, _checkAll, _whitelist] spawn {
|
||||
private ["_missingAddon", "_missingAddonServer", "_oldVersionClient", "_oldVersionServer", "_text", "_error", "_rscLayer", "_ctrlHint"];
|
||||
PARAMS_3(_mode,_checkAll,_whitelist);
|
||||
[{
|
||||
if (isNil "ACE_Version_ClientErrors") exitWith {};
|
||||
|
||||
waitUntil {
|
||||
sleep 1;
|
||||
!isNil "ACE_Version_ClientErrors"
|
||||
};
|
||||
ACE_Version_ClientErrors params ["_missingAddon", "_missingAddonServer", "_oldVersionClient", "_oldVersionServer"];
|
||||
|
||||
_missingAddon = ACE_Version_ClientErrors select 0;
|
||||
_missingAddonServer = ACE_Version_ClientErrors select 1;
|
||||
_oldVersionClient = ACE_Version_ClientErrors select 2;
|
||||
_oldVersionServer = ACE_Version_ClientErrors select 3;
|
||||
(_this select 0) params ["_mode", "_checkAll", "_whitelist"];
|
||||
|
||||
// Display error message.
|
||||
if (_missingAddon || {_missingAddonServer} || {_oldVersionClient} || {_oldVersionServer}) then {
|
||||
private ["_text", "_error"];
|
||||
|
||||
_text = "[ACE] Version mismatch:<br/><br/>";
|
||||
_error = format ["ACE version mismatch: %1: ", profileName];
|
||||
|
||||
@ -72,6 +65,8 @@ if (!isServer) then {
|
||||
if (_mode < 2) then {
|
||||
_text = composeText [lineBreak, parseText format ["<t align='center'>%1</t>", _text]];
|
||||
|
||||
private ["_rscLayer", "_ctrlHint"];
|
||||
|
||||
_rscLayer = "ACE_RscErrorHint" call BIS_fnc_rscLayer;
|
||||
_rscLayer cutRsc ["ACE_RscErrorHint", "PLAIN", 0, true];
|
||||
|
||||
@ -91,9 +86,11 @@ if (!isServer) then {
|
||||
["[ACE] ERROR", _text, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
}, 1, [_mode, _checkAll, _whitelist]] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
if (_checkAll) then {
|
||||
0 spawn COMPILE_FILE(scripts\Version\checkVersionNumber);
|
||||
0 spawn COMPILE_FILE(scripts\Version\checkVersionNumber); // @todo
|
||||
};
|
||||
|
@ -1,22 +1,19 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Unit claims the ownership over an object. This is used to prevent multiple players from draging the same ammo box or using up the same wheel when repairing etc.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that claims another object. ObjNull to remove claim. (Object)
|
||||
* 1: The object that gets claimed. (Object)
|
||||
* 2: Lock the claimed object aswell? (Bool)
|
||||
* 0: Unit that claims another object. ObjNull to remove claim. <OBJECT>
|
||||
* 1: The object that gets claimed. <OBJECT>
|
||||
* 2: Lock the claimed object aswell? (optional: false) <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
* None
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_unit,_target,_lockTarget);
|
||||
|
||||
if (isNil "_lockTarget") then {_lockTarget = false};
|
||||
params ["_unit", "_target", ["_lockTarget", false]];
|
||||
|
||||
private "_owner";
|
||||
_owner = _target getVariable [QGVAR(owner), objNull];
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Closes the current dialog if the target moves, changes vehicle etc.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Target unit
|
||||
* 1: Ignore the unit being dead? (Optional, default: No)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
_this spawn {
|
||||
PARAMS_2(_target,_ignoreDead);
|
||||
private["_inVehicle", "_position", "_vehiclePlayer", "_vehicleTarget"];
|
||||
|
||||
if (isNil "_ignoreDead") then {_ignoreDead = false};
|
||||
|
||||
_vehicleTarget = vehicle _target;
|
||||
_vehiclePlayer = vehicle ACE_player;
|
||||
_inVehicle = _target != _vehicleTarget;
|
||||
|
||||
_position = getPosASL _target;
|
||||
|
||||
_fnc_check = {
|
||||
// either unit changed vehicles
|
||||
if (_vehiclePlayer != vehicle ACE_player) exitWith {True};
|
||||
if (_vehicleTarget != vehicle _target) exitWith {True};
|
||||
|
||||
// target died
|
||||
if (!alive _target && {!_ignoreDead}) exitWith {True};
|
||||
|
||||
// player fell unconscious
|
||||
if (ACE_player getVariable ["ACE_isUnconscious", False]) exitWith {True};
|
||||
|
||||
// target moved (outside of vehicle)
|
||||
(!_inVehicle && {getPosASL _target distanceSqr _position > 1})
|
||||
};
|
||||
|
||||
waitUntil {
|
||||
if (call _fnc_check) then {
|
||||
closeDialog 0;
|
||||
call EFUNC(interaction,hideMenu);
|
||||
};
|
||||
(isNil QEGVAR(interaction,MainButton) && !dialog) || {!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])} //Exit loop if DisableMouse dialog open
|
||||
};
|
||||
};
|
@ -1,4 +1,15 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
* Converts some keys to an Arma Dik Code.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Key <CODE, STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Dik Code <STRING>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
["", "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"] select ([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] find (_this select 0)) + 1
|
||||
|
@ -1,22 +1,23 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Removes the brackets around a code and returns the code as a string. It does nothing if the code is already a string.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Code (Code or String)
|
||||
* 0: Code <CODE, STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Code (String)
|
||||
* Code <STRING>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_function);
|
||||
params ["_function"];
|
||||
|
||||
if (typeName _function == "STRING") exitWith {_function};
|
||||
|
||||
_function = toArray str _function;
|
||||
_function set [0, -1];
|
||||
_function set [count _function - 1, -1];
|
||||
_function = toString (_function - [-1]);
|
||||
_function
|
||||
_function deleteAt 0;
|
||||
_function deleteAt (count _function - 1);
|
||||
|
||||
toString _function // return
|
||||
|
@ -1,27 +1,30 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Get a key code used in AGM key input eh.
|
||||
*
|
||||
* Get a key code used in ACE key input eh.
|
||||
* Arguments:
|
||||
* 0: Arma DIK code <NUMBER>
|
||||
* 1: Key state for shift left and shift right key <BOOL>
|
||||
* 2: Key state for ctrl left and ctrl right key <BOOL>
|
||||
* 3: Key state for alt and alt gr key <BOOL>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Arma DIK code (Number)
|
||||
* 1: Key state for shift left and shift right key (Bool)
|
||||
* 2: Key state for ctrl left and ctrl right key (Bool)
|
||||
* 3: Key state for alt and alt gr key (Bool)
|
||||
* Return Value:
|
||||
* Key code <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Key code (Number)
|
||||
* Public: Yes
|
||||
*
|
||||
* Deprecated
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define KEY_MODIFIERS [42, 54, 29, 157, 56, 184]
|
||||
|
||||
PARAMS_1(_key);
|
||||
params ["_key", "_stateShift", "_stateCtrl", "_stateAlt"];
|
||||
|
||||
if (_key in KEY_MODIFIERS) exitWith {_key};
|
||||
|
||||
if (_this select 1) then {_key = _key + 0.1};
|
||||
if (_this select 2) then {_key = _key + 0.2};
|
||||
if (_this select 3) then {_key = _key + 0.4};
|
||||
if (_stateShift) then {_key = _key + 0.1};
|
||||
if (_stateCtrl) then {_key = _key + 0.2};
|
||||
if (_stateAlt) then {_key = _key + 0.4};
|
||||
|
||||
_key
|
||||
|
@ -1,19 +1,21 @@
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
*
|
||||
* Returns a orthonormal system of reference aligned with the supplied vector
|
||||
*
|
||||
* Argument:
|
||||
* Vector to align the coordinate system with (Array)
|
||||
*
|
||||
* Return value:
|
||||
* 0: v1 (Array)
|
||||
* 1: v2 (Array)
|
||||
* 2: v3 (Array)
|
||||
* Return Value:
|
||||
* 0: Vector Normalized <ARRAY>
|
||||
* 1: Normalized Cross Product Vector <ARRAY>
|
||||
* 2: Vector Cross Product <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_v1","_v2","_v3"];
|
||||
private ["_v1", "_v2", "_v3"];
|
||||
|
||||
_v1 = vectorNormalized _this;
|
||||
_v2 = vectorNormalized (_v1 vectorCrossProduct [0,0,1]);
|
||||
_v3 = _v2 vectorCrossProduct _v1;
|
||||
|
@ -3,11 +3,13 @@
|
||||
*
|
||||
* Returns the current radio / chat / marker channel.
|
||||
*
|
||||
* Argument:
|
||||
* NONE.
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* The current channel. Can be "group", "side", "global", "command", "vehicle", "direct" or "custom_X" (String)
|
||||
* Return Value:
|
||||
* The current channel ("group", "side", "global", "command", "vehicle", "direct", "custom_X") <STRING>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
@ -1,51 +1,43 @@
|
||||
/**
|
||||
* fn_debug.sqf
|
||||
* @Descr: Print logging messages through the ACE framework.
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Print logging messages through the ACE framework.
|
||||
*
|
||||
* @Arguments: [message ANY, level NUMBER (Optional)]
|
||||
* @Return: BOOL True if message has been printed
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Message <ANY>
|
||||
* 1: Level (default: 2) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Message is Printed <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define DEFAULT_LOGGING_LEVEL -1
|
||||
#define DEFAULT_TEXT_DISPLAY -1
|
||||
|
||||
private ["_level", "_prefix", "_defaultLoglevel","_defaultLogDisplayLevel", "_message"];
|
||||
PARAMS_1(_msg);
|
||||
_level = if (count _this > 1) then {_this select 1} else { 2 };
|
||||
params ["_msg", ["_level", 2, [0]]];
|
||||
|
||||
if (typeName _level != "NUMBER") then {
|
||||
_level = 2;
|
||||
};
|
||||
private ["_defaultLoglevel", "_defaultLogDisplayLevel"];
|
||||
|
||||
_defaultLoglevel = if (isNil QGVAR(LOGLEVEL)) then {
|
||||
DEFAULT_LOGGING_LEVEL;
|
||||
} else {
|
||||
GVAR(LOGLEVEL);
|
||||
};
|
||||
_defaultLoglevel = [GVAR(LOGLEVEL), DEFAULT_LOGGING_LEVEL] select isNil QGVAR(LOGLEVEL);
|
||||
|
||||
if (_defaultLoglevel < 0) exitwith {
|
||||
false
|
||||
};
|
||||
if (_defaultLoglevel < 0) exitwith {false};
|
||||
|
||||
_defaultLogDisplayLevel = if (isnil QGVAR(LOGDISPLAY_LEVEL)) then {
|
||||
DEFAULT_TEXT_DISPLAY;
|
||||
} else {
|
||||
GVAR(LOGDISPLAY_LEVEL);
|
||||
};
|
||||
_defaultLogDisplayLevel = [GVAR(LOGDISPLAY_LEVEL), DEFAULT_TEXT_DISPLAY] select isNil QGVAR(LOGDISPLAY_LEVEL);
|
||||
|
||||
if (_level <= _defaultLoglevel) then {
|
||||
private ["_prefix", "_message"];
|
||||
|
||||
_prefix = switch (_level) do {
|
||||
case 0: { "ACE Error" };
|
||||
case 1: { "ACE Warn" };
|
||||
case 2: { "ACE Debug" };
|
||||
case 3: { "ACE Info" };
|
||||
default { "ACE Unknown" };
|
||||
switch (_level) do {
|
||||
case 0: {_prefix = "Error"};
|
||||
case 1: {_prefix = "Warn"};
|
||||
case 2: {_prefix = "Debug"};
|
||||
case 3: {_prefix = "Info"};
|
||||
default {_prefix = "Unknown"};
|
||||
};
|
||||
_message = format["[%1] %2",_prefix,_msg];
|
||||
|
||||
_message = format ["[ACE %1] %2", _prefix, _msg];
|
||||
|
||||
if (_level <= _defaultLogDisplayLevel) then {
|
||||
systemChat _message;
|
||||
@ -55,4 +47,5 @@ if (_level <= _defaultLoglevel) then {
|
||||
// pass it onwards to the log function:
|
||||
// [0, [], compile format["%1",_msg], true] call FUNC(log);
|
||||
};
|
||||
|
||||
true
|
||||
|
@ -1,16 +1,18 @@
|
||||
/**
|
||||
* fn_debugModule.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_entity);
|
||||
params ["_entity"];
|
||||
|
||||
GVAR(LOGDISPLAY_LEVEL) = call compile (_entity getvariable ["logDisplayLevel","4"]);
|
||||
GVAR(LOGLEVEL) = call compile (_entity getvariable ["logLevel","4"]);
|
||||
|
@ -1,38 +1,34 @@
|
||||
/**
|
||||
* fn_defineVariable.sqf
|
||||
* @Descr: Define a variable for the ACE variable framework
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Define a variable for the ACE variable framework
|
||||
*
|
||||
* @Arguments: [name STRING, defaultValue ANY, publicFlag BOOL, category STRING, type NUMBER, persistentFlag BOOL]
|
||||
* @Return:
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: Name <STRING>
|
||||
* 1: defaultValue <ANY>
|
||||
* 2: publicFlag <BOOL>
|
||||
* 3: category <STRING>
|
||||
* 4: type (default: 0) <NUMBER>
|
||||
* 5: persistentFlag (default: false) <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_code","_persistent"];
|
||||
params ["_name", "_value", "_defaultGlobal", "_category", ["_code", 0], ["_persistent", false]];
|
||||
|
||||
PARAMS_4(_name,_value,_defaultGlobal,_catagory);
|
||||
if (isNil "_defaultGlobal") exitWith {};
|
||||
|
||||
_code = 0;
|
||||
_persistent = false;
|
||||
|
||||
if (count _this < 3) exitwith {};
|
||||
if (count _this > 4) then {
|
||||
_code = _this select 4;
|
||||
if (count _this > 5) then {
|
||||
_persistent = _this select 5;
|
||||
};
|
||||
};
|
||||
|
||||
if (typeName _name != typeName "") exitwith {
|
||||
if (typeName _name != "STRING") exitwith {
|
||||
[format["Tried to the deinfe a variable with an invalid name: %1 Arguments: %2", _name, _this]] call FUNC(debug);
|
||||
};
|
||||
|
||||
if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) then {
|
||||
if (isNil QGVAR(OBJECT_VARIABLES_STORAGE)) then {
|
||||
GVAR(OBJECT_VARIABLES_STORAGE) = [];
|
||||
};
|
||||
|
||||
GVAR(OBJECT_VARIABLES_STORAGE) pushback [_name,_value,_defaultGlobal,_catagory,_code, _persistent];
|
||||
|
||||
missionNamespace setvariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + _name, [_name,_value,_defaultGlobal,_catagory,_code, _persistent]];
|
||||
GVAR(OBJECT_VARIABLES_STORAGE) pushBack [_name, _value, _defaultGlobal, _category, _code, _persistent];
|
||||
|
||||
missionNamespace setVariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + _name, [_name, _value, _defaultGlobal, _category, _code, _persistent]];
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Finds next valid index for the device array.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Offset from currentIndex (use 1 to find next valid after current) or a displayName string <STRING>or<NUMBER><OPTIONAL>
|
||||
* 0: Offset from currentIndex (use 1 to find next valid after current) or a displayName string (default: 0)<STRING, NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* The new index (-1 if no valid) <NUMBER>
|
||||
@ -16,23 +16,25 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
DEFAULT_PARAM(0,_searchOffsetOrName,0);
|
||||
params [["_searchOffsetOrName", 0]];
|
||||
|
||||
private ["_validIndex", "_offsetBy", "_realIndex", "_offset"];
|
||||
private ["_validIndex", "_realIndex"];
|
||||
|
||||
_validIndex = -1;
|
||||
|
||||
if ((typeName _searchOffsetOrName) == "STRING") then {
|
||||
if (typeName _searchOffsetOrName == "STRING") then {
|
||||
{
|
||||
if ((_x select 0) == _searchOffsetOrName) exitWith {
|
||||
if (_x select 0 == _searchOffsetOrName) exitWith {
|
||||
_validIndex = _forEachIndex;
|
||||
};
|
||||
} forEach GVAR(deviceKeyHandlingArray);
|
||||
} else {
|
||||
if ((count GVAR(deviceKeyHandlingArray)) > 0) then {
|
||||
_baseIndex = if (GVAR(deviceKeyCurrentIndex) == -1) then {0} else {GVAR(deviceKeyCurrentIndex) + _searchOffsetOrName};
|
||||
for "_offset" from _baseIndex to ((count GVAR(deviceKeyHandlingArray)) - 1 + _baseIndex) do {
|
||||
if (count GVAR(deviceKeyHandlingArray) > 0) then {
|
||||
_baseIndex = [GVAR(deviceKeyCurrentIndex) + _searchOffsetOrName, 0] select (GVAR(deviceKeyCurrentIndex) == -1);
|
||||
|
||||
for "_offset" from _baseIndex to (count GVAR(deviceKeyHandlingArray) - 1 + _baseIndex) do {
|
||||
_realIndex = _offset % (count GVAR(deviceKeyHandlingArray));
|
||||
|
||||
if ([] call ((GVAR(deviceKeyHandlingArray) select _realIndex) select 2)) exitWith {
|
||||
_validIndex = _realIndex;
|
||||
};
|
||||
|
@ -10,7 +10,7 @@
|
||||
* 4: Close Code (on ctrl-home press) <CODE>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [(localize "STR_ACE_microdagr_itemName"), QUOTE(PATHTOF(images\microDAGR_item.paa)), _conditionCode, _toggleCode, _closeCode] call ace_common_fnc_deviceKeyRegisterNew
|
||||
@ -19,7 +19,8 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_5(_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode);
|
||||
params ["_displayName", "_iconImage", "_conditionCode", "_toggleCode", "_closeCode"];
|
||||
|
||||
GVAR(deviceKeyHandlingArray) pushBack [_displayName, _iconImage, _conditionCode, _toggleCode, _closeCode];
|
||||
|
||||
GVAR(deviceKeyHandlingArray) pushBack [_displayName,_iconImage,_conditionCode,_toggleCode,_closeCode];
|
||||
[] call FUNC(deviceKeyFindValidIndex);
|
||||
|
@ -10,15 +10,17 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [bob, true] call ace_common_fnc_disableAI;
|
||||
* [bob, true] call ace_common_fnc_disableAI
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_disable);
|
||||
params ["_unit", "_disable"];
|
||||
|
||||
if ((local _unit) && {!([_unit] call EFUNC(common,isPlayer))}) then {
|
||||
if (!local _unit) exitWith {};
|
||||
|
||||
if !([_unit] call EFUNC(common,isPlayer)) then {
|
||||
if (_disable) then {
|
||||
_unit disableAI "MOVE";
|
||||
_unit disableAI "TARGET";
|
||||
@ -27,7 +29,10 @@ if ((local _unit) && {!([_unit] call EFUNC(common,isPlayer))}) then {
|
||||
_unit disableConversation true;
|
||||
} else {
|
||||
//Sanity check to make sure we don't enable unconsious AI
|
||||
if (_unit getVariable ["ace_isunconscious", false] && alive _unit) exitWith {ERROR("Enabling AI for unconsious unit");};
|
||||
if (_unit getVariable ["ace_isunconscious", false] && alive _unit) exitWith {
|
||||
ERROR("Enabling AI for unconsious unit");
|
||||
};
|
||||
|
||||
_unit enableAI "MOVE";
|
||||
_unit enableAI "TARGET";
|
||||
_unit enableAI "AUTOTARGET";
|
||||
|
Loading…
Reference in New Issue
Block a user