Altitude AGL

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
User avatar
TitaniumTrout
Posts: 472
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

Altitude AGL

Post by TitaniumTrout »

I'm trying to determine the altitude of a unit above ground level. The unit.altitude gives me the altitude from sea level. I'm at a loss on how to query the altitude at the units location and subtract it, or to define altitude.agl or some such.

I'm finding the unit info using ScenEdit_UnitX().
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Altitude AGL

Post by michaelm75au »

You could use World_GetElevation() to get the elevation (in meters) of the unit's position.

local unit = ScenEdit_UnitX()
local grdlevel = World_GetElevation({latitude=unit.latitude,longitude=unit.longitude})
Michael
User avatar
TitaniumTrout
Posts: 472
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Altitude AGL

Post by TitaniumTrout »

Beautiful! Thank you!
User avatar
TitaniumTrout
Posts: 472
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Altitude AGL

Post by TitaniumTrout »

It seems weapons detonate at flight level, or at least cruise missiles do.

Image

I tried referencing unit.weapon.detonated but found it to be erratic. Most of the time it did not match the status of the detonated weapon.

If anyone has an idea on how to track if a weapon was intercepted or struck target please let me know.
Post Reply

Return to “Lua Legion”