mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-25 01:49:19 +03:00
Update Snap and Vector build
- pre compile all snap and vector functions, it was only pre compiled if got started from modular_build before but not if it got called from the action menu - localize snap and vector building - clean up the code - remove old Cinderwall vector fix, it looks like it is not needed anymore - Update modular_build and player_build
This commit is contained in:
@@ -2,17 +2,14 @@
|
||||
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","_finished","_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","_canBuild"];
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_40" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
private ["_location","_pos","_dir","_classname","_item","_cancel","_reason","_finished","_dis","_sfx","_tmpbuilt","_onLadder","_text","_offset","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_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","_canBuild","_friendsArr","_vector"];
|
||||
|
||||
_pos = [player] call FNC_GetPos;
|
||||
|
||||
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
|
||||
|
||||
_cancel = false;
|
||||
_canBuildOnPlot = false;
|
||||
|
||||
_vehicle = vehicle player;
|
||||
_inVehicle = (_vehicle != player);
|
||||
|
||||
@@ -48,39 +45,35 @@ _reason = "";
|
||||
_needNear = getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "neednearby");
|
||||
|
||||
{
|
||||
switch(_x) do{
|
||||
case "fire":
|
||||
{
|
||||
call {
|
||||
if (_x == "fire") exitwith {
|
||||
_distance = 3;
|
||||
_isNear = {inflamed _x} count (_pos nearObjects _distance);
|
||||
if(_isNear == 0) then {
|
||||
if (_isNear == 0) then {
|
||||
_abort = true;
|
||||
_reason = localize "STR_EPOCH_FIRE";
|
||||
};
|
||||
};
|
||||
case "workshop":
|
||||
{
|
||||
if (_x == "workshop") exitwith {
|
||||
_distance = 3;
|
||||
_isNear = count (nearestObjects [_pos, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
|
||||
if(_isNear == 0) then {
|
||||
if (_isNear == 0) then {
|
||||
_abort = true;
|
||||
_reason = localize "STR_EPOCH_WORKBENCH_NEARBY";
|
||||
};
|
||||
};
|
||||
case "fueltank":
|
||||
{
|
||||
if (_x == "fueltank") exitwith {
|
||||
_distance = 30;
|
||||
_isNear = count (nearestObjects [_pos, dayz_fuelsources, _distance]);
|
||||
if(_isNear == 0) then {
|
||||
if (_isNear == 0) then {
|
||||
_abort = true;
|
||||
_reason = localize "STR_EPOCH_VEHUP_TNK";
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _needNear;
|
||||
} count _needNear;
|
||||
|
||||
|
||||
if(_abort) exitWith {
|
||||
if (_abort) exitWith {
|
||||
format[localize "str_epoch_player_135",_reason,_distance] call dayz_rollingMessages;
|
||||
dayz_actionInProgress = false;
|
||||
};
|
||||
@@ -89,7 +82,7 @@ _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");
|
||||
|
||||
if (isText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "buildText")) then {
|
||||
_text = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "buildText");
|
||||
} else {
|
||||
@@ -98,16 +91,16 @@ if (_canBuild select 0) then {
|
||||
_ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview");
|
||||
|
||||
_lockable = 0;
|
||||
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then {
|
||||
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then {
|
||||
_lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable");
|
||||
};
|
||||
|
||||
_isAllowedUnderGround = 1;
|
||||
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
|
||||
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
|
||||
_isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
|
||||
};
|
||||
|
||||
_offset = getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
|
||||
_offset = getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
|
||||
|
||||
_location = [0,0,0];
|
||||
_isOk = true;
|
||||
@@ -121,7 +114,7 @@ if (_canBuild select 0) then {
|
||||
|
||||
_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
|
||||
|
||||
if((count _offset) <= 0) then {
|
||||
if ((count _offset) <= 0) then {
|
||||
_offset = [0,(abs(((boundingBox _object)select 0) select 1)),0];
|
||||
};
|
||||
|
||||
@@ -180,47 +173,47 @@ if (_canBuild select 0) then {
|
||||
_dir = 0;
|
||||
};
|
||||
|
||||
if(_rotate) then {
|
||||
if (_rotate) then {
|
||||
_object setDir _dir;
|
||||
_object setPosATL _position;
|
||||
//diag_log format["DEBUG Rotate BUILDING POS: %1", _position];
|
||||
};
|
||||
|
||||
if(_zheightchanged) then {
|
||||
if (_zheightchanged) then {
|
||||
detach _object;
|
||||
|
||||
_position = getPosATL _object;
|
||||
|
||||
if(_zheightdirection == "up") then {
|
||||
if (_zheightdirection == "up") then {
|
||||
_position set [2,((_position select 2)+0.1)];
|
||||
_objHDiff = _objHDiff + 0.1;
|
||||
};
|
||||
if(_zheightdirection == "down") then {
|
||||
if (_zheightdirection == "down") then {
|
||||
_position set [2,((_position select 2)-0.1)];
|
||||
_objHDiff = _objHDiff - 0.1;
|
||||
};
|
||||
|
||||
if(_zheightdirection == "up_alt") then {
|
||||
if (_zheightdirection == "up_alt") then {
|
||||
_position set [2,((_position select 2)+1)];
|
||||
_objHDiff = _objHDiff + 1;
|
||||
};
|
||||
if(_zheightdirection == "down_alt") then {
|
||||
if (_zheightdirection == "down_alt") then {
|
||||
_position set [2,((_position select 2)-1)];
|
||||
_objHDiff = _objHDiff - 1;
|
||||
};
|
||||
|
||||
if(_zheightdirection == "up_ctrl") then {
|
||||
if (_zheightdirection == "up_ctrl") then {
|
||||
_position set [2,((_position select 2)+0.01)];
|
||||
_objHDiff = _objHDiff + 0.01;
|
||||
};
|
||||
if(_zheightdirection == "down_ctrl") then {
|
||||
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 {
|
||||
if ((_isAllowedUnderGround == 0) && {(_position select 2) < 0}) then {
|
||||
_position set [2,0];
|
||||
};
|
||||
|
||||
@@ -236,16 +229,17 @@ if (_canBuild select 0) then {
|
||||
|
||||
_location2 = getPosATL player;
|
||||
|
||||
if(DZE_5) exitWith {
|
||||
if (DZE_5) exitWith {
|
||||
_isOk = false;
|
||||
detach _object;
|
||||
_dir = getDir _object;
|
||||
_position = getPosATL _object;
|
||||
_vector = [(vectorDir _object),(vectorUp _object)];
|
||||
//diag_log format["DEBUG BUILDING POS: %1", _position];
|
||||
deleteVehicle _object;
|
||||
};
|
||||
|
||||
if(_location1 distance _location2 > DZE_buildMaxMoveDistance) exitWith {
|
||||
if (_location1 distance _location2 > DZE_buildMaxMoveDistance) exitWith {
|
||||
_isOk = false;
|
||||
_cancel = true;
|
||||
_reason = format[localize "STR_EPOCH_BUILD_FAIL_MOVED",DZE_buildMaxMoveDistance];
|
||||
@@ -253,14 +247,14 @@ if (_canBuild select 0) then {
|
||||
deleteVehicle _object;
|
||||
};
|
||||
|
||||
if(abs(_objHDiff) > DZE_buildMaxHeightDistance) exitWith {
|
||||
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 (DZE_BuildHeightLimit > 0 && {_position select 2 > DZE_BuildHeightLimit}) exitWith {
|
||||
_isOk = false;
|
||||
_cancel = true;
|
||||
@@ -292,9 +286,9 @@ if (_canBuild select 0) then {
|
||||
};
|
||||
|
||||
// No building in trader zones
|
||||
if(!canbuild) then { _cancel = true; _reason = format[localize "STR_EPOCH_PLAYER_136",localize "STR_EPOCH_TRADER"]; };
|
||||
if (!canbuild) then { _cancel = true; _reason = format[localize "STR_EPOCH_PLAYER_136",localize "STR_EPOCH_TRADER"]; };
|
||||
|
||||
if(!_cancel) then {
|
||||
if (!_cancel) then {
|
||||
|
||||
_classname = _classnametmp;
|
||||
|
||||
@@ -306,7 +300,7 @@ if (_canBuild select 0) then {
|
||||
// Get position based on object
|
||||
_location = _position;
|
||||
|
||||
if((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then {
|
||||
if ((_isAllowedUnderGround == 0) && {(_location select 2) < 0}) then {
|
||||
_location set [2,0];
|
||||
};
|
||||
|
||||
@@ -339,16 +333,16 @@ if (_canBuild select 0) then {
|
||||
|
||||
_finished = ["Medic",1,{player getVariable["combattimeout",0] >= diag_tickTime or DZE_cancelBuilding}] call fn_loopAction;
|
||||
|
||||
if(!_finished) exitWith {
|
||||
if (!_finished) exitWith {
|
||||
_isOk = false;
|
||||
_proceed = false;
|
||||
};
|
||||
|
||||
if(_finished) then {
|
||||
if (_finished) then {
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
|
||||
if(_counter == _limit) exitWith {
|
||||
if (_counter == _limit) exitWith {
|
||||
_isOk = false;
|
||||
_proceed = true;
|
||||
};
|
||||
@@ -357,14 +351,14 @@ if (_canBuild select 0) then {
|
||||
if (_proceed) then {
|
||||
|
||||
_num_removed = ([player,_item] call BIS_fnc_invRemove);
|
||||
if(_num_removed == 1) then {
|
||||
if (_num_removed == 1) then {
|
||||
["Working",0,[20,10,5,0]] call dayz_NutritionSystem;
|
||||
call player_forceSave;
|
||||
format[localize "str_build_01",_text] call dayz_rollingMessages;
|
||||
|
||||
_tmpbuilt setVariable ["OEMPos",_location,true];
|
||||
|
||||
if(_lockable > 1) then {
|
||||
if (_lockable > 1) then {
|
||||
|
||||
_combinationDisplay = "";
|
||||
|
||||
@@ -449,7 +443,7 @@ if (_canBuild select 0) then {
|
||||
};
|
||||
if (DZE_GodModeBase && {!(_classname in DZE_GodModeBaseExclude)}) then {
|
||||
_tmpbuilt addEventHandler ["HandleDamage",{false}];
|
||||
};
|
||||
};
|
||||
} else {
|
||||
deleteVehicle _tmpbuilt;
|
||||
localize "str_epoch_player_46" call dayz_rollingMessages;
|
||||
|
||||
Reference in New Issue
Block a user