Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

SO while the screenshot does make me giggle, is there something I am missing in my code to prevent this for spawning a group? :doh:

 

Yeah, stop recruiting soldiers with Jedi training :lol:

Link to comment
Share on other sites

You can't create a zone that would be recognized with the trigger.misc.getZone() function. You can create a variable that is scripting only which could be referenced within the script in the same way as St3v3f described...

 

local myZone = {

point = Vec3,

radius = Distance

}

 

local unitPos = Unit.getByName('unit1'):getPosition().p

 

 

if math.sqrt(((myZone.point.x + unitPos.x)^2) + ((myZone.point.z + unitPos.z)^2)) < myZone.radius then

print('Unit is inside the zone')

end

 

 

BBQ, you can use it however you want to as long as Mist is loaded before the first script that requires Mist is ran. Typically I use either mission start or initialize to start Mist.

 

Maybe Joyride wants to use a triggerzone created in a script for script functions that use names of triggerzones as an argument. I would certainly see the use if Mist functions could accept "raw" data for triggerzones as well as names

aka: Baron

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

:thumbup:

 

Thanks to Grimes for getting me sorted with LUA, I should have a nice little script to share by the end of the week!

 

Specifically aimed towards UH-1H Huey pilots and mission designers.

 

:pilotfly:

 

I've been working on a script for my mission, Asset Extraction, so that I can add the Huey as a user controlled aircraft and have it replace the existing UH-60 Blackhawks for the actual extraction part of the mission.

 

Here's a little demonstration of how far I've gotten using Lua, addGroup and MIST.

 

 

The two CSAR infantry units that spawn "from" the Blackhawk are completely dynamic based on the position of the helicopter, they dynamically figure out a path from that point to the asset, do the obligatory mission pause for [insert time here] and then dynamically figure out a path back to the helicopter before moving back for extraction.

 

Oh, and they can tell what helicopter is the current "rescue helicopter" (meaning first helicopter to touch down in their extraction zone) and navigate to it... if there are any. If no helicopters exist in the extraction zone (if, for example, you decided to take off and keep an eye on the surroundings from a nice high vantage point) they will report that their mission has been completed and they are waiting for you to land nearby so that they can hitch a ride.

 

Pretty neat stuff, I think!

 

:music_whistling:

 

Once I've tested it a bit more and worked out any bugs I might find, I'll post the Lua code to paste bin and link it here so that anyone who is interested can use it. My first foray into Lua programming so I'll have to apologize if the code is messy or not as concise as a veteran might be able to accomplish.

 

I'm shooting to have this ready for release by the end of the week or early next week as well as an updated version of my DCS: World mission (which will once again support all DCS modules except Combined Arms).

 

:joystick:

Wow! Nice! I'm a DCS noob who just started on mission designing, and this sounds exactly like something I need. I want to be able to block a convoy of cars by landing in front of them and arresting a guy in one of the cars.

Link to comment
Share on other sites

Maybe Joyride wants to use a triggerzone created in a script for script functions that use names of triggerzones as an argument. I would certainly see the use if Mist functions could accept "raw" data for triggerzones as well as names

 

In many respects such a function already exists within Mist, although not explicitly. Most, if not all, of the functions that accept trigger zones convert the data for a more common "scripting" function to use it. For example the function mist.groupToRandomZone() accepts zone names but it converts the zone data for use within mist.groupToRandomPoint() which does all of the actual work.

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

Is there any issue with mist.DBs.zonesByName ?

 

I am sure that there are several trigger zones into my mission, I can get them thanks to

trigger.misc.getZone('RescueZone')

but

 

env.info("Zones nb: "..table.getn(mist.DBs.zonesByName))

provides 0 zone !?!!

 

Am I doing something wrong ?

 

I tried both v1.1 and v2.0, same result....

 

EDIT:

 

If I try with

env.info("Zones nb: "..table.getn(mist.DBs.zonesByNum))

I get the right number.... ;)


Edited by galevsky06
Link to comment
Share on other sites

The zones are indexed by name in mist.DBs.zonesByName. They are indexed by an arbitrary number value in mist.DBs.zonesByNum.

 

For example,

mist.DBs.zonesByName['RescueZone']

will be the zone you called "RescueZone".

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Link to comment
Share on other sites

After 4,5hrs testing and swearing I got few pieces of scripts together I found here in the forum and in the MIST guide and finally have it somewhat working as supposed to, but only somewhat. It is a script which shall trigger a defined infanty group to move to my heli and simulate a boarding.

 

