Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

Hi Grimes, an info: I would like to use teleport to move some groups from a remote poiint tp an urban area with a great distribution (i.e. imagine a trigger zone over Krasnodar having a radius of 3 km).

 

Is there a way to prevent units, vehicles in particoular, to be teleported over buildings?

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

I'm having an error in call utility functions. Any function with utils in the name I get a nil value error. Such as

 

mist.utils.converter

 

I get

 

attemp to call 'converter' (a nil value)

 

As I say, I've tried a few utils, and get similar results.

Have the utilities been removed?

 

**Added**

 

Is there a way to basically combine mist.message.add and DCS func radioTransmission?

What I'd like is to use MiST's excellent multSound capability, but only over a specified frequency, like you can with radiotrasnmission.

Thanks as always! :pilotfly:


Edited by Wrench
Link to comment
Share on other sites

Converter should be working, but keep in mind I never actually got around to pushing that built out of the "development" branch. So make sure you are using a file from here: https://github.com/mrSkortch/MissionScriptingTools/tree/development

 

As for the radio transmission, I think it would be doable. It would be an extra set of parameters on an already complicated scripting function though. Radio transmissions are quite separated from triggered messages and sounds, so I'd be more inclined to create a new function to do it. I probably would give it the ability to do transmissions from units if desired. I've got the perfect mission to test it out on.

 

 

Chromium, I'll look into it. As a quick fix you could probably make the units drive a little bit. If they spawn on a building, whenever the unit moves it gets teleported back to ground level. It might be a complicated mess in the future due to all the new trees on Caucuses and the tree positioning isn't exactly detectable.

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

Chromium, I'll look into it. As a quick fix you could probably make the units drive a little bit. If they spawn on a building, whenever the unit moves it gets teleported back to ground level. It might be a complicated mess in the future due to all the new trees on Caucuses and the tree positioning isn't exactly detectable.

 

That's the point. May I suggest you to check y value of the spawned unit, if it's > than land.getHeight you might assume that you're not on ground level (wouldn't work for bridges.. but could be feasible?). I might move the units but doing so I would lose larger "disperse" parameter.

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

You can also easily validate the returned units and either try it again or if applicable just remove the offending unit.

 

That isn't a solution I'd prefer to do within mist because it could be kind of resource intensive. I'd prefer to try and figure out if an object is in a building before it even spawns. I have one idea worth trying out that I am experimenting with right now. Part of the problem is that you can detect buildings near a point, but you don't know a whole lot about the shape of a building. Its sadly not a simple pointInPolygon test as there isn't a polygon to test. Suppose I could build

or ask ED for a 2d point DB of assorted world objects.

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

or else you might try to run a world.search on Scenery object for a 5 m radius for each unit placement. But sounds like calculation intense even writing it...

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

  • 2 weeks later...
try to use it in dcs 2 ti get a string error as soon as mission is un paused any thoughts?

 

I need to know what the error is. Copy paste the error that is in dcs.log.

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

  • 3 weeks later...

Apologies, this is probably a dumb question. It's my first DCS script I am trying, let alone MIST. I just want to output a different message to two pilots for a training mission. Whatever I seem to do, both client aircraft receive both messages despite them being called 'Pilot01' and 'Pilot02' and using the below code.

 

Mist is running at startup and I get no errors so I think all is well with that.

 

Maybe I have a scope problem? I don't yet have my head around scoping in DCS or LUA. Any ideas? This is in DCS 1.5.8 latest build.

 

 


   local msg = {} 
   msg.text = 'Your callsign for this sortie  is COLT 1-1' 
   msg.displayTime = 10  
   msg.msgFor = {units = {'Pilot01'}} 
   mist.message.add(msg)


   local msg = {} 
   msg.text = 'Your callsign for this sortie  is COLT 1-2' 
   msg.displayTime = 10  
   msg.msgFor = {units = {'Pilot02'}} 
   mist.message.add(msg)


Edited by Darkfury
Link to comment
Share on other sites

Apologies, this is probably a dumb question. It's my first DCS script I am trying, let alone MIST. I just want to output a different message to two pilots for a training mission. Whatever I seem to do, both client aircraft receive both messages despite them being called 'Pilot01' and 'Pilot02' and using the below code.

 

Mist is running at startup and I get no errors so I think all is well with that.

 

