mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
add function to start repair action
This commit is contained in:
parent
8e2f478534
commit
d5fd0fcf7d
@ -2,6 +2,8 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(doRepair);
|
||||
PREP(repairVehicle);
|
||||
PREP(setDamage);
|
||||
PREP(setHitPointDamage);
|
||||
|
||||
|
33
addons/repair/functions/fnc_doRepair.sqf
Normal file
33
addons/repair/functions/fnc_doRepair.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
|
||||
*
|
||||
* Arguments:
|
||||
* Stuff from progress bar.
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicle", "_hitPoint", "_elapsedTime", "_totalTime"];
|
||||
|
||||
_vehicle = _this select 0 select 0;
|
||||
_hitPoint = _this select 0 select 1;
|
||||
|
||||
_elapsedTime = _this select 1;
|
||||
_totalTime = _this select 2;
|
||||
|
||||
// get current hitpoint damage
|
||||
private "_hitPointDamage";
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
// subtract repaired damage
|
||||
_hitPointDamage = _hitPointDamage - _hitPointDamage * (_elapsedTime / _totalTime);
|
||||
|
||||
// don't use negative values for damage
|
||||
_hitPointDamage = _hitPointDamage max 0;
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
|
37
addons/repair/functions/fnc_repairVehicle.sqf
Normal file
37
addons/repair/functions/fnc_repairVehicle.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Start a repair action and open progress bar.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing (Object)
|
||||
* 1: vehicle to repair (Object)
|
||||
* 2: Selected hitpoint (String)
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_vehicle", "_hitPoint"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_vehicle = _this select 1;
|
||||
_hitPoint = _this select 2;
|
||||
|
||||
// exit if not a valid hitpoint
|
||||
if !(_hitPoint in ([_vehicle] call EFUNC(common,getHitPoints))) exitWith {};
|
||||
|
||||
// calculate time to fully repair the hitpoint
|
||||
private ["_damage", "_time"];
|
||||
|
||||
_damage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
_time = 5 * _damage;
|
||||
|
||||
// get string of the hitpoint
|
||||
private "_text";
|
||||
_text = "Repair placeholder";
|
||||
|
||||
// open the loading bar
|
||||
[_time, [_vehicle, _hitPoint], DFUNC(doRepair), DFUNC(doRepair), _text, {true}, []] call EFUNC(common,progressBar);
|
Loading…
Reference in New Issue
Block a user