{"name":"setHit","operator":null,"title":"setHit","type":"command","url":"https://community.bistudio.com/wiki/setHit","revid":369851,"updated":"2024-10-16T13:52:03Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":"local","effect":"global","server_exec":false},"exec":null,"description":"|  |  |  |\n|---|---|---|\n| + | Event Handler | Triggered |\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]","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":"local object","types":["Object"],"since":null,"text":"object: Object - local object"},{"name":"part","type":"String","optional":false,"default":null,"description":"name of the part (selection name)","types":["String"],"since":null,"text":"part: String - name of the part (selection name)"},{"name":"damage","type":"Number","optional":false,"default":null,"description":"damage value ranging 0..1, 0 being fully functional, 1 being destroyed","types":["Number"],"since":null,"text":"damage: Number - damage value ranging 0..1, 0 being fully functional, 1 being destroyed"},{"name":"useEffects","type":"Boolean","optional":true,"default":"true","description":"false to skip destruction effects","types":["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- 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.","types":["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- 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- 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.","types":["Object"],"since":"arma3 2.12","text":"instigator: Object - (Optional, default objNull) the person that instigated the damage.\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.","types":["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","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"[part, damage, useEffects, killer, instigator, breakRotor]","types":["Array"]}}],"examples":[{"text":"```sqf\nvehicle player setHit [\"motor\", 1];\n```","code":["vehicle player setHit [\"motor\", 1];"]},{"text":"```sqf\nvehicle player setHit [\"mala vrtule\", 0.95];\n```","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};"]}],"multiplayer":null,"problems":null,"aliases":[],"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```"}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 2 version 1.00","Scripting Commands","Scripting Commands: Global Effect","Take On Helicopters: Scripting Commands"]}