Merge pull request #2530 from acemod/commoncleanup6

common code cleanup part 6
This commit is contained in:
commy2 2015-09-20 10:44:31 +02:00
commit 8c8b23ec18
24 changed files with 347 additions and 364 deletions

View File

@ -27,7 +27,6 @@ PREP(checkPBOs);
PREP(claim); PREP(claim);
PREP(codeToLetter); PREP(codeToLetter);
PREP(codeToString); PREP(codeToString);
PREP(convertKeyCode);
PREP(createOrthonormalReference); PREP(createOrthonormalReference);
PREP(currentChannel); PREP(currentChannel);
PREP(debug); PREP(debug);
@ -151,7 +150,6 @@ PREP(removeSpecificMagazine);
PREP(requestCallback); PREP(requestCallback);
PREP(resetAllDefaults); PREP(resetAllDefaults);
PREP(restoreVariablesJIP); PREP(restoreVariablesJIP);
PREP(revertKeyCodeLocalized);
PREP(runAfterSettingsInit); PREP(runAfterSettingsInit);
PREP(sanitizeString); PREP(sanitizeString);
PREP(sendRequest); PREP(sendRequest);

View File

@ -1,30 +0,0 @@
/*
* Author: commy2
* Get a key code used in AGM 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>
*
* Return Value:
* Key code <NUMBER>
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
#define KEY_MODIFIERS [42, 54, 29, 157, 56, 184]
params ["_key", "_stateShift", "_stateCtrl", "_stateAlt"];
if (_key in KEY_MODIFIERS) exitWith {_key};
if (_stateShift) then {_key = _key + 0.1};
if (_stateCtrl) then {_key = _key + 0.2};
if (_stateAlt) then {_key = _key + 0.4};
_key

View File

@ -1,25 +1,23 @@
/* /*
* Author: commy2 * Author: commy2
*
* Remove a map marker creation event handler. * Remove a map marker creation event handler.
* *
* Argument: * Arguments:
* 0: ID of the event handler (Number) * 0: ID of the event handler <NUMBER>
* *
* Return value: * Return Value:
* None. * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_actionsVar", "_currentId", "_actionIDs", "_actions"]; params ["_id"];
PARAMS_1(_id);
private "_actionsVar";
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_MapMarker", [-1, [], []]]; _actionsVar = missionNamespace getVariable ["ACE_EventHandler_MapMarker", [-1, [], []]];
_currentId = _actionsVar select 0; _actionsVar params ["_currentId", "_actionIDs", "_actions"];
_actionIDs = _actionsVar select 1;
_actions = _actionsVar select 2;
_id = _actionIDs find _id; _id = _actionIDs find _id;

View File

@ -1,25 +1,23 @@
/* /*
* Author: commy2 * Author: commy2
*
* Remove a scroll wheel event handler. * Remove a scroll wheel event handler.
* *
* Argument: * Arguments:
* 0: ID of the event handler (Number) * 0: ID of the event handler <NUMBER>
* *
* Return value: * Return Value:
* None. * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_actionsVar", "_currentId", "_actionIDs", "_actions"]; params ["_id"];
PARAMS_1(_id);
private "_actionsVar";
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]]; _actionsVar = missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]];
_currentId = _actionsVar select 0; _actionsVar params ["_currentId", "_actionIDs", "_actions"];
_actionIDs = _actionsVar select 1;
_actions = _actionsVar select 2;
_id = _actionIDs find _id; _id = _actionIDs find _id;

View File

@ -2,68 +2,77 @@
* Author: esteldunedain * Author: esteldunedain
* Removes a magazine from the unit that has an specific ammo count * Removes a magazine from the unit that has an specific ammo count
* *
* Argument: * Arguments:
* 0: Player <OBJECT> * 0: Unit <OBJECT>
* 1: Magazine <STRING> * 1: Magazine <STRING>
* 2: Ammo count <NUMBER> * 2: Ammo count <NUMBER>
* *
* Return value: * Return Value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
EXPLODE_3_PVT(_this,_player,_magazineType,_ammoCount); params ["_unit", "_magazineType", "_ammoCount"];
private ["_isRemoved", "_magazines", "_index"];
private ["_magazines","_index","_isRemoved"];
_isRemoved = false; _isRemoved = false;
// Check uniform // Check uniform
_magazines = [magazinesAmmoCargo uniformContainer _player, {_this select 0 == _magazineType}] call FUNC(filter); _magazines = [magazinesAmmoCargo uniformContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
_index = _magazines find [_magazineType,_ammoCount]; _index = _magazines find [_magazineType, _ammoCount];
if (_index > -1) exitWith { if (_index > -1) exitWith {
{ {
_player removeItemFromUniform (_x select 0); _unit removeItemFromUniform (_x select 0);
} forEach _magazines; false
} count _magazines;
{ {
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then { if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
_isRemoved = true; _isRemoved = true;
} else { } else {
(uniformContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1]; (uniformContainer _unit) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
}; };
} forEach _magazines; false
} count _magazines;
}; };
// Check vest // Check vest
_magazines = [magazinesAmmoCargo vestContainer _player, {_this select 0 == _magazineType}] call FUNC(filter); _magazines = [magazinesAmmoCargo vestContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
_index = _magazines find [_magazineType,_ammoCount]; _index = _magazines find [_magazineType,_ammoCount];
if (_index > -1) exitWith { if (_index > -1) exitWith {
{ {
_player removeItemFromVest (_x select 0); _unit removeItemFromVest (_x select 0);
} forEach _magazines; false
} count _magazines;
{ {
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then { if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
_isRemoved = true; _isRemoved = true;
} else { } else {
(vestContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1]; (vestContainer _unit) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
}; };
} forEach _magazines; false
} count _magazines;
}; };
// Check backpack // Check backpack
_magazines = [magazinesAmmoCargo backpackContainer _player, {_this select 0 == _magazineType}] call FUNC(filter); _magazines = [magazinesAmmoCargo backpackContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
_index = _magazines find [_magazineType,_ammoCount]; _index = _magazines find [_magazineType,_ammoCount];
if (_index > -1) exitWith { if (_index > -1) exitWith {
{ {
_player removeItemFromBackpack (_x select 0); _unit removeItemFromBackpack (_x select 0);
} forEach _magazines; false
} count _magazines;
{ {
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then { if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
_isRemoved = true; _isRemoved = true;
} else { } else {
(backpackContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1]; (backpackContainer _unit) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
}; };
} forEach _magazines; false
} count _magazines;
}; };

View File

@ -1,27 +1,28 @@
/* /*
* Author: jaynus * Author: jaynus
*
* Remove a synced event handler * Remove a synced event handler
* *
* Argument: * Arguments:
* 0: Name (String) * 0: Name <STRING>
* *
* Return value: * Return Value:
* Boolean of success * Boolean of success
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_name); params ["_name"];
private ["_data", "_eventId"];
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
ACE_LOGERROR("Synced event key not found."); ACE_LOGERROR("Synced event key not found.");
false false
}; };
private ["_data", "_eventId"];
_data = HASH_GET(GVAR(syncedEvents),_name); _data = HASH_GET(GVAR(syncedEvents),_name);
_eventId = _data select 3; _eventId = _data select 3;
[_eventId] call ace_common_fnc_removeEventHandler; [_eventId] call FUNC(removeEventHandler);
HASH_REM(GVAR(syncedEvents),_name); HASH_REM(GVAR(syncedEvents),_name);

View File

@ -1,22 +1,19 @@
/** /*
* fn_requestCallback.sqf * Author: Glowbal
* @Descr: N/A * N/A
* @Author: Glowbal
* *
* @Arguments: [] * Arguments:
* @Return: * ?
* @PublicAPI: false *
* Return Value:
* ?
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"]; params ["_info", "_accepted"];
PARAMS_2(_info,_accepted);
_caller = _info select 0; _info params ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"];
_target = _info select 1;
_requestID = _info select 2;
_requestMessage = _info select 3;
_callBack = _info select 4;
[_caller, _target, _accepted] call compile _callBack; [_caller, _target, _accepted] call compile _callBack;

View File

@ -1,19 +1,20 @@
/* /*
* Author: jaynus * Author: jaynus
*
* Send a request to synchronize an event name from the client->server. Execute on client only. * Send a request to synchronize an event name from the client->server. Execute on client only.
* *
* Argument: * Arguments:
* 0: eventName (String) * 0: eventName <STRING>
* *
* Return value: * Return Value:
* Boolean of success * Boolean of success
*
* Public: No
*/ */
//#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_eventName);
params ["_eventName"];
// Only JIP machines on initialization send this off, requesting sync on events with the serverCommand // Only JIP machines on initialization send this off, requesting sync on events with the serverCommand
if(isServer) exitWith { false }; if (isServer) exitWith {false};
["SEH_s", [_eventName, ACE_player] ] call ace_common_fnc_serverEvent; ["SEH_s", [_eventName, ACE_player] ] call FUNC(serverEvent);

