Merge branch '323cleanuphitpoints' into commoncleanup10

This commit is contained in:
commy2 2015-09-21 13:24:12 +02:00
commit 5adca6616d
4 changed files with 37 additions and 90 deletions

View File

@ -208,6 +208,7 @@ PREP(getConfigGunner);
PREP(getConfigCommander);
PREP(getHitPoints);
PREP(getHitPointsWithSelections);
PREP(getSelectionsWithoutHitPoints);
PREP(getReflectorsWithSelections);
PREP(getLightProperties);
PREP(getLightPropertiesWeapon);

View File

@ -1,7 +1,7 @@
/*
* Author: commy2
*
* Returns all hitpoints of any vehicle. Non unique hitpoints in turrets are ignored.
* Returns all hitpoints of any vehicle. Might contain duplicates if the turrets contain non unique hitpoints with different selection names.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
@ -11,46 +11,6 @@
*/
#include "script_component.hpp"
private ["_config", "_hitpoints", "_i"];
params ["_vehicle"];
PARAMS_1(_vehicle);
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_hitpoints = [];
// get all classes that can contain hitpoints
private "_hitpointClasses";
_hitpointClasses = [_config >> "HitPoints"];
{
private "_class";
_class = ([_config, _x] call FUNC(getTurretConfigPath)) >> "HitPoints";
if (isClass _class) then {
_hitpointClasses pushBack _class;
};
} forEach allTurrets _vehicle;
// iterate through all classes with hitpoints and their parents
{
private "_class";
_class = _x;
while {isClass _class} do {
for "_i" from 0 to (count _class - 1) do {
private "_entry";
_entry = configName (_class select _i);
if (!(_entry in _hitpoints) && {!isNil {_vehicle getHitPointDamage _entry}}) then {
_hitpoints pushBack _entry;
};
};
_class = inheritsFrom _class;
};
} forEach _hitpointClasses;
_hitpoints
(getAllHitPointsDamage _vehicle select 0) - [""]

View File

@ -11,51 +11,9 @@
*/
#include "script_component.hpp"
private ["_config", "_hitpoints", "_selections", "_i"];
params ["_vehicle"];
PARAMS_1(_vehicle);
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_hitpoints = [];
_selections = [];
// get all classes that can contain hitpoints
private "_hitpointClasses";
_hitpointClasses = [_config >> "HitPoints"];
{
private "_class";
_class = ([_config, _x] call FUNC(getTurretConfigPath)) >> "HitPoints";
if (isClass _class) then {
_hitpointClasses pushBack _class;
};
} forEach allTurrets _vehicle;
// iterate through all classes with hitpoints and their parents
{
private "_class";
_class = _x;
while {isClass _class} do {
for "_i" from 0 to (count _class - 1) do {
if (isClass (_class select _i)) then {
private ["_entry", "_selection"];
_entry = configName (_class select _i);
_selection = getText (_class select _i >> "name");
if (!(_selection in _selections) && {!isNil {_vehicle getHit _selection}}) then {
_hitpoints pushBack _entry;
_selections pushBack _selection;
};
};
};
_class = inheritsFrom _class;
};
} forEach _hitpointClasses;
[_hitpoints, _selections]
private "_hitPointsWithSelections";
_hitPointsWithSelections = getAllHitPointsDamage _vehicle;
_hitPointsWithSelections resize 2;
_hitPointsWithSelections

View File

@ -0,0 +1,28 @@
/*
* Author: commy2
*
* Returns all damageable selections without hitpoints of any vehicle.
*
* Arguments:
* 0: A vehicle, not the classname (Object)
*
* Return Value:
* The selections without hitpoints, i.e. reflectors. (Array)
*/
#include "script_component.hpp"
params ["_vehicle"];
private ["_hitPointsFull", "_allSelectionsWithoutHitpoints"];
_hitPointsFull = getAllHitPointsDamage _vehicle;
_allSelectionsWithoutHitpoints = [];
{
if (_x == "") then {
_allSelectionsWithoutHitpoints pushBack (_hitPointsFull select 1 select _forEachIndex);
};
} forEach (_hitPointsFull select 0);
_allSelectionsWithoutHitpoints