Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

Hello,

 

(as usual) I need help but maybe what I'm asking could be useful for someone.

 

Is there a way to use the MIST go.route or something else to make a callsign identified group to specific L/Long decimal coordinates by chat text?

 

i.e.:

 

the clients flying on KA-50s are escorting a ground convoy made by a group that has callsign "Hammer 2", that is moving on a preplanned route. After acquiring contact with an enemy outpost along the route, one of the pilot type in chat:

 

"Hammer 2, head to N 42.33.400 E 041.33.400"

 

and the group, named "xxx" but identified by mission editor with callsign "Hammer 2" (set callsign inbuild function) change route and head to the assigned coordinates. Once there, it stops waiting for other instructions.

 

ADD: maybe it could be useful to add an "on road" or "off road" capabilities to the request, that make the group heading first to the nearest road and than set a route than to the nearest road point in proximity to destination coordinates.. but it's not so necessary for me at the moment.

 

Do you think it's possibile? Maybe, some kind heart can try to traslate this in a script to be loaded somehow after mission start and MIST?

 

Thanks in advance :)

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

It is possible, but it would likely have to be part of Slmod or something else that could identify multiplayer chat text and perform commands based on what was typed.

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

  • 2 weeks later...

I'll be making some changes to the databases in mist v3. Mainly I am integrating the spawn clone teleport script into mist, and part of it is to update the databases as stuff gets spawned in. I've also added some static DBs which will simply have 'ME" inserted into the names, for example "mist.DBs.MEgroupsByName." These databases won't change as objects are dynamically spawned in. The current databases will only update with either new group information or overwrite existing information whenever a group or object has the same name or Id. I possibly need to make a change to the DB entries of country names so that dynamically spawned groups outside of mist can be added to the mist DBs. Basically right now the country names are case sensitive (Russia instead of RUSSIA or russia). For whatever reason in mission editor (therefor mist) have case sensitive names while the scripting engine doesn't. So I'm just curious how many of you out there utilize code that relies on a case sensitive country name from mist.DBs lookups.

 

Its basically a question of doing something the easier way now, but potentially screwing up people scripts and not really having to deal with it as much in the future or having to write some additional code that would need to be used whenever the issue exists in the future. I'm leaning toward the easier approach.

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

  • 2 weeks later...

Mist 3.0

 

I think Mist v3 is ready for release so here it is. The big changes with this release is the integration of my "Spawn Clone Teleport" script directly into Mist. Also the DBs will now update if groups are dynamically added to the mission. After this release it is my intention is to release several smaller updates adding at least a few functions per release. At the moment the functions I have in mind are related to dynamically spawning groups and some useful features for that. Basically its everything I was going to put into sctv3.

 

V3 Changelog.

 

Message Functions

- mist.message.removeById added

- mist.message.remove functionality changed (see Syntax Changes note at bottom)

- miss.message.add updated to accept a vars.sound variable. This allows you to play audio messages with text messages.

- added mist.msgMGRS

- added mist.msgLL

- added mist.msgBR

- added mist.msgBRA

- added mist.msgBullseye

- added mist.msgLeadingMGRS

- added mist.msgLeadingLL

- added mist.msgLeadingBR

 

Updated Functions/Fixes

- Some Flag funcs now accept a toggle variable. This will set the flag to false when the conditions aren't met. Applies to:

-mist.flagFunc.units_in_polygon

-mist.flagFunc.units_in_zones

-mist.flagFunc.units_in_moving_zones

-mist.flagFunc.units_LOS

- mist.getRandPointInCircle now accepts both vec 2 and 3 coordinates

- fixed mist.getUnitsInZones and mist.getUnitsInMovingZones to return only activated units

- Fixed bug with DBs where countryId was the mission table index of the country table and not the actual country Id

- Reorganized documentation a bit

- Fixed bug with how functions called mist.toStringLL

- bug with mist.removeFunction should be fixed now.

 

Spawn Clone Teleport Script merged and renamed functions

-- Added mist.dbUpdate()

-- added mist.dynAdd()

-- added mist.getCurrentGroupData()

-- added mist.getGroupData()

-- added mist.getPayload()

-- added mist.teleportToPoint()

-- added mist.respawnInZone()

-- added mist.teleportInZone()

-- added mist.cloneInZone()

-- added mist.respawnGroup()

-- added mist.cloneGroup()

-- added mist.teleportGroup()

- added mist.isTerrainValid

 

Database Updates

- added alt and alt_type to units databases

- Added startTime to group tables

- Country names in DBs are all now lower case.

- added mist.DBs.dynGroupsAdded

- added mist.DBs.MEunits

