Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ PREP(getWeaponAzimuthAndInclination);
PREP(getWeaponIndex);
PREP(getWeaponState);
PREP(getWeight);
PREP(getWheelHitPointsWithSelections);
PREP(getWindDirection);
PREP(getZoom);
PREP(goKneeling);
Expand Down
1 change: 1 addition & 0 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PREP_RECOMPILE_END;
GVAR(syncedEvents) = createHashMap;
GVAR(showHudHash) = createHashMap;
GVAR(vehicleIconCache) = createHashMap; // for getVehicleIcon
GVAR(wheelSelections) = createHashMap;

GVAR(blockItemReplacement) = false;

Expand Down
104 changes: 104 additions & 0 deletions addons/common/functions/fnc_getWheelHitPointsWithSelections.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#include "..\script_component.hpp"
/*
* Author: commy2, johnb43
* Returns the wheel hitpoints and their selections.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* 0: Wheel hitpoints <ARRAY>
* 1: Wheel hitpoint selections <ARRAY>
*
* Example:
* cursorObject call ace_common_fnc_getWheelHitPointsWithSelections
*
* Public: No
*/

params ["_vehicle"];
TRACE_1("params",_vehicle);

// TODO: Fix for GM vehicles
GVAR(wheelSelections) getOrDefaultCall [typeOf _vehicle, {
// Get the vehicles wheel config
private _wheels = configOf _vehicle >> "Wheels";

if (isClass _wheels) then {
// Get all hitpoints and selections
(getAllHitPointsDamage _vehicle) params ["_hitPoints", "_hitPointSelections"];

// Get all wheels and read selections from config
_wheels = "true" configClasses _wheels;

private _wheelHitPoints = [];
private _wheelHitPointSelections = [];

{
private _wheelName = configName _x;
private _wheelCenter = getText (_x >> "center");
private _wheelBone = getText (_x >> "boneName");
private _wheelBoneNameResized = _wheelBone select [0, 9]; // Count "wheel_X_Y"; // this is a requirement for physx. Should work for all addon vehicles.

TRACE_4("",_wheelName,_wheelCenter,_wheelBone,_wheelBoneNameResized);

private _wheelHitPoint = "";
private _wheelHitPointSelection = "";

// Commy's orginal method
{
if ((_wheelBoneNameResized != "") && {_x find _wheelBoneNameResized == 0}) exitWith { // same as above. Requirement for physx.
_wheelHitPoint = _hitPoints select _forEachIndex;
_wheelHitPointSelection = _hitPointSelections select _forEachIndex;
TRACE_2("wheel found [Orginal]",_wheelName,_wheelHitPoint);
};
} forEach _hitPointSelections;


if (_vehicle isKindOf "Car") then {
// Backup method, search for the closest hitpoint to the wheel's center selection pos.
// Ref #2742 - RHS's HMMWV
if (_wheelHitPoint == "") then {
private _wheelCenterPos = _vehicle selectionPosition _wheelCenter;
if (_wheelCenterPos isEqualTo [0, 0, 0]) exitWith {TRACE_1("no center?",_wheelCenter);};


private _bestDist = 99;
private _bestIndex = -1;
{
if (_x != "") then {
// Filter out things that definitly aren't wheeels (#3759)
if ((toLowerANSI (_hitPoints select _forEachIndex)) in ["hitengine", "hitfuel", "hitbody"]) exitWith {TRACE_1("filter",_x)};
private _xPos = _vehicle selectionPosition _x;
if (_xPos isEqualTo [0, 0, 0]) exitWith {};
private _xDist = _wheelCenterPos distance _xPos;
if (_xDist < _bestDist) then {
_bestIndex = _forEachIndex;
_bestDist = _xDist;
};
};
} forEach _hitPointSelections;

TRACE_2("closestPoint",_bestDist,_bestIndex);
if (_bestIndex != -1) then {
_wheelHitPoint = _hitPoints select _bestIndex;
_wheelHitPointSelection = _hitPointSelections select _bestIndex;
TRACE_2("wheel found [Backup]",_wheelName,_wheelHitPoint);
};
};
};

if ((_wheelHitPoint != "") && {_wheelHitPointSelection != ""}) then {
_wheelHitPoints pushBack _wheelHitPoint;
_wheelHitPointSelections pushBack _wheelHitPointSelection;
};
} forEach _wheels;

[_wheelHitPoints, _wheelHitPointSelections]
} else {
// Exit with nothing if the vehicle has no wheels class
TRACE_1("No Wheels",_wheels);

[[], []]
}
}, true] // return
28 changes: 6 additions & 22 deletions addons/grenades/functions/fnc_damageEngineAndWheels.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,22 @@
*/

