2015-03-11 14:21:35 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2015-08-16 18:14:54 +00:00
|
|
|
* Checks if the vehicles class already has the actions initialized, otherwise add all available repair options. Calleed from init EH.
|
2015-03-11 14:21:35 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-16 18:14:54 +00:00
|
|
|
* 0: Vehicle <OBJECT>
|
2015-03-11 14:21:35 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-16 18:14:54 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [vehicle] call ace_repair_fnc_addRepairActions
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-03-11 14:21:35 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-09 06:54:44 +00:00
|
|
|
params ["_vehicle"];
|
|
|
|
TRACE_1("params", _vehicle);
|
2015-03-11 14:21:35 +00:00
|
|
|
|
|
|
|
private ["_type", "_initializedClasses"];
|
|
|
|
|
|
|
|
_type = typeOf _vehicle;
|
|
|
|
|
|
|
|
_initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
|
|
|
|
|
|
|
|
// do nothing if the class is already initialized
|
|
|
|
if (_type in _initializedClasses) exitWith {};
|
|
|
|
|
2015-08-23 23:51:34 +00:00
|
|
|
// get all hitpoints and selections
|
|
|
|
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitPoints", "_hitPointsSelections"];
|
2015-03-11 14:21:35 +00:00
|
|
|
|
2015-08-23 23:51:34 +00:00
|
|
|
// get hitpoints of wheels with their selections
|
|
|
|
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitPointSelections"];
|
2015-03-11 14:21:35 +00:00
|
|
|
|
|
|
|
|
2015-08-23 23:04:57 +00:00
|
|
|
private ["_hitPointsAddedNames", "_hitPointsAddedStrings", "_hitPointsAddedAmount"];
|
|
|
|
_hitPointsAddedNames = [];
|
|
|
|
_hitPointsAddedStrings = [];
|
|
|
|
_hitPointsAddedAmount = [];
|
|
|
|
|
2015-03-11 14:21:35 +00:00
|
|
|
// add repair events to this vehicle class
|
|
|
|
{
|
|
|
|
if (_x in _wheelHitPoints) then {
|
|
|
|
// add wheel repair action
|
|
|
|
|
2015-03-28 10:08:17 +00:00
|
|
|
private ["_icon", "_selection"];
|
2015-03-11 14:21:35 +00:00
|
|
|
|
2015-03-11 18:54:19 +00:00
|
|
|
_icon = QUOTE(PATHTOF(ui\tire_ca.paa));
|
2015-08-09 15:23:32 +00:00
|
|
|
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";
|
|
|
|
// textDefault = "<img image='\A3\ui_f\data\igui\cfg\actions\repair_ca.paa' size='1.8' shadow=2 />";
|
2015-03-11 14:21:35 +00:00
|
|
|
_selection = _wheelHitPointSelections select (_wheelHitPoints find _x);
|
|
|
|
|
2015-03-28 10:08:17 +00:00
|
|
|
private ["_name", "_text", "_condition", "_statement"];
|
2015-03-11 14:21:35 +00:00
|
|
|
|
2015-03-28 10:08:17 +00:00
|
|
|
// remove wheel action
|
|
|
|
_name = format ["Remove_%1", _x];
|
2015-08-23 23:25:00 +00:00
|
|
|
_text = localize LSTRING(RemoveWheel);
|
2015-03-11 14:21:35 +00:00
|
|
|
|
2015-08-09 13:53:52 +00:00
|
|
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
|
|
|
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
|
2015-03-11 14:21:35 +00:00
|
|
|
|
2015-03-27 02:44:04 +00:00
|
|
|
private "_action";
|
2015-03-28 10:08:17 +00:00
|
|
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 2] call EFUNC(interact_menu,createAction);
|
2015-03-27 02:44:04 +00:00
|
|
|
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
|
2015-03-28 10:08:17 +00:00
|
|
|
// replace wheel action
|
|
|
|
_name = format ["Replace_%1", _x];
|
2015-08-09 06:54:44 +00:00
|
|
|
_text = localize LSTRING(ReplaceWheel);
|
2015-03-28 10:08:17 +00:00
|
|
|
|
2015-08-09 13:53:52 +00:00
|
|
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(canRepair)};
|
|
|
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(repair)};
|
2015-03-28 10:08:17 +00:00
|
|
|
|
|
|
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 2] call EFUNC(interact_menu,createAction);
|
2015-03-27 02:44:04 +00:00
|
|
|
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
2015-03-11 14:21:35 +00:00
|
|
|
|
|
|
|
} else {
|
2015-03-11 20:52:34 +00:00
|
|
|
// exit if the hitpoint is in the blacklist, e.g. glasses
|
|
|
|
if (_x in IGNORED_HITPOINTS) exitWith {};
|
|
|
|
|
2015-08-24 18:03:11 +00:00
|
|
|
private ["_hitpointGroupConfig", "_inHitpointSubGroup", "_currentHitpoint"];
|
|
|
|
|
|
|
|
// Get hitpoint groups if available
|
|
|
|
_hitpointGroupConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroups);
|
|
|
|
_inHitpointSubGroup = false;
|
|
|
|
if (isArray _hitpointGroupConfig) then {
|
2015-08-26 20:51:41 +00:00
|
|
|
// Set variable if current hitpoint is in a sub-group (to be excluded from adding action)
|
2015-08-24 18:03:11 +00:00
|
|
|
_currentHitpoint = _x;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_x == _currentHitpoint) exitWith {
|
|
|
|
_inHitpointSubGroup = true;
|
|
|
|
};
|
|
|
|
} forEach (_x select 1);
|
|
|
|
} forEach (getArray _hitpointGroupConfig);
|
|
|
|
};
|
|
|
|
|
2015-08-26 20:51:41 +00:00
|
|
|
// Exit if current hitpoint is in sub-group (only main hitpoints get actions)
|
2015-08-24 18:03:11 +00:00
|
|
|
if (_inHitpointSubGroup) exitWith {};
|
2015-03-11 20:52:34 +00:00
|
|
|
|
2015-03-11 23:12:54 +00:00
|
|
|
// exit if the hitpoint is virtual
|
|
|
|
if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {};
|
|
|
|
|
2015-03-11 14:21:35 +00:00
|
|
|
// add misc repair action
|
2015-08-24 18:58:54 +00:00
|
|
|
private ["_name", "_icon", "_selection", "_condition", "_statement"];
|
2015-03-11 14:21:35 +00:00
|
|
|
|
2015-03-27 02:44:04 +00:00
|
|
|
_name = format ["Repair_%1", _x];
|
2015-03-29 11:54:50 +00:00
|
|
|
|
2015-08-24 18:58:54 +00:00
|
|
|
// Find localized string and track those added for numerization
|
|
|
|
([_x, "%1", _x, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"];
|
|
|
|
_hitPointsAddedNames = _trackArray select 0;
|
|
|
|
_hitPointsAddedStrings = _trackArray select 1;
|
|
|
|
_hitPointsAddedAmount = _trackArray select 2;
|
2015-08-23 23:04:57 +00:00
|
|
|
|
2015-08-09 15:23:32 +00:00
|
|
|
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";
|
2015-08-24 01:23:37 +00:00
|
|
|
|
2015-03-11 18:54:19 +00:00
|
|
|
_selection = "";
|
2015-08-24 16:17:56 +00:00
|
|
|
|
2015-08-24 01:23:37 +00:00
|
|
|
// Get custom position if available
|
2015-08-24 16:17:56 +00:00
|
|
|
_customSelectionsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions);
|
|
|
|
if (isArray _customSelectionsConfig) then {
|
|
|
|
// Loop through custom hitpoint positions array
|
|
|
|
_currentHitpoint = _x;
|
|
|
|
{
|
|
|
|
_x params ["_hitpoint", "_position"];
|
|
|
|
// Exit with supplied custom position when same hitpoint name found or print RPT error if it's invalid
|
|
|
|
if (_hitpoint == _currentHitpoint) exitWith {
|
|
|
|
if (typeName _position == "ARRAY") exitWith {
|
|
|
|
_selection = _position; // Position in model space
|
|
|
|
};
|
|
|
|
if (typeName _position == "STRING") exitWith {
|
|
|
|
_selection = _vehicle selectionPosition _position; // Selection name
|
|
|
|
};
|
|
|
|
diag_log text format ["[ACE] ERROR: Invalid custom position %1 of hitpoint %2 in vehicle %3", _position, _hitpoint, _vehicle];
|
2015-08-24 01:23:37 +00:00
|
|
|
};
|
2015-08-24 16:17:56 +00:00
|
|
|
} forEach (getArray _customSelectionsConfig);
|
2015-08-24 01:23:37 +00:00
|
|
|
};
|
2015-08-24 16:17:56 +00:00
|
|
|
|
2015-08-24 01:23:37 +00:00
|
|
|
// If position still empty (not a position array or selection name) try extracting from model
|
|
|
|
if (typeName _selection == "STRING" && {_selection == ""}) then {
|
|
|
|
_selection = _vehicle selectionPosition (_hitPointsSelections select (_hitPoints find _x));
|
|
|
|
};
|
|
|
|
|
2015-08-09 13:53:52 +00:00
|
|
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)};
|
2015-08-09 15:23:32 +00:00
|
|
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)};
|
|
|
|
|
2015-08-11 19:35:13 +00:00
|
|
|
if (_x in TRACK_HITPOINTS) then {
|
|
|
|
if (_x == "HitLTrack") then {
|
|
|
|
_selection = [-1.75, 0, -1.75];
|
|
|
|
} else {
|
|
|
|
_selection = [1.75, 0, -1.75];
|
|
|
|
};
|
|
|
|
private "_action";
|
|
|
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "RepairTrack"], _selection, 4] call EFUNC(interact_menu,createAction);
|
|
|
|
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
} else {
|
2015-08-09 15:23:32 +00:00
|
|
|
private "_action";
|
|
|
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction);
|
2015-08-24 15:58:19 +00:00
|
|
|
// Put inside main actions if no other position was found above
|
|
|
|
if (_selection isEqualTo [0, 0, 0]) then {
|
|
|
|
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
} else {
|
|
|
|
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
};
|
2015-08-11 19:35:13 +00:00
|
|
|
};
|
2015-03-11 14:21:35 +00:00
|
|
|
};
|
|
|
|
} forEach _hitPoints;
|
|
|
|
|
2015-08-14 18:49:51 +00:00
|
|
|
private ["_action", "_condition", "_statement"];
|
|
|
|
|
|
|
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)};
|
|
|
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)};
|
|
|
|
_action = [QGVAR(fullRepair), localize LSTRING(fullRepair), "A3\ui_f\data\igui\cfg\actions\repair_ca.paa", _statement, _condition, {}, ["", "fullRepair"], "", 4] call EFUNC(interact_menu,createAction);
|
|
|
|
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
|
2015-03-11 14:21:35 +00:00
|
|
|
// set class as initialized
|
|
|
|
_initializedClasses pushBack _type;
|
|
|
|
|
|
|
|
SETMVAR(GVAR(initializedClasses),_initializedClasses);
|