Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

My mission using mist.teleportinzone was working flawlessly a few months ago, but now the units are not teleported and I get an error in the log with MIST : south_ossetia is not a country 

 

any idea ? The units are south Ossetian tanks

 

2020-12-20 22:09:28.327 ERROR   SCRIPTING: MIST|1407: Country not found: usaf_aggressors
2020-12-20 22:09:28.328 ERROR   SCRIPTING: MIST|1407: Country not found: south_ossetia

 

 

If I use Russian units it works....


Edited by inconnudiscret
Link to comment
Share on other sites

On 12/20/2020 at 2:52 AM, Wrench said:

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.

 

mist.cloneGroup doesn't have a "livery_id" field in variables. It is only available if you use mist.dynAdd, so the only workaround I can see is to use this function to "spawn" the new groups instead of cloning 1 group.

Link to comment
Share on other sites

17 hours ago, inconnudiscret said:

My mission using mist.teleportinzone was working flawlessly a few months ago, but now the units are not teleported and I get an error in the log with MIST : south_ossetia is not a country 

 

any idea ? The units are south Ossetian tanks

 

2020-12-20 22:09:28.327 ERROR   SCRIPTING: MIST|1407: Country not found: usaf_aggressors
2020-12-20 22:09:28.328 ERROR   SCRIPTING: MIST|1407: Country not found: south_ossetia

 

 

If I use Russian units it works....

 

 

No idea... except a new tool to change coalitions after a mission is created has been introduced, maybe it's related to ? If you want to post your mission it can be looked at ?

Link to comment
Share on other sites

1 hour ago, toutenglisse said:

 

No idea... except a new tool to change coalitions after a mission is created has been introduced, maybe it's related to ? If you want to post your mission it can be looked at ?


Here's the mission file. I have no idea honnestly... Thanks for the hard work and the help

 

https://drive.google.com/drive/folders/15fxIv5qU51MG8SgcbSp9qViW3s1qOZFC?usp=sharing

Link to comment
Share on other sites

5 hours ago, inconnudiscret said:


Here's the mission file. I have no idea honnestly... Thanks for the hard work and the help

 

https://drive.google.com/drive/folders/15fxIv5qU51MG8SgcbSp9qViW3s1qOZFC?usp=sharing

 

Sorry I can't take a quick look for now as mods are required to open the mission. ( PS I'm just a DCS & MIST user 🌝 )

 

Edit : maybe something you can try : change south_ossetia where it is used in your trigger/script by 'SOUTH_OSETIA' which should be the right spelling for script engine (same for usaf_aggressors it should be 'AGGRESSORS')


Edited by toutenglisse
Link to comment
Share on other sites

  • 2 weeks later...

Is there anyway to refresh the MIST database? Not sure thats even a relevant question though, see below.

 

I'm using both MOOSE and MIST in a campaign I'm working on and I have  sets of tanks that are spawning using MOOSE and some times units will get stuck together and then the whole group will not move as these units spin around each other. I devised a fix for this using MIST teleport  and then MIST groupToPoint :

local vars = {} 
  vars.gpName = 'Nellis2Mesquite Blue Tanks 1#001'
  vars.action = 'teleport' 
  vars.point = mist.getLeadPos('Nellis2Mesquite Blue Tanks 1#001')
  vars.radius = 25 
  vars.disperse = 'disp' 
  vars.maxDisp = 100
  mist.teleportToPoint(vars) 

mist.groupToPoint( "Nellis2Mesquite Blue Tanks 1#001", "Mesquite Defense Zone", "On Road", 360, 50, 0 )

 

Works nicely to separate the stuck units and restart them on their path. Works nicely once the campaign has been restarted that is. What I mean by that is I'm using Simple Group Saving by Pikey to continue the campaign and the code above works nicely on units that are alive before restart. Where I run into problems is on units that are recently spawned and then I get an error with the code above "Nellis2Mesquite Blue Tanks 1#001 not found in MIST database" pointing specifically at the mist.teleportToPoint line. Thing is mist.groupToPoint has no problems if I run it alone or before the teleport but obviously that's not going to work.

Link to comment
Share on other sites

  • 4 weeks later...

Hi everyone!

 

I apologise if this has already been answered already (which it probably has), but there are just so many posts here that I can't find the answer I'm looking for. I have no experience with scripting, and all I've done so far is use methods I've seen explained on YouTube videos.

 

I'm trying to work out how to get ground units to endlessly respawn for a training mission. I've managed to do this with air units using MIST, and using DO SCRIPT with this script that I saw someone use on YouTube on a repetitive trigger:

 

 if not Group.getByName('MiG1') then
   mist.respawnGroup('MiG1', true)
 end

 

Now I'm assuming that the first line checks to see if the named group exists, and if it doesn't then the second line spawns the group back in. Is this right? (Remember I know NOTHING about scripting.)

 

