Add proper medic anim

The medic animation can be interrupted now. Also clean up the script from redundant code.
This commit is contained in:
A Man
2019-11-01 16:07:39 +01:00
parent bc75ad8590
commit 91a5ccf06a

View File

@@ -1,8 +1,8 @@
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true; dayz_actionInProgress = true;
private ["_vehicle","_canSize","_configVeh","_capacity","_nameType","_curFuel","_newFuel","_dis","_sfx","_fueling","_array","_cantype", private ["_vehicle","_canSize","_configVeh","_capacity","_nameType","_curFuel","_newFuel","_dis","_sfx","_array","_cantype",
"_emptycan","_started","_finished","_animState","_isRefuel","_type"]; "_emptycan","_finished","_type"];
_array = _this select 3; _array = _this select 3;
_cantype = _array select 0; _cantype = _array select 0;
@@ -15,68 +15,41 @@ _capacity = getNumber(_configVeh >> "fuelCapacity");
_nameType = getText(_configVeh >> "displayName"); _nameType = getText(_configVeh >> "displayName");
_curFuel = ((fuel _vehicle) * _capacity); _curFuel = ((fuel _vehicle) * _capacity);
_newFuel = (_curFuel + _canSize); _newFuel = (_curFuel + _canSize);
_fueling = player getVariable ["fueling",false];
if (fuel _vehicle == 1 || !(_canType in magazines player)) exitWith {dayz_actionInProgress = false;}; if (fuel _vehicle == 1 || {!(_canType in magazines player)}) exitWith {dayz_actionInProgress = false;};
player removeAction s_player_fillfuel + _capacity; player removeAction s_player_fillfuel + _capacity;
player setVariable ["fueling", true];
if (!_fueling) then { _dis=5;
[player] allowGetIn false; _sfx = "refuel";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] call player_alertZombies;
_finished = ["Medic",1] call fn_loopAction;
if (_finished) then {
if (_newFuel > _capacity) then {_newFuel = _capacity}; if (_newFuel > _capacity) then {_newFuel = _capacity};
_newFuel = (_newFuel / _capacity); _newFuel = (_newFuel / _capacity);
player removeMagazine _cantype; player removeMagazine _cantype;
player addMagazine _emptycan; player addMagazine _emptycan;
player playActionNow "Medic";
_dis=5;
_sfx = "refuel";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] call player_alertZombies;
// Added Nutrition-Factor for work // Added Nutrition-Factor for work
["Working",0,[0,1,3,0]] call dayz_NutritionSystem; ["Working",0,[0,1,3,0]] call dayz_NutritionSystem;
if ((_type == "Generator_DZ") && {!(_vehicle getVariable ["GeneratorFilled", false])}) then {
r_doLoop = true; _vehicle setVariable ["GeneratorFilled", true, 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;
}; };
r_doLoop = false; if (local _vehicle) then {
[_vehicle,_newFuel] call local_setFuel;
if (_finished) then { } else {
if ((_type == "Generator_DZ") && {!(_vehicle getVariable ["GeneratorFilled", false])}) then { PVDZ_send = [_vehicle,"SetFuel",[_vehicle,_newFuel]];
_vehicle setVariable ["GeneratorFilled", true, true]; publicVariableServer "PVDZ_send";
};
if (local _vehicle) then {
[_vehicle,_newFuel] call local_setFuel;
} else {
PVDZ_send = [_vehicle,"SetFuel",[_vehicle,_newFuel]];
publicVariableServer "PVDZ_send";
};
format[localize "str_player_05",_nameType,_canSize] call dayz_rollingMessages;
uiSleep 1;
call fnc_usec_medic_removeActions;
}; };
[player] allowGetIn true;
format[localize "str_player_05",_nameType,_canSize] call dayz_rollingMessages;
uiSleep 1;
call fnc_usec_medic_removeActions;
} else { } else {
localize "str_refuel_fail" call dayz_rollingMessages; localize "str_epoch_player_26" call dayz_rollingMessages;
}; };
r_action = false;
player setVariable ["fueling", false];
dayz_actionInProgress = false; dayz_actionInProgress = false;