- added mist.DBs.MEunitsByName

- added mist.DBs.MEunitsById

- added mist.DBs.MEunitsByCat

- added mist.DBs.MEunitsByNum

- added mist.DBs.MEgroupsByName

- added mist.DBs.MEgroupsById

- added mist.DBs.const

 

The following DBs now update as groups are dynamically spawned:

- mist.DBs.groupsById

- mist.DBs.groupsByname

- mist.DBs.units

- mist.DBs.unitsByName

- mist.DBs.unitsByCat

- mist.DBs.unitsByNum

 

If groups are dynamically spawned outside of Mist, the DBs will still update. NOTE: With DCS 1.2.5 this is ONLY true of aircraft and helicopters. Future patches might fix this, currently unknown at the moment. Also Mist will attempt to generate new group and unitIds if the new spawned group/unit Ids are close to what mist is currently using.

 

 

 

Syntax Changes/Stuff that could potentially mess with scripts

mist.message.remove updated so it accepts a self variable. This is mainly for mist to use the mist.message class, but it is accessible globally.

mist.message.removeById added; essentially has the same functionality as the old mist.message.remove, so if you had used mist.message.remove please change it to removeById

Several DBs now update for dynamically spawned groups. If a new groups spawns with the same name as an older group it will effectively replace the older group.

Country names in all DBs are all now lower case. This was changed so that dynamically spawned groups could be updated within the DBs.

mist.message.add now accepts a "sound" vars to play audio. Due to how it is implemented, Combined Arms players will be UNABLE hear any sounds.

 

Mist 3.1 Download


Edited by Grimes
Remove 3.0 Download, replaced with 3.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

no sound with msg

 

I cannot get the new option to play a sound with the mist message system to work. Here is the OLD version that works,

 

trigger.action.outSoundForCoalition(coalition.side.RED,'Sound File.wav')

local msg = {}

msg.text = 'Text here'

msg.displayTime = 10

msg.msgFor = {coa = {'red'}}

mist.message.add(msg)

 

Here is the NEW version that does not work:

 

local msg = {}

msg.text = 'Text here'

msg.displayTime = 10

msg.msgFor = {coa = {'red'}}

msg.sound = 'Sound File.wav'

mist.message.add(msg),

 

there is no sound. What am I doing wrong? Yes, I checked the sound file is contained in the .miz file

 

help!

[sIGPIC][/sIGPIC]

 

Intel Core I7 4820K @4.3 GHz, Asus P9X79 motherboard, 16 GB RAM @ 933 MHz, NVidia GTX 1070 with 8 GB VRAM, Windows 10 Pro

Link to comment
Share on other sites

I'll add it to the documentation asap.

As for sound, are you in an aircraft?

 

The way the mist message system works is it sends every message to each client or player skill level aircraft. It does this because the messages can be unique for each player if you wanted it to be. Due to how Combined Arms works, the message system does a cheap trick where it displays and outTextForCoalition first and then it is completely overwritten (for clients) with an outTextForGroup. I didn't include an outSoundForCoalition as part of the code for CA as I didn't want others in the team to hear it. Although with mist 3.1 I should probably change it to allow for messages to coa to be played for the whole coalition.

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

Yes, client UH-1H

 

I found the issue. Will try to add an audio output exception for coa while I'm at 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

Thanks for the update Grimes!

 

I've converted the tests from my SCT issues over to Mist v3, these are the results:

 

While creating a script to respawn tankers, I encountered some strange issues. But I am not sure whether it's a problem with SCT or the SSE:

 

  1. Case: Tanker Airstarting
    sct.cloneGroup('Tanker_Arco', true)
     
    Result: The second tanker appears with the engines off, diving into the ground

Now with mist.cloneGroup:

The tanker starts in the air, with 0 speed, stalls out and dives downwards, but has the engines on and can recover.

 

2. Case: Tanker Rampstart

sct.cloneGroup('Tanker_Arco', true)

 

Result: Exactly the same, the second tanker appears (in air!), engines off, nosediving

While he airstarted at 6000 feet with sct, he now does at about 100. Although the engines are now running as in Case 1, the 100 feet are obviously not enough to recover from the 0 speed and it crashes.

 

3. Case: As a workaround, I tried to build the group data and create the group with sct.dynAdd:

local group = sct.getGroupData('Tanker_Arco')

group.route = { points = mist.getGroupRoute('Tanker_Arco', true) }

sct.dynAdd('USA', 'AIRPLANE', group)

 

Result: Good so far. The original group despawns of course, the new tanker starts up and takes off

New code, same result:

