Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair - Fix taking wheels from invincible vehicles #6976

Merged
merged 2 commits into from
May 11, 2019
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
16 changes: 15 additions & 1 deletion addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,23 @@ if (isServer) then {
[QGVAR(playActionNow), {(_this select 0) playActionNow (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(switchMove), {(_this select 0) switchMove (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVectorDirAndUp), {(_this select 0) setVectorDirAndUp (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVanillaHitPointDamage), {(_this select 0) setHitPointDamage (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(addWeaponItem), {(_this select 0) addWeaponItem [(_this select 1), (_this select 2)]}] call CBA_fnc_addEventHandler;

[QGVAR(setVanillaHitPointDamage), {
params ["_object", "_hitPointAnddamage"];
private _damageDisabled = !isDamageAllowed _object;

if (_damageDisabled) then {
_object allowDamage true;
};

_object setHitPointDamage _hitPointAnddamage;

if (_damageDisabled) then {
_object allowDamage false;
};
}] call CBA_fnc_addEventHandler;

// Request framework
[QGVAR(requestCallback), FUNC(requestCallback)] call CBA_fnc_addEventHandler;
[QGVAR(receiveRequest), FUNC(receiveRequest)] call CBA_fnc_addEventHandler;
Expand Down
9 changes: 9 additions & 0 deletions addons/medical_engine/functions/fnc_setStructuralDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ if (!local _unit) exitWith {

private _hitPointDamages = getAllHitPointsDamage _unit param [2, []];

private _damageDisabled = !isDamageAllowed _unit;
if (_damageDisabled) then {
_unit allowDamage true;
};

_unit setDamage _damage;

{
_unit setHitIndex [_forEachIndex, _x];
} forEach _hitPointDamages;

if (_damageDisabled) then {
_unit allowDamage false;
};
15 changes: 14 additions & 1 deletion addons/repair/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@
[QGVAR(setVehicleHitPointDamage), {_this call FUNC(setHitPointDamage)}] call CBA_fnc_addEventHandler;

// wheels
[QGVAR(setWheelHitPointDamage), {(_this select 0) setHitPointDamage [_this select 1, _this select 2]}] call CBA_fnc_addEventHandler;
[QGVAR(setWheelHitPointDamage), {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could replace use of this event with QEGVAR(common,setVanillaHitPointDamage)

params ["_object", "_hitPoint", "_damage"];
private _damageDisabled = !isDamageAllowed _object;

if (_damageDisabled) then {
_object allowDamage true;
};

_object setHitPointDamage [_hitPoint, _damage];

if (_damageDisabled) then {
_object allowDamage false;
};
}] call CBA_fnc_addEventHandler;
9 changes: 9 additions & 0 deletions addons/repair/functions/fnc_setDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ if !(local _vehicle) exitWith {};
(getAllHitPointsDamage _vehicle) params [["_allHitPoints", []], ["_allHitPointsSelections", []], ["_allHitPointDamages", []]];

// set damage of the vehicle
private _damageDisabled = !isDamageAllowed _vehicle;
if (_damageDisabled) then {
_vehicle allowDamage true;
};

_vehicle setDamage _damage;

// restore original hitpoint damage values
Expand All @@ -35,3 +40,7 @@ _vehicle setDamage _damage;

// normalize hitpoints
[_vehicle] call FUNC(normalizeHitPoints);

if (_damageDisabled) then {
_vehicle allowDamage false;
};
9 changes: 9 additions & 0 deletions addons/repair/functions/fnc_setHitPointDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ if (_hitPointDamageSumOld > 0) then {
TRACE_5("structuralDamage",_damageOld,_damageNew,_hitPointDamageRepaired,_hitPointDamageSumOld,_realHitpointCount);

// set new structural damage value
private _damageDisabled = !isDamageAllowed _vehicle;
if (_damageDisabled) then {
_vehicle allowDamage true;
};

_vehicle setDamage [_damageNew, _useEffects];

//Repair the hitpoint in the damages array:
Expand All @@ -74,3 +79,7 @@ _allHitPointDamages set [_hitPointIndex, _hitPointDamage];

// normalize hitpoints
[_vehicle] call FUNC(normalizeHitPoints);

if (_damageDisabled) then {
_vehicle allowDamage false;
};