Jump to content
Sign in to follow this  
Ed!

Getting configfile hitpoints

Recommended Posts

Im trying to get all the hitpoints for a truck, but it returns 0. When I look in the config browser, it is there.

count(configfile >> "CfgVehicles" >> "B_Truck_01_box_F" >> "HitPoints")

it returns 0 for the truck, but it is correct for every other vehicle.

Is it a bug maybe?

I noticed the Parents in the config browser of the truck are ["HitPoints", "HitPoints"] while for other vehicles it is only ["HitPoints"].

Edit: BIS_fnc_returnChildren seems to fix the issue. Thank you guys.

Edited by Ed

Share this post


Link to post
Share on other sites

Edit: I was mistaken about the behavior of count. The problem seems to be that count only sees configs entries that are defined/overridden in that class, but not if they were simply inherited.

BIS_fnc_returnChildren will return all the sub-classes (including inherited) in 'Hitpoints' as an array of configs, which you can then count:

_kids = [(configfile >> "CfgVehicles" >> "B_Truck_01_box_F" >> "HitPoints"),0] call BIS_fnc_returnChildren;
_cnt = count kids;


//and you can still use the config array elements of _kids[] with [url="https://community.bistudio.com/wiki/getText"]getText[/url], or other commands (fyi inherited configs will have different parents):
_hitName = getText (_kids select 0 >> "name");    //returns the Hit-Point name, required for use with [url="https://community.bistudio.com/wiki/setHit"]setHit[/url]

Edited by dr_strangepete
mistaken

Share this post


Link to post
Share on other sites
count will return number of config properties, but not subclasses (each hitpoint is its own sub-class).
This is not correct, counting a config entry will return the number of items is contains whether these are properties or classes.

For example create a Description.ext

class myClass {

class myChildClass {

	myString = "1st Child";
	myNumber = 2;
	myArray[] = {"Bob", "Betty", "Sue"};

};

class mySecondChildClass {

	myString = "2nd Child";
	myNumber = 3;
	myArray[] = {"Bob", "Betty", "Sue"};

};

class myInheritedChildClass : myChildClass {

	myString = "Inherited Child";

};

myString = "Parent";
myNumber = 1;
myArray[] = {"David", "Kate", "Steve"};

};

and in the DebugConsole type

count (missionconfigfile >> "MyClass")

Will return 6, 3 classes and 3 properties.

There is something wrong with the Truck_01 tree. Just look at the return from your code

[(configfile >> "CfgVehicles" >> "B_Truck_01_box_F" >> "HitPoints"),0] call BIS_fnc_returnChildren;

just looking at the first index shows it has to traverse alll the way down to Car_F

