Jump to content
BEAKSBY

Check surface command?

Recommended Posts

HI folks,

A while back I thought I came across a series of commands that can be used to check the surface of terrain or building rooftop, does this sound familiar to anyone?

In my script I'm dropping assets into the battlefield but I don't want them to land on rooftops or trees ...etc. Is there a command I can use to check the surface type of terrain?

Thanks

Share this post


Link to post
Share on other sites

There's only one command to check for a specific terrain type which is isOnRoad. But to use that you still need some dummy object on the ground as you can't use positions for that command.

But for your question about buildings and trees, you can simply check for nearestObjects and if a house or tree is in there, redo your position finding process.

The only problem with nearestObjects is that it will not return proper objects for "terrain" objects like trees and stuff, plus it will return flies and footsteps as well, so it will return a lot more than you actually need.

Anyway, you could try this to check for houses, walls, some tree types and stones:

[color=#FF8040][color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color]
   [color=#8B3E2F][b]{[/b][/color]
       [color=#1874CD]_strX[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]str[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b];[/b][/color]
       [color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color]
           [color=#1874CD]_strX[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"house"[/color] [color=#8B3E2F][b]>[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#FF0000]0[/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color]
           [color=#8B3E2F][b]{[/b][/color][color=#1874CD]_strX[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"stone"[/color] [color=#8B3E2F][b]>[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]}[/b][/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color]
           [color=#8B3E2F][b]{[/b][/color][color=#1874CD]_strX[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"city"[/color] [color=#8B3E2F][b]>[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]}[/b][/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color]
           [color=#8B3E2F][b]{[/b][/color][color=#1874CD]_strX[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"wall"[/color] [color=#8B3E2F][b]>[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]}[/b][/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color]
           [color=#8B3E2F][b]{[/b][/color][color=#1874CD]_strX[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"nerium"[/color] [color=#8B3E2F][b]>[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]}[/b][/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color]
           [color=#8B3E2F][b]{[/b][/color][color=#1874CD]_strX[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"ficus"[/color] [color=#8B3E2F][b]>[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b]}[/b][/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color]
           [color=#8B3E2F][b]{[/b][/color][color=#1874CD]_strX[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"populus"[/color] [color=#8B3E2F][b]>[/b][/color][color=#8B3E2F][b]=[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b]}[/b][/color]
       [color=#8B3E2F][b])[/b][/color] [color=#191970][b]exitWith[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#000000]true[/color][color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
       [color=#000000]false[/color]
   [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]count[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]nearestObjects[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#1874CD]_position[/color][color=#8B3E2F][b],[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]20[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color]
   [color=#191970][b]isEqualTo[/b][/color] [color=#FF0000]1[/color]
[color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color]
[color=#8B3E2F][b]{[/b][/color]
   [color=#006400][i]//find another position[/i][/color]
[color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color][/color]

Kudos to Killzone_Kid for his SQF to BBCode Converter.

I hope that helps somehow.

Regards,

Johnny

Share this post


Link to post
Share on other sites

You can do getPos on a position, then since getPos only gets the Z value of the object under it, do getPosATL and compare (pretty much anything taller than 5m is a building)

Not sure if that'll really help or not though

Share this post


Link to post
Share on other sites

Not tested that, but according to surfaceType BIKI description, it ignores vertical coord and always check surface of the ground level, not for objects like buildings, only for the map surfaces.

If it's just about finding safe place for spawn, not too close to any object, and this way I understood, what you are asking in fact, then apart from feature built-in into createVehicle and createUnit commands, controlled by last parameter, you have to disposal also isFlatEmpty or findEmptyPosition or even somehow helpful may be selectBestPlaces, if you want to avoid objects with preliminary avoidance of whole high density areas like towns or forest. We also have surfaceIsWater to keep spawn position on the dry land.

For lazy people, there is also ready function: BIS_fnc_findSafePos. It is created around isFlatEmpty.

But to use that you still need some dummy object on the ground as you can't use positions for that command.

According to BIKI isOnRoad works also with position instead of object. Quite useful tool to avoid positions too close to roads may be nearRoads. But it checks distance from the center of road segment, not the edge, so setting distances like 10 may still lead to actual on road position, as typical road segment is bigger than 10 meters. So this one is useful, if you want keep given position not only off the actual road surface, but roughly far enough from any road.

BTW, if you spawn many units at a time, especially at init, under loading screen for better performance (as I do in Pilgrimage and HWS), better to save also positions of already spawned units to make additional distance check from each of such positions to avoid spawning one unit (vehicle) over the another.

Edited by Rydygier

Share this post


Link to post
Share on other sites

surfaceType will tell you the surface type at a position but it is not what you think it is. this command only works on the terrain model, so even giving a position of a building will just tell you what the terrain is below it.

findEmptyPosition can be used to find an empty position that do not contain any objects and can be passed an object type that it will use to make sure it finds a position it can fit in.

selectBestPlaces can be used to find areas with certain parameters, like whether it is a hill, woods, meadows, has buildings or is near the sea.

isFlatEmpty can be used to find.. well flat empty positions :/.

Heres a little snippet i use to make sure stuff im placing down is not stuck in buildings or in models like large rock faces.

fnc_checkPos = {

_pos = [ _this, 0, [ 0, 0, 0 ], [ [] ], [ 2, 3 ] ] call BIS_fnc_param;

_tracePos = +_pos;
_tracePos set [2, 25];
for "_i" from 0 to 24.75 step 0.25 do {
  	_pos set [2, _i];
  	if (!(lineIntersects [ATLToASL _tracePos, ATLToASL _pos])) exitWith {};
  };

_pos
};

Combine this with some of the commands above and you could make yourself a pretty robust position check function.

Ninja'd multiple times ;)

Share this post


Link to post
Share on other sites

Droping as on parachutes? Well there's wind too, not sure how you gonna steer unmanned parachute to selected position.

Share this post


Link to post
Share on other sites

maybe with the setVelocity and the vectorFromTo commands but not sure if this will work as the parachute will have impact on the velocity vector...

I would imagine a little loop that executes every second to correct the velocity vector using the commands above until the object hits the ground.

Edited by Lappihuan

Share this post


Link to post
Share on other sites

Ok thanks everyone,

I set the wind to 0 so parachuted assets will land predictably where they are supposed to. The video of my multiplayer game version is below. I am now creating a coop version against the AI.

http://steamcommunity.com/sharedfiles/filedetails/?id=329663824

Thanks KK for the parachute script from your blogs...very helpful stuff along with the rest of this great community!

Edited by BEAKSBY

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

×