mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-04-16 09:23:23 +03:00
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
This commit is contained in:
@@ -1,111 +1,164 @@
|
||||
/*
|
||||
DayZ Base Building Upgrades
|
||||
Made for DayZ Epoch please ask permission to use/edit/distribute email vbawol@veteranbastards.com.
|
||||
*/
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_48" call dayz_rollingMessages;};
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DayZ Base Building Downgrades
|
||||
// Made for DayZ Epoch please ask permission to use/edit/distribute email vbawol@veteranbastards.com.
|
||||
//
|
||||
// Updated by: Victor the Cleaner
|
||||
// Date: August 2021
|
||||
//
|
||||
// - Now includes helper spheres for improved player experience.
|
||||
// - Reapply damage to upgraded object if necessary.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_48" call dayz_rollingMessages;}; // Downgrade is already in progress.
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
private ["_location","_dir","_classname","_text","_object","_objectID","_objectUID","_newclassname","_refund","_obj","_upgrade","_objectCharacterID","_ownerID","_i","_invResult","_itemOut","_countOut","_abortInvAdd","_addedItems","_finished","_playerNear"];
|
||||
|
||||
player removeAction s_player_downgrade_build;
|
||||
s_player_downgrade_build = 1;
|
||||
|
||||
_obj = _this select 3;
|
||||
local _obj = _this select 3;
|
||||
|
||||
_objectCharacterID = _obj getVariable ["CharacterID","0"];
|
||||
local _objectCharacterID = _obj getVariable ["CharacterID","0"];
|
||||
|
||||
if (DZE_Lock_Door != _objectCharacterID) exitWith {dayz_actionInProgress = false; s_player_downgrade_build = -1; localize "str_epoch_player_49" call dayz_rollingMessages;};
|
||||
if (DZE_Lock_Door != _objectCharacterID) exitWith { // Unable to downgrade, you do not know the combination.
|
||||
dayz_actionInProgress = false;
|
||||
s_player_downgrade_build = -1;
|
||||
localize "str_epoch_player_49" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
_playerNear = {isPlayer _x} count (([_obj] call FNC_GetPos) nearEntities ["CAManBase", 12]) > 1;
|
||||
if (_playerNear) exitWith {dayz_actionInProgress = false; s_player_downgrade_build = -1; localize "str_pickup_limit_5" call dayz_rollingMessages;};
|
||||
local _playerNear = {isPlayer _x} count (([_obj] call FNC_GetPos) nearEntities ["CAManBase", 12]) > 1;
|
||||
|
||||
_objectID = _obj getVariable ["ObjectID","0"];
|
||||
_objectUID = _obj getVariable ["ObjectUID","0"];
|
||||
if (_playerNear) exitWith { // Another player is nearby. Only one player can be near to perform this action.
|
||||
dayz_actionInProgress = false;
|
||||
s_player_downgrade_build = -1;
|
||||
localize "str_pickup_limit_5" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (_objectID == "0" && _objectUID == "0") exitWith {dayz_actionInProgress = false; s_player_downgrade_build = -1; localize "str_epoch_player_50" call dayz_rollingMessages;};
|
||||
local _objectID = _obj getVariable ["ObjectID","0"];
|
||||
local _objectUID = _obj getVariable ["ObjectUID","0"];
|
||||
|
||||
_classname = typeOf _obj;
|
||||
if (_objectID == "0" && _objectUID == "0") exitWith { // Not setup yet.
|
||||
dayz_actionInProgress = false;
|
||||
s_player_downgrade_build = -1;
|
||||
localize "str_epoch_player_50" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
||||
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "downgradeBuilding");
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if ((count _upgrade) > 0) then {
|
||||
_newclassname = _upgrade select 0;
|
||||
_refund = _upgrade select 1;
|
||||
local _classname = typeOf _obj;
|
||||
local _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
||||
local _upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "downgradeBuilding");
|
||||
|
||||
[player,(getPosATL player),40,"repair"] spawn fnc_alertZombies;
|
||||
if (count _upgrade > 0) then {
|
||||
|
||||
local _newclassname = _upgrade select 0;
|
||||
local _refund = _upgrade select 1;
|
||||
|
||||
[_obj] call fn_displayHelpers; // create helpers
|
||||
|
||||
[player, (getPosATL player), 40, "repair"] spawn fnc_alertZombies; // make noise
|
||||
|
||||
local _finished = ["Medic",1] call fn_loopAction; // animation
|
||||
|
||||
[] call fn_displayHelpers; // delete helpers
|
||||
|
||||
_finished = ["Medic",1] call fn_loopAction;
|
||||
if (!_finished) exitWith {};
|
||||
|
||||
["Working",0,[3,2,4,0]] call dayz_NutritionSystem;
|
||||
|
||||
_invResult = false;
|
||||
_abortInvAdd = false;
|
||||
_i = 0;
|
||||
_addedItems = [];
|
||||
false call dz_fn_meleeMagazines; // Remove melee magazines (BIS_fnc_invAdd fix)
|
||||
local _invResult = false;
|
||||
local _i = 0;
|
||||
local _addedItems = [];
|
||||
local _itemOut = ""; // item class
|
||||
|
||||
false call dz_fn_meleeMagazines; // Remove melee magazines (BIS_fnc_invAdd fix)
|
||||
|
||||
{
|
||||
_itemOut = _x select 0;
|
||||
_countOut = _x select 1;
|
||||
local _countOut = _x select 1;
|
||||
|
||||
for "_x" from 1 to _countOut do {
|
||||
_invResult = [player,_itemOut] call BIS_fnc_invAdd;
|
||||
if(!_invResult) exitWith {
|
||||
_abortInvAdd = true;
|
||||
};
|
||||
if(_invResult) then {
|
||||
_i = _i + 1;
|
||||
_addedItems set [(count _addedItems),[_itemOut,1]];
|
||||
};
|
||||
};
|
||||
|
||||
if (_abortInvAdd) exitWith {};
|
||||
_invResult = [player, _itemOut] call BIS_fnc_invAdd;
|
||||
|
||||
if (!_invResult) exitWith {};
|
||||
|
||||
_i = _i + 1;
|
||||
_addedItems set [(count _addedItems), [_itemOut, 1]];
|
||||
};
|
||||
if (!_invResult) exitWith {};
|
||||
} count _refund;
|
||||
|
||||
true call dz_fn_meleeMagazines;
|
||||
|
||||
if (_i != 0) then {
|
||||
_location = _obj getVariable["OEMPos",getPosATL _obj];
|
||||
if (_i > 0) then {
|
||||
|
||||
_dir = getDir _obj;
|
||||
_vector = [(vectorDir _obj),(vectorUp _obj)];
|
||||
local _position = _obj getVariable["OEMPos", getPosATL _obj];
|
||||
local _dir = getDir _obj;
|
||||
local _vector = [(vectorDir _obj), (vectorUp _obj)];
|
||||
|
||||
if (_classname in DZE_DoorsLocked) then {
|
||||
_obj setVariable ["CharacterID",dayz_characterID,true];
|
||||
|
||||
_obj setVariable ["CharacterID", dayz_characterID, true];
|
||||
_objectCharacterID = dayz_characterID;
|
||||
};
|
||||
|
||||
_classname = _newclassname;
|
||||
|
||||
_object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"];
|
||||
local _object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"];
|
||||
//_object setDir _dir; // setdir is incompatible with setVectorDirAndUp and should not be used together on the same object https://community.bistudio.com/wiki/setVectorDirAndUp
|
||||
_object setVariable["memDir",_dir,true];
|
||||
_object setVariable["memDir", _dir, true];
|
||||
_object setVectorDirAndUp _vector;
|
||||
_object setPosATL _location;
|
||||
_object setPosATL _position;
|
||||
|
||||
format[localize "str_epoch_player_142",_text] call dayz_rollingMessages;
|
||||
format[localize "str_epoch_player_142", _text] call dayz_rollingMessages; // You have downgraded %1.
|
||||
|
||||
if (DZE_GodModeBase && {!(_classname in DZE_GodModeBaseExclude)}) then {_object addEventHandler ["HandleDamage",{false}];};
|
||||
if (DZE_GodModeBase && {!(_classname in DZE_GodModeBaseExclude)}) then {
|
||||
|
||||
_object addEventHandler ["HandleDamage", {false}];
|
||||
|
||||
} else {
|
||||
//
|
||||
// reapply damage based on armor values
|
||||
//
|
||||
local _armorOld = getNumber (configFile >> "CfgVehicles" >> (typeOf _obj) >> "armor");
|
||||
local _damageOld = damage _obj;
|
||||
|
||||
local _armorNew = getNumber (configFile >> "CfgVehicles" >> _classname >> "armor");
|
||||
local _damageNew = _damageOld;
|
||||
|
||||
// check for divide by 0
|
||||
if (_armorNew > 0) then {
|
||||
_damageNew = (_damageOld * _armorOld) / _armorNew;
|
||||
};
|
||||
|
||||
_object setDamage _damageNew;
|
||||
};
|
||||
|
||||
if (DZE_permanentPlot) then {
|
||||
_ownerID = _obj getVariable["ownerPUID","0"];
|
||||
_object setVariable ["ownerPUID",_ownerID,true];
|
||||
PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location,dayz_playerUID,_vector],_classname,_obj,player,[],dayz_authKey];
|
||||
} else {
|
||||
PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location, _vector],_classname,_obj,player,[],dayz_authKey];
|
||||
};
|
||||
publicVariableServer "PVDZE_obj_Swap";
|
||||
|
||||
local _ownerID = _obj getVariable["ownerPUID", "0"];
|
||||
_object setVariable ["ownerPUID", _ownerID, true];
|
||||
|
||||
PVDZE_obj_Swap = [_objectCharacterID, _object, [_dir, _position, dayz_playerUID, _vector], _classname, _obj, player, [], dayz_authKey];
|
||||
} else {
|
||||
PVDZE_obj_Swap = [_objectCharacterID, _object, [_dir, _position, _vector], _classname, _obj, player, [], dayz_authKey];
|
||||
};
|
||||
|
||||
publicVariableServer "PVDZE_obj_Swap";
|
||||
player reveal _object;
|
||||
|
||||
} else {
|
||||
format[localize "str_epoch_player_143",_i,getText(configFile >> "CfgMagazines" >> _itemOut >> "displayName")] call dayz_rollingMessages;
|
||||
_text = getText(configFile >> "CfgMagazines" >> _itemOut >> "displayName");
|
||||
|
||||
format[localize "str_epoch_player_143", _i, _text] call dayz_rollingMessages; // %1 of %2 could not be added to your inventory. (not enough room?) // poorly worded
|
||||
{
|
||||
[player,(_x select 0),(_x select 1)] call BIS_fnc_invRemove;
|
||||
[player, (_x select 0), (_x select 1)] call BIS_fnc_invRemove;
|
||||
|
||||
} count _addedItems;
|
||||
};
|
||||
} else {
|
||||
localize "str_epoch_player_51" call dayz_rollingMessages;
|
||||
localize "str_epoch_player_51" call dayz_rollingMessages; // No downgrades are available
|
||||
};
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
|
||||
Reference in New Issue
Block a user