Jump to content
pognivet

How to delete all objects with specific classnames from a map

Recommended Posts

I would like to play the map "Kidal" but without the ungodly amount of rocks and stones scattered through the desert. It makes it impossible for the AI tanks to navigate through. Is there a way that I can hideobjectglobal all of these rocks based on their classnames either through a gamelogic or init.sqf? Thanks.

Share this post


Link to post
Share on other sites
_allStuff = nearestTerrainObjects [(getMarkerPos "hideMarker"), ["ROCK", "ROCKS"], 250000, true];
{_x hideObjectGlobal true;} forEach _toHide;

Untested, if it doesn't work clear the types array of nearestTerrainObjects and use a manual filter on types in the forEach loop.

Share this post


Link to post
Share on other sites
On 9/13/2018 at 3:46 AM, stanhope said:

_allStuff = nearestTerrainObjects [(getMarkerPos "hideMarker"), ["ROCK", "ROCKS"], 250000, true];
{_x hideObjectGlobal true;} forEach _toHide;

Untested, if it doesn't work clear the types array of nearestTerrainObjects and use a manual filter on types in the forEach loop.

This doesn't work, but I'll try the other thing you mentioned. Could you possibly give a small example?

Share this post


Link to post
Share on other sites

(Tested on Altis)

_allStuff = nearestTerrainObjects [getPos player, [], 2000, true];

{
  _type = toLower (str _x);

  if (_type find 'stone' > -1) then {
  	_x hideObjectGlobal true;
  };
  if (_type find 'rock' > -1) then {
  	_x hideObjectGlobal true;
  };

} forEach _allStuff;

 

Before running that code:

 

After running that code:

 

You can still see some rocks in the background but I only ran the code for a 20 meter radius around where I was standing.

Edited by stanhope
Tweaked code a bit for more coverage
  • Like 1

Share this post


Link to post
Share on other sites

Under 3den editor systems and environment there is a hide object module you can use to hide map objects. No scripting needed.

Share this post


Link to post
Share on other sites
8 hours ago, cobra4v320 said:

Under 3den editor systems and environment there is a hide object module you can use to hide map objects. No scripting needed.

Not specific for rocks!

 

in init.sqf

{_x hideObject true} forEach (nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["ROCK", "ROCKS","HIDE"], WorldSize*0.7, false,true])

 

Do not use global command. You can hide that locally at mission start for each player. HIDE is a generic class you can add or remove, depending on your "rock" classes. Test with/without it.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
17 hours ago, pierremgi said:

Not specific for rocks!

 

in init.sqf

{_x hideObject true} forEach (nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["ROCK", "ROCKS","HIDE"], WorldSize*0.7, false,true])

 

Do not use global command. You can hide that locally at mission start for each player. HIDE is a generic class you can add or remove, depending on your "rock" classes. Test with/without it.

Damn you're right... they have them lumped together with all the "other" things. Should be an option for just rocks as well.

  • Like 1

Share this post


Link to post
Share on other sites
On 9/15/2018 at 2:33 AM, stanhope said:

(Tested on Altis)


_allStuff = nearestTerrainObjects [getPos player, [], 2000, true];

{
  _type = toLower (str _x);

  if (_type find 'stone' > -1) then {
  	_x hideObjectGlobal true;
  };
  if (_type find 'rock' > -1) then {
  	_x hideObjectGlobal true;
  };

} forEach _allStuff;

 

Before running that code:

  Reveal hidden contents

 

After running that code:

  Reveal hidden contents

 

You can still see some rocks in the background but I only ran the code for a 20 meter radius around where I was standing.

This freezes the game for like ten seconds right when a mission starts, as is expected, but it works perfectly.

 

What are some other "types" that I can search for and delete, such as trees and bushes? I tried replacing rock and stone with tree and bush, but no luck.

 

Also do you know of a way to replace the deleted objects? For example, if I wanted to delete every streetlight on the map and replace them with a different model of steetlight facing the same direction and in the same place as the deleted ones, is there a simple init.sqf type script that I can use to do that? Thanks.

Share this post


Link to post
Share on other sites
23 minutes ago, pognivet said:

What are some other "types" that I can search for and delete, such as trees and bushes? I tried replacing rock and stone with tree and bush, but no luck.

I don't know by hard, just walk around the map and do "hint str typeOf cursorObject".

 

24 minutes ago, pognivet said:

Also do you know of a way to replace the deleted objects? For example, if I wanted to delete every streetlight on the map and replace them with a different model of steetlight facing the same direction and in the same place as the deleted ones, is there a simple init.sqf type script that I can use to do that? Thanks.

  Sure:

{
  _x hideObject true;
  if (typeOf _x = "yourStreetlightClassname") then {
      private _newLight = "newStreetlightClassname" createVehicle [0,0,0];
      _newLight setDir (getDir _x);
      _newLight setPosWorld (getPosWorld _x);
  };
} forEach (nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["ROCK", "ROCKS","HIDE", "yourStreetlightClassname"], WorldSize*0.7, false,true]);

Untested. 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 4/19/2019 at 2:39 PM, stanhope said:

I don't know by hard, just walk around the map and do "hint str typeOf cursorObject".

 

  Sure:


{
  _x hideObject true;
  if (typeOf _x = "yourStreetlightClassname") then {
      private _newLight = "newStreetlightClassname" createVehicle [0,0,0];
      _newLight setDir (getDir _x);
      _newLight setPosWorld (getPosWorld _x);
  };
} forEach (nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["ROCK", "ROCKS","HIDE", "yourStreetlightClassname"], WorldSize*0.7, false,true]);

Untested. 

Thank you for being so helpful and taking the time and taking the time to write this. I'll try this out.

Share this post


Link to post
Share on other sites
6 hours ago, pierremgi said:

 

Excellent addon Pierre.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×