{"name":"setHit","title":"setHit","type":"command","url":"https://community.bistudio.com/wiki/setHit","revid":369851,"updated":"2024-10-16T13:52:03Z","groups":["Object Manipulation"],"status":"ok","games":{"arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.00","arma3_since":"0.50","locality":{"argument":"local","effect":"global"},"description":"| Event Handler | Triggered |\n|---|---|\n| `Hit` | ✗ |\n| `HandleDamage` | ✗ |\n| `Killed` | ✓ |\n| `MPKilled` | ✓ |\n\nSet damage on a part of an object.\n\n> [!NOTE]\n> Some part names are in Czech; see the translation table.","syntaxes":[{"syntax":"object setHit [part, damage, useEffects, killer, instigator, breakRotor]","params":[{"name":"object","type":"Object","description":"local object","type_expr":"Object"},{"name":"part","type":"String","description":"name of the part (selection name)","type_expr":"String"},{"name":"damage","type":"Number","description":"damage value ranging 0..1, 0 being fully functional, 1 being destroyed","type_expr":"Number"},{"name":"useEffects","type":"Boolean","optional":true,"default":"true","description":"false to skip destruction effects","type_expr":"Boolean","since":"arma3 1.68","text":"useEffects: Boolean - (Optional, default true) false to skip destruction effects"},{"name":"killer","type":"Object","optional":true,"default":"objNull","description":"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.\n\n- it can be used to show \"killed by player\" in debriefing statistics and kill messages in the chat (if death messages are enabled).\n- it will alter the killer's rating as if the killer directly killed the unit.\n- it will be listed as `_killer` parameter in the Killed event handler.","type_expr":"Object","since":"arma3 2.08","text":"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.\n\n- it can be used to show \"killed by player\" in debriefing statistics and kill messages in the chat (if death messages are enabled).\n- it will alter the killer's rating as if the killer directly killed the unit.\n- it will be listed as `_killer` parameter in the Killed event handler."},{"name":"instigator","type":"Object","optional":true,"default":"objNull","description":"the person that instigated the damage.\n\n- if a tank is a killer, the tank gunner that pulled the trigger is instigator\n- it will be listed as `_instigator` parameter in the Killed event handler.","type_expr":"Object","since":"arma3 2.12","text":"instigator: Object - (Optional, default objNull) the person that instigated the damage.\n\n- if a tank is a killer, the tank gunner that pulled the trigger is instigator\n- it will be listed as `_instigator` parameter in the Killed event handler."},{"name":"breakRotor","type":"Boolean","optional":true,"default":"false","description":"if the hitpoint is rotor on a helicopter, true will break the rotor as well as play corresponding sound if 'useEffects' is also true.","type_expr":"Boolean","since":"arma3 2.18","text":"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."}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"object"},"right":{"text":"[part, damage, useEffects, killer, instigator, breakRotor]"}}],"examples":[{"code":["vehicle player setHit [\"motor\", 1];"]},{"code":["vehicle player setHit [\"mala vrtule\", 0.95];"]},{"text":"```sqf\nif (local _heli) then\n{\n    _heli setHit [\"velka vrtule\", 0];\n}\nelse\n{\n    hint (\"Vehicle \" + str _heli + \" must be local to this machine to do that!\");\n};\n```","code":["if (local _heli) then\n{\n\t_heli setHit [\"velka vrtule\", 0];\n}\nelse\n{\n\thint (\"Vehicle \" + str _heli + \" must be local to this machine to do that!\");\n};"]}],"see_also":["getHit","getHitPointDamage","setHitPointDamage","damage","setDamage","setFuel","setAmmo","getHitIndex","setHitIndex","forceHitPointsDamageSync"],"notes":[{"user":"Deadfast","date":"2009-08-24T11:09:00Z","text":"Damaging specific parts of the vehicle will not update its overall damage value (as of v1.03):\n\n```sqf\nplayer setHit [\"hands\", 0.9];\nhint str (damage player); // will return 0\n```"},{"user":"DenV","date":"2011-03-29T14:25:00Z","text":"Direct use of the names of sections of the model is likely a bad practice, and will not work on some addons.\nSo instead:\n\n```sqf\n_MH60S setHit [\"elektronika\", _hit];\n```\n\nshould be used:\n\n```sqf\n_MH60S setHit [getText (configFile >> \"cfgVehicles\" >> \"MH60S\" >> \"HitPoints\" >> \"HitAvionics\" >> \"name\"), _hit];\n```"}]}