mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added support for multiple groups, Fixed check group damage returning true even if hitpoint not in a group
This commit is contained in:
parent
144af2ed17
commit
78e7565121
@ -287,7 +287,7 @@ class CfgVehicles {
|
||||
|
||||
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"};
|
||||
GVAR(hitpointGroups[]) = { {"HitEngine", {"HitEngine1", "HitEngine2"}}, {"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;
|
||||
@ -308,7 +308,7 @@ class CfgVehicles {
|
||||
|
||||
class Car_F;
|
||||
class Offroad_01_base_F: Car_F {
|
||||
GVAR(hitpointGroup[]) = {"HitGlass1", "HitGlass2"};
|
||||
GVAR(hitpointGroups[]) = { {"HitGlass1", {"HitGlass2"}} };
|
||||
};
|
||||
class Offroad_01_repair_base_F: Offroad_01_base_F {
|
||||
GVAR(canRepair) = 1;
|
||||
@ -316,7 +316,7 @@ class CfgVehicles {
|
||||
};
|
||||
|
||||
class MRAP_01_base_F: Car_F {
|
||||
GVAR(hitpointGroup[]) = {"HitGlass1", "HitGlass2", "HitGlass3", "HitGlass4", "HitGlass5", "HitGlass6"};
|
||||
GVAR(hitpointGroups[]) = { {"HitGlass1", {"HitGlass2", "HitGlass3", "HitGlass4", "HitGlass5", "HitGlass6"}} };
|
||||
};
|
||||
|
||||
class B_Truck_01_mover_F;
|
||||
|
@ -75,11 +75,27 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
|
||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
|
||||
} else {
|
||||
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 {};
|
||||
private ["_hitpointGroupConfig", "_inHitpointSubGroup", "_currentHitpoint"];
|
||||
|
||||
// Get hitpoint groups if available
|
||||
_hitpointGroupConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroups);
|
||||
_inHitpointSubGroup = false;
|
||||
if (isArray _hitpointGroupConfig) then {
|
||||
// Loop through hitpoint groups
|
||||
_currentHitpoint = _x;
|
||||
{
|
||||
// Loop through sub-group
|
||||
{
|
||||
// Current hitpoint is in a sub-group, set it so
|
||||
if (_x == _currentHitpoint) exitWith {
|
||||
_inHitpointSubGroup = true;
|
||||
};
|
||||
} forEach (_x select 1);
|
||||
} forEach (getArray _hitpointGroupConfig);
|
||||
};
|
||||
|
||||
// Exit if current hitpoint is not a group leader (only they get actions)
|
||||
if (_inHitpointSubGroup) exitWith {};
|
||||
|
||||
// exit if the hitpoint is virtual
|
||||
if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {};
|
||||
|
@ -17,19 +17,29 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_hitpointGroup", "_postRepairDamage", "_return"];
|
||||
private ["_hitpointGroupConfig", "_hitpointGroup", "_postRepairDamage", "_return"];
|
||||
params ["_caller", "_target", "_hitPoint"];
|
||||
|
||||
// Check hitpoint group
|
||||
_hitpointGroup = configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hitpointGroup);
|
||||
_hitpointGroup = if (isArray _hitpointGroup) then {getArray _hitpointGroup} else {[]};
|
||||
|
||||
if !(_hitPoint in _hitpointGroup) then {
|
||||
_hitpointGroup pushBack _hitPoint;
|
||||
// Get hitpoint groups if available
|
||||
_hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hitpointGroup);
|
||||
_hitpointGroup = [];
|
||||
if (isArray _hitpointGroupConfig) then {
|
||||
// Loop through hitpoint groups
|
||||
{
|
||||
// Exit using found hitpoint group if this hitpoint is leader of any
|
||||
if (_x select 0 == _hitPoint) exitWith {
|
||||
_hitpointGroup = _x select 1;
|
||||
};
|
||||
} forEach (getArray _hitpointGroupConfig);
|
||||
};
|
||||
|
||||
// Add current hitpoint to the group
|
||||
_hitpointGroup pushBack _hitPoint;
|
||||
|
||||
// Get post repair damage
|
||||
_postRepairDamage = [_caller] call FUNC(getPostRepairDamage);
|
||||
|
||||
// Return true if damage can be repaired on any hitpoint in the group, else false
|
||||
_return = false;
|
||||
{
|
||||
if ((_target getHitPointDamage _x) > _postRepairDamage) exitWith {
|
||||
|
@ -31,19 +31,27 @@ _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 (no specific damage, main hitpoint is enough)
|
||||
_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
|
||||
// Get hitpoint groups if available
|
||||
_hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroup);
|
||||
_hitpointGroup = [];
|
||||
if (isArray _hitpointGroupConfig) then {
|
||||
// Loop through hitpoint groups
|
||||
{
|
||||
// Exit using found hitpoint group if this hitpoint is leader of any
|
||||
if (_x select 0 == _hitPoint) exitWith {
|
||||
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitpoints"];
|
||||
// Loop through the found group
|
||||
{
|
||||
// If hitpoint is valid set damage to 0, else print RPT error
|
||||
if (_x in _hitpoints) then {
|
||||
_vehicle setHitPointDamage [_x, 0];
|
||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _x, 0]] call EFUNC(common,targetEvent);
|
||||
} else {
|
||||
diag_log text format ["[ACE] ERROR: Invalid hitpoint %1 in hitpointGroup of %2", _x, _vehicle];
|
||||
diag_log text format ["[ACE] ERROR: Invalid hitpoint %1 in hitpointGroups of %2", _x, _vehicle];
|
||||
};
|
||||
} forEach _hitpointGroup;
|
||||
|
||||
} forEach (_x select 1);
|
||||
};
|
||||
} forEach (getArray _hitpointGroupConfig);
|
||||
};
|
||||
|
||||
// display text message if enabled
|
||||
|
Loading…
Reference in New Issue
Block a user