Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

Make a function to respawn the group and copy all of the mist.respawnGroup and controller stuff into that.

 

local function respawn(groupName, val)
mist.respawnGroup(groupName, true)
local con = Group.getByName(groupName):getController()
con:setOption(AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD)
con:setOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.NEVER)
con:setOption(AI.Option.Air.id.SILENCE, true)
con:setOption(AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE)
end

 

Then schedule the function to respawn it.

 

mist.scheduleFunction(respawn, {v['group'], true}, timer.getTime() + 10

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

  • 1 month later...

Hey guys,

 

 

Just wanted to make sure I'm correctly understanding something. If I want to spawn a specific aircraft group from a table that I've created using mist.makeUnitTable({'[blue][plane]}), do I then need to get get the groupName of the unit in question and then use that to find the reference to the group I want to spawn? e.g.

 

table_BlueAircraft = mist.makeUnitTable('[blue][plane]')

unitToSpawn = table_BlueAircraft[indexOfInterest]

groupToSpawn = mist.DBs.MEunitsByName[unitToSpawn].groupName

Group.activate(Group.getByName(groupToSpawn))

 

 

This feels pretty convoluted, and I suspect it's just a product of my lack of scripting skill. Is there a cleaner, more efficient way of accomplishing the same thing?

i7-7700K @ 4.9Ghz | 16Gb DDR4 @ 3200Mhz | MSI Z270 Gaming M7 | MSI GeForce GTX 1080ti Gaming X | Win 10 Home | Thrustmaster Warthog | MFG Crosswind pedals | Oculus Rift S

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Is mist.groupRandomDistSelf broken?

 

I made a small mission with a couple of ground units where I first make them go mist.groupToRandomZone depending on where our planes are coming from, and then later go mist.groupRandomDistSelf when receiving damage so as to mimic them panicking and deviating from their assigned route. No can do, because mist.groupRandomDistSelf complains about a missing "self" then croaks!

 

Is it just me? I did check the pertinent function calls for syntactical errors etc. and didn't find any, but it could've still been something I overlooked. Anyone else seeing this or similar?

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

Link to comment
Share on other sites

Post the script used to call it?

 

I was actually using it earlier to test something else and aside for me wanting them to use roads and going off road, they did at least go to a random spot. Best guess it doesn't like something about the group name or group data sent to it. In my earlier test I was using group names.

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

Yep, call a routing function with a group name parameter twice in a row and the second call always croaks, complaining about a missing attribute. The exact attribute depends on the function called, but at least mist.groupRandomDistSelf and mist.groupToRandomZone both fail when used like this. Any ideas?

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

Link to comment
Share on other sites

OK, as per the commented screenshot below. EDIT: And just for clarification, 201 always gets set first and 111 later when the unit receives 50% damage. The first call succeeds, the 2nd always fails.

Screen_200104_102033.thumb.jpg.b624c0d3fe3bc4eec46356af4d657b3c.jpg


Edited by msalama

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

Link to comment
Share on other sites

I don't think flag values trigger a switched condition.

 

They do. The function definitely gets called when either flag turns true. EDIT: I used "switched condition" because off the top of my head the ONCE attribute means just that, i.e. it runs once and the function call is then removed from the stack and you cannot call it again. Not sure about this though, just how I remember it. EDIT2: And yeah, flag values per se do not trigger this, but a flag coming into existence does.


Edited by msalama

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

Link to comment
Share on other sites

Would be helpful to know the error it is giving so I can figure out what line it is complaining about.

 

Is the unit alone in the group? So that it could be dead and still run the function. I might need to add some further error protection if that is the case.

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

OK, I'll get a screenshot of the error. Yes, the unit is alone in the group.

 

When it happens go to DCS.log and copy the relevant bits. The screenshot of the error box always cuts stuff out.

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

OK, here we go. The randomDistSelf function throws an error about the 'self' attribute as well, but cannot provide an example here since the mission doesn't have those calls anymore.

 

2020-01-06 07:38:37.567 ERROR   DCS: Mission script error: : [string "C:\Temp\DCS.openbeta\/~mis00007628.lua"]:6158: attempt to index local 'point' (a nil value)
stack traceback:
[C]: ?
[string "C:\Temp\DCS.openbeta\/~mis00007628.lua"]:6158: in function 'buildWP'
[string "C:\Temp\DCS.openbeta\/~mis00007628.lua"]:6400: in function 'groupToRandomPoint'
[string "C:\Temp\DCS.openbeta\/~mis00007628.lua"]:6452: in function 'groupToRandomZone'
[string "mist.groupToRandomZone('RARM_4', {'RAAS_2.1', 'RAAS_2.2', 'RAAS_2.3', 'RAAS_2.4', 'RAAS_2.5', 'RAAS_2.6'}, 'off road', nil, nil, true)"]:1: in main chunk

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

Link to comment
Share on other sites

Made a test with the randomDistSelf function too. The error thrown is this:

 

ERROR   DCS: Mission script error: : [string "C:\Temp\DCS.openbeta\/~mis00001CC1.lua"]:6423: attempt to index local 'pos' (a nil value)
stack traceback:
[C]: ?
[string "C:\Temp\DCS.openbeta\/~mis00001CC1.lua"]:6423: in function 'groupRandomDistSelf'
[string "mist.groupRandomDistSelf('RARM_2', 10000, 'off road')"]:1: in main chunk

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

Link to comment
Share on other sites

What is the unit type that is getting hit and what are you hitting it with?

 

It looks to purely be an issue of the unit taking damage, which triggers the function call, and likely almost being dead or dead enough that getPosition() fails on it. Thus a nil value is being returned from mist.getLeadPos(), the script continues on, and errors because I guess I didn't think of that possibility existing.

 

Problem is easily fixable, just would like to be able to recreate it to know if it is a DCS issue and to ensure that the fix I make to mist works.

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

This happens regardless of the unit type and the weapons / platform used. I believe it's a current DCS issue myself, since I've done stuff like this in the past and it has worked OK.

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

Link to comment
Share on other sites

  • 1 month later...

Destroy client planes in a zone ?

 

Hello there !

 

I would like to destroy/kill client airplanes/helicopters when they enter a specific zone. Or better, to set client planes/helicopters fuel quantity to zero if they enter this zone ;)

 

Is it a way to do that with mist ? And if yes could someone tell me how ? I try to figure out how it works, without success for now :music_whistling:

Link to comment
Share on other sites

In my opinion, the only way to destroy a client plane/helo is to destroy it with an explosion or a weapon hit.

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

What I want is destroying player aircraft/helicopter unit in a specific zone (here DA Groomlake) I had a look on the web, and I try to copy/paste some lines from some scripts I found, and I came to this:

 

local units = mist.makeUnitTable{('[blue][plane]','[blue][helicopter]')}, -- make list of all blue planes and helicopters

local zone = trigger.misc.getZone('DA Groomlake') -- get the trigger zone

local inZone = {}, -- table of units inside the zone

 

local function check()

for i = 1, #units do -- iterate units

if Unit.getByName(units) then -- if returned

local u = Unit.getByName(units)

if u:getLife() > 0 then -- if it is alive

if mist.utils.get2DDist(u:getPosition().p, zone.point) < zone.radius then --if it's une zone

u:getController():function unit:destroy()

inZone[u:getName()] = true

end

end

end

end

end

end

 

 

attachment.php?attachmentid=226931&stc=1&d=1581263110

 

Of course, I tried it and had mist error message in game. But am I close from something ? I copiedpasted some stuff, but I do not know anything about lua

Capture.thumb.PNG.9f974d160d5765a8ac74b7a711916245.PNG

Link to comment
Share on other sites

What error do you get ?

 

Your lua seems pretty good to me, except that you should use a variable to store Unit.getByName(units) instead of calling Unit.getByName() twice.

 

 

If you ever need french-speaking help with mission editing, feel free to drop to the VEAF's discord or forum. I'm often here, and always eager to help !

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

i am fool and super noob... really trying to learn this , and my question is :

is it possible to import real weather data from METAR and other charts like wind charts etc... automatically by Scripting for having real LIVE weather condition in servers ?!?

and can call that thing weather engine ?!

for example in FSX it is possible to download weather condition from Internet and refreshing it every 15 minutes !

 
icon modules dcs small.png
 
My Liveries : Download Here       IIF Project : Click here       My Discord : Isaac#5625       Iranian DCS Community Discord Channel : Click Here
___________________________________________________________________________________________________________________________________________________________________________________
My Gear :

CPU: i5 7500 @ 3.8GHz | Mainboard: ASUS STRIX H270F Gaming | Ram: 32gig 2400 | GPU: ASUS DUAL GTX 1060 6G OC | Monitor: ASUS VG278HE 27" 144Hrz | Headtracker: Open Track + DIY Clips | HOTAS : T.16000M | Mouse & Keyboard: ROG IMPACT II & Cooler Master Devastator 3

___________________________________________________________________________________________________________________________________________________________________________________

WISH LIST Maps : Iraq and West of IRAN  | Vietnam 

Link to comment
Share on other sites

After this recent upgrade to DCS v2.5.6,

I am getting a new error of -

...:4618: in function 'units in zones'...

from a file called ~mis00002F51.lua, see the screenshot of the error

The attached zip contains the screenshot, the mission, the .lua file.

The ~mis00002F51.lua file is the same as the mist v4.3.74 that I load into the mission with a Do Script File action.

 

attachment.php?attachmentid=227753&stc=1&d=1581880391

 

I am running DCS 2.5.6 Open Beta as a client and also as a server and the error is coming up on both installs.

2039722804_DCSMISTerrorgetUnitsInZones.png.9264ecae2bac5cbf7353f97134e06e16.png

DCS MIST error getUnitsInZones WC 20200216 - Copy.zip

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Link to comment
Share on other sites

Likely related to all the mission start with no conditions bugs like this one: https://forums.eagle.ru/showthread.php?t=263603

 

It is trying to run code before all of the the objects are even loaded in. Mist won't even be able to correctly schedule the check to run.

 

Just from my test mission I added some logging and note the timestamps:

 

2020-02-18 00:12:08.967 INFO SCRIPTING: Mission Start No Condition

2020-02-18 00:12:52.280 INFO SCRIPTING: Once No Condition Check

 

Missions started loading just before that first entry, then 44 seconds later when time starts advancing in the actual mission the Once condition is run.

 

You can wait for a patch to fix it or switch all of the mist function calls to Once>Time More>Do Scripts.

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