getAllHitPointsDamage – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - " <!-- (DIS)?CONTINUE Notes -->" to "")
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Notes from main page ==
== Notes from main page ==


<!-- CONTINUE Notes -->
<dl class="command_description">
<dl class="command_description">
<dt></dt>
<dd class="notedate">Posted on September 27, 2015 - 00:42 (UTC)</dd>
<dd class="notedate">Posted on September 27, 2015 - 00:42 (UTC)</dd>
<dt class="note">[[User:PabstMirror|PabstMirror]]</dt>
<dt class="note">[[User:PabstMirror|PabstMirror]]</dt>
Line 10: Line 10:


<dl class="command_description">
<dl class="command_description">
<dt></dt>
<dd class="notedate">Posted on April 22, 2016 - 23:40 (UTC)</dd>
<dd class="notedate">Posted on April 22, 2016 - 23:40 (UTC)</dd>
<dt class="note">[[User:Pierre MGI|Pierre MGI]]</dt>
<dt class="note">[[User:Pierre MGI|Pierre MGI]]</dt>
Line 15: Line 16:
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->


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 future[[User:Killzone Kid|Killzone Kid]] ([[User talk:Killzone Kid|talk]]) 16:23, 23 April 2016 (CEST)
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 future[[User:Killzone Kid|Killzone Kid]] ([[User talk:Killzone Kid|talk]]) 16:23, 23 April 2016 (CEST)
Line 25: Line 25:
  _damage_array = if (getAllHitPointsDamage cursorObject isEqualTo [] or getAllHitPointsDamage cursorObject isEqualTo [[],[],[]]) then [{[[""],[""],[0]]},{getAllHitPointsDamage cursorObject}];
  _damage_array = if (getAllHitPointsDamage cursorObject isEqualTo [] or getAllHitPointsDamage cursorObject isEqualTo [[],[],[]]) then [{[[""],[""],[0]]},{getAllHitPointsDamage cursorObject}];
_damage = (_damage_array select 2) call BIS_fnc_arithmeticMean; </pre>
_damage = (_damage_array select 2) call BIS_fnc_arithmeticMean; </pre>
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 on each objects...
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.
But I'm always listener for clever solution.

Revision as of 01:53, 6 April 2021

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.