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(codeToLetter);
PREP(codeToString);
PREP(convertKeyCode);
PREP(createOrthonormalReference);
PREP(currentChannel);
PREP(debug);
@ -151,7 +150,6 @@ PREP(removeSpecificMagazine);
PREP(requestCallback);
PREP(resetAllDefaults);
PREP(restoreVariablesJIP);
PREP(revertKeyCodeLocalized);
PREP(runAfterSettingsInit);
PREP(sanitizeString);
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
*
* Remove a map marker creation event handler.
*
* Argument:
* 0: ID of the event handler (Number)
* Arguments:
* 0: ID of the event handler <NUMBER>
*
* Return value:
* None.
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_actionsVar", "_currentId", "_actionIDs", "_actions"];
PARAMS_1(_id);
params ["_id"];
private "_actionsVar";
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_MapMarker", [-1, [], []]];
_currentId = _actionsVar select 0;
_actionIDs = _actionsVar select 1;
_actions = _actionsVar select 2;
_actionsVar params ["_currentId", "_actionIDs", "_actions"];
_id = _actionIDs find _id;

View File

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

View File

@ -2,68 +2,77 @@
* Author: esteldunedain
* Removes a magazine from the unit that has an specific ammo count
*
* Argument:
* 0: Player <OBJECT>
* Arguments:
* 0: Unit <OBJECT>
* 1: Magazine <STRING>
* 2: Ammo count <NUMBER>
*
* Return value:
* Return Value:
* None
*
* Public: No
*/
#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;
// Check uniform
_magazines = [magazinesAmmoCargo uniformContainer _player, {_this select 0 == _magazineType}] call FUNC(filter);
_index = _magazines find [_magazineType,_ammoCount];
_magazines = [magazinesAmmoCargo uniformContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
_index = _magazines find [_magazineType, _ammoCount];
if (_index > -1) exitWith {
{
_player removeItemFromUniform (_x select 0);
} forEach _magazines;
_unit removeItemFromUniform (_x select 0);
false
} count _magazines;
{
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
_isRemoved = true;
} 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
_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];
if (_index > -1) exitWith {
{
_player removeItemFromVest (_x select 0);
} forEach _magazines;
_unit removeItemFromVest (_x select 0);
false
} count _magazines;
{
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
_isRemoved = true;
} 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
_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];
if (_index > -1) exitWith {
{
_player removeItemFromBackpack (_x select 0);
} forEach _magazines;
_unit removeItemFromBackpack (_x select 0);
false
} count _magazines;
{
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
_isRemoved = true;
} 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
*
* Remove a synced event handler
*
* Argument:
* 0: Name (String)
* Arguments:
* 0: Name <STRING>
*
* Return value:
* Return Value:
* Boolean of success
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_name);
private ["_data", "_eventId"];
params ["_name"];
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
ACE_LOGERROR("Synced event key not found.");
false
};
private ["_data", "_eventId"];
_data = HASH_GET(GVAR(syncedEvents),_name);
_eventId = _data select 3;
[_eventId] call ace_common_fnc_removeEventHandler;
[_eventId] call FUNC(removeEventHandler);
HASH_REM(GVAR(syncedEvents),_name);

View File

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

View File

