HandleDamage
Available in Arma 2 only.
Triggered when the unit is damaged. Works with all vehicles.
Code provided must return a value what should be the damage of given part after processing.
Adding this eventhandler with no return value or with return value 0, replaces damage handling by the engine, making the object invulnerable if damage is not scripted in the eventhandler. If you want default processing to be done, be sure to return _this select 2.
You can setDamage and setHit in combination for additional damage handling.
Locality: HandleDamage is triggered where the unit is local. See also Locality in Multiplayer.
Local.
This EH is triggered separately for every selection of the damaged object.
Passed array: [unit, selectionName, damage, source, projectile]
unit: Object - Object the event handler is assigned to. 【_this select 0】这个是第一个函数,本单位
selectionName: String - Name of the selection where the unit was damaged. "" for
_this select 1 第二个函数 该单位受伤部位
over-all structural damage, "?" for unknown selections.
damage: Number - Resulting level of damage for the selection. _this select 2 第三个 该单位受伤值
source: Object - The source unit that caused the damage. _this select 3 这个就是该单位伤害来源与谁了。。
projectile: String - Classname of the projectile that caused inflicted the damage. ("" for unknown, such as falling damage.)
在玩家初始栏这样写
this addEventHandler ["handleDamage", {(_this select 3) setdammage 1}];
如果我没弄错的话。。这句话的意思就是。。伤害了玩家单位的人。。就会被直接设置成零生命值。。就是谁打你谁就死。。。其他操作看你自己了 @
@dieeasy