Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

For a line (untested):

function getRandomPointOnLine(start, end)  -- start and end are Vec3's
 local diff = mist.vec.sub(end, start)
 local length = mist.vec.mag(diff)
 local direction = mist.vec.getUnitVec(diff)
 return mist.vec.add(start, mist.vec.scalar_mult(direction, mist.random(length)))
end

 

For a random point in a polygon, I would repeatedly calculate a random point in a bounding box until you get a hit with mist.pointInPolygon().

Link to comment
Share on other sites

There has always been some pause whenever a group spawns in. Usually though it is caused from having to load the model and textures, especially if those objects and textures aren't already active on the map and therefore in your ram. For instance running the clone script has a jitter when its first used, but if you clone the same group again there is virtually no pause.

 

I guess the question is what type of object you are respawning?

 

 

Heya grimes - sorry for the late reply but the stutters are coming with each respawn of an AI wingpair. there are 8 wingpairs per side and each uses MIST to respawn upon death or despawn. I am using a continuous trigger - should I be using a switched condition instead to mitigate stutters?

ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 

"This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL

Link to comment
Share on other sites

Heya grimes - sorry for the late reply but the stutters are coming with each respawn of an AI wingpair. there are 8 wingpairs per side and each uses MIST to respawn upon death or despawn. I am using a continuous trigger - should I be using a switched condition instead to mitigate stutters?

 

Is it respawning all in one go or as each group dies they get respawned? I could see the former causing a slight stutter, but the latter not so much.

 

How big of a stutter is it?

 

Triggers shouldn't matter as long as the script is short enough.

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

Heya grimes - sorry for the late reply but the stutters are coming with each respawn of an AI wingpair. there are 8 wingpairs per side and each uses MIST to respawn upon death or despawn. I am using a continuous trigger - should I be using a switched condition instead to mitigate stutters?

 

 

I actually just wrote a script using mist that does exactly what it sounds like what you're trying to do. I haven't noticed any stutters, you can give it a try if you want. All you have to do is put "_rspwn_" somewhere in group name for the groups that you want to respawn. it works for planes, helos, and ground units.

GrpRespawn.lua

Link to comment
Share on other sites

Hope I'm in the right thread here where someone with '.lua' / MIST experience can help me with the following Huey issue:

 

Have been playing around with Triggers ('Type', 'Conditions' & 'Actions') and after some research and testing came across these EGT parameters that seem to work with the EGT gauge readings.

When I fly within the 'Normal Operating EG Temperatures', as I can see on the EGT gauge, all is well and the helicopter is flying normal without problems.

 

However, when I fly the EGTs outside their operating range, AND depending on how long & at what EXCESS temperature, an engine failure ensues. Resulting in a nice 'real life' auto-rotation "practice" to the ground. (time-duration-limits and temperatures were found in the RL Huey manual!)

 

I have no experience with '.lua' or MIST coding whatsoever, but would assume that these triggers (in this case EGT) could somehow be pasted into a '.lua' file and thus simplifying the trigger set-up in any new mission.

 

That said, I am wondering if someone could show me how to make this EGT triggers in the attached .MIZ file into a "Do Script" or "Do Script File" format.

In that way, I won't need to implement a bunch of Triggers when I want to make a new mission, but can just paste one trigger ("Do Script → 'EGT Limitations') and move on with the mission making.

 

DSPALLASVI

ASUS Sabertooth X79 TUF Motherboard / Intel Core i7-3930K Unlocked Processor Six Core / Corsair CMP32GX3M4X1600C10 Dominator Memory Kit - 32GB (4x 8GB) / OCZ Solid 3 480GB Solid State Drive / EVGA GeForce GTX 670 FTW+ / Corsair CW-9060002-WW Hydro H70 CORE CPU Cooler / Seagate ST1000DM003 1TB Hard Drive / BenQ XL2420TX 24" Widescreen LED Gaming Monitor - 1920 x 1080 / Windows 7 Ultimate Edition, 64-bit / C-Tek 12-bit: Foot Pedals - Robinson Cyclic - 5-button-hat cyclic - Collective / TrackIR-5

Link to comment
Share on other sites

  • 2 weeks later...

Uploaded a new version to development branch. Key changes are that I've added the hidden variable to all DBs in addition to 'AddPropAircraft' which seems to have a number of purposes and for different aircraft. The biggest change has been a refactor of the display message code. It should be a little more effecient now, but if there are any differences between the old and new systems let me know. I also added the functionality for multiple sound messages to be played throughout a single message.

 

