Jump to content

Recommended Posts

Need to register when unit is in graveyard dynamically according to proximity of an actual gravestone.

 

 Found only these classnames:

Land_Grave_V1_F

Land_Grave_V2_F

Land_Grave_V3_F

 

However:

             _list =  (nearestTerrainObjects [player, [], 50]) select 0 ;

              hint str _list

 

when standing next to a Gravestone only delivers:

 

              472366 grave_05_f p3d which i guess is the model name and doesnt help

 

 Adding typeOf:

 

               

            _list =  (nearestTerrainObjects [player, [], 50]) select 0 ;

            _to = typeOf _list;

             hint str _to

 

 Returns only an empty ""

Share this post


Link to post
Share on other sites

This might be useful; a little script I used to get the locations of all items of a certain model

_locations = [];
{
	if (str _x find "busstop_01_shelter_f" != -1) then
	{
		_location = [getPos _x select 0, getPos _x select 1];
		_locations pushBack _location;
	};
} forEach nearestObjects [player, [], 50000];
hint str _locations;
copyToClipboard str _locations

You'd replace "busstop_01_shelter_f" with " Land_Grave_ ". And the 50000 with whatever distance you want.

Share this post


Link to post
Share on other sites

There is no class on your returned objects. That's the reason why you can sort the result by distance. Then catch the good one with your selection, depending on the player's position.

Share this post


Link to post
Share on other sites

I just tested,  this:

_locations = []; 
{ 
 if (str _x find "grave" != -1) then 
 { 
  _location = getPos _x; 
  _locations pushBack _location; 
 }; 
} forEach nearestObjects [player, [], 500]; 
hint str _locations; 
copyToClipboard str _locations

works fine for me. I teleported myself into a graveyard and it gives me a bunch of locations for graves.

 

Or probably better for you:

{ 
 if (str _x find "grave" != -1) exitWith {hint "there's a grave near"}
} forEach nearestObjects [player, [], 50]; 

Should only give the hint if there's a gravestone within 50m

  • Like 1

Share this post


Link to post
Share on other sites

Yep, the JSD code works also on nearestTerrainObjects, except if you placed yours in editor! If not, you can save some resource with nearestTerrainObjects which doesn't return useless things like player himself, mosquitos, honeybees... even footprints...

 

Give attention to these differences:

- Adding classes in the array of (typeOf) searched objects like ["Land_Grave_V1_F","Land_Grave_V2_F","Land_Grave_V3_F"] can't work if there is no (returned) class. That's the case for these graves if they are embedded on map (not edited). And that will be the case for all null object on the map. To test that, try cursorTarget and cursorObject (w or wo type of) in debug console. cursorObject detects far more map objects. cursorTarget works on same objects if any class, or if edited: (like edited grave).

 

- on the other hand, nearestTerrainObjects will fail for these edited objects.

 

- So, [] array is OK to pick all kid of objects (terrain or not) but some differences. Terrain's ones are like on bare map, no ambient life, no units, but also not edited ones.

  • Like 1

Share this post


Link to post
Share on other sites

I'm using getModelInfo in place of typeOf to confirm existence of a particular near terrain object (in this case I'm looking for tree of type "t_ficus_big_f.p3d"):

_nearTrees = nearestTerrainObjects [player modelToWorld [0,0,30], ["TREE"], 10];
_terrainTreeFound = false;
_terrainTree = objNull;
{
    if (getModelInfo (_nearTrees select _x select 0) == "t_ficus_big_f.p3d") then 
    {
        _terrainTreeFound = true;
        _terrainTree = _x;
        //hint ["tree=%1",_tree];
    };
} foreach _nearTrees;

 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, JSD said:

I just tested,  this:

works fine for me. I teleported myself into a graveyard and it gives me a bunch of locations for graves.

 

Or probably better for you:


{ 
 if (str _x find "grave" != -1) exitWith {hint "there's a grave near"}
} forEach nearestObjects [player, [], 50]; 

Should only give the hint if there's a gravestone within 50m

 

 Man that works awesome! 

(str _x find "grave" != -1)

Can you explain the != -1   ? Thats an interesting was to  find just part of a string -gonna be useful for alot

 

Thanks

 

@JohnnyBonesJones - The only problem id have with that is what ["Type"] would i use for Gravestone?

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, froggyluv said:

 

 Man that works awesome! 


(str _x find "grave" != -1)

Can you explain the != -1   ? Thats an interesting was to  find just part of a string -gonna be useful for alot

 

Thanks

 

@JohnnyBonesJones - The only problem id have with that is what ["Type"] would i use for Gravestone?

I found that way a while back. If you use find on a string it returns the number at which the particular bit of string you're looking for starts, and if it isn't there it returns -1. So as long as it doesn't return -1 whatever you're looking for is somewhere in the string.

That's about as far as I can explain though, I'm still fairly new to all this. Glad I could help though!

  • 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

×