View File

@ -1,39 +1,44 @@
/** /*
* fn_resetAllDefaults_f.sqf * Author: Glowbal
* @Descr: reset all variables that have been defined * reset all variables that have been defined
* @Author: Glowbal
* *
* @Arguments: [] * Arguments:
* @Return: * ?
* @PublicAPI: false *
* Return Value:
* ?
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_unit); params ["_unit"];
_unit setvariable ["ACE_isDead",nil,true]; _unit setvariable ["ACE_isDead", nil, true];
_unit setvariable ["ACE_isUnconscious", nil, true]; _unit setvariable ["ACE_isUnconscious", nil, true];
if (isPlayer _unit) then { if (isPlayer _unit) then {
[true] call FUNC(setVolume); [true] call FUNC(setVolume);
[false] call FUNC(disableKeyInput); [false] call FUNC(disableKeyInput);
if (["ace_medical"] call FUNC(isModLoader)) then { if (["ace_medical"] call FUNC(isModLoader)) then {
[false] call EFUNC(medical,effectBlackOut); [false] call EFUNC(medical,effectBlackOut);
}; };
if !(isnil QGVAR(DISABLE_USER_INPUT_COLLECTION)) then { if !(isNil QGVAR(DISABLE_USER_INPUT_COLLECTION)) then {
// clear all disable user input // clear all disable user input
{ {
[_x, false] call FUNC(setDisableUserInputStatus); [_x, false] call FUNC(setDisableUserInputStatus);
}foreach GVAR(DISABLE_USER_INPUT_COLLECTION); false
} count GVAR(DISABLE_USER_INPUT_COLLECTION);
}; };
}; };
{ {
if (!(_x select 4)) then { if !(_x select 4) then {
_unit setvariable [(_x select 0),nil,_x select 3]; _unit setvariable [_x select 0, nil, _x select 3];
}; };
} forEach ([_unit] call FUNC(getAllDefinedSetVariables)); false
} count ([_unit] call FUNC(getAllDefinedSetVariables));
_unit setVariable ["ACE_forceWalkStatusNumber", 0, true]; _unit setVariable ["ACE_forceWalkStatusNumber", 0, true];

View File

@ -3,18 +3,19 @@
* *
* Called from respawn eventhandler. Resets all public object namespace variables that are added via FUNC(setVariableJIP). * Called from respawn eventhandler. Resets all public object namespace variables that are added via FUNC(setVariableJIP).
* *
* Argument: * Arguments:
* 0: Object (Object) * 0: Object <OBJECT>
* *
* Return value: * Return Value:
* Nothing. * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit"];
private "_respawnVariables"; private "_respawnVariables";
PARAMS_1(_unit);
_respawnVariables = _unit getVariable ["ACE_respawnVariables", []]; _respawnVariables = _unit getVariable ["ACE_respawnVariables", []];
// yes those // yes those
@ -22,4 +23,6 @@ _respawnVariables pushBack "ACE_PersistentFunctions";
{ {
_unit setVariable [_x, _unit getVariable _x, true]; _unit setVariable [_x, _unit getVariable _x, true];
} forEach _respawnVariables; false
} count _respawnVariables;
nil

View File

@ -1,39 +0,0 @@
/*
* Author: commy2
*
* Revert a key code to a readible text.
*
* Argument:
* 0: Key code (Number)
*
* Return value:
* What input will result in the given key code? (String)
*/
#include "script_component.hpp"
private ["_key", "_alt", "_ctrl", "_shift"];
PARAMS_1(_keyCode);
_key = toString ((toArray keyName floor _keyCode) - [34]);
_keyCode = round ((_keyCode % 1) * 10);
switch (_keyCode) do {
case 8 : {format [localize QUOTE(DOUBLES(STR,GVAR(DoubleTapKey))), _key]};
case 9 : {format [localize QUOTE(DOUBLES(STR,GVAR(HoldKey))), _key]};
default {
_keyCode = toArray ([_keyCode, 3] call FUNC(toBin));
_alt = "1" == toString [_keyCode select 0];
_ctrl = "1" == toString [_keyCode select 1];
_shift = "1" == toString [_keyCode select 2];
format ["%1%2%3%4",
["", format ["%1 + ", localize QUOTE(DOUBLES(STR,GVAR(Alt)))]] select _alt,
["", format ["%1 + ", localize QUOTE(DOUBLES(STR,GVAR(Ctrl)))]] select _ctrl,
["", format ["%1 + ", localize QUOTE(DOUBLES(STR,GVAR(Shift)))]] select _shift,
_key
]
};
};