Basically it transforms what I did with WAY to many freaking triggers in 'On Station' into a much more condensed and practical function call. For example:

 

local msg = {}
msg.text = 'Tusk, this is Wizard. New Picture, area threats include enemy fighter aircraft, over.'
msg.displayTime = 50
msg.msgFor = { coa  = {'all'}}
msg.multSound = {
[1] = {time = 0, file = 'hq_Tusk.wav'},
[2] = {time = 1.5, file = 'hq_ThisIsWizard.wav'},
[3] = {time = 4, file = 'hq_newPicture.wav'},
[4] = {time = 4.5, file = 'hq_AreaThreatsInclude.wav'},
[5] = {time = 6, file = 'hq_EnemyFighterAircraft.wav'},
[6] = {time = 8, file = 'hq_over.wav'},
}
msg.name = 'multSound2'

mist.message.add(msg)

 

FYI, just cause I used the audio from On Station doesn't mean that "On Station 2: A Few Stations More" is in development. :megalol:

 

 

Anyways. Gotta fix the documentation before release. Unless there are some needed features that are sorely needed that I could sneak in real fast...

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 May lead to some interesting message composition

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

v46 is up on github development branch.

 

I went through my library of unfinished scripting functions and decided the forgotten "time" functions should get polished up and added. So I spent the last day or two fixing them up and adding new functions related to it. Since time in the game is defined in seconds from the date June 1, 2011 its kind of a pain to work with. So these functions convert time measured in seconds into something useful be it date, military time, a clock, whatever.

 

Will release mist 3.7 after I do some more tests on the messages and do my absolutely favorite part of maintaining mist, the documentation.

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

Does anyone know if teleportToPoint works for transportable crates?

 

I tried the code below (assume that the variables are all correct :) ) but it doesnt seem to move the crate to the new specified position.

 

I tried TeleportToPoint like so

 


    local vars = {}
       vars.gpName = _spawnedCrate:getName()
       vars.action = 'teleport'
       vars.point = _heli:getPoint()

       mist.teleportToPoint(vars)

 

No errors but the crate just stays where it was weirdly.

 

BTW thanks for such a great script, makes scripting a lot easier!

Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD

CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup

Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script

 

Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :)

DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord

Link to comment
Share on other sites

Mist is currently missing some of the critical table entries to correctly identify and spawn cargo objects. I'm checking the feasibility of adding that support. In terms of adding the cargos via mist functions it appears to be ok, the problem is in trying to get data on objects spawned outside of mist and adding it to the DBs. It is a little difficult because there are a few known bugs with cargo objects within the scripting engine or some data just isn't accessible. At this point the worst case is I just have to make an exception for cargo objects and either exclude them from the DBs unless they were added via mist or try to guess on some of the missing data.

 

For anyone using v46 please be aware that in the next release I decided to rename some of the mist.time functions. Notably:

 

- changed mist.time.getMilString to mist.getMilString

- changed mist.time.getClockString to mist.getClockString

- changed mist.time.getDateStrimg to mist.getDateString

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 for the info Grimes! I'll play around with it some more then.

 

I actually don't care about the crate after I've used the teleport function as I was purposefully teleporting it out of the way as I couldnt find a way to destroy it. If it ends up being broken in some way that's OK for me!

Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD

CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup

Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script

 

Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :)

DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord

Link to comment
Share on other sites

3.7 Release Download

 

Changelog

-added mist.time.milToGame

-added mist.time.getDate

-added mist.time.getDHMS

-added mist.time.convertToSec

-added mist.getDateString

-added mist.getClockString

-added mist.getMilString

-added support for cargo objects for all dynAdd related scripts (clone, teleport, respawn)

-added cargo spawned outside of mist should be correctly added to mist DBs.

-added multSound entry for mist.message.add

 

-fixed mist.getCurrentGroupData to return static data and hidden value correctly

-fixed mist.getGroupData to return static data and hidden value correctly

-fixed mist.dynAdd not accepting either startTime or start_time values

 

-refactored mist message display code.

Functionality should be the same, but the backend should be more efficient. As stated earlier I also added the multSound entry which allows for multiple sound files to be played during the course of a single message at different times.

 

Entries added to DBs

-hidden

-AddPropAircraft

-mass

-canCargo

-categoryStatic

-startTime

 

PDF documentation has been updated. Wiki documentation will be updated shortly.

 

 

As always feel free to post any issues because chances are something slipped past... there is almost always something that does. :huh:

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

 

Changelog

-added mist.time.milToGame

-added mist.time.getDate

-added mist.time.getDHMS

-added mist.time.convertToSec

