diff --git a/CHANGE LOG 1.0.6.txt b/CHANGE LOG 1.0.6.txt index 0fd53a46e..fd965c027 100644 --- a/CHANGE LOG 1.0.6.txt +++ b/CHANGE LOG 1.0.6.txt @@ -36,6 +36,7 @@ [NEW] Temperature factors are now configurable with DZE_TempVars see ConfigVariables.sqf for more info @icomrade [NEW] Weather effects are now configurable with DZE_WeatherVariables See DynamicWeatherEffects.sqf for info on these values @icomrade [NEW] Full height cinderblock wall kits are now in game, classname "full_cinder_wall_kit" #1172 @icomrade +[NEW] Vector Building is now part of Epoch, only enabled with Snap Building DZE_modularBuild = true; Note there is no option to turn off Vector Building with Snap Building enabled @strikerforce @icomrade [CHANGED] Many duplicate functions and variables were renamed. See Documents\1.0.6 Variable Name Changes.txt @ebaydayz [CHANGED] Several weapon, item and tool classnames changed. Admins see SQL\1.0.6_Updates @ebaydayz diff --git a/SQF/dayz_code/actions/A_Plot_for_Life/plot_take_ownership.sqf b/SQF/dayz_code/actions/A_Plot_for_Life/plot_take_ownership.sqf index 318b02de8..f56a127f1 100644 --- a/SQF/dayz_code/actions/A_Plot_for_Life/plot_take_ownership.sqf +++ b/SQF/dayz_code/actions/A_Plot_for_Life/plot_take_ownership.sqf @@ -50,7 +50,8 @@ if ((_isowner select 0 )) then { }; _position = getPosATL _object; - _worldspace = [round(direction _object),_position,_playerUID]; + _vector = [(vectorDir _object),(vectorUp _object)]; + _worldspace = [round(direction _object),_position,_playerUID,_vector]; _invW = getWeaponCargo _object; { diff --git a/SQF/dayz_code/actions/modular_build.sqf b/SQF/dayz_code/actions/modular_build.sqf index 98684117b..21d1a79eb 100644 --- a/SQF/dayz_code/actions/modular_build.sqf +++ b/SQF/dayz_code/actions/modular_build.sqf @@ -29,6 +29,11 @@ DZE_F = false; DZE_cancelBuilding = false; +DZE_updateVec = false; +DZE_memDir = 0; +DZE_memForBack = 0; +DZE_memLeftRight = 0; + call gear_ui_init; closeDialog 1; @@ -126,6 +131,10 @@ if (_canBuild select 0) then { ["","","",["Init",_object,_classname,_objectHelper]] spawn snap_build; }; + if !(DZE_buildItem in DZE_noRotate) then{ + ["","","",["Init","Init",0]] spawn build_vectors; + }; + _objHDiff = 0; _cancel = false; _reason = ""; @@ -173,24 +182,39 @@ if (_canBuild select 0) then { if (DZE_4) then { _rotate = true; DZE_4 = false; - _dir = -45; + if(DZE_dirWithDegrees) then{ + DZE_memDir = DZE_memDir - DZE_curDegree; + }else{ + DZE_memDir = DZE_memDir - 45; + }; }; if (DZE_6) then { _rotate = true; DZE_6 = false; - _dir = 45; + if(DZE_dirWithDegrees) then{ + DZE_memDir = DZE_memDir + DZE_curDegree; + }else{ + DZE_memDir = DZE_memDir + 45; + }; }; - if (DZE_F and _canDo) then { - if (helperDetach) then { - _objectHelperDir = getDir _objectHelper; + if(DZE_updateVec) then{ + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; + DZE_updateVec = false; + }; + + if (DZE_F and _canDo) then { + if (helperDetach) then { _objectHelper attachTo [player]; - _objectHelper setDir _objectHelperDir-(getDir player); + DZE_memDir = DZE_memDir-(getDir player); helperDetach = false; - } else { - _objectHelperDir = getDir _objectHelper; - detach _objectHelper; - [_objectHelper] call FNC_GetSetPos; + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; + } else { + _objectHelperPos = getPosATL _objectHelper; + detach _objectHelper; + DZE_memDir = getDir _objectHelper; + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; + _objectHelper setPosATL _objectHelperPos; _objectHelper setVelocity [0,0,0]; //fix sliding glitch helperDetach = true; }; @@ -198,19 +222,7 @@ if (_canBuild select 0) then { }; if(_rotate) then { - if (helperDetach) then { - _objectHelperDir = getDir _objectHelper; - _objectHelper setDir _objectHelperDir+_dir; - [_objectHelper] call FNC_GetSetPos; - } else { - detach _objectHelper; - _objectHelperDir = getDir _objectHelper; - _objectHelper setDir _objectHelperDir+_dir; - [_objectHelper] call FNC_GetSetPos; - _objectHelperDir = getDir _objectHelper; - _objectHelper attachTo [player]; - _objectHelper setDir _objectHelperDir-(getDir player); - }; + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; }; if(_zheightchanged) then { @@ -260,8 +272,8 @@ if (_canBuild select 0) then { if (!helperDetach) then { _objectHelper attachTo [player]; - _objectHelper setDir _objectHelperDir-(getDir player); }; + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; }; uiSleep 0.5; @@ -274,6 +286,7 @@ if (_canBuild select 0) then { _position = [_object] call FNC_GetPos; detach _object; _dir = getDir _object; + _vector = [(vectorDir _object),(vectorUp _object)]; deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; @@ -351,6 +364,7 @@ if (_canBuild select 0) then { _tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; //create actual object that will be published to database _tmpbuilt setdir _dir; //set direction inherited from passed args from control + _tmpbuilt setVariable["memDir",_dir,true]; // Get position based on object _location = _position; @@ -358,7 +372,21 @@ if (_canBuild select 0) then { if((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then { //check Z axis if not allowed to build underground _location set [2,0]; //reset Z axis to zero (above terrain) }; - + + _tmpbuilt setVectorDirAndUp _vector; + + _buildOffset = [0,0,0]; + _vUp = _vector select 1; + switch (_classname) do { + case "MetalFloor_DZ": { _buildOffset = [(_vUp select 0) * .148, (_vUp select 1) * .148,0]; }; + }; + + _location = [ + (_location select 0) - (_buildOffset select 0), + (_location select 1) - (_buildOffset select 1), + (_location select 2) - (_buildOffset select 2) + ]; + if (surfaceIsWater _location) then { _tmpbuilt setPosASL _location; _location = ASLtoATL _location; //Database uses ATL @@ -494,7 +522,11 @@ if (_canBuild select 0) then { _tmpbuilt setVariable ["CharacterID",_combination,true]; //set combination as a character ID //call publish precompiled function with given args and send public variable to server to save item to database - PVDZ_obj_Publish = [_combination,_tmpbuilt,[_dir,_location],[]]; + PVDZ_obj_Publish = [_combination,_tmpbuilt,[_dir,_location, _vector],[]]; + if (DZE_plotforLife) then { + _tmpbuilt setVariable ["ownerPUID",_playerUID,true]; + PVDZ_obj_Publish = [_combination,_tmpbuilt,[_dir,_location,_playerUID, _vector],_classname]; + }; publicVariableServer "PVDZ_obj_Publish"; format[localize "str_epoch_player_140",_combinationDisplay,_text] call dayz_rollingMessages; //display new combination @@ -502,12 +534,18 @@ if (_canBuild select 0) then { } else { //if not lockable item _tmpbuilt setVariable ["CharacterID",dayz_characterID,true]; + if (DZE_plotforLife) then { + _tmpbuilt setVariable ["ownerPUID",_playerUID,true]; + }; // fire? if(_tmpbuilt isKindOf "Land_Fire_DZ") then { //if campfire, then spawn, but do not publish to database _tmpbuilt spawn player_fireMonitor; } else { - PVDZ_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location],[]]; + PVDZ_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location, _vector],[]]; + if (DZE_plotforLife) then { + PVDZ_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location,_playerUID, _vector],_classname]; + }; publicVariableServer "PVDZ_obj_Publish"; }; }; diff --git a/SQF/dayz_code/actions/player_buildingDowngrade.sqf b/SQF/dayz_code/actions/player_buildingDowngrade.sqf index 651558ca4..fdf332f31 100644 --- a/SQF/dayz_code/actions/player_buildingDowngrade.sqf +++ b/SQF/dayz_code/actions/player_buildingDowngrade.sqf @@ -113,6 +113,7 @@ if ((count _upgrade) > 0) then { // Get direction _dir = getDir _obj; + _vector = [(vectorDir _obj),(vectorUp _obj)]; // Reset the character ID on locked doors before they inherit the newclassname if (_classname in DZE_DoorsLocked) then { @@ -127,6 +128,10 @@ if ((count _upgrade) > 0) then { // Set direction _object setDir _dir; + _object setVariable["memDir",_dir,true]; + + // Set vector + _object setVectorDirAndUp _vector; // Set location _object setPosATL _location; @@ -134,9 +139,9 @@ if ((count _upgrade) > 0) then { format[localize "str_epoch_player_142",_text] call dayz_rollingMessages; - PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,player]; + PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location, _vector],_classname,_obj,player]; if (DZE_plotforLife) then { - PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location,_playerUID],_classname,_obj,player]; + PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location,_playerUID, _vector],_classname,_obj,player]; }; publicVariableServer "PVDZE_obj_Swap"; diff --git a/SQF/dayz_code/actions/player_upgrade.sqf b/SQF/dayz_code/actions/player_upgrade.sqf index 77fe15ef2..490522fa3 100644 --- a/SQF/dayz_code/actions/player_upgrade.sqf +++ b/SQF/dayz_code/actions/player_upgrade.sqf @@ -124,6 +124,8 @@ if ((count _upgrade) > 0) then { // Get direction _dir = getDir _obj; + // Get vector + _vector = [(vectorDir _obj),(vectorUp _obj)]; // Current charID _objectCharacterID = _obj getVariable ["CharacterID","0"]; @@ -135,6 +137,10 @@ if ((count _upgrade) > 0) then { // Set direction _object setDir _dir; + _object setVariable["memDir",_dir,true]; + + // Set vector + _object setVectorDirAndUp _vector; // Set location _object setPosATL _location; @@ -157,7 +163,7 @@ if ((count _upgrade) > 0) then { format[localize "str_epoch_player_159",_text] call dayz_rollingMessages; }; - PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,player]; + PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location, _vector],_classname,_obj,player]; publicVariableServer "PVDZE_obj_Swap"; player reveal _object; diff --git a/SQF/dayz_code/actions/snap_build.sqf b/SQF/dayz_code/actions/snap_build.sqf index be479cf6a..0a91f3796 100644 --- a/SQF/dayz_code/actions/snap_build.sqf +++ b/SQF/dayz_code/actions/snap_build.sqf @@ -31,15 +31,15 @@ fnc_snapActionCleanup = { player removeAction s_player_toggleSnapSelect; s_player_toggleSnapSelect = -1; if (count s_player_toggleSnapSelectPoint != 0) then {{player removeAction _x;} count s_player_toggleSnapSelectPoint; s_player_toggleSnapSelectPoint=[]; snapActions = -1;}; if (_s1 > 0) then { - s_player_toggleSnap = player addaction [format[("" + ("Snap: %1") +""),snapActionState],"\z\addons\dayz_code\actions\snap_build.sqf",[snapActionState,_object,_classname,_objectHelper],6,false,true]; + s_player_toggleSnap = player addaction [format[("" + ("Snap: %1") +""),snapActionState],"\z\addons\dayz_code\actions\snap_build.sqf",[snapActionState,_object,_classname,_objectHelper],10,false,true]; }; if (_s2 > 0) then { - s_player_toggleSnapSelect = player addaction [format[("" + ("Snap Point: %1") +""),snapActionStateSelect],"\z\addons\dayz_code\actions\snap_build.sqf",[snapActionStateSelect,_object,_classname,_objectHelper],5,false,true]; + s_player_toggleSnapSelect = player addaction [format[("" + ("Snap Point: %1") +""),snapActionStateSelect],"\z\addons\dayz_code\actions\snap_build.sqf",[snapActionStateSelect,_object,_classname,_objectHelper],9,false,true]; }; if (_s3 > 0) then { s_player_toggleSnapSelectPoint=[]; _cnt = 0; - {snapActions = player addaction [format[("" + ("%1)Select: %2") +""),_cnt,_x select 3],"\z\addons\dayz_code\actions\snap_build.sqf",["Selected",_object,_classname,_objectHelper,_cnt],4,false,false]; + {snapActions = player addaction [format[("" + ("%1)Select: %2") +""),_cnt,_x select 3],"\z\addons\dayz_code\actions\snap_build.sqf",["Selected",_object,_classname,_objectHelper,_cnt],8,false,false]; s_player_toggleSnapSelectPoint set [count s_player_toggleSnapSelectPoint,snapActions]; _cnt = _cnt+1; }count _points; @@ -67,7 +67,8 @@ fnc_initSnapPointsNearby = { { _objectSnapGizmo = "Sign_sphere10cm_EP1" createVehicleLocal [0,0,0]; _objectSnapGizmo setobjecttexture [0,_objColorInactive]; - _objectSnapGizmo setDir (getDir _nearbyObject); + //_objectSnapGizmo setDir (getDir _nearbyObject); + _objectSnapGizmo setDir (_nearbyObject getVariable["memDir",0]); _posNearby = _nearbyObject modelToWorld [_x select 0,_x select 1,_x select 2]; if (surfaceIsWater _posNearby) then { _objectSnapGizmo setPosASL [(_posNearby) select 0,(_posNearby) select 1,(getPosASL _nearbyObject select 2) + (_x select 2)]; @@ -114,7 +115,9 @@ fnc_snapDistanceCheck = { _distClosestPointFoundPos = getPosATL _distClosestPointFound; _objectHelper setPosATL _distClosestPointFoundPos; }; - _objectHelper setDir _distClosestPointFoundDir; + //_objectHelper setDir _distClosestPointFoundDir; + DZE_memDir = _distClosestPointFoundDir; + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; waitUntil {uiSleep 0.1; !helperDetach}; }; } else { @@ -150,7 +153,9 @@ fnc_snapDistanceCheck = { _object attachTo [_objectHelper]; _objectHelper setPosATL _distClosestPointFoundPos; }; - _objectHelper setDir _distClosestPointFoundDir; + //_objectHelper setDir _distClosestPointFoundDir; + DZE_memDir = _distClosestPointFoundDir; + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; waitUntil {uiSleep 0.1; !helperDetach}; }; }; @@ -277,6 +282,7 @@ switch (snapActionState) do { _object attachTo [_objectHelper]; _x setobjecttexture [0,_objColorActive]; if (!helperDetach) then {_objectHelper attachTo [player]; _objectHelper setDir ((getDir _objectHelper)-(getDir player));}; + [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw; }; _cnt = _cnt+1; }count snapGizmos; diff --git a/SQF/dayz_code/compile/BuildVectors/build_vectors.sqf b/SQF/dayz_code/compile/BuildVectors/build_vectors.sqf new file mode 100644 index 000000000..3ac437072 --- /dev/null +++ b/SQF/dayz_code/compile/BuildVectors/build_vectors.sqf @@ -0,0 +1,145 @@ +/*-----------------------------------*/ +// by Raymix // +// July 10 2014 // +/*--------------------------------*/ + +private ["_object","_objectSnapGizmo","_objColorActive","_objColorInactive","_classname","_whitelist","_radius","_cfg","_cnt","_pos","_findWhitelisted","_nearbyObject","_posNearby","_selectedAction","_newPos","_pointsNearby","_onWater","_waterBase"]; +//Args +_todo = _this select 3 select 2; +if(_todo == 0) then{ + vectorActionState = _this select 3 select 0; + degreeActionState = _this select 3 select 1; +}else{ + if(_todo == 1) then{ + vectorActionState = _this select 3 select 0; + }else{ + degreeActionState = _this select 3 select 1; + }; +}; +_selected = _this select 3 select 3; +_staticRotate = ["Pitch Forward","Pitch Back","Bank Left","Bank Right","Reset"]; +fnc_vectorActionCleanup = { + private ["_s1","_s2"]; + _s1 = _this select 0; + _s2 = _this select 1; + player removeAction s_player_toggleVector; s_player_toggleVector = -1; + if (count s_player_toggleVectors != 0) then {{player removeAction _x;} count s_player_toggleVectors; s_player_toggleVectors=[]; vectorActions = -1;}; + if (_s1 > 0) then { + s_player_toggleVector = player addaction [format[("" + ("Vectors: %1") +""),vectorActionState],DZE_build_vector_file,[vectorActionState,degreeActionState,1],7,false,false]; + }; + if (_s2 > 0) then { + s_player_toggleVectors=[]; + { + vectorActions = player addaction [format[("" + (" %1") +""),_x],DZE_build_vector_file,[_x,degreeActionState,1],6,false,false]; + s_player_toggleVectors set [count s_player_toggleVectors,vectorActions]; + }count _staticRotate; + }; +}; + +fnc_degreeActionCleanup = { + private ["_s1","_s2"]; + _s1 = _this select 0; + _s2 = _this select 1; + player removeAction s_player_toggleDegree; s_player_toggleDegree = -1; + if (count s_player_toggleDegrees != 0) then {{player removeAction _x;} count s_player_toggleDegrees; s_player_toggleDegrees=[]; degreeActions = -1;}; + if (_s1 > 0) then { + s_player_toggleDegree = player addaction [format[("" + ("Degrees: %1") +""),degreeActionState],DZE_build_vector_file,[vectorActionState,degreeActionState,2],5,false,false]; + }; + if (_s2 > 0) then { + s_player_toggleDegrees=[]; + { + if(DZE_curDegree == _x) then{ + degreeActions = player addaction [format[("" + (" Select: %1") +""),_x],DZE_build_vector_file,[vectorActionState,"SELECT",2,_x],4,false,false]; + }else{ + degreeActions = player addaction [format[("" + (" Select: %1") +""),_x],DZE_build_vector_file,[vectorActionState,"SELECT",2,_x],4,false,false]; + }; + + s_player_toggleDegrees set [count s_player_toggleDegrees,degreeActions]; + }count DZE_vectorDegrees; + }; +}; + +if(_todo == 1 || _todo == 0) then{ + switch (vectorActionState) do { + case "Init": { + vectorActionState = "OPEN"; + [1,0] call fnc_vectorActionCleanup; + [] spawn { + while {true} do { + if(!DZE_ActionInProgress || DZE_cancelBuilding) exitWith {[0,0] call fnc_vectorActionCleanup; vectorActionState = "CLOSE";}; + sleep 2; + }; + }; + }; + case "OPEN": { + vectorActionState = "CLOSE"; + [1,1] call fnc_vectorActionCleanup; + }; + + case "CLOSE":{ + vectorActionState = "OPEN"; + [1,0] call fnc_vectorActionCleanup; + }; + case "Pitch Forward":{ + vectorActionState = "CLOSE"; + [1,1] call fnc_vectorActionCleanup; + DZE_updateVec = true; + DZE_memForBack = DZE_memForBack + (DZE_curDegree * -1); + }; + case "Pitch Back":{ + vectorActionState = "CLOSE"; + [1,1] call fnc_vectorActionCleanup; + DZE_updateVec = true; + DZE_memForBack = DZE_memForBack + DZE_curDegree; + }; + case "Bank Left":{ + vectorActionState = "CLOSE"; + [1,1] call fnc_vectorActionCleanup; + DZE_updateVec = true; + DZE_memLeftRight = DZE_memLeftRight + (DZE_curDegree * -1); + }; + case "Bank Right":{ + vectorActionState = "CLOSE"; + [1,1] call fnc_vectorActionCleanup; + DZE_updateVec = true; + DZE_memLeftRight = DZE_memLeftRight + DZE_curDegree; + }; + case "Reset":{ + vectorActionState = "CLOSE"; + [1,1] call fnc_vectorActionCleanup; + DZE_memForBack = 0; + DZE_memLeftRight = 0; + DZE_memDir = 0; + DZE_updateVec = true; + }; + }; +}; + +if(_todo == 2 || _todo == 0) then{ + switch (degreeActionState) do { + case "Init": { + degreeActionState = "OPEN"; + [1,0] call fnc_degreeActionCleanup; + [] spawn { + while {true} do { + if(!DZE_ActionInProgress || DZE_cancelBuilding) exitWith {[0,0] call fnc_degreeActionCleanup; degreeActionState = "CLOSE";}; + sleep 2; + }; + }; + }; + case "OPEN": { + degreeActionState = "CLOSE"; + [1,1] call fnc_degreeActionCleanup; + }; + + case "CLOSE":{ + degreeActionState = "OPEN"; + [1,0] call fnc_degreeActionCleanup; + }; + case "SELECT":{ + degreeActionState = "CLOSE"; + DZE_curDegree = _selected; + [1,1] call fnc_degreeActionCleanup; + }; + }; +}; diff --git a/SQF/dayz_code/compile/BuildVectors/fnc_SetPitchBankYaw.sqf b/SQF/dayz_code/compile/BuildVectors/fnc_SetPitchBankYaw.sqf new file mode 100644 index 000000000..7abbf0ca9 --- /dev/null +++ b/SQF/dayz_code/compile/BuildVectors/fnc_SetPitchBankYaw.sqf @@ -0,0 +1,46 @@ +private ["_sinaroundX","_cosaroundX","_dirY","_dirZ","_upY","_upZ","_sinaroundY","_cosaroundY","_dirX","_upX","_sinaroundZ","_cosaroundZ","_dirXTemp","_upXTemp","_object","_rotations","_aroundX","_aroundY","_aroundZ","_dir","_up"]; +_object = _this select 0; +_rotations = _this select 1; +_aroundX = _rotations select 0; +_aroundY = _rotations select 1; +_aroundZ = (360 - (_rotations select 2)) - 360; + +_dirX = 0; +_dirY = 1; +_dirZ = 0; +_upX = 0; +_upY = 0; +_upZ = 1; + +if (_aroundX != 0) then { + _sinaroundX = sin _aroundX; + _cosaroundX = cos _aroundX; + _dirY = _cosaroundX; + _dirZ = _sinaroundX; + _upY = -(_sinaroundX); + _upZ = _cosaroundX; +}; + +if (_aroundY != 0) then { + _sinaroundY = sin _aroundY; + _cosaroundY = cos _aroundY; + _dirX = _dirZ * _sinaroundY; + _dirZ = _dirZ * _cosaroundY; + _upX = _upZ * _sinaroundY; + _upZ = _upZ * _cosaroundY; +}; + +if (_aroundZ != 0) then { + _sinaroundZ = sin _aroundZ; + _cosaroundZ = cos _aroundZ; + _dirXTemp = _dirX; + _dirX = (_dirXTemp * _cosaroundZ) - (_dirY * _sinaroundZ); + _dirY = (_dirY * _cosaroundZ) + (_dirXTemp * _sinaroundZ); + _upXTemp = _upX; + _upX = (_upXTemp * _cosaroundZ) - (_upY * _sinaroundZ); + _upY = (_upY * _cosaroundZ) + (_upXTemp * _sinaroundZ); +}; + +_dir = [_dirX, _dirY, _dirZ]; +_up = [_upX, _upY, _upZ]; +_object setVectorDirAndUp [_dir, _up]; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_lockVault.sqf b/SQF/dayz_code/compile/player_lockVault.sqf index 442bf7cc4..f1bfba18f 100644 --- a/SQF/dayz_code/compile/player_lockVault.sqf +++ b/SQF/dayz_code/compile/player_lockVault.sqf @@ -3,8 +3,7 @@ Usage: [_obj] spawn player_unlockVault; Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com. */ -private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_weapons","_magazines","_backpacks","_alreadyPacking","_lockedClass","_text","_playerNear"]; - +private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_weapons","_magazines","_backpacks","_alreadyPacking","_lockedClass","_text","_playerNear","_combination","_ComboMatch","_objType","_charID","_vector"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_10" call dayz_rollingMessages;}; DZE_ActionInProgress = true; @@ -45,6 +44,7 @@ if (_alreadyPacking == 1) exitWith {DZE_ActionInProgress = false; s_player_lockv _obj setVariable["packing",1]; _dir = direction _obj; +_vector = [(vectorDir _obj),(vectorUp _obj)]; _pos = _obj getVariable["OEMPos",(getposATL _obj)]; if (!isNull _obj) then { @@ -57,6 +57,8 @@ if (!isNull _obj) then { //place vault _holder = createVehicle [_lockedClass,_pos,[], 0, "CAN_COLLIDE"]; _holder setdir _dir; + _holder setVariable["memDir",_dir,true]; + _holder setVectorDirAndUp _vector; _holder setPosATL _pos; player reveal _holder; diff --git a/SQF/dayz_code/compile/player_unlockVault.sqf b/SQF/dayz_code/compile/player_unlockVault.sqf index b4c0bfc4c..2f48c5e23 100644 --- a/SQF/dayz_code/compile/player_unlockVault.sqf +++ b/SQF/dayz_code/compile/player_unlockVault.sqf @@ -3,7 +3,7 @@ Usage: [_obj] spawn player_unlockVault; Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com. */ -private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr","_alreadyPacking","_playerNear","_playerID","_claimedBy","_unlockedClass","_text","_nul","_objType"]; +private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr","_alreadyPacking","_playerNear","_playerID","_claimedBy","_unlockedClass","_text","_objType","_combination","_ComboMatch","_vector","_characterID"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_21" call dayz_rollingMessages;}; DZE_ActionInProgress = true; @@ -56,6 +56,7 @@ if (_ComboMatch || (_ownerID == dayz_playerUID)) then { }; _dir = direction _obj; + _vector = [(vectorDir _obj),(vectorUp _obj)]; _pos = _obj getVariable["OEMPos",getPosATL _obj]; _objectID = _obj getVariable["ObjectID","0"]; _objectUID = _obj getVariable["ObjectUID","0"]; @@ -86,6 +87,8 @@ if (_ComboMatch || (_ownerID == dayz_playerUID)) then { // Remove locked vault deleteVehicle _obj; _holder setdir _dir; + _holder setVariable["memDir",_dir,true]; + _holder setVectorDirAndUp _vector; _holder setPosATL _pos; player reveal _holder; diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index d2d1aca55..89cb1612b 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -68,6 +68,13 @@ DZE_MaxPlotFriends = 6; //Maximum number of friends allowed on a plot pole. (def DZE_plotforLife = true; //Enable or disable a plot for life mod DZE_PlotOwnership = true; //allows plot owner to take ownership of buildables (excluding lockable items) near a plot pole. Useful for servers that allow base capturing so the new owner can modify/delete/upgrade existing structures +/////////// Vector Building Variables /////////// +// ENABLED ONLY WITH SNAP BUILDING ENABLED - DZE_modularBuild = true; +// Currently no switch to enable or disable due to continginces that may arise from various aspects of gameplay while switching between off/on +DZE_noRotate = []; //Objects that cannot be rotated. Ex: DZE_noRotate = ["ItemVault"] (NOTE: The objects magazine classname) +DZE_vectorDegrees = [0.01, 0.1, 1, 5, 15, 45, 90]; +DZE_curDegree = 45; //Starting rotation angle. //Prefered any value in array above +DZE_dirWithDegrees = true; //When rotating objects with Q&E, use the custom degrees //////////////////////////////////////////////// /* diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 8c6eb48b1..e4668b943 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -92,6 +92,9 @@ if (!isDedicated) then { } else { player_build = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_build.sqf"; }; + fnc_SetPitchBankYaw = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\BuildVectors\fnc_SetPitchBankYaw.sqf"; //Vector building + DZE_build_vector_file = "\z\addons\dayz_code\compile\BuildVectors\build_vectors.sqf"; //Vector building + build_vectors = compile preprocessFileLineNumbers DZE_build_vector_file; //Vector building FNC_check_owner = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\A_Plot_for_Life\fn_check_owner.sqf"; FNC_find_plots = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\A_Plot_for_Life\fn_find_plots.sqf"; diff --git a/SQF/dayz_server/init/server_functions.sqf b/SQF/dayz_server/init/server_functions.sqf index c1a2b9d89..bf2100558 100644 --- a/SQF/dayz_server/init/server_functions.sqf +++ b/SQF/dayz_server/init/server_functions.sqf @@ -170,16 +170,60 @@ server_getDiff2 = { // 1.8.7 dayz_objectUID2 seems to generate keys that are too long for Epoch hive. Keep old method for now. dayz_objectUID2 = { - private["_position","_dir","_key"]; + private["_position","_dir","_key","_element","_vector","_set","_vecCnt","_usedVec"]; _dir = _this select 0; _key = ""; _position = _this select 1; - { - _x = _x * 10; - if (_x < 0) then { _x = _x * -10 }; - _key = _key + str(round(_x)); - } count _position; - _key = _key + str(round(_dir)); + if((count _this) == 2) then{ + { + _x = _x * 10; + if (_x < 0) then { _x = _x * -10 }; + _key = _key + str(round(_x)); + } count _position; + _key = _key + str(round(_dir)); + } else { + _vector = []; + _usedVec = false; + { + _element = _x; + if(typeName _element == "ARRAY") then{ + _vector = _element; + if((count _vector) == 2)then{ + if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{ + { + _x = _x * 10; + if ( _x < 0 ) then { _x = _x * -10 }; + _key = _key + str(round(_x)); + } count _position; + + _vecCnt = 0; + { + _set = _x; + { + _vecCnt = _vecCnt + (round (_x * 100)); + + } foreach _set; + + } foreach _vector; + if(_vecCnt < 0)then{ + _vecCnt = ((_vecCnt * -1) * 3); + }; + _key = _key + str(_vecCnt); + _usedVec = true; + }; + }; + }; + } count _this; + + if!(_usedVec) then{ + { + _x = _x * 10; + if ( _x < 0 ) then { _x = _x * -10 }; + _key = _key + str(round(_x)); + } count _position; + _key = _key + str(round(_dir)); + }; + }; // Make sure the generated key is not a duplicate while {true} do { if !(_key in currentObjectUIDs) exitWith {currentObjectUIDs set [count currentObjectUIDs,_key];}; diff --git a/SQF/dayz_server/system/server_monitor.sqf b/SQF/dayz_server/system/server_monitor.sqf index 01290a946..1cea649c9 100644 --- a/SQF/dayz_server/system/server_monitor.sqf +++ b/SQF/dayz_server/system/server_monitor.sqf @@ -96,7 +96,54 @@ if (_status == "ObjectStreamStart") then { diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos)); }; - + //Vector building + _vector = [[0,0,0],[0,0,0]]; + _vecExists = false; + _ownerPUID = "0"; + if (count _worldspace >= 3) then{ + if(count _worldspace == 3) then{ + if(typename (_worldspace select 2) == "STRING")then{ + _ownerPUID = _worldspace select 2; + }else{ + if(typename (_worldspace select 2) == "ARRAY")then{ + _vector = _worldspace select 2; + if(count _vector == 2)then{ + if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{ + _vecExists = true; + }; + }; + }; + }; + }else{ + //Was not 3 elements, so check if 4 or more + if(count _worldspace == 4) then{ + if(typename (_worldspace select 3) == "STRING")then{ + _ownerPUID = _worldspace select 3; + }else{ + if(typename (_worldspace select 2) == "STRING")then{ + _ownerPUID = _worldspace select 2; + }; + }; + if(typename (_worldspace select 2) == "ARRAY")then{ + _vector = _worldspace select 2; + if(count _vector == 2)then{ + if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{ + _vecExists = true; + }; + }; + }else{ + if(typename (_worldspace select 3) == "ARRAY")then{ + _vector = _worldspace select 3; + if(count _vector == 2)then{ + if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{ + _vecExists = true; + }; + }; + }; + }; + }; + }; + }; /* Plot For Life 2.5 */ // Realign characterID to OwnerPUID - need to force save though. if (count _worldspace < 3) then { @@ -153,6 +200,9 @@ if (_status == "ObjectStreamStart") then { }; _object setVariable ["CharacterID", _ownerID, true]; _object setDir _dir; + if(_vecExists)then{ + _object setVectorDirAndUp _vector; + }; _object setDamage _damage; if (!_wsDone) then {[_object,"position",true] call server_updateObject;}; @@ -220,6 +270,7 @@ if (_status == "ObjectStreamStart") then { }; _object setPosATL _pos; if ((_object isKindOf "DZ_buildables") or ((_type in DayZ_SafeObjects) && !(_object isKindOf "TrapItems"))) then { + _object setVariable["memDir",_dir,true]; if (DZE_GodModeBase) then {_object addEventHandler ["HandleDamage",{false}];} else {_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];}; _object enableSimulation false; // Test disabling simulation server side on buildables only. _object setVariable ["OEMPos",_pos,true]; // used for inplace upgrades and lock/unlock of safe