@ -1,19 +1,20 @@
/*
* Author: jaynus
*
* Send a request to synchronize an event name from the client->server. Execute on client only.
*
* Argument:
* 0: eventName (String)
* Arguments:
* 0: eventName <STRING>
*
* Return value:
* Return Value:
* Boolean of success
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_1(_eventName);
params ["_eventName"];
// 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
* @Descr: reset all variables that have been defined
* @Author: Glowbal
/*
* Author: Glowbal
* reset all variables that have been defined
*
* @Arguments: []
* @Return:
* @PublicAPI: false
* Arguments:
* ?
*
* Return Value:
* ?
*
* Public: No
*/
#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];
if (isPlayer _unit) then {
[true] call FUNC(setVolume);
[false] call FUNC(disableKeyInput);
if (["ace_medical"] call FUNC(isModLoader)) then {
[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
{
[_x, false] call FUNC(setDisableUserInputStatus);
}foreach GVAR(DISABLE_USER_INPUT_COLLECTION);
false
} count GVAR(DISABLE_USER_INPUT_COLLECTION);
};
};
{
if (!(_x select 4)) then {
_unit setvariable [(_x select 0),nil,_x select 3];
if !(_x select 4) then {
_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];

View File

@ -3,18 +3,19 @@
*
* Called from respawn eventhandler. Resets all public object namespace variables that are added via FUNC(setVariableJIP).
*
* Argument:
* 0: Object (Object)
* Arguments:
* 0: Object <OBJECT>
*
* Return value:
* Nothing.
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
private "_respawnVariables";
PARAMS_1(_unit);
_respawnVariables = _unit getVariable ["ACE_respawnVariables", []];
// yes those
@ -22,4 +23,6 @@ _respawnVariables pushBack "ACE_PersistentFunctions";
{
_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
*
* Removes quotation marks to avoid exploits and optionally html tags from text to avoid conflicts with structured text.
*
* Arguments:
* 0: Source string (String)
* 1: Remove html tags (Bool, optional)
* 0: Source string <STRING>
* 1: Remove html tags (optional) <BOOL>
*
* Return Value:
* Sanitized string
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_string", ["_removeTags", false]];
private ["_array", "_arrayNew"];
PARAMS_2(_string,_removeTags);
if (isNil "_removeTags") then {_removeTags = false};
_array = toArray _string;
_arrayNew = [];
@ -37,6 +36,7 @@ _arrayNew = [];
_arrayNew = _arrayNew + [_x];
};
};
} forEach _array;
false
} count _array;
toString _arrayNew

View File

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

View File

@ -1,46 +1,53 @@
/**
* fn_sendDisplayMessageTo.sqf
* @Descr: Displays a message on locality of receiver
* @Author: Glowbal
/*
* Author: Glowbal
* Displays a message on locality of receiver
*
* @Arguments: [receiver OBJECT, title STRING, content STRING, type NUMBER (Optional)]
* @Return: void
* @PublicAPI: true
* Arguments:
* 0: receiver <OBJECT>
* 1: title <STRING>
* 2: content <ARRAY>
* 3: type (optional) <NUMBER>
*
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_reciever","_title","_content","_type", "_parameters", "_localizationArray"];
_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;
params [["_reciever", objNull], ["_title", ""], ["_content", ""], ["_type", 0], ["_parameters", []]];
if (isPlayer _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 {
if (isLocalized _title) then {
_title = localize _title;
};
if (isLocalized _content) then {
_content = localize _content;
};
private "_localizationArray";
_localizationArray = [_title];
{
_localizationArray pushback _x;
}foreach _parameters;
_localizationArray pushBack _x;
false
} count _parameters;
_title = format _localizationArray;
_localizationArray = [_content];
{
_localizationArray pushback _x;
}foreach _parameters;
_localizationArray pushBack _x;
false
} count _parameters;
_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
* @Descr: Send a request to an unit and execute code based upon results.
* @Author: Glowbal
/*
* Author: Glowbal
* Send a request to an unit and execute code based upon results.
*
* @Arguments: [caller OBJECT, target OBJECT, requestID STRING, requestMessage STRING (Will be localized for other target object), callback CODE (Code called upon accept or decline.)]
* @Return: void
* @PublicAPI: true
* Arguments:
* 0: caller <OBJECT>
* 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"
PARAMS_5(_caller,_target,_requestID,_requestMessage,_callBack);
params ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"];
if (isPlayer _target) then {
// 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 {
// accept it, since it's an AI.
[_caller, _target, true] call compile _callBack;

View File

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

View File

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

View File

@ -1,21 +1,22 @@
/*
* Author: commy2
*
* Set the captivity status of an unit. This allows the handling of more than one reason to set a unit captive.
*
* Argument:
* 0: Unit (Object)
* 1: The reason of the captivity (String)
* 2: Is the reason still valid? True for setting this reason, false for removing it (Bool)
* Arguments:
* 0: Unit <OBJECT>
* 1: The reason of the captivity <STRING>
* 2: Is the reason still valid? True for setting this reason, false for removing it <BOOL>
*
* Return value:
* None.
* Return Value:
* None
*
* Public: No
*/
#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", []];

View File

