Jump to content
Sign in to follow this  
Genderbent

How can I get the health of a vehicles hull/trurret/tracks?

Recommended Posts

What's the command for getting the health of specific part of a vehicle?

I'm trying to create a trigger for when a tank's turret is disabled but can't find any info on this.

Share this post


Link to post
Share on other sites

A turret being disabled won't prevent the gun from firing, just from traversing and elevating.

Share this post


Link to post
Share on other sites

Use the getHitPointDamage command.

Heres a little script to run from the debug console.

terminate h;
h = [] spawn {
while {true} do {

		hinttext = format ["%1\n\nMain Points\n******\n", typeOf cursorTarget];
		_veh = cursorTarget;
		_baseCFG = configFile >> "CFGVehicles" >> typeOf _veh;
		for "_i" from 0 to (count (_baseCFG >> "HitPoints"))-1 do {
			_HPName = configName((_baseCFG >> "HitPoints") select _i);
			hinttext = hinttext + format["%1 >> %2\n", _HPName, cursorTarget getHitPointDamage _HPName ];
		};

		for "_i" from 0 to (count (_baseCFG >> "Turrets"))-1 do {
			hinttext = hinttext + format["\n%1\n******\n", configName ((_baseCFG >> "Turrets") select _i)];
			_turretCFG = ((_baseCFG >> "Turrets") select _i);
			for "_j" from 0 to (count (_turretCFG >> "HitPoints"))-1 do {
				_HPName = configName((_turretCFG >> "HitPoints") select _j);
				hinttext = hinttext + format["%1 >> %2\n", _HPName, cursorTarget getHitPointDamage _HPName ];
			};
		};

	hintSilent hinttext;
	sleep 1;
};
};

Run around and what ever you look at it will hint its HitPoints and their current damage value.

For some reason the hemtt trucks dont return a count for the number of HitPoints they have from the config maybe something that needs posting on the tracker, unless someone can point out a mistake ive made. EDIT: Found this feedback relating to some HitPoints not reporting properly from the config, vote up.

Edited by Larrow

Share this post


Link to post
Share on other sites

Ok here's the thing I'm trying to do, while a player is in the gunner seat of any vehicle I want them to be able to see a hint with extended information of their weapons. But if their turret is damaged it's to disappear and apply some damage to the player (to simulate getting messed up by the impact). What would be a simple way to accomplish this?

while {true} do {

if (vehicle player != player && driver vehicle player == player && (vehicle player turret?? gethitpointdamage >0.5)) then {

hint "blablabla";

};

sleep 0.5;

};

As you might be able to tell I'm not great with scripting, and I'm struggling to understand the methodology of what you did above.

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  

×