Anyway, this works fine in the air. Shoot down the plane, and when it hits the ground a new one spawns. Perfect. Now I've tried testing the same concept (without any modifications except for the group names) on trucks on the ground. The trucks are set up to just sit there, not follow a route. When I destroy the trucks though I just get left with the burning wreckage, and nothing new spawns in. Is it because the wreckage occupies the spawn location?

 

Has anyone got time to explain why this is happening, and how I can fix it? The eventual purpose is to endlessly respawn SAM sites for friends to practice use of HARMs, Sidearms and other weapons on SEAD missions.

 

Thanks for reading.

Link to comment
Share on other sites

Just checking Group.getByName() is a very simple test to see whether something is returned. For a while any group that was dead failed to return, but at somepoint that was changed. So it is best to check for other values. I like to use something like this.

 

if (Group.getByName('whatever') and Group.getByName('whatever'):getSize() == 0) or not Group.getByName('whatever') then
  -- do code
end

Basically if the group object is returned, but it has no units alive or the group object isn't returned then respawn the group or whatever else you want to do. I also do this check which also covers the bases. 

 

	local function groupIsDead(groupName) -- a certain bug hasnt been fixed, so I have to use this instead. 
		if (Group.getByName(groupName) and ( Group.getByName(groupName):isExist() == false or #Group.getByName(groupName):getUnits() < 1)) or not Group.getByName(groupName) then
			return true
		end
		return false
	end

Difference being it checks isExist() or can fall back to checking the size of the getUnits() table. 


Edited by Grimes

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

Thank you Grimes! Wow, that looks complicated, but I think I kind of understand the basic gist of it. I'm just on my way to bed now but I'll give it a go tomorrow afternoon as soon as I get a chance.

 

Can you recommend a good book or resource for me to try with a view to learning how to do all this stuff myself? The last time I did anything even remotely connected with programming was using Basic or Logo when I was about 10 years old, nearly 40 years ago and on an Apple IIe. There seem to be so many different scripting languages(?)/formats, and without any background in this stuff I can't even work out what I need to learn, let alone how. LOL

 

(Actually, I tell a lie. I did have to do a computing module when I started at university, and I still have nightmares about it. We were plonked in front of a computer, and just told to write a program that would take temperature readings from an attached probe and graph them on the screen, using C++. Most of us hadn't even heard of C++. No instruction, no guidance. This was on day 1. Needless to say, I and many others failed that module.)

Link to comment
Share on other sites

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_Documentation is more specific to DCS but a lot of the principles remain the same. 

  • Thanks 2

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

Ive loaded a FARP initiated after a vehicle enters a zone using  mist.dynAddStatic(vars). The FARP loads ok but I cannot communicate with it. Is there a way I can make it so that I can rearm and refuel at this new farp?

local vars = 
{
 type = 'FARP', 
 country = 'UK', 
 category = 'Heliports', 
 x = -279221.99287927, 
 y = 22610.496047639,
 name = 'FOB', 
 heading = 4.7822021504645,
 clone = true,
 dead =false,
 }
 
 mist.dynAddStatic(vars)

 

Thanks in advance

Link to comment
Share on other sites

1 hour ago, Iceviper said:

Ive loaded a FARP initiated after a vehicle enters a zone using  mist.dynAddStatic(vars). The FARP loads ok but I cannot communicate with it. Is there a way I can make it so that I can rearm and refuel at this new farp?


local vars = 
{
 type = 'FARP', 
 country = 'UK', 
 category = 'Heliports', 
 x = -279221.99287927, 
 y = 22610.496047639,
 name = 'FOB', 
 heading = 4.7822021504645,
 clone = true,
 dead =false,
 }
 
 mist.dynAddStatic(vars)

 

Thanks in advance

Forget my last. I had failed to load in a cp, ammo dump and fuel depot to make it a working FARP. Now Working. Thanks

 

local vars = 
{
 type = 'FARP', 
 country = 'USA', 
 category = 'Heliports', 
 x = -279221.99287927, 
 y = 22610.496047639,
 name = 'FOB', 
 heading = 4.7822021504645,
 clone = true,
 dead =false,
 }
 
 mist.dynAddStatic(vars)
 
 local vars2 = 
{
 type = 'FARP Ammo Dump Coating', 
 country = 'USA', 
 category = 'Fortifications', 
 x = -279096.38525582, 
 y = 22460.881098381,
 name = 'AD2', 
 heading = 4.7822021504645,
 clone = true,
 dead =false,
 }
 
 mist.dynAddStatic(vars2)
 
 local vars3 = 
{
 type = 'FARP Fuel Depot', 
 country = 'USA', 
 category = 'Fortifications', 
 x = -279086.42310297, 
 y = 22471.042494287,
 name = 'FD2', 
 heading = 4.7822021504645,
 clone = true,
 dead =false,
 }
 
 mist.dynAddStatic(vars3)
 
  local vars4 = 
{
 type = 'FARP CP Blindage', 
 country = 'USA', 
 category = 'Fortifications', 
 x = -278894.86029389, 
 y = 22665.08068319,
 name = 'CP2', 
 heading = 4.7822021504645,
 clone = true,
 dead =false,
 }
 
 mist.dynAddStatic(vars4)

 

Link to comment
Share on other sites

If a route was assigned via mist.goRoute or defined when spawning the group via mist.dynAdd it would be possible to save it and then look up for later use. Unfortunately there is no function to get a route that was assigned by another script or CA. Also cannot get any information about or from targeting pods. The best alternative for recon would be to use mark panels, track where smoke rockets land, or do something with custom F10 menues. 

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

I explored a F10 item way to use TGP coordinates and managed to do something working "pretty" well.

Player locate a target with TGP, transmit/enter coordinates-elevation through F10 menu (from root by unbuilding menu and adding a selection of 10 numbers 0 to 9) by selecting 16 numbers in a row. (a message displays coordinates growing during process)

A screen message finally displays coordinates entered (N XX°XX'XX%' E XX°XX'XX%' ELEV XXXX feet) and asks for validation or cancellation.

The Vec3 point obtained is maybe not close enough for an AI Gps bomb (actually I use it to spawn a smoke that is some meters away from target) but good enough for artillery strike or AI Gps cluster glide bomb if target is soft enough (I think TGP can't display better accuracy than degree/minute/hundredth minute).

🙂 thanks for the F10 menu idea.

Test-coord.jpg


Edited by toutenglisse
Link to comment
Share on other sites

  • 2 weeks later...

Grimes answered me in discord, thank you for the quick reply

Quote


Grimes
that 120 is a delay for when the task is given to the AI. Which doesn't really work with AI aircraft because they effectively have no task and RTB immediately. Change it to true
if you do it on a ground group for example they would just sit stationary for 2 minutes and then they'd get their route and follow it.

 


 

I have two questions, just started using MIST:

i'm trying to make infinite spawning planes but the group when it responds immediately dives to minimal altitude, speed brake out, high AOA.

2nd, i'm trying to add a delay from death till the next group spawns and that doesn't seem to be firing correctly either.  The script is generating the 2-10 groups as expected:

if not Group.getByName('backup2') then
   mist.respawnGroup('backup2', 120)
end
it just doesn't seem like they are picking up the waypoints at all and going to do "their job".

I'm sure this has been asked before, do you have an FAQ for these kinds of questions?


Edited by Kitchen_Duty
Link to comment
Share on other sites

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 change because I don't know how many missions it'd mess up purely by someone updating mist in it. The thing is it is a wrapper function that calls mist.groupToRandomPoint to do the actual work. Big difference is that function accepts a table and has the road setting labeled abit better, while groupToPoint is several input values.  

  • Like 1

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

I think I was wrong and it works as advertised after all. So if roadUsing is false the group will still always use the roads if it is far enough from the arrival zone. I was trying to create a mission where group will head straight through the desert to a random point/zone. Is it possible to do with MIST?

roadUsing = boolean. If false and the group is 1.3 * radius outside the center of the zone, the group will go to the nearest road
    and follow it to the nearest on road point of the new random point in the zone.
Link to comment
Share on other sites

Made it a little more clear on the wiki https://wiki.hoggitworld.com/view/MIST_groupToPoint

 

So a true value at the end for that should do the trick. Alternatively you can build the route fairly easily on your own.

 

local path = {}
local group = Group.getByName('someGroup')
local speed = mist.utils.kmphToMps(30)
path[#path + 1] = mist.ground.buildWP(mist.getLeadPos(group), "Vee", speed)
path[#path + 1] = mist.ground.buildWP(trigger.misc.getZone('whatever').point, "Vee", speed0)
mist.goRoute(group, path)

 

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

The problem is that no matter what the last boolean is the group will always head to the closest road and not straight to randomized point on the map.
Edit: I was actually using groupToRandomZone. Anyway group will always head to the closest road. Mission file attached.

random_zone.miz


Edited by Kaitsu
Added a mission file
Link to comment
Share on other sites

Part of the problem is in the documentation and potential problem you can encounter is a DCS AI issue. 

 

The wiki mist.groupToRandomZone erroneously has the disable roads entry but in the code it isn't actually passed or used by that function. While groupToPoint does use it. I'm not sure why it doesn't use that input at all or why it wasn't included when originally made, but that could be rectified. 

 

The AI issue is that sometimes the AI will just refuse to drive it. I'm still investigating this but it partially seems like vehicle type, distance travelling, and size of the group seems to impact it. 

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

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...