Talk:getAllHitPointsDamage

From Bohemia Interactive Community
Revision as of 01:53, 6 April 2021 by Lou Montana (talk | contribs) (Text replacement - " <!-- (DIS)?CONTINUE Notes -->" to "")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Notes from main page

Posted on September 27, 2015 - 00:42 (UTC)
PabstMirror
Will only return [] instead of [[],[],[]] if object has no hitpoints
Posted on April 22, 2016 - 23:40 (UTC)
Pierre MGI
To implement the PabstMirror's note, for example, cursorTarget (or cursorobject) pointing at sky returns [], but, pointing at a building like "Land_dp_smallFactory_F" returns [[],[],[]]. Hard to manage if you want to script something with the figures in third array. Try an intermediate value like _intermediate = if (getAllHitPointsDamage cursorObject isEqualTo [] or getAllHitPointsDamage cursorObject isEqualTo [[],[],[]]) then [{[[""],[""],[0]]},{getAllHitPointsDamage cursorObject}];

Moving these notes here from main page. 1. [] is returned only when object is null or has no shape. If object has shape but no hitpoints it will return [[],[],[]]. This has been added to the description so the 1st note is now obsolete, moved here for historical keeping. 2. substituting return of [[],[],[]] with [[""],[""],[0]] is wrong. getAllHitPointsDamage has result ordered with hit index in mind so [[""],[""],[0]] would mean that object has 1 hitpoint with index 0, that has no name. This is plain wrong if object in fact has no hitpoints. Keeping this so no one will attempt to make this mistake in the futureKillzone Kid (talk) 16:23, 23 April 2016 (CEST)

Pierre MGI : I probably missed the reason for this substitution: I just want to obtain, on each frame (or loop), the "average" of all hit points for the objects under the cursortarget. Doing this check, you obtain a variety of possible arrays along with the cursorObject. I didn't write something stupid when I said this command returns [] when cursortarget is at sky and [[],[],[]] for some buildings but I appreciate your precision about that. The problem occurs when you're scripting with this command and you want to avoid zero divisor. Example: As far as I hate to read no damage (damage = 0) on an halftrack or an hunter riddled by 7.62 cal. up to explosion, I just wanted to deal a "poor" mean (average) with all these hit points values.

My code is:

 _damage_array = if (getAllHitPointsDamage cursorObject isEqualTo [] or getAllHitPointsDamage cursorObject isEqualTo [[],[],[]]) then [{[[""],[""],[0]]},{getAllHitPointsDamage cursorObject}];
_damage = (_damage_array select 2) call BIS_fnc_arithmeticMean; 

No problem so far because I don't care if the sky or the building is unbreakable,has point point or not, I avoid an arithmetic mean returning zero divisor, and I can use cursortarget on each frame, sweeping any objects... But I'm always listener for clever solution.