mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common cleanup
This commit is contained in:
@ -1,73 +1,64 @@
|
|||||||
/*
|
/*
|
||||||
* Author: commy2
|
* 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.
|
* 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:
|
* Arguments:
|
||||||
* 0: Unit the action should be assigned to (Object)
|
* 0: Unit the action should be assigned to <OBJECT>
|
||||||
* 1: Name of the action, e.g. "DefaultAction" (String)
|
* 1: Name of the action, e.g. "DefaultAction" <STRING>
|
||||||
* 2: Condition (Code or String)
|
* 2: Condition <CODE, STRING>
|
||||||
* 3: Code to execute (Code or String)
|
* 3: Code to execute <CODE, STRING>
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return Value:
|
||||||
* ID of the action (used to remove it later).
|
* ID of the action (used to remove it later) <NUMBER>
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_action", "_condition", "_statement", "_name", "_actionsVar", "_actionID", "_actions", "_id", "_actionIDs"];
|
params ["_unit", "_action", "_condition", "_statement"];
|
||||||
//IGNORE_PRIVATE_WARNING("_count", "_index", "_return", "_target");
|
|
||||||
|
|
||||||
_unit = _this select 0;
|
|
||||||
_action = _this select 1;
|
|
||||||
_condition = _this select 2;
|
|
||||||
_statement = _this select 3;
|
|
||||||
|
|
||||||
if (typeName _condition == "STRING") then {
|
if (typeName _condition == "STRING") then {
|
||||||
_condition = compile _condition;
|
_condition = compile _condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeName _statement == "STRING") then {
|
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]];
|
_actionsVar = _unit getVariable [_name, [-1, [-1, [], []], objNull]];
|
||||||
|
|
||||||
if (_unit != _actionsVar select 2) then { // check if the unit is still valid, fixes respawn issues
|
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;
|
_actionsVar params ["_actionID", "_actionsArray"];
|
||||||
_actions = _actionsVar select 1;
|
_actionsArray params ["_id", "_actionIDs", "_actions"];
|
||||||
|
|
||||||
_id = (_actions select 0) + 1;
|
_id = _id + 1;
|
||||||
_actionIDs = _actions select 1;
|
|
||||||
_actions = _actions select 2;
|
|
||||||
|
|
||||||
_actionIDs pushBack _id;
|
_actionIDs pushBack _id;
|
||||||
_actions pushBack [_condition, _statement];
|
_actions pushBack [_condition, _statement];
|
||||||
|
|
||||||
// first action to add, unit needs addAction command
|
// first action to add, unit needs addAction command
|
||||||
if (_actionID == -1) then {
|
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 [
|
_actionID = _unit addAction _addAction;
|
||||||
"[
|
|
||||||
'',
|
|
||||||
{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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_unit setVariable [_name, [_actionID, [_id, _actionIDs, _actions], _unit], false];
|
_unit setVariable [_name, [_actionID, [_id, _actionIDs, _actions], _unit], false];
|
||||||
|
@ -1,29 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Author: commy2
|
* 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.
|
* 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:
|
* Arguments:
|
||||||
* 0: Unit the action should be assigned to (Object)
|
* 0: Unit the action should be assigned to <OBJECT>
|
||||||
* 1: Menu title of the action (String)
|
* 1: Menu title of the action <STRING>
|
||||||
* 2: Name of the action, e.g. "DefaultAction" (String)
|
* 2: Name of the action, e.g. "DefaultAction" <STRING>
|
||||||
* 3: Condition (Code or String)
|
* 3: Condition <CODE, STRING>
|
||||||
* 4: Code to execute by the action (Code or String)
|
* 4: Code to execute by the action <CODE, STRING>
|
||||||
* 5: Condition for the menu action (Code or String)
|
* 5: Condition for the menu action <CODE, STRING>
|
||||||
* 6: Code to execute from the menu (Code or String)
|
* 6: Code to execute from the menu <CODE, STRING>
|
||||||
* 7: Priority of the action (Number, optional default: 0)
|
* 7: Priority of the action (default: 0) <NUMBER>
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return Value:
|
||||||
* ID of the action (used to remove it later).
|
* ID of the action (used to remove it later) <NUMBER>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_name", "_actionsVar", "_id", "_actionIDs", "_actions", "_nameVar", "_addAction", "_actionID"];
|
params ["_unit", "_displayName", "_action", "_condition", "_statement", "_condition2", "_statement2", ["_priority", 0]];
|
||||||
//IGNORE_PRIVATE_WARNING("_target");
|
|
||||||
|
|
||||||
PARAMS_8(_unit,_displayName,_action,_condition,_statement,_condition2,_statement2,_priority);
|
|
||||||
|
|
||||||
if (isNil "_priority") then {_priority = 0};
|
|
||||||
|
|
||||||
if (typeName _condition == "STRING") then {
|
if (typeName _condition == "STRING") then {
|
||||||
_condition = compile _condition;
|
_condition = compile _condition;
|
||||||
@ -41,13 +37,16 @@ if (typeName _statement2 == "STRING") then {
|
|||||||
_statement2 = compile _statement2;
|
_statement2 = compile _statement2;
|
||||||
};
|
};
|
||||||
|
|
||||||
_name = format ["ACE_ActionMenu_%1", _action];
|
private ["_name", "_actionsVar"];
|
||||||
|
|
||||||
|
_name = format ["ACE_ActionMenu_%1", _action];
|
||||||
_actionsVar = _unit getVariable [_name, [-1, [], []]];
|
_actionsVar = _unit getVariable [_name, [-1, [], []]];
|
||||||
|
|
||||||
_id = (_actionsVar select 0) + 1;
|
_actionsVar params ["_id", "_actionIDs", "_actions"];
|
||||||
_actionIDs = _actionsVar select 1;
|
|
||||||
_actions = _actionsVar select 2;
|
_id = _id + 1;
|
||||||
|
|
||||||
|
private ["_nameVar", "_addAction", "_actionID"];
|
||||||
|
|
||||||
_nameVar = format ["%1_ID%2", _name, _id];
|
_nameVar = format ["%1_ID%2", _name, _id];
|
||||||
missionNamespace setVariable [_nameVar, [_condition, _statement, _condition2, _statement2]];
|
missionNamespace setVariable [_nameVar, [_condition, _statement, _condition2, _statement2]];
|
||||||
@ -56,14 +55,14 @@ _actionIDs pushBack _id;
|
|||||||
|
|
||||||
_addAction = call compile format [
|
_addAction = call compile format [
|
||||||
"[
|
"[
|
||||||
'%2',
|
'%2',
|
||||||
{if (inputAction '%1' == 0) then {if (_this call (%3 select 2)) then {_this call (%3 select 3)}} else {_this call (%3 select 1)}},
|
{if (inputAction '%1' == 0) then {if (_this call (%3 select 2)) then {_this call (%3 select 3)}} else {_this call (%3 select 1)}},
|
||||||
nil,
|
nil,
|
||||||
%4,
|
%4,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
'%1',
|
'%1',
|
||||||
""if (_this != ACE_player || {vehicle _this != _target}) exitWith {false}; [_target, _this] call (%3 select 0)""
|
""if (_this != ACE_player || {vehicle _this != _target}) exitWith {false}; [_target, _this] call (%3 select 0)""
|
||||||
]",
|
]",
|
||||||
_action,
|
_action,
|
||||||
_displayName,
|
_displayName,
|
||||||
|
@ -1,31 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Author: commy2
|
* Author: commy2
|
||||||
*
|
|
||||||
* Add a condition that gets checked by ace_common_fnc_canInteractWith.
|
* Add a condition that gets checked by ace_common_fnc_canInteractWith.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: The conditions id. Used to remove later or as exception name. An already existing name overwrites. (String)
|
* 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)
|
* 1: The condition to check. format of "_this" is "[_player, _target]". <CODE>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Unit can interact?
|
* None
|
||||||
*
|
*
|
||||||
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_conditionName", "_conditionFunc"];
|
params ["_conditionName", "_conditionFunc"];
|
||||||
//IGNORE_PRIVATE_WARNING("_player", "_target");
|
|
||||||
|
|
||||||
|
_conditionName = toLower _conditionName;
|
||||||
|
|
||||||
_conditionName = toLower (_this select 0);
|
private "_conditions";
|
||||||
_conditionFunc = _this select 1;
|
|
||||||
|
|
||||||
private ["_conditions", "_conditionNames", "_conditionFuncs"];
|
|
||||||
|
|
||||||
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
_conditions = missionNamespace getVariable [QGVAR(InteractionConditions), [[],[]]];
|
||||||
|
_conditions params ["_conditionNames", "_conditionFuncs"];
|
||||||
_conditionNames = _conditions select 0;
|
|
||||||
_conditionFuncs = _conditions select 1;
|
|
||||||
|
|
||||||
private "_index";
|
private "_index";
|
||||||
_index = _conditionNames find _conditionName;
|
_index = _conditionNames find _conditionName;
|
||||||
@ -37,4 +31,4 @@ if (_index == -1) then {
|
|||||||
_conditionNames set [_index, _conditionName];
|
_conditionNames set [_index, _conditionName];
|
||||||
_conditionFuncs set [_index, _conditionFunc];
|
_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"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private "_dlg";
|
|
||||||
|
|
||||||
disableSerialization;
|
disableSerialization;
|
||||||
|
|
||||||
|
private "_dlg";
|
||||||
_dlg = ctrlParent _this;
|
_dlg = ctrlParent _this;
|
||||||
|
|
||||||
_dlg displayAddEventHandler ["unload", {
|
_dlg displayAddEventHandler ["unload", {
|
||||||
|
Reference in New Issue
Block a user