diff --git a/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf b/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf index c53c5caa34..363e71e8d1 100644 --- a/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf +++ b/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf @@ -40,12 +40,14 @@ systemChat format ["starting %1", diag_tickTime]; //If player moved >5 meters from last pos, then rescan if (((getPosASL ace_player) distance _setPosition) < 5) exitWith {}; - //Make the common case fast (looking at a door): + //Make the common case fast (looking at a door): if ((!isNull cursorTarget) && {cursorTarget isKindOf "Static"} && {!(cursorTarget in _housesScaned)}) then { - _houseBeingScaned = cursorTarget; _housesScaned pushBack _houseBeingScaned; + if ((isClass (_configPath >> "UserActions")) || {(count (getArray (configFile >> "CfgVehicles" >> (typeOf _theHouse) >> "ladders"))) > 0}) then { + _houseBeingScaned = cursorTarget; + }; }; - + if (isNull _houseBeingScaned) then { _houseWasScaned = false; _nearBuidlings = nearestObjects [ace_player, ["Static"], 30]; @@ -56,7 +58,7 @@ systemChat format ["starting %1", diag_tickTime]; _housesScaned pushBack _x; if ((typeOf _theHouse) != "") then { _configPath = (configFile >> "CfgVehicles" >> (typeOf _theHouse)); - if (isClass (_configPath >> "UserActions")) then { + if ((isClass (_configPath >> "UserActions")) || {(count (getArray (configFile >> "CfgVehicles" >> (typeOf _theHouse) >> "ladders"))) > 0}) then { _args set [3, _theHouse]; }; }; @@ -85,9 +87,9 @@ systemChat format ["starting %1", diag_tickTime]; if (surfaceIsWater _helperPos) then { _helperObject setPosAslw _helperPos; } else { - _helperObject setPos _helperPos; + _helperObject setPosAtl _helperPos; }; - _helperObject hideObject true; + // _helperObject hideObject true; TRACE_3("Making New Helper",_helperObject,_x,_houseBeingScaned); { [_helperObject, 0, [], _x] call EFUNC(interact_menu,addActionToObject); diff --git a/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf b/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf index 4b9977d590..093d50751f 100644 --- a/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf +++ b/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf @@ -11,7 +11,7 @@ * * Public: Yes */ - #include "script_component.hpp" +#include "script_component.hpp" PARAMS_1(_typeOfBuilding); @@ -19,21 +19,35 @@ PARAMS_1(_typeOfBuilding); _memPoints = []; _memPointsActions = []; -_configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions"; +//Get the offset for a memory point: +_fnc_getMemPointOffset = { + PARAMS_1(_memoryPoint); + _memPointIndex = _memPoints find _memoryPoint; + _actionOffset = [0,0,0]; + if (_memPointIndex == -1) then { + _memPoints pushBack _memoryPoint; + _memPointsActions pushBack []; + } else { + _actionOffset set [2, 0.05 * (count (_memPointsActions select _memPointIndex))]; + }; + _actionOffset +}; -_fncStatement = { +// Add UserActions for the building: +_fnc_userAction_Statement = { PARAMS_3(_target,_player,_variable); EXPLODE_2_PVT(_variable,_actionStatement,_actionCondition); this = _target getVariable [QGVAR(building), objNull]; call _actionStatement; }; -_fncCondition = { +_fnc_userAction_Condition = { PARAMS_3(_target,_player,_variable); EXPLODE_2_PVT(_variable,_actionStatement,_actionCondition); this = _target getVariable [QGVAR(building), objNull]; call _actionCondition; }; +_configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions"; for "_index" from 0 to ((count _configPath) - 1) do { _actionPath = _configPath select _index; @@ -72,19 +86,54 @@ for "_index" from 0 to ((count _configPath) - 1) do { }; }; + _actionOffset = [_actionPosition] call _fnc_getMemPointOffset; _memPointIndex = _memPoints find _actionPosition; - _actionOffset = [0,0,0]; - if (_memPointIndex == -1) then { - _memPointIndex = count _memPoints; - _memPoints pushBack _actionPosition; - _memPointsActions pushBack []; - } else { - _actionOffset set [2, 0.05 * (count (_memPointsActions select _memPointIndex))]; - }; - _action = [(configName _actionPath), _actionDisplayName, _iconImage, _fncStatement, _fncCondition, {}, [_actionStatement, _actionCondition], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction); + _action = [(configName _actionPath), _actionDisplayName, _iconImage, _fnc_userAction_Statement, _fnc_userAction_Condition, {}, [_actionStatement, _actionCondition], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction); (_memPointsActions select _memPointIndex) pushBack _action; - }; +// Add Ladder Actions for the building: +_fnc_ladder_ladderUp = { + PARAMS_3(_target,_player,_variable); + EXPLODE_1_PVT(_variable,_ladderIndex); + _building = _target getVariable [QGVAR(building), objNull]; + ACE_player action ["LadderUp", _building, _ladderIndex, 0]; +}; +_fnc_ladder_ladderDown = { + PARAMS_3(_target,_player,_variable); + EXPLODE_1_PVT(_variable,_ladderIndex); + _building = _target getVariable [QGVAR(building), objNull]; + ACE_player action ["LadderUp", _building, (_variable select 0), 1]; +}; + +_ladders = getArray (configFile >> "CfgVehicles" >> _typeOfBuilding >> "ladders"); +{ + + + EXPLODE_2_PVT(_x,_ladderBottomMemPoint,_ladderTopMemPoint); + + _actionMaxDistance = 2; + + _actionDisplayName = "Climb Ladder Up"; + _iconImage = "\A3\ui_f\data\igui\cfg\actions\ladderup_ca.paa"; + //Ladder Up Action: + _actionOffset = [_ladderBottomMemPoint] call _fnc_getMemPointOffset; + _actionOffset = _actionOffset vectorAdd [0,0,1]; + _memPointIndex = _memPoints find _ladderBottomMemPoint; + _action = [format ["LadderUp_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderUp, {true}, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction); + (_memPointsActions select _memPointIndex) pushBack _action; + + _actionDisplayName = "Climb Ladder Down"; + _iconImage = "\A3\ui_f\data\igui\cfg\actions\ladderdown_ca.paa"; + //Ladder Down Action: + _actionOffset = [_ladderTopMemPoint] call _fnc_getMemPointOffset; + _actionOffset = _actionOffset vectorAdd [0,0,1]; + _memPointIndex = _memPoints find _ladderTopMemPoint; + _action = [format ["LadderDown_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderDown, {true}, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction); + (_memPointsActions select _memPointIndex) pushBack _action; + +} forEach _ladders; + + [_memPoints, _memPointsActions]