setHit: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|PARAMETER1= |p3=" to "|PARAMETER2= |p3=")
Line 11: Line 11:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Damage / repair part of object. The object must be [[local]] to the computer where command is executed.
| Set damage on a part of an object.
 
{{Informative | Some part names are in Czech; see [[Translations|translation table]]. }} |DESCRIPTION=
Damage 0 means fully functional, damage 1 means completely destroyed / dead. '''Note:''' Some part names are in Czech; see [[Translations|translation table]]. |DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________


| object '''setHit''' [part, damage, useEffects] |SYNTAX=
| object [[setHit]] [part, damage, useEffects] |SYNTAX=


|p1 = [part, damage, useEffects]: [[Array]] |Parameter1=
|p1 = [part, damage, useEffects]: [[Array]] |Parameter1=
|p2= object: [[Object]] - |PARAMETER2=


|p3= part: [[String]] - Name of the part ([[Named_Selection|selection]] name).
|p2= object: [[Object]] - |PARAMETER2=
 
|p3= part: [[String]] - Name of the part ([[Named_Selection|selection]] name) |Parameter3=
 
|p4= damage: [[Number]] - Damage value ranging 0..1, 0 being fully functional, 1 being destroyed |Parameter4=


|p4= damage: [[Number]] - |= Damage value ranging from 0 to 1, 1 being destroyed. Non-integer values work fine.
|p5 = {{GVI|arma3|1.67}} useEffects: [[Boolean]] - (Optional, default [[true]]) [[false]] to skip destruction effects |Parameter5=


|p5 = useEffects (Optional): [[Boolean]] - [[false]] to skip destruction effects. Default: [[true]] (Since Arma 3 v1.67)|=
| [[Nothing]] |RETURNVALUE=
____________________________________________________________________________________________


| [[Nothing]] |RETURNVALUE=  
|x1= <code>[[vehicle]] [[player]] [[setHit]] ["motor", 1];</code> |EXAMPLE1=


|x2= <code>[[vehicle]] [[player]] [[setHit]] ["mala vrtule", 0.95];</code> |EXAMPLE2=


|x1= <code>[[vehicle]] [[player]] [[setHit]] ["motor", 1]</code> |EXAMPLE1=
|x2= <code>[[vehicle]] [[player]] [[setHit]] ["mala vrtule", 0.95]</code> |EXAMPLE2=
|x3= <code>[[if]] ([[local]] _heli) [[then]] {
|x3= <code>[[if]] ([[local]] _heli) [[then]] {
_heli [[setHit]] ["velka vrtule", 0];
_heli [[setHit]] ["velka vrtule", 0];
} [[else]] {
} [[else]] {
[[hint]] "Vehicle " + [[str]] _heli + " must be local to this machine to do that!";
[[hint]] ("Vehicle " + [[str]] _heli + " must be local to this machine to do that!");
};</code> |EXAMPLE3=
};</code> |EXAMPLE3=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[getHit]], [[getHitPointDamage]], [[setHitPointDamage]], [[damage]], [[setDamage]], [[setFuel]], [[setAmmo]], [[getHitIndex]], [[setHitIndex]] |SEEALSO=  
| [[getHit]], [[getHitPointDamage]], [[setHitPointDamage]], [[damage]], [[setDamage]], [[setFuel]], [[setAmmo]], [[getHitIndex]], [[setHitIndex]] |SEEALSO=
 
|  |MPBEHAVIOUR=
____________________________________________________________________________________________
}}
}}


Line 51: Line 49:


<dd class="notedate">
<dd class="notedate">
<dt class="note">'''[[User:Deadfast|Deadfast]]'''
<dt class="note">[[User:Deadfast|Deadfast]]
<dd class="note">Damaging specific parts of the vehicle will not update its overall [[damage]] value (as of v1.03):
<dd class="note">Damaging specific parts of the vehicle will not update its overall [[damage]] value (as of v1.03):
<pre>
<code>[[player]] [[setHit]] ["hands", 0.9];
player setHit ["hands", 0.9];
[[hint]] [[str]] ([[damage]] [[player]]); {{cc|will return 0}}</code>
hint str (damage player); //will return 0
</pre>
 
 


