LoseBummer 4 Posted June 3, 2016 [FIX version in the post #3. thanks to Kylania] Looking for a way to remove objectmaps like junk, garbage and scrap cars within a range I come across with nearestTerrainObjects. The types name "hide" appears to be the one. There are different ones. I´ve been searching this for a while now, thanks to the help of R3vo and das attorney i adapt a script from Brun (link to the reference post). Gamelogic>init null = ["MARKERNAME"] execVM "SCRIPTNAME.sqf"; The radious is taken from the size of area marker. Script.sqf _marker = _this param [0,"CENTER",[""]]; _Size = markerSize _marker; _markerSize = _Size select 1; { hideObjectGlobal _x; } foreach (nearestTerrainObjects [markerpos _marker, ["HIDE"],_markerSize]); 2 Share this post Link to post Share on other sites
kylania 568 Posted June 4, 2016 Turns out "HIDE" captures a lot more than just wrecks and garbage unfortunately. Here's 100m worth of "HIDE" standing on the hospital in Kavala capturing things like sidewalks, lampposts, ATMs, traffic signs, benches, phonebooths, garbage bins and more. http://imgur.com/a/lQvq1 You can delete just the wrecks with this tweak to the above: { if ((toUpper(str _x) find "WRECK") >= 0) then { hideObjectGlobal _x; }; } foreach (nearestTerrainObjects [markerpos _marker, ["HIDE"], _markerSize]); 2 Share this post Link to post Share on other sites
LoseBummer 4 Posted June 4, 2016 Nice! Thanks Kylania. With Wreck, Toilet and Garbage in my case is enough. _marker = _this param [0,"CENTER",[""]]; _Size = markerSize _marker; _markerSize = _Size select 1; { if ((toUpper(str _x) find "WRECK") >= 0) then { hideObjectGlobal _x; }; } foreach (nearestTerrainObjects [markerpos _marker, ["HIDE"], _markerSize]); { if ((toUpper(str _x) find "GARBAGE") >= 0) then { hideObjectGlobal _x; }; } foreach (nearestTerrainObjects [markerpos _marker, ["HIDE"], _markerSize]); { if ((toUpper(str _x) find "TOILET") >= 0) then { hideObjectGlobal _x; }; } foreach (nearestTerrainObjects [markerpos _marker, ["HIDE"], _markerSize]); Share this post Link to post Share on other sites
kylania 568 Posted June 4, 2016 Ack! Duplicate code detected! Nobody panic! :P I'm sure there's a better way of doing this, but I wasn't finding anything definite so try this maybe? _marker = _this param [0,"CENTER",[""]]; _markerSize = (markerSize _marker) select 1; _junk = ["GARBAGE", "WRECK", "TOILET", "TYRES", "JUNKPILE"]; { _item = _x; if ({(toUpper(str _item) find _x >=0)} count _junk > 0) then { hideObjectGlobal _item; }; } foreach nearestTerrainObjects [markerpos _marker, ["HIDE"], _markerSize]; 1 Share this post Link to post Share on other sites
LoseBummer 4 Posted June 5, 2016 Great (I knew it that was wrong, but i was too shy to ask). Share this post Link to post Share on other sites
kylania 568 Posted June 5, 2016 Nothing you wrote was wrong at all! Just not as elegant as it could be. :) Share this post Link to post Share on other sites
Persian MO 82 Posted June 5, 2016 it's weird.The codes not working for me.can you share a sample mission here, please? Share this post Link to post Share on other sites
kylania 568 Posted June 5, 2016 Here's a demo mission. The demo mission has an info stand with three actions on it. First is default using the 50x70 area "center" marker which will miss the wreck to the left and the washing machine even though they within 70m of the center of the marker they are on the 50m side so out of range of the area of the marker. Second action is using a custom non-area marker and default radius of 50m. So it'll pick up the washing machine but not the wreck on the left. Third action is that same custom marker but with a specified 70m range which will clear the washing machine and the wreck (and more!). The code has been changed to take into account marker area even if it's not symmetrical. The marker name is optional (defaults to "center") and the area is optional as well (defaults to 50m or the area of a marker). Here's the improved code: /* Ex: null = [] execVM "clean.sqf // Defaults to marker named "center" and 50m radius (unless it's an area marker). null = ["myOtherMarker"] execVM "clean.sqf // Cleans around a marker named "myOtherMarker" with 50m radius (unless it's an area marker). null = ["myUglyBackyard", 200] execVM "clean.sqf // Cleans 200m around a marker named "myUglyBackyard" (unless it's an area marker). */ // Defaults params [["_marker", "center"], ["_area", 50]]; // Types of junk to clean. _junk = ["GARBAGE", "WRECK", "TOILET", "TYRES", "JUNKPILE"]; // Area marker flag _markerArea = false; // If we're an area marker sort sizes to get the largest size and set the area flag for later. if (markerShape _marker in ["ELLIPSE", "RECTANGLE"]) then { _shape = markerSize _marker; // Returns the size, ie [50, 70] _shape sort false; // Sort the area array, ie now [70, 50] _area = _shape select 0; // Set area to the largest size _markerArea = true; // Set flag for later }; { _item = _x; // Current item in search area list // If we're an area marker check that the object is actually within the marker. Ie, 65m away from the 50m side for example. if (_markerArea && !(getPosWorld _item inArea _marker)) exitWith {}; // If we're in the area compare the object name to the _junk list. If we match hide the object. if ({(toUpper(str _item) find _x >=0)} count _junk > 0) then { hideObjectGlobal _item; }; } foreach nearestTerrainObjects [markerpos _marker, ["HIDE"], _area]; 3 Share this post Link to post Share on other sites
rob3para 5 Posted June 5, 2016 Hi If you set the marker size to the full size of Altis will it help with performance a bit. Share this post Link to post Share on other sites
Persian MO 82 Posted June 5, 2016 thanks alot for sample mission. _junk = ["GARBAGE", "WRECK", "TOILET", "TYRES", "JUNKPILE"]; about _junk, have i need to put all objects class names or its a something like cfgpatch classnames? Share this post Link to post Share on other sites
kylania 568 Posted June 5, 2016 Here's what the return of nearestTerrainObjects looks like: [ 1571177: garbagewashingmachine_f.p3d, 1571174: garbage_square3_f.p3d, 1571206: wreck_offroad_f.p3d, 1571179: lampshabby_off_f.p3d, 1571178: garbagepallet_f.p3d, 1571207: wreck_offroad2_f.p3d, 1571172: junkpile_f.p3d, 1570414: powerpolewooden_small_f.p3d, 51195: signt_dangerbendsr.p3d ] So you'd place it _junk capitalized unique parts of what you'd want to remote from that list. So like putting "GARBAGE" would clean up the garbagewashingmachine, garbage square and garbagepallet. If you added in "POWERPOLE" you'd also remove the small wooden power pole that's nearby. If you changed "GARBAGE" to "GARBAGE_" you'd only remove the square of garbage but leave behind the washing machine and pallet. So in the editor you might play around with it to get a list of objects first to see what to filter from. Here's my debug console from while I'd been testing the mission. You'll see I was able to test the script in the top execute field on demand. I had the list of objects around me in the first watch field. I had a gamelogic near the left wreck I used to create the bob object which I could then check the distance from the custom marker I had and check if it was in the area of my area marker too. Debug console is pretty useful. You can bring it up in the editor by pressing ESC. Make sense? 2 Share this post Link to post Share on other sites
MikeMuir 9 Posted June 5, 2016 You can aslo type in your debug console "hint str cursorObject;" to get the name of a specific object you're directly looking at. Perfect to identify those uglys FISHINGGEAR and CRABCAGES. 2 Share this post Link to post Share on other sites
Aradol 13 Posted June 5, 2016 I added "CARGO" to try and get rid of those horrible cargo houses on the Stratis airbase and they are still there. Share this post Link to post Share on other sites
kylania 568 Posted June 5, 2016 I added "CARGO" to try and get rid of those horrible cargo houses on the Stratis airbase and they are still there. If you mean the rusty ones that's because those are considered "HOUSE" rather than "HIDE". So to capture things like that change the last line of the script to read: } foreach nearestTerrainObjects [markerpos _marker, ["HIDE", "HOUSE"], _area]; Share this post Link to post Share on other sites
Aradol 13 Posted June 5, 2016 Thanks. I thought HIDE was the command to make it invisible, So if I want to get rid of walls/ fences will either of those work or do i need another bit of text? Share this post Link to post Share on other sites
kylania 568 Posted June 5, 2016 "FENCE" and "WALL" should work it seems. You can see the full list of options on the Biki. Share this post Link to post Share on other sites
Aradol 13 Posted June 5, 2016 If you mean the rusty ones that's because those are considered "HOUSE" rather than "HIDE". So to capture things like that change the last line of the script to read: } foreach nearestTerrainObjects [markerpos _marker, ["HIDE", "HOUSE"] They still show up in mission after making changes. Share this post Link to post Share on other sites
Aradol 13 Posted June 5, 2016 I added all types on that link you sent so that I have options later on. Share this post Link to post Share on other sites
kylania 568 Posted June 5, 2016 You can change the first line to: params [["_marker", "center"], ["_area", 50], ["_types", ["HIDE"]]]; and the last line to: } foreach nearestTerrainObjects [markerpos _marker, _types, _area]; Then if you need the extra types you can call it with: null = ["myMarker", 30, ["HIDE", "HOUSE"]] execVM "clean.sqf"; or just this if you're happy with just HIDE objects and a 50 meter range: null = ["myMarker"] execVM "clean.sqf"; Share this post Link to post Share on other sites
LoseBummer 4 Posted June 6, 2016 Oh that improved code its beautiful. I´m triyng to find a way to replace the p3d off lamps with the on version without results. It´s possible? Share this post Link to post Share on other sites
kylania 568 Posted June 6, 2016 Got an idea how, but do you have a sample of where one of these lamps are? All the ones I can find turn on at night automatically. Share this post Link to post Share on other sites
LoseBummer 4 Posted June 6, 2016 Yeah, I´m working in a template in this sector to build a compound. Link part mission; With a previous version o the script with command nearestobject what i do is search for the object (that version can´t find map objects). Searchs Off or ON lamps and change it for the counterpart. Radio Alpha is ON, Radio Bravo is Off. (In my case I manually find the off lamps and create one by one a on version above hidding the old one) Triyng to adapt with the neastestTerrainObject goes above my little knowlegde. With your script i can find it but not create the new object. Share this post Link to post Share on other sites
kylania 568 Posted June 6, 2016 You can use createSimpleObject to make a new one but I wasn't able to detect the lampposts with nearestTerrainObjects. I think they are still actual objects so you'd need to use nearestObjects to find them. However in my tests I think it was creating them underground since I couldn't see them. It wasn't till I added in the vectorAdd stuff from the example before I could see the objects however they were like 10m in the air! Share this post Link to post Share on other sites
LoseBummer 4 Posted June 6, 2016 Ok, progress. I remix the two scripts. One issue, if createsimpleobject is use the lights are on but without the light effect (i can explain better, the model of lamp is white but has no light effect on object). And with createvehicle, the light effect and model are created and can be destroyed. Sample Mission with the example. LINK Share this post Link to post Share on other sites