damage: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *T([a-z ])" to "$1 - t$2")
(84 intermediate revisions by 18 users not shown)
Line 1: Line 1:
[[Category:Scripting Commands]]
{{RV|type=command
[[Category:Scripting Commands OFP 1.97]]
[[Category:Scripting Commands ArmA]]


back to [[Scripting_Reference#D|COMREF]]
|game1= ofp


<h2 style="color:#000066">'''damage ''anything'''''</h2>
|version1=


|game2= arma1
|version2= 1.00


'''Operand types:'''
|game3= arma2
|version3= 1.00


'''object:''' [[Object]]
|game4= arma2oa
|version4= 1.50


'''Type of returned value:'''
|game5= tkoh
|version5= 1.00


[[Number]]
|game6= arma3
|version6= 0.50


'''Compatibility:'''
|arg= global


Added in version '''1.50'''
|gr1= Object Manipulation


'''Description:'''
|descr= Return the damage value of an object.


Object damage in range 0 to 1.
|alias= [[getDammage|getDammage<sup>sic</sup>]] <!-- cannot use {{sic}} here (counts it as alias link) -->


'''Note:''' This function is identical to [[getDammage]].
|s1= [[damage]] object


|p1= object: [[Object]]


'''Example:'''
|r1= [[Number]] - the returned number in range (healthy) 0..1 (dead).


? (('''damage''' [[player]]) > 0.3) : [[hint]] "Ouch!!"
|x1= <sqs>? damage player > 0.1 : player groupChat "I'm hurt! Medic!"</sqs>
 
|x2= <sqf>
if (damage player > 0.1) then
{
player groupChat "I'm hurt! Medic!";
};
</sqf>
 
|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
|timestamp= 20150213202000
|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.
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.
}}

Revision as of 16:50, 8 November 2023

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.