Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

  • 2 weeks later...
  • Replies 1.6k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Mission Scripting Tools Expanded Lua Scripting Library for mission scripting by Speed and Grimes   What is it? MIssion Scripting Tools (Mist) is a collection of Lua functions and databases that is

http://lua-users.org/wiki/TutorialDirectory and http://lua-users.org/wiki/SampleCode are pretty helpful for learning the basics of lua. https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Doc

I think it fell into the "just get it working" category of coding and was having some problem or another with it the other way around. Fast forward several years its something I'm not sure I wanna cha

Hello everyone. I could use a little assistance. I’m new to all this. I use to build in the ME but am trying my hand at using mist. I am creating a mission where I am using the radio to infinitely spawn in enemy units. I have figured out how to respawn the units using the radio when the unit is dead. What I am trying to figure out is how to spawn the units randomly on the map. Is there a way to do this?

Link to post
Share on other sites

It depends on how complicated you want to get with it. At a simple level you can use either mist.cloneInZone or mist.respawnInZone for a group and it will randomly spawn those units somewhere within a given zone. Something a bit more complicated would be to use something like mist.getGroupData, figure out a new randomized point however you want, change the coordinates for that group, then spawn it. It'd be something like this:

 

local newGroup = mist.getGroupData('whatever')
local newPoint = mist.getRandPointInCircle('whateverPoint', 'whateverRadius')

for i = 1, #newGroup.units do
    newGroup.units[i].x = newGroup.units[i].x + newPoint.x
    newGroup.units[i].y = newGroup.units[i].y + newPoint.y

end

mist.dynAdd(newGroup)

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites

Thanks Grimes that should get me pointed in the right direction. Another question I have is about using the EWRS for warbirds. I have seen it used on through the inferno and storm of war servers. I did some googling and found the code that was used for it and I copied it in and put to load after mist but it doesn't see enemy. I can use the radio command and f10 and request enemy report but it doesn't see anything. I am not sure how to make it work. if you have any insight on that it would be helpful. thanks again for replying.

Link to post
Share on other sites

So I put the respawn in zone script and it works good but the enemy units don't fly a particular route. He just spawns in and zooms off to nowhere. I kill and spawn in another and he spawns in a different location like he is supposed to but he goes off in another direction. Is there a script that will make them fly in a certain zone/area/orbit?

 

Link to post
Share on other sites

Not sure about the EWRS script, I've never used it.

 

 

The respawn/clone/teleportInZone functions are more meant for ground units with no route. If you used my example you can get their existing route data via mist.getGroupRoute(gpName, true).

 

newGroup.route = mist.getGroupRoute('whatever', true)

 

Now the important thing to keep in mind with all this is that the route data is what was assigned and setup in the editor. Coordinates of waypoints and tasks won't be shifted. The solution is to either shift them similar to what I did with each unit in the group or create a new flight plan and tasks based on what you need them to do. Which can be done either by assigning a task directly or assigning a mission task which has their flight plan and other tasking information.

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites

Hello everybody. I'm doing an online mission where I must count the death of each vehicle. I am writing a script. Part of the script was helped by Sir Grimes.

But the script does not work yet.

 

local blueUnits = mist.makeUnitTable({'[blue][vehicle]'})

for i = 1, #blueUnits do

if (Unit.getByName(blueUnits) and Unit.getByName(blueUnits):getLife()) > 0 or not Unit.getByName(blueUnits) then

trigger.action.setUserFlag('2500', true)

end

end

 

Need help please. Where I'm wrong?

Link to post
Share on other sites

I fiugred out the radar and the flight path. Now I am struggling to find a script that I can run to clean up airplanes that land or get shot up and rtb. Once they are on the ground you can't destroy them no matter how many times you shoot them. You will get the battle damage assessment saying unit was killed but it remains there and it prevents me from spawning the unit again with my radio. Is there a way to destroy or make disappear enemy AI on the runway?

 

Link to post
Share on other sites
https://wiki.hoggitworld.com/view/DCS_func_destroy would be the primary way to go about doing that. Could use an event handler to check for certain events (or just periodically check all aircraft), check if the aircraft is on the ground, and then use destroy() on it if the conditions are right.

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites
I fiugred out the radar and the flight path. Now I am struggling to find a script that I can run to clean up airplanes that land or get shot up and rtb. Once they are on the ground you can't destroy them no matter how many times you shoot them. You will get the battle damage assessment saying unit was killed but it remains there and it prevents me from spawning the unit again with my radio. Is there a way to destroy or make disappear enemy AI on the runway?

 

