davidoss 552 Posted March 17, 2020 Trenches , digg cover for your self if you not able to find any.. usage: place scripts dirctory in your mission root directory add lines in: init.sqf if (hasInterface) then { 0 = [] spawn compile preprocessFileLineNumbers "scripts\lib_trenches\trenches.sqf"; player addEventHandler ["Respawn", { 0 = [] spawn compile preprocessFileLineNumbers "scripts\lib_trenches\trenches.sqf"; }]; }; description.ext class CfgSFX { class digging_sound { sound0[] = {"scripts\lib_trenches\sounds\ShovelDigging.ogg", db-0, 1.0, 100, 0.2, 99, 99, 99}; sounds[] = {sound0}; empty[] = {"", 0, 0, 0, 0, 0, 0, 0}; }; }; class CfgVehicles { class player_digging_sound { sound = "digging_sound"; }; }; script overwiev: trenches.sqf /* by DaVidoSS Digging trenches for cover usage: place scripts directory in your mission root directory add lines in: init.sqf if (hasInterface) then { 0 = [] spawn compile preprocessFileLineNumbers "scripts\lib_trenches\trenches.sqf"; player addEventHandler ["Respawn", { 0 = [] spawn compile preprocessFileLineNumbers "scripts\lib_trenches\trenches.sqf"; }]; }; description.ext class CfgSFX { class digging_sound { sound0[] = {"scripts\lib_trenches\sounds\ShovelDigging.ogg", db-0, 1.0, 100, 0.2, 99, 99, 99}; sounds[] = {sound0}; empty[] = {"", 0, 0, 0, 0, 0, 0, 0}; }; }; class CfgVehicles { class player_digging_sound { sound = "digging_sound"; }; }; */ if !(hasInterface) exitWith {}; waitUntil {!isNull player}; waitUntil {player == player}; player addAction [ "<t>Dig Trench </t><img size='1' image='\a3\ui_f\data\IGUI\Cfg\Actions\Obsolete\ui_action_turnin_ca'/>", { params [["_target",objNull,[objNull]],["_unit",objNull,[objNull]]]; (AGLToASL (_unit modelToWorldVisual [0,1.5,0])) params ["_vx","_vy","_vz"]; if !(isNull (objectParent _unit)) exitWith {0 = [[format ["<t size='.8'> %1</t>","Really? While driving?"],1,1,5]] spawn BIS_fnc_EXP_camp_SITREP}; if (surfaceIsWater (position _unit)) exitWith {0 = [[format ["<t size='.8'> %1</t>","Oh come on, you cant be that stupid!"],1,1,5]] spawn BIS_fnc_EXP_camp_SITREP}; if !(count (lineIntersectsObjs [(AGLToASL (_unit modelToWorldVisual [0,1.5,0])), [_vx,_vy,(_vz + 20)]]) == 0) exitWith {0 = [[format ["<t size='.8'> %1</t>","Open your eyes, no suitable space here!"],1,1,5]] spawn BIS_fnc_EXP_camp_SITREP}; if (!(isTouchingGround _unit ) || {((getPosATL _unit) select 2) > 0.2}) exitWith {0 = [[format ["<t size='.8'> %1</t>","Ok, but hit the ground first!"],1,1,5]] spawn BIS_fnc_EXP_camp_SITREP}; if (isOnRoad (ASLToAGL (getPosASL _unit))) exitWith {0 = [[format ["<t size='.8'> %1</t>","Sorry, solid ground here!"],1,1,5]] spawn BIS_fnc_EXP_camp_SITREP}; _unit setVariable ["digging",true,false]; _unit playMove "AinvPknlMstpSnonWnonDnon_medic_1"; //playSound3D [getMissionPath "scripts\lib_trenches\sounds\ShovelDigging.ogg", _unit, false, getPosASL _unit, 3, 1, 25];// in MP others cant hear the shovel - switched to soundsource private _diggsnd = createSoundSource ["player_digging_sound", _unit, [], 0]; waituntil { animationState _unit == "ainvpknlmstpsnonwnondnon_medic_1"}; sleep 4; private _trench = createVehicle ["Land_ShellCrater_02_small_F",_target modelToWorld [0,2,0], [], 0, "CAN_COLLIDE"]; deleteVehicle _diggsnd; _trench setDir (getDir _target - 90); private _radGrad = ([getPos _trench, getDir _target] call BIS_fnc_terrainGradAngle)/30; _trench setVectorUp (surfacenormal (getPosATL _trench)); private _posASL = getPosASL _trench; _trench setPosASL [_posASL select 0,_posASL select 1, ((_posASL select 2) + _radGrad)]; _unit setVariable ["digging",nil,false]; _unit setVariable ["mytrench",_trench,false]; 0 = [_trench, [ "<t>Remove Trench </t><img size='1' image='\a3\ui_f\data\IGUI\Cfg\Actions\Obsolete\ui_action_turnout_ca'/>", { params [["_target",objNull,[objNull]],["_unit",objNull,[objNull]]]; _unit setVariable ["digging",true,false]; _unit playMove "AinvPknlMstpSnonWnonDnon_medic_1"; //playSound3D ["A3\sounds_f\characters\human-sfx\01_medikit1.wss", _unit, false, getPosASL _unit, 3, 1, 25]; // in MP others cant hear the shovel - switched to soundsource private _diggsnd = createSoundSource ["player_digging_sound", _unit, [], 0]; waituntil { animationState _unit == "ainvpknlmstpsnonwnondnon_medic_1"}; sleep 4; deleteVehicle _target; deleteVehicle _diggsnd; _unit setVariable ["digging",nil,false]; },nil,0,true,true,"","(isNil {_this getVariable 'digging'})",3,false,"","" ] ] remoteExec ["addAction", [0,-2] select isDedicated,_trench]; },nil,0,false,true,"", "isNull (_this getVariable ['mytrench',objNull]) && {isNil {_this getVariable 'digging'}} && {((animationState _this) in [ 'amovpknlmstpsraswpstdnon', 'amovpknlmstpslowwpstdnon', 'amovppnemstpsraswpstdnon', 'amovpknlmstpsraswrfldnon', 'amovpknlmstpslowwrfldnon', 'amovppnemstpsraswrfldnon', 'amovpknlmstpsraswlnrdnon', 'amovpknlmstpsnonwnondnon', 'amovppnemstpsnonwnondnon' ])}", -1, false, "", ""]; 0 = [[format ["<t size='.8'> %1</t>","TRENCH Started"],1,1,5]] spawn BIS_fnc_EXP_camp_SITREP; Trenches 5 Share this post Link to post Share on other sites
Gunter Severloh 4064 Posted March 18, 2020 Cool love the idea! Some screenshots and maybe a video for demonstration would be inspiring. How would you "dig" a trench though, do you need a shovel from something, like say ACE, or does the script add one? Wouldn't a foxhole be more ideal, i mean a trench is fairly big, i remember in OFP's mod Liberation 1941-45 there was a menu with various trench types you could build, and when you chose it, and started digging, you could even assign AI to dig it, and each thing you chose it would say how long it would take to create in the menu, was pretty cool especially for OFP! 1 Share this post Link to post Share on other sites
Burbonizer 0 Posted August 8, 2020 Hi, not sure if a mod if stopping this working for me, but i have followed the instructions above and i get no addaction to build a trench. No errors, no nothing. When i start my mission i noticed the it says trench started in the bottom right, but other than that nothing. Any ideas? Share this post Link to post Share on other sites
kibaBG 53 Posted September 4, 2022 It starts because it says TTRENCHES on the left side of the screen but no addAction on player or anything? Share this post Link to post Share on other sites
Gunter Severloh 4064 Posted July 7 (edited) Adding to this thread, for the two previous comments asking and pointing out that the script or the ability to dig a trench dont work for them, you have to crouch for the addaction to show in your action menu. Also adding to this, i installed this script, tested it out, figured out how to dig the trench, now the original script in the OP will only allow you to build (dig) one trench, however i went to my friend Rydygier with an idea on how to increase the number of trenches you can build, and now its possible. Credits: Rydygier For those of you whom are interested in this script and its function, i have a video below here demonstrating how it works, and review the script, theres also a link below the video here where i have uploaded the script as you see it in the video with the ability to build more then one trench. Download the updated version: LINK Download the hold version: LINK Edited November 24 by Gunter Severloh Updated adding alternative version 1 2 Share this post Link to post Share on other sites
Alleged Accomplice 29 Posted September 27 This and this need to get married. Have the trench make a depression and put the crater stuff around the top or not, it doesn't have to. I have no clue how to do it. 1 Share this post Link to post Share on other sites
Gunter Severloh 4064 Posted November 24 Updated the script there is now an alternative version, this one you will hold for the function to dig. So when you crouch you will get a circle icon that says dig trench, you hold that and will dig the trench, by the time the trench is dug then the hold circle (icon) will be finished, use your action menu to remove the trench and same function. The updated code adds this function https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd it was setup so that the function syncs with the digging animation. Credits go to Rydygier for updating the script with this alternative version 2 Share this post Link to post Share on other sites
mikey74 186 Posted November 29 Nice Job!!!! I thought this may be something you may be interested in: I added a dirt patch and grass cutter they will also delete when trench is deleted. Hope you like. 🙂 Spoiler numbers 63 - 100 in code block private _trench = createVehicle ["Land_ShellCrater_02_small_F",_target modelToWorld [0,0,0], [], 0, "CAN_COLLIDE"]; private _dirt = createVehicle ["Land_DirtPatch_05_F", (_target modelToWorld [0,0,0]), [], 0, "NONE"]; _dirt setPos (_target modelToWorld [0,0,0]); _dirt setDir (random 360); _unit setVariable ["dirt",_dirt,false]; private _cutter = createVehicle ["Land_ClutterCutter_large_F", (_target modelToWorld [0,0,0]), [], 0, "NONE"]; _cutter setPos (_target modelToWorld [0,0,0]); _cutter setDir (random 360); _unit setVariable ["cutter",_cutter,false]; deleteVehicle _diggsnd; _trench setDir (getDir _target - 90); private _radGrad = ([getPos _trench, getDir _target] call BIS_fnc_terrainGradAngle)/30; _trench setVectorUp (surfacenormal (getPosATL _trench)); private _posASL = getPosASL _trench; _trench setPosASL [_posASL select 0,_posASL select 1, ((_posASL select 2) + _radGrad)]; _unit setVariable ["digging",nil,false]; _unit setVariable ["mytrench",_trench,false]; 0 = [_trench, [ "<t>Remove Trench </t><img size='1' image='\a3\ui_f\data\IGUI\Cfg\Actions\Obsolete\ui_action_turnout_ca'/>", { params [["_target",objNull,[objNull]],["_unit",objNull,[objNull]]]; _unit setVariable ["digging",true,false]; _unit playMove "AinvPknlMstpSnonWnonDnon_medic_1"; //playSound3D ["A3\sounds_f\characters\human-sfx\01_medikit1.wss", _unit, false, getPosASL _unit, 3, 1, 25]; // in MP others cant hear the shovel - switched to soundsource private _diggsnd = createSoundSource ["player_digging_sound", _unit, [], 0]; waituntil { animationState _unit == "ainvpknlmstpsnonwnondnon_medic_1"}; sleep 4; deleteVehicle _target; deleteVehicle _diggsnd; deleteVehicle (_unit getVariable "dirt"); deleteVehicle (_unit getVariable "cutter"); _unit setVariable ["digging",nil,false]; },nil,0,true,true,"","(isNil {_this getVariable 'digging'})",3,false,"","" ] ] remoteExec ["addAction", [0,-2] select isDedicated,_trench]; }, 2 Share this post Link to post Share on other sites