damage: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " +<\/code>" to "</code>")
m (Text replacement - "\]\] +\[\[" to "]] [[")
 
(30 intermediate revisions by 2 users not shown)
Line 26: Line 26:
|descr= Return the damage value of an object.
|descr= Return the damage value of an object.


|alias= [[getDammage|getDammage<sup>sic</sup>]]
|alias= [[getDammage|getDammage<sup>sic</sup>]] <!-- cannot use {{sic}} here (counts it as alias link) -->


|s1= [[damage]] object
|s1= [[damage]] object
Line 32: Line 32:
|p1= object: [[Object]]
|p1= object: [[Object]]


|r1= [[Number]] - The returned number in range (healthy) 0..1 (dead).
|r1= [[Number]] - the returned number in range (healthy) 0..1 (dead).
 
|x1= <code>[[?]] ([[damage]] [[player]]) [[a_greater_b|>]] 0.1) : [[player]] [[groupChat]] "I'm hurt! Medic!" {{cc|SQS}}</code>


|x2= <code>[[if]] (([[damage]] [[player]]) [[a_greater_b|>]] 0.1) [[then]] {
|x1= <sqs>? damage player > 0.1 : player groupChat "I'm hurt! Medic!"</sqs>
    [[player]] [[groupChat]] "I'm hurt! Medic!";
};</code>


|x3= <code>[[private]] _health = (1 - [[damage]] [[player]]) * 100; {{cc|Health in % from 0 to 100}}</code>
|x2= <sqf>
if (damage player > 0.1) then
{
player groupChat "I'm hurt! Medic!";
};
</sqf>


|seealso= [[setDamage]], [[setHit]], [[getHit]], [[getHitIndex]], [[setHitIndex]], [[getHitPointDamage]], [[setHitPointDamage]], [[Arma 3: Event Handlers#HandleDamage|"HandleDamage" Event Handler]]
|x3= <sqf>private _health = (1 - damage player) * 100; // health in % from 0 to 100</sqf>
 
|seealso= [[setDamage]] [[setHit]] [[getHit]] [[getHitIndex]] [[setHitIndex]] [[getHitPointDamage]] [[setHitPointDamage]] [[waterDamaged]] [[Arma 3: Event Handlers#HandleDamage|"HandleDamage" Event Handler]]
}}
}}


 
{{Note
 
|user= Pierre MGI
<dl class="command_description">
|timestamp= 20150213202000
<dt></dt>
|text= The returned value depends on the couple target/ammo fired. This value has no correlation with the sum of all hitpoints damage status and the effective status of the object.
<dd class="notedate">Posted on February 13, 2015 - 20:20 (UTC)</dd>
Firing bullets on cars often lead to weird results. For example: [[damage]] returns zero while a Hunter is fired at will with an .50 HMG! Hunter can be almost destroyed with zero damage for this function.
<dt class="note">[[User:Pierre MGI|Pierre MGI]]</dt>
If you script, use instead the [[getHitPointDamage]] command.
<dd class="note">
}}
The returned value depends on the couple target/ammo fired. This value has no correlation with the sum of all hitpoints damage status and the effective status of the object. Firing bullets on cars often lead to weird results. For example: [[damage]] returns zero while a Hunter is fired at will with an .50 HMG! Hunter can be almost destroyed with zero damage for this function. If you script, use instead the [[getHitPointDamage]] command.
</dd>
</dl>

Latest revision as of 11:44, 5 May 2024

Hover & click on the images for description

Description

Description:
Return the damage value of an object.
Alias:
getDammagesic
Groups:
Object Manipulation

Syntax

Syntax:
damage object
Parameters:
object: Object
Return Value:
Number - the returned number in range (healthy) 0..1 (dead).

Examples

Example 1:
? damage player > 0.1 : player groupChat "I'm hurt! Medic!"
Example 2:
if (damage player > 0.1) then { player groupChat "I'm hurt! Medic!"; };
Example 3:
private _health = (1 - damage player) * 100; // health in % from 0 to 100

Additional Information

See also:
setDamage setHit getHit getHitIndex setHitIndex getHitPointDamage setHitPointDamage waterDamaged "HandleDamage" Event Handler

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Pierre MGI - c
Posted on Feb 13, 2015 - 20:20 (UTC)
The returned value depends on the couple target/ammo fired. This value has no correlation with the sum of all hitpoints damage status and the effective status of the object. Firing bullets on cars often lead to weird results. For example: damage returns zero while a Hunter is fired at will with an .50 HMG! Hunter can be almost destroyed with zero damage for this function. If you script, use instead the getHitPointDamage command.