diff --git a/addons/repair/CfgVehicles.hpp b/addons/repair/CfgVehicles.hpp index 56f5b9cc81..13706ef1f8 100644 --- a/addons/repair/CfgVehicles.hpp +++ b/addons/repair/CfgVehicles.hpp @@ -4,8 +4,8 @@ class ACE_MainActions { \ class GVAR(Repair) { \ displayName = "$STR_AGM_Repair_Repair"; \ - condition = QUOTE([ARR_2(_player, _target)] call DFUNC(canRepair)); \ - statement = QUOTE([ARR_2(_player, _target)] call DFUNC(repair);); \ + condition = QUOTE([ARR_2(_player, _target)] call DFUNC(actionCanRepair)); \ + statement = QUOTE([ARR_2(_player, _target)] call DFUNC(actionRepair);); \ showDisabled = 0; \ priority = 2; \ icon = "\A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; \ diff --git a/addons/repair/XEH_preInit.sqf b/addons/repair/XEH_preInit.sqf index 34b63517cb..fdd4eba0bc 100644 --- a/addons/repair/XEH_preInit.sqf +++ b/addons/repair/XEH_preInit.sqf @@ -2,9 +2,10 @@ ADDON = false; -PREP(canRepair); +PREP(actionCanRepair); +PREP(actionRepair); PREP(doRepair); -PREP(repair); +PREP(getWheelHitPointsWithSelections); PREP(repairVehicle); PREP(setDamage); PREP(setHitPointDamage); diff --git a/addons/repair/functions/fnc_canRepair.sqf b/addons/repair/functions/fnc_actionCanRepair.sqf similarity index 100% rename from addons/repair/functions/fnc_canRepair.sqf rename to addons/repair/functions/fnc_actionCanRepair.sqf diff --git a/addons/repair/functions/fnc_repair.sqf b/addons/repair/functions/fnc_actionRepair.sqf similarity index 100% rename from addons/repair/functions/fnc_repair.sqf rename to addons/repair/functions/fnc_actionRepair.sqf diff --git a/addons/repair/functions/fnc_getWheelHitPointsWithSelections.sqf b/addons/repair/functions/fnc_getWheelHitPointsWithSelections.sqf new file mode 100644 index 0000000000..60a652d5fc --- /dev/null +++ b/addons/repair/functions/fnc_getWheelHitPointsWithSelections.sqf @@ -0,0 +1,78 @@ +/* + * Author: commy2 + * + * Returns the wheel hitpoints and their selections. + * + * Arguments: + * 0: A vehicle (Object) + * + * Return Value: + * Wheel positions in model coordinates. (Array) + */ +#include "script_component.hpp" + +private "_vehicle"; + +_vehicle = _this select 0; + +// get the vehicles wheel config +private "_wheels"; +_wheels = configfile >> "CfgVehicles" >> typeOf _vehicle >> "Wheels"; + +// exit with nothing if the vehicle has no wheels class +if !(isClass _wheels) exitWith {[[],[]]}; + +// get all wheels and read selections from config +private ["_selections", "_bones"]; + +_wheels = "true" configClasses _wheels; + +_selections = []; +_bones = []; +{ + _selections pushBack getText (_x >> "center"); + + private "_bone"; + _bone = getText (_x >> "boneName"); + + _bone = toArray _bone; + _bone resize count "wheel_X_Y"; // this is a requirement for physx. Should work for all addon vehicles. + _bone = toString _bone; + + _bones pushBack _bone; +} forEach _wheels; + +// get hitpoints with their fire geometry selections +private ["_hitPointsWithSelections", "_hitPoints", "_hitPointSelections"]; + +_hitPointsWithSelections = [_vehicle] call EFUNC(common,getHitPointsWithSelections); + +_hitPoints = _hitPointsWithSelections select 0; +_hitPointSelections = _hitPointsWithSelections select 1; + +// assign hitpoints to correct wheel selection by comparing bone name and fire geometry selection +private ["_wheelHitPoints", "_wheelHitPointSelections"]; + +_wheelHitPoints = []; +_wheelHitPointSelections = []; +{ + private "_bone"; + _bone = _x; + + private "_index"; + + _index = -1; + { + if (_bone != "" && {_x find _bone == 0}) exitWith { // same as above. Requirement for physx. + _index = _forEachIndex; + }; + } forEach _hitPointSelections; + + if (_index != -1) then { + _wheelHitPoints pushBack (_hitPoints select _index); + _wheelHitPointSelections pushBack (_selections select _forEachIndex); + }; + +} forEach _bones; + +[_wheelHitPoints, _wheelHitPointSelections]