Maybe I have a scope problem? I don't yet have my head around scoping in DCS or LUA. Any ideas? This is in DCS 1.5.8 latest build.

 

 


   local msg = {} 
   msg.text = 'Your callsign for this sortie  is COLT 1-1' 
   msg.displayTime = 10  
   msg.msgFor = {units = {'Pilot01'}} 
   mist.message.add(msg)


   local msg = {} 
   msg.text = 'Your callsign for this sortie  is COLT 1-2' 
   msg.displayTime = 10  
   msg.msgFor = {units = {'Pilot02'}} 
   mist.message.add(msg)

 

I thought I'd run that through a quick mission to see if anything obvious stood out. Funny thing, I can't output any message with that script. And I see it is literally the exact syntax demonstrated at the Hoggit wiki.

 

MIST loads fine; I can see that in the logs. But I cannot get a message to ouput. I've tried various conditions, "time more", UNIT IS ALIVE, etc....but nothing outputs a message. I have the units named properly.

 

A workaround would be to make the planes single-unit groups, with group and unit names the same, then use the native "MESSAGE TO GROUP" to output the message.

 

If you have a single group with two individually named aircraft, try changing it to two groups with single aircraft. A "Pilot01" group and a "Pilot02" group. I have a suspicion, MIST is treating groups as units (?).


Edited by doodenkoff

Win 10 | i7 4770 @ 3.5GHz | 32GB DDR3 | 6 GB GTX1060

Link to comment
Share on other sites

Apologies, this is probably a dumb question. It's my first DCS script I am trying, let alone MIST. I just want to output a different message to two pilots for a training mission. Whatever I seem to do, both client aircraft receive both messages despite them being called 'Pilot01' and 'Pilot02' and using the below code.

 

Mist is running at startup and I get no errors so I think all is well with that.

 

Maybe I have a scope problem? I don't yet have my head around scoping in DCS or LUA. Any ideas? This is in DCS 1.5.8 latest build.

 

 


   local msg = {} 
   msg.text = 'Your callsign for this sortie  is COLT 1-1' 
   msg.displayTime = 10  
   msg.msgFor = {units = {'Pilot01'}} 
   mist.message.add(msg)


   local msg = {} 
   msg.text = 'Your callsign for this sortie  is COLT 1-2' 
   msg.displayTime = 10  
   msg.msgFor = {units = {'Pilot02'}} 
   mist.message.add(msg)

 

If they are in the same group it is unfortunately a limitation of DCS at present. A while back you could only have one client aircraft per group, but they changed it so each unit could be a client. However they haven't in turn added a "Message to Unit" functionality. The smallest entity we can send a message to is the group. If they aren't in the same group, then there could be a bug in my code.

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

Thanks a ton Grimes. At least I know I am not doing anything wrong. They are all in the same group. Damn that current limitation!

 

I will amend my mission to either separate them, or skip that bit.

 

Thanks doodenkoff for trying to help as well!

Link to comment
Share on other sites

Hi guys.

 

Is there a way in MIST to set an air unit with unlimited fuel or set his fuel back to full ?

 

In my case, it's a reaper acting as JTAC. If I use a respawn script while he is on a scripted orbit, the game crashes.

i9 9900k, 64 Go RAM, RTX 4090, Warthog HOTAS Throttle & Stick, Saitek Combat Rudder, MFD Cougar, Trackir 5 Pro, Multipurpose UFC and Oculus Rift S (when I want some VR),

http://www.twitch.tv/zarma4074 /  https://www.youtube.com/user/Zarma4074 

 

Copy-of-DCS-A-10C-User-Bar-CMR-ConvertImage.jpg

Link to comment
Share on other sites

DCS engine only has facilities to read fuel status, sadly you cannot write values

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

  • 4 weeks later...

MIst units in zone flag function

 

Any help is appreciated, my apologies if this is not the appropriate thread.

I'm trying to accomplish: When Troops dropped via CTLD are in zone, flag is set to true. This works fine with ME units active or late activated however, when "Dropped Group #" is in zone, nothing is returned. Can anyone please advise, I would appreciate it greatly.

 

Thank you.

 

blueZoneUnits = mist.makeUnitTable({'[blue][vehicles]'})

 

trainStation1 =

{

units = blueZoneUnits,

zones = {"9_TrainStation1"},

flag = 901,

zone_type = "sphere",

req_num = 1,

interval = 5,

toggle = false,

unitTableDef = blueZoneUnits,

}

 

