2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-05-03 04:13:35 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Scans for nearby "Static" objects (buildings) and adds the UserActions to them.
|
2016-01-08 04:43:37 +00:00
|
|
|
* Called when interact_menu starts rendering (from "interactMenuOpened" event)
|
2015-05-03 04:13:35 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Interact Menu Type (0 - world, 1 - self) <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-05-03 04:13:35 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2016-01-08 04:43:37 +00:00
|
|
|
* [0] call ace_interact_menu_fnc_userActions_addHouseActions
|
2015-05-03 04:13:35 +00:00
|
|
|
*
|
2016-01-08 04:43:37 +00:00
|
|
|
* Public: No
|
2015-05-03 04:13:35 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-04 22:46:57 +00:00
|
|
|
params ["_interactionType"];
|
2015-05-03 04:13:35 +00:00
|
|
|
|
2015-05-29 18:00:04 +00:00
|
|
|
//Ignore if not enabled:
|
|
|
|
if (!GVAR(addBuildingActions)) exitWith {};
|
2015-05-03 04:13:35 +00:00
|
|
|
//Ignore self-interaction menu:
|
|
|
|
if (_interactionType != 0) exitWith {};
|
|
|
|
//Ignore when mounted:
|
|
|
|
if ((vehicle ACE_player) != ACE_player) exitWith {};
|
|
|
|
|
|
|
|
[{
|
2015-08-04 22:46:57 +00:00
|
|
|
params ["_args", "_pfID"];
|
2022-03-09 03:41:21 +00:00
|
|
|
_args params ["_setPosition", "_addedHelpers", "_housesScanned", "_housesToScanForActions"];
|
2015-05-03 04:13:35 +00:00
|
|
|
|
|
|
|
if (!EGVAR(interact_menu,keyDown)) then {
|
|
|
|
{deleteVehicle _x;} forEach _addedHelpers;
|
|
|
|
[_pfID] call CBA_fnc_removePerFrameHandler;
|
|
|
|
} else {
|
|
|
|
// Prevent Rare Error when ending mission with interact key down:
|
2022-03-09 03:41:21 +00:00
|
|
|
if (isNull ACE_player) exitWith {};
|
2015-05-03 04:13:35 +00:00
|
|
|
|
2015-05-03 07:06:49 +00:00
|
|
|
//Make the common case fast (cursorTarget is looking at a door):
|
2022-03-09 03:41:21 +00:00
|
|
|
if ((!isNull cursorTarget) && {cursorTarget isKindOf "Static"} && {!(cursorTarget in _housesScanned)}) then {
|
2021-02-18 18:58:08 +00:00
|
|
|
if (((count (configOf cursorTarget >> "UserActions")) > 0) || {(count (getArray (configOf cursorTarget >> "ladders"))) > 0}) then {
|
2015-05-04 19:06:33 +00:00
|
|
|
_housesToScanForActions = [cursorTarget];
|
|
|
|
} else {
|
2022-03-09 03:41:21 +00:00
|
|
|
_housesScanned pushBack cursorTarget;
|
2015-05-03 05:33:20 +00:00
|
|
|
};
|
2015-05-03 04:13:35 +00:00
|
|
|
};
|
2015-05-03 05:33:20 +00:00
|
|
|
|
2015-05-04 19:06:33 +00:00
|
|
|
//For performance, we only do 1 thing per frame,
|
|
|
|
//-either do a wide scan and search for houses with actions
|
|
|
|
//-or scan one house at a time and add the actions for that house
|
|
|
|
|
|
|
|
if (_housesToScanForActions isEqualTo []) then {
|
|
|
|
//If player moved >2 meters from last pos, then rescan
|
2022-03-09 03:41:21 +00:00
|
|
|
if (((getPosASL ACE_player) distance _setPosition) < 2) exitWith {};
|
2015-05-04 19:06:33 +00:00
|
|
|
|
2022-03-09 03:41:21 +00:00
|
|
|
private _nearBuidlings = nearestObjects [ACE_player, ["Static"], 30];
|
2015-05-03 04:13:35 +00:00
|
|
|
{
|
2022-03-09 03:41:21 +00:00
|
|
|
private _configOfHouse = configOf _x;
|
|
|
|
if (((count (_configOfHouse >> "UserActions")) == 0) && {(count (getArray (_configOfHouse >> "ladders"))) == 0}) then {
|
|
|
|
_housesScanned pushBack _x;
|
2015-05-04 19:06:33 +00:00
|
|
|
} else {
|
|
|
|
_housesToScanForActions pushBack _x;
|
2015-05-03 04:13:35 +00:00
|
|
|
};
|
2022-03-09 03:41:21 +00:00
|
|
|
} forEach (_nearBuidlings - _housesScanned);
|
2015-05-03 04:13:35 +00:00
|
|
|
|
2022-03-09 03:41:21 +00:00
|
|
|
_args set [0, (getPosASL ACE_player)];
|
2015-05-03 04:13:35 +00:00
|
|
|
} else {
|
2022-03-09 03:41:21 +00:00
|
|
|
private _houseBeingScanned = _housesToScanForActions deleteAt 0;
|
2015-05-04 19:06:33 +00:00
|
|
|
//Skip this house for now if we are outside of it's radius
|
|
|
|
//(we have to scan far out for the big houses, but we don't want to waste time adding actions on every little shack)
|
2022-03-09 03:41:21 +00:00
|
|
|
if ((_houseBeingScanned != cursorTarget) && {((ACE_player distance _houseBeingScanned) - ((boundingBoxReal _houseBeingScanned) select 2)) > 4}) exitWith {};
|
2015-05-04 19:06:33 +00:00
|
|
|
|
2022-03-09 03:41:21 +00:00
|
|
|
_housesScanned pushBack _houseBeingScanned;
|
2015-05-04 19:06:33 +00:00
|
|
|
|
2022-03-09 03:41:21 +00:00
|
|
|
private _actionSet = [typeOf _houseBeingScanned] call FUNC(userActions_getHouseActions);
|
2015-08-04 22:46:57 +00:00
|
|
|
_actionSet params ["_memPoints", "_memPointsActions"];
|
2015-05-03 04:13:35 +00:00
|
|
|
|
2022-03-09 03:41:21 +00:00
|
|
|
TRACE_3("Add Actions for [%1] (count %2) @ %3",typeOf _houseBeingScanned,(count _memPoints),diag_tickTime);
|
2015-05-03 04:13:35 +00:00
|
|
|
{
|
2022-03-09 03:41:21 +00:00
|
|
|
private _helperPos = _houseBeingScanned modelToWorldWorld (_houseBeingScanned selectionPosition _x);
|
2016-07-26 05:03:29 +00:00
|
|
|
private _helperObject = "ACE_LogicDummy" createVehicleLocal [0,0,0];
|
2015-05-03 04:13:35 +00:00
|
|
|
_addedHelpers pushBack _helperObject;
|
2022-03-09 03:41:21 +00:00
|
|
|
_helperObject setVariable [QGVAR(building), _houseBeingScanned];
|
2015-05-04 19:06:33 +00:00
|
|
|
_helperObject setPosASL _helperPos;
|
2022-03-09 03:41:21 +00:00
|
|
|
TRACE_3("Making New Helper",_helperObject,_x,_houseBeingScanned);
|
2015-05-04 19:06:33 +00:00
|
|
|
|
2015-05-03 04:13:35 +00:00
|
|
|
{
|
|
|
|
[_helperObject, 0, [], _x] call EFUNC(interact_menu,addActionToObject);
|
2022-03-09 03:41:21 +00:00
|
|
|
} forEach (_memPointsActions select _forEachIndex);
|
2016-01-09 07:15:09 +00:00
|
|
|
} forEach _memPoints;
|
2015-05-03 04:13:35 +00:00
|
|
|
};
|
|
|
|
};
|
2022-03-09 03:41:21 +00:00
|
|
|
}, 0, [((getPosASL ACE_player) vectorAdd [-100,0,0]), [], [], []]] call CBA_fnc_addPerFrameHandler;
|