2015-03-10 20:49:53 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-16 18:14:54 +00:00
|
|
|
* 0: Unit that does the repairing <OBJECT>
|
|
|
|
* 1: Vehicle to repair <OBJECT>
|
|
|
|
* 2: Selected hitpoint <STRING>
|
2015-03-10 20:49:53 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-16 18:14:54 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doRepair
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-03-10 20:49:53 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-24 02:17:24 +00:00
|
|
|
private ["_hitPointDamage", "_text", "_hitpointGroup"];
|
2015-08-09 15:23:32 +00:00
|
|
|
params ["_unit", "_vehicle", "_hitPoint"];
|
|
|
|
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
2015-03-10 20:49:53 +00:00
|
|
|
|
|
|
|
// get current hitpoint damage
|
|
|
|
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
|
|
|
|
2015-08-09 15:23:32 +00:00
|
|
|
_hitPointDamage = _hitPointDamage - 0.5;
|
2015-03-10 20:49:53 +00:00
|
|
|
// don't use negative values for damage
|
2015-04-22 19:01:22 +00:00
|
|
|
_hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage));
|
2015-03-10 20:49:53 +00:00
|
|
|
|
|
|
|
// raise event to set the new hitpoint damage
|
|
|
|
["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
|
2015-03-10 21:52:44 +00:00
|
|
|
|
2015-08-24 18:03:11 +00:00
|
|
|
// Get hitpoint groups if available
|
2015-08-24 18:12:45 +00:00
|
|
|
_hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroups);
|
2015-08-24 18:03:11 +00:00
|
|
|
_hitpointGroup = [];
|
|
|
|
if (isArray _hitpointGroupConfig) then {
|
2015-08-26 20:51:41 +00:00
|
|
|
// Retrieve group if current hitpoint is leader of any
|
2015-08-24 02:17:24 +00:00
|
|
|
{
|
2015-08-24 18:03:11 +00:00
|
|
|
if (_x select 0 == _hitPoint) exitWith {
|
|
|
|
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitpoints"];
|
2015-08-26 20:51:41 +00:00
|
|
|
// Set all sub-group hitpoints' damage to 0, if a hitpoint is invalid print RPT error
|
2015-08-24 18:03:11 +00:00
|
|
|
{
|
|
|
|
if (_x in _hitpoints) then {
|
|
|
|
["setVehicleHitPointDamage", _vehicle, [_vehicle, _x, 0]] call EFUNC(common,targetEvent);
|
|
|
|
} else {
|
|
|
|
diag_log text format ["[ACE] ERROR: Invalid hitpoint %1 in hitpointGroups of %2", _x, _vehicle];
|
|
|
|
};
|
|
|
|
|
|
|
|
} forEach (_x select 1);
|
2015-08-24 02:17:24 +00:00
|
|
|
};
|
2015-08-24 18:03:11 +00:00
|
|
|
} forEach (getArray _hitpointGroupConfig);
|
2015-08-24 02:17:24 +00:00
|
|
|
};
|
|
|
|
|
2015-03-10 21:52:44 +00:00
|
|
|
// display text message if enabled
|
|
|
|
if (GVAR(DisplayTextOnRepair)) then {
|
2015-08-24 18:58:54 +00:00
|
|
|
private ["_textLocalized", "_textDefault"];
|
2015-03-10 21:52:44 +00:00
|
|
|
|
2015-08-24 18:58:54 +00:00
|
|
|
// Find localized string
|
|
|
|
_textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointDamage > 0));
|
|
|
|
_textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointDamage > 0));
|
|
|
|
([_hitPoint, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"];
|
2015-03-10 21:52:44 +00:00
|
|
|
|
2015-08-24 03:24:25 +00:00
|
|
|
// Display text
|
2015-03-10 21:52:44 +00:00
|
|
|
[_text] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|