2015-05-03 04:13:35 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
2015-05-03 07:06:49 +00:00
|
|
|
* Scans the buidling type for UserActions and Ladder mount points.
|
2015-05-03 04:13:35 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Building Classname <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* [[Array of MemPoints], [Array Of Actions]]
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-05-03 05:33:20 +00:00
|
|
|
#include "script_component.hpp"
|
2015-05-03 04:13:35 +00:00
|
|
|
|
|
|
|
PARAMS_1(_typeOfBuilding);
|
|
|
|
|
2015-05-03 07:06:49 +00:00
|
|
|
private["_action", "_actionDisplayName", "_actionDisplayNameDefault", "_actionMaxDistance", "_actionOffset", "_actionPath", "_actionPosition", "_building", "_configPath", "_endIndex", "_iconImage", "_index", "_ladders", "_memPointIndex", "_memPoints", "_memPointsActions", "_startIndex"];
|
|
|
|
|
2015-05-04 19:06:33 +00:00
|
|
|
_searchIndex = GVAR(cachedBuildingTypes) find _typeOfBuilding;
|
|
|
|
if (_searchIndex != -1) exitWith {GVAR(cachedBuildingActionPairs) select _searchIndex};
|
|
|
|
|
2015-05-03 04:13:35 +00:00
|
|
|
_memPoints = [];
|
|
|
|
_memPointsActions = [];
|
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
//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 {
|
2015-05-29 18:00:04 +00:00
|
|
|
_actionOffset set [2, 0.0254 * (count (_memPointsActions select _memPointIndex))];
|
2015-05-03 05:33:20 +00:00
|
|
|
};
|
|
|
|
_actionOffset
|
|
|
|
};
|
2015-05-03 04:13:35 +00:00
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
// Add UserActions for the building:
|
|
|
|
_fnc_userAction_Statement = {
|
2015-05-03 04:13:35 +00:00
|
|
|
PARAMS_3(_target,_player,_variable);
|
|
|
|
EXPLODE_2_PVT(_variable,_actionStatement,_actionCondition);
|
|
|
|
this = _target getVariable [QGVAR(building), objNull];
|
|
|
|
call _actionStatement;
|
|
|
|
};
|
2015-05-03 05:33:20 +00:00
|
|
|
_fnc_userAction_Condition = {
|
2015-05-03 04:13:35 +00:00
|
|
|
PARAMS_3(_target,_player,_variable);
|
|
|
|
EXPLODE_2_PVT(_variable,_actionStatement,_actionCondition);
|
|
|
|
this = _target getVariable [QGVAR(building), objNull];
|
2015-05-29 18:00:04 +00:00
|
|
|
if (isNull this) exitWith {false};
|
2015-05-03 04:13:35 +00:00
|
|
|
call _actionCondition;
|
|
|
|
};
|
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
_configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions";
|
2015-05-03 04:13:35 +00:00
|
|
|
for "_index" from 0 to ((count _configPath) - 1) do {
|
|
|
|
_actionPath = _configPath select _index;
|
|
|
|
|
|
|
|
_actionDisplayName = getText (_actionPath >> "displayName");
|
|
|
|
_actionDisplayNameDefault = getText (_actionPath >> "displayNameDefault");
|
|
|
|
_actionPosition = getText (_actionPath >> "position");
|
|
|
|
_actionCondition = getText (_actionPath >> "condition");
|
|
|
|
_actionStatement = getText (_actionPath >> "statement");
|
|
|
|
_actionMaxDistance = getNumber (_actionPath >> "radius");
|
|
|
|
|
|
|
|
if (_actionDisplayName == "") then {_actionDisplayName = (configName _x);};
|
|
|
|
if (_actionPosition == "") then {ERROR("Bad Position");};
|
|
|
|
if (_actionCondition == "") then {_actionCondition = "true";};
|
|
|
|
if (_actionStatement == "") then {ERROR("No Statement");};
|
|
|
|
|
|
|
|
_actionStatement = compile _actionStatement;
|
|
|
|
_actionCondition = compile _actionCondition;
|
2015-05-04 19:06:33 +00:00
|
|
|
_actionMaxDistance = _actionMaxDistance + 0.1; //increase range slightly
|
2015-05-03 04:13:35 +00:00
|
|
|
_iconImage = "";
|
|
|
|
|
2015-05-04 19:06:33 +00:00
|
|
|
//extension ~4x as fast:
|
2015-05-03 18:44:02 +00:00
|
|
|
_iconImage = "ace_parse_imagepath" callExtension _actionDisplayNameDefault;
|
2015-05-04 19:06:33 +00:00
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
_actionOffset = [_actionPosition] call _fnc_getMemPointOffset;
|
2015-05-03 04:13:35 +00:00
|
|
|
_memPointIndex = _memPoints find _actionPosition;
|
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
_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);
|
2015-05-03 04:13:35 +00:00
|
|
|
(_memPointsActions select _memPointIndex) pushBack _action;
|
2015-05-03 05:33:20 +00:00
|
|
|
};
|
2015-05-03 04:13:35 +00:00
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
// 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];
|
2015-05-29 18:00:04 +00:00
|
|
|
TRACE_3("Ladder Action - UP",_player,_building,_ladderIndex);
|
2015-05-03 07:06:49 +00:00
|
|
|
_player action ["LadderUp", _building, _ladderIndex, 0];
|
2015-05-03 05:33:20 +00:00
|
|
|
};
|
|
|
|
_fnc_ladder_ladderDown = {
|
|
|
|
PARAMS_3(_target,_player,_variable);
|
|
|
|
EXPLODE_1_PVT(_variable,_ladderIndex);
|
|
|
|
_building = _target getVariable [QGVAR(building), objNull];
|
2015-05-29 18:00:04 +00:00
|
|
|
TRACE_3("Ladder Action - Down",_player,_building,_ladderIndex);
|
|
|
|
_player action ["LadderDown", _building, _ladderIndex, 1];
|
2015-05-03 07:06:49 +00:00
|
|
|
};
|
|
|
|
|
2015-05-29 18:00:04 +00:00
|
|
|
_fnc_ladder_conditional = {
|
|
|
|
PARAMS_2(_target,_player);
|
|
|
|
//(Check distance < 2) and (Don't show actions if on a ladder)
|
|
|
|
((_target distance _player) < 2) && {((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _player) >> "onLadder")) == 0)}
|
2015-05-03 04:13:35 +00:00
|
|
|
};
|
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
_ladders = getArray (configFile >> "CfgVehicles" >> _typeOfBuilding >> "ladders");
|
|
|
|
{
|
|
|
|
EXPLODE_2_PVT(_x,_ladderBottomMemPoint,_ladderTopMemPoint);
|
|
|
|
|
2015-05-29 18:00:04 +00:00
|
|
|
_actionMaxDistance = 3; //interact_menu will check head -> target's offset; leave this high and do a precice distance check in condition
|
2015-05-03 05:33:20 +00:00
|
|
|
|
2015-05-03 07:06:49 +00:00
|
|
|
_actionDisplayName = localize "str_action_ladderup";
|
2015-05-03 05:33:20 +00:00
|
|
|
_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;
|
2015-05-03 07:06:49 +00:00
|
|
|
_action = [format ["LadderUp_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderUp, _fnc_ladder_conditional, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction);
|
2015-05-03 05:33:20 +00:00
|
|
|
(_memPointsActions select _memPointIndex) pushBack _action;
|
|
|
|
|
2015-05-03 07:06:49 +00:00
|
|
|
_actionDisplayName = localize "str_action_ladderdown";
|
2015-05-03 05:33:20 +00:00
|
|
|
_iconImage = "\A3\ui_f\data\igui\cfg\actions\ladderdown_ca.paa";
|
|
|
|
//Ladder Down Action:
|
|
|
|
_actionOffset = [_ladderTopMemPoint] call _fnc_getMemPointOffset;
|
2015-05-03 07:06:49 +00:00
|
|
|
_actionOffset = _actionOffset vectorAdd [0,0,0.25];
|
2015-05-03 05:33:20 +00:00
|
|
|
_memPointIndex = _memPoints find _ladderTopMemPoint;
|
2015-05-03 07:06:49 +00:00
|
|
|
_action = [format ["LadderDown_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderDown, _fnc_ladder_conditional, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction);
|
2015-05-03 05:33:20 +00:00
|
|
|
(_memPointsActions select _memPointIndex) pushBack _action;
|
|
|
|
|
|
|
|
} forEach _ladders;
|
|
|
|
|
2015-05-04 19:06:33 +00:00
|
|
|
GVAR(cachedBuildingTypes) pushBack _typeOfBuilding;
|
|
|
|
GVAR(cachedBuildingActionPairs) pushBack [_memPoints, _memPointsActions];
|
|
|
|
|
2015-05-03 05:33:20 +00:00
|
|
|
|
2015-05-03 04:13:35 +00:00
|
|
|
[_memPoints, _memPointsActions]
|