@ -1,31 +1,30 @@
/**
* fn_setVariable.sqf
* @Descr: Setvariable value
* @Author: Glowbal
/*
* Author: Glowbal
* Setvariable value
*
* @Arguments: [unit OBJECT, variableName STRING, value ANY]
* @Return: void
* @PublicAPI: true
* Arguments:
* 0: Unit <OBJECT>
* 1: variableName <STRING>
* 2: value <ANY>
*
* Return Value:
* None
*
* Public: Yes
*/
#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;
if (count _this > 3) then {
_global = _this select 3;
} else {
_definedVariable = ([_variable] call FUNC(getDefinedVariableInfo));
if (count _definedVariable > 2) then {
_global = _definedVariable select 2;
};
_definedVariable params ["", "", ["_global", false]];
};
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
* @Descr: Disables the user input. Works stacked.
* @Author: Glowbal
/*
* Author: Glowbal
* Disables the user input. Works stacked.
*
* @Arguments: [id STRING, disable BOOL]
* @Return: void
* @PublicAPI: true
* Arguments:
* 0: id <STRING>
* 1: disable <BOOL>
*
* Return Value:
* None
*
* Public: Yes
*/
#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) = [];
};
if (_disable) then {
GVAR(DISABLE_USER_INPUT_COLLECTION) pushback _id;
GVAR(DISABLE_USER_INPUT_COLLECTION) pushBack _id;
[true] call FUNC(disableUserInput);
} else {
GVAR(DISABLE_USER_INPUT_COLLECTION) = GVAR(DISABLE_USER_INPUT_COLLECTION) - [_id];
if (GVAR(DISABLE_USER_INPUT_COLLECTION) isEqualTo []) then {
[false] call FUNC(disableUserInput);
};
};
};

View File

@ -1,36 +1,34 @@
/*
Name: FUNC(setForceWalkStatus)
Author: Pabst Mirror (from captivity by commy2)
Description:
Sets the forceWalk status of an unit. This allows the handling of more than one reason to set forceWalk.
Unit will force walk until all reasons are removed.
Parameters:
0: OBJECT - Unit
1: STRING - Reason for forcing walking
2: BOOL - Is the reason still valid. True to force walk, false to remove restriction.
Returns:
None
Example:
[ACE_Player, "BrokenLeg", true] call 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.
* Unit will force walk until all reasons are removed.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Reason for forcing walking <STRING>
* 2: Is the reason still valid. True to force walk, false to remove restriction. <BOOL>
*
* Returns:
* None
*
* Example:
* [ACE_Player, "BrokenLeg", true] call FUNC(setForceWalkStatus)
*
* Public: No
*/
#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", []];
// register new reason (these reasons are shared publicly, since units can change ownership, but keep their forceWalk status)
if !(_reason in _forceWalkReasons) then {
_forceWalkReasons pushBack _reason;
ACE_forceWalkReasons = _forceWalkReasons;
publicVariable "ACE_forceWalkReasons";
_forceWalkReasons pushBack _reason;
ACE_forceWalkReasons = _forceWalkReasons;
publicVariable "ACE_forceWalkReasons";
};
// 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 set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons];
_forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons];
} forEach _forceWalkReasons;
_forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status];
@ -48,4 +46,4 @@ _bitmaskNumber = _forceWalkReasonsBooleans call FUNC(toBitmask);
_unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true];
// 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
* @Descr: Handle set volume calls. Will use the lowest available volume setting.
* @Author: Glowbal
/*
* Author: Glowbal
* Handle set volume calls. Will use the lowest available volume setting.
*
* @Arguments: [id STRING, settings NUMBER, add BOOL (Optional. True will add, false will remove. Default value is true)]
* @Return: nil
* @PublicAPI: true
* Arguments:
* 0: id <STRING>
* 1: settings <NUMBER>
* 2: add (default: true) <BOOL>
*
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_add", "_exists", "_map", "_lowestVolume"];
params ["_id", "_settings", ["_add", true]];
PARAMS_2(_id,_settings);
_add = true;
if (count _this > 2) then {
_add = _this select 2;
};
private ["_map", "_exists", "_lowestVolume"];
_map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]];
@ -44,7 +43,8 @@ missionNamespace setVariable [QGVAR(setHearingCapabilityMap), _map];
_lowestVolume = 1;
{
_lowestVolume = (_x select 1) min _lowestVolume;
} forEach _map;
false
} count _map;
// in game sounds
0 fadeSound _lowestVolume;

View File

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

View File

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