Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

I can get the aircraft to respawn just fine. I use a "time since flag" condition so it delays the aircraft a little bit followed by a "if not Group.getByName('') then mist.respawnGroup('', true)
 end" script. That's on a switched condition using flags. I can't get ground vehicles to respawn after the get taken out. Im pretty new at using MIST. Is there something im missing when it comes to the ground units?

 

Link to comment
Share on other sites

In general there have been some oddities with simply relying on checking Group.getByName to know if a group is actually dead. There is a mist function mist.groupIsDead that you can use that handles the exceptions to the rule. 

if mist.groupIsDead(groupName) == true then
  -- do code to respawn group or whatever. 
end

 

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

Apologies if this is not the best place to post a possible bug.

Also... much thanks to Grimes and the community for keeping MIST going. Awesome body of work.

Was using the function mist.getWindBearingAndVel in version mist_4_5_107.

Seems this is in error:

    function mist.getWindBearingAndVel(p)
        local point = mist.utils.makeVec3(o)   <--- should be the point table "p" passed into the function ?

Also... the simple trig function:

local bearing = math.tan(t.z/t.x)

is intended to give wind direction in radians, but I am getting some wacky numbers back when I convert to degrees.

Link to comment
Share on other sites

8 hours ago, Cheyenne56 said:

Was using the function mist.getWindBearingAndVel in version mist_4_5_107.

It was fixed on development build back in July: https://github.com/mrSkortch/MissionScriptingTools/commit/2c54802861b97bcd581664d4f9e23191fd72539c

I should probably merge it to the main build. 

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

Hello, I´m just taking my first steps with MIST or .lua in general and I´m having a hard time figuring out the basics...

What I´m trying to do is spawn a random group within a random spawn zone.
For testing, I setup a simple mission with three trigger zones (Spawn-1, Spawn-3 and Spawn-3) and three ground units (Ground-1, Ground-2 and Ground-3)
I managed to get the random Spawn zones to work with a single unit, but I can´t get the script to pick one random group of the three defined ground units.

This is my script so far:


local z = {'Spawn-1', 'Spawn-2', 'Spawn-3'}
local g = {'Ground-1', 'Ground-2', 'Ground-3'}
mist.respawnInZone(g, z)

