Stagger creating actions over time

This commit is contained in:
PabstMirror 2015-04-15 00:13:23 -05:00
parent b2be71c9cf
commit 1f13d229a8

View File

@ -24,9 +24,9 @@ if (_interactionType != 0) exitWith {};
if ((vehicle ACE_player) != ACE_player) exitWith {};
[{
private ["_fncStatement", "_player", "_fncCondition", "_variable", "_theHouse", "_statement", "_condition", "_configPath", "_houseHelpers", "_displayName", "_displayNameDefault", "_iconImage", "_position", "_maxDistance", "_helperObject", "_actionOffset", "_memPoint", "_object", "_count", "_helperPos", "_action"];
private ["_fncStatement", "_player", "_fncCondition", "_variable", "_theHouse", "_statement", "_condition", "_configPath", "_displayName", "_displayNameDefault", "_iconImage", "_position", "_maxDistance", "_helperObject", "_actionOffset", "_memPoint", "_object", "_count", "_helperPos", "_action"];
PARAMS_2(_args,_pfID);
EXPLODE_3_PVT(_args,_setPosition,_addedHelpers,_housesScaned);
EXPLODE_4_PVT(_args,_setPosition,_addedHelpers,_housesScaned,_houseBeingScaned);
if (!EGVAR(interact_menu,keyDown)) then {
{deleteVehicle _x;} forEach _addedHelpers;
@ -38,6 +38,33 @@ if ((vehicle ACE_player) != ACE_player) exitWith {};
//If player moved >5 meters from last pos, then rescan
if (((getPosASL ace_player) distance _setPosition) < 5) exitWith {};
// systemChat str _houseBeingScaned;
if (_houseBeingScaned isEqualTo []) then {
_houseWasScaned = false;
{
_theHouse = _x;
if (!(_theHouse in _housesScaned)) exitWith {
_houseWasScaned = true;
_housesScaned pushBack _x;
if ((typeOf _theHouse) != "") then {
_configPath = (configFile >> "CfgVehicles" >> (typeOf _theHouse));
if (isClass (_configPath >> "UserActions")) then {
_args set [3, [_theHouse, 0, []]];
};
};
};
// Need to scan fairly far, because houses are big. You can be 25m from center of building but right next to a door.
} forEach nearestObjects [ace_player, ["Static"], 30];
if (!_houseWasScaned) then {
_args set [0, (getPosASL ace_player)];
};
} else {
EXPLODE_3_PVT(_houseBeingScaned,_theHouse,_index,_houseHelpers);
_configPath = configFile >> "CfgVehicles" >> (typeOf _theHouse) >> "UserActions";
if (_index < ((count _configPath) - 1)) then {
_actionPath = _configPath select _index;
_fncStatement = {
PARAMS_3(_target,_player,_variable);
EXPLODE_3_PVT(_variable,_theHouse,_statement,_condition);
@ -51,22 +78,12 @@ if ((vehicle ACE_player) != ACE_player) exitWith {};
call _condition;
};
{
_theHouse = _x;
if (!(_theHouse in _housesScaned)) then {
_housesScaned pushBack _x;
if ((typeOf _theHouse) != "") then {
_configPath = (configFile >> "CfgVehicles" >> (typeOf _theHouse));
if (isClass (_configPath >> "UserActions")) then {
_houseHelpers = [];
{
_displayName = getText (_x >> "displayName");
_displayNameDefault = getText (_x >> "displayNameDefault");
_position = getText (_x >> "position");
_condition = getText (_x >> "condition");
_statement = getText (_x >> "statement");
_maxDistance = getNumber (_x >> "radius");
_displayName = getText (_actionPath >> "displayName");
_displayNameDefault = getText (_actionPath >> "displayNameDefault");
_position = getText (_actionPath >> "position");
_condition = getText (_actionPath >> "condition");
_statement = getText (_actionPath >> "statement");
_maxDistance = getNumber (_actionPath >> "radius");
if (_displayName == "") then {_displayName = (configName _x);};
if (_position == "") then {ERROR("Bad Position");};
@ -80,7 +97,6 @@ if ((vehicle ACE_player) != ACE_player) exitWith {};
if (_displayNameDefault != "") then {
//something like: "<img image='\A3\Ui_f\data\IGUI\Cfg\Actions\open_door_ca.paa' size='2.5' />";
//find the end [.paa']
_endIndex = _displayNameDefault find ".paa'";
if (_endIndex == -1) exitWith {};
@ -124,16 +140,14 @@ if ((vehicle ACE_player) != ACE_player) exitWith {};
TRACE_3("Making New Helper %1",_helperObject,_helperPos,_theHouse);
};
_action = [(configName _x), _displayName, _iconImage, _fncStatement, _fncCondition, {}, [_theHouse, _statement, _condition], _actionOffset, _maxDistance] call EFUNC(interact_menu,createAction);
_action = [(configName _actionPath), _displayName, _iconImage, _fncStatement, _fncCondition, {}, [_theHouse, _statement, _condition], _actionOffset, _maxDistance] call EFUNC(interact_menu,createAction);
[_helperObject, 0, [],_action] call EFUNC(interact_menu,addActionToObject);
} foreach configproperties [(_configPath >> "UserActions")];
_index = _index + 1;
_args set [3, [_theHouse, _index, _houseHelpers]];
} else {
_args set [3, []];
};
};
};
//Need to scan fairly far, because houses are big. You can be 25m from center of building but right next to a door.
} forEach nearestObjects [ace_player, ["Static"], 30];
_args set [0, (getPosASL ace_player)];
};
}, 0.1, [((getPosASL ace_player) vectorAdd [-100,0,0]), [], []]] call CBA_fnc_addPerFrameHandler;
}, 0, [((getPosASL ace_player) vectorAdd [-100,0,0]), [], [], []]] call CBA_fnc_addPerFrameHandler;