From c7e58da56d6e8cb0b36bcd29ef0c686094d56425 Mon Sep 17 00:00:00 2001 From: He-Man Date: Sun, 28 May 2017 00:25:42 +0200 Subject: [PATCH] Reworked Building Script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added Vecorbuilding - Added: Building element can be detached to walk around the Element before saving - Added: Help-Arrow to indicate door-opening direction - Added: Max building height now will be checked direcly by building element placement - Changed: Replaced 0/90/180/270° direction build mode with "Rotate 90°" - Fixed: 90° and 270° Snap was broken - Fixed: Sometimes rotated elements rotate back on save Credits: The Base Vector Building Scripts comes from DirtySanches from "DonkeyPunch Community Gaming Development Team". Based on his Script, we reworked and fixed some more stuff in the building script together. --- Changelogs/0.6.0.0.txt | 9 + Server_Install_Pack/sc/battleye/scripts.txt | 2 +- .../compile/building/EPOCH_staticMove.sqf | 438 +++++++++--------- .../EPOCH_KeyDown.sqf | 34 +- .../compile/setup/EPOCH_clientInit.sqf | 3 + .../compile/setup/EPOCH_clientKeyMap.sqf | 7 +- .../CfgActionMenu/CfgActionMenu_self.hpp | 33 +- 7 files changed, 277 insertions(+), 249 deletions(-) diff --git a/Changelogs/0.6.0.0.txt b/Changelogs/0.6.0.0.txt index cc7ea180..2dbb67a9 100644 --- a/Changelogs/0.6.0.0.txt +++ b/Changelogs/0.6.0.0.txt @@ -14,3 +14,12 @@ Debris is spawned using createSimpleObject and is made to conform with the upper [Added] Epoch Dev Libs by @raymix [Fixed] BE kick since 1.70. + +[Changed] Reworked Basebuilding Script. @DirtySanches & @Ignatz-Heman + - Added Vecorbuilding + - Added: Building element can be detached to walk around the Element before saving + - Added: Help-Arrow to indicate door-opening direction + - Added: Max building height now will be checked direcly by building element placement + - Changed: Replaced 0/90/180/270° direction build mode with "Rotate 90°" + - Fixed: 90° and 270° Snap was broken + - Fixed: Sometimes rotated elements rotate back on save diff --git a/Server_Install_Pack/sc/battleye/scripts.txt b/Server_Install_Pack/sc/battleye/scripts.txt index 7c536064..51922f4a 100644 --- a/Server_Install_Pack/sc/battleye/scripts.txt +++ b/Server_Install_Pack/sc/battleye/scripts.txt @@ -30,7 +30,7 @@ 7 setViewDistance !="setViewDistance 1600" 7 createGroup !="EPOCH_server_createGroup" !="_grp = createGroup [RESISTANCE, true];" !="if (isserver) then {\n_group = creategroup sidelogic;" !="grpVIPGeneral = createGroup [RESISTANCE, true];" !="_grp = createGroup side _plyr;" !="_grp = createGroup [_side, true];" !="_grp = createGroup [(side _plyr), true];" !="createcenter sidelogic;\n_grpLogic = creategroup sidelogic;\nbis_functions_mainscope" !="_group = createGroup [west, true];" 7 createVehicleCrew !="createvehiclecrew _x;" -7 createVehicleLocal !="\"#particlesource\" createVehicleLocal" !="\"#lightpoint\" createVehicleLocal" !="\"BloodSplat\" createVehicleLocal" !="[\"lightning1_F\", \"lightning2_F\"] call BIS_fnc_selectRandom;\n_lighting = _class createVehicleLocal" !="SLX_XEH_DUMMY createVehicleLocal [0, 0, 0];" !="CBA_eventHandlers = \"Logic\" createVehicleLocal [0, 0];" +7 createVehicleLocal !="\"Sign_Arrow_Direction_Yellow_F\" createVehicleLocal" !="\"#particlesource\" createVehicleLocal" !="\"#lightpoint\" createVehicleLocal" !="\"BloodSplat\" createVehicleLocal" !="[\"lightning1_F\", \"lightning2_F\"] call BIS_fnc_selectRandom;\n_lighting = _class createVehicleLocal" !="SLX_XEH_DUMMY createVehicleLocal [0, 0, 0];" !="CBA_eventHandlers = \"Logic\" createVehicleLocal [0, 0];" 7 createUnit !="_driver = _grp createUnit[\"I_UAV_AI\", position _unit, [], 0, \"CAN_COLLIDE\"];" !="axeGeneral = grpVIPGeneral createUnit [\"I_officer_F\", axeGeneralPos, [], 1, \"CAN_COLLIDE\"];" !="bis_functions_mainscope = _grpLogic createunit [\"Logic\",[9,9,9],[],0,\"none\"];" !="_unit = _grp createUnit[selectRandom _arrUnits, _pos, [], 0, \"FORM\"];" !="_driver = (group player) createUnit[\"I_UAV_AI\", position axeUAV, [], 0, \"CAN_COLLIDE\"];" 7 createAgent !="bis_revive_ratioLethal = createAgent [\"Logic\", [10,10,0], [], 0, \"CAN_COLLIDE\"];" !="_unit = createAgent[_unitClass, _targetPos, [], 256, \"FORM\"];" !="_unit = createAgent [_unitClass, _targetPos, [], 120, \"FORM\"];" !="_animal = createAgent[_randomAIClass, _animalPos, [], 5, \"NONE\"];" !="_unit = createAgent [\"Epoch_Cloak_F\", _pos, [], 0, \"CAN_COLLIDE\"];" !="_unit = createAgent [\"Epoch_Sapper_F\", _targetPos, [], 180, \"FORM\"];" !="_sapper = createAgent [\"Epoch_Sapper_F\", getPos _cage2, [], 0, \"FORM\"];" !="_unit = createAgent[_unitClass, position player, [], _zRange, \"FORM\"];" !="_animal = createAgent[_randomAIClass, _animalPos, [], 0, \"CAN_COLLIDE\"];" !="_axeSapper = createAgent [\"Epoch_Sapper_F\", _pos, [], 12, \"FORM\"];" !="_nestMate = createAgent [\"Epoch_Sapper_F\", _garrPos, [], 0, \"FORM\"];" 7 createTeam diff --git a/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf b/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf index df40071e..d11088e0 100644 --- a/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf +++ b/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf @@ -23,7 +23,7 @@ NOTHING */ //[[[cog import generate_private_arrays ]]] -private ["_EPOCH_1","_EPOCH_2","_allowedSnapObjects","_allowedSnapPoints","_arr_snapPoints","_baselineSnapPos","_cfgBaseBuilding","_class","_currentOffSet","_currentPos","_currentTarget","_dir2","_direction","_distance","_energyCost","_ins","_isSnap","_lastCheckTime","_maxHeight","_maxSnapDistance","_nearestObject","_nearestObjects","_numberOfContacts","_objSlot","_objType","_offSet","_offsetZPos","_pOffset","_pos1","_pos1_snap","_pos2","_pos2ATL","_pos2_snap","_pos_snapObj","_rejectMove","_simulClass","_snapChecks","_snapConfig","_snapDistance","_snapPointsPara","_snapPointsPerp","_snapPos","_snapPos1","_snapPosition","_snapType","_stabilityCheck","_up2","_worldspace"]; +private ["_snapped","_EPOCH_1","_EPOCH_2","_allowedSnapObjects","_allowedSnapPoints","_arr_snapPoints","_baselineSnapPos","_cfgBaseBuilding","_class","_currentOffSet","_currentPos","_currentTarget","_dir2","_direction","_distance","_energyCost","_ins","_isSnap","_lastCheckTime","_maxHeight","_maxSnapDistance","_nearestObject","_nearestObjects","_numberOfContacts","_objSlot","_objType","_offSet","_offsetZPos","_pOffset","_pos1","_pos1_snap","_pos2","_pos2ATL","_pos2_snap","_pos_snapObj","_rejectMove","_simulClass","_snapChecks","_snapConfig","_snapDistance","_snapPointsPara","_snapPointsPerp","_snapPos","_snapPos1","_snapPosition","_snapType","_stabilityCheck","_up2","_worldspace"]; //[[[end]]] if !(isNil "EPOCH_simulSwap_Lock") exitWith{}; @@ -43,35 +43,39 @@ if (EPOCH_playerEnergy <= 0) exitWith{ // Remove object if not allowed if !(_object call EPOCH_isBuildAllowed) exitWith{ deleteVehicle _object }; + EPOCH_simulSwap_Lock = true; - _objType = typeOf _object; - _cfgBaseBuilding = 'CfgBaseBuilding' call EPOCH_returnConfig; - -_energyCost = getNumber(_cfgBaseBuilding >> _objType >> "energyCost"); -if (_energyCost == 0) then { - _energyCost = 0.1; -}; - _class = getText(_cfgBaseBuilding >> _objType >> "GhostPreview"); -_maxHeight = getNumber(_cfgBaseBuilding >> _objType >> "maxHeight"); -_simulClass = getText(_cfgBaseBuilding >> _objType >> "simulClass"); -_snapChecks = getArray(("CfgSnapChecks" call EPOCH_returnConfig) >> _objType >> "nails"); - -_maxSnapDistance = 1; -_lastCheckTime = diag_tickTime; -_stabilityCheck = false; - -// force sim check if object has sim class and default max height to 9m if not already specified -if (_simulClass != "") then { - _stabilityCheck = true; - if (_maxHeight == 0) then { - _maxHeight = 500; - }; -}; if (_class != "") then { + _energyCost = getNumber(_cfgBaseBuilding >> _objType >> "energyCost"); + _maxHeight = getNumber(_cfgBaseBuilding >> _objType >> "maxHeight"); + _simulClass = getText(_cfgBaseBuilding >> _objType >> "simulClass"); + _snapChecks = getArray(("CfgSnapChecks" call EPOCH_returnConfig) >> _objType >> "nails"); + _allowedSnapPoints = getArray(_cfgBaseBuilding >> _class >> "allowedSnapPoints"); + _allowedSnapObjects = getArray(_cfgBaseBuilding >> _class >> "allowedSnapObjects"); + + if (_energyCost == 0) then {_energyCost = 0.1;}; + + _maxSnapDistance = 1; + _lastCheckTime = diag_tickTime; + _stabilityCheck = false; + + // force sim check if object has sim class and default max height to 9m if not already specified + if (_simulClass != "") then { + _stabilityCheck = true; + if (_maxHeight == 0) then { + _maxHeight = 500; + }; + }; + + _CfgEpochClient = 'CfgEpochClient' call EPOCH_returnConfig; + _maxBuildingHeight = getNumber(_CfgEpochClient >> "maxBuildingHeight"); + if !(_maxBuildingHeight == 0) then { + _maxHeight = _maxHeight min _maxBuildingHeight; + }; _objSlot = _object getVariable["BUILD_SLOT", -1]; @@ -100,209 +104,71 @@ if (_class != "") then { _currentTarget setVariable["BUILD_SLOT", _objSlot, true]; }; - _allowedSnapPoints = getArray(_cfgBaseBuilding >> _class >> "allowedSnapPoints"); - _allowedSnapObjects = getArray(_cfgBaseBuilding >> _class >> "allowedSnapObjects"); - - _currentOffSet = []; + EPOCH_X_OFFSET = 0; + EPOCH_Y_OFFSET = 5; + EPOCH_Z_OFFSET = 0; + EPOCH_buildDirection = 0; + EPOCH_buildDirectionPitch = 0; + EPOCH_buildDirectionRoll = 0; + EPOCH_target_attachedTo = player; EP_snap = objNull; EP_snapPos = [0, 0, 0]; _isSnap = false; - + _currentOffSet = []; _EPOCH_1 = diag_tickTime; _EPOCH_2 = diag_tickTime; _nearestObjects = []; + _Snapdirection = EPOCH_snapDirection; + _snapped = false; + _currentTargetAttachedTo = player; + _AnchorPos = []; + _helper = objnull; + + if (typeof EPOCH_target in ["CinderWallHalf_Ghost_EPOCH","WoodLargeWall_Ghost_EPOCH"]) then { + _helper = "Sign_Arrow_Direction_Yellow_F" createVehicleLocal (getpos EPOCH_target); + _helper attachto [EPOCH_target, [0, -0.5, 1]]; + _helper setdir 180; + }; - while {EPOCH_target == _currentTarget} do { - - _rejectMove = false; - if ((diag_tickTime - _lastCheckTime) > 10) then { - _lastCheckTime = diag_tickTime; - _rejectMove = !(_object call EPOCH_isBuildAllowed); - }; - if (_rejectMove) exitWith{ - deleteVehicle EPOCH_target; - }; - - _offSet = [EPOCH_X_OFFSET, EPOCH_Y_OFFSET, EPOCH_Z_OFFSET]; - _pos2 = player modelToWorldVisual _offSet; - - if (surfaceIsWater _pos2) then { - _pos2 set[2, ((getPosASL player) select 2) + EPOCH_Z_OFFSET]; - }; - - if !(_currentOffSet isEqualTo _offSet) then { + _MoveObject = { + if (!(_currentOffSet isEqualTo _offSet) || EPOCH_doRotate || !isnull EP_snap && _currentTargetAttachedTo isequalto EPOCH_target_attachedTo) then { _currentOffSet = _offSet; - { - detach _x; - } forEach attachedObjects player; - - if (_pos2 select 2 > _maxHeight) then { - _pos2 set[2, _maxHeight]; - }; + EPOCH_doRotate = false; + EPOCH_arr_snapPoints = []; + EP_snap = objnull; _pos2ATL = _pos2; if (surfaceIsWater _pos2ATL) then { _pos2ATL = ASLtoATL _pos2ATL; }; - EPOCH_target setposATL _pos2ATL; - EPOCH_target attachTo[player]; - }; - - if (EPOCH_doRotate) then { - _dir2 = [vectorDir player, EPOCH_buildDirection] call BIS_fnc_returnVector; - _up2 = (vectorUp player); - EPOCH_doRotate = false; - EPOCH_target setVectorDirAndUp [_dir2,_up2]; - }; - - { - _nearestObject = _x; - if !(isNull EP_snap) then { - if ((_pos2 distance EP_snapPos) < _maxSnapDistance) then { - _nearestObject = EP_snap; - }; + if (_currentTargetAttachedTo isequalto player) then { + EPOCH_target attachTo [player]; + } + else { + { + detach _x; + } forEach attachedObjects player; }; + _newDirAndUp = [[sin EPOCH_buildDirection * cos EPOCH_buildDirectionPitch, cos EPOCH_buildDirection * cos EPOCH_buildDirectionPitch, sin EPOCH_buildDirectionPitch],[[ sin EPOCH_buildDirectionRoll,-sin EPOCH_buildDirectionPitch,cos EPOCH_buildDirectionRoll * cos EPOCH_buildDirectionPitch],-EPOCH_buildDirection] call BIS_fnc_rotateVector2D]; + EPOCH_target setVectorDirAndUp _newDirAndUp; + }; + }; - if (!isNull _nearestObject && _nearestObject isEqualTo _x) then { - - _isSnap = false; - _snapPosition = [0, 0, 0]; - _snapConfig = _cfgBaseBuilding >> (typeOf _nearestObject); - _snapPointsPara = getArray(_snapConfig >> "snapPointsPara"); - _snapPointsPerp = getArray(_snapConfig >> "snapPointsPerp"); - - // base line for z height offset - _baselineSnapPos = _nearestObject modelToWorldVisual [0,0,0]; - - if (EPOCH_buildMode == 1) then { - { - _x params ["_snapPoints","_type"]; - { - if (_x in _allowedSnapPoints) then { - _pOffset = _nearestObject selectionPosition _x; - _snapPos = _nearestObject modelToWorldVisual _pOffset; - if (surfaceIsWater _snapPos) then { - _snapPos set[2, ((getPosASL _nearestObject) select 2) + (_pOffset select 2)]; - }; - _snapDistance = _pos2 distance _snapPos; - if (_snapDistance < _maxSnapDistance) exitWith{ - _isSnap = true; - _snapPosition = _snapPos; - _snapType = _type; - }; - }; - } forEach _snapPoints; - } forEach [[_snapPointsPara,"para"],[_snapPointsPerp,"perp"]]; - }; - - _distance = _pos2 distance _currentTarget; - - if (_isSnap && _distance < 5) then { - - EP_snap = _nearestObject; - EP_snapPos = _snapPosition; - - _direction = getDir _nearestObject; - if (_snapType == "perp") then { - _snapPos1 = [_snapPosition select 0, _snapPosition select 1, 0]; - _pos_snapObj = getposATL _nearestObject; - _pos_snapObj set[2, 0]; - _direction = _direction - (_snapPos1 getDir _pos_snapObj); - } else { - _direction = 0; - }; - if (EPOCH_snapDirection > 0) then { - if (EPOCH_snapDirection == 1) then { - _direction = _direction + 90; - }; - if (EPOCH_snapDirection == 2) then { - _direction = _direction + 180; - }; - if (EPOCH_snapDirection == 3) then { - _direction = _direction + 270; - }; - }; - if (_direction > 360) then { - _direction = _direction - 360; - }; - if (_direction < 0) then { - _direction = 360 + _direction; - }; - - if !(attachedObjects player isEqualTo[]) then { - { - detach _x; - } forEach attachedObjects player; - if (EPOCH_snapDirection > 0) then { - if (EPOCH_snapDirection == 1) then { - _direction = _direction + 90; - }; - if (EPOCH_snapDirection == 2) then { - _direction = _direction + 180; - }; - if (EPOCH_snapDirection == 3) then { - _direction = _direction + 270; - }; - }; - if (_direction > 360) then { - _direction = _direction - 360; - }; - if (_direction < 0) then { - _direction = 360 + _direction; - }; - - _dir2 = [vectorDir _nearestObject, _direction] call BIS_fnc_returnVector; - - if (_pos2 select 2 > _maxHeight) then { - _pos2 set[2, _maxHeight]; - }; - if (surfaceIsWater _snapPosition) then { - _snapPosition = ASLtoATL _snapPosition; - }; - - _currentTarget setVectorDirAndUp[_dir2, (vectorUp _nearestObject)]; - _currentTarget setposATL _snapPosition; - - - if ((diag_tickTime - _EPOCH_2) > 2) then { - _EPOCH_2 = diag_tickTime; - _arr_snapPoints = []; - EPOCH_arr_snapPoints = []; - { - _pos1_snap = _currentTarget modelToWorldVisual (_x select 0); - _pos2_snap = _currentTarget modelToWorldVisual (_x select 1); - _ins = lineIntersectsSurfaces [AGLToASL _pos1_snap, AGLToASL _pos2_snap,player,_currentTarget,true,1,"VIEW","FIRE"]; - if (count _ins > 0) then { - if (surfaceIsWater _snapPosition) then { - _arr_snapPoints pushBackUnique (_ins select 0 select 0); - } else { - _arr_snapPoints pushBackUnique ASLToATL(_ins select 0 select 0); - }; - }; - if (count _arr_snapPoints >= 2) exitWith { EPOCH_arr_snapPoints = _arr_snapPoints; } - } forEach _snapChecks; - }; - - }; - - } else { - - EPOCH_arr_snapPoints = []; - if !(attachedObjects player isEqualTo[]) then { - _offSet = [EPOCH_X_OFFSET, EPOCH_Y_OFFSET, EPOCH_Z_OFFSET]; - _pos1 = player modelToWorldVisual _offSet; - if (surfaceIsWater _pos1) then { - _pos1 set[2, ((getPosASL player) select 2) + EPOCH_Z_OFFSET]; - _pos1 = ASLtoATL _pos1; - }; - EPOCH_target setposATL _pos1; - EPOCH_target attachTo[player]; - }; - }; - }; - - } forEach _nearestObjects; - + while {EPOCH_target == _currentTarget} do { + _rejectMove = false; + if ((diag_tickTime - _lastCheckTime) > 10) then { + _lastCheckTime = diag_tickTime; + _rejectMove = !(EPOCH_target call EPOCH_isBuildAllowed); + }; + if (_rejectMove) exitWith{ + deleteVehicle EPOCH_target; + _currentTarget = objnull; + }; + if (player distance _currentTarget > 15) exitWith{ + deleteVehicle EPOCH_target; + _currentTarget = objnull; + ["Building Abort: Distance to high", 5] call Epoch_message; + }; if ((diag_tickTime - _EPOCH_1) > 1) then { _EPOCH_1 = diag_tickTime; if !(isNull EPOCH_target) then { @@ -310,15 +176,159 @@ if (_class != "") then { EPOCH_playerEnergy = (EPOCH_playerEnergy - _energyCost) max 0; }; }; + if !(_currentTargetAttachedTo isequalto EPOCH_target_attachedTo) then { + _currentTargetAttachedTo = EPOCH_target_attachedTo; + EPOCH_X_OFFSET = 0; + EPOCH_Z_OFFSET = 0; + EPOCH_doRotate = true; + if !(_currentTargetAttachedTo isequalto player) then { + EPOCH_buildDirection = getdir EPOCH_target; + EPOCH_Y_OFFSET = 0; + _AnchorPos = getposasl EPOCH_target; + } + else { + EPOCH_buildDirection = 0; + EPOCH_Y_OFFSET = 5; + }; + }; + _offSet = [EPOCH_X_OFFSET, EPOCH_Y_OFFSET, EPOCH_Z_OFFSET]; + if (_currentTargetAttachedTo isequalto player) then { + _pos2 = _currentTargetAttachedTo modelToWorldVisual _offSet; + if (surfaceIsWater _pos2) then { + _pos2 set[2, ((getPosASL _currentTargetAttachedTo) select 2) + EPOCH_Z_OFFSET]; + }; + } + else { + _pos2 = [(_AnchorPos select 0) + EPOCH_X_OFFSET,(_AnchorPos select 1) + EPOCH_Y_OFFSET,(_AnchorPos select 2) + EPOCH_Z_OFFSET]; + if !(surfaceIsWater _pos2) then { + _pos2 = asltoatl _pos2; + }; + }; + if (_pos2 select 2 > _maxHeight) then { + _pos2 set[2, _maxHeight]; + EPOCH_doRotate = true; + }; + if (_currentTargetAttachedTo isequalto player) then { + if (!(_nearestobjects isequalto []) && EPOCH_buildMode == 1) then { + if ((_pos2 distance EP_snapPos) > _maxSnapDistance || EPOCH_snapDirection != _Snapdirection) then { + _Snapdirection = EPOCH_snapDirection; + EP_snapPos = [0,0,0]; + _snapped = false; + { + _nearestObject = _x; + _isSnap = false; + _snapPosition = [0, 0, 0]; + if (!isNull _nearestObject) then { + _snapConfig = _cfgBaseBuilding >> (typeOf _nearestObject); + _snapPointsPara = getArray(_snapConfig >> "snapPointsPara"); + _snapPointsPerp = getArray(_snapConfig >> "snapPointsPerp"); + // base line for z height offset + _baselineSnapPos = _nearestObject modelToWorldVisual [0,0,0]; + { + _x params ["_snapPoints","_type"]; + { + if (_x in _allowedSnapPoints) then { + _pOffset = _nearestObject selectionPosition _x; + _snapPos = _nearestObject modelToWorldVisual _pOffset; + if (surfaceIsWater _snapPos) then { + _snapPos set[2, ((getPosASL _nearestObject) select 2) + (_pOffset select 2)]; + }; + _snapDistance = _pos2 distance _snapPos; + if (_snapDistance < _maxSnapDistance) exitWith{ + _isSnap = true; + _snapPosition = _snapPos; + _snapType = _type; + }; + }; + } forEach _snapPoints; + } forEach [[_snapPointsPara,"para"],[_snapPointsPerp,"perp"]]; + _distance = _pos2 distance _currentTarget; + if (_isSnap && _distance < 5) exitwith { + EP_snap = _nearestObject; + EP_snapPos = _snapPosition; + _direction = getDir _nearestObject; + if (_snapType == "perp") then { + _snapPos1 = [_snapPosition select 0, _snapPosition select 1, 0]; + _pos_snapObj = getposATL _nearestObject; + _pos_snapObj set[2, 0]; + _direction = _direction - (_snapPos1 getDir _pos_snapObj); + } + else { + _direction = 0; + }; + if (EPOCH_snapDirection > 0) then { + if (EPOCH_snapDirection == 1) then { + _direction = _direction + 90; + }; + if (EPOCH_snapDirection == 2) then { + _direction = _direction + 180; + }; + if (EPOCH_snapDirection == 3) then { + _direction = _direction + 270; + }; + }; + if (_direction > 360) then { + _direction = _direction - ((floor (_direction/360))*360); + }; + if (_direction < 0) then { + _direction = _direction + ((floor (-_direction/360))*360); + }; + { + detach _x; + } forEach attachedObjects player; + _dir2 = [vectorDir _nearestObject, _direction] call BIS_fnc_returnVector; + if (_pos2 select 2 > _maxHeight) then { + _pos2 set[2, _maxHeight]; + }; + if (surfaceIsWater _snapPosition) then { + _snapPosition = ASLtoATL _snapPosition; + }; + _currentTarget setVectorDirAndUp[_dir2, (vectorUp _nearestObject)]; + _currentTarget setposATL _snapPosition; + _snapped = true; + _arr_snapPoints = []; + EPOCH_arr_snapPoints = []; + { + _pos1_snap = _currentTarget modelToWorldVisual (_x select 0); + _pos2_snap = _currentTarget modelToWorldVisual (_x select 1); + _ins = lineIntersectsSurfaces [AGLToASL _pos1_snap, AGLToASL _pos2_snap,player,_currentTarget,true,1,"VIEW","FIRE"]; + if (count _ins > 0) then { + if (surfaceIsWater _snapPosition) then { + _arr_snapPoints pushBackUnique (_ins select 0 select 0); + } else { + _arr_snapPoints pushBackUnique ASLToATL(_ins select 0 select 0); + }; + }; + if (count _arr_snapPoints >= 2) exitWith { EPOCH_arr_snapPoints = _arr_snapPoints; } + } forEach _snapChecks; + }; + }; + if (_snapped) exitwith {}; + } forEach _nearestObjects; + }; + if (!_snapped) then { + [] call _MoveObject; + }; + } + else { + [] call _MoveObject; + }; + } + else { + [] call _MoveObject; + }; }; EPOCH_arr_snapPoints = []; { detach _x; - } forEach attachedObjects player; - + } forEach attachedObjects _currentTargetAttachedTo; + + if (!isnull _helper) then { + deletevehicle _helper; + }; if !(isNull _currentTarget) then { diff --git a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf index d3a0c574..3e05d81f 100644 --- a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf +++ b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf @@ -102,12 +102,8 @@ if (vehicle player == player) then { if (_dikCode == EPOCH_keysBuildMode1 && EPOCH_buildMode > 0) then { EPOCH_buildMode = 0; - EPOCH_snapDirection = 0; ["Build Mode: Disabled", 5] call Epoch_message; EPOCH_Target = objNull; - EPOCH_Z_OFFSET = 0; - EPOCH_X_OFFSET = 0; - EPOCH_Y_OFFSET = 5; _handled = true; }; @@ -128,16 +124,28 @@ if (vehicle player == player) then { if (EPOCH_buildMode > 0) then { if (!_ctrl) then { + _step = 0.5; + if(_shift)then{_step = 1.5;}; + if(_alt)then{_step = 0.01;}; switch (_dikCode) do { - case EPOCH_keysBuildMovUp: { EPOCH_Z_OFFSET = (EPOCH_Z_OFFSET + 0.1) min 6; _handled = true }; - case EPOCH_keysBuildMovDn: { EPOCH_Z_OFFSET = (EPOCH_Z_OFFSET - 0.1) max - 3; _handled = true }; - case EPOCH_keysBuildMovFwd: { EPOCH_Y_OFFSET = (EPOCH_Y_OFFSET + 0.1) min 5; _handled = true }; - case EPOCH_keysBuildMovBak: { EPOCH_Y_OFFSET = (EPOCH_Y_OFFSET - 0.1) max 2; _handled = true }; - case EPOCH_keysBuildMovL: { EPOCH_X_OFFSET = (EPOCH_X_OFFSET + 0.1) min 5; _handled = true }; - case EPOCH_keysBuildMovR: { EPOCH_X_OFFSET = (EPOCH_X_OFFSET - 0.1) max - 5; _handled = true }; - case EPOCH_keysBuildRotL: { EPOCH_buildDirection = (EPOCH_buildDirection + 1) min 360; EPOCH_doRotate = true; _handled = true }; - case EPOCH_keysBuildRotR: { EPOCH_buildDirection = (EPOCH_buildDirection - 1) max 0; EPOCH_doRotate = true; _handled = true }; - //case EPOCH_keysBuildIt: { cursorTarget call EPOCH_fnc_SelectTarget; _handled = true }; + case EPOCH_keysBuildMovUp: { _adj = 0.1;if(_shift)then{_adj = 0.5};if(_alt)then{_adj = 0.01};EPOCH_Z_OFFSET = (EPOCH_Z_OFFSET + _adj) min 6; _handled = true }; + case EPOCH_keysBuildMovDn: { _adj = 0.1;if(_shift)then{_adj = 0.5};if(_alt)then{_adj = 0.01};EPOCH_Z_OFFSET = (EPOCH_Z_OFFSET - _adj) max - 3; _handled = true }; + case EPOCH_keysBuildMovFwd: { _adj = 0.1;if(_shift)then{_adj = 0.5};if(_alt)then{_adj = 0.01};EPOCH_Y_OFFSET = (EPOCH_Y_OFFSET + _adj) min 5; _handled = true }; + case EPOCH_keysBuildMovBak: { _adj = 0.1;if(_shift)then{_adj = 0.5};if(_alt)then{_adj = 0.01};EPOCH_Y_OFFSET = (EPOCH_Y_OFFSET - _adj) max -5; _handled = true }; + case EPOCH_keysBuildMovL: { _adj = 0.1;if(_shift)then{_adj = 0.5};if(_alt)then{_adj = 0.01};EPOCH_X_OFFSET = (EPOCH_X_OFFSET + _adj) min 5; _handled = true }; + case EPOCH_keysBuildMovR: { _adj = 0.1;if(_shift)then{_adj = 0.5};if(_alt)then{_adj = 0.01};EPOCH_X_OFFSET = (EPOCH_X_OFFSET - _adj) max -5; _handled = true }; + case EPOCH_keysBuildRotL: { _adj = 1;if(_shift)then{_adj = 2.5};if(_alt)then{_adj = 0.5};EPOCH_buildDirection = (EPOCH_buildDirection + _adj) min 180; EPOCH_doRotate = true; _handled = true }; + case EPOCH_keysBuildRotR: { _adj = 1;if(_shift)then{_adj = 2.5};if(_alt)then{_adj = 0.5};EPOCH_buildDirection = (EPOCH_buildDirection - _adj) max -180; EPOCH_doRotate = true; _handled = true }; + /*case EPOCH_keysBuildIt: { cursorTarget call EPOCH_fnc_SelectTarget; _handled = true };*/ + case eXpoch_keysVectorResetObject: { EPOCH_X_OFFSET = 0;EPOCH_Y_OFFSET = 5;EPOCH_Z_OFFSET = 0;EPOCH_buildDirection = 0;EPOCH_buildDirectionPitch = 0;EPOCH_buildDirectionRoll = 0;EPOCH_doRotate = true;_handled = true }; + }; + if (Epoch_target iskindof 'Const_Ghost_EPOCH') then { + switch (_dikCode) do { + case eXpoch_keysVectorTiltL: {_adj = 1;if(_shift)then{_adj = 2.5};if(_alt)then{_adj = 0.5};EPOCH_buildDirectionRoll = (EPOCH_buildDirectionRoll - _adj) max -180; EPOCH_doRotate = true; _handled = true }; + case eXpoch_keysVectorTiltR: {_adj = 1;if(_shift)then{_adj = 2.5};if(_alt)then{_adj = 0.5};EPOCH_buildDirectionRoll = (EPOCH_buildDirectionRoll + _adj) min 180; EPOCH_doRotate = true; _handled = true }; + case eXpoch_keysVectorTiltAwy: {_adj = 1;if(_shift)then{_adj = 2.5};if(_alt)then{_adj = 0.5};EPOCH_buildDirectionPitch = (EPOCH_buildDirectionPitch - _adj) max -180; EPOCH_doRotate = true; _handled = true }; + case eXpoch_keysVectorTiltTwd: {_adj = 1;if(_shift)then{_adj = 2.5};if(_alt)then{_adj = 0.5};EPOCH_buildDirectionPitch = (EPOCH_buildDirectionPitch + _adj) min 180; EPOCH_doRotate = true; _handled = true }; + }; }; }; }; diff --git a/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf b/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf index 1f822284..172193b2 100644 --- a/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf +++ b/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf @@ -23,6 +23,9 @@ */ EPOCH_buildMode = 0; EPOCH_buildDirection = 0; +EPOCH_buildDirectionPitch = 0; +EPOCH_buildDirectionRoll = 0; +EPOCH_target_attachedTo = player; EPOCH_debugMode = false; EPOCH_snapDirection = 0; EPOCH_stabilityTarget = objNull; diff --git a/Sources/epoch_code/compile/setup/EPOCH_clientKeyMap.sqf b/Sources/epoch_code/compile/setup/EPOCH_clientKeyMap.sqf index bd6da6e4..dcbb424e 100644 --- a/Sources/epoch_code/compile/setup/EPOCH_clientKeyMap.sqf +++ b/Sources/epoch_code/compile/setup/EPOCH_clientKeyMap.sqf @@ -46,7 +46,12 @@ _keyMap = ["Build: Move LEFT", "EPOCH_keysBuildMovL", 0xD2], ["Build: Move RIGHT", "EPOCH_keysBuildMovR", 0xD3], ["Build: Rotate LEFT", "EPOCH_keysBuildRotL", 0x12], - ["Build: Rotate RIGHT", "EPOCH_keysBuildRotR", 0x10] + ["Build: Rotate RIGHT", "EPOCH_keysBuildRotR", 0x10], + ["Build: Vector LEFT", "eXpoch_keysVectorTiltL", 0xCB], + ["Build: Vector RIGHT", "eXpoch_keysVectorTiltR", 0xCD], + ["Build: Vector AWAY", "eXpoch_keysVectorTiltAwy", 0xC8], + ["Build: Vector TOWARD", "eXpoch_keysVectorTiltTwd", 0xD0], + ["Build: Reset Object", "eXpoch_keysVectorResetObject", 0x4C] ]; _keyMap call EPOCH_custom_KeyMap; diff --git a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp index 5e1b8eb5..319501f4 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_self.hpp @@ -70,34 +70,27 @@ class base_mode_disable icon = "x\addons\a3_epoch_code\Data\UI\buttons\build_remove.paa"; tooltip = "Build Mode: Disable"; }; - -class base_mode_snap_direction_0 +class base_mode_snap_direction { - condition = "EPOCH_buildMode == 1 && EPOCH_snapDirection != 0"; - action = "EPOCH_snapDirection = 0;[format['SNAP DIRECTION MODE: %1', EPOCH_snapDirection], 5] call Epoch_message;"; + condition = "EPOCH_buildMode == 1"; + action = "EPOCH_snapDirection = EPOCH_snapDirection + 1; if (EPOCH_snapDirection > 3) then {EPOCH_snapDirection = 0};[format['SNAP DIRECTION: %1°', EPOCH_snapDirection*90], 5] call Epoch_message;"; icon = "x\addons\a3_epoch_code\Data\UI\buttons\build_move.paa"; - tooltip = "Build Mode: Snap Direction 0°"; + tooltip = "Build Mode: Rotate 90°"; + tooltipcode = "format ['Build Mode: Switch Snap Direction to %1° (current %2°)',if (EPOCH_snapDirection < 3) then {(EPOCH_snapDirection+1)*90} else {0},EPOCH_snapDirection*90]"; }; -class base_mode_snap_direction_1 +class base_mode_detach { - condition = "EPOCH_buildMode == 1 && EPOCH_snapDirection != 1"; - action = "EPOCH_snapDirection = 1;[format['SNAP DIRECTION MODE: %1', EPOCH_snapDirection], 5] call Epoch_message;"; + condition = "EPOCH_buildMode > 0 && !isnull EPOCH_target && EPOCH_target_attachedTo isequalto player && Epoch_target iskindof 'Const_Ghost_EPOCH'"; + action = "EPOCH_target_attachedTo = objnull; ['Object Detached', 5] call Epoch_message;"; icon = "x\addons\a3_epoch_code\Data\UI\buttons\build_move.paa"; - tooltip = "Build Mode: Snap Direction 90°"; + tooltip = "Build Mode: Detach Object"; }; -class base_mode_snap_direction_2 +class base_mode_attach { - condition = "EPOCH_buildMode == 1 && EPOCH_snapDirection != 2"; - action = "EPOCH_snapDirection = 2;[format['SNAP DIRECTION MODE: %1', EPOCH_snapDirection], 5] call Epoch_message;"; + condition = "EPOCH_buildMode > 0 && !isnull EPOCH_target && !(EPOCH_target_attachedTo isequalto player) && Epoch_target iskindof 'Const_Ghost_EPOCH'"; + action = "EPOCH_target_attachedTo = player; ['Object Attached', 5] call Epoch_message;"; icon = "x\addons\a3_epoch_code\Data\UI\buttons\build_move.paa"; - tooltip = "Build Mode: Snap Direction 180°"; -}; -class base_mode_snap_direction_3 -{ - condition = "EPOCH_buildMode == 1 && EPOCH_snapDirection != 3"; - action = "EPOCH_snapDirection = 3;[format['SNAP DIRECTION MODE: %1', EPOCH_snapDirection], 5] call Epoch_message;"; - icon = "x\addons\a3_epoch_code\Data\UI\buttons\build_move.paa"; - tooltip = "Build Mode: Snap Direction 270°"; + tooltip = "Build Mode: Attach Object"; }; class Drink {