froggyluv 2130 Posted June 2, 2017 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
JSD 18 Posted June 2, 2017 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
pierremgi 4739 Posted June 2, 2017 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
JSD 18 Posted June 2, 2017 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 1 Share this post Link to post Share on other sites
pierremgi 4739 Posted June 2, 2017 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. 1 Share this post Link to post Share on other sites
johnnyboy 3743 Posted June 2, 2017 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; 1 Share this post Link to post Share on other sites
froggyluv 2130 Posted June 2, 2017 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? 1 Share this post Link to post Share on other sites
JSD 18 Posted June 2, 2017 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! 1 Share this post Link to post Share on other sites