I am using trigger, boundary condition. First create a group with delayed activation. The group should activate on your spawn command :

mist.respawnGroup('NameOfYourGroup', true)

 

After that, you create an boundary condition trigger:

Lua predicate condition:

if Group.getByName('NameOfYourGroup') == nil then

return true

else

return false

end

 

or

 

condition: Object speed below 2 knots

 

If one of the conditions, you run scripts on respawn group.

 

As a result, you get that the group is activated at the beginning by the command of respawn, but if it is destroyed or the plane lands on the airfield and stops, then the group is reactivated again.

 

 

Link to post
Share on other sites
  • 2 weeks later...

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

I'm getting the error ':2568: attempt to call method 'isActive' (a nil value)'

Something broke after latest patch or two (incl hotfix).

Used by: https://wiki.hoggitworld.com/view/MIST_getUnitsInZones

Just me or..? Tried a re-save and to isolate the code.. Alternatives?

DCS World 2.5.x | F-14 | F/A-18C | AV-8B | AJS-37 | A10C | M-2000C | F-15C | MiG-21 | Hawk | FW190 | BF109K | Spitfire Mk. IX | P-51D | Gazelle | UH-1H | MI-8 | BS | CA | Persian Gulf | Normandy | NTTR

Win10-x64 | ASUS Strix Z270H Gaming | Intel i7-7700K | Gigabyte GeForce GTX 1080 Ti Gaming OC | Corsair Vengeance LPX 32 GB DDR4 | SSD Samsung 850 | TM Hotas Warthog | Saitek Pro Flight Pedals | Oculus Rift CV1

Link to post
Share on other sites

Hi Grimes, can you maybe assist me in what will cause this error.

 

:4941: in function 'group_alive_more_than'

[string "mist.flagFunc.group_alive_more_than { units = 'Timer', flag = 100, percent = 60, interval = 600, toggle = true, }"]:1: in main chunk

 

Using Mist ver.4_4_90

I know it is not much context.

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to post
Share on other sites

@Midnight : I didn't use this specific mist.flag function but others, and I see things strange in your code line (it looks like exemples given in mist pdf but different from explainations that are before exemples) :

I would try : mist.flagFunc.group_alive_more_than ({ groupName = 'Timer', flag = "100", percent = 60, interval = 600, toggle = true, }) (added "(" around the Vars and groupName instead of units, as units is used for unit flag functions and not group ones)

 

Edit : in fact I used the same function but "less_than" instead of "more_than" and my script looks like this :

 

mist.flagFunc.group_alive_less_than ({

groupName = 'Red Target Group',

flag = "2",

percent = 99,

})

 

if trigger.misc.getUserFlag("2") > 0 then

(whatever the actions wanted)

end

 

  • Like 1
Link to post
Share on other sites
Can't reproduce on my end. Can you attach a miz that generates the error? Would be extremely helpful.

 

Found it, somehow adding a 'invisible farp' makes the function stop working. I have no idea how.. I've attached a cleaned version of my mission.

Start, choose random slot, within a couple of seconds the script runs as a AI enters the zone and I only get the "TRIGGER" text.

Remove the 'Invisible farp' (near Kutaisi) and re-run, now it should work.

?

TEST.miz

DCS World 2.5.x | F-14 | F/A-18C | AV-8B | AJS-37 | A10C | M-2000C | F-15C | MiG-21 | Hawk | FW190 | BF109K | Spitfire Mk. IX | P-51D | Gazelle | UH-1H | MI-8 | BS | CA | Persian Gulf | Normandy | NTTR

Win10-x64 | ASUS Strix Z270H Gaming | Intel i7-7700K | Gigabyte GeForce GTX 1080 Ti Gaming OC | Corsair Vengeance LPX 32 GB DDR4 | SSD Samsung 850 | TM Hotas Warthog | Saitek Pro Flight Pedals | Oculus Rift CV1

Link to post
Share on other sites

