setHit: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (2.16 -> 2.18)
 
(82 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2 |= Game name
|game1= arma2
|version1= 1.00


|1.00|= Game version
|game2= arma2oa
|version2= 1.50


|arg= local |= Arguments in MP
|game3= tkoh
|version3= 1.00


|eff= global |= Effects in MP
|game4= arma3
____________________________________________________________________________________________
|version4= 0.50


| Damage / repair part of object. Damage 0 means fully functional, damage 1 means completely destroyed / dead. '''Note:''' Some part names are in Czech; see [[Translations|translation table]].  |= Description
|arg= local
____________________________________________________________________________________________


| object '''setHit''' [part, damage] |= Syntax
|eff= global


|p1= object: [[Object]] - |= PARAMETER1
|gr1= Object Manipulation


|p2= part: [[String]] - Name of the part.
|descr=
{{{!}} class="wikitable float-right align-center-col-2"
{{!}}+
! {{Link|:Category: Event Handlers|Event Handler}}
! Triggered
{{!}}-
{{!}} {{hl|Hit}}
{{!}} {{Icon|unchecked}}
{{!}}-
{{!}} {{hl|HandleDamage}}
{{!}} {{Icon|unchecked}}
{{!}}-
{{!}} {{hl|Killed}}
{{!}} {{Icon|checked}}
{{!}}-
{{!}} {{hl|MPKilled}}
{{!}} {{Icon|checked}}
{{!}}}


|p3= damage: [[Number]] - |= Damage value ranging from 0 to 1, 1 being destroyed. Non-integer values work fine.
Set damage on a part of an object.
{{Feature|informative|Some part names are in Czech; see the [[ArmA: Armed Assault: Selection Translations|translation table]].}}


| [[Nothing]] |= RETURNVALUE
|s1= object [[setHit]] [part, damage, useEffects, killer, instigator, breakRotor]


|p1= object: [[Object]] - [[local]] object


|x1= <pre>vehicle player setHit ["motor", 1]</pre> |= EXAMPLE1
|p2= part: [[String]] - name of the part ([[Named_Selection|selection]] name)
|x2= <pre>vehicle player setHit ["mala vrtule", 0.95]</pre> |= EXAMPLE2


____________________________________________________________________________________________
|p3= damage: [[Number]] - damage value ranging 0..1, 0 being fully functional, 1 being destroyed


| |= SEEALSO
|p4= useEffects: [[Boolean]] - (Optional, default [[true]]) [[false]] to skip destruction effects
|p4since= arma3 1.68


| |= MPBEHAVIOUR
|p5= killer: [[Object]] - (Optional, default [[objNull]]) the entity that caused the damage. If the damage leads to the death of the unit, the killer will be used as the object that caused the kill.
____________________________________________________________________________________________
* it can be used to show "killed by player" in debriefing statistics and kill messages in the chat (if death messages are enabled).
}}
* it will alter the killer's [[rating]] as if the killer directly killed the unit.
* it will be listed as <sqf inline>_killer</sqf> parameter in the [[Arma 3: Event Handlers#Killed|Killed]] event handler.
|p5since= arma3 2.08


<h3 style='display:none'>Notes</h3>
|p6= instigator: [[Object]] - (Optional, default [[objNull]]) the person that instigated the damage.
<dl class='command_description'>
* if a tank is a killer, the tank gunner that pulled the trigger is instigator
<!-- Note Section BEGIN -->
* it will be listed as <sqf inline>_instigator</sqf> parameter in the [[Arma 3: Event Handlers#Killed|Killed]] event handler.
|p6since= arma3 2.12


<dd class="notedate">
|p7= breakRotor: [[Boolean]] - (Optional, default [[false]]) if the hitpoint is rotor on a helicopter, [[true]] will break the rotor as well as play corresponding sound if 'useEffects' is also [[true]].
<dt class="note">'''[[User:Deadfast|Deadfast]]'''
|p7since= arma3 2.18
<dd class="note">Damaging specific parts of the vehicle will not update its overall [[damage]] value (as of v1.03):
<pre>
player setHit ["hands", 0.9];
hint str (damage player); //will return 0
</pre>


|r1= [[Nothing]]


|x1= <sqf>vehicle player setHit ["motor", 1];</sqf>


<dd class="notedate">
|x2= <sqf>vehicle player setHit ["mala vrtule", 0.95];</sqf>
<dt class="note">'''[[User:DenV|denisko.redisko]]'''
<dd class="note">Direct use of the names of sections of the model is likely a bad practice, and will not work on some addons.
So instead:
<pre>_MH60S setHit ["elektronika", _hit];</pre>
should be used:
<pre>_MH60S setHit [getText(configFile >> "cfgVehicles" >> "MH60S" >> "HitPoints" >> "HitAvionics" >> "name"), _hit];</pre>


|x3= <sqf>
if (local _heli) then
{
_heli setHit ["velka vrtule", 0];
}
else
{
hint ("Vehicle " + str _heli + " must be local to this machine to do that!");
};
</sqf>


|seealso= [[getHit]] [[getHitPointDamage]] [[setHitPointDamage]] [[damage]] [[setDamage]] [[setFuel]] [[setAmmo]] [[getHitIndex]] [[setHitIndex]] [[forceHitPointsDamageSync]]
}}


<dd class="notedate">
{{Note
<dt class="note">'''[[User:LongEnoughName|Sa-Matra]]'''
|user= Deadfast
<dd class="note">Since there is no getHit (as of 1.61), you can use [[canMove|canMove]] command to check if vehicle is capable of moving.
|timestamp= 20090824110900
|text= Damaging specific parts of the vehicle will not update its overall [[damage]] value (as of v1.03):
<sqf>
player setHit ["hands", 0.9];
hint str (damage player); // will return 0
</sqf>
|game= arma2
}}


For land wheeled vehicles canMove will return false if any real wheel (damaging nonexistent wheels doesn't count) has hitpoint damage greater than 0.9. Having HitEngine damage greater than 0.9 will as well make canMove to return false (as well as will result in vehicle exploding). HitFuel however doesn't make canMove return false even though having high HitFuel damage will make car explode.
{{Note
 
|user= DenV
For helicopters HitEngine with damage greater than 0.9 will make canMove return false as well. Having HitHRotor (main rotor) damaged even up to 1 will never make canMove return false. However, if HitVRotor (tail rotor) will have damage greater than 0.703608 it will make canMove return false (even though some helicopters are controllable and flyable by player with broken tail rotor).
|timestamp= 20110329142500
 
|text= Direct use of the names of sections of the model is likely a bad practice, and will not work on some addons.
In same manner you can use [[canFire|canFire]] to check if turret hitpoints are not damaged enough to be able to fire.
So instead:
 
<sqf>_MH60S setHit ["elektronika", _hit];</sqf>
Update: Since ArmA 3 1.31 [[getHit|getHit]] has been introduced.
should be used:
 
<sqf>_MH60S setHit [getText (configFile >> "cfgVehicles" >> "MH60S" >> "HitPoints" >> "HitAvionics" >> "name"), _hit];</sqf>
<!-- Note Section END -->
}}
</dl>
 
<h3 style='display:none'>Bottom Section</h3>
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 16:06, 8 February 2024

Hover & click on the images for description

Description

Description:
Event Handler Triggered
Hit Unchecked
HandleDamage Unchecked
Killed Checked
MPKilled Checked

Set damage on a part of an object.

Some part names are in Czech; see the translation table.
Groups:
Object Manipulation

Syntax

Syntax:
object setHit [part, damage, useEffects, killer, instigator, breakRotor]
Parameters:
object: Object - local object
part: String - name of the part (selection name)
damage: Number - damage value ranging 0..1, 0 being fully functional, 1 being destroyed
since Arma 3 logo black.png1.68
useEffects: Boolean - (Optional, default true) false to skip destruction effects
since Arma 3 logo black.png2.08
killer: Object - (Optional, default objNull) the entity that caused the damage. If the damage leads to the death of the unit, the killer will be used as the object that caused the kill.
  • it can be used to show "killed by player" in debriefing statistics and kill messages in the chat (if death messages are enabled).
  • it will alter the killer's rating as if the killer directly killed the unit.
  • it will be listed as _killer parameter in the Killed event handler.
since Arma 3 logo black.png2.12
instigator: Object - (Optional, default objNull) the person that instigated the damage.
  • if a tank is a killer, the tank gunner that pulled the trigger is instigator
  • it will be listed as _instigator parameter in the Killed event handler.
since Arma 3 logo black.png2.18
breakRotor: Boolean - (Optional, default false) if the hitpoint is rotor on a helicopter, true will break the rotor as well as play corresponding sound if 'useEffects' is also true.
Return Value:
Nothing

Examples

Example 1:
vehicle player setHit ["motor", 1];
Example 2:
vehicle player setHit ["mala vrtule", 0.95];
Example 3:
if (local _heli) then { _heli setHit ["velka vrtule", 0]; } else { hint ("Vehicle " + str _heli + " must be local to this machine to do that!"); };

Additional Information

See also:
getHit getHitPointDamage setHitPointDamage damage setDamage setFuel setAmmo getHitIndex setHitIndex forceHitPointsDamageSync

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
Deadfast - c
Posted on Aug 24, 2009 - 11:09 (UTC)

Damaging specific parts of the vehicle will not update its overall damage value (as of v1.03):

player setHit ["hands", 0.9]; hint str (damage player); // will return 0

DenV - c
Posted on Mar 29, 2011 - 14:25 (UTC)
Direct use of the names of sections of the model is likely a bad practice, and will not work on some addons. So instead:
_MH60S setHit ["elektronika", _hit];
should be used:
_MH60S setHit [getText (configFile >> "cfgVehicles" >> "MH60S" >> "HitPoints" >> "HitAvionics" >> "name"), _hit];