mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-20 15:12:56 +03:00
Update object pickup actions
- pre-compile object_BackpackAction, object_pickupAction and the actionMonitor - switch from execVM to spawn - pickup actions are grouped under actions\pickupActions now
This commit is contained in:
48
SQF/dayz_code/actions/pickupActions/actionMonitor.sqf
Normal file
48
SQF/dayz_code/actions/pickupActions/actionMonitor.sqf
Normal file
@@ -0,0 +1,48 @@
|
||||
private ["_action","_run","_timeout","_holder", "_type", "_classname","_name","_distance"];
|
||||
|
||||
_holder = _this select 0;
|
||||
_type = _this select 1;
|
||||
_classname = _this select 2;
|
||||
_name = _this select 3;
|
||||
|
||||
_action = -1;
|
||||
_distance = player distance _holder;
|
||||
_run = true;
|
||||
_timeout = 2;
|
||||
|
||||
//diag_log format["Holder: %1, Type: %2 Classname: %3, Name: %4",_holder, _type, _classname, _name];
|
||||
|
||||
while { _run } do {
|
||||
if (alive _holder) then {
|
||||
_distance = player distance _holder;
|
||||
// Add action to player
|
||||
if ((_distance < 1.75) && {_action == -1}) then {
|
||||
_action = player addAction [format[(localize "str_init_take"),_name], "\z\addons\dayz_code\actions\pickupActions\object_pickup.sqf",[_type,_classname,_holder], 20, true, true];
|
||||
player reveal _holder;
|
||||
_timeout = 0.3;
|
||||
};
|
||||
// Remove action from player
|
||||
if ((_distance >= 1.75) && {_action != -1}) then {
|
||||
player removeAction _action;
|
||||
pickupInit = true;
|
||||
_action = -1;
|
||||
_timeout = 2;
|
||||
};
|
||||
// Stop the loop and fall back to old code
|
||||
if (_distance > 100) then {
|
||||
null = _holder addAction [format[(localize "str_init_take"),_name], "\z\addons\dayz_code\actions\pickupActions\object_pickup.sqf",[_type,_classname,_holder], 20, true, true];
|
||||
player reveal _holder;
|
||||
_run = false;
|
||||
_timeout = 0;
|
||||
};
|
||||
} else {
|
||||
if (_action != -1) then {
|
||||
player removeAction _action;
|
||||
_action = -1;
|
||||
pickupInit = true;
|
||||
};
|
||||
_timeout = 0;
|
||||
_run = false;
|
||||
};
|
||||
uiSleep _timeout;
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
if (player isKindOf "PZombie_VB") exitWith {};
|
||||
|
||||
private ["_holder", "_type", "_classname", "_actionSet", "_name"];
|
||||
|
||||
_holder = _this select 0;
|
||||
_type = _this select 1;
|
||||
_classname = _this select 2;
|
||||
|
||||
_name = getText (configFile >> _type >> _classname >> "displayName");
|
||||
|
||||
if ((!isNil "_holder") and {(!isNull _holder)}) then {
|
||||
_actionSet = _holder getVariable["actionSet", false];
|
||||
|
||||
if ((isNil "_actionSet") or {(!_actionSet)}) then {
|
||||
s_player_holderPickup = _holder addAction [format [localize "str_init_take", _name], "\z\addons\dayz_code\actions\pickupActions\object_pickup.sqf",[_type,_classname,_holder], 20, true, true];
|
||||
player reveal _holder;
|
||||
_holder setVariable["actionSet", true];
|
||||
};
|
||||
};
|
||||
100
SQF/dayz_code/actions/pickupActions/object_pickup.sqf
Normal file
100
SQF/dayz_code/actions/pickupActions/object_pickup.sqf
Normal file
@@ -0,0 +1,100 @@
|
||||
if (player isKindOf "PZombie_VB") exitWith {};
|
||||
private ["_array","_type","_classname","_holder","_playerID","_text","_broken","_claimedBy","_config","_isOk","_PlayerNear","_wpn","_ismelee","_hasBag"];
|
||||
|
||||
_array = _this select 3;
|
||||
_type = _array select 0;
|
||||
_classname = _array select 1;
|
||||
_holder = _array select 2;
|
||||
|
||||
if (player distance _holder > 3) exitwith { localize "str_pickup_limit_1","PLAIN DOWN" };
|
||||
|
||||
_playerID = getPlayerUID player;
|
||||
player removeAction s_player_holderPickup;
|
||||
_text = getText (configFile >> _type >> _classname >> "displayName");
|
||||
|
||||
if (!canPickup) exitwith {
|
||||
if (pickupInit) then {
|
||||
localize "str_pickup_limit_2" call dayz_rollingMessages;
|
||||
} else {
|
||||
localize "str_pickup_limit_3" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
_claimedBy = _holder getVariable "claimed";
|
||||
|
||||
if (isnil "claimed") then {
|
||||
_holder setVariable["claimed",_playerID,true];
|
||||
};
|
||||
|
||||
canPickup = false;
|
||||
|
||||
player playActionNow "PutDown";
|
||||
|
||||
//Adding random chance of arrow is re-usable on pickup
|
||||
_broken = ((_classname == "1Rnd_Arrow_Wood") && {[0.15] call fn_chance});
|
||||
if (_broken) exitWith { deleteVehicle _holder; localize "str_broken_arrow" call dayz_rollingMessages; };
|
||||
|
||||
_claimedBy = _holder getVariable["claimed","0"];
|
||||
|
||||
if (_claimedBy != _playerID) exitWith { format[localize "str_player_beinglooted",_text] call dayz_rollingMessages; };
|
||||
|
||||
if (_classname isKindOf "Bag_Base_EP1") exitWith {
|
||||
_PlayerNear = {isPlayer _x} count ((getPosATL _holder) nearEntities ["CAManBase", 10]) > 1;
|
||||
if (_PlayerNear) exitWith {localize "str_pickup_limit_4" call dayz_rollingMessages;};
|
||||
|
||||
//diag_log("Picked up a bag: " + _classname);
|
||||
|
||||
_hasBag = unitBackpack player;
|
||||
|
||||
if (isNull _hasBag) then {
|
||||
player action ["TakeBag", _holder];
|
||||
} else {
|
||||
player action ["putbag", player];
|
||||
uiSleep 0.03;
|
||||
player action ["TakeBag", _holder];
|
||||
};
|
||||
|
||||
//Lets wait to make sure the player has some kind of backpack.
|
||||
waitUntil { !isNull (unitBackpack player) };
|
||||
uiSleep 0.03;
|
||||
|
||||
//Lets call inventory save
|
||||
PVDZ_plr_Save = [player,nil,false];
|
||||
publicVariableServer "PVDZ_plr_Save";
|
||||
};
|
||||
|
||||
_config = (configFile >> _type >> _classname);
|
||||
|
||||
//Remove melee magazines (BIS_fnc_invAdd fix)
|
||||
false call dz_fn_meleeMagazines;
|
||||
_isOk = [player,_config] call BIS_fnc_invAdd;
|
||||
true call dz_fn_meleeMagazines;
|
||||
|
||||
if (_isOk) then {
|
||||
if (_holder isKindOf "TrapItems") then {
|
||||
if !(_holder getVariable ["fullRefund",true]) then {
|
||||
//Trap was already triggered, refund all parts except grenade
|
||||
player removeMagazine _classname;
|
||||
["equip_string",1,1] call fn_dropItem;
|
||||
["PartWoodPile",1,1] call fn_dropItem;
|
||||
["equip_duct_tape",1,1] call fn_dropItem;
|
||||
};
|
||||
PVDZ_obj_Destroy = [(_holder getVariable["ObjectID","0"]),(_holder getVariable["ObjectUID","0"]),player,_holder,dayz_authKey];
|
||||
publicVariableServer "PVDZ_obj_Destroy";
|
||||
} else {
|
||||
deleteVehicle _holder;
|
||||
};
|
||||
} else {
|
||||
if (!_isOk) exitWith {
|
||||
_holder setVariable["claimed",0,true];
|
||||
localize "str_player_24" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
uiSleep 3;
|
||||
|
||||
//adding melee mags back if needed
|
||||
_wpn = primaryWeapon player;
|
||||
_ismelee = (getNumber (configFile >> "CfgWeapons" >> _wpn >> "melee") == 1);
|
||||
if (_ismelee) then {
|
||||
call dayz_meleeMagazineCheck;
|
||||
};
|
||||
22
SQF/dayz_code/actions/pickupActions/object_pickupAction.sqf
Normal file
22
SQF/dayz_code/actions/pickupActions/object_pickupAction.sqf
Normal file
@@ -0,0 +1,22 @@
|
||||
if (player isKindOf "PZombie_VB") exitWith {};
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter from R4Z0R49.
|
||||
*/
|
||||
private["_holder","_type","_classname","_name"];
|
||||
|
||||
_holder = _this select 0;
|
||||
_type = _this select 1;
|
||||
_classname = _this select 2;
|
||||
|
||||
_name = getText (configFile >> _type >> _classname >> "displayName");
|
||||
|
||||
pickupInit = true;
|
||||
|
||||
if (_classname == "1Rnd_Arrow_Wood") then {
|
||||
[_holder,_type,_classname,_name] spawn actionMonitor;
|
||||
} else {
|
||||
s_player_holderPickup = _holder addAction [format[(localize "str_init_take"),_name], "\z\addons\dayz_code\actions\pickupActions\object_pickup.sqf",[_type,_classname,_holder], 20, true, true];
|
||||
player reveal _holder;
|
||||
pickupInit = true;
|
||||
};
|
||||
Reference in New Issue
Block a user