In the wiki it says mist.respawnInZone(string groupName ,string/table zoneName/tableOfZoneNames

as it only mentions the tables for zone names, I assume, it doesn´t work the same way with groups ?
Is there a simple way to make this work ? 

Thanks

Link to comment
Share on other sites

18 hours ago, Eugel said:

as it only mentions the tables for zone names, I assume, it doesn´t work the same way with groups ?
Is there a simple way to make this work ? 

It has to be passed a specific group that you want to spawn in that zone. You can randomize it before hand with something as simple as. 

 

local z = {'Spawn-1', 'Spawn-2', 'Spawn-3'}
local g = {'Ground-1', 'Ground-2', 'Ground-3'}
mist.respawnInZone(g[math.random(#g)], z)

So what that does is its using the size of the g table as the max value for math.random. Thus it'll pick a random number between 1 and 3. Think of it as g[2] for example, which means it is passing the value at index 2 of the g table,  which is "Ground-2". 

  • Thanks 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

  • 1 month later...
3 hours ago, Six Gun said:

Is there a MIST version past 4_5_107 or is that one the latest version?

Select the develop branch on github. I remain terrible at adding to one version and pushing the commits to the other. 

  • 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

Hi, i'm new on Mist,

I'm trying to teleport a unit to a moving zone or trigger zone linked to a unit. I use mist.teleportInZone but it only works when i untick the link option on trigger zone and make static.

I'm doing something wrong?  is it possible to teleport a unit into a moving trigger zone?

 

thanks!

Link to comment
Share on other sites

On 2/7/2023 at 9:54 AM, epy123 said:

Hi, i'm new on Mist,

I'm trying to teleport a unit to a moving zone or trigger zone linked to a unit. I use mist.teleportInZone but it only works when i untick the link option on trigger zone and make static.

I'm doing something wrong?  is it possible to teleport a unit into a moving trigger zone?

 

thanks!

It might be a bug with mist that it doesn't work if link is checked, I'll have to test. 

However last I remember a moving trigger zone doesn't actually move, it just uses information about that zone and applies it to the unit it is "attached" to. Mist doesn't At one point I think the zone was still active where-ever it was on the map, but I digress. 

To answer your question you can directly just call mist.teleportToPoint directly. Its actually what mist.teleportInZone uses to do the teleporting, it just fills in the values as needed. 

 local vars = {} 
  vars.gpName = 'group1' 
  vars.action = 'teleport' 
  vars.point = Unit.getByName("UnitNameYouWantToTeleportNear"):getPoint() 
  vars.radius =  20 -- match the radius of the zone you have set. 
  mist.teleportToPoint(vars) 

 

2 hours ago, Six Gun said:

Trying to figure out how to make a mission persistent. Is this something that can be done with MIST or is it a different script tool that you guys are using to do that?

Persistence is all about saving data to a file and then reading that file on the next load. As a result you end up needing to allow io and lfs to exist via modifying MissionScripting.lua. io for opening and writing files. lfs because its useful to get your saved games folder without hard-coding the file path in. 

I do use mist when it comes to writing the data. Either mist.utils.oneLineSerialize or mist.utils.serialize are most useful in this regard. If I'm being lazy and just want to write a whole table on each go I'll use mist.debug.writeData. 

  • 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

En 9/2/2023 a las 0:50, Grimes dijo:

It might be a bug with mist that it doesn't work if link is checked, I'll have to test. 

However last I remember a moving trigger zone doesn't actually move, it just uses information about that zone and applies it to the unit it is "attached" to. Mist doesn't At one point I think the zone was still active where-ever it was on the map, but I digress. 

To answer your question you can directly just call mist.teleportToPoint directly. Its actually what mist.teleportInZone uses to do the teleporting, it just fills in the values as needed. 

 local vars = {} 
  vars.gpName = 'group1' 
  vars.action = 'teleport' 
  vars.point = Unit.getByName("UnitNameYouWantToTeleportNear"):getPoint() 
  vars.radius =  20 -- match the radius of the zone you have set. 
  mist.teleportToPoint(vars) 

Persistence is all about saving data to a file and then reading that file on the next load. As a result you end up needing to allow io and lfs to exist via modifying MissionScripting.lua. io for opening and writing files. lfs because its useful to get your saved games folder without hard-coding the file path in. 

I do use mist when it comes to writing the data. Either mist.utils.oneLineSerialize or mist.utils.serialize are most useful in this regard. If I'm being lazy and just want to write a whole table on each go I'll use mist.debug.writeData. 

It's work!! thank you a lot.

 


Edited by epy123
Link to comment
Share on other sites

  • 3 weeks later...

heyo - new to mist/lua/scripting here;

-I've been reading the docs, scripting up some examples & tests... and come upon a question- hope this is the right place to ask...


...it looks to me like there's various trigger.actions for a lot of the actions available in the mission editor (ex, trigger.action.outSound = the "play sound file" action). 

-But I don't see a trigger.action for the various (somewhat newer) 'show picture to ____' actions?


-Can I somehow trigger a 'show picture to ____' action from a lua script? 

Any info would be much appreciated, thanks!


 

Link to comment
Share on other sites

6 hours ago, MegaTherion666 said:

-But I don't see a trigger.action for the various (somewhat newer) 'show picture to ____' actions?


-Can I somehow trigger a 'show picture to ____' action from a lua script? 

Correct they haven't added a scripting function for it yet. There are a few others like that unfortunately. As for how to activate it via script the only way to do it is to have a trigger and make the condition for it to become true. Easiest way is with flag is true and you simply set the flag state via script when you need it to be called. 

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

Good morning everyone

I'm using the latest version of Mist on our server.
Every time any player destroys an Oil Rig or Gas platform, the server crashes and this message appears:

1.png

2.png

I have tried with old versions and the same thing happens.
Also, I tried removing all the triggers and leaving only Mist, and the problem persists.
Any ideas?

Thank you


Edited by Colmillo

[sIGPIC][/sIGPIC]

Intel(R) Core(TM) i9-10900KF CPU @ 3.70GHz   3.70 GHz ROG STRIX Z490-E GAMING
RAM 128 M.2*2 2T total SSD*3 2.5T total
GeForce RTX 3090   Orion2 HOTAS F-16EX  Saitek Pro Rudder

Link to comment
Share on other sites

  • 1 month later...

Hi avrora74

Here are two ways with Mist that you may be able to use --

-- the zone is defined by 6 unit locations, 02 Yellow Zone ZGrp #001, through 02 Yellow Zone ZGrp #006
-- this is not the best way
mist.flagFunc.units_in_polygon{
    units = {'Blue VGrp01'},
    zone = {
        [1] = mist.DBs.unitsByName['02 Yellow Zone ZGrp #001'].point,
        [2] = mist.DBs.unitsByName['02 Yellow Zone ZGrp #002'].point,
        [3] = mist.DBs.unitsByName['02 Yellow Zone ZGrp #003'].point,
        [4] = mist.DBs.unitsByName['02 Yellow Zone ZGrp #004'].point,
        [5] = mist.DBs.unitsByName['02 Yellow Zone ZGrp #005'].point,
        [6] = mist.DBs.unitsByName['02 Yellow Zone ZGrp #006'].point,
    },
    flag = 50127,
    toggle = true,    
}

-- define the zone with a single hidden unit using its waypoints
mist.flagFunc.units_in_polygon{
 units = {'[blue][vehicle]','[-g]Blue ZGrp30 Armor'},
 zone = mist.getGroupPoints('Blue ZGrp30 Armor'),
 flag = 73008,
}


 

 

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

Hello All,

I'm trying to use MIST to indicate the color of the forces controlling an airbase. A white circle for neutral, red circle for red forces and blue circle for blue forces. I've been able to get only one airbase to show the circle and change colors. When I try to add another air base, just the one base works. Being new at this, I have read so many how to's, I have done nothing but confuse myself. Any help to clear my mind would be greatly appreciated. miz file included

 

World Conquer STEP 2.miz

Link to comment
Share on other sites

@SC_SquadCentral You are using the same ID (1) for both circles. Try using another ID, like this:

local ref = trigger.misc.getZone("Krymsk")
trigger.action.circleToAll(-1, 2, ref.point, ref.radius, {0, 0, 0, 0}, {1, 0, 0, .7}, 0, true) -- notice the second parameter is now 2

Than you can use that ID to alter the color:

trigger.action.setMarkupColor(2, {0,0,1,1}) -- there is no third parameter

Also, trigger.misc.getZone() only takes a single string parameter.

local ref = trigger.misc.getZone("Novo", "Krymsk") -- only one zone at a time!

I'm not seeing that you are actually using MiST (or CTLD) at the moment...

Link to comment
Share on other sites

  • 2 months later...

Hi all,

I'm trying to manipulate the radios on Late Activation AI groups, with the idea that using mist.respawnGroup on that Late Activation group will inherit the new radio freq and AI Option state (basically what I'm trying to do is prevent all AI units from communicating with players in our team's missions, by moving them to an uncommon freq, and using Silence where available). 

So it works great with active units, but I only want to run this function once at mission startup, and not have to re-run it every time a mist.respawnGroup is initiated. What I'm seeing though, is that while no error gets thrown when I attempt to update the Late Activation group, the respawned group appears to inherit the original radio state/freq.

This is a snippet of what I'm doing to silence the radios:

IAIRF.SetFrequency = { 
  id = 'SetFrequency', 
  params = { 
    frequency = 256000, 
    modulation = radio.modulation.AM, 
  } 
}

	for i, gp in pairs(coalition.getGroups(coalition.side.BLUE, Group.Category.AIRPLANE)) do
		if not ((#gp:getUnits() > 0 and gp:getUnit(1):hasAttribute("Tankers")) or groupsOfHumansByName[gp:getName()]) then
			-- its not a blue tanker, its not a blue player, so silence the radios
			env.info(gp:getName() .. " being silenced", true)
			gp:getController():setOption(AI.Option.Air.id.SILENCE,true)
			gp:getController():setCommand(IAIRF.SetFrequency)
		end
	end

this is how I'm respawning the Late Activation unit:

mist.respawnGroup("late activation group", true)

i'm testing it on an AWACS by hopping in a client aircraft and trying to get Bogey Dope on the radio freqs. When I use the above silence logic on an active AWACS, I see evidence they have moved to 256AM. When run the silence logic on the Late Activation AWACS, then respawnGroup him, this group appears to be on the original 251AM freq, per the ME.

Appreciate any insight someone might have, maybe this just doesn't work with Late Activation. Thanks,


Edited by Zyll
Link to comment
Share on other sites

On 7/18/2023 at 12:18 PM, Zyll said:

So it works great with active units, but I only want to run this function once at mission startup, and not have to re-run it every time a mist.respawnGroup is initiated. What I'm seeing though, is that while no error gets thrown when I attempt to update the Late Activation group, the respawned group appears to inherit the original radio state/freq.

AI won't accept the commands while they are late activated or uncontrolled. What you can do is modify the frequency that gets set in the group that spawns in.

local gp = mist.getGroupTable("whatever")
gp.frequency = 256  -- freqyncy set via editor is in this format because who cares about consistency
mist.dynAdd(gp)

Silence is a little more tricky but still doable by adding the task to the AI's task queue. See this page as an example. 

https://wiki.hoggitworld.com/view/DCS_exam_group_plane

It gets tricky because the formatting of the table can be changed based on the tasks that are assigned on a given waypoint. Best to place an AI unit with the task, save the mission, then open that mission archive, then load the mission file into a text editor to get the formatting used. You can assign the frequency there too if you wanted.

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