There are two issues. The first is that for some reason the invisible farp is registered as a unit and not a static object. The second issue is that the unitsInZones function doesn't handle static objects correctly. This is mostly due to it not knowing the category of different objects and an extra check I had done to prevent late activated units from being checked.

 

I'll fix it soon.

  • Like 1

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites

Just a quick question if you don't mind. Functions such as "mist.teleportInZone" etc. don't work with WW2 units, meaning those units can't be teleported, moved or commanded by Mist. Any idea why that is?

The DCS Mi-8MTV2. The best aviational BBW experience you could ever dream of.

Link to post
Share on other sites

Well its not by design on my part thats for sure. Respawn and clone appear to be ok, but teleport isn't. Guessing there is something different about the WW2 units preventing it from working because if I switch to modern units it'll execute as expected. Its a game bug then, will report.

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites

And oh yeah, found out that cloneInZone works as well, so I'm good! And using it instead of teleporting actually adds some much-needed "world" activity, because I can use the DCS ME to plonk down reserve / off-duty units puttering about in the rear and then just clone them as needed. Spiffy extremo!

The DCS Mi-8MTV2. The best aviational BBW experience you could ever dream of.

Link to post
Share on other sites

Fixed the issue with that error message occurring with 4.5.95.

 

-Added support for static objects in makeUnitTable function. It still returns a list of all objects in a single table, so be careful and know that it WILL return static objects.

-Added optional value to mist.makeUnitTable to exclude categories of objects. Can be used to filter out statics or any other type. Input is a string or a table of strings.

-Added/fixed getUnitsInZones, getUnitsInPolygon, getUnitsInMovingZones, and getUnitsLOS to support static objects. Change was made due to farp objects returning via Unit.getByName() and not checking for object category.

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites

I'm probably missing something basic but I can't get 4.5.95 to load. "attempt to index global 'mist'" no matter when I load. What am I missing?

Simple test included (should display unit heading 2 sec after start) and works with 4.4.90.

TEST.miz

DCS World 2.5.x | F-14 | F/A-18C | AV-8B | AJS-37 | A10C | M-2000C | F-15C | MiG-21 | Hawk | FW190 | BF109K | Spitfire Mk. IX | P-51D | Gazelle | UH-1H | MI-8 | BS | CA | Persian Gulf | Normandy | NTTR

Win10-x64 | ASUS Strix Z270H Gaming | Intel i7-7700K | Gigabyte GeForce GTX 1080 Ti Gaming OC | Corsair Vengeance LPX 32 GB DDR4 | SSD Samsung 850 | TM Hotas Warthog | Saitek Pro Flight Pedals | Oculus Rift CV1

Link to post
Share on other sites
I'm probably missing something basic but I can't get 4.5.95 to load. "attempt to index global 'mist'" no matter when I load. What am I missing?

Simple test included (should display unit heading 2 sec after start) and works with 4.4.90.

 

That was entirely my mistake. I pushed a change that had a few syntax errors in it. Realized it the next day, fixed those errors, recommitted the changes, but forgot to push those changes to github. So they were just sitting fixed locally with me thinking the problem was resolved. Redownload it on the github page and use that version, should fix it for you.

  • Like 1

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

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites

Ah I see :) shit happens, thanks for the quick fix!

DCS World 2.5.x | F-14 | F/A-18C | AV-8B | AJS-37 | A10C | M-2000C | F-15C | MiG-21 | Hawk | FW190 | BF109K | Spitfire Mk. IX | P-51D | Gazelle | UH-1H | MI-8 | BS | CA | Persian Gulf | Normandy | NTTR

Win10-x64 | ASUS Strix Z270H Gaming | Intel i7-7700K | Gigabyte GeForce GTX 1080 Ti Gaming OC | Corsair Vengeance LPX 32 GB DDR4 | SSD Samsung 850 | TM Hotas Warthog | Saitek Pro Flight Pedals | Oculus Rift CV1

Link to post
Share on other sites
  • 4 weeks later...

I'm using mist.cloneGroup to clone ground units, to whom I've applied  a custom skin. They are spawning with the default skin, which does not fit the mission I'm building. Does anyone know a work around?
The mission originally had them using the default skins, so I've tried creating copies of the groups in the ME, then deleting the originals, then renaming their replacements to the same naming conventions, but to no avail. I also tried making a new test .miz, and same results.

Link to post
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...