-added mist.getDateString

-added mist.getClockString

-added mist.getMilString

-added support for cargo objects for all dynAdd related scripts (clone, teleport, respawn)

-added cargo spawned outside of mist should be correctly added to mist DBs.

-added multSound entry for mist.message.add

 

-fixed mist.getCurrentGroupData to return static data and hidden value correctly

-fixed mist.getGroupData to return static data and hidden value correctly

-fixed mist.dynAdd not accepting either startTime or start_time values

 

-refactored mist message display code.

Functionality should be the same, but the backend should be more efficient. As stated earlier I also added the multSound entry which allows for multiple sound files to be played during the course of a single message at different times.

 

Entries added to DBs

-hidden

-AddPropAircraft

-mass

-canCargo

-categoryStatic

-startTime

 

PDF documentation has been updated. Wiki documentation will be updated shortly.

 

 

As always feel free to post any issues because chances are something slipped past... there is almost always something that does. :huh:

 

Thanks Grimes! I'll test out teleporting my crates in the CTLD script tonight as they're added outside of MIST. I'll also try spawning them with mist and teleporting as well.

Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD

CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup

Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script

 

Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :)

DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord

Link to comment
Share on other sites

Thank you !!!!

 

On the other hand, I have a problem here... I am starting with this amazing tool, I finnally had guts !!!

 

what is wrong with this? I want the unit called "red1" move to a random point from the group blindados at certain moment, so i want to create a triggerzone in blindados and give the order groupToPoint.

 

-----------

local bluepoint = Group.getByName("blindados"):getUnit(1):getPosition().p

local bluezone = {

point = 'bluepoint',

radius = 300

}

 

 

function mist.groupToPoint(group = 'red1', table = 'bluezone', form = Cone, heading = nil,speed = 15, useRoads = false )

---------------

 

the error says ")" expected near "="... but I dont get it


Edited by ESAc_matador
Link to comment
Share on other sites

3.7 Release Download

 

Changelog

-added mist.time.milToGame

-added mist.time.getDate

-added mist.time.getDHMS

-added mist.time.convertToSec

-added mist.getDateString

-added mist.getClockString

-added mist.getMilString

-added support for cargo objects for all dynAdd related scripts (clone, teleport, respawn)

-added cargo spawned outside of mist should be correctly added to mist DBs.

-added multSound entry for mist.message.add

 

-fixed mist.getCurrentGroupData to return static data and hidden value correctly

-fixed mist.getGroupData to return static data and hidden value correctly

-fixed mist.dynAdd not accepting either startTime or start_time values

 

-refactored mist message display code.

Functionality should be the same, but the backend should be more efficient. As stated earlier I also added the multSound entry which allows for multiple sound files to be played during the course of a single message at different times.

 

Entries added to DBs

-hidden

-AddPropAircraft

-mass

-canCargo

-categoryStatic

-startTime

 

PDF documentation has been updated. Wiki documentation will be updated shortly.

 

 

As always feel free to post any issues because chances are something slipped past... there is almost always something that does. :huh:

 

Tested spawning a dynamic crate with MIST, that worked perfectly so thanks for that!

 

The teleport didn't work and I just ended up with two crates, the original and a new one. Interestingly the new one wouldn't appear on the F6 Menu.

 

There must be something special about cargo crates as I don't see how you can have two units with the same unitId and groupId in two different places on the map...

 

Maybe the destroy function will be fixed for cargo crates and then the issue can be solved.

 

I've attached a test mission for the CTLD script using the new mist and the teleport command if you're interested but I don't think there's much that can be done. :(

test-mission.miz

Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD

CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup

Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script

 

Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :)

DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord

Link to comment
Share on other sites

3.7 Release Download

 

Changelog

-added mist.time.milToGame

-added mist.time.getDate

-added mist.time.getDHMS

-added mist.time.convertToSec

-added mist.getDateString

-added mist.getClockString

-added mist.getMilString

-added support for cargo objects for all dynAdd related scripts (clone, teleport, respawn)

-added cargo spawned outside of mist should be correctly added to mist DBs.

-added multSound entry for mist.message.add

 

-fixed mist.getCurrentGroupData to return static data and hidden value correctly

-fixed mist.getGroupData to return static data and hidden value correctly

-fixed mist.dynAdd not accepting either startTime or start_time values

 

-refactored mist message display code.

Functionality should be the same, but the backend should be more efficient. As stated earlier I also added the multSound entry which allows for multiple sound files to be played during the course of a single message at different times.

 

Entries added to DBs

-hidden

-AddPropAircraft

