Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

waiting the bug fixed

i have done this addon in your mist file (and all seem okay)

 

local function isGroupAlive(groupName)
   local groupUnits = Group.getByName(groupName)
   local unitsAlive = {}
   local i = 1
   if groupUnits ~= nil then
       groupUnits = groupUnits:getUnits()
       if groupUnits ~= nil and #groupUnits > 0 then
           for i = 1, #groupUnits do
               if groupUnits[i]:getLife() > 0 then
                   table.insert(unitsAlive, groupUnits[i])
               end
           end
       end
   end
   return #unitsAlive > 0
end

and in the mist alive function

 

you test

 

if isGroupAlive(groupName) == true then

and false for dead function

 

i am not expert in lua, may be there is better coding than mine.

 

thierry


Edited by Frenchy
Link to comment
Share on other sites

getUnits() is thankfully returning only alive units, so comparing the size of the table should be enough.

 

Fix is live on release branch of github btw.

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

Custom Zones and the mist.respawnInZone command

 

Hi all,

 

I was hoping someone could help me with a problem I've been trying to work out for a few days now. I'd like to use custom zones like those that can be created with the command:

 

mist.getGroupPoints(Zone1)

 

that can be used in some of the flag functions like "mist.flagFunc.mapobjs_dead_polygon()"

 

but instead use these custom zones in functions like

 

mist.respawnInZone('Group', {'Zone1', 'Zone2', etc..}, Boolean, number)

 

where zones in the second script are defined by the unspawned units from mist.getGroupPoints('Zone1') defining an irregularly shaped polygon.

 

