Files
DayZ-Epoch/SQF/dayz_code/compile/player_packTent.sqf
A Man 58c4a4d1f7 Update remove/deconstruct, add helpers
Removing and Deconstructing Objects

- Now adds colored helpers to modular objects.
- Green: Refund one kit.
- Blue:  Refund entire recipe of parts (multiple items).
- Red:	 No refund will be given. Either because the object is too damaged, or the refund feature is disabled.
- If the object has a door open while selected, no helper will display/float in the open door space.
- The gear panel will only open if a refund is available.
- If a lit fire barrel is removed, the flame will now be extinguished.
- If a plot pole is removed, plot boundary helpers will now be deleted.
- Refunds for non-modular objects are handled by their respective config settings.
- Removed non-lockable storage objects will now refund their contents.
- The corresponding storage kit will be refunded.
- If there is room outdoors, backpacks will be arranged in a neat circle close to the refund point.
- If the spawn point is too close to a building, backpacks will spawn at the player's location.
- Helpers will now appear on wrecked/ruined modular objects.
- Helper color arrays were changed to helper transparency values only, to make it easier (and safer) for server owners.

Upgrading, Downgrading, Maintaining and Packing Objects

- Now includes colored helper spheres for improved player experience.
- Reapply damage to upgraded/downgraded object if necessary.

Changes made by @Victor-the-Cleaner
2021-09-19 18:50:14 +02:00

98 lines
3.4 KiB
Plaintext

///////////////////////////////////////////////////////////////////////////////////////////////////
//
// [_obj] call player_packTent;
//
// Updated by: Victor the Cleaner
// Date: August 2021
//
// - Now includes helper spheres for improved player experience
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (dayz_actionInProgress) exitWith {
localize "str_player_actionslimit" call dayz_rollingMessages; // Wait for the previous action to complete to perform another!
};
dayz_actionInProgress = true;
local _obj = _this;
local _objType = typeOf _obj;
local _ownerID = _obj getVariable["CharacterID","0"];
local _objectID = _obj getVariable["ObjectID","0"];
local _objectUID = _obj getVariable["ObjectUID","0"];
if (DZE_permanentPlot) then {
_ownerID = _obj getVariable["ownerPUID","0"];
};
local _playerNear = {isPlayer _x} count (([_obj] call FNC_GetPos) nearEntities ["CAManBase", 12]) > 1;
if (_playerNear) exitWith {
dayz_actionInProgress = false;
localize "str_pickup_limit_5" call dayz_rollingMessages; // Another player is nearby. Only one player can be near to perform this action.
};
local _packobj = getText (configFile >> "CfgVehicles" >> _objType >> "pack"); // classname
player removeAction s_player_packtent;
s_player_packtent = -1;
player removeAction s_player_packtentinfected;
s_player_packtentinfected = -1;
if (_ownerID in [dayz_characterID, dayz_playerUID] || {_objType in ["IC_DomeTent","IC_Tent"]}) then { // if player is the owner, or infected camp items
local _alreadyPacking = _obj getVariable["packing", 0];
if (_alreadyPacking == 1) exitWith {
localize "str_player_beingpacked" call dayz_rollingMessages; // That tent is already being packed.
};
local _text = getText (configFile >> "CfgVehicles" >> _objType >> "displayName");
format[localize "str_epoch_player_121", _text] call dayz_rollingMessages; // Packing %1, move from this position to cancel within 5 seconds.
_obj setVariable["packing", 1, true];
local _dir = direction _obj;
local _pos = getPosATL _obj;
[_obj, DZE_NoRefundTexture] call fn_displayHelpers; // create helpers (red)
[player,(getPosATL player), 20, "tentpack"] spawn fnc_alertZombies; // make noise
local _finished = ["Medic",1] call fn_loopAction; // animation
[] call fn_displayHelpers; // delete helpers
if (isNull _obj) exitWith {};
if (!_finished) exitWith {_obj setVariable["packing", 0, true];}; // cancel & reset
_pos set [2, (getPosATL player) select 2];
if (_pos select 2 < 0) then { // match player height or place on ground
_pos set [2,0];
};
local _bag = _packobj createVehicle [0,0,0]; // packed tent
_bag setDir _dir;
_bag setPosATL _pos;
local _holder = "WeaponHolder" createVehicle [0,0,0]; // any packed items go here
_holder setPosATL _pos;
local _weapons = getWeaponCargo _obj; // prepare items
local _magazines = getMagazineCargo _obj;
local _backpacks = getBackpackCargo _obj;
PVDZ_obj_Destroy = [_objectID, _objectUID, player, _pos, dayz_authKey, false]; // delete original tent
publicVariableServer "PVDZ_obj_Destroy";
deleteVehicle _obj;
[_weapons, _magazines, _backpacks, _holder] call fn_addCargo; // pile everything onto the ground
player reveal _holder;
localize "str_success_tent_pack" call dayz_rollingMessages; // Your tent has been packed
} else {
localize "str_fail_tent_pack" call dayz_rollingMessages; // You cannot pack this tent, it is not yours
};
dayz_actionInProgress = false;