OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: RedHouse on 22 Aug 2006, 05:14:52

Title: check for a clear 3d straight line path (need mathmatical forumla)
Post by: RedHouse on 22 Aug 2006, 05:14:52
My problem is I am not so good at maths, does anyone have a script or funciton that checks that the straight line between two points does not pass through any ground such as hills. The reason I need this formula is becuase I am working on a script so when an AI soldier knows the roughly the location of an enemy soldier but cannot see him directly he will supress that position with indirect fire.

Would apreciate any Redhouse
Title: Re: check for a clear 3d straight line path (need mathmatical forumla)
Post by: THobson on 22 Aug 2006, 08:57:55
A quick thought, and it doesn't require much maths:

Create a Game Logic at the location of one point.  Have a loop that moves it slightly towards the other point (in all three dimensions) and keep looping until it gets there.  In each loop check the height of the GL above ground if it is <= 0 then there is some earth in the way.

Will not detect buildings or trees though.  Also you would need to remember that getPos XX select 2 will give you the height above ground level.  You would need to use the heights above sea level to determine the path to be followed by the GL.  To get the height above sealevel just setPos a tigger each of the locations.  Triggers are setposed at sea level so you can then use that to work out the absolute location of each point.

I think the failure to detect buildings and trees could be a killer here though
Title: Re: check for a clear 3d straight line path (need mathmatical forumla)
Post by: h- on 22 Aug 2006, 10:22:53
Here (http://www.ofpec.com/forum/index.php?topic=23970.0) is an old topic about LOS script(s)..

May prove to be usefull..
Didn't read the whole thread just now so dunno if it ever was completed, or was some major setback discovered...
Title: Re: check for a clear 3d straight line path (need mathmatical forumla)
Post by: RedHouse on 22 Aug 2006, 16:03:30
@Thobson,
Thats the first thing that popped into my head, but I thought I'd check if someone had already done it before I atempted it myself.

@h-
Thanks that's helpful