params ["_vehicle", "_position"];
TRACE_1("damageWheelsAndEngine",_vehicle);
TRACE_2("damageWheelsAndEngine",_vehicle,_position);

// Vehicle needs to be local and vulnerable
if !(local _vehicle && {isDamageAllowed _vehicle}) exitWith {};

// Burn tires
private _fnc_isWheelHitPoint = {
params ["_selectionName"];
// Wheels must use a selection named "wheel_X_Y_steering" for PhysX to work
_selectionName select [0, 6] == "wheel_" && {
_selectionName select [count _selectionName - 9] == "_steering"
} // return
};

private _config = configOf _vehicle >> "HitPoints";

{
private _wheelSelection = getText (_config >> _x >> "name");

if (_wheelSelection call _fnc_isWheelHitPoint) then {
private _wheelPosition = _vehicle modelToWorld (_vehicle selectionPosition _wheelSelection);

if (_position distance _wheelPosition < EFFECT_SIZE * 2) then {
_vehicle setHit [_wheelSelection, 1];
};
// If wheel is close enough to incendiary, burn it
if (_position distance (_vehicle modelToWorld (_vehicle selectionPosition _x)) < EFFECT_SIZE * 2) then {
_vehicle setHit [_x, 1];
};
} forEach (getAllHitPointsDamage _vehicle param [0, []]);
} forEach ((_vehicle call EFUNC(common,getWheelHitPointsWithSelections)) select 1);

// Burn car engines only
if (_vehicle isKindOf "Wheeled_APC_F") exitWith {};

private _engineSelection = getText (_config >> "HitEngine" >> "name");
private _engineSelection = getText (configOf _vehicle >> "HitPoints" >> "HitEngine" >> "name");
private _enginePosition = _vehicle modelToWorld (_vehicle selectionPosition _engineSelection);

if (_position distance _enginePosition < EFFECT_SIZE * 2) then {
Expand Down
1 change: 0 additions & 1 deletion addons/repair/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ PREP(getSelectionsToIgnore);
PREP(getPatchWheelTime);
PREP(getPostRepairDamage);
PREP(getRepairItems);
PREP(getWheelHitPointsWithSelections);
PREP(hasItems);
PREP(isEngineer);
PREP(isInRepairFacility);
Expand Down
3 changes: 2 additions & 1 deletion addons/repair/dev/draw_showRepairInfo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#include "..\script_component.hpp"

addMissionEventHandler ["Draw3D", {
if (isGamePaused) exitWith {};
if !((cursorObject isKindOf "Car") || (cursorObject isKindOf "Tank") || (cursorObject isKindOf "Air")) exitWith {};
private _config = configOf cursorObject;

private _hitpointPositions = getArray (_config >> QGVAR(hitpointPositions));
private _hitpointGroups = getArray (_config >> QGVAR(hitpointGroups));

(getAllHitPointsDamage cursorObject) params [["_hitPoints", []], ["_hitSelections", []]];
([cursorObject] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
([cursorObject] call EFUNC(common,getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];

private _output = [];

Expand Down
2 changes: 1 addition & 1 deletion addons/repair/functions/fnc_addRepairActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private _selectionsToIgnore = _vehicle call FUNC(getSelectionsToIgnore);
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]]; // Since 1.82 these are all lower case

// get hitpoints of wheels with their selections
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
([_vehicle] call EFUNC(common,getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];

private _hitPointsAddedNames = [];
private _hitPointsAddedStrings = [];
Expand Down
2 changes: 1 addition & 1 deletion addons/repair/functions/fnc_getSelectionsToIgnore.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi

(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]];
// get hitpoints of wheels with their selections
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
([_vehicle] call EFUNC(common,getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];

private _indexesToIgnore = [];
private _processedSelections = [];
Expand Down
97 changes: 0 additions & 97 deletions addons/repair/functions/fnc_getWheelHitPointsWithSelections.sqf

This file was deleted.