My question is how do I get the "function main()" to be repeated after the script was initialized by a flag? No I have to initialize the script manually several times to get the small steps done. This is the script:

 

--create F10 options for flag 902 to request to pick up troops
--script should be called by scwitched condition / flag 902, which is initialized by F-10 menu
--create a group with the name "pickup" and the first unit name "pickup"
--create a heli with unit name "test"

local inf               = Unit.getByName('pickup') --unit name of 1ste unit of pickup group
local infgroup            = Group.getByName('pickup') --groupname of troops to be pickedup
local heli                 = Unit.getByName('test') --unit name of transport heli
local heligroup         = Group.getByName('test') --group name of transport heli

mist.flagFunc.units_in_moving_zones 
{
       units           = {"pickup"}, 
       zone_units      = {"test"},
       radius          = 200,--distance to call infantry
       flag            = 903,
       stopflag        = 4
}

local helipos = heli:getPosition().p
local heliagl = helipos.y - land.getHeight({x = helipos.x, y = helipos.z}) - 1.5
local helivel = heli:getVelocity()
local abshelivel = math.abs(helivel.x) + math.abs(helivel.y) + math.abs(helivel.z)

function main()
if (trigger.misc.getUserFlag(902) > 0 and trigger.misc.getUserFlag(903) > 0)
           then
               
               if (abshelivel > 1)  
                   then 
                   trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Slow down"), 10) 
                   end

                   if (heliagl > 1)  
                       then 
                       trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Get lower"), 10) 
                       end
                       
                           if (heliagl <= 1 and abshelivel <= 1) 
                               then 
                               trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Troops are embarking, hold position!"), 10)
                               trigger.action.setUserFlag('904', true) --Flag 1004 indicates troops can embark
                               local getin = 
                                           {
                                           group = Group.getByName('pickup'),
                                           point = {y = helipos.y, x = helipos.x, z = helipos.z},
                                           radius = 1,
                                           form = "Diamond",
                                           speed = 10,
                                           disableRoads = 1
                                           }
                               mist.groupToRandomPoint(getin)
                               mist.flagFunc.units_in_moving_zones --creating zone to trigger that troops embarked
                                           {
                                           units           = {"test"}, 
                                           zone_units      = {"pickup"},
                                           radius          = 20, --distance at which infanty embark
                                           flag            = 905,
                                           stopflag        = 906,
                                           req_num            = 1
                                           }
                           end
           else
           trigger.action.outTextForGroup(Group.getID(heligroup), string.format("You are too far away from LZ!"), 10)
           trigger.action.setUserFlag('902', false) --initial trigger set false again
end


if (trigger.misc.getUserFlag(904) > 0 and trigger.misc.getUserFlag(905) > 0)
           then
               infgroup:destroy()
               trigger.action.setUserFlag('906', true) --Flag 1006 indicates troops are on board
               trigger.action.outTextForGroup(Group.getID(heligroup), string.format("All troops on board!"), 10)
               mist.removeFunction(funcID)
           end
end
local funcID = mist.scheduleFunction(main, {}, timer.getTime() + 5, 1200)

 

I tried the MIST scheduleFunction as you see, but it doesn´t repeat the check of the IF loops, so I have to initialize the script manually, to get the infantry moving and finally after several calls, to get the check done, to destroy them in case they are close to the heli, to simulate them boarding.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Hi,

 

is there any way to get the route of a group that has changed by a Groundcommander?

The function "getRoute" return the ME Route but not a altered one.

 

Thanks for your help.

 

cu...

 

No, that data is not available to the mission scripting environment.

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Link to comment
Share on other sites

First of all, thanks for SCT and MIST! Unlike a lot of fancy things I've tried to do with various mission editors, these worked perfectly the first time I tried them.

 

I'm using them to build some simple missions now where there is a fair bit of random variability, e.g. a patrol mission where you don't know exactly what you will encounter or where.

 

I found it useful to add a 'disableRoads' parameter to mist.groupToRandomZone, which it can then pass along to the groupToRandomPoint function that it eventually calls. It was easy enough for me to add that myself, but thought it might make a good addition to the official code.

Link to comment
Share on other sites

How will I edit this script to allow for all Blue Coalition aircraft or Blue Pilots in mission please?

 

customEventHandler = {};

 

function customEventHandler:onEvent(event)

if (world.event.S_EVENT_EJECTION == event.id) then

_ejectloc = event.initiator:getPoint();

DPcallsign = Unit.getName(event.initiator)

_ejecttime = timer.getTime();

 