View File

@ -1,23 +1,22 @@
/* /*
* Author: esteldunedain, based on Killzone-Kid code * Author: esteldunedain, based on Killzone-Kid code
*
* Removes quotation marks to avoid exploits and optionally html tags from text to avoid conflicts with structured text. * Removes quotation marks to avoid exploits and optionally html tags from text to avoid conflicts with structured text.
* *
* Arguments: * Arguments:
* 0: Source string (String) * 0: Source string <STRING>
* 1: Remove html tags (Bool, optional) * 1: Remove html tags (optional) <BOOL>
* *
* Return Value: * Return Value:
* Sanitized string * Sanitized string
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_string", ["_removeTags", false]];
private ["_array", "_arrayNew"]; private ["_array", "_arrayNew"];
PARAMS_2(_string,_removeTags);
if (isNil "_removeTags") then {_removeTags = false};
_array = toArray _string; _array = toArray _string;
_arrayNew = []; _arrayNew = [];
@ -37,6 +36,7 @@ _arrayNew = [];
_arrayNew = _arrayNew + [_x]; _arrayNew = _arrayNew + [_x];
}; };
}; };
} forEach _array; false
} count _array;
toString _arrayNew toString _arrayNew

View File

@ -1,47 +1,53 @@
/** /*
* fn_sendDisplayInformationTo.sqf * Author: Glowbal
* @Descr: Sends a display information hint to a receiver * Sends a display information hint to a receiver
* @Author: Glowbal
* *
* @Arguments: [receiver OBJECT, title STRING, content ARRAY (An array with strings), type NUMBER (Optional)] * Arguments:
* @Return: void * 0: receiver <OBJECT>
* @PublicAPI: true * 1: title <STRING>
* 2: content <ARRAY>
* 3: type (optional) <NUMBER>
*
* Return Value:
* None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_reciever","_title","_content","_type", "_parameters", "_localizationArray"]; params [["_reciever", objNull], ["_title", ""], ["_content", ""], ["_type", 0], ["_parameters", []]];
_reciever = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
_title = [_this, 1, "",[""]] call BIS_fnc_Param;
_content = [_this, 2, [""],[[""]]] call BIS_fnc_Param;
_type = [_this, 3, 0,[0]] call BIS_fnc_Param;
_parameters = [_this, 4, [], [[]]] call BIS_fnc_Param;
if (isPlayer _reciever) then { if (isPlayer _reciever) then {
if (!local _reciever) then { if (!local _reciever) then {
[_this, QUOTE(FUNC(sendDisplayInformationTo)), _reciever, false] call EFUNC(common,execRemoteFnc); [_this, QFUNC(sendDisplayInformationTo), _reciever, false] call FUNC(execRemoteFnc);
} else { } else {
if (isLocalized _title) then { if (isLocalized _title) then {
_title = localize _title; _title = localize _title;
}; };
private "_localizationArray";
_localizationArray = [_title]; _localizationArray = [_title];
{ {
_localizationArray pushback _x; _localizationArray pushback _x;
} forEach _parameters; false
} count _parameters;
_title = format _localizationArray; _title = format _localizationArray;
{ {
if (isLocalized _x) then { if (isLocalized _x) then {
_localizationArray = [localize _x]; _localizationArray = [localize _x];
{ {
_localizationArray pushback _x; _localizationArray pushBack _x;
} forEach _parameters; false
} count _parameters;
_content set [_foreachIndex, format _localizationArray]; _content set [_forEachIndex, format _localizationArray];
}; };
} forEach _content;
}foreach _content; [_title, _content, _type] call FUNC(displayInformation);
[_title,_content,_type] call EFUNC(common,displayInformation);
}; };
}; };

View File

@ -1,46 +1,53 @@
/** /*
* fn_sendDisplayMessageTo.sqf * Author: Glowbal
* @Descr: Displays a message on locality of receiver * Displays a message on locality of receiver
* @Author: Glowbal
* *
* @Arguments: [receiver OBJECT, title STRING, content STRING, type NUMBER (Optional)] * Arguments:
* @Return: void * 0: receiver <OBJECT>
* @PublicAPI: true * 1: title <STRING>
* 2: content <ARRAY>
* 3: type (optional) <NUMBER>
*
* Return Value:
* None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_reciever","_title","_content","_type", "_parameters", "_localizationArray"]; params [["_reciever", objNull], ["_title", ""], ["_content", ""], ["_type", 0], ["_parameters", []]];
_reciever = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
_title = [_this, 1, "",[""]] call BIS_fnc_Param;
_content = [_this, 2, "",[""]] call BIS_fnc_Param;
_type = [_this, 3, 0,[0]] call BIS_fnc_Param;
_parameters = [_this, 4, [], [[]]] call BIS_fnc_Param;
if (isPlayer _reciever) then { if (isPlayer _reciever) then {
if (!local _reciever) then { if (!local _reciever) then {
[_this, QUOTE(FUNC(sendDisplayMessageTo)), _reciever, false] call EFUNC(common,execRemoteFnc); [_this, QFUNC(sendDisplayMessageTo), _reciever, false] call FUNC(execRemoteFnc);
} else { } else {
if (isLocalized _title) then { if (isLocalized _title) then {
_title = localize _title; _title = localize _title;
}; };
if (isLocalized _content) then { if (isLocalized _content) then {
_content = localize _content; _content = localize _content;
}; };
private "_localizationArray";
_localizationArray = [_title]; _localizationArray = [_title];
{ {
_localizationArray pushback _x; _localizationArray pushBack _x;
}foreach _parameters; false
} count _parameters;
_title = format _localizationArray; _title = format _localizationArray;
_localizationArray = [_content]; _localizationArray = [_content];
{ {
_localizationArray pushback _x; _localizationArray pushBack _x;
}foreach _parameters; false
} count _parameters;
_content = format _localizationArray; _content = format _localizationArray;
[_title,_content,_type] call EFUNC(common,displayMessage); [_title, _content, _type] call FUNC(displayMessage);
}; };
}; };

View File

@ -1,20 +1,26 @@
/** /*
* fn_sendRequest_f.sqf * Author: Glowbal
* @Descr: Send a request to an unit and execute code based upon results. * Send a request to an unit and execute code based upon results.
* @Author: Glowbal
* *
* @Arguments: [caller OBJECT, target OBJECT, requestID STRING, requestMessage STRING (Will be localized for other target object), callback CODE (Code called upon accept or decline.)] * Arguments:
* @Return: void * 0: caller <OBJECT>
* @PublicAPI: true * 1: target <OBJECT>
* 2: requestID (STRING)
* 3: requestMessage Will be localized for other target object. (STRING)
* 4: callback Code called upon accept or decline. (CODE)
*
* Return Value:
* None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_5(_caller,_target,_requestID,_requestMessage,_callBack); params ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"];
if (isPlayer _target) then { if (isPlayer _target) then {
// Pass request on to target locality for player accept/decline. // Pass request on to target locality for player accept/decline.
[[_caller, _target, _requestID, _requestMessage, _callBack], QUOTE(FUNC(receiveRequest)), _target, false] call EFUNC(common,execRemoteFnc); [[_caller, _target, _requestID, _requestMessage, _callBack], QFUNC(receiveRequest), _target, false] call FUNC(execRemoteFnc);
} else { } else {
// accept it, since it's an AI. // accept it, since it's an AI.
[_caller, _target, true] call compile _callBack; [_caller, _target, true] call compile _callBack;

View File

@ -1,26 +1,27 @@
/* /*
* Author: Nou * Author: Nou
*
* Execute a event only on the server. * Execute a event only on the server.
* *
* Argument: * Argument:
* 0: Event name (string) * 0: Event name <STRING>
* 1: Event args (any) * 1: Event args <ANY>
* *
* Return value: * Return Value:
* Nothing * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
//IGNORE_PRIVATE_WARNING("_handleNetEvent");
PARAMS_2(_eventName,_eventArgs); params ["_eventName", "_eventArgs"];
#ifdef DEBUG_EVENTS #ifdef DEBUG_EVENTS
ACE_LOGINFO_1("* Server Event: %1",_eventName); ACE_LOGINFO_1("* Server Event: %1",_eventName);
ACE_LOGINFO_1(" args=%1",_eventArgs); ACE_LOGINFO_1(" args=%1",_eventArgs);
#endif #endif
ACEg = [_eventName, _eventArgs]; ACEg = [_eventName, _eventArgs];
if (!isServer) then { if (!isServer) then {
publicVariableServer "ACEg"; publicVariableServer "ACEg";
} else { } else {

View File

@ -1,8 +1,19 @@
// by esteldunedain /*
* Author: esteldunedain
* ?
*
* Arguments:
* ?
*
* Return Value:
* None
*
* Public: no
*/
#include "script_component.hpp" #include "script_component.hpp"
if (isServer) then { if (isServer) then {
diag_log _this; diag_log _this;
} else { } else {
[_this, QUOTE(FUNC(serverLog)), 1] call FUNC(execRemoteFnc); [_this, QFUNC(serverLog), 1] call FUNC(execRemoteFnc);
}; };

