ACE3/addons/repair/functions/fnc_getFullRepairTime.sqf
Grim 04e41a4d5a
Repair - Make Full Repair Time dependent on vehicle damage (#8417)
* add variable full repair time

* enable compile cache

* Fix stupid

* whoops

* incremental full repair

* cleanup function header

* ignore hitpoints inFullRepairProgress

* fix getHitPointsToIgnore

* final cleanup

* don't show repair hint while doing full repair

* make this all work

* fix stupid

put this back in place

* Add setting for speedup when near repair facility/vehicle

enable compile cache

* refactor near repair facility/vehicle checks

* remove skipping hint from do_repair

better for feedback this way

* git diff stuff

* use functions directly in ACE_Repair.hpp

* add check for vehicle proximity

* add a new line

* switch to multiply by setting instead

* speed boost settings, remove exit addRepairActions

* stringtable

* remove speed boost settings

* fix things, add forceDisplayName

* name in function header

* fix TRACE

* add animation looping

* remove systemChat

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* add time coefficient setting

* move to repair category

* time coefficient max and default values

---------

Co-authored-by: Salluci <69561145+Salluci@users.noreply.github.com>
Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
2023-07-06 06:52:04 +03:00

43 lines
1.2 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: LinkIsGrim
* Calculates the Full Repair time based on the amount of hitpoints to repair
*
* Arguments:
* 0: Engineer <OBJECT>
* 1: Vehicle <OBJECT>
*
* Return Value:
* Repair Time <NUMBER>
*
* Example:
* [player, vehicle] call ace_repair_fnc_getFullRepairTime
*
* Public: No
*/
params ["_engineer", "_vehicle"];
private _allHitPointsDamage = getAllHitPointsDamage _vehicle;
_allHitPointsDamage params ["_hitPoints", "", "_damageValues"];
private _hitPointsToIgnore = [_vehicle] call FUNC(getHitPointsToIgnore);
private _repairsNeeded = 0;
private _doExtraRepair = false;
{
if (_x <= 0) then {continue}; // skip hitpoints that don't need repairs
private _hitPoint = _hitPoints select _forEachIndex;
if (_hitPoint in _hitPointsToIgnore) then { // only add extra repair for ignore hitpoints if they're damaged
_doExtraRepair = true;
continue
};
_repairsNeeded = _repairsNeeded + ceil (_x / 0.5); // repair is capped at 0.5 in FUNC(doRepair)
} forEach _damageValues;
if (_doExtraRepair) then {
_repairsNeeded = _repairsNeeded + 1;
};
_repairsNeeded * GVAR(miscRepairTime) * GVAR(timeCoefficientFullRepair) // return