Jump to content
Sign in to follow this  
AngusHeaf

Global elevation and fixed mortars

Recommended Posts

How would I calculate the global elevation of an object? GetPos doesn't work, obviously.

I've searched the ol' forums and found a whopping ONE topic covering how to find the true elevation of something and wanted to know if there's been any progress on things since. All I want to do is take two objects and find the difference in height between the two.

And I'm really bummed because finally someone released a nice fixed mortar that was turning out to be actually useful for indirect fire, but my efforts to script a system for putting aiming stakes on the ground has hit the wall because I can't get the height of the mortar and the height of the stakes on the ground. GetPos doesn't do it since it only returns the height above the ground (how useful is that, really now).

Anyways, so the thing I was working on (if anyone cares) is added aiming stakes to UpMinder's recently released mortar. Because he went so far as the actually create a crosshair for his mortar that has ranges on it (from 250-800m) it is possible to precisely fire your shots a specific distance. But because of the way his mortar aims the distances marked in the crosshair are relative to the horizon. This means if you're aiming at something below the mortar (that you can see) you might thing that because it is 400m away you would put the 400m line in the crosshair on the target and fine. Sadly this just means that you've actually lowered the barrel too much and have fired way too far.

To fix this I decided to do what they do in real life, which is use aiming stakes. Basically I took the red/white poles from OFP and set them 5m away from the mortar in a couple places (left and right of center). Lowered the poles so the top edge was exactly level with the mortar crosshair. Now you can position yourself behind an object and indirect fire accurately if you know the range and direction (easy to find with calculator). Fantastic. Except that I thought getPos would take the true Z height of an object (the mortar) and set the poles with the same height as their own. Btw I mean Z as in global height. I'm stumped why anyone would call Z distance north to south.

So, sadly my aiming stakes only work when the stakes and the mortar are at the same elevation. Pretty useless since the terrain in all the islands is pretty hilly. Can anyone think of a way around this elevation issue? Someone posted about using setpos and triggers but it seemed like you just end up taking the height of the trigger above ground (zero, presumably) and subjecting it from the height above ground of an object (zero again) and ending with zero.

Apologies if I come off as pissy. It's New Years and I've had some spirits, plus I really wanted this to work. Bah!!

HAPPY NEW YEARS !!!   biggrin.gif

Share this post


Link to post
Share on other sites

Try this...(a trigger's position is [x,y], just like a marker's, not [x,y,z] so of course that doesn't work smile.gif )

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_level = "heliHempty" createVehicle getPos mortar

_xDelta = (getpos aimStick select 0) - (getpos mortar select 0)

_yDelta = (getpos aimStick select 1) - (getpos mortar select 1)

_level setPos [(getPos mortar select 0) + _xDelta, (getPos mortar select 1) + _yDelta, getPos mortar select 2]

;zDelta is the difference in height...(i.e. if the stick is lower, zDelta will be negative...)

zDelta = (getPos aimStick select 2) - (getpos _level select 2)

<span id='postcolor'>

I dunno if it'll work, but it's worth a try...(if it doesn't then I'm not sure that it's possible to get the global z...)

Share this post


Link to post
Share on other sites

That solution won't work, as a HeliH is an object and is set to 0 AGL.

Here's a few ways:

A. If you have control over the mission design, use a trigger. A named trigger can be setpos, and if you use X,Y, the Z will express sea level as a function of AGL. (e.g., at 145m ASL, the trigger will have a Z value of -145).

If you don't have control over mission design (e.g., let's say you wanted to make those aiming stakes scripted organically from the mortar mod via eventhandlers), there are two ways to do it:

B. camcreate a logic out to sea (like at 0,0,0), i.e. where ASL and AGL are the same, and use trig to figure out the height ASL. The problem here is that the ranges are such that you won't get a very accurate reading with OFP's floats.

C. Camcreate a logic at the location, measure the (3-d) distance, use trig to get the 2-d distance and Z component, then one more distance measurement to get the +/-

For the directional mines in CoCMines, I used C (since I figured you could tilt a claymore a bit, and in fact elevation is set by terrain at 50m). In fact, there's a function in the CoCMines/scripts directory called elevation.sqf . It requires a gamelogic called CoCMinesWidget, and a semaphore CoCMinesWidgetLock. IIRC, you can read the information by:

CoCMinesWidget = "Logic" Camcreate [0,0,0]

CoCMinesWidgetLock = false

...

#clearsemaphore

?!CoCMinesWidgetLock:CoCMinesWidgetLock = true; goto "getelevation"

~.0001

goto "ClearSemaphore"

#getelevation

degrees = [object, direction, range] call loadfile "\CoC_Mines\scripts\elevation.sqf"

CoCMinesWidgetLock = false

be sure and double check all this against the docs in CoC_mines. Or you can just write your own.

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
Sign in to follow this  

×