if DPcallsign == 'Blue Pilot #1' then trigger.action.setUserFlag("20", true) end

 

end

end;

 

world.addEventHandler(customEventHandler)

 

I tried some combinations with {} and , only to get some errors.

 

Thx

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

Nope..ok lets try this... hehe

 

What will this script look like if I want to add more pilots? Not working...

 

mist.flagFunc.units_LOS{

unitset1 = {'119'},

altoffset1 = 2,

unitset2 = {'Player'}, I used this: {'Player' ,'Player2' ,'Player3'}

altoffset2 = 0,

flag = 30,

stopflag = 40,

radius = 3000

}

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

How do I use mist.getLLString, mist.getMGRSString and mist.getBRString to work? I'm trying to get the coordinates for a group but I can't figure out how. Any working examples? Thanks for a great library!

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

How do I use mist.getLLString, mist.getMGRSString and mist.getBRString to work? I'm trying to get the coordinates for a group but I can't figure out how. Any working examples? Thanks for a great library!

 

Not tested, but this should do:

 

mist.getMGRSString{

units = {'Unit1', 'Unit2'},

acc = 3

}

 

mist.getLLString{

units = {'Unit1', 'Unit2'},

acc = 3

}

 

mist.getBRString{

units = {'Unit1', 'Unit2'},

ref = coalition.getMainRefPoint(coalition.side.RED),

alt = 15000,

}


Edited by St3v3f
  • Like 1

aka: Baron

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Thanks that solved it! Only problem is LL doesn't seem to work properly, as the longitude isn't correct :( The other do work perfectly!

 

Also, the messaging system seems to stop working for me whenever I insert my script into a Mission Generator-based mission. Works flawlessly when I make the mission myself :huh:

 

Anyway, thanks again for this huge contribution to the community!

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

Well, the longitude was stuck at E300000 for both DMS and DDM... It might very well be that I have made a mistake with the coordinates, like shifting the Y and Z axis, but MGRS and BRA is working for some reason...?

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

  • ED Team

Ok, this Mist stuff is good at making me feel dumb :)

 

Here is my code, trying to make a random explosion in a zone I set in the ME:

 

local pos = trigger.misc.getZone('Zone1')
local newpoint = mist.getRandPointInCircle(Vec3, 5000)
local Vec3 = {
x = 1,
y = land.getHeight(1),
z = 1
}
trigger.action.explosion(Vec3, 2000)

 

Here is the error... tried a bunch of things, bt mostly I just break other things :doh:

error.png.d5bb3e5768e0a5d202e298d194281aa3.png

64Sig.png
Forum RulesMy YouTube • My Discord - NineLine#0440• **How to Report a Bug**

1146563203_makefg(6).png.82dab0a01be3a361522f3fff75916ba4.png  80141746_makefg(1).png.6fa028f2fe35222644e87c786da1fabb.png  28661714_makefg(2).png.b3816386a8f83b0cceab6cb43ae2477e.png  389390805_makefg(3).png.bca83a238dd2aaf235ea3ce2873b55bc.png  216757889_makefg(4).png.35cb826069cdae5c1a164a94deaff377.png  1359338181_makefg(5).png.e6135dea01fa097e5d841ee5fb3c2dc5.png

Link to comment
Share on other sites

  • ED Team

Well got that error to go away by changing some stuff...

 

local pos = trigger.misc.getZone{'Zone1'}

local newpoint = mist.getRandPointInCircle{pos.point, pos.radius}

local vec3 = {
x = newpoint.1000,
y = land.getHeight(newpoint),
z = newpoint.1000
}

trigger.action.explosion{vec3, 2000}

Of course I have a new one something about, expecting a close on line 5 near 1000.... me thinks I need to load the Lua manual to the iPad :)

error2.png.65b7604d56e72dd02106e145107acd43.png


Edited by NineLine

64Sig.png
Forum RulesMy YouTube • My Discord - NineLine#0440• **How to Report a Bug**

1146563203_makefg(6).png.82dab0a01be3a361522f3fff75916ba4.png  80141746_makefg(1).png.6fa028f2fe35222644e87c786da1fabb.png  28661714_makefg(2).png.b3816386a8f83b0cceab6cb43ae2477e.png  389390805_makefg(3).png.bca83a238dd2aaf235ea3ce2873b55bc.png  216757889_makefg(4).png.35cb826069cdae5c1a164a94deaff377.png  1359338181_makefg(5).png.e6135dea01fa097e5d841ee5fb3c2dc5.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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