[config.bin/CfgVehicles/Car_F/HitPoints/HitRGlass

if you do the same with O_Truck_02_box_F its first result is from itself

config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitLFWheel

yet if you open up its config you will see that it does not define its own hitpoint

class Car_F;
class Truck_F: Car_F
{
	class ViewPilot;
};
class Truck_02_base_F: Truck_F
{
	class Turrets{};
};
class O_Truck_02_box_F: Truck_02_base_F
{
	author = "$STR_A3_Bohemia_Interactive";
	_generalMacro = "O_Truck_02_box_F";
	side = 0;
	faction = "OPF_F";
	crew = "O_soldier_F";
	vehicleClass = "Support";
	scope = 2;
	displayName = "$STR_A3_CfgVehicles_Truck_02_Repair0";
	model = "\A3\soft_f_gamma\Truck_02\Truck_02_box_F";
	picture = "\A3\soft_f_gamma\Truck_02\data\UI\Truck_02_box_CA.paa";
	Icon = "\A3\soft_f_gamma\Truck_02\data\UI\Map_Truck_02_box_CA.paa";
	castCargoShadow = 1;
	transportSoldier = 2;
	transportRepair = 200000000;
	supplyRadius = 10;
	class TransportItems
	{
		class _xx_FirstAidKit
		{
			name = "FirstAidKit";
			count = 4;
		};
	};
	hiddenSelectionsTextures[] = {"\A3\soft_f_beta\Truck_02\Data\Truck_02_kab_OPFOR_co.paa","\A3\soft_f_beta\Truck_02\Data\Truck_02_repair_OPFOR_co.paa"};
};

Edit: I see that you have changed your post while i was writing this.

Still your assumption can not be true 'count only sees configs entries that are defined/overridden in that class', if this was the case (as shown above) the count of O_Truck_02_box_F would be 0 as it does not define its own HiPoints, but it does not it returns 8 yet it has 19 :/

So using

[(configfile >> "CfgVehicles" >> "O_Truck_02_box_F" >> "HitPoints"),0] call BIS_fnc_returnChildren;

returns

[config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitLFWheel,
config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitLF2Wheel,
config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitLMWheel,
config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitLBWheel,
config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitRFWheel,
config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitRF2Wheel,
config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitRMWheel,
config.bin/CfgVehicles/O_Truck_02_box_F/HitPoints/HitRBWheel,
config.bin/CfgVehicles/Car_F/HitPoints/HitRGlass,
config.bin/CfgVehicles/Car_F/HitPoints/HitLGlass,
config.bin/CfgVehicles/Car_F/HitPoints/HitGlass1,
config.bin/CfgVehicles/Car_F/HitPoints/HitGlass2,
config.bin/CfgVehicles/Car_F/HitPoints/HitGlass3,
config.bin/CfgVehicles/Car_F/HitPoints/HitGlass4,
config.bin/CfgVehicles/Car_F/HitPoints/HitGlass5,
config.bin/CfgVehicles/Car_F/HitPoints/HitGlass6,
config.bin/CfgVehicles/Car_F/HitPoints/HitBody,
config.bin/CfgVehicles/Car_F/HitPoints/HitFuel,
config.bin/CfgVehicles/Car_F/HitPoints/HitEngine]

From this i would agree with you 8 are from itself, 11 are from Car_F. Yet the config for itself show no overridden/defined HitPoint classes. They actually come from a previous definition of Truck_f from soft_f_beta.

class CfgVehicles
{
class Car;
class Car_F: Car
{
	class HitPoints;
};
class Truck_F: Car_F
{
	class ViewPilot;
	class HitPoints: HitPoints
	{
		class HitLFWheel;
		class HitLBWheel;
		class HitLMWheel;
		class HitLF2Wheel;
		class HitRFWheel;
		class HitRBWheel;
		class HitRMWheel;
		class HitRF2Wheel;
	};
	class AnimationSources;
};

Im confused am i missing somehting obvious here? Is this maybe a bug with count related to configs? as the results seem inconsistent.

Edited by Larrow

Share this post


Link to post
Share on other sites

What you posted for return of O_Truck_02 is consistent with what i observed when i tested with B_Heli_Light_01_F (personal fav) - count returns 10 (being the ones directly defined under B_Heli) out of 19, ignoring the ones which were picked up as part of the parent hitpoints{}. A quick browse of A3/air_f/heli_light_01 also shows those 10 hitpoints overridden.

so depending on how you look at it, count is either broken or working exactly as the wiki describes ;)

it doesn't help either that the configviewer doesn't visually differentiate between defined and inherited classes like it does with properties(tab)

dump:

9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitFuel
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitHull
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitEngine
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitAvionics
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitHRotor
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitVRotor
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitGlass1
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitGlass2
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitGlass3
9:31:07 bin\config.bin/CfgVehicles/B_Heli_Light_01_F/HitPoints/HitGlass4
9:31:07 bin\config.bin/CfgVehicles/Helicopter_Base_F/HitPoints/HitEngine1
9:31:07 bin\config.bin/CfgVehicles/Helicopter_Base_F/HitPoints/HitEngine2
9:31:07 bin\config.bin/CfgVehicles/Helicopter_Base_F/HitPoints/HitMissiles
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitRGlass
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitLGlass
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitEngine3
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitWinch
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitTransmission
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitGlass5
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitGlass6
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitLight
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitHydraulics
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitGear
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitHStabilizerL1
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitHStabilizerR1
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitVStabilizer1
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitTail
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitPitotTube
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitStaticPort
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitStarter1
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitStarter2
9:31:07 bin\config.bin/CfgVehicles/Helicopter/HitPoints/HitStarter3

config:

class HitPoints: HitPoints
	{
		class HitFuel: HitFuel
		{
			visual="";
			radius=0.1;
			explosionShielding=2;
		};
		class HitHull: HitHull
		{
			armor=999;
			visual="zbytek";
			depends="Total";
			radius=0.0099999998;
		};
		class HitEngine: HitEngine
		{
			visual="";
			radius=0.2;
			explosionShielding=2;
		};
		class HitAvionics: HitAvionics
		{
			armor=1;
			visual="";
			radius=0.5;
			explosionShielding=2;
		};
		class HitHRotor: HitHRotor
		{
			visual="main rotor static";
			armor=3;
			radius=0.30000001;
			explosionShielding=2.5;
		};
		class HitVRotor: HitVRotor
		{
			visual="tail rotor static";
			armor=2;
			radius=0.059999999;
			explosionShielding=6;
		};
		class HitGlass1: HitGlass1
		{
			armor=0.5;
			radius=0.15000001;
		};

glass 1-4....etc..

EDIT: i see now what you are saying about O_Truck_02 not having overridding configs, looking at it again, i misread. so it is odd that some still show in the returnChildren return as being direct, and others inherited...maybe its the morning, but i'm thoroughly confused :)

Edited by dr_strangepete

Share this post


Link to post
Share on other sites
#define getHPdmg(hpname) _veh getHitPointDamage hpname
_veh = _this;
if !(typeName _veh == "OBJECT") exitWith {
diag_log "ERROR getHitPoints, _this is not an object";
[];
};

_vehCfg = configFile >> "CfgVehicles" >> typeOf _veh;
_hitPointsVeh = _vehCfg >> "HitPoints";
_turrets = _vehCfg >> "Turrets";

_hitpoints = [];
for "_i" from 0 to ((count _hitPointsVeh)-1) do {
_hpname = configName (_hitPointsVeh select _i);
_hitpoints pushback [_hpname, getHPdmg(_hpname)];
};

for "_i" from 0 to ((count _turrets)-1) do {
_hitPointsTurret = (_turrets select _i) >> "HitPoints";
for "_j" from 0 to ((count _hitPointsTurret)-1) do {
	_hpname = configName (_hitPointsTurret select _j);
	_hitpoints pushback [_hpname, getHPdmg(_hpname)];
};
};

//Returns [["hitpointname",damageasinteger],["name",integer]]
_hitpoints;

Share this post


Link to post
Share on other sites

Today, dev branch got very nice command:

[color="#FF8040"][color="#1874CD"]_hitPoints[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]configProperties[/b][/color] [color="#8B3E2F"][b][[/b][/color]
[color="#191970"][b]configFile[/b][/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]>[/b][/color] [color="#7A7A7A"]"CfgVehicles"[/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]>[/b][/color] [color="#7A7A7A"]"O_Truck_02_box_F"[/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]>[/b][/color] [color="#7A7A7A"]"HitPoints"[/color][color="#8B3E2F"][b],[/b][/color] 
[color="#7A7A7A"]"_hitPoints pushBack configName _x; true"[/color][color="#8B3E2F"][b],[/b][/color] 
[color="#000000"]true[/color]
[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]hint[/b][/color] [color="#191970"][b]str[/b][/color] [color="#1874CD"]_hitPoints[/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

["HitLFWheel","HitLF2Wheel","HitLMWheel","HitLBWheel","HitRFWheel","HitRF2Wheel","HitRMWheel","HitRBWheel","HitRGlass","HitLGlass","HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitBody","HitFuel","HitEngine"]

Share this post


Link to post
Share on other sites
EDIT: i see now what you are saying about O_Truck_02 not having overridding configs, looking at it again, i misread. so it is odd that some still show in the returnChildren return as being direct, and others inherited...maybe its the morning, but i'm thoroughly confused
Ah you finally saw what i was trying to get across. Confused too, join the club.

@Viba - Your code suffers from the same problem as we have been discussing, it does not return all hitpoints available for a vehicle as count seems to return inconsistent results.

h = [] spawn {
_vehCfg = configFile >> "CfgVehicles" >> "O_Truck_02_box_F";
_hitPointsVeh = _vehCfg >> "HitPoints";

_hitpoints = [];
for "_i" from 0 to ((count _hitPointsVeh)-1) do {
	_hpname = configName (_hitPointsVeh select _i);
	_hitpoints pushback [_hpname];
};

copyToClipboard str _hitpoints;
};

//Results

[["HitLFWheel"],["HitLF2Wheel"],["HitLMWheel"],["HitLBWheel"],["HitRFWheel"],["HitRF2Wheel"],["HitRMWheel"],["HitRBWheel"]] == 8

Where if you look at KK's quote or my initial output from returnChildren it actually has 19 hitPoints.

@KK - Oh nice, does it work properly , lol. From your quote box which i presume are the results, it does. (not on Dev so cant test)

@Ed : To answer yout original post you can get all the hitPoint names from returnChildren as dr_strangepete suggested. e.g

h = [] spawn {
_hitpoints = [];
{
	_hitpoints pushBack ( configName _x ) ;
}forEach ( [configFile >> "CfgVehicles" >> "B_Truck_01_box_F" >> "HitPoints",0]call BIS_fnc_returnChildren );

hint format [ "Array:\n%1\n\nCount:\n%2", _hitpoints, count _hitpoints ];
};

Edited by Larrow

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×