Home   Help Search Login Register  

Author Topic: How to check if the ground is flat?  (Read 1676 times)

0 Members and 1 Guest are viewing this topic.

Offline Ole

  • Members
  • *
How to check if the ground is flat?
« on: 26 Sep 2010, 02:10:58 »
Hi!

I need to check if the ground is flat where a chopper can land. No bushes and trees etc..

I want an evac chopper to pick me up, and want to click on the map where i can setpos an unvisible helipad. Lets call the helipad ("HeliLand")
I know how to do this, but sometimes the chopper crashes if there are trees or other objects in that area.

Is there anyone who can write down an example on how I can check the area around the helipad ("Heliland") and see if it is safe to land.

There is a command called  "isFlatEmpty" but i could not figure out how to use it.

Thanks in advance

Offline F2kSel

  • Members
  • *
Re: How to check if the ground is flat?
« Reply #1 on: 26 Sep 2010, 02:55:30 »
I haven't done much with this myself but it does seem to work.

Code: [Select]
if ((count (getpos this isFlatEmpty [20, 0, 0.5, 10, 0, false, objNull])) > 0) then {hint "Area ok"};
If you were to put that in a gamelogic or units init it will tell you the area is ok if the gradient is less than 0.5 and it's 20meters from the nearest object.   As for the rest of the numbers you'll have to look here.  You can replace the hint part with the spawning of the heli pad.

Code: [Select]
_isFlat = (position _preview) isflatempty [
(sizeof typeof _preview) / 2, //--- Minimal distance from another object
0, //--- If 0, just check position. If >0, select new one
0.7, //--- Max gradient
(sizeof typeof _preview), //--- Gradient area
0, //--- 0 for restricted water, 2 for required water,
false, //--- True if some water can be in 25m radius
_preview //--- Ignored object
];

I'm not saying it's the correct way of doing it but it's as far as I've gotten.



Offline Ole

  • Members
  • *
Re: How to check if the ground is flat?
« Reply #2 on: 26 Sep 2010, 17:12:33 »
Just what i needed :)

Many thanks.