Jump to content
Sign in to follow this  
ligthert

Getting available hitpoints from the config

Recommended Posts

I can't seem to find anything on google or the biki, also my experiments have failed.

I am trying to gather the available hitpoints available to a unit.

If I do for example:

getarray(configfile >> "CfgVehicles" >> "B_Soldier_02_f" >> "HitPoints")

This returns

[]

After some investigation configfile >> "CfgVehicles" >> "B_Soldier_02_f" hitpoints doesn't show up, but is a tree on itself. Turning every attempt to use getArray moot.

Does anybody know how I can fetch these hitpoints?

Thanks in advance! :)

Share this post


Link to post
Share on other sites

I don't know if this is the only way but it does work, it's an old A2/OA script that someone made.

null=this execvm "hitpoints.sqf"

private [  "_blgs", "_blg", "_blgtyp", "_scts", "_hitmx","_sctcl", "_sct"];

_blgs = [];
_blgtyp = typeOf _this;
_scts = [];
_hitmx = (count (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints")) - 1;
for "_i" from 0 to _hitmx do {
	_sctcl = (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints") select _i;
	_sct = getText(_sctcl >> "name");
	_scts = _scts + [_sct];
};
hint str _scts;

Share this post


Link to post
Share on other sites

Yeah it works! Thanks!

I hope I can minimize this piece of code. Will post when finished.

Share this post


Link to post
Share on other sites
private [  "_blgs", "_blg", "_blgtyp", "_scts", "_hitmx","_sctcl", "_sct"];

_blgs = [];
_blgtyp = typeOf _this;
_scts = [];
_hitmx = (count (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints")) - 1;
for "_i" from 0 to _hitmx do {
	_sctcl = (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints") select _i;
	_sct = getText(_sctcl >> "name");
	_scts = _scts + [_sct];
};
hint str _scts;

Out of boredom, I googled "_blgtyp". I thought it was one of the abstractions that Samatra does to his code (pointlessly I might add if you've got a copy of notepad++), but it turns out that it was from tcp:

http://forums.bistudio.com/showthread.php?89184-Make-A-City-Town-Ruined-Destroyed-At-Mission-Start&p=1476017&viewfull=1#post1476017

Haven't seen him on these forums for a good while, which is a shame. Thanks for posting it up F2K SEL :)

Share this post


Link to post
Share on other sites

Here is a working version of the same code for Arma 3

This will return an array of HitPart items on a specific vehicle.

Here are 2 functions I wrote that appear to work. (shocking I know), Majority of smart stuff copied from F2K Sel.

GetPartDmg = {
private ["_objtype","_array","_hitC","_cfg","_PartN","_HitP"];
//To use: Vehicle call GetPartDmg; >> OutPut Array Similar to [["fuel_hit",0.5],["hull_hit",0.5],["engine_hit",0.5] etc etc]
   _objtype = typeOf _this; 
    _array = []; 
   _hitC = (count ((configFile >> "CfgVehicles" >> _objtype >> "HitPoints") call Bis_fnc_getCfgSubClasses)) - 1; 
   for "_i" from 0 to _hitC do { 
       _cfg = (configFile >> "CfgVehicles" >> _objtype >> "HitPoints") select _i; 
       _PartN = getText(_cfg >> "name");
_HitP = _this getHit _PartN;
_array set [_i,[_PartN,_HitP]];
   }; 
_array
};

SetPartDmg = {
private ["_obj","_array","_count","_cfg","_PartN","_HitP"];
////To use: [Vehicle,GETPartDmgArray] call SetPartDmg; This will set all the damage back to the way it was.
    _obj = _this select 0;
 _array = _this select 1;
 _count = (count _this) - 1;
 for "_i" from 0 to _count do { 
       _hitP = _array select _i;
_obj sethit _hitP;
       }; 
};

[/code]

GetPartDmg returns an array of arrays for every hitpart on that particular vehicle.

SetPartDmg uses the output of GetPartDmg and puts all the dmg back.

Tested and working locally with Arma 3

NOTE: Does not work in Multiplayer. Will be changing the code to see if I can get it working.

Edited by OzDeaDMeaT

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  

×