Jump to content

Recommended Posts

Posted (edited)

Quick question: is there any script for returning clock positions strings, like the one your wingman always uses (sam launch, 1 o'clock etc.)? I can't find any, either in the ED doc or the mist doc.

BRstring works fine, but it feels unnatural for your copilot in the Huey to instantly give you exact range and heading...

 

Don't waste any time on my account, just if you could point me in the right direction I'd appreciate it very much.

 

Thanks a lot in advance

 

Edit: Here it is if it can spare anyone time:

 

unit2UnitClock = function(unit1Name, unit2Name)

local hdg1 = mist.getHeading(Unit.getByName(unit1Name))
local hdg2 = mist.utils.getDir(( mist.vec.sub(Unit.getByName(unit2Name):getPosition().p ,Unit.getByName(unit1Name):getPosition().p)), Unit.getByName(unit1Name):getPosition().p)

local clock = (hdg2-hdg1)*6/math.pi

clock = math.floor(clock + 0.5)

if clock <= 0 then clock = clock + 12 end

return clock

end

unit2UnitClockString = function(unit1Name, unit2Name, text)

local hdg1 = mist.getHeading(Unit.getByName(unit1Name))
local hdg2 = mist.utils.getDir(( mist.vec.sub(Unit.getByName(unit2Name):getPosition().p ,Unit.getByName(unit1Name):getPosition().p)), Unit.getByName(unit1Name):getPosition().p)

local clock = (hdg2-hdg1)*6/math.pi

clock = math.floor(clock + 0.5)

if clock <= 0 then clock = clock + 12 end

return (text .. clock .. " o'clock.")

end

unit2UnitClock.lua

Edited by PLP

[sIGPIC][/sIGPIC]

Posted

Just take the bearing, divide it by 30, round to the closest natural number and add 12 if the result is 0

 

sort of like this:

 

local clock = bearing / 30
clock = math.floor(clock + 0.5)
if clock == 0 then clock = 12 end

aka: Baron

[sIGPIC][/sIGPIC]

Posted

Just thought the clock reference is relative and not absolute like the bearing, so you need to account for the unit's heading. This should work:

 

local clock = (bearing + 360 - heading) / 30
clock = math.floor(clock + 0.5)
if clock > 12 then clock = clock - 12 end

aka: Baron

[sIGPIC][/sIGPIC]

Posted

Yeah, still debugging, but along the lines of:

 

Unit2UnitClock = function(unit1Name, unit2Name)
   
   --local unit1pos = Unit.getByName(unit1Name):getPosition.p
   --local unit2pos = Unit.getByName(unit2Name):getPosition.p
   
   local hdg1 = mist.getHeading(Unit.getByName(unit1Name))

   local hdg2 = mist.getDir(Unit.getByName(unit2Name):getPosition.p, Unit.getByName(unit1Name):getPosition.p)

   local clock = (hdg2-hdg1)*6*math.pi

   clock = math.floor(clock + 0.5)

   if clock == 0 then clock = 12 end
   
   return clock
   
end

[sIGPIC][/sIGPIC]

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...