Added hitpoint groups framework

This commit is contained in:
jonpas 2015-08-24 04:17:24 +02:00
parent 27d974687e
commit f2bda7c434
4 changed files with 33 additions and 10 deletions

View File

@ -285,7 +285,10 @@ class CfgVehicles {
transportRepair = 0;
};
class Heli_Transport_04_base_F;
class Helicopter_Base_H;
class Heli_Transport_04_base_F: Helicopter_Base_H {
GVAR(hitpointGroup[]) = {"Glass_1_hitpoint", "Glass_2_hitpoint", "Glass_3_hitpoint", "Glass_4_hitpoint", "Glass_5_hitpoint", "Glass_6_hitpoint", "Glass_7_hitpoint", "Glass_8_hitpoint", "Glass_9_hitpoint", "Glass_10_hitpoint", "Glass_11_hitpoint", "Glass_12_hitpoint", "Glass_13_hitpoint", "Glass_14_hitpoint", "Glass_15_hitpoint", "Glass_16_hitpoint", "Glass_17_hitpoint", "Glass_18_hitpoint", "Glass_19_hitpoint", "Glass_20_hitpoint"};
};
class O_Heli_Transport_04_repair_F: Heli_Transport_04_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
@ -303,12 +306,19 @@ class CfgVehicles {
transportRepair = 0;
};
class Offroad_01_base_F;
class Car_F;
class Offroad_01_base_F: Car_F {
GVAR(hitpointGroup[]) = {"HitGlass1", "HitGlass2"};
};
class Offroad_01_repair_base_F: Offroad_01_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class MRAP_01_base_F: Car_F {
GVAR(hitpointGroup[]) = {"HitGlass1", "HitGlass2", "HitGlass3", "HitGlass4", "HitGlass5", "HitGlass6"};
};
class B_Truck_01_mover_F;
class B_Truck_01_Repair_F: B_Truck_01_mover_F {
GVAR(canRepair) = 1;

View File

@ -75,8 +75,11 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
} else {
// exit if the hitpoint is in the blacklist, e.g. glasses
if (_x in IGNORED_HITPOINTS) exitWith {};
private "_hitpointGroup";
// Exit if the hitpoint is in group and not main group hitpoint (which gets added as group repair action)
_hitpointGroup = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroup);
_hitpointGroup = if (isArray _hitpointGroup) then {getArray _hitpointGroup} else {[]};
if (count _hitpointGroup > 0 && {_x in _hitpointGroup} && {_x != _hitpointGroup select 0}) exitWith {};
// exit if the hitpoint is virtual
if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {};

View File

@ -17,11 +17,11 @@
*/
#include "script_component.hpp"
private ["_hitPointDamage", "_text", "_hitpointGroup"];
params ["_unit", "_vehicle", "_hitPoint"];
TRACE_3("params",_unit,_vehicle,_hitPoint);
// get current hitpoint damage
private "_hitPointDamage";
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
_hitPointDamage = _hitPointDamage - 0.5;
@ -31,9 +31,23 @@ _hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage));
// raise event to set the new hitpoint damage
["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
// Repair the rest in the group (don't need to worry about specific damage as it's not checked)
_hitpointGroup = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroup);
_hitpointGroup = if (isArray _hitpointGroup) then {getArray _hitpointGroup} else {[]};
if (count _hitpointGroup > 0) then {
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitpoints"];
_hitpointGroup deleteAt 0; // Remove main group hitpoint
{
if (_x in _hitpoints) then {
_vehicle setHitPointDamage [_x, 0];
} else {
diag_log text format ["[ACE] ERROR: Invalid hitpoint %1 in hitpointGroup of %2", _x, _vehicle];
};
} forEach _hitpointGroup;
};
// display text message if enabled
if (GVAR(DisplayTextOnRepair)) then {
private "_text";
_text = format ["STR_ACE_Repair_%1", _hitPoint];
if (isLocalized _text) then {

View File

@ -10,7 +10,3 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define IGNORED_HITPOINTS ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitGlass7","HitGlass8","HitGlass9","HitGlass10","HitGlass11","HitGlass12","HitGlass13","HitGlass14","HitGlass15","HitRGlass","HitLGlass"]
// #define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"];