Files
DayZ-Epoch/dayz_code/compile/vehicle_handleDamage.sqf
2012-11-05 16:11:06 -06:00

37 lines
1.2 KiB
Plaintext

/***********************************************************
ASSIGN DAMAGE TO A UNIT
- Function Vehicle_HandleDamage
- [unit, selectionName, damage, source, projectile] call Vehicle_HandleDamage;
************************************************************/
private["_unit","_selection","_strH","_dam","_total","_damage","_needUpdate"];
_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;
_dam = _unit getVariable["totalDmg",0];
_needUpdate = _unit getVariable["needUpdate",false];
if (_dam < 1 ) then {
if ( (_selection != "") ) then {
_strH = "hit_" + (_selection);
} else {
_strH = "totalDmg";
};
if (_total > 0.98) then {
_total = 1;
};
if ( _total>0 ) then {
_unit setVariable [_strH,_total,true];
if ( !_needUpdate ) then {
_unit setVariable ["needUpdate",true,true];
dayzUpdateVehicle = [_unit,"damage"];
if (isServer) then {
if (allowConnection) then {
dayzUpdateVehicle call server_updateObject;
};
} else {
publicVariableServer "dayzUpdateVehicle";
};
};
};
};
_total