Files
DayZ-Epoch/SQF/dayz_code/actions/repair.sqf
AirwavesMan 9ad86a84a3 Group sounds and zombie calls
dayz_zombieSpeak and player_alertZombies are called often together or should be. fnc_alertZombies groups them together and uses the given parameters. This streamlines and corrects the missing or incorrect calls from dayz_zombieSpeak or player_alertZombies.
2020-09-12 01:30:45 +02:00

55 lines
1.8 KiB
Plaintext

if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true;
private ["_id","_hits","_array","_vehicle","_part","_hitpoint","_type","_nameType","_namePart","_damage","_selection","_finished"];
_id = _this select 2;
_array = _this select 3;
_vehicle = _array select 0;
_part = _array select 1;
_hitpoint = _array select 2;
_type = typeOf _vehicle;
{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
dayz_myCursorTarget = objNull;
//diag_log(format["%1 %2", __FILE__, _this]);
//moving this here because we need to know which part needed if we don't have it
_nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
_namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName");
if ("ItemToolbox" in items player && {_part in magazines player}) then {
[player,(getPosATL player),30,"repair"] spawn fnc_alertZombies;
_finished = ["Medic",1] call fn_loopAction;
// Check again to make sure player did not drop item
if (!_finished or !(_part in magazines player)) exitWith {};
player removeMagazine _part;
// Added Nutrition-Factor for work
["Working",0,[20,40,15,0]] call dayz_NutritionSystem;
_hits = [_vehicle,_hitpoint] call object_getHit;
_damage = _hits select 0;
_vehicle removeAction _id;
//dont waste loot on undamaged parts
if (_damage > 0) then {
//Fix the part
_selection = _hits select 1;
[_vehicle, _selection, 0, true] call fnc_veh_handleRepair;
_vehicle setvelocity [0,0,1];
//Success!
format[localize "str_player_04",_namePart,_nameType] call dayz_rollingMessages;
} else {
player addMagazine _part;
};
} else {
format[localize "str_player_03",_namePart] call dayz_rollingMessages;
};
dayz_actionInProgress = false;