Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

  • 2 weeks later...

Question:

I have 3 different SAM groups, selected for late activation in the ME.

If I want to randomly select any 1 group to spawn at a random time, by setting a time limit range, then what will be the lua code?

Can somebody please help..... :helpsmilie:

Rig - I7-9700K/GIGABYTE Z390D/RTX-2080 SUPER/32-GB CORSAIR VENGEANCE RAM/1-TB SSD

Mods - A10C / F18C / AV8B / Mig21 / Su33 / SC / F14B

Link to comment
Share on other sites

Rephrasing the Question:

How to spawn a randomly selected group from a given group names, that spawns at a particular trigger location at a random time? :helpsmilie:

Hope I get the answer this time.....:(

Rig - I7-9700K/GIGABYTE Z390D/RTX-2080 SUPER/32-GB CORSAIR VENGEANCE RAM/1-TB SSD

Mods - A10C / F18C / AV8B / Mig21 / Su33 / SC / F14B

Link to comment
Share on other sites

Apolloace, assuming that you pre-defined the groups in the editor and set them all to delayed start, as well as defined the zone:

 

NOTE: MiST makes this stuff super easy

 

1) Define a list of group names.

local groupNames = {"Group1", "Group2", "Group3"}

2) Choose a random group name.

local groupName = groupNames[mist.random(#groupNames)]

3) Figure out how many seconds from now that you want it to respawn.

local randomTime = timer.getTime() + mist.random(120) // up to 120 seconds in the future

4) You will need to have something that checks the current time to trigger the spawn. A simple approach would be to create a new scheduled function that fires immediately and checks each second thereafter.

 

local timerNum = mist.scheduleFunction(checkTime, {groupName, randomTime}, timer.getTime(), 1)

5) Create the new function that checks the current time against the desired spawn time.

 

function checkTime(obj)
if timer.getTime() >= obj.randomTime then
 mist.respawnInZone(obj.groupName, "myZone")
end
end

This should work, although it is from memory and not verified. There is some extra code that could be written to stop the timer. Please let me know if you have issues with it.

  • Like 1
Link to comment
Share on other sites

 

I am already aware of that. Anyway thanks for your reply. :)

 

Apolloace, assuming that you pre-defined the groups in the editor and set them all to delayed start, as well as defined the zone:

 

NOTE: MiST makes this stuff super easy

...................................................................

.............................................................................

 

This should work, although it is from memory and not verified. There is some extra code that could be written to stop the timer. Please let me know if you have issues with it.

 

Thanks for your reply with the suggested codes.

 

I will check this out and let you know. :)

 

Rig - I7-9700K/GIGABYTE Z390D/RTX-2080 SUPER/32-GB CORSAIR VENGEANCE RAM/1-TB SSD

Mods - A10C / F18C / AV8B / Mig21 / Su33 / SC / F14B

Link to comment
Share on other sites

 

Originally Posted by Chump

Apolloace, assuming that you pre-defined the groups in the editor and set them all to delayed start, as well as defined the zone:

 

NOTE: MiST makes this stuff super easy

.................................................. .................

.................................................. ...........................

 

This should work, although it is from memory and not verified. There is some extra code that could be written to stop the timer. Please let me know if you have issues with it.

 

Thanks for your reply with the suggested codes.

 

I will check this out and let you know. :)

 

 

I have checked your codes. It works! :thumbup:

 

Just had to tweak the randomTime & checkTime functions a bit. Otherwise, every thing is fine. :)

 

Again thanks a lot for the help!!

 

Rig - I7-9700K/GIGABYTE Z390D/RTX-2080 SUPER/32-GB CORSAIR VENGEANCE RAM/1-TB SSD

Mods - A10C / F18C / AV8B / Mig21 / Su33 / SC / F14B

Link to comment
Share on other sites

So my conclusion, given if i remove DAWS and use MIST run at mission time, is that its just MIST being called early that's the issue, since the code is all the same.

 

Now...I know you said Chromium, that you tested it and it was working on .73, so if nothing else has changed, its the DCS version that does something different? I'm not going to revert a version to test, as much as I love my QA job here at Eagle Dynamics :) :)

 

As from DAWS thread, I modified the code so that now integrated MIST version in DAWS is loaded at very first second of the mission, that should prevent the issue (it does in the attached test mission with last uploaded DAWS version).

 

@Grimes: I know that this is something that don't belongs to you, but I can't do nothing from DAWS to prevent the double-loading of mist caused by mission designer loading mist code in a trigger (after DAWS). I don't know a way to prevent this in DAWS code. I'm asking you, if you can, to add that "mist is loaded" check in the MIST code, so that if a mist is already loaded it won't load itself again. Do you think it's possibile?