I assume that this needs to be done first by adding the new zone to the missions table of zones (I don't know how to do this) and then calling the zone in the second command as you normally would for a circular zone.

 

I have little experience with Lua, so I apologize if this question is mundane or has already been covered elsewhere - if you point me in the right direction I'll be happy to take a look, I did a cursory search before posting and came up empty.

 

Otherwise, What I'm really looking for is an explanation of how to implement this using the mission editor - or an explanation of why this isn't possible at the present time if that is the case.

 

As always, thanks in advance for all your efforts - Your efforts with the scripting engine have taken this sim far beyond what it was originally.

Link to comment
Share on other sites

hi khlosaet

 

this function is not functional with zone...but group

i have read in pdf

 

mist.getGroupPoints (string/number groupName/groupId)

 

so

in sample given in pdf we have

 

inZone = mist.pointInPolygon(point, mist.getGroupPoints('Polygon Group 1'))

 

that means the group 'Polygon Group 1' has different waypoints and these wp give a polygon

so If point is inside this polygon the value inZone is True


Edited by Frenchy
mistake in sentence
Link to comment
Share on other sites

Hi Frenchie,

 

First off thank you for the response. I think I have not done a good job of communicating my problem... either that, or I haven't understood your answer. I've loaded a sample mission to help illustrate my point. At the beginning of the mission I teleport the tanks from off screen using the following script:

 

mist.teleportInZone('Insurgent Armor Group 1', {'Poti 1', 'Poti 2', 'Poti 3','Poti 4', 'Poti 5'}, true, 500)

 

I only execute this line once, just to place the units on the map at some random position within the zone in the zone table (note these are all the circular zones that are created by default in the mission editor). I then set a switched condition that fires on the condition that "Insurgent Armor Group 1" is DEAD. When this happens I call this script:

 

if not

Group.getByName('groupName') then

mist.respawnInZone('Insurgent Armor Group 1', {'Poti 1', 'Poti 2','Poti 3','Poti 4','Poti 5',}, true, 500)

end

 

This checks for the presence of the armor group and if it is no longer present it respawns it somewhere within the indicated zones (Poti 1, Poti 2, Poti 3, Poti 4, Poti 5). This will happen in this case forever, but it isn't hard to imagine how we could make it happen only for a set number over times, or under a more constrained set of conditions, and how this could really simplify mission design for highly randomized campaigns.

 

So here is what I would like to do.... You see the three fire truck units that I have set to "late activation" with the really oddly shaped routes? I'd like to use the areas encompassed by these routes as my zones in the function above Instead of (Poti 1, Poti 2, Poti 3, Poti 4, Poti 5). It is my hope that this will allow me to work more regularly in regions that mandate irregularly shaped zones (like in the mountain valleys to the North, or close to water for example)

 

Hope this makes the problem more clear.

 

Any idea on how I might accomplish this?

New Effort.miz


Edited by Kholsaet
Link to comment
Share on other sites

Okay, i understand better what you want.. in fact you 'd like a function RespawnInPolygon, so no such function in mist library.

 

you should write a new function for that..(possible but not easy to select a random point inside a poygon (good in math!!)...)

 

what i could to suggest you is to put circles zone inside your zone defined by the waypoint

 

you could put one or more circle to cover the zone (see the mission modified)

 

 

 

the problem with that is if you have 3 zones,if first have 10 circles and the second have 5 circles and last 1 circle (for example) you could understand if you use random zone, you have more chance to respawn in the first zone..

 

if you want equal chance between the 3 polygon, choice a random number between 1 and 3 and following the result respawn random in the circles of the polygon choosen

 

you can use the function math.random(1, 3) to select randomly a number between 1 and 3 and after you test the value and mist.respawn inside the desired zone..

 

hope you understand my poor english

New Effort_1.miz


Edited by Frenchy
Link to comment
Share on other sites

(possible but not easy to select a random point inside a poygon (good in math!!)...)

 

There is probably a more clever and more efficient way to do this, but if all you need is a "good enough" solution (i.e. you won't run this hundreds of times per second), the following should work and be easy enough to implement:

 

1. Calculate an axis-aligned bounding box for your polygon (x_topleft = minimum of all x coords, y_topleft = minimum of all y coords, x_bottomright = maximum of all x coords, y_bottomright = maximum of all y coords)

2. Pick a random point in the AABB, x = math.random(x_topleft, x_bottomright); y = math.random(y_topleft, y_bottomright)

3. Check with mist.pointInPolygon if it is inside your polygon. If not, go back to step 2.

Link to comment
Share on other sites

  • 3 weeks later...

message system messed up in mist 3_7_48

 

Anyone else having troubles with the message system in the latest mist build (mist 3_7_4) ? Same scripts used to work fine in previous builds, but now:

 

(i) if I send a message to a particular coalition (say blue) it displays for all coalitions. The message simply displays for red, but for blue it diaplays the message plus a line above it saying "combined arms message"

 

(ii) messages sent to a particular unit don't display at all.

 

Here is the code I use for displaying text to a particular coalition:

 

 
HS_out = function(coa,outText,outTime) -- function outputs text using the mist message system
 if outText and outTime then
 local msg = {}
 msg.text = outText
 msg.displayTime = outTime
 msg.msgFor = {coa = {coa}}
 msg.sound = HS_radioStaticAudio
 mist.message.add(msg)
end
end 

Here is the code I use for displaying text to a particular unit:

 

 
HS_outUnit = function(forUnit,outText,outTime) -- function outputs text to a specific unit using the mist message system
 if outText and outTime then
 local msg = {}
 msg.text = outText
 msg.displayTime = outTime
 msg.msgFor = {units = {forUnit}}
 msg.sound = HS_radioStaticAudio
 mist.message.add(msg)
end
end

[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

The display code was completely refactored and I ran it through my test mission with everything looking ok. But I'll have another look tonight to see if I can replicate and fix your issue.

 

Edit. Hmmm, can't seem to replicate it with a basic setup. So I'm guessing it occurs under a particular circumstance of messages being sent and displayed. Do you have a sample mission you are capable of sharing for me to test it out on?


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

What am I missing?

This bit of code does nothing. Not even throwing an error.

 

MRGS= {
   UTMZone = "38T",
   MGRSDigraph = "KM",
   Easting = 55829,
   Northing = 81111
}
mist.teleportToPoint({groupName="test", point=coord.LLtoLO(coord.MGRStoLL(MRGS)), action="respawn"})

 

 

EDIT: nevermind, had to give all the parameters for the teleport command.


Edited by Stuka

dUJOta.jpg

 

Windows 11 | i9 12900KF | 64GB DDR4 | RTX 3090 | TM Warthog HOTAS | Saitek Combat Rudder Pedals | TM MFDs + Lilliput 8" | TIR5 Pro

Link to comment
Share on other sites

The display code was completely refactored and I ran it through my test mission with everything looking ok. But I'll have another look tonight to see if I can replicate and fix your issue.

 

Edit. Hmmm, can't seem to replicate it with a basic setup. So I'm guessing it occurs under a particular circumstance of messages being sent and displayed. Do you have a sample mission you are capable of sharing for me to test it out on?

 

Thanks for looking into it. I'll send you a sample mission tonight. A quick question: under what circumstances is "combined arms message" displayed in the line above the actual message? What is that meant to indicate? I don't even own CA.

 

Wolle


Edited by wolle

[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

Thanks for looking into it. I'll send you a sample mission tonight. A quick question: under what circumstances is "combined arms message" displayed in the line above the actual message? What is that meant to indicate? I don't even own CA.

 

The message system works by sending a message to specific groups instead of using coalition, country, or all message triggers. However this doesn't apply to Combined Arms as there is no way to send a message only to CA players in game, so what the script does is it actually sends 2 messages. One is a message to the coalition so CA players can see it which is immediately followed by another message to individual groups. For players in aircraft the coalition message is instantly replaced by the group message.

 

The "Combined Arms message" is just attached to each CA sent message. Its for whenever CA might be receiving a message and player aircraft are not because players will see the coalition wide message. I've put some thought into selectively displaying CA messages based on whether or not CA slots are in the mission, or even sending messages to any ground group that can be controlled (because ground groups can receive messages), however I have not coded any of this yet. So in many respects it is acting as a "backup" for any coalition wide message just in case the message fails to send to each group.

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

Hi Grimes,

 

As promised, I attached two "missions" (it is a highly simplified version of my mission that does nothing but output test texts). They are exactly the same, but one uses the latest mist, and one the previous mist. The latter one works as expected, the prior does not.

 

Would be great if you could figure out what causes this.

 

Thanks, also for the explanation in the previous video.

 

Wolle

test mission for Grimes.miz

test mission for Grimes with old mist.miz

[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

Good news is I think I found it and fixed the issue. The bad news is this should have been discovered and fixed earlier because I swear I had this exact issue occur in a previous version. I also added a little check that will disable the CA messages if there aren't any of those slots in a mission.

 

Fix will get pushed to github tonight.

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

A little help here. I'm just now experimenting with scripts in the ME. How many versions of MIST are out there? I've been searching through the forums and I see:

3.1 in the OP

3.3 in the OP

 

and later I found a 3.4, then there's a 3.5 around the 64th page of this thread...:huh:

 

Which is the latest version that I should use? Is it the 3.7 linked above, or is that some kind of beta? Thanks for your help.

P-51D | Fw 190D-9 | Bf 109K-4 | Spitfire Mk IX | P-47D | WW2 assets pack | F-86 | Mig-15 | Mig-21 | Mirage 2000C | A-10C II | F-5E | F-16 | F/A-18 | Ka-50 | Combined Arms | FC3 | Nevada | Normandy | Straight of Hormuz | Syria

Link to comment
Share on other sites

MiST development has moved to GitHub.

You can always get the current stable release (and also any previous one) from the "releases" page.

 

If it says something like "10 commits to master since this release" next to a release, it means the current development version has changes that are not included in that release. If that is the case for the latest release and you want to try the bleeding-edge development version instead, you can click the "Download ZIP" button on the main page.

 

In general, use the latest release version.

When reporting a bug, also test with the latest development version if possible (obviously, you only need to do that when it is actually different from the latest release).


Edited by [FSF]Ian
  • Like 1
Link to comment
Share on other sites

Thank you. Is there any way to find version 3_5_37? I'm trying to run a script that was made for that version of mist, and the script doesn't work with 3_7_51. I can find some older releases on the site but not that one.


Edited by gavagai

P-51D | Fw 190D-9 | Bf 109K-4 | Spitfire Mk IX | P-47D | WW2 assets pack | F-86 | Mig-15 | Mig-21 | Mirage 2000C | A-10C II | F-5E | F-16 | F/A-18 | Ka-50 | Combined Arms | FC3 | Nevada | Normandy | Straight of Hormuz | Syria

Link to comment
Share on other sites

Speed is off working on his doctorate and has pretty much disappeared. Since he was the one who created the thread I have no control over the first post, so I try to update the 3rd post (my first) in the thread whenever possible. Also in my signature has a link to the latest mist release page on github. You can get older versions of it via the "releases" page on github here.

 

 

What script are you trying to use that doesn't work with the latest version? Backward compatibility is extremely important for mist, so it'd help if I can find and fix any problems related to that.

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