mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2497 from acemod/commoncleanup2
common code cleanup part 2
This commit is contained in:
commit
dee025bbea
@ -1,20 +1,29 @@
|
||||
//fnc__handleNetEvent.sqf
|
||||
// internal handler for net events
|
||||
/*
|
||||
* Author: jaynus
|
||||
* Internal net event handler.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_eventName", "_eventArgs", "_eventNames", "_eventIndex", "_eventTargets", "_sentEvents", "_owner", "_serverFlagged", "_events"];
|
||||
//IGNORE_PRIVATE_WARNING("_handleNetEvent");
|
||||
|
||||
|
||||
PARAMS_2(_eventType,_event);
|
||||
params ["_eventType", "_event"];
|
||||
|
||||
if (_eventType == "ACEg") then {
|
||||
_eventName = _event select 0;
|
||||
_eventArgs = _event select 1;
|
||||
_event params ["_eventName", "_eventArgs"];
|
||||
|
||||
private ["_eventNames", "_eventIndex"];
|
||||
|
||||
_eventNames = GVAR(events) select 0;
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
|
||||
if (_eventIndex != -1) then {
|
||||
private "_events";
|
||||
_events = (GVAR(events) select 1) select _eventIndex;
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
@ -35,9 +44,9 @@ if (_eventType == "ACEg") then {
|
||||
|
||||
if (_eventType == "ACEc") then {
|
||||
if (isServer) then {
|
||||
_eventName = _event select 0;
|
||||
_eventTargets = _event select 1;
|
||||
_eventArgs = _event select 2;
|
||||
_event params ["_eventName", "_eventTargets", "_eventArgs"];
|
||||
|
||||
private ["_sentEvents", "_owner", "_serverFlagged"];
|
||||
|
||||
_sentEvents = [];
|
||||
if (!IS_ARRAY(_eventTargets)) then {
|
||||
@ -45,20 +54,21 @@ if (_eventType == "ACEc") then {
|
||||
};
|
||||
|
||||
//If not multiplayer, and there are targets, then just run localy
|
||||
if ((!isMultiplayer) && {(count _eventTargets) > 0}) exitWith {
|
||||
ACEg = [_eventName, _eventArgs];
|
||||
["ACEg", ACEg] call FUNC(_handleNetEvent);
|
||||
if (!isMultiplayer && {count _eventTargets > 0}) exitWith {
|
||||
ACEg = [_eventName, _eventArgs];
|
||||
["ACEg", ACEg] call FUNC(_handleNetEvent);
|
||||
};
|
||||
|
||||
_serverFlagged = false;
|
||||
{
|
||||
_owner = _x;
|
||||
if (IS_OBJECT(_x)) then {
|
||||
_owner = owner _x;
|
||||
_owner = owner _x;
|
||||
};
|
||||
if (!(_owner in _sentEvents)) then {
|
||||
PUSH(_sentEvents, _owner);
|
||||
if !(_owner in _sentEvents) then {
|
||||
_sentEvents pushBack _owner;
|
||||
ACEg = [_eventName, _eventArgs];
|
||||
|
||||
if (isDedicated || {_x != ACE_player}) then {
|
||||
if (isDedicated && {local _x} && {!_serverFlagged}) then {
|
||||
_serverFlagged = true;
|
||||
|
@ -1,25 +1,26 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Handles a server-side request for synchronization ALL events on JIP to a client.
|
||||
*
|
||||
* Argument:
|
||||
* 0: client (object)
|
||||
*
|
||||
* Return value:
|
||||
* Boolean of success
|
||||
* Arguments:
|
||||
* 0: client <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Event is successed <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
PARAMS_1(_client);
|
||||
|
||||
params ["_client"];
|
||||
|
||||
{
|
||||
private["_eventName", "_eventEntry", "_eventLog"];
|
||||
_eventName = _x;
|
||||
_eventEntry = HASH_GET(GVAR(syncedEvents),_eventName);
|
||||
private ["_eventEntry", "_eventLog"];
|
||||
|
||||
_eventEntry = HASH_GET(GVAR(syncedEvents),_x);
|
||||
_eventLog = _eventEntry select 1;
|
||||
|
||||
["SEH_s", _client, [_eventName, _eventLog] ] call FUNC(targetEvent);
|
||||
["SEH_s", _client, [_x, _eventLog]] call FUNC(targetEvent);
|
||||
} forEach (GVAR(syncedEvents) select 0);
|
||||
|
||||
true
|
||||
true
|
||||
|
@ -1,47 +1,48 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Receives either requests for synchronization from clients, or the synchronization data from the server.
|
||||
*
|
||||
* Arguments [Client] :
|
||||
* 0: eventName (String)
|
||||
* 1: eventLog (Array)
|
||||
* 0: eventName <STRING>
|
||||
* 1: eventLog <ARRAY>
|
||||
*
|
||||
* Arguments [Server] :
|
||||
* 0: eventName (String)
|
||||
* 1: client (Object)
|
||||
* 0: eventName <STRING>
|
||||
* 1: client <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Boolean of success
|
||||
* Return Value:
|
||||
* Event is successed <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
//IGNORE_PRIVATE_WARNING("_handleSyncedEvent");
|
||||
|
||||
//SEH_s
|
||||
if(isServer) then {
|
||||
if (isServer) then {
|
||||
// Find the event name, and shovel out the events to the client
|
||||
PARAMS_2(_eventName,_client);
|
||||
private["_eventEntry", "_eventLog"];
|
||||
params ["_eventName", "_client"];
|
||||
|
||||
if(!HASH_HASKEY(GVAR(syncedEvents),_eventName)) exitWith {
|
||||
if (!HASH_HASKEY(GVAR(syncedEvents),_eventName)) exitWith {
|
||||
ACE_LOGERROR("Request for synced event - key not found.");
|
||||
false
|
||||
};
|
||||
|
||||
private ["_eventEntry", "_eventLog"];
|
||||
|
||||
_eventEntry = HASH_GET(GVAR(syncedEvents),_eventName);
|
||||
_eventLog = _eventEntry select 1;
|
||||
|
||||
["SEH_s", _client, [_eventName, _eventLog] ] call FUNC(targetEvent);
|
||||
["SEH_s", _client, [_eventName, _eventLog]] call FUNC(targetEvent);
|
||||
} else {
|
||||
PARAMS_2(_eventName,_eventLog);
|
||||
private ["_eventArgs"];
|
||||
params ["_eventName", "_eventLog"];
|
||||
|
||||
// This is the client handling the response from the server
|
||||
// Start running the events
|
||||
{
|
||||
_eventArgs = _x select 1;
|
||||
[_eventName, _eventArgs, (_x select 2)] call FUNC(_handleSyncedEvent);
|
||||
_x params ["", "_eventArgs","_ttl"];
|
||||
[_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent);
|
||||
} forEach _eventLog;
|
||||
|
||||
ACE_LOGINFO_1("[%1] synchronized",_eventName);
|
||||
};
|
||||
|
||||
|
@ -1,32 +1,36 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Handles synced events being received. Server will log them, and server/client will execute them.
|
||||
*
|
||||
* Arguments [Client] :
|
||||
* 0: eventName (String)
|
||||
* 1: arguments (Array)
|
||||
* 2: ttl (Scalar)
|
||||
* 0: eventName <STRING>
|
||||
* 1: arguments <ARRAY>
|
||||
* 2: ttl <SCALAR>
|
||||
*
|
||||
* Return value:
|
||||
* Boolean of success
|
||||
* Return Value:
|
||||
* Boolean of success <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
PARAMS_3(_name,_args,_ttl);
|
||||
private["_internalData", "_eventLog", "_eventCode"];
|
||||
|
||||
if(!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
params ["_name", "_args", "_ttl"];
|
||||
|
||||
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
ACE_LOGERROR("Synced event key not found.");
|
||||
false
|
||||
};
|
||||
|
||||
private ["_internalData", "_eventCode"];
|
||||
|
||||
_internalData = HASH_GET(GVAR(syncedEvents),_name);
|
||||
|
||||
if(isServer) then {
|
||||
if (isServer) then {
|
||||
// Server needs to internally log it for synchronization
|
||||
if(_ttl > -1) then {
|
||||
if (_ttl > -1) then {
|
||||
_internalData = HASH_GET(GVAR(syncedEvents),_name);
|
||||
|
||||
private "_eventLog";
|
||||
_eventLog = _internalData select 1;
|
||||
_eventLog pushback [ACE_diagTime, _args, _ttl];
|
||||
};
|
||||
|
@ -1,73 +1,64 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Add an addAction event to a unit. Used to handle multiple addAction events. Global arguments, local effects. Does only work for player controlled units.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit the action should be assigned to (Object)
|
||||
* 1: Name of the action, e.g. "DefaultAction" (String)
|
||||
* 2: Condition (Code or String)
|
||||
* 3: Code to execute (Code or String)
|
||||
* Arguments:
|
||||
* 0: Unit the action should be assigned to <OBJECT>
|
||||
* 1: Name of the action, e.g. "DefaultAction" <STRING>
|
||||
* 2: Condition <CODE, STRING>
|
||||
* 3: Code to execute <CODE, STRING>
|
||||
*
|
||||
* Return value:
|
||||
* ID of the action (used to remove it later).
|
||||
* Return Value:
|
||||
* ID of the action (used to remove it later) <NUMBER>
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_action", "_condition", "_statement", "_name", "_actionsVar", "_actionID", "_actions", "_id", "_actionIDs"];
|
||||
//IGNORE_PRIVATE_WARNING("_count", "_index", "_return", "_target");
|
||||
|
||||
_unit = _this select 0;
|
||||
_action = _this select 1;
|
||||
_condition = _this select 2;
|
||||
_statement = _this select 3;
|
||||
params ["_unit", "_action", "_condition", "_statement"];
|
||||
|
||||
if (typeName _condition == "STRING") then {
|
||||
_condition = compile _condition;
|
||||
_condition = compile _condition;
|
||||
};
|
||||
|
||||
if (typeName _statement == "STRING") then {
|
||||
_statement = compile _statement;
|
||||
_statement = compile _statement;
|
||||
};
|
||||
|
||||
_name = format ["ACE_Action_%1", _action];
|
||||
private ["_name", "_actionsVar"];
|
||||
|
||||
_name = format ["ACE_Action_%1", _action];
|
||||
_actionsVar = _unit getVariable [_name, [-1, [-1, [], []], objNull]];
|
||||
|
||||
if (_unit != _actionsVar select 2) then { // check if the unit is still valid, fixes respawn issues
|
||||
_actionsVar = [-1, [-1, [], []], objNull];
|
||||
_actionsVar = [-1, [-1, [], []], objNull];
|
||||
};
|
||||
|
||||
_actionID = _actionsVar select 0;
|
||||
_actions = _actionsVar select 1;
|
||||
_actionsVar params ["_actionID", "_actionsArray"];
|
||||
_actionsArray params ["_id", "_actionIDs", "_actions"];
|
||||
|
||||
_id = (_actions select 0) + 1;
|
||||
_actionIDs = _actions select 1;
|
||||
_actions = _actions select 2;
|
||||
_id = _id + 1;
|
||||
|
||||
_actionIDs pushBack _id;
|
||||
_actions pushBack [_condition, _statement];
|
||||
|
||||
// first action to add, unit needs addAction command
|
||||
if (_actionID == -1) then {
|
||||
private "_addAction";
|
||||
private "_addAction";
|
||||
_addAction = call compile format [
|
||||
"[
|
||||
'',
|
||||
{if (inputAction '%1' == 0) exitWith {}; {if (_this call (_x select 0)) then {_this call (_x select 1)}} forEach (((_this select 0) getVariable '%2') select 1 select 2)},
|
||||
nil,
|
||||
-1,
|
||||
false,
|
||||
true,
|
||||
'%1',
|
||||
""if (_this != ACE_player || {vehicle _this != _target}) exitWith {false}; _actions = (_this getVariable '%2') select 1 select 2; _count = count _actions; _index = 0; _return = false; while {_index < _count && {!_return}} do {_return = [_target, _this] call ((_actions select _index) select 0); _index = _index + 1}; _return""
|
||||
]",
|
||||
_action,
|
||||
_name
|
||||
];
|
||||
|
||||
_addAction = call compile format [
|
||||
"[
|
||||
'',
|
||||
{if (inputAction '%1' == 0) exitWith {}; {if (_this call (_x select 0)) then {_this call (_x select 1)}} forEach (((_this select 0) getVariable '%2') select 1 select 2)},
|
||||
nil,
|
||||
-1,
|
||||
false,
|
||||
true,
|
||||
'%1',
|
||||
""if (_this != ACE_player || {vehicle _this != _target}) exitWith {false}; _actions = (_this getVariable '%2') select 1 select 2; _count = count _actions; _index = 0; _return = false; while {_index < _count && {!_return}} do {_return = [_target, _this] call ((_actions select _index) select 0); _index = _index + 1}; _return""
|
||||
]",
|
||||
_action,
|
||||
_name
|
||||
];
|
||||
|
||||
_actionID = _unit addAction _addAction;
|
||||
_actionID = _unit addAction _addAction;
|
||||
};
|
||||
|
||||
_unit setVariable [_name, [_actionID, [_id, _actionIDs, _actions], _unit], false];
|
||||
|
@ -1,29 +1,25 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Add an addAction event to a unit. Used to handle multiple addAction events and add a action to the mouse wheel menu. Global arguments, local effects. Does only work for player controlled units.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit the action should be assigned to (Object)
|
||||
* 1: Menu title of the action (String)
|
||||
* 2: Name of the action, e.g. "DefaultAction" (String)
|
||||
* 3: Condition (Code or String)
|
||||
* 4: Code to execute by the action (Code or String)
|
||||
* 5: Condition for the menu action (Code or String)
|
||||
* 6: Code to execute from the menu (Code or String)
|
||||
* 7: Priority of the action (Number, optional default: 0)
|
||||
* Arguments:
|
||||
* 0: Unit the action should be assigned to <OBJECT>
|
||||
* 1: Menu title of the action <STRING>
|
||||
* 2: Name of the action, e.g. "DefaultAction" <STRING>
|
||||
* 3: Condition <CODE, STRING>
|
||||
* 4: Code to execute by the action <CODE, STRING>
|
||||
* 5: Condition for the menu action <CODE, STRING>
|
||||
* 6: Code to execute from the menu <CODE, STRING>
|
||||
* 7: Priority of the action (default: 0) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* ID of the action (used to remove it later).
|
||||
* Return Value:
|
||||
* ID of the action (used to remove it later) <NUMBER>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_name", "_actionsVar", "_id", "_actionIDs", "_actions", "_nameVar", "_addAction", "_actionID"];
|
||||
//IGNORE_PRIVATE_WARNING("_target");
|
||||
|
||||
PARAMS_8(_unit,_displayName,_action,_condition,_statement,_condition2,_statement2,_priority);
|
||||
|
||||
if (isNil "_priority") then {_priority = 0};
|
||||
params ["_unit", "_displayName", "_action", "_condition", "_statement", "_condition2", "_statement2", ["_priority", 0]];
|
||||
|
||||
if (typeName _condition == "STRING") then {
|
||||
_condition = compile _condition;
|
||||
@ -41,13 +37,16 @@ if (typeName _statement2 == "STRING") then {
|
||||
_statement2 = compile _statement2;
|
||||
};
|
||||
|
||||
_name = format ["ACE_ActionMenu_%1", _action];
|
||||
private ["_name", "_actionsVar"];
|
||||
|
||||
_name = format ["ACE_ActionMenu_%1", _action];
|
||||
_actionsVar = _unit getVariable [_name, [-1, [], []]];
|
||||
|
||||
_id = (_actionsVar select 0) + 1;
|
||||
_actionIDs = _actionsVar select 1;
|
||||
_actions = _actionsVar select 2;
|
||||
_actionsVar params ["_id", "_actionIDs", "_actions"];
|
||||
|
||||
_id = _id + 1;
|
||||
|
||||
private ["_nameVar", "_addAction", "_actionID"];
|
||||
|
||||
_nameVar = format ["%1_ID%2", _name, _id];
|
||||
missionNamespace setVariable [_nameVar, [_condition, _statement, _condition2, _statement2]];
|
||||
@ -56,14 +55,14 @@ _actionIDs pushBack _id;
|
||||
|
||||
_addAction = call compile format [
|
||||
"[
|
||||
'%2',
|
||||
{if (inputAction '%1' == 0) then {if (_this call (%3 select 2)) then {_this call (%3 select 3)}} else {_this call (%3 select 1)}},
|
||||
nil,
|
||||
%4,
|
||||
false,
|
||||
true,
|
||||
'%1',
|
||||
""if (_this != ACE_player || {vehicle _this != _target}) exitWith {false}; [_target, _this] call (%3 select 0)""
|
||||
'%2',
|
||||
{if (inputAction '%1' == 0) then {if (_this call (%3 select 2)) then {_this call (%3 select 3)}} else {_this call (%3 select 1)}},
|
||||
nil,
|
||||
%4,
|
||||
false,
|
||||
true,
|
||||
'%1',
|
||||
""if (_this != ACE_player || {vehicle _this != _target}) exitWith {false}; [_target, _this] call (%3 select 0)""
|
||||
]",
|
||||
_action,
|
||||
_displayName,
|
||||
|
@ -1,31 +1,25 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Add a condition that gets checked by ace_common_fnc_canInteractWith.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The conditions id. Used to remove later or as exception name. An already existing name overwrites. (String)
|
||||
* 1: The condition to check. format of "_this" is "[_player, _target]". (Code)
|
||||
* 0: The conditions id. Used to remove later or as exception name. An already existing name overwrites. <STRING>
|
||||
* 1: The condition to check. format of "_this" is "[_player, _target]". <CODE>
|
||||
*
|
||||
* Return Value:
|
||||
* Unit can interact?
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_conditionName", "_conditionFunc"];
|
||||
//IGNORE_PRIVATE_WARNING("_player", "_target");
|
||||
params ["_conditionName", "_conditionFunc"];
|
||||
|
||||
_conditionName = toLower _conditionName;
|
||||
|
||||
_conditionName = toLower (_this select 0);
|
||||
_conditionFunc = _this select 1;
|
||||
|
||||
private ["_conditions", "_conditionNames", "_conditionFuncs"];
|
||||
|
||||
private "_conditions";
|
||||
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
||||
|
||||
_conditionNames = _conditions select 0;
|
||||
_conditionFuncs = _conditions select 1;
|
||||
_conditions params ["_conditionNames", "_conditionFuncs"];
|
||||
|
||||
private "_index";
|
||||
_index = _conditionNames find _conditionName;
|
||||
@ -37,4 +31,4 @@ if (_index == -1) then {
|
||||
_conditionNames set [_index, _conditionName];
|
||||
_conditionFuncs set [_index, _conditionFunc];
|
||||
|
||||
GVAR(InteractionConditions) = [_conditionNames, _conditionFuncs];
|
||||
GVAR(InteractionConditions) = _conditions;
|
||||
|
@ -1,9 +1,19 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Arguments:
|
||||
* Display where the Unload event was added <DISPLAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_dlg";
|
||||
|
||||
disableSerialization;
|
||||
|
||||
private "_dlg";
|
||||
_dlg = ctrlParent _this;
|
||||
|
||||
_dlg displayAddEventHandler ["unload", {
|
||||
|
@ -1,33 +1,34 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
* Add an event handler.
|
||||
*
|
||||
* Add a event handler.
|
||||
* Arguments:
|
||||
* 0: Event name <STRING>
|
||||
* 1: Event code <CODE>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Event name (string)
|
||||
* 1: Event code (code)
|
||||
* Return Value:
|
||||
* Event handler ID number (for use with fnc_removeEventHandler) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Event handler ID number (for use with fnc_removeEventHandler)
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_eventNames", "_eventFunctions", "_eventNameCount", "_eventIndex", "_eventFunctionCount"];
|
||||
params ["_eventName", "_eventCode"];
|
||||
|
||||
PARAMS_2(_eventName,_eventCode);
|
||||
private ["_eventNames", "_eventFunctions", "_eventIndex"];
|
||||
|
||||
_eventNames = GVAR(events) select 0;
|
||||
_eventFunctions = [];
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
|
||||
if (_eventIndex != -1) then {
|
||||
_eventFunctions = (GVAR(events) select 1) select _eventIndex;
|
||||
} else {
|
||||
private "_eventNameCount";
|
||||
_eventNameCount = count _eventNames;
|
||||
_eventNames set[_eventNameCount, _eventName];
|
||||
(GVAR(events) select 1) set[_eventNameCount, _eventFunctions];
|
||||
|
||||
_eventNames set [_eventNameCount, _eventName];
|
||||
(GVAR(events) select 1) set [_eventNameCount, _eventFunctions];
|
||||
};
|
||||
|
||||
_eventFunctionCount = count _eventFunctions;
|
||||
_eventFunctions set [_eventFunctionCount, _eventCode];
|
||||
|
||||
_eventFunctionCount;
|
||||
_eventFunctions pushBack _eventCode // Return event function count
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
*
|
||||
* Add line to draw on debug
|
||||
*
|
||||
* Argument:
|
||||
* 0: Start point ASL (Array)
|
||||
* 1: End point ASL (Array)
|
||||
* 2: Color (Array)
|
||||
* Arguments:
|
||||
* 0: Start point ASL <ARRAY>
|
||||
* 1: End point ASL <ARRAY>
|
||||
* 2: Color <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
@ -45,4 +45,4 @@ if (isNil QGVAR(debugDrawHandler)) then {
|
||||
drawLine3D [_p0, _p1, _x select 2];
|
||||
} forEach GVAR(debugLines);
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
@ -1,29 +1,29 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Add a map marker creation event handler.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Code to execute (Code or String)
|
||||
* Arguments:
|
||||
* 0: Code to execute <CODE, STRING>
|
||||
*
|
||||
* Return value:
|
||||
* ID of the event script (used to remove it later).
|
||||
* Return Value:
|
||||
* ID of the event script (used to remove it later). <NUMBER>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_actionsVar", "_id", "_actionIDs", "_actions"];
|
||||
|
||||
PARAMS_1(_statement);
|
||||
params ["_statement"];
|
||||
|
||||
if (typeName _statement == "STRING") then {
|
||||
_statement = compile _statement;
|
||||
};
|
||||
|
||||
private "_actionsVar";
|
||||
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_MapMarker", [-1, [], []]];
|
||||
|
||||
_id = (_actionsVar select 0) + 1;
|
||||
_actionIDs = _actionsVar select 1;
|
||||
_actions = _actionsVar select 2;
|
||||
_actionsVar params ["_id", "_actionIDs", "_actions"];
|
||||
|
||||
_id = _id + 1;
|
||||
|
||||
if (_id == 0) then {
|
||||
uiNamespace setVariable ["ACE_EventHandler_MapMarker", count allMapMarkers];
|
||||
|
@ -1,29 +1,30 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Add an event handler that executes every ACE_time the scroll wheel is used. This is needed, because adding a MouseZ display event handler to display 46 will break in save games.
|
||||
* _this will be [Interval] where 'Interval' is a number.
|
||||
*
|
||||
* Add an event handler that executes every ACE_time the scroll wheel is used. This is needed, because adding a MouseZ display event handler to display 46 will break in save games. Argument will be [Interval] where 'Interval' is a number.
|
||||
* Arguments:
|
||||
* 0: Code to execute <CODE, STRING>
|
||||
*
|
||||
* Argument:
|
||||
* 0: Code to execute (Code or String)
|
||||
* Return Value:
|
||||
* ID of the event script (used to remove it later). <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* ID of the event script (used to remove it later).
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_actionsVar", "_id", "_actionIDs", "_actions"];
|
||||
|
||||
PARAMS_1(_statement);
|
||||
params ["_statement"];
|
||||
|
||||
if (typeName _statement == "STRING") then {
|
||||
_statement = compile _statement;
|
||||
_statement = compile _statement;
|
||||
};
|
||||
|
||||
private "_actionsVar";
|
||||
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]];
|
||||
|
||||
_id = (_actionsVar select 0) + 1;
|
||||
_actionIDs = _actionsVar select 1;
|
||||
_actions = _actionsVar select 2;
|
||||
_actionsVar params ["_id", "_actionIDs", "_actions"];
|
||||
|
||||
_id = _id + 1;
|
||||
|
||||
_actionIDs pushBack _id;
|
||||
_actions pushBack _statement;
|
||||
|
@ -11,7 +11,7 @@
|
||||
* 4: localizedDescription <STRING>
|
||||
* 5: possibleValues <ARRAY>
|
||||
* 6: isForced <BOOL>
|
||||
* 7: defaultValue (Any)
|
||||
* 7: defaultValue <ANY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -20,10 +20,9 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_8(_name,_typeName,_isClientSetable,_localizedName,_localizedDescription,_possibleValues,_isForced,_value);
|
||||
|
||||
private ["_settingData"];
|
||||
params ["_name", "", "", "", "", "", "", "_value"]; //["_name", "_typeName", "_isClientSetable", "_localizedName", "_localizedDescription", "_possibleValues", "_isForced", "_value"];
|
||||
|
||||
private "_settingData";
|
||||
_settingData = [_name] call FUNC(getSettingData);
|
||||
|
||||
// Exit if the setting already exists
|
||||
|
@ -1,34 +1,29 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Register an event handler for an ACE synced event
|
||||
*
|
||||
* Argument:
|
||||
* 0: Name (String)
|
||||
* 1: Handler (Code)
|
||||
* 2: TTL (Number or Code) [Optional]
|
||||
* Arguments:
|
||||
* 0: Name <STRING>
|
||||
* 1: Handler <CODE>
|
||||
* 2: TTL (optional: 0) <NUMBER, CODE>
|
||||
*
|
||||
* Return value:
|
||||
* Boolean of success
|
||||
* Return Value:
|
||||
* Boolean of success <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
//IGNORE_PRIVATE_WARNING("_handleSyncedEvent");
|
||||
|
||||
PARAMS_2(_name,_handler);
|
||||
params ["_name", "_handler", ["_ttl", 0]];
|
||||
|
||||
private["_ttl", "_eventId", "_data"];
|
||||
if( (count _this) > 2) then {
|
||||
_ttl = _this select 2;
|
||||
} else {
|
||||
_ttl = 0;
|
||||
};
|
||||
|
||||
if(HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
ACE_LOGERROR("Duplicate synced event creation.");
|
||||
false
|
||||
};
|
||||
|
||||
private ["_eventId", "_data"];
|
||||
|
||||
_eventId = [_name, FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
|
||||
_data = [_handler,[],_ttl,_eventId];
|
||||
_data = [_handler, [], _ttl, _eventId];
|
||||
|
||||
HASH_SET(GVAR(syncedEvents),_name,_data);
|
||||
|
@ -1,95 +1,141 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
* Adds an item,weapon,magazine to the unit's inventory
|
||||
* or places it in a weaponHolder if no space.
|
||||
* Adds an item, weapon, or magazine to the unit's inventory or places it in a weaponHolder if no space.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Classname <STRING>
|
||||
* 2: Container (uniform, vest, backpack) <STRING><OPTIONAL>
|
||||
* 3: Magazine Ammo Count <NUMBER><OPTIONAL>
|
||||
* 2: Container (uniform, vest, backpack) (default: "") <STRING>
|
||||
* 3: Magazine Ammo Count (default: -1) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Array:
|
||||
* 0: Added to player (Bool)
|
||||
* 1: weaponholder (OBJECT)
|
||||
* 0: Added to player <BOOL>
|
||||
* 1: weaponholder <OBJECT>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_classname);
|
||||
DEFAULT_PARAM(2,_container,"");
|
||||
DEFAULT_PARAM(3,_ammoCount,-1);
|
||||
params ["_unit", "_classname", ["_container", ""], ["_ammoCount", -1]];
|
||||
|
||||
private ["_addedToPlayer", "_canAdd", "_type", "_pos"];
|
||||
private ["_type", "_canAdd", "_addedToUnit"];
|
||||
|
||||
_canAdd = false;
|
||||
_addedToPlayer = true;
|
||||
|
||||
_type = [_classname] call EFUNC(common,getItemType);
|
||||
_type = [_classname] call FUNC(getItemType);
|
||||
|
||||
switch (_container) do {
|
||||
case "vest": { _canAdd = _unit canAddItemToVest _classname; };
|
||||
case "backpack": { _canAdd = _unit canAddItemToBackpack _classname; };
|
||||
case "uniform": { _canAdd = _unit canAddItemToUniform _classname; };
|
||||
default {_canAdd = _unit canAdd _classname;};
|
||||
};
|
||||
|
||||
switch ((_type select 0)) do {
|
||||
case "weapon": {
|
||||
if (_canAdd) then {
|
||||
switch (_container) do {
|
||||
case "vest": { (vestContainer _unit) addWeaponCargoGlobal [_classname, 1]; };
|
||||
case "backpack": { (backpackContainer _unit) addWeaponCargoGlobal [_classname, 1]; };
|
||||
case "uniform": { (uniformContainer _unit) addWeaponCargoGlobal [_classname, 1]; };
|
||||
default { _unit addWeaponGlobal _classname; };
|
||||
};
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorldVisual [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addWeaponCargoGlobal [_classname,1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
case "vest": {
|
||||
_canAdd = _unit canAddItemToVest _classname;
|
||||
};
|
||||
case "magazine": {
|
||||
if (_ammoCount == -1) then {_ammoCount = getNumber (configFile >> "CfgMagazines" >> _classname >> "count");};
|
||||
if (_canAdd) then {
|
||||
switch (_container) do {
|
||||
case "vest": { (vestContainer _unit) addMagazineCargoGlobal [_classname, _ammoCount]; };
|
||||
case "backpack": { (backpackContainer _unit) addMagazineCargoGlobal [_classname, _ammoCount]; };
|
||||
case "uniform": { (uniformContainer _unit) addMagazineCargoGlobal [_classname, _ammoCount]; };
|
||||
default {_unit addMagazine [_classname, _ammoCount]; };
|
||||
};
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorldVisual [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addMagazineCargoGlobal [_classname, _ammoCount];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
case "backpack": {
|
||||
_canAdd = _unit canAddItemToBackpack _classname;
|
||||
};
|
||||
case "item": {
|
||||
if (_canAdd) then {
|
||||
switch (_container) do {
|
||||
case "vest": { _unit addItemToVest _classname; };
|
||||
case "backpack": { _unit addItemToBackpack _classname; };
|
||||
case "uniform": { _unit addItemToUniform _classname; };
|
||||
default { _unit addItem _classname; };
|
||||
};
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorldVisual [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addItemCargoGlobal [_classname,1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
case "uniform": {
|
||||
_canAdd = _unit canAddItemToUniform _classname;
|
||||
};
|
||||
default {
|
||||
_canAdd = _unit canAdd _classname;
|
||||
};
|
||||
};
|
||||
|
||||
switch (_type select 0) do {
|
||||
case "weapon": {
|
||||
if (_canAdd) then {
|
||||
_addedToUnit = true;
|
||||
|
||||
switch (_container) do {
|
||||
case "vest": {
|
||||
(vestContainer _unit) addWeaponCargoGlobal [_classname, 1];
|
||||
};
|
||||
case "backpack": {
|
||||
(backpackContainer _unit) addWeaponCargoGlobal [_classname, 1];
|
||||
};
|
||||
case "uniform": {
|
||||
(uniformContainer _unit) addWeaponCargoGlobal [_classname, 1];
|
||||
};
|
||||
default {
|
||||
_unit addWeaponGlobal _classname;
|
||||
};
|
||||
};
|
||||
} else {
|
||||
_addedToUnit = false;
|
||||
|
||||
private "_pos";
|
||||
_pos = _unit modelToWorldVisual [0,1,0.05];
|
||||
|
||||
_unit = createVehicle ["WeaponHolder_Single_F", _pos, [], 0, "NONE"];
|
||||
_unit addWeaponCargoGlobal [_classname, 1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
|
||||
case "magazine": {
|
||||
if (_ammoCount == -1) then {
|
||||
_ammoCount = getNumber (configFile >> "CfgMagazines" >> _classname >> "count");
|
||||
};
|
||||
|
||||
if (_canAdd) then {
|
||||
_addedToUnit = true;
|
||||
|
||||
switch (_container) do {
|
||||
case "vest": {
|
||||
(vestContainer _unit) addMagazineCargoGlobal [_classname, 1/*_ammoCount*/]; //@todo Bug! This isn't really the ammo, but magazine count. No such command.
|
||||
};
|
||||
case "backpack": {
|
||||
(backpackContainer _unit) addMagazineCargoGlobal [_classname, 1/*_ammoCount*/]; //@todo Bug! This isn't really the ammo, but magazine count. No such command.
|
||||
};
|
||||
case "uniform": {
|
||||
(uniformContainer _unit) addMagazineCargoGlobal [_classname, 1/*_ammoCount*/]; //@todo Bug! This isn't really the ammo, but magazine count. No such command.
|
||||
};
|
||||
default {
|
||||
_unit addMagazine [_classname, _ammoCount];
|
||||
};
|
||||
};
|
||||
} else {
|
||||
_addedToUnit = false;
|
||||
|
||||
private "_pos";
|
||||
_pos = _unit modelToWorldVisual [0,1,0.05];
|
||||
|
||||
_unit = createVehicle ["WeaponHolder_Single_F", _pos, [], 0, "NONE"];
|
||||
_unit addMagazineCargoGlobal [_classname, 1/*_ammoCount*/]; //@todo Bug! This isn't really the ammo, but magazine count. No such command.
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
|
||||
case "item": {
|
||||
if (_canAdd) then {
|
||||
_addedToUnit = true;
|
||||
|
||||
switch (_container) do {
|
||||
case "vest": {
|
||||
_unit addItemToVest _classname;
|
||||
};
|
||||
case "backpack": {
|
||||
_unit addItemToBackpack _classname;
|
||||
};
|
||||
case "uniform": {
|
||||
_unit addItemToUniform _classname;
|
||||
};
|
||||
default {
|
||||
_unit addItem _classname;
|
||||
};
|
||||
};
|
||||
} else {
|
||||
_addedToUnit = false;
|
||||
|
||||
private "_pos";
|
||||
_pos = _unit modelToWorldVisual [0,1,0.05];
|
||||
|
||||
_unit = createVehicle ["WeaponHolder_Single_F", _pos, [], 0, "NONE"];
|
||||
_unit addItemCargoGlobal [_classname, 1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
|
||||
default {
|
||||
_addedToUnit = false;
|
||||
ACE_LOGWARNING_2("Incorrect item type passed to %1, passed: %2",QFUNC(AddToInventory),_type);
|
||||
};
|
||||
};
|
||||
|
||||
[_addedToPlayer,_unit]
|
||||
[_addedToUnit, _unit]
|
||||
|
@ -3,12 +3,14 @@
|
||||
*
|
||||
* Returns a brightness value depending on the sun and moon state. Ranges from 0 to 1 (dark ... bright).
|
||||
*
|
||||
* Argument:
|
||||
* None.
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* Ambient brightness (Number)
|
||||
* Return Value:
|
||||
* Ambient brightness <NUMBER>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
(sunOrMoon * sunOrMoon * (1 - overcast * 0.25) + (moonIntensity/5) * (1 - overcast)) min 1
|
||||
(sunOrMoon * sunOrMoon * (1 - overcast * 0.25) + (moonIntensity / 5) * (1 - overcast)) min 1
|
||||
|
@ -1,25 +1,23 @@
|
||||
/*
|
||||
Name: FUNC(applyForceWalkStatus)
|
||||
|
||||
Author: Pabst Mirror
|
||||
|
||||
Description:
|
||||
Applys the forceWalk status of an unit. Called from Extended_InitPost_EventHandlers.
|
||||
|
||||
Parameters:
|
||||
0: OBJECT - Unit
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
Example:
|
||||
[ACE_Player] call FUNC(applyForceWalkStatus)
|
||||
* Author: Pabst Mirror
|
||||
* Applys the forceWalk status of an unit. Called from Extended_InitPost_EventHandlers.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_Player] call FUNC(applyForceWalkStatus)
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_forceWalkNumber"];
|
||||
params ["_unit"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
private "_forceWalkNumber";
|
||||
_forceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0];
|
||||
|
||||
_unit forceWalk (_forceWalkNumber > 0);
|
||||
|
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get a binary equivalent of a decimal number.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Decimal Number (Number)
|
||||
* 1: Minimum length of the returned Array, note: returned array can be larger (Number, optional default 8)
|
||||
* Arguments:
|
||||
* 0: Decimal Number <NUMBER>
|
||||
* 1: Minimum length of the returned Array, note: returned array can be larger (default: 8) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Booleans (Array)
|
||||
* Return Value:
|
||||
* Booleans <ARRAY>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_number", "_minLength", "_array", "_index", "_rest"];
|
||||
params ["_number", ["_minLength", 8]];
|
||||
|
||||
_number = round (_this select 0);
|
||||
_minLength = _this select 1;
|
||||
_number = round _number;
|
||||
|
||||
if (isNil "_minLength") then {_minLength = 8};
|
||||
private ["_array", "_index", "_rest"];
|
||||
|
||||
_array = [];
|
||||
_array resize _minLength;
|
||||
@ -35,4 +35,5 @@ while {_number > 0} do {
|
||||
_array set [_index, _rest == 1];
|
||||
_index = _index + 1;
|
||||
};
|
||||
|
||||
_array
|
||||
|
@ -1,30 +1,33 @@
|
||||
/**
|
||||
* fn_gui_blurScreen.sqf
|
||||
* @Descr:
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: ID <NUMBER>
|
||||
* 1: Show? <BOOL, NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
private ["_show"];
|
||||
PARAMS_1(_id);
|
||||
_show = if (count _this > 1) then {_this select 1} else {false};
|
||||
params ["_id", ["_show", false]];
|
||||
|
||||
if (typeName _show == "SCALAR") then {
|
||||
_show = _show == 1;
|
||||
};
|
||||
|
||||
if (isNil QGVAR(SHOW_BLUR_SCREEN_COLLECTION)) then {
|
||||
GVAR(SHOW_BLUR_SCREEN_COLLECTION) = [];
|
||||
};
|
||||
if (typeName _show == typeName 0) then {
|
||||
_show = (_show == 1);
|
||||
};
|
||||
|
||||
if (_show) then {
|
||||
GVAR(SHOW_BLUR_SCREEN_COLLECTION) pushback _id;
|
||||
GVAR(SHOW_BLUR_SCREEN_COLLECTION) pushBack _id;
|
||||
|
||||
// show blur
|
||||
if (isnil QGVAR(MENU_ppHandle_GUI_BLUR_SCREEN)) then {
|
||||
GVAR(MENU_ppHandle_GUI_BLUR_SCREEN) = ppEffectCreate ["DynamicBlur", 102];
|
||||
@ -34,9 +37,10 @@ if (_show) then {
|
||||
};
|
||||
} else {
|
||||
GVAR(SHOW_BLUR_SCREEN_COLLECTION) = GVAR(SHOW_BLUR_SCREEN_COLLECTION) - [_id];
|
||||
|
||||
if (GVAR(SHOW_BLUR_SCREEN_COLLECTION) isEqualTo []) then {
|
||||
// hide blur
|
||||
if (!isnil QGVAR(MENU_ppHandle_GUI_BLUR_SCREEN)) then {
|
||||
if (!isNil QGVAR(MENU_ppHandle_GUI_BLUR_SCREEN)) then {
|
||||
ppEffectDestroy GVAR(MENU_ppHandle_GUI_BLUR_SCREEN);
|
||||
GVAR(MENU_ppHandle_GUI_BLUR_SCREEN) = nil;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user