<dd class="notedate">
<dd class="notedate">
<dt class="note">'''[[User:DenV|denisko.redisko]]'''
<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.
<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:
So instead:
<pre>_MH60S setHit ["elektronika", _hit];</pre>
<code>_MH60S [[setHit]] ["elektronika", _hit];</code>
should be used:
should be used:
<pre>_MH60S setHit [getText(configFile >> "cfgVehicles" >> "MH60S" >> "HitPoints" >> "HitAvionics" >> "name"), _hit];</pre>
<code>_MH60S [[setHit]] [<nowiki/>[[getText]] ([[configFile]] >> "cfgVehicles" >> "MH60S" >> "HitPoints" >> "HitAvionics" >> "name"), _hit];</code>
 
 


<dd class="notedate">
<dd class="notedate">
<dt class="note">'''[[User:LongEnoughName|Sa-Matra]]'''
<dt class="note">[[User:LongEnoughName|Sa-Matra]]
<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.
<dd class="note">Since there is no [[getHit]] (as of A2OA 1.61), you can use [[canMove]] command to check if vehicle is capable of moving.<br>
 
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.
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 make canMove to return false as well (plus will result in vehicle exploding). HitFuel however doesn't make canMove return false even though having high HitFuel damage will make car explode.
Having HitEngine damage greater than 0.9 will make canMove to return false as well (plus will result in vehicle exploding).
HitFuel however doesn't make canMove return false even though having high HitFuel damage will make car explode.<br>


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).
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).<br>


In same manner you can use [[canFire|canFire]] to check if turret hitpoints are not damaged enough to be able to fire. (canFire always returns false if there is nobody in vehicle)
You can use [[canFire]] the same way in order to check if turret hitpoints are not damaged enough to be able to fire. ([[canFire]] always returns [[false]] if there is no gunner in the vehicle).


Update: Since ArmA 3 1.31 [[getHit|getHit]] has been introduced.
'''Update:''' Since ArmA 3 1.31 [[getHit|getHit]] has been introduced.


<!-- Note Section END -->
<!-- Note Section END -->
Line 97: Line 90:
<dt class="note">[[User:HazJ|HazJ]]</dt>
<dt class="note">[[User:HazJ|HazJ]]</dt>
<dd class="note">
<dd class="note">
You can use getHit if you are using 1.64 EOL version.
You can use [[getHit]] if you are using 1.64 EOL version.
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 12:36, 19 September 2019

Hover & click on the images for description

Description

Description:
Set damage on a part of an object.
Some part names are in Czech; see translation table.
Groups:
Uncategorised

Syntax

Syntax:
object setHit [part, damage, useEffects]
Parameters:
[part, damage, useEffects]: Array
object: Object -
part: String - Name of the part (selection name)
damage: Number - Damage value ranging 0..1, 0 being fully functional, 1 being destroyed
Arma 3 logo black.png1.67 useEffects: Boolean - (Optional, default true) false to skip destruction effects
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:
getHitgetHitPointDamagesetHitPointDamagedamagesetDamagesetFuelsetAmmogetHitIndexsetHitIndex

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

Notes

Deadfast
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
denisko.redisko
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];
Sa-Matra
Since there is no getHit (as of A2OA 1.61), you can use canMove command to check if vehicle is capable of moving.
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 make canMove to return false as well (plus will result in vehicle exploding). HitFuel however doesn't make canMove return false even though having high HitFuel damage will make car explode.
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).
You can use canFire the same way in order to check if turret hitpoints are not damaged enough to be able to fire. (canFire always returns false if there is no gunner in the vehicle). Update: Since ArmA 3 1.31 getHit has been introduced.

Bottom Section

Posted on September 11, 2018 - 19:37 (UTC)
HazJ
You can use getHit if you are using 1.64 EOL version.