Jump to content

Help with msgBRA


kingsnake11

Recommended Posts

Hi. I was wondering if some of you folks more familiar with MIST than me can point out what I am doing wrong. I've been pretty good at getting a lot fo the MIST functions working but for some reason I can't get msgBRA to work. It probably is something simple.  What I have is two groups, named Bandit-1 with one unit, Igor, and a second group Hammer-1, with one unit named Snake.  What I want to do is generate a message regarding Bandit-1. The code I have tried is:

               mist.msgBRA({
                                          units = ('Bandit-1'),
                                          ref = {units = {"Igor"}},
                                         metric= false,
                                         text="BRA ",
                                         displayTime = 10,
                                         msgFor = {units = "Snake"},

                                    })

Thanks  in advance.

Link to comment
Share on other sites

I see that mist.msgBRA is requesting for 'units' parameter to be  a valid table and you are passing a group name:

 

 local mytunits = mist.makeUnitTable({'[g]Bandit-1','[g]Hammer-1'}, 'static')

 

then use it on your code:

  mist.msgBRA({
                                          units = mytunits,
                                          ref = "Igor",
                                         metric= false,
                                         text="BRA ",
                                         displayTime = 10,
                                         msgFor = {mytunits["Snake"]},

                                    })

See references:

https://wiki.hoggitworld.com/view/MIST_msgBRA

https://wiki.hoggitworld.com/view/MIST_makeUnitTable

https://wiki.hoggitworld.com/view/UnitNameTables

 

Hope it helps 🙂

 

 

Link to comment
Share on other sites

Update. Thank you Darkwood for the help...however, I think that there is something wrong with the msgBRA, either a bug, or in the description. I did get what I wanted to work, but in another way.  Adapting what you supplied, I coded this:

local mytunits = mist.makeUnitTable({'[g]Bandit-1','[g]Hammer-1'}, 'static')-- org

               mist.msgBRA({
                           units = mytunits,
                           ref = 'Igor',
                           metric= false,
                           text="BRA ",
                           displayTime = 30,
                         msgFor = {units={'Snake'}}
                            })

This worked and gave me a BRA...but it was the average info for the two units, not the BRA from Snake to Igor.  The correct answer is 343 for 142 at 58748 but what I get is 170 for 70 at 29374.  Which of course is the correct answer divided by the number of groups (2). So I tried a variant, but removing the Hammer-1 group.


local mytunits = mist.makeUnitTable({'[g]Bandit-1'}, 'static')
                  mist.msgBRA({
                           units = mytunits,
                           ref = 'Igor',
                           metric= false,
                           text="BRA ",
                           displayTime = 30,
                         msgFor = {units={'Snake'}}
                            })

This gave me the correct bearing of 343 and the correct altitude of 58748, but the distance was calculated as 0 rather than the 142.  

The method I used to get the correct bearing was using the getBRstring and messageAdd, triggered by a zone.  Here is the code:

     local  string Che = mist.getBRString({
                                           units = {"Igor"},
                                           ref = trigger.misc.getZone('test1').point,
                                           alt = true,
                                           metric = false
                                           })
 do
    local msg = {} 
    msg.text = "Bandit Position is "..Che 
    msg.displayTime = 25  
    msg.msgFor = {units={'Snake'}} 
    mist.message.add(msg)
  end 

This gave me the correct BRA from the trigger test1 as Hammer-1 (Snake) entered the zone.  I have no idea how to fix the msgBRA function or if indeed it is meant to give the average position...which seems a bit useless.   

Link to comment
Share on other sites

8 hours ago, kingsnake11 said:

local mytunits = mist.makeUnitTable({'[g]Bandit-1'}, 'static')
                  mist.msgBRA({
                           units = mytunits,
                           ref = 'Igor',
                           metric= false,
                           text="BRA ",
                           displayTime = 30,
                         msgFor = {units={'Snake'}}
                            })

This gave me the correct bearing of 343 and the correct altitude of 58748, but the distance was calculated as 0 rather than the 142. 

I think distance is 0 cause unit Igor is part of Bandit-1 group. Anyway, see this topic, maybe it gives you some solutions: 

Otherwise, if still not working, you can try to build your own function, get distance, get bearing, etc. then mix them together in a message. 

Link to comment
Share on other sites

There might be a fundamental misunderstanding of what does what. 

units = The targets you want to display where they are

ref = The reference point from which the bearing will be based on.

msgFor = who gets to see that message. 

On 11/9/2021 at 4:35 PM, kingsnake11 said:

local mytunits = mist.makeUnitTable({'[g]Bandit-1','[g]Hammer-1'}, 'static')-- org

This worked and gave me a BRA...but it was the average info for the two units, not the BRA from Snake to Igor.  The correct answer is 343 for 142 at 58748 but what I get is 170 for 70 at 29374.  Which of course is the correct answer divided by the number of groups (2). So I tried a variant, but removing the Hammer-1 group.

As you figured out it is taking the average position of the two groups and any unit within those groups. Which you correctly removed in the next try but...

On 11/9/2021 at 4:35 PM, kingsnake11 said:


         ref = 'Igor',
 This gave me the correct bearing of 343 and the correct altitude of 58748, but the distance was calculated as 0 rather than the 142.  

You are getting the BRA from igor to igor. I am not actually sure why the bearing would return as the expected value because the two points used should be identical.  You want to get the bearing from the reference (snake) to the target (igor). 

  mist.msgBRA({
    units = 'Igor',
    ref = 'Snake',
    metric= false,
    text="BRA ",
    displayTime = 30,
    msgFor = {units={'Snake'}}
  })
On 11/9/2021 at 4:35 PM, kingsnake11 said:

 I have no idea how to fix the msgBRA function or if indeed it is meant to give the average position...which seems a bit useless.   

Its the average position of the targets to be vectored to. If you add in the reference point then it is gonna throw some things off. Granted BRA for average aircraft position, especially if you did multiple groups might not be the most useful thing in the world. I think it depends more on what the AI are doing, if it is a big WW2 formation of B-17s its fine however if it is 4 different groups of fighters then the value can easily lose clarity. The averaging is mostly to make the behavior the same as the msgLL and msgMGRS functions. If you want to use a single point then pass a single unit, when there are multiple then average it out. Hope this helps. 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

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