From 366d02c10e710a5d6f846262c47dc5029fb0610a Mon Sep 17 00:00:00 2001 From: Tom Blount Date: Sat, 3 Dec 2022 17:04:29 +0000 Subject: [PATCH 1/2] Updates to drawBuild (#75) * Removed git clutter from config * Add new objects and update UI * Add "tall" sandbags * Add cables * Add extra row to UI * Remove preview images for unused UI grids * Call enableSimulationGlobal locally now * Add "stacking" of objects * "Walkable" objects (e.g. hescos) can be stacked * Objects can now be placed on buildings (with some degree of success) * Add overhead cables to drawBuild * Tweaked cableheight of small poles --- CrowsZA/config.cpp | 6 -- CrowsZA/functions/fn_drawBuild.sqf | 95 +++++++++++++++++++++++--- CrowsZA/functions/fn_drawBuildZeus.sqf | 10 ++- CrowsZA/ui/drawbuildGui.hpp | 35 ++++++++-- 4 files changed, 124 insertions(+), 22 deletions(-) diff --git a/CrowsZA/config.cpp b/CrowsZA/config.cpp index 8c84145..71cfa1b 100644 --- a/CrowsZA/config.cpp +++ b/CrowsZA/config.cpp @@ -19,15 +19,9 @@ class CfgPatches }; author = "Crowdedlight"; authorUrl = "https://forums.bohemia.net/profile/1173289-crowdedlight/"; -<<<<<<< HEAD - version = 1.10.2; - versionStr = "1.10.2"; - versionAr[] = {1,10,2}; -======= version = 1.10.3; versionStr = "1.10.3"; versionAr[] = {1,10,3}; ->>>>>>> release/1.10.3 }; }; diff --git a/CrowsZA/functions/fn_drawBuild.sqf b/CrowsZA/functions/fn_drawBuild.sqf index db2eed9..af4cccf 100644 --- a/CrowsZA/functions/fn_drawBuild.sqf +++ b/CrowsZA/functions/fn_drawBuild.sqf @@ -18,6 +18,7 @@ params ["_startPos", "_endPos", "_objectName", "_enableSim", "_enableDmg"]; private _spawnObjectLength = 0; private _spawnObjectLengthOffset = 0; private _spawnDirOffset = 0; +private "_spawnObjectHeight"; switch(_objectName) do { // smaller hesco @@ -41,6 +42,13 @@ switch(_objectName) do { _spawnObjectLengthOffset = 0.7; _spawnDirOffset = 90; //90deg offset }; + // tall sandbags + case "Land_SandbagBarricade_01_F": + { + _spawnObjectLength = 1.7; + _spawnObjectLengthOffset = 1.7; + _spawnDirOffset = 90; //90deg offset + }; // trench case "fort_envelopebig": //only exists if grad trenches is on the server { @@ -125,6 +133,29 @@ switch(_objectName) do { _spawnObjectLengthOffset = 1.2; _spawnDirOffset = 90; //90deg offset }; + //power cables + case "PowerCable_01_StraightLong_F": + { + _spawnObjectLength = 5.02368; + _spawnObjectLengthOffset = 2.49; + _spawnDirOffset = 0; //no offset + }; + //concrete overhead line + case "Land_PowerLine_03_pole_F": + { + _spawnObjectLength = 40; + _spawnObjectLengthOffset = 20; + _spawnDirOffset = 0; //no offset + _spawnObjectHeight = 8.8; + }; + //wood overhead line + case "Land_PowerLine_02_pole_small_F": + { + _spawnObjectLength = 40; + _spawnObjectLengthOffset = 20; + _spawnDirOffset = 0; //no offset + _spawnObjectHeight = 8.9; + }; }; // calculate distance between points to know amount of hesco to cover the length - https://community.bistudio.com/wiki/vectorDistance @@ -146,7 +177,7 @@ private _distMove = _spawnObjectLength; // array of spawned objects private _allObjects = []; -// loop over the amount of hesco needed to be placed (distance calculation) +// loop over the amount of object needed to be placed (distance calculation) for "_i" from 1 to _iterations do { // increment distance - https://community.bistudio.com/wiki/getPos // if first position, we only move the offset from clicked position, for the rest we move position and offset. @@ -155,17 +186,21 @@ for "_i" from 1 to _iterations do { if (_i == 1) then { _nextPos = _tempPos getPos [_spawnObjectLengthOffset, _direction]; } else { - _nextPos = _tempPos getPos [_distMove, _direction]; + _nextPos = _tempPos getPos [_distMove, _direction]; }; - // diag_log format["nextpos: %1", _nextPos]; - - // spawn hesco - https://community.bistudio.com/wiki/createVehicle + // spawn object - https://community.bistudio.com/wiki/createVehicle _object = createVehicle [_objectName, _nextPos, [], 0, "CAN_COLLIDE"]; - // disable simulation if selected - Executed on server + // Align to highest surface (via killzone_kid at https://community.bistudio.com/wiki/Position#PositionAGLS) + _nextPos set [2, worldSize]; + _object setPosASL _nextPos; + _nextPos set [2, vectorMagnitude (_nextPos vectorDiff getPosVisual _object)]; + _object setPosASL _nextPos; + + // disable simulation if selected if (!_enableSim) then { - [_object, false] remoteExec ["enableSimulationGlobal", 2]; + _object enableSimulationGlobal false; }; // disable damage if chosen - If we see issues with this in future, consider setting owner to server, before disabling damage as the owner shouldn't change short of server crash... and then it doesnt matter @@ -176,10 +211,52 @@ for "_i" from 1 to _iterations do { // rotate it - https://community.bistudio.com/wiki/setVectorDir _object setDir _direction + _spawnDirOffset; //is individual offset + _object setVectorUp surfaceNormal position _object; + // set same position again to sync rotation across clients (Also snaps it to ground level better after rotation) - _object setPos (getPos _object); + //_object setPos (getPos _object); + _object setPosWorld getPosWorld _object; + + + // Special code for overhead wires + if(_objectName in ["Land_PowerLine_03_pole_F", "Land_PowerLine_02_pole_small_F"]) then { + + _object setVectorUp [0,0,1]; + // Create an invisible object, that "wires" (ropes) can be attached to + _dummy = "PortableHelipadLight_01_blue_F" createVehicle [0,0]; + _dummy hideObjectGlobal true; + _dummy disableCollisionWith _object; + _dummy setVehiclePosition [_object, [], 0, "CAN_COLLIDE"]; + [_dummy, [0,0,0]] call BIS_fnc_setObjectRotation; //Use this rather than setVectorUp - allows objects to collide + + // if (!_enableSim) then { + // _dummy enableSimulationGlobal false; + // }; // Wires don't like attaching to static/simple objects + _dummy allowDamage false; + + // Note: attatchTo would be great, so that moving a pole also moved + // the wires; but the wires don't like static/simple objects + // (this is especially an issue if the "dummy" object, e.g., rolls down a hill!) + // and we can't do it the other way around or the pole wouldn't take damage + _allObjects pushBack _dummy; + + // Create the wires between this pole and the previous "pole" + if(!isNull crowsZA_drawbuild_lastPole) then { + _distance = (_dummy distance crowsZA_drawbuild_lastPole); + _rope = ropeCreate [_dummy, [0, 0, _spawnObjectHeight], crowsZA_drawbuild_lastPole, [0, 0, _spawnObjectHeight], _distance]; + _rope enableSimulationGlobal false; + _allObjects pushBack _rope; + }; + crowsZA_drawbuild_lastPole = _dummy; + + _object setVariable ["_dummy", _dummy]; + _object addEventHandler ["Killed", { + params ["_unit", "_killer", "_instigator", "_useEffects"]; + deleteVehicle (_unit getVariable "_dummy"); + }]; + }; - // add to array to make zeus editable. Doing like so to only send one server event and not one per spawned element, more effecient. + // add to array to make zeus editable. Doing like so to only send one server event and not one per spawned element, more efficient. _allObjects pushBack _object; // update temp position diff --git a/CrowsZA/functions/fn_drawBuildZeus.sqf b/CrowsZA/functions/fn_drawBuildZeus.sqf index 0e0ebd5..449060b 100644 --- a/CrowsZA/functions/fn_drawBuildZeus.sqf +++ b/CrowsZA/functions/fn_drawBuildZeus.sqf @@ -14,6 +14,8 @@ Starts the selection handler to select multiple points for you to draw params [["_pos",[0,0,0],[[]],3], ["_unit",objNull,[objNull]]]; +crowsZA_drawbuild_lastPole = objNull; + //create display if (!createDialog "crowsZA_drawbuild_display") exitWith {["Failed to open drawbuild dialog"] call crowsZA_fnc_showHint}; @@ -31,6 +33,7 @@ private _arrOptions = [ "Land_HBarrier_3_F", //hesco default "Land_HBarrier_Big_F", //big hesco default "Land_BagFence_Short_F", //sandbag wall - default + "Land_SandbagBarricade_01_F", //tall sandbags "Land_TyreBarrier_01_line_x4_F", //tire wall "Land_ConcreteWall_01_m_4m_F", //concrete wall @@ -45,7 +48,12 @@ private _arrOptions = [ "Land_Hedge_01_s_2m_F", //grass hedge "Land_NetFence_02_m_4m_F", //net fence "Land_New_WiredFence_5m_F", //wire fence - "Land_Razorwire_F" //razor wire + "Land_Razorwire_F", //razor wire + + //misc. + "PowerCable_01_StraightLong_F", //power cable + "Land_PowerLine_03_pole_F", //concrete overhead line + "Land_PowerLine_02_pole_small_F" //wood overhead line ]; // only add grad trenches if that mod is loaded diff --git a/CrowsZA/ui/drawbuildGui.hpp b/CrowsZA/ui/drawbuildGui.hpp index 05217e8..653e3b4 100644 --- a/CrowsZA/ui/drawbuildGui.hpp +++ b/CrowsZA/ui/drawbuildGui.hpp @@ -25,13 +25,14 @@ class crowsZA_drawbuild_display { }; class Content: RscControlsGroupNoScrollbars { idc = IDC_CONTENT; - h = POS_H(11); + h = POS_H(13.5); x = POS_X(12); w = POS_W(14); class controls { class grid1: RscActivePicture { idc = IDC_ICON_GRID_FIRST; - text = "\A3\EditorPreviews_F\Data\CfgVehicles\Land_BagFence_Short_F.jpg"; + //text = "\A3\EditorPreviews_F\Data\CfgVehicles\Land_BagFence_Short_F.jpg"; + text = ""; // Don't display a preview image if there's no content for the grid color[] = {1,1,1,0.8}; //change from 0.5 alpha to not be too dark but still show when hovered tooltip = ""; x = 0; @@ -99,11 +100,33 @@ class crowsZA_drawbuild_display { idc = IDC_ICON_GRID_FIRST + 14; x = POS_W(12); }; + // row 4 + class row4: grid1 { + idc = IDC_ICON_GRID_FIRST + 15; + x = 0; + y = POS_H(8); + }; + class grid17: row4 { + idc = IDC_ICON_GRID_FIRST + 16; + x = POS_W(3); + }; + class grid18: row4 { + idc = IDC_ICON_GRID_FIRST + 17; + x = POS_W(6); + }; + class grid19: row4 { + idc = IDC_ICON_GRID_FIRST + 18; + x = POS_W(9); + }; + class grid20: row4 { + idc = IDC_ICON_GRID_FIRST + 19; + x = POS_W(12); + }; // bottom rows for toggle enables, simulation class cbSimulation: RscCheckBox { idc = IDC_CHECKBOX_SIMULATION; x = 0; - y = POS_H(8); + y = POS_H(10.5); w = POS_W(1); h = POS_H(1); soundClick[] = {"\a3\ui_f\data\sound\rscbutton\soundclick", 0.09, 1}; @@ -115,7 +138,7 @@ class crowsZA_drawbuild_display { class lblSimulation: RscText { idc = -1; x = POS_W(1); - y = POS_H(8); + y = POS_H(10.5); w = POS_W(10); h = POS_H(1); // colorBackground[] = {0, 0, 0, 0.7}; @@ -124,11 +147,11 @@ class crowsZA_drawbuild_display { // damage class cbDamage: cbSimulation { idc = IDC_CHECKBOX_DAMAGE; - y = POS_H(9.5); + y = POS_H(12); checked = 0; //default to be disabled }; class lblDamage: lblSimulation { - y = POS_H(9.5); + y = POS_H(12); text = "Enable Damage"; }; }; From ed99445be8003a967006034e14f389f9b7bb60be Mon Sep 17 00:00:00 2001 From: Frederik Mazur Andersen Date: Sat, 3 Dec 2022 18:34:06 +0100 Subject: [PATCH 2/2] version bump --- CrowsZA/config.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CrowsZA/config.cpp b/CrowsZA/config.cpp index 71cfa1b..1929c98 100644 --- a/CrowsZA/config.cpp +++ b/CrowsZA/config.cpp @@ -19,9 +19,9 @@ class CfgPatches }; author = "Crowdedlight"; authorUrl = "https://forums.bohemia.net/profile/1173289-crowdedlight/"; - version = 1.10.3; - versionStr = "1.10.3"; - versionAr[] = {1,10,3}; + version = 1.10.4; + versionStr = "1.10.4"; + versionAr[] = {1,10,4}; }; };