mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
work on repairing vehicles
This commit is contained in:
parent
68749136c9
commit
f72e171247
@ -1,6 +1,6 @@
|
||||
|
||||
class CfgVehicleClasses {
|
||||
class GVAR(items) {
|
||||
displayName = "ACE REPAIR ITEMS";
|
||||
displayName = "ACE";
|
||||
};
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
class ACE_MainActions { \
|
||||
class GVAR(Repair) { \
|
||||
displayName = "$STR_ACE_Repair_Repair"; \
|
||||
condition = ""; \
|
||||
condition = QUOTE([ARR_2(_this select 0, GVAR(engineerSetting_Repair))] call DFUNC(isEngineer)); \
|
||||
statement = "'show a hint with the hitpart damage'"; \
|
||||
runOnHover = 1; \
|
||||
showDisabled = 0; \
|
||||
|
@ -9,7 +9,9 @@ PREP(canReplaceWheel);
|
||||
PREP(doRemoveWheel);
|
||||
PREP(doRepair);
|
||||
PREP(doReplaceWheel);
|
||||
PREP(getPostRepairDamage);
|
||||
PREP(getWheelHitPointsWithSelections);
|
||||
PREP(isEngineer);
|
||||
PREP(moduleRepairSettings);
|
||||
PREP(normalizeHitPoints);
|
||||
PREP(removeWheel);
|
||||
|
@ -21,4 +21,6 @@ _hitPoint = _this select 2;
|
||||
|
||||
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint > 0}
|
||||
if !([_unit, GVAR(engineerSetting_Repair)] call FUNC(isEngineer)) exitWith {false};
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint > ([_unit] call FUNC(getPostRepairDamage))}
|
||||
|
@ -21,6 +21,8 @@ _hitPoint = _this select 2;
|
||||
|
||||
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
if !([_unit, GVAR(engineerSetting_Wheel)] call FUNC(isEngineer)) exitWith {false};
|
||||
|
||||
// check for a near wheel
|
||||
private "_wheel";
|
||||
_wheel = objNull;
|
||||
|
@ -31,7 +31,7 @@ if (_hitPointDamage >= 1) exitWith {};
|
||||
// spawn wheel
|
||||
private "_wheel";
|
||||
_wheel = ["ACE_Wheel", getPosASL _unit] call FUNC(spawnObject);
|
||||
_wheel setdamage _damage;
|
||||
_wheel setdamage _hitPointDamage;
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
||||
|
@ -11,10 +11,11 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicle", "_hitPoint", "_elapsedTime", "_totalTime"];
|
||||
private ["_unit", "_vehicle", "_hitPoint", "_elapsedTime", "_totalTime"];
|
||||
|
||||
_vehicle = _this select 0 select 0;
|
||||
_hitPoint = _this select 0 select 1;
|
||||
_unit = _this select 0 select 0;
|
||||
_vehicle = _this select 0 select 1;
|
||||
_hitPoint = _this select 0 select 2;
|
||||
|
||||
_elapsedTime = _this select 1;
|
||||
_totalTime = _this select 2;
|
||||
@ -27,7 +28,7 @@ _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
_hitPointDamage = _hitPointDamage - _hitPointDamage * (_elapsedTime / _totalTime);
|
||||
|
||||
// don't use negative values for damage
|
||||
_hitPointDamage = _hitPointDamage max 0;
|
||||
_hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage));
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
|
||||
|
11
addons/repair/functions/fnc_getPostRepairDamage.sqf
Normal file
11
addons/repair/functions/fnc_getPostRepairDamage.sqf
Normal file
@ -0,0 +1,11 @@
|
||||
// by comm2
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_unit";
|
||||
|
||||
_unit = _this select 0;
|
||||
|
||||
if ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold_Engineer)};
|
||||
if ([_unit, GVAR(engineerSetting_Repair)] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold)};
|
||||
|
||||
1
|
25
addons/repair/functions/fnc_isEngineer.sqf
Normal file
25
addons/repair/functions/fnc_isEngineer.sqf
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Author: Glowbal, KoffeinFlummi, commy2
|
||||
* Check if a unit is any engineer class
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Unit <OBJECT>
|
||||
* 1: Class <NUMBER> <OPTIONAL>
|
||||
*
|
||||
* ReturnValue:
|
||||
* Is in of medic class <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_engineerN", "_class"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_engineerN = if (count _this > 1) then {_this select 1} else {1};
|
||||
|
||||
_class = _unit getVariable [QGVAR(engineerClass),
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer")
|
||||
];
|
||||
|
||||
_class >= _engineerN min GVAR(engineerSetting_Repair)
|
@ -27,7 +27,7 @@ private ["_damage", "_time"];
|
||||
|
||||
_damage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
_time = 5 + 10 * _damage;
|
||||
_time = (5 + 10 * _damage) * ([1.5, 1] select ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer)));
|
||||
|
||||
// get string of the hitpoint
|
||||
private "_text";
|
||||
@ -40,7 +40,7 @@ if (isLocalized _text) then {
|
||||
};
|
||||
|
||||
// open the loading bar
|
||||
[_time, [_vehicle, _hitPoint], {_this call DFUNC(doRepair)}, {_this call DFUNC(doRepair)}, _text, {true}, []] call EFUNC(common,progressBar);
|
||||
[_time, [_unit, _vehicle, _hitPoint], {_this call DFUNC(doRepair)}, {_this call DFUNC(doRepair)}, _text, {true}, []] call EFUNC(common,progressBar);
|
||||
|
||||
// do animation
|
||||
[_unit] call EFUNC(common,goKneeling);
|
||||
|
Loading…
Reference in New Issue
Block a user