mist.flagFunc.units_in_zones(trainStation1)

Link to comment
Share on other sites

Most probably because the list of units with makeunittable only takes the initial units. Dropped, spawned, cloned units, can have the same name, but different ID.

 

Unless you redo the list after dropping units it won't work.

 

You can make a loop repeating the script every minute to ensure it takes into account all units

Link to comment
Share on other sites

Hopefully someone smarter than me can tell me why I am getting this error?

 

6fbc4d1dd856443f9b2d0988b9ff0735.png

 

Here is the script:

 

local grpTemplate = {

units = Group.getByName("Insurgent BTR-80"):getUnits(),

country = 17,

category = "GROUND_UNIT",

groupName = nil,

groupId = nil,

clone = true,

route = nil

}

 

mist.dynAdd(grpTemplate)

Link to comment
Share on other sites

Group.getByName("Insurgent BTR-80"):getUnits() returns a group of unit objects, its not in the same format that mist.dynAdd() is expecting for the units table.

 

You can just grab the data directly from mist.DBs, for example:

units = mist.DBs.groupsByName["Insurgent BTR-80"].units

More specifically you can just add the clone value to a table that is grabbed from the DB itself, for example:

local grpTemplate = mist.getGroupData("Insurgent BTR-80")
grpTemplate.clone = true
mist.dynAdd(grpTemplate)

 

 

 

mist.groupToRandomZone and others in this group of functions do not have parameter to set if AI should use roads or not.

Wiki page does not reflect what is in code! Code should be fixed asap ...

 

It automatically forces roads if the group is more than 1.3x the radius of the zone away from the center. If you want more control over it just feed the data you want into mist.groupToRandomPoint()

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'm having a hard time trying to figure out a simple script with MIST. I'm looking to simply set a Flag value if a player destroys another player

(RED team killed member of BLUE), set flag 7001,1

 

Can anyone help me with this? I've been searching most of the day and can't seem to figure it out in my rookie stages. Apologies if this isn't the appropriate thread.


Edited by maverickturner
thread / not threat
Link to comment
Share on other sites

You have to use an event handler. A really basic example could be something like...

 

local lastHit = {}
local function score(event)
   if event.id ==  world.event.S_EVENT_HIT then
       if event.target and mist.DBs.humansByName[unit.getName(event.target)] then
           if event.initiator and mist.DBs.humansByName[unit.getName(event.initiator)] then
               lastHit[unit.getName(event.target)] = Unit.getName(event.initiator)
           end
       end
   elseif  event.id ==  world.event.S_EVENT_DEAD then
       if event.initiator and mist.DBs.humansByName[unit.getName(event.initiator)] and lastHit[unit.getName(event.initiator)] then 
           if mist.DBs.humansByName[unit.getName(event.initiator)].coalition == 'red' then
               trigger.action.setUserFlag(7001, 1)
           else
           
           end
       end
   end
end
mist.addEventHandler(score)

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

You have to use an event handler. A really basic example could be something like...

 

local lastHit = {}
local function score(event)
   if event.id ==  world.event.S_EVENT_HIT then
       if event.target and mist.DBs.humansByName[unit.getName(event.target)] then
           if event.initiator and mist.DBs.humansByName[unit.getName(event.initiator)] then
               lastHit[unit.getName(event.target)] = Unit.getName(event.initiator)
           end
       end
   elseif  event.id ==  world.event.S_EVENT_DEAD then
       if event.initiator and mist.DBs.humansByName[unit.getName(event.initiator)] and lastHit[unit.getName(event.initiator)] then 
           if mist.DBs.humansByName[unit.getName(event.initiator)].coalition == 'red' then
               trigger.action.setUserFlag(7001, 1)
           else
           
           end
       end
   end
end
mist.addEventHandler(score)

 

 

 

Grimes, this is absolutely perfect. Just what I was looking for. I'll test it out when I get home today. Thanks for the help!

Link to comment
Share on other sites

You have to use an event handler. A really basic example could be something like...

 

 

To use this code in conjunction with say CTLD, would I identify the medical helos like this:

 

if event.target == ctld.transportPilotNames and mist.DBs.humansByName...

 

I'm getting the overall idea but missing something due to my lack of experience with .lua.

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