2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-03-10 18:42:21 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2015-08-16 18:14:54 +00:00
|
|
|
* Sets the structural damage of a vehicle without altering the hitPoints, requires local vehicle.
|
2015-03-10 18:42:21 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-16 18:14:54 +00:00
|
|
|
* 0: Local Vehicle to Damage <OBJECT>
|
|
|
|
* 1: Total Damage <NUMBER>
|
2015-03-10 18:42:21 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-16 18:14:54 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [vehicle, 0.5] call ace_repair_fnc_setDamage
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-03-10 18:42:21 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-09 06:54:44 +00:00
|
|
|
params ["_vehicle", "_damage"];
|
|
|
|
TRACE_2("params",_vehicle,_damage);
|
2015-03-10 18:42:21 +00:00
|
|
|
|
|
|
|
// can't execute all commands if the vehicle isn't local. exit here.
|
|
|
|
if !(local _vehicle) exitWith {};
|
|
|
|
|
|
|
|
// save array with damage values of all hitpoints
|
2016-02-20 22:58:45 +00:00
|
|
|
(getAllHitPointsDamage _vehicle) params [["_allHitPoints", []], ["_allHitPointsSelections", []], ["_allHitPointDamages", []]];
|
2015-03-10 18:42:21 +00:00
|
|
|
|
|
|
|
// set damage of the vehicle
|
2019-05-03 15:09:16 +00:00
|
|
|
private _damageDisabled = !isDamageAllowed _vehicle;
|
|
|
|
if (_damageDisabled) then {
|
2019-05-03 15:03:17 +00:00
|
|
|
_vehicle allowDamage true;
|
|
|
|
};
|
|
|
|
|
2015-03-10 18:42:21 +00:00
|
|
|
_vehicle setDamage _damage;
|
|
|
|
|
|
|
|
// restore original hitpoint damage values
|
|
|
|
{
|
2016-02-20 22:58:45 +00:00
|
|
|
_vehicle setHitIndex [_forEachIndex, _x];
|
|
|
|
} forEach _allHitPointDamages;
|
2015-03-11 22:53:08 +00:00
|
|
|
|
|
|
|
// normalize hitpoints
|
|
|
|
[_vehicle] call FUNC(normalizeHitPoints);
|
2019-05-03 15:09:16 +00:00
|
|
|
|
|
|
|
if (_damageDisabled) then {
|
|
|
|
_vehicle allowDamage false;
|
|
|
|
};
|