JoMiMi 3 Posted May 24, 2020 Is there a way using holdAction to delete obstacles (e.g. Shoothouse Wall (long)) in the way of doors/windows? I am very inexperienced in scripting, and I couldn't figure out how to do it myself. 1 Share this post Link to post Share on other sites
wogz187 1086 Posted May 24, 2020 @JoMiMi, Hey something like this should work, Spoiler you_clearThis=[ player, "Remove Barricade", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "(cursorTarget getvariable ""you_isBarricade"") ==1 && player distance cursorTarget<3", "isNull objectParent player", {}, {}, { deleteVehicle cursorTarget; }, {}, [], duration, 0, false, true] call BIS_fnc_holdActionAdd; give each object the variable "you_isBarricade" to make them removable or remove that condition so it works with whatever object. Have fun! 1 Share this post Link to post Share on other sites
JoMiMi 3 Posted May 26, 2020 Is that in the .sqf file or in the unit's init field? Share this post Link to post Share on other sites
wogz187 1086 Posted May 27, 2020 @JoMiMi, Quote Is that in the .sqf file or in the unit's init field? You may paste that just about anywhere code will stick. The unit's init, the init properties field, init.sqf, the init of some random object. For MP you would want to replace the player reference with "this" and put it in the unit's init (I think). Something like this, Spoiler you_clearThis=[ this, "Remove Barricade", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "(cursorTarget getvariable ""you_isBarricade"") ==1 && _this distance cursorTarget<3", "isNull objectParent _this", {}, {}, { deleteVehicle cursorTarget; }, {}, [], duration, 0, false, true] call BIS_fnc_holdActionAdd; and of course paste, Spoiler this setvariable ["you_isBarricade", 1]; into the the init of each removable object. The reason why "you_isBarricade" is not boolean (true, false), is you may want some objects to have different removal settings. For example, a larger object takes longer to move. With an extra line or two of code the action can be programmed to determine the length of the hold. Be sure to fill in "duration" with the desired time it takes to remove an object. Have fun! edit: Spoiler I love this idea and I'm totally going to use it. The function will allow barricade objects to be grabbed and thrown away (to the ground) and will also handle things like, say, crash-site debris. I'll post that function here when it's done. Share this post Link to post Share on other sites
ZaellixA 383 Posted May 27, 2020 (edited) I am not sure about it, so please correct me if I am wrong, but I believe that the init field code is run for each and every player that logs in the game. So, I believe it would be wiser to keep it simple for MP missions and if possible divert the code that has to be run only once to some other script like initServer.sqf. This could be done easily if you give specific (code)names to your objects and then look for them in the initServer.sqf (or any other script you decide to use). This, for example, could be done like /* * initServer.sqf * --------------- * The names given to the objects of interest is obj_X, where X is just an integer. You could * most probably find a better naming convention. */ // Go through the objects for private _i from 0 to 10 do { private _obj = "obj_" + (str _i); // Create the name of the object _obj setValue["YOU_isBarricade", 1]; // Wogz's code }; This has the limitation that you must know and hardcode the names and the number of objects, which may not be so convenient. It would work quite well for a small amount of objects though. Alternatively you could work by type and do something like /* * initServer.sqf * --------------- * You have to hardcode the types you would like to search for. */ // Set up some variables _objTypes = ["B_Heli_Light_01_armed_F", "Land_Cargo_HQ_V1_F"]; // Set the object types -> Used some random here for demonstration // Get the centre of the "world" private _centre = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"); // Calculate the radius of search (used below) private _mapRadius = (sqrt (2 * worldSize * worldSize))/2; // Calculate half the diagonal of the map // Search in the whole map for those objects { private _objs = _centre nearObjects[_objTypes select _forEachIndex, _mapRadius]; // Go through the objects { _x setVariable["YOU_isBarricade", 1]; // Set the variable } forEach _objs; } forEach _objTypes; Most probably there must be a better and more efficient way to do it, but I haven't really thought of anything :P... I'll try to put some more thought into it later and if I manage to refine it or find another way I'll let you know. As always........ this is not tested so, TEST, TEST, TEST, TEST and when done... TEST SOME MORE before use. 🙂 Edited May 31, 2020 by ZaellixA Corrected the half-diagonal calculation 2 Share this post Link to post Share on other sites