mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
eb53e7a2fe
* tools - handle header sub indexs for arguements * convert remaining * Update coding-guidelines.md
48 lines
1.2 KiB
Plaintext
48 lines
1.2 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: commy2
|
|
* Sets the structural damage of a vehicle without altering the hitPoints, requires local vehicle.
|
|
*
|
|
* Arguments:
|
|
* 0: Local Vehicle to Damage <OBJECT>
|
|
* 1: Total Damage <NUMBER>
|
|
* 2: Use destruction effects <BOOL>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [vehicle, 0.5] call ace_repair_fnc_setDamage
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_vehicle", "_damage", ["_useEffects", false]];
|
|
TRACE_2("params",_vehicle,_damage);
|
|
|
|
// 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
|
|
(getAllHitPointsDamage _vehicle) params [["_allHitPoints", []], ["_allHitPointsSelections", []], ["_allHitPointDamages", []]];
|
|
|
|
// set damage of the vehicle
|
|
private _damageDisabled = !isDamageAllowed _vehicle;
|
|
if (_damageDisabled) then {
|
|
_vehicle allowDamage true;
|
|
};
|
|
|
|
_vehicle setDamage [_damage, _useEffects];
|
|
|
|
// restore original hitpoint damage values
|
|
{
|
|
_vehicle setHitIndex [_forEachIndex, _x];
|
|
} forEach _allHitPointDamages;
|
|
|
|
// normalize hitpoints
|
|
[_vehicle] call FUNC(normalizeHitPoints);
|
|
|
|
if (_damageDisabled) then {
|
|
_vehicle allowDamage false;
|
|
};
|