mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 20:13:13 +03:00
Actions Done
This commit is contained in:
@@ -1,151 +1,84 @@
|
||||
private ["_vehicle","_curFuel","_newFuel","_started","_finished","_animState","_isMedic","_location1","_location2","_abort","_canName","_canSize","_configCan","_configVeh","_capacity","_nameText","_availableCans","_canText"];
|
||||
private["_vehicle","_canSize","_configVeh","_capacity","_nameType","_curFuel","_newFuel","_dis","_sfx","_fueling"];
|
||||
|
||||
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_24") , "PLAIN DOWN"] };
|
||||
DZE_ActionInProgress = true;
|
||||
|
||||
// Use target from addaction
|
||||
_vehicle = _this select 0;
|
||||
_vehicle = cursorTarget;
|
||||
_array = _this select 3;
|
||||
_cantype = _array select 0;
|
||||
_canSize = getNumber(configFile >> "cfgMagazines" >> _cantype >> "fuelQuantity");
|
||||
_emptycan = getText(configFile >> "cfgMagazines" >> _cantype >> "emptycan");
|
||||
_configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle);
|
||||
_capacity = getNumber(_configVeh >> "fuelCapacity");
|
||||
_nameType = getText(_configVeh >> "displayName");
|
||||
_curFuel = ((fuel _vehicle) * _capacity);
|
||||
_newFuel = (_curFuel + _canSize);
|
||||
_fueling = player getVariable ["fueling",false];
|
||||
_isMan = _vehicle isKindOf "Man";
|
||||
_isAnimal = _vehicle isKindOf "Animal";
|
||||
_isZombie = _vehicle isKindOf "zZombie_base";
|
||||
|
||||
_abort = false;
|
||||
if (_isMan or _isAnimal or _isZombie) exitWith {DZE_ActionInProgress = false; cutText [localize "str_refuel_notvehicle", "PLAIN DOWN"] };
|
||||
if (fuel _vehicle == 1) exitwith {DZE_ActionInProgress = false;};
|
||||
|
||||
// Static vehicle fuel information
|
||||
_configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle);
|
||||
_capacity = getNumber(_configVeh >> "fuelCapacity");
|
||||
_nameText = getText(_configVeh >> "displayName");
|
||||
player removeAction s_player_fillfuel + _capacity;
|
||||
|
||||
// _availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"];
|
||||
_availableCans = ["ItemJerrycan","ItemFuelBarrel"];
|
||||
a_player_jerryfilling = true;
|
||||
player setVariable ["fueling", true];
|
||||
|
||||
// Loop to find containers that can could hold fuel && fill them
|
||||
{
|
||||
_configCan = configFile >> "CfgMagazines" >> _x;
|
||||
if (!_fueling) then {
|
||||
[player] allowGetIn false;
|
||||
|
||||
if(_x in _availableCans) then {
|
||||
|
||||
// Get full can size
|
||||
_canName = _x;
|
||||
_canSize = getNumber(_configCan >> "fuelQuantity");
|
||||
_canText = getText(_configCan >> "displayName");
|
||||
|
||||
_curFuel = ((fuel _vehicle) * _capacity);
|
||||
_newFuel = (_curFuel + _canSize);
|
||||
if (_newFuel > _capacity) then {_newFuel = _capacity};
|
||||
_newFuel = (_newFuel / _capacity);
|
||||
|
||||
if (_newFuel <= _capacity) then {
|
||||
player removeMagazine _cantype;
|
||||
player addMagazine _emptycan;
|
||||
player playActionNow "Medic";
|
||||
|
||||
// calculate new fuel
|
||||
_newFuel = (_newFuel / _capacity);
|
||||
_dis=5;
|
||||
_sfx = "refuel";
|
||||
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
|
||||
[player,_dis,true,(getPosATL player)] call player_alertZombies;
|
||||
|
||||
//diag_log ("refuel check: " + str(_newFuel) + " / " + str(_capacity));
|
||||
// Added Nutrition-Factor for work
|
||||
["Working",0,[20,40,15,0]] call dayz_NutritionSystem;
|
||||
|
||||
cutText [format[(localize "str_epoch_player_160"),_canText], "PLAIN DOWN"];
|
||||
|
||||
// alert zombies
|
||||
[player,20,true,(getPosATL player)] spawn player_alertZombies;
|
||||
|
||||
_finished = false;
|
||||
|
||||
if(!dayz_isSwimming) then {
|
||||
|
||||
[1,1] call dayz_HungerThirst;
|
||||
// force animation
|
||||
player playActionNow "Medic";
|
||||
|
||||
r_interrupt = false;
|
||||
_animState = animationState player;
|
||||
r_doLoop = true;
|
||||
_started = false;
|
||||
|
||||
while {r_doLoop} do {
|
||||
_animState = animationState player;
|
||||
_isMedic = ["medic",_animState] call fnc_inString;
|
||||
if (_isMedic) then {
|
||||
_started = true;
|
||||
};
|
||||
if (_started && !_isMedic) then {
|
||||
r_doLoop = false;
|
||||
_finished = true;
|
||||
};
|
||||
if (r_interrupt) then {
|
||||
r_doLoop = false;
|
||||
};
|
||||
if (vehicle player != player) then {
|
||||
r_doLoop = false;
|
||||
};
|
||||
uiSleep 0.1;
|
||||
};
|
||||
r_doLoop = false;
|
||||
|
||||
if(!_finished) then {
|
||||
r_interrupt = false;
|
||||
if (vehicle player == player) then {
|
||||
[objNull, player, rSwitchMove,""] call RE;
|
||||
player playActionNow "stop";
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
// Alternate method in water make sure player stays in one spot for 6 seconds
|
||||
_location1 = getPosATL player;
|
||||
uiSleep 6;
|
||||
_location2 = getPosATL player;
|
||||
if(_location1 distance _location2 < 3) then {
|
||||
_finished = true;
|
||||
};
|
||||
};
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
// Get vehicle fuel levels again
|
||||
_curFuel = ((fuel _vehicle) * _capacity);
|
||||
_newFuel = (_curFuel + _canSize);
|
||||
|
||||
if (_newFuel <= _capacity) then {
|
||||
|
||||
// calculate minimum needed fuel
|
||||
_newFuel = (_newFuel / _capacity);
|
||||
|
||||
if(([player,_canName] call BIS_fnc_invRemove) == 1) then {
|
||||
|
||||
/* PVS/PVC - Skaronator */
|
||||
if (local _vehicle) then {
|
||||
[_vehicle,_newFuel] call local_setFuel;
|
||||
} else {
|
||||
PVDZE_send = [_vehicle,"SFuel",[_vehicle,_newFuel]];
|
||||
publicVariableServer "PVDZE_send";
|
||||
};
|
||||
|
||||
// Play sound
|
||||
[player,"refuel",0,false] call dayz_zombieSpeak;
|
||||
player addMagazine _canName+"Empty";
|
||||
cutText [format[localize "str_player_05",_nameText,_canSize], "PLAIN DOWN"];
|
||||
|
||||
call fnc_usec_medic_removeActions;
|
||||
r_action = false;
|
||||
|
||||
uiSleep 1;
|
||||
} else {
|
||||
_abort = true;
|
||||
};
|
||||
|
||||
} else {
|
||||
cutText [format[(localize "str_epoch_player_161"),_nameText], "PLAIN DOWN"];
|
||||
_abort = true;
|
||||
};
|
||||
|
||||
} else {
|
||||
cutText [(localize "str_epoch_player_87") , "PLAIN DOWN"];
|
||||
_abort = true;
|
||||
};
|
||||
|
||||
} else {
|
||||
cutText [format[(localize "str_epoch_player_161"),_nameText], "PLAIN DOWN"];
|
||||
_abort = true;
|
||||
};
|
||||
r_doLoop = true;
|
||||
_started = false;
|
||||
_finished = false;
|
||||
while {r_doLoop} do {
|
||||
_animState = animationState player;
|
||||
_isRefuel = ["medic",_animState] call fnc_inString;
|
||||
if (_isRefuel or dayz_isSwimming) then {
|
||||
_started = true;
|
||||
};
|
||||
if (_started and !_isRefuel) then {
|
||||
r_doLoop = false;
|
||||
_finished = true;
|
||||
};
|
||||
uisleep 0.1;
|
||||
};
|
||||
|
||||
// exit if abort flag was set
|
||||
if(_abort) exitWith {};
|
||||
r_doLoop = false;
|
||||
|
||||
} count magazines player;
|
||||
if (_finished) then {
|
||||
if (local _vehicle) then {
|
||||
[_vehicle,_newFuel] call local_setFuel;
|
||||
} else {
|
||||
PVDZE_send = [_vehicle,"SFuel",[_vehicle,_newFuel]];
|
||||
publicVariableServer "PVDZE_send";
|
||||
};
|
||||
|
||||
DZE_ActionInProgress = false;
|
||||
cutText [format [localize "str_player_05",_nameType,_canSize], "PLAIN DOWN"];
|
||||
uisleep 1;
|
||||
|
||||
call fnc_usec_medic_removeActions;
|
||||
};
|
||||
[player] allowGetIn true;
|
||||
} else {
|
||||
cutText [localize "str_refuel_fail","PLAIN DOWN"];
|
||||
};
|
||||
a_player_jerryfilling = false;
|
||||
r_action = false;
|
||||
player setVariable ["fueling", false];
|
||||
DZE_ActionInProgress = false;
|
||||
|
||||
Reference in New Issue
Block a user