mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common cleanup
This commit is contained in:
parent
f83dea6e01
commit
7efcfcc8a0
@ -26,7 +26,6 @@ PREP(changeProjectileDirection);
|
||||
PREP(checkFiles);
|
||||
PREP(checkPBOs);
|
||||
PREP(claim);
|
||||
PREP(closeDialogIfTargetMoves);
|
||||
PREP(codeToLetter);
|
||||
PREP(codeToString);
|
||||
PREP(convertKeyCode);
|
||||
|
@ -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