-mass

-canCargo

-categoryStatic

-startTime

 

PDF documentation has been updated. Wiki documentation will be updated shortly.

 

 

As always feel free to post any issues because chances are something slipped past... there is almost always something that does. :huh:

 

Thank you.

Link to comment
Share on other sites

local bluepoint = Group.getByName("blindados"):getUnit(1):getPosition().p

local bluezone = {

point = 'bluepoint',

radius = 300

}

 

 

function mist.groupToPoint(group = 'red1', table = 'bluezone', form = Cone, heading = nil,speed = 15, useRoads = false )

---------------

 

the error says ")" expected near "="... but I dont get it

 

Well there are a few errors. The first is point = 'bluepoint'. By putting bluepoint in quotation marks you are just setting point to equal a string and not the table you just created. Remove the quotes and it will be just fine. You can even simplify it a little more by the following:

 

local bluezone = {

point = Group.getByName("blindados"):getUnit(1):getPosition().p,

radius = 300

}

 

The 2nd problem is how you are calling the function.

 

Call it as: mist.groupToPoint( 'red1', bluezone, "Cone", nil, 15, false)

 

By actually writing the word "function" in front of it, you are actually creating a new function, and therefore overwriting the existing mist function. For usage see the examples in the documentation: http://wiki.hoggit.us/view/GroupToPoint

 

It is important to note how a function is called and what the input variables are. In the case of mist.groupToPoint, it has several input variables and the order of the variables matters. So the first variable MUST be the name of a group or a group object. It only needs the first two variables, the rest are optional. However if you wanted the last optional variable and none of the others, you still need to create the correct number of input variables.

 

The way you did it is mostly correct for a function called with a table as the input variables. For example the way mist.groupToPoint actually works in the mist code is it converts its input variables for use within another mist function, in this case its mist.groupToRandomPoint. So the way you called it initially would just have to be slightly changed to use it with this function...

 

mist.groupToRandomPoint({group = 'red1', point = Group.getByName("blindados"):getUnit(1):getPosition().p, radius = 300, form = 'Cone', speed = 15, disableRoads= false})

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

Well there are a few errors. The first is point = 'bluepoint'. By putting bluepoint in quotation marks you are just setting point to equal a string and not the table you just created. Remove the quotes and it will be just fine. You can even simplify it a little more by the following:

 

local bluezone = {

point = Group.getByName("blindados"):getUnit(1):getPosition().p,

radius = 300

}

 

The 2nd problem is how you are calling the function.

 

Call it as: mist.groupToPoint( 'red1', bluezone, "Cone", nil, 15, false)

 

By actually writing the word "function" in front of it, you are actually creating a new function, and therefore overwriting the existing mist function. For usage see the examples in the documentation: http://wiki.hoggit.us/view/GroupToPoint

 

It is important to note how a function is called and what the input variables are. In the case of mist.groupToPoint, it has several input variables and the order of the variables matters. So the first variable MUST be the name of a group or a group object. It only needs the first two variables, the rest are optional. However if you wanted the last optional variable and none of the others, you still need to create the correct number of input variables.

 

The way you did it is mostly correct for a function called with a table as the input variables. For example the way mist.groupToPoint actually works in the mist code is it converts its input variables for use within another mist function, in this case its mist.groupToRandomPoint. So the way you called it initially would just have to be slightly changed to use it with this function...

 

mist.groupToRandomPoint({group = 'red1', point = Group.getByName("blindados"):getUnit(1):getPosition().p, radius = 300, form = 'Cone', speed = 15, disableRoads= false})

 

Thank you! I am not a programmer, so i still have some confusion between strings, tables, etc!.But With some help I am creating really funny thing i will post the mission when ready!

Link to comment
Share on other sites

mist.flagFunc.group_alive problem?

 

hi

 

i try to use Mist but i have some problem

 

1) i have created a group of vehicle with one vehicle

2) i have put this action (i test if the group is alive or not) set the useflag 100 to false when dead

 

 

mist.flagFunc.group_alive{
groupName = 'U100',
flag = 100,
toggle = true
}

but the flag 100 keeps its value true, because in coding of mist function

if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true 

is always True and True even when the group U100 is destroyed

 

is there a problem or i have forgotten something?

 

thanks for help

Thierry


Edited by Frenchy
Link to comment
Share on other sites

No you aren't doing anything wrong. It isn't working because there is a bug in DCS where Group.getByName(groupName):isExist() always returns true even if the group is dead. Its extremely annoying that it is broken.

 

I've written a little work-around. It is up on the development github page here.

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