mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-22 03:16:27 +03:00
Plot for Life and Plot Management work best together. They essentially provide the same functionality. Both let you keep your plot after death by using UID instead of CharacterID. Plot Management doesn't even have an option to save characterID, so by default it is always keeping all friends and the owner permanently until they are removed. The only major difference between them is Plot For Life also adds permanent ownership of built items on the plot, which is behavior most people expect. It doesn't make sense to keep ownership of the plot after death but not the other objects built on it. The other functionality it adds (take ownership) can be toggled with a config variable. It is rare that someone would want Plot For Life enabled, but Plot Management disabled or vice versa. If they really want that they can still do it manually, but consolidating them to a single config option greatly simplifies things for everyone else. I removed links to mod githubs because many changes have been made to the 1.0.6 versions, so outdated information there will likely confuse people. Authors are already credited in the README and change log. In variables.sqf "DZ_storage_base" is now the parent class which includes all tents and stashes. DZE_checkNearbyRadius variable is not used (identical to DZE_PlotPole select 0).
484 lines
14 KiB
Plaintext
484 lines
14 KiB
Plaintext
// If an array was passed redirect to vanilla player_build (Epoch items pass a string)
|
|
if (!isNil "_this" && {typeName _this == "ARRAY"} && {count _this > 0}) exitWith {_this spawn player_buildVanilla;};
|
|
/*
|
|
DayZ Base Building
|
|
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
|
|
*/
|
|
private ["_location","_pos","_dir","_classname","_item","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_tmpbuilt","_onLadder","_require","_text","_offset","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_distance","_classnametmp","_ghost","_lockable","_zheightchanged","_rotate","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display","_combinationDisplay","_zheightdirection","_abort","_isNear","_needNear","_vehicle","_inVehicle","_objHDiff","_isAllowedUnderGround","_playerUID","_canBuild"];
|
|
|
|
if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_40" call dayz_rollingMessages;};
|
|
DZE_ActionInProgress = true;
|
|
_pos = [player] call FNC_GetPos;
|
|
|
|
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
|
|
|
|
_cancel = false;
|
|
_canBuildOnPlot = false;
|
|
_playerUID = [player] call FNC_GetPlayerUID;
|
|
|
|
_vehicle = vehicle player;
|
|
_inVehicle = (_vehicle != player);
|
|
|
|
DZE_Q = false;
|
|
DZE_Z = false;
|
|
|
|
DZE_Q_alt = false;
|
|
DZE_Z_alt = false;
|
|
|
|
DZE_Q_ctrl = false;
|
|
DZE_Z_ctrl = false;
|
|
|
|
DZE_5 = false;
|
|
DZE_4 = false;
|
|
DZE_6 = false;
|
|
|
|
DZE_cancelBuilding = false;
|
|
|
|
call gear_ui_init;
|
|
closeDialog 1;
|
|
|
|
if (dayz_isSwimming) exitWith {DZE_ActionInProgress = false; localize "str_player_26" call dayz_rollingMessages;};
|
|
if (_inVehicle) exitWith {DZE_ActionInProgress = false; localize "str_epoch_player_42" call dayz_rollingMessages;};
|
|
if (_onLadder) exitWith {DZE_ActionInProgress = false; localize "str_player_21" call dayz_rollingMessages;};
|
|
if (player getVariable["combattimeout",0] >= diag_tickTime) exitWith {DZE_ActionInProgress = false; localize "str_epoch_player_43" call dayz_rollingMessages;};
|
|
|
|
_item = _this;
|
|
|
|
// Need Near Requirements
|
|
_abort = false;
|
|
_reason = "";
|
|
|
|
_needNear = getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "neednearby");
|
|
|
|
{
|
|
switch(_x) do{
|
|
case "fire":
|
|
{
|
|
_distance = 3;
|
|
_isNear = {inflamed _x} count (_pos nearObjects _distance);
|
|
if(_isNear == 0) then {
|
|
_abort = true;
|
|
_reason = localize "STR_EPOCH_FIRE";
|
|
};
|
|
};
|
|
case "workshop":
|
|
{
|
|
_distance = 3;
|
|
_isNear = count (nearestObjects [_pos, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
|
|
if(_isNear == 0) then {
|
|
_abort = true;
|
|
_reason = localize "STR_BLD_name_ItemWorkshop";
|
|
};
|
|
};
|
|
case "fueltank":
|
|
{
|
|
_distance = 30;
|
|
_isNear = count (nearestObjects [_pos, dayz_fuelsources, _distance]);
|
|
if(_isNear == 0) then {
|
|
_abort = true;
|
|
_reason = localize "STR_EPOCH_VEHUP_TNK";
|
|
};
|
|
};
|
|
};
|
|
} forEach _needNear;
|
|
|
|
|
|
if(_abort) exitWith {
|
|
format[localize "str_epoch_player_135",_reason,_distance] call dayz_rollingMessages;
|
|
DZE_ActionInProgress = false;
|
|
};
|
|
|
|
_canBuild = [_pos, _item, true] call dze_buildChecks;
|
|
if (_canBuild select 0) then {
|
|
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
|
|
_classnametmp = _classname;
|
|
_require = getArray (configFile >> "cfgMagazines" >> _this >> "ItemActions" >> "Build" >> "require");
|
|
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
|
_ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview");
|
|
|
|
_lockable = 0;
|
|
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then {
|
|
_lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable");
|
|
};
|
|
|
|
_isAllowedUnderGround = 1;
|
|
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
|
|
_isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
|
|
};
|
|
|
|
_offset = getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
|
|
|
|
_location = [0,0,0];
|
|
_isOk = true;
|
|
_location1 = [player] call FNC_GetPos; // get inital players position
|
|
_dir = getDir player;
|
|
|
|
// if ghost preview available use that instead
|
|
if (_ghost != "") then {
|
|
_classname = _ghost;
|
|
};
|
|
|
|
_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
|
|
|
|
if((count _offset) <= 0) then {
|
|
_offset = [0,(abs(((boundingBox _object)select 0) select 1)),0];
|
|
};
|
|
|
|
_object attachTo [player,_offset];
|
|
|
|
_position = getPosATL _object;
|
|
|
|
localize "str_epoch_player_45" call dayz_rollingMessages;
|
|
|
|
_objHDiff = 0;
|
|
|
|
while {_isOk} do {
|
|
|
|
_zheightchanged = false;
|
|
_zheightdirection = "";
|
|
_rotate = false;
|
|
|
|
if (DZE_Q) then {
|
|
DZE_Q = false;
|
|
_zheightdirection = "up";
|
|
_zheightchanged = true;
|
|
};
|
|
if (DZE_Z) then {
|
|
DZE_Z = false;
|
|
_zheightdirection = "down";
|
|
_zheightchanged = true;
|
|
};
|
|
if (DZE_Q_alt) then {
|
|
DZE_Q_alt = false;
|
|
_zheightdirection = "up_alt";
|
|
_zheightchanged = true;
|
|
};
|
|
if (DZE_Z_alt) then {
|
|
DZE_Z_alt = false;
|
|
_zheightdirection = "down_alt";
|
|
_zheightchanged = true;
|
|
};
|
|
if (DZE_Q_ctrl) then {
|
|
DZE_Q_ctrl = false;
|
|
_zheightdirection = "up_ctrl";
|
|
_zheightchanged = true;
|
|
};
|
|
if (DZE_Z_ctrl) then {
|
|
DZE_Z_ctrl = false;
|
|
_zheightdirection = "down_ctrl";
|
|
_zheightchanged = true;
|
|
};
|
|
if (DZE_4) then {
|
|
_rotate = true;
|
|
DZE_4 = false;
|
|
_dir = 180;
|
|
};
|
|
if (DZE_6) then {
|
|
_rotate = true;
|
|
DZE_6 = false;
|
|
_dir = 0;
|
|
};
|
|
|
|
if(_rotate) then {
|
|
_object setDir _dir;
|
|
_object setPosATL _position;
|
|
//diag_log format["DEBUG Rotate BUILDING POS: %1", _position];
|
|
};
|
|
|
|
if(_zheightchanged) then {
|
|
detach _object;
|
|
|
|
_position = getPosATL _object;
|
|
|
|
if(_zheightdirection == "up") then {
|
|
_position set [2,((_position select 2)+0.1)];
|
|
_objHDiff = _objHDiff + 0.1;
|
|
};
|
|
if(_zheightdirection == "down") then {
|
|
_position set [2,((_position select 2)-0.1)];
|
|
_objHDiff = _objHDiff - 0.1;
|
|
};
|
|
|
|
if(_zheightdirection == "up_alt") then {
|
|
_position set [2,((_position select 2)+1)];
|
|
_objHDiff = _objHDiff + 1;
|
|
};
|
|
if(_zheightdirection == "down_alt") then {
|
|
_position set [2,((_position select 2)-1)];
|
|
_objHDiff = _objHDiff - 1;
|
|
};
|
|
|
|
if(_zheightdirection == "up_ctrl") then {
|
|
_position set [2,((_position select 2)+0.01)];
|
|
_objHDiff = _objHDiff + 0.01;
|
|
};
|
|
if(_zheightdirection == "down_ctrl") then {
|
|
_position set [2,((_position select 2)-0.01)];
|
|
_objHDiff = _objHDiff - 0.01;
|
|
};
|
|
|
|
_object setDir (getDir _object);
|
|
|
|
if((_isAllowedUnderGround == 0) && ((_position select 2) < 0)) then {
|
|
_position set [2,0];
|
|
};
|
|
|
|
_object setPosATL _position;
|
|
|
|
//diag_log format["DEBUG Change BUILDING POS: %1", _position];
|
|
|
|
_object attachTo [player];
|
|
|
|
};
|
|
|
|
uiSleep 0.5;
|
|
|
|
_location2 = getPosATL player;
|
|
|
|
if(DZE_5) exitWith {
|
|
_isOk = false;
|
|
detach _object;
|
|
_dir = getDir _object;
|
|
_position = getPosATL _object;
|
|
//diag_log format["DEBUG BUILDING POS: %1", _position];
|
|
deleteVehicle _object;
|
|
};
|
|
|
|
if(_location1 distance _location2 > DZE_buildMaxMoveDistance) exitWith {
|
|
_isOk = false;
|
|
_cancel = true;
|
|
_reason = format[localize "STR_EPOCH_BUILD_FAIL_MOVED",DZE_buildMaxMoveDistance];
|
|
detach _object;
|
|
deleteVehicle _object;
|
|
};
|
|
|
|
if(abs(_objHDiff) > DZE_buildMaxHeightDistance) exitWith {
|
|
_isOk = false;
|
|
_cancel = true;
|
|
_reason = format[localize "STR_EPOCH_BUILD_FAIL_HEIGHT",DZE_buildMaxHeightDistance];
|
|
detach _object;
|
|
deleteVehicle _object;
|
|
};
|
|
|
|
if (player getVariable["combattimeout",0] >= diag_tickTime) exitWith {
|
|
_isOk = false;
|
|
_cancel = true;
|
|
_reason = localize "str_epoch_player_43";
|
|
detach _object;
|
|
deleteVehicle _object;
|
|
};
|
|
|
|
if (DZE_cancelBuilding) exitWith {
|
|
_isOk = false;
|
|
_cancel = true;
|
|
_reason = localize "STR_EPOCH_PLAYER_46";
|
|
detach _object;
|
|
deleteVehicle _object;
|
|
};
|
|
};
|
|
|
|
//No building on roads unless toggled
|
|
if (!DZE_BuildOnRoads) then {
|
|
if (isOnRoad _position) then { _cancel = true; _reason = localize "STR_EPOCH_BUILD_FAIL_ROAD"; };
|
|
};
|
|
|
|
// No building in trader zones
|
|
if(!canbuild) then { _cancel = true; _reason = format[localize "STR_EPOCH_PLAYER_136",localize "STR_EPOCH_TRADER"]; };
|
|
|
|
if(!_cancel) then {
|
|
|
|
_classname = _classnametmp;
|
|
|
|
// Start Build
|
|
_tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
|
|
|
|
_tmpbuilt setdir _dir;
|
|
|
|
// Get position based on object
|
|
_location = _position;
|
|
|
|
if((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then {
|
|
_location set [2,0];
|
|
};
|
|
|
|
_tmpbuilt setPosATL _location;
|
|
|
|
|
|
format[localize "str_epoch_player_138",_text] call dayz_rollingMessages;
|
|
|
|
_limit = 3;
|
|
|
|
if (DZE_StaticConstructionCount > 0) then {
|
|
_limit = DZE_StaticConstructionCount;
|
|
}
|
|
else {
|
|
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then {
|
|
_limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount");
|
|
};
|
|
};
|
|
|
|
_isOk = true;
|
|
_proceed = false;
|
|
_counter = 0;
|
|
|
|
while {_isOk} do {
|
|
|
|
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
|
|
player playActionNow "Medic";
|
|
|
|
_dis=20;
|
|
_sfx = "repair";
|
|
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
|
|
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
|
|
|
|
r_interrupt = false;
|
|
r_doLoop = true;
|
|
_started = false;
|
|
_finished = false;
|
|
|
|
while {r_doLoop} do {
|
|
_animState = animationState player;
|
|
_isMedic = ["medic",_animState] call fnc_inString;
|
|
if (_isMedic) then {
|
|
_started = true;
|
|
};
|
|
if (_started && !_isMedic) then {
|
|
r_doLoop = false;
|
|
_finished = true;
|
|
};
|
|
if (r_interrupt || (player getVariable["combattimeout",0] >= diag_tickTime)) then {
|
|
r_doLoop = false;
|
|
};
|
|
if (DZE_cancelBuilding) exitWith {
|
|
r_doLoop = false;
|
|
};
|
|
uiSleep 0.1;
|
|
};
|
|
r_doLoop = false;
|
|
|
|
|
|
if(!_finished) exitWith {
|
|
_isOk = false;
|
|
_proceed = false;
|
|
};
|
|
|
|
if(_finished) then {
|
|
_counter = _counter + 1;
|
|
};
|
|
|
|
format[localize "str_epoch_player_139",_text, _counter,_limit] call dayz_rollingMessages;
|
|
|
|
if(_counter == _limit) exitWith {
|
|
_isOk = false;
|
|
_proceed = true;
|
|
};
|
|
|
|
};
|
|
|
|
if (_proceed) then {
|
|
|
|
_num_removed = ([player,_item] call BIS_fnc_invRemove);
|
|
if(_num_removed == 1) then {
|
|
|
|
format[localize "str_build_01",_text] call dayz_rollingMessages;
|
|
|
|
//if (_canBuild select 1) then {
|
|
//[] spawn player_plotPreview;
|
|
//};
|
|
|
|
_tmpbuilt setVariable ["OEMPos",_location,true];
|
|
|
|
if(_lockable > 1) then {
|
|
|
|
_combinationDisplay = "";
|
|
|
|
switch (_lockable) do {
|
|
|
|
case 2: { // 2 lockbox
|
|
_combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
|
|
_combination_2 = floor(random 10);
|
|
_combination_3 = floor(random 10);
|
|
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
|
dayz_combination = _combination;
|
|
if (_combination_1 == 100) then {
|
|
_combination_1_Display = localize "STR_EPOCH_RED";
|
|
};
|
|
if (_combination_1 == 101) then {
|
|
_combination_1_Display = localize "STR_EPOCH_GREEN";
|
|
};
|
|
if (_combination_1 == 102) then {
|
|
_combination_1_Display = localize "STR_EPOCH_BLUE";
|
|
};
|
|
_combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
|
|
};
|
|
|
|
case 3: { // 3 combolock
|
|
_combination_1 = floor(random 10);
|
|
_combination_2 = floor(random 10);
|
|
_combination_3 = floor(random 10);
|
|
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
|
dayz_combination = _combination;
|
|
_combinationDisplay = _combination;
|
|
};
|
|
|
|
case 4: { // 4 safe
|
|
_combination_1 = floor(random 10);
|
|
_combination_2 = floor(random 10);
|
|
_combination_3 = floor(random 10);
|
|
_combination_4 = floor(random 10);
|
|
_combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
|
|
dayz_combination = _combination;
|
|
_combinationDisplay = _combination;
|
|
};
|
|
};
|
|
|
|
_tmpbuilt setVariable ["CharacterID",_combination,true];
|
|
PVDZ_obj_Publish = [_combination,_tmpbuilt,[_dir,_location],[]];
|
|
if (DZE_permanentPlot) then {
|
|
_tmpbuilt setVariable ["ownerPUID",_playerUID,true];
|
|
PVDZ_obj_Publish = [_combination,_tmpbuilt,[_dir,_location,_playerUID],_classname];
|
|
};
|
|
publicVariableServer "PVDZ_obj_Publish";
|
|
|
|
format[localize "str_epoch_player_140",_combinationDisplay,_text] call dayz_rollingMessages;
|
|
systemChat format[localize "str_epoch_player_140",_combinationDisplay,_text];
|
|
|
|
} else {
|
|
_tmpbuilt setVariable ["CharacterID",dayz_characterID,true];
|
|
if (DZE_permanentPlot) then {
|
|
_tmpbuilt setVariable ["ownerPUID",_playerUID,true];
|
|
};
|
|
// fire?
|
|
if(_tmpbuilt isKindOf "Land_Fire_DZ") then {
|
|
_tmpbuilt spawn player_fireMonitor;
|
|
} else {
|
|
PVDZ_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location],[]];
|
|
if (DZE_permanentPlot) then {
|
|
PVDZ_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location,_playerUID],_classname];
|
|
};
|
|
publicVariableServer "PVDZ_obj_Publish";
|
|
};
|
|
};
|
|
} else {
|
|
deleteVehicle _tmpbuilt;
|
|
localize "str_epoch_player_46" call dayz_rollingMessages;
|
|
};
|
|
|
|
} else {
|
|
r_interrupt = false;
|
|
if (vehicle player == player) then {
|
|
[objNull, player, rSwitchMove,""] call RE;
|
|
player playActionNow "stop";
|
|
};
|
|
|
|
deleteVehicle _tmpbuilt;
|
|
|
|
localize "str_epoch_player_46" call dayz_rollingMessages;
|
|
};
|
|
|
|
} else {
|
|
format[localize "str_epoch_player_47",_text,_reason] call dayz_rollingMessages;
|
|
};
|
|
};
|
|
|
|
DZE_ActionInProgress = false; |