local group = mist.getGroupData('Tanker_Arco')

group.route = { points = mist.getGroupRoute('Tanker_Arco', true) }

group.country = 'USA'

group.groupType = 'AIRPLANE'

mist.dynAdd(group)

 

4. Case: Since I don't want a respawn but a clone, my next step was to remove the unit/goup names/ids from the collected data:

local group = sct.getGroupData('Tanker_Arco')

group.route = { points = mist.getGroupRoute('Tanker_Arco', true) }

group.groupName = nil

group.groupId = nil

group.units[1].unitId = nil

group.units[1].unitName = nil

sct.dynAdd('USA', 'AIRPLANE', group)

 

Result: The original tanker does it's thing. Starts up and takes off all well. The new group however spawns in, turns the engines off and will sit around idle

 

Now things get a bit weird.

local group = mist.getGroupData('Tanker_Arco')
group.route = { points = mist.getGroupRoute('Tanker_Arco', true) }
group.country = 'USA'
group.groupType = 'AIRPLANE'
group.groupName = nil
group.groupId = nil
group.units[1].unitId = nil
group.units[1].unitName = nil
mist.dynAdd(group)

Result:

00023.635 ERROR DCS: Mission script error: : [string "--[[..."]:4576: bad argument #1 to 'lower' (string expected, got nil)

stack traceback:

[C]: ?

[C]: in function 'lower'

[string "--[[..."]:4576: in function 'getPayload'

[string "--[[..."]:4473: in function 'dynAdd'

[string "local group = mist.getGroupData('Tanker_Arc..."]:9: in main chunk

 

If I do group.units[1].unitName = 'bla', it'll do the same as with sct, spawn a new tanker that sits idle on the ramp

 

It seems to me that there is a check missing that getPayload doesn't get called in cases like this. So I tried to commenting the line out and the tanker spawned with unitName = nil and sat idle on the ramp again.

 

5. Case: The same code as 4 with the tanker air starting

 

Result: This is where the circle closes. The new tanker spawns in, engines off, nosediving into the ground.

 

I then created the group data by taking the complete group informations out of the mission file, changed the group/unit names/ids and called coalition.addGroup and everything worked as it should, the second group spawned and took off.

So it's my impression that something within SCT doesn't work out

 

Same as 4


Edited by St3v3f

aka: Baron

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Thanks for the detailed testing. I was out of town yesterday so I didn't really have a chance to figure out what was going on with it, but I'm in the process of fixing it right now. There should be an update either later today or tomorrow.

  • 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

Mist 3.1

 

Attached mist 3.1.

 

Changelog

- fixed bug with sending sounds to clients

- if an audio message is sent to a correct coalition or 'all', CA players will now hear it

- added speed entry to units DBs (applies only to aircraft)

- fixed typo with mist.respawnGroup returning a nil value

- modified mist.cloneGroup, mist.teleportGroup, mist.respawnGroup behavior if task variable is given.

--If task is anything except for a number, the task become the groups default route.

--if task is a number, then the route will be assigned after however many seconds you specify.

- mist.dynAdd now accepts a route variable as part of the table passed to it

- overloaded mist.dynAdd to accept route data if the points part of the table is missing ( groupTable.route[1]... instead of the correct format groupTable.route.points[1]...)

- fixed mist.getPayload, must now be sent a string

 

 

The plan for mist 3.2 is to fix anything else you guys discover, but also include some fun group manipulation functions. For example splitGroup, joinGroup. Stuff like that. Also once the 1.2.6 Open beta gets released I will release the first version of my IADS script. :)

 

In the mean time, I'll be working toward porting mist documentation to also be available via a wiki page. Until we get the ED wiki back I'll be updating the info on the Hoggit Wiki. I'll also update the scripting engine wiki pages there as needed for 1.2.5 and 1.2.6.

 

 

St3v3f thanks again for testing that and providing thorough results and methods. Just to be informational the problems with the bugs were...

1 and 2: Adding alt and alt_type to DBs caused a knock-on effect where a default speed was not assigned to the units. Thus I added speed to the DBs and created an additional check to add speed if its not there.

4 and 5. The aircraft didn't get fuel as part of its payload, thus it crashes. The payload script has been updated to check if its been passed a string value.

 

Generally speaking payloads in the scripting engine are currently a pain to deal with. To spawn a group you need the mission editor data which generally consists of CLSIDs for weapons, the scripting engine does not have access to CLSIDs. Also the getFuel() function returns the fuel state between 0 and 1 (or more if fuel tanks are on). Spawning an aircraft uses the actual fuel weight, which again is not accessible to the scripting engine.

 

