mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 20:13:13 +03:00
Add medic anim function with proper interrupt
Closes #1386 Vanilla commits applied:f99a3deced731b957e8eRemoved two unused files and a few variables made redundant by actionInProgress
This commit is contained in:
51
SQF/dayz_code/compile/fn_loopAction.sqf
Normal file
51
SQF/dayz_code/compile/fn_loopAction.sqf
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Runs playActionNow the specified number of times.
|
||||
Entering a vehicle, moving or vaulting interrupts the loop.
|
||||
Must be called from a scheduled context (script executed by spawn or execVM)
|
||||
|
||||
Params:
|
||||
_this select 0: String: Action name to play
|
||||
_this select 1: Number: Number of times to play action
|
||||
_this select 2: (Optional) Code: Extra condition that interrupts action when true
|
||||
|
||||
Returns:
|
||||
Bool: True (finished), false (interrupted)
|
||||
|
||||
Usage:
|
||||
_finished = ["Medic",1] call fn_loopAction;
|
||||
*/
|
||||
private ["_action","_extra","_loop","_loops","_started"];
|
||||
|
||||
_action = _this select 0;
|
||||
_loops = _this select 1;
|
||||
_extra = if (count _this > 2) then {_this select 2} else {{false}};
|
||||
|
||||
r_interrupt = false;
|
||||
_started = false;
|
||||
_loop = 0;
|
||||
|
||||
while {_loop < _loops && !r_interrupt && !(call _extra) && (vehicle player == player)} do {
|
||||
if (!_started) then {
|
||||
player playActionNow _action;
|
||||
_started = true;
|
||||
};
|
||||
|
||||
if ([_action,animationState player] call fnc_inString) then {
|
||||
waitUntil {
|
||||
getNumber(configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "disableWeapons") == 0 //Finished or entered a vehicle
|
||||
or r_interrupt or (call _extra)
|
||||
};
|
||||
_loop = _loop + 1;
|
||||
_started = false;
|
||||
};
|
||||
|
||||
uiSleep 0.1;
|
||||
};
|
||||
|
||||
if (vehicle player == player && (r_interrupt or (call _extra))) then {
|
||||
[objNull, player, rSwitchMove, ""] call RE;
|
||||
player playActionNow "Stop";
|
||||
};
|
||||
|
||||
//Player did not interrupt by moving, entering a vehicle or extra condition
|
||||
(!r_interrupt && !(call _extra) && (vehicle player == player))
|
||||
@@ -378,17 +378,6 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
|
||||
};
|
||||
};
|
||||
|
||||
// Not needed.
|
||||
/*
|
||||
if(_cursorTarget == dayz_hasFire) then {
|
||||
if ((s_player_fireout < 0) && !(_cursorTarget call isInflamed) && (player distance _cursorTarget < 3)) then {
|
||||
s_player_fireout = player addAction [localize "str_actions_self_06", "\z\addons\dayz_code\actions\fire_pack.sqf",_cursorTarget, 0, false, true];
|
||||
};
|
||||
} else {
|
||||
player removeAction s_player_fireout;
|
||||
s_player_fireout = -1;
|
||||
};
|
||||
*/
|
||||
if (_isAlive) then {
|
||||
_restrict = _typeOfCursorTarget in DZE_restrictRemoval;
|
||||
|
||||
@@ -1041,8 +1030,6 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
|
||||
s_player_cook = -1;
|
||||
player removeAction s_player_boil;
|
||||
s_player_boil = -1;
|
||||
player removeAction s_player_fireout;
|
||||
s_player_fireout = -1;
|
||||
player removeAction s_player_packtent;
|
||||
s_player_packtent = -1;
|
||||
player removeAction s_player_packtentinfected;
|
||||
|
||||
@@ -148,9 +148,7 @@ if (isNil "keyboard_keys") then {
|
||||
};
|
||||
};
|
||||
_interrupt = {
|
||||
if (vehicle player == player) then { //allow med actions in moving vehicles
|
||||
r_interrupt = true;
|
||||
};
|
||||
r_interrupt = true;
|
||||
if (DZE_Surrender) then {call dze_surrender_off};
|
||||
if (dayz_autoRun) then {call dayz_autoRunOff;};
|
||||
};
|
||||
@@ -187,13 +185,6 @@ if (isNil "keyboard_keys") then {
|
||||
};
|
||||
_handled = true;
|
||||
};
|
||||
// tents and stash construction
|
||||
_object = player getVariable ["constructionObject", objNull];
|
||||
if (!isNull _object) then {
|
||||
_dir = getDir _object - 3;
|
||||
_object setDir _dir;
|
||||
_handled = true;
|
||||
};
|
||||
dayz_dodge = true;
|
||||
};
|
||||
_build_right = {
|
||||
@@ -210,35 +201,29 @@ if (isNil "keyboard_keys") then {
|
||||
};
|
||||
_handled = true;
|
||||
};
|
||||
// tents and stash construction
|
||||
_object = player getVariable ["constructionObject", objNull];
|
||||
if (!isNull _object) then {
|
||||
_dir = getDir _object + 3;
|
||||
_object setDir _dir;
|
||||
_handled = true;
|
||||
};
|
||||
dayz_dodge = true;
|
||||
};
|
||||
|
||||
_build_camOnOff = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_buildCamera.sqf";
|
||||
|
||||
_build_str8OnOff = {
|
||||
r_interrupt = true;
|
||||
|
||||
if (0 != count Dayz_constructionContext) then {
|
||||
Dayz_constructionContext set [ 5, !(Dayz_constructionContext select 5) ];
|
||||
_handled = true;
|
||||
r_interrupt = true;
|
||||
};
|
||||
|
||||
if (animationState player in ["bunnyhopunarmed","bunnyhoprifle"]) then {
|
||||
//Fixes invisible weapon switch glitch if double tapping vault with no weapon in hands
|
||||
_handled = true;
|
||||
};
|
||||
if (player isKindOf "PZombie_VB") then {
|
||||
if (player isKindOf "PZombie_VB") then {
|
||||
_handled = true; // do not allow player zombies to vault or jump
|
||||
} else {
|
||||
_nearbyObjects = nearestObjects[getPosATL player, dayz_disallowedVault, 8];
|
||||
_nearbyObjects = nearestObjects [getPosATL player, dayz_disallowedVault, 8];
|
||||
if (count _nearbyObjects > 0) then {
|
||||
if ((diag_tickTime - dayz_lastCheckBit > 4)) then {
|
||||
if (diag_tickTime - dayz_lastCheckBit > 4) then {
|
||||
[objNull, player, rSwitchMove,"GetOver"] call RE;
|
||||
player playActionNow "GetOver";
|
||||
dayz_lastCheckBit = diag_tickTime;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
private ["_alreadyPacking","_backpacks","_bag","_campItems","_countr","_dir","_holder","_magazines","_obj","_objWpnQty","_objWpnTypes","_objectID","_objectUID","_ownerID","_packobj","_playerNear","_pos","_weapons"];
|
||||
private ["_alreadyPacking","_backpacks","_bag","_campItems","_countr","_dir","_holder","_magazines","_obj","_objWpnQty","_objWpnTypes","_objectID","_objectUID","_ownerID","_packobj","_playerNear","_pos","_weapons","_finished"];
|
||||
|
||||
_obj = _this;
|
||||
_ownerID = _obj getVariable["CharacterID","0"];
|
||||
@@ -14,10 +14,6 @@ if (DZE_permanentPlot) then {
|
||||
_ownerID = _obj getVariable["ownerPUID","0"];
|
||||
};
|
||||
|
||||
// Make sure you are the closest player to the tent
|
||||
_playerNear = _obj call dze_isnearest_player;
|
||||
if (_playerNear) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_16" call dayz_rollingMessages;};
|
||||
|
||||
// Make sure no other players are nearby
|
||||
_playerNear = {isPlayer _x} count (([_obj] call FNC_GetPos) nearEntities ["CAManBase",10]) > 1;
|
||||
if (_playerNear) exitWith {dayz_actionInProgress = false; localize "str_pickup_limit_5" call dayz_rollingMessages;};
|
||||
@@ -32,7 +28,6 @@ s_player_packtentinfected = -1;
|
||||
_campItems = ["IC_DomeTent","IC_Tent"];
|
||||
|
||||
if (_ownerID in [dayz_characterID,dayz_playerUID] or typeOf _obj in _campItems) then {
|
||||
player playActionNow "Medic";
|
||||
_alreadyPacking = _obj getVariable["packing",0];
|
||||
if (_alreadyPacking == 1) exitWith {localize "str_player_beingpacked" call dayz_rollingMessages;};
|
||||
|
||||
@@ -42,7 +37,10 @@ if (_ownerID in [dayz_characterID,dayz_playerUID] or typeOf _obj in _campItems)
|
||||
|
||||
[player,"tentpack",0,false,20] call dayz_zombieSpeak;
|
||||
[player,20,true,getPosATL player] call player_alertZombies;
|
||||
uiSleep 3;
|
||||
|
||||
_finished = ["Medic",1] call fn_loopAction;
|
||||
if (isNull _obj) exitWith {};
|
||||
if (!_finished) exitWith {_obj setVariable["packing",0,true];};
|
||||
|
||||
//place tent (local)
|
||||
_bag = createVehicle [_packobj, _pos, [], 0, "CAN_COLLIDE"];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
[_obj] spawn player_packVault;
|
||||
*/
|
||||
private ["_obj","_ownerID","_objectID","_objectUID","_alreadyPacking","_location1","_location2","_packedClass","_text","_playerNear"];
|
||||
private ["_obj","_ownerID","_objectID","_objectUID","_location1","_location2","_packedClass","_text","_playerNear","_finished"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_15" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
@@ -13,6 +13,7 @@ _text = getText (configFile >> "CfgVehicles" >> (typeOf _obj) >> "displayName");
|
||||
// Silently exit if object no longer exists
|
||||
if (isNull _obj || !(alive _obj)) exitWith { dayz_actionInProgress = false; };
|
||||
|
||||
// Server_handleSafeGear runs unscheduled and exits if object is null, so more secure check is not needed
|
||||
_playerNear = _obj call dze_isnearest_player;
|
||||
if (_playerNear) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_16" call dayz_rollingMessages;};
|
||||
|
||||
@@ -29,10 +30,6 @@ if (_objectID == "0" && _objectUID == "0") exitWith {dayz_actionInProgress = fal
|
||||
|
||||
if (!_ComboMatch && (_ownerID != dayz_playerUID)) exitWith { dayz_actionInProgress = false; s_player_packvault = -1; format[localize "str_epoch_player_119",_text] call dayz_rollingMessages;};
|
||||
|
||||
_alreadyPacking = _obj getVariable["packing",0];
|
||||
if (_alreadyPacking == 1) exitWith {dayz_actionInProgress = false; s_player_packvault = -1; format[localize "str_epoch_player_120",_text] call dayz_rollingMessages;};
|
||||
_obj setVariable["packing",1];
|
||||
|
||||
format[localize "str_epoch_player_121",_text] call dayz_rollingMessages;
|
||||
uiSleep 1;
|
||||
_location1 = getPosATL player;
|
||||
@@ -41,18 +38,18 @@ _location2 = getPosATL player;
|
||||
|
||||
if(_location1 distance _location2 > 0.1) exitWith {
|
||||
format[localize "str_epoch_player_122",_text] call dayz_rollingMessages;
|
||||
_obj setVariable["packing",0];
|
||||
s_player_packvault = -1;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
|
||||
if (!isNull _obj && alive _obj) then {
|
||||
["Working",0,[3,2,4,0]] call dayz_NutritionSystem;
|
||||
player playActionNow "Medic";
|
||||
[player,"tentpack",0,false] call dayz_zombieSpeak;
|
||||
uiSleep 3;
|
||||
|
||||
disableUserInput true; // Make sure player can not modify gear while it is being added
|
||||
_finished = ["Medic",1] call fn_loopAction;
|
||||
if (isNull _obj or !_finished) exitWith {};
|
||||
|
||||
["Working",0,[3,2,4,0]] call dayz_NutritionSystem;
|
||||
|
||||
(findDisplay 106) closeDisplay 0; // Close gear
|
||||
dze_waiting = nil;
|
||||
|
||||
@@ -62,7 +59,6 @@ if (!isNull _obj && alive _obj) then {
|
||||
publicVariableServer "PVDZE_handleSafeGear";
|
||||
//wait for response from server to verify pack was logged and gear added before proceeding
|
||||
waitUntil {!isNil "dze_waiting"};
|
||||
disableUserInput false; // Gear is done being added now
|
||||
|
||||
format[localize "str_epoch_player_123",_text] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
DayZ Epoch Vehicle Upgrades
|
||||
Made for DayZ Unleashed by [VB]AWOL please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
|
||||
*/
|
||||
private ["_proceed","_itemIn","_countIn","_missing","_missingQty","_qty","_removed","_tobe_removed_total","_textMissing","_num_removed","_removed_total","_temp_removed_array","_countr","_objectID","_objectUID","_location","_dir","_objectCharacterID","_weapons","_magazines","_backpacks","_classname","_object","_holder","_objWpnTypes","_objWpnQty","_newclassname","_requirements","_upgrade","_vehicle","_findNearestVehicles","_findNearestVehicle","_IsNearVehicle"];
|
||||
private ["_proceed","_itemIn","_countIn","_missing","_missingQty","_qty","_removed","_tobe_removed_total","_textMissing","_num_removed","_removed_total","_objectID","_objectUID","_location","_dir","_objectCharacterID","_classname","_newclassname","_upgrade","_vehicle","_findNearestVehicles","_findNearestVehicle","_IsNearVehicle","_finished","_temp_removed_array_mag","_temp_removed_array_wep"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "STR_EPOCH_PLAYER_52" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
@@ -32,7 +32,7 @@ if (_IsNearVehicle >= 1) then {
|
||||
|
||||
_classname = typeOf _vehicle;
|
||||
|
||||
// lookup vehicle && find if any upgrades are available
|
||||
// lookup vehicle and find if any upgrades are available
|
||||
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "Upgrades" >> _upgrade);
|
||||
|
||||
if (!isNil "_upgrade" && (count _upgrade) > 0) then {
|
||||
@@ -59,9 +59,9 @@ if (_IsNearVehicle >= 1) then {
|
||||
} forEach _requirementsWeapon;
|
||||
|
||||
if (_proceed) then {
|
||||
|
||||
player playActionNow "Medic";
|
||||
[player,20,true,(getPosATL player)] spawn player_alertZombies;
|
||||
_finished = ["Medic",1] call fn_loopAction;
|
||||
if (!_finished) exitWith {};
|
||||
|
||||
_temp_removed_array_mag = [];
|
||||
_temp_removed_array_wep = [];
|
||||
|
||||
Reference in New Issue
Block a user