DAWS_SM_AE_test3_teleport.miz

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

  • 1 month later...

Hi all

I look for a script

 

plane group fires = Flag1 on

 

The Plane Group is Bf-109K-4

 

 

 

 

i try this, but it will not work:

 

local Plane = UNIT:FindByName( "Plane" )

 

Plane:HandleEvent( EVENTS.Shot )

 

---

-- @param Wrapper.Unit#UNIT self

-- @param Core.Event#EVENTDATA EventData

function Plane:OnEventShot(EventData)

 

if EventData.WeaponName == "weapons.MG_131" then

MESSAGE:New("Plane shot Gun",15,"Alert!"):ToAll()

local Task = EventData.IniGroup:TaskOrbitCircle( 5000, 450 )

EventData.IniGroup:pushTask( Task, 30 )

end

 

end

Link to comment
Share on other sites

The shot event is for all non rapid fire shell based weapons. You need to use the event shooting start. This event does not return any weapon data, only the initiator, but it will occur anytime a rapid fire gun is fired. You would need to either know the aircraft type and its associated MG ammo type or use world.searchObjects in the immediate area around the initiator aircraft to find the shell and get the name type.

 

So take an M1 Abrams for example. The main cannon would produce a "SHOT" event with HE and AP shells. The coaxial and commander turret will create "SHOOTING START" and "SHOOTING STOP" events. In the case of aircraft that have more than one gun that can fire at a time, each one will create a shooting start/stop events.

 

By the way it is not ideal to post questions related to a specific scripting library in a different scripting thread. In this case posting moose code in the mist thread. So while I will answer questions specifically related to the scripting engine in general here, I can't really help you with the moose side of things.

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

To save me from reading through 127 pages and is a daft question but does MIST need to be installed on the server or can I just install it to my local laptop create the mission and then export to a dedicated server? Apologies for my noobishness.

EVGA GTX1080TISC2 Black Hybrid Cooler, Asus Strix X399, Water cooled ThreadRipper 1920X, Dominator 32GB 3200Mhz,NVME Samsung 250/500GB SSDs, Corsair Air 740 case, Acer Predator 34' Gsync curved display + 3x Alienware 23inch 120hz monitors. TM HOTAS, RAZER - Tiamat,Blackwidow, Mamba, Tartarus and Oculus Rift CV1/DK2 + TrackIR5, MFG crosswinds

 

Oh and a very understanding wife.

Link to comment
Share on other sites

It is a mission script. You add it as part of a trigger, usually Once> Time Less than 10> Do Script File(mist.lua) works quite well. So by adding to execute as part of a trigger it will automatically embed the mist file into the mission file. Once the trigger runs in the mission all of the mist functions and tables are globally accessible. Its up to you to make a script that uses 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

You are going to have to be more descriptive with your question. I don't understand what exactly you are asking.

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 are going to have to be more descriptive with your question. I don't understand what exactly you are asking.

I have group 'g1' and uses this script:

if not Group.getByName('g1') then
 mist.respawnGroup('g1', 100)
end

Respawn after 100s.

In DCS 1.5 'g1' respawn at once.

test.miz

CPU: i7-8700K @5200MHz / RAM: G.Skill Trident Z 2x16GB @3500MHz CL15 / MB: ASUS PRIME Z370-A / GPU: ASUS STRIX RTX 2080 / DCS-Storage: Samsung 960Evo 500GB / Thrustmaster Hotas Warthog + T.Flight Rudder Pedals

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

@Yappo, I think you are misunderstanding the parameters.

string mist.respawnGroup(string groupName, boolean/[b]number[/b] task/[b]taskDelay[/b])

The group will always respawn immediately. If the taskDelay parameter is present, it will re-assign their original route after the specified number of seconds.

Link to comment
Share on other sites

@Yappo, I think you are misunderstanding the parameters.

string mist.respawnGroup(string groupName, boolean/[b]number[/b] task/[b]taskDelay[/b])

The group will always respawn immediately. If the taskDelay parameter is present, it will re-assign their original route after the specified number of seconds.

I understood. Thanks.

CPU: i7-8700K @5200MHz / RAM: G.Skill Trident Z 2x16GB @3500MHz CL15 / MB: ASUS PRIME Z370-A / GPU: ASUS STRIX RTX 2080 / DCS-Storage: Samsung 960Evo 500GB / Thrustmaster Hotas Warthog + T.Flight Rudder Pedals

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Are respawnInZone and teleportInZone working for player groups? I can respawn the player using the basic respawnGroup, but when I try to use respawnInZone I get "Err: Can't execute trigger. Err: "mist.respawnInZone('PlayerGroup', 'SpawnZone', false)"

 

Substituting a non-player group works fine with no other changes to the syntax

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