@wolle, You will now find 2.5 pages worth of documentation on mist.dynAdd

Mistv3_1.rar

  • 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

Excellent job Grimes, wish I could +rep you again

 

+1

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

Hi Grimes, I started using MIST3.1 yesterday and I'm interested in using the mist.groupToRandomPoint function called on group itself as group and a using mist.getGroupPoints upon a single unit whitout route to get the Vec3 of the point.

 

this is how the code looks but it does not work: seems it can't find the Vec3 point. This is the script text:

 

local sg = ...

local pt = mist.getGroupPoints("Destination_Point")

 

mist.groupToRandomPoint



{

group = sg,

 

point = pt,



radius = 100

}



 

I can't understand the error.

 

PS: an idea:

 

it may be useful if this function could be called on a large number of group, as a group table, and activated only on a defined percentage of these groups each time. Maybe the best solution could be use the group's table as a database updated every "n" minutes using custom conditions (i.e. LOS to a enemy group, proximity to a defined table of zones, etc).

 

For example, It could be called to move "n" group toward a point far away to simulate axis of advance and stopping groups after 10 minutes. then called again after "n" minutes to resume movement (overwriting previous route) and so on.

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 don't know if this has been reported yet, but when I tested the mist.respawn script with an airplane that respawns in parking hot, the respawned airplane was bugged and kept crashing at the respawn spot.

 

Not sure if it has been fixed in 3.1 but thought it's importent to mention.

Link to comment
Share on other sites

getGroupPoints won't work for that because it returns a vec 2 table and not a vec3 table. Furthermore its not formatted the correct way anyways.

 

The point variable needs to be formatted like this:

{x, y, z}

 

getGroupPoints returns the following even if the group has no waypoints.

{[1] ={x, y}}

 

I'd recommend using either mist.getLeadPos or mist.getAvgPos to get the position of a unit to turn it into a vec3 point. Also if the units name is known you could just use. point = Unit.getByName('myUnit'):getPosition().p

 

Yeah there could probably be a "send random groups to random points" function. I've been thinking about how to best track orders and tasks given to AI to utilize as an AI enhancement mod of sorts, but it might be outside the scope of something to be built into mist.

 

xcom, try it in 3.1 as I made several fixes to the spawn scripts. Although I have yet to try it all out in 1.2.6.

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've been really dumb :s : I didn't notice that it was Vec2. I'll try again following your suggestion :).

 

PS:

I'm REALLY looking forward your IADS scritp :)

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

Thank you Grimes and St3v3f for the effort it is greatly apreciated.

 

I have 2 problems with Dynadd and I don't know if it s a bug or a lack of skill on my part

 

1) I have a group of Su-25T attacking randomly targets one at a time. Once one group is destroyed the Su-25T go back to base and respawn via Dynadd. So far so good. However the 2nd time it looks like the order attack group is not carried out. (Also the destoyed group is not respawning but it s a mistake on my part with the flag).

 

2) every time i exit the mission to go back to the editor DCS crashed. I wonder if it s not due to DynAdd in 1.2.6 (in 1.2.5 with mist 3.1 I had no problem). I tried other missions without Dynadd and there is no crash.

 

Also how do I add mist.schedulefunction with dynadd?

mist.scheduleFunction(dynadd(Group), {101, true}, timer.getTime() + 40)

 

Thank you.

test randomtarget.miz

Link to comment
Share on other sites

Hi,

 

I tried to used a MIST function called on "self" as a triggered action in a 3-unit BTR-80 group, but it does not work.

 

This is the error:

 

[string "local gp = ......"]:3: attempt to index a nil value

stack traceback:

[C]: ?

[string "local gp = ......"]:3: in main chunk

 

This is the function:

local gp = ...

 

local pointDest = Unit.getByName("Polygon Group 1"):getPosition().p

 

mist.groupToRandomPoint{gp,pointDest,100}

 

Any suggestion?

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

error to PDF version 3.1

 


[left]mist.respawnGroup[/left]


table mist.respawnGroup (string groupName, boolean/number task)



[left]mist.cloneGroup[/left]


table mist.respawnGroup (string groupName, boolean/number task)

 

 

to

 



[left]mist.respawnGroup[/left]


table mist.respawnGroup (string groupName, boolean/number task)



[left]mist.cloneGroup[/left]


table mist.cloneGroup (string groupName, boolean/number task)

====VIAF====

Spinter 155° "Pantere Nere"

 

TsSimComms

 

My Site aiupgrade.net

 

 

 

Link to comment
Share on other sites

IADS=International Association of Dental Students? Can you elaborate?

 

Integrated Air Defence System

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

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