Skip to content

Commit bb6f885

Browse files
authored
Repair - Patch to detect GM Wheel position and selection (#10871)
* initial take at fixing GM wheel detection * fix spelling misakes in comments
1 parent 871b16a commit bb6f885

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

addons/common/functions/fnc_getWheelHitPointsWithSelections.sqf

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
params ["_vehicle"];
2020
TRACE_1("params",_vehicle);
2121

22-
// TODO: Fix for GM vehicles
2322
GVAR(wheelSelections) getOrDefaultCall [typeOf _vehicle, {
2423
// Get the vehicles wheel config
2524
private _wheels = configOf _vehicle >> "Wheels";
@@ -33,6 +32,7 @@ GVAR(wheelSelections) getOrDefaultCall [typeOf _vehicle, {
3332

3433
private _wheelHitPoints = [];
3534
private _wheelHitPointSelections = [];
35+
private _isGM = 1 == getNumber (configOf _vehicle >> "isgmContent");
3636

3737
{
3838
private _wheelName = configName _x;
@@ -54,6 +54,20 @@ GVAR(wheelSelections) getOrDefaultCall [typeOf _vehicle, {
5454
};
5555
} forEach _hitPointSelections;
5656

57+
if (_isGM) then {
58+
_wheelHitPointSelection = _wheelBone + "_axis";
59+
{ // modified Commy's method, they tag "hitpoint_" onto their hitpoints when they have them
60+
if ((_wheelBoneNameResized != "") && {_x find _wheelBoneNameResized == 9}) exitWith { // same as above. Requirement for physx.
61+
_wheelHitPoint = _hitPoints select _forEachIndex;
62+
TRACE_3("wheel found [GM]",_wheelName,_wheelHitPoint,_wheelHitPointSelection);
63+
};
64+
} forEach _hitPointSelections;
65+
if (_wheelHitPoint == "" && _vehicle isKindOf "Car") then { // takes longer but a guarantee to find the hitpoint name
66+
private _class = format ["""%1"" in getText (_x >> ""visual"")",_wheelName] configClasses (configOf _vehicle >> "Hitpoints");
67+
_wheelHitPoint = toLowerANSI configName (_class#0);
68+
TRACE_3("wheel found [GM Config)]",_wheelName,_wheelHitPoint,_wheelHitPointSelection);
69+
};
70+
};
5771

5872
if (_vehicle isKindOf "Car") then {
5973
// Backup method, search for the closest hitpoint to the wheel's center selection pos.

addons/repair/functions/fnc_addRepairActions.sqf

+10-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
3838

3939
// get hitpoints of wheels with their selections
4040
([_vehicle] call EFUNC(common,getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
41+
private _isGM = 1 == getNumber (configOf _vehicle >> "isgmContent");
42+
if (_isGM) then { // the hitpoint selection does not properly overlap
43+
_hitPoints append _wheelHitPoints;
44+
_hitSelections append _wheelHitSelections;
45+
};
4146

4247
private _hitPointsAddedNames = [];
4348
private _hitPointsAddedStrings = [];
@@ -61,7 +66,11 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
6166
};
6267

6368
if (_selection in _wheelHitSelections) then {
64-
private _position = compile format ["_target selectionPosition ['%1', 'HitPoints', 'AveragePoint'];", _selection];
69+
private _position = if (_isGM) then {
70+
compile format ["_target selectionPosition ['%1', 'Memory', 'AveragePoint'];", _selection];
71+
} else {
72+
compile format ["_target selectionPosition ['%1', 'HitPoints', 'AveragePoint'];", _selection];
73+
};
6574

6675
TRACE_3("Adding Wheel Actions",_hitpoint,_forEachIndex,_selection);
6776

addons/repair/functions/fnc_getSelectionsToIgnore.sqf

+11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if (_type in _initializedClasses) exitWith {_initializedClasses get _type};
2525
private _vehCfg = configOf _vehicle;
2626
private _hitpointGroups = getArray (_vehCfg >> QGVAR(hitpointGroups));
2727
private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehicle, "commander", true])) apply {_x # 3};
28+
private _isGM = 1 == getNumber (configOf _vehicle >> "isgmContent");
2829

2930
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]];
3031
// get hitpoints of wheels with their selections
@@ -43,6 +44,16 @@ private _processedSelections = [];
4344
continue
4445
};
4546

47+
if (_isGM && {"wheel" in _selection}) then {
48+
TRACE_3("Skipping GM wheels",_hitpoint,_forEachIndex,_selection);
49+
/*#ifdef DEBUG_MODE_FULL
50+
systemChat format ["Skipping duplicate wheel, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
51+
#endif*/
52+
_indexesToIgnore pushBack _forEachIndex;
53+
_processedSelections pushBack _selection;
54+
continue
55+
};
56+
4657
if (_isWheelOrTrack && {_selection in _processedSelections || {_selection isEqualTo ""}}) then { // skip duplicate or empty selection wheel/track
4758
TRACE_3("Skipping duplicate Wheel/Track or empty selection",_hitpoint,_forEachIndex,_selection);
4859
/*#ifdef DEBUG_MODE_FULL

0 commit comments

Comments
 (0)