View File

@ -1,21 +1,22 @@
/* /*
* Author: commy2 * Author: commy2
*
* Set the captivity status of an unit. This allows the handling of more than one reason to set a unit captive. * Set the captivity status of an unit. This allows the handling of more than one reason to set a unit captive.
* *
* Argument: * Arguments:
* 0: Unit (Object) * 0: Unit <OBJECT>
* 1: The reason of the captivity (String) * 1: The reason of the captivity <STRING>
* 2: Is the reason still valid? True for setting this reason, false for removing it (Bool) * 2: Is the reason still valid? True for setting this reason, false for removing it <BOOL>
* *
* Return value: * Return Value:
* None. * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_captivityReasons", "_unitCaptivityReasons", "_captivityReasonsBooleans", "_bitmask"]; params ["_unit", "_reason", "_status"];
PARAMS_3(_unit,_reason,_status); private ["_captivityReasons", "_unitCaptivityReasons", "_captivityReasonsBooleans", "_bitmask"];
_captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []]; _captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []];

View File

@ -1,31 +1,30 @@
/** /*
* fn_setVariable.sqf * Author: Glowbal
* @Descr: Setvariable value * Setvariable value
* @Author: Glowbal
* *
* @Arguments: [unit OBJECT, variableName STRING, value ANY] * Arguments:
* @Return: void * 0: Unit <OBJECT>
* @PublicAPI: true * 1: variableName <STRING>
* 2: value <ANY>
*
* Return Value:
* None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_global","_definedVariable"]; params ["_unit", "_variable", "_value", "_global"];
PARAMS_3(_unit,_variable,_value); if (isNil "_global") then {
private "_definedVariable";
_definedVariable = [_variable] call FUNC(getDefinedVariableInfo);
_global = false; _definedVariable params ["", "", ["_global", false]];
if (count _this > 3) then {
_global = _this select 3;
} else {
_definedVariable = ([_variable] call FUNC(getDefinedVariableInfo));
if (count _definedVariable > 2) then {
_global = _definedVariable select 2;
};
}; };
if (!isNil "_value") exitwith { if (!isNil "_value") exitwith {
_unit setvariable [_variable, _value, _global]; _unit setVariable [_variable, _value, _global];
}; };
_unit setvariable [_variable, nil, _global];
_unit setVariable [_variable, nil, _global];

View File

@ -1,26 +1,30 @@
/** /*
* fn_setDisableUserInputStatus.sqf * Author: Glowbal
* @Descr: Disables the user input. Works stacked. * Disables the user input. Works stacked.
* @Author: Glowbal
* *
* @Arguments: [id STRING, disable BOOL] * Arguments:
* @Return: void * 0: id <STRING>
* @PublicAPI: true * 1: disable <BOOL>
*
* Return Value:
* None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_id,_disable); params ["_id", "_disable"];
if (isnil QGVAR(DISABLE_USER_INPUT_COLLECTION)) then { if (isNil QGVAR(DISABLE_USER_INPUT_COLLECTION)) then {
GVAR(DISABLE_USER_INPUT_COLLECTION) = []; GVAR(DISABLE_USER_INPUT_COLLECTION) = [];
}; };
if (_disable) then { if (_disable) then {
GVAR(DISABLE_USER_INPUT_COLLECTION) pushback _id; GVAR(DISABLE_USER_INPUT_COLLECTION) pushBack _id;
[true] call FUNC(disableUserInput); [true] call FUNC(disableUserInput);
} else { } else {
GVAR(DISABLE_USER_INPUT_COLLECTION) = GVAR(DISABLE_USER_INPUT_COLLECTION) - [_id]; GVAR(DISABLE_USER_INPUT_COLLECTION) = GVAR(DISABLE_USER_INPUT_COLLECTION) - [_id];
if (GVAR(DISABLE_USER_INPUT_COLLECTION) isEqualTo []) then { if (GVAR(DISABLE_USER_INPUT_COLLECTION) isEqualTo []) then {
[false] call FUNC(disableUserInput); [false] call FUNC(disableUserInput);
}; };
}; };

View File

@ -1,36 +1,34 @@
/* /*
Name: FUNC(setForceWalkStatus) * Author: Pabst Mirror (from captivity by commy2)
* Sets the forceWalk status of an unit. This allows the handling of more than one reason to set forceWalk.
Author: Pabst Mirror (from captivity by commy2) * Unit will force walk until all reasons are removed.
*
Description: * Arguments:
Sets the forceWalk status of an unit. This allows the handling of more than one reason to set forceWalk. * 0: Unit <OBJECT>
Unit will force walk until all reasons are removed. * 1: Reason for forcing walking <STRING>
* 2: Is the reason still valid. True to force walk, false to remove restriction. <BOOL>
Parameters: *
0: OBJECT - Unit * Returns:
1: STRING - Reason for forcing walking * None
2: BOOL - Is the reason still valid. True to force walk, false to remove restriction. *
* Example:
Returns: * [ACE_Player, "BrokenLeg", true] call FUNC(setForceWalkStatus)
None *
* Public: No
Example:
[ACE_Player, "BrokenLeg", true] call FUNC(setForceWalkStatus)
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_forceWalkReasons", "_unitForceWalkReasons", "_forceWalkReasonsBooleans", "_bitmaskNumber"]; params ["_unit", "_reason", "_status"];
PARAMS_3(_unit,_reason,_status); private ["_forceWalkReasons", "_unitForceWalkReasons", "_forceWalkReasonsBooleans", "_bitmaskNumber"];
_forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []];
// register new reason (these reasons are shared publicly, since units can change ownership, but keep their forceWalk status) // register new reason (these reasons are shared publicly, since units can change ownership, but keep their forceWalk status)
if !(_reason in _forceWalkReasons) then { if !(_reason in _forceWalkReasons) then {
_forceWalkReasons pushBack _reason; _forceWalkReasons pushBack _reason;
ACE_forceWalkReasons = _forceWalkReasons; ACE_forceWalkReasons = _forceWalkReasons;
publicVariable "ACE_forceWalkReasons"; publicVariable "ACE_forceWalkReasons";
}; };
// get reasons why the unit is forceWalking already and update to the new status // get reasons why the unit is forceWalking already and update to the new status
@ -38,7 +36,7 @@ _unitForceWalkReasons = [_unit] call FUNC(getForceWalkStatus);
_forceWalkReasonsBooleans = []; _forceWalkReasonsBooleans = [];
{ {
_forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons]; _forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons];
} forEach _forceWalkReasons; } forEach _forceWalkReasons;
_forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status]; _forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status];
@ -48,4 +46,4 @@ _bitmaskNumber = _forceWalkReasonsBooleans call FUNC(toBitmask);
_unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true]; _unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true];
// actually apply the forceWalk command globaly // actually apply the forceWalk command globaly
[[_unit], QUOTE(FUNC(applyForceWalkStatus)), 2] call FUNC(execRemoteFnc); [[_unit], QFUNC(applyForceWalkStatus), 2] call FUNC(execRemoteFnc);

View File

@ -1,23 +1,22 @@
/** /*
* fn_setHearingCapability.sqf * Author: Glowbal
* @Descr: Handle set volume calls. Will use the lowest available volume setting. * Handle set volume calls. Will use the lowest available volume setting.
* @Author: Glowbal
* *
* @Arguments: [id STRING, settings NUMBER, add BOOL (Optional. True will add, false will remove. Default value is true)] * Arguments:
* @Return: nil * 0: id <STRING>
* @PublicAPI: true * 1: settings <NUMBER>
* 2: add (default: true) <BOOL>
*
* Return Value:
* None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_add", "_exists", "_map", "_lowestVolume"]; params ["_id", "_settings", ["_add", true]];
PARAMS_2(_id,_settings); private ["_map", "_exists", "_lowestVolume"];
_add = true;
if (count _this > 2) then {
_add = _this select 2;
};
_map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]]; _map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]];
@ -44,7 +43,8 @@ missionNamespace setVariable [QGVAR(setHearingCapabilityMap), _map];
_lowestVolume = 1; _lowestVolume = 1;
{ {
_lowestVolume = (_x select 1) min _lowestVolume; _lowestVolume = (_x select 1) min _lowestVolume;
} forEach _map; false
} count _map;
// in game sounds // in game sounds
0 fadeSound _lowestVolume; 0 fadeSound _lowestVolume;

View File

@ -4,19 +4,23 @@
* Sets the value of an ACE_Parameter and makes it public. * Sets the value of an ACE_Parameter and makes it public.
* *
* Arguments: * Arguments:
* 0: Parameter name (string) * 0: Parameter name <STRING>
* 1: Value * 1: Value
* *
* Return Value: * Return Value:
* None * None
*
* Public: Yes
*
* Deprecated *@todo commy
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_name,_value); params ["_name", "_value"];
// Hack to keep backward compatibility for the moment // Hack to keep backward compatibility for the moment
if ((typeName (missionNamespace getVariable _name)) == "BOOL") then { if (typeName (missionNamespace getVariable _name) == "BOOL") then {
if ((typeName _value) == "SCALAR") then { if (typeName _value == "SCALAR") then {
_value = _value > 0; _value = _value > 0;
}; };
}; };

View File

@ -1,26 +1,25 @@
/* /*
* Taken From: * Author: Bohemia Interactive edit by KoffeinFlummi
* https://community.bistudio.com/wiki/BIS_fnc_setPitchBank * Sets the value of an ACE_Parameter and makes it public.
* Edited By:
* KoffeinFlummi
* *
* Arguments: * Arguments:
* 0: Unit/Vehicle * 0: Unit/Vehicle <OBJECT>
* 1: Pitch (degrees) * 1: Pitch <NUMBER>
* 2: Yaw (degrees) * 2: Yaw <NUMBER>
* 3: Bank (degrees) * 3: Bank <NUMBER>
* *
* Return Value: * Return Value:
* None * None
*
* Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_object", "_aroundX", "_aroundY", "_aroundZ", "_dirX", "_dirY", "_dirZ", "_upX", "_upY", "_upZ", "_dir", "_up", "_dirXTemp", "_upXTemp"]; params ["_object", "_aroundX", "_aroundY", "_aroundZ"];
_object = _this select 0; _aroundZ = - _aroundZ;
_aroundX = _this select 1;
_aroundY = _this select 2; private ["_dirX", "_dirY", "_dirZ", "_upX", "_upY", "_upZ", "_dir", "_up"];
_aroundZ = (360 - (_this select 3)) - 360;
_dirX = 0; _dirX = 0;
_dirY = 1; _dirY = 1;
@ -28,28 +27,34 @@ _dirZ = 0;
_upX = 0; _upX = 0;
_upY = 0; _upY = 0;
_upZ = 1; _upZ = 1;
if (_aroundX != 0) then { if (_aroundX != 0) then {
_dirY = cos _aroundX; _dirY = cos _aroundX;
_dirZ = sin _aroundX; _dirZ = sin _aroundX;
_upY = -sin _aroundX; _upY = -sin _aroundX;
_upZ = cos _aroundX; _upZ = cos _aroundX;
};
if (_aroundY != 0) then {
_dirX = _dirZ * sin _aroundY;
_dirZ = _dirZ * cos _aroundY;
_upX = _upZ * sin _aroundY;
_upZ = _upZ * cos _aroundY;
};
if (_aroundZ != 0) then {
_dirXTemp = _dirX;
_dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ);
_dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);
_upXTemp = _upX;
_upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ);
_upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ);
}; };
_dir = [_dirX,_dirY,_dirZ]; if (_aroundY != 0) then {
_up = [_upX,_upY,_upZ]; _dirX = _dirZ * sin _aroundY;
_dirZ = _dirZ * cos _aroundY;
_upX = _upZ * sin _aroundY;
_upZ = _upZ * cos _aroundY;
};
if (_aroundZ != 0) then {
private ["_dirXTemp", "_upXTemp"];
_dirXTemp = _dirX;
_dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ);
_dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);
_upXTemp = _upX;
_upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ);
_upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ);
};
_dir = [_dirX, _dirY, _dirZ];
_up = [_upX, _upY, _upZ];
_object setVectorDirAndUp [_dir,_up]; _object setVectorDirAndUp [_dir,_up];