Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

Thank you, Grimes, for your continued hard work and support of this very important tool! S!

Justificus

 

System Specs:

i7 4970K @ 4.8, GTX 1080 SC, 32GB G.Skill DDR 2133,Thermaltake Level 10 Full Tower Case, Noctua NH-D15 6 Cooler, Win 10 Pro, Warthog, CH Pro Pedals, CH Throttle Quadrant, Oculus, 1 32" & 2 19" Monitors

 

 

 

Modules Owned: A-10C I+II, Ka-50, FC3, F-86, Mig-15, Mig21, UH-1H, Mi-8, CA, P-51D, BF-109K-4, FW-190 D-9, Hawk, NTTR, M-2000C, SA342, F-5E, Spit Mk. IX, AJS-37, Normandy, WWII A.P., AV-8B, F/A-18C, L-39, Persian Gulf, Mig-19P, I-16, Super Carrier, F-16, Channel, Syria

Link to comment
Share on other sites

hello all,

 

I am trying to use the range of a SAM as a radius for a mist.flag func unitinmovingzones. Since I dont want to put all the ranges manually, I want the script to get it automatically, but I am not getting there.

 

THis is what I have done so far. But I guess I am doing something wrong...

 

samsites = {'sam1','sam2'} 
for i, v in pairs(samsites) do
local sam = samsites[i]


if sam ~= nil then
local unit = Unit.getByName(sam)
local ammo = unit:Weapon.DescMissile():
local range = ammo["rangeMaxAltMin"]

trigger.action.outText(" the radius is".. range, 5)
end
end

Link to comment
Share on other sites

Hello, it's possibile to separate a single unit from its group (resulting in two groups, one of a single unit and one with the other units)?

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

Should be possible to do that by removing the old group and spawning two new ones

 

Don't like much that solution, but if it's the only one...

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

Hello, it's possibile to separate a single unit from its group (resulting in two groups, one of a single unit and one with the other units)?

 

 

 

You want to control am individual unit in a group? Grimes told that a unit also has an individual controller... That is at least valid for planes...

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Hi, is it possible to script a unit to a designated username or GUID? Scripted so if someone that does not pass the check use the unit get kicked from server?

 

Optionally password for each unit?

 

Thanks.

Link to comment
Share on other sites

MIST teleport issue

 

After the latest 1.5 update(1.5.3.53279), I can't get mist.teleportInZone work properly.

The biggest problem is that the teleported groups won't attack any enemy units.

Respawn function won't work properly either.

 

Any solutions?

 

Please check attachment track file.

test.trk

Link to comment
Share on other sites

Unfortunately it seems a bug in the game was introduced preventing dynamically spawned ground AI from working correctly. Hopefully it will get fixed soon.

 

 

Hijack, your suggestions are outside the scope of mist.

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

Unfortunately it seems a bug in the game was introduced preventing dynamically spawned ground AI from working correctly. Hopefully it will get fixed soon.

 

Thanks for the reply. So it seems that we have to wait for the future update of DCS. Should it be reported as a bug officially? I'm not sure MIST related issues would be treated in official bug report forums.

Link to comment
Share on other sites

Thanks for the reply. So it seems that we have to wait for the future update of DCS. Should it be reported as a bug officially? I'm not sure MIST related issues would be treated in official bug report forums.

 

No its already been reported officially. Report any mist bugs here, if it happens to be a game related bug then I'll report it anyways when I investigate whatever is going on with mist.

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

Hotfix 1 release: https://github.com/mrSkortch/MissionScriptingTools/releases/tag/4.3.72

 

Fixed an issue with the flagFuncs dealing with unitNameTables. For information see the linked post here.

  • 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

Hotfix 1 release: https://github.com/mrSkortch/MissionScriptingTools/releases/tag/4.3.72

 

Fixed an issue with the flagFuncs dealing with unitNameTables. For information see the linked post here.

 

 

I am having an issue with a script using this. If an aircraft its outside the zone the radar is in Green status (Off)...

 

THere are other things, and works fine, but I realized that if an aircraft is shot down in the area, it look as if the script is still considering it inside the zone. Is it possible?? Or I should have doing something wrong??

 

    local samsites = {'sam1','sam2','sam3'}

    for f,c in pairs(samsites) do
			sam = samsites[f]
			
			mist.flagFunc.units_in_moving_zones{
			units = {'[blue][plane]','[blue][helicopter]'},
			zone_units = {sam},
			flag = 500,
			radius = 10000,
			stopflag = 9999,
			req_num = 1,
			zone_type = 'cylinder',
			interval = 1,
			toggle = true
			}
	if
           trigger.misc.getUserFlag('500')== 0 
       then
           _group = Group.getByName(sam)
           _controller = _group:getController()
           _controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.GREEN )-- we switch off the SAM
	end    

 

by the way, can I use" flag = tonumber(sam)" to keep independant flags???


Edited by ESAc_matador
Link to comment
Share on other sites

I am having an issue with a script using this. If an aircraft its outside the zone the radar is in Green status (Off)...

 

THere are other things, and works fine, but I realized that if an aircraft is shot down in the area, it look as if the script is still considering it inside the zone. Is it possible?? Or I should have doing something wrong??

 

 

by the way, can I use" flag = tonumber(sam)" to keep independant flags???

 

I did a quick test and for me it was toggling the flag on/off as needed. Its possible if the aircraft is still alive it would end up returning positional information. Helicopters have a nasty habit of crash landing without being "destroyed". Aside for that are you sure there are no other aircraft in the zone at the time?

 

The sam value looks to be a string and not a number so it wouldn't convert it to a number. Flags can be string values, when doing so they are only accessible via the scripting engine and not with the built in triggers. So you can use it, you just gotta keep track of which flags are in use so you can check them as needed.

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 did a quick test and for me it was toggling the flag on/off as needed. Its possible if the aircraft is still alive it would end up returning positional information. Helicopters have a nasty habit of crash landing without being "destroyed". Aside for that are you sure there are no other aircraft in the zone at the time?

 

The sam value looks to be a string and not a number so it wouldn't convert it to a number. Flags can be string values, when doing so they are only accessible via the scripting engine and not with the built in triggers. So you can use it, you just gotta keep track of which flags are in use so you can check them as needed.

 

Thanks grimes!

Link to comment
Share on other sites

Grimes, you told me once that I should learn to do som .lua scripting!! and that is what I am doing. I am spending hours and days to learn the basics, I am studing the .lua manual, but sometimes I find somehting I cant solve by myself. Using mist, it is great!! but I need some clarifications yet.

 

for instance, and this is very important to my future scripts.

 

I want this to work... it is just, when units are in zone, smoke in each group.

 

this code works fine, and I get the message.

do
redunits = mist.makeUnitTable({'[red][vehicles]'})
targets = mist.getUnitsInZones(redunits,{'North'} , 'cylinder')

for k, v in pairs(targets) do

	local targetunit = targets[k]		
	local targetgroup = targetunit:getGroup():getName()	

	do
	trigger.action.outText(targetgroup ..  " detectado ", 30)
	end	
end
end

 

but when I try to put some somoke in the group.... not. I seems that I am not naming properly the "targetgroup" because if I use let say ({'[g] Group A'}) the script is fine. What is wrong to this argument??

 

do
redunits = mist.makeUnitTable({'[red][vehicles]'})
targets = mist.getUnitsInZones(redunits,{'N'} , 'cylinder')

for k, v in pairs(targets) do

	local targetunit = targets[k]		
	local targetgroup = targetunit:getGroup():getName()	
	
	
	do 
	trigger.action.smoke(gmist.getAvgPos(mist.makeUnitTable([b]targetgroup[/b])), "Orange")
	end	

end
end

Link to comment
Share on other sites

Today I have had this error, came out of nowhere?

 

5782 line?

 

gpId = mist.DBs.MEgroupsByName[groupIdent].groupId

CaptureBUG075.JPG.54ecb54d3d49ec0ea7649e648f4de1bc.JPG

51PVO Founding member (DEC2007-)

100KIAP Founding member (DEC2018-)

 

:: Shaman aka [100☭] Shamansky

tail# 44 or 444

[sIGPIC][/sIGPIC] 100KIAP Regiment Early Warning & Control officer

Link to comment
Share on other sites

but when I try to put some somoke in the group.... not. I seems that I am not naming properly the "targetgroup" because if I use let say ({'[g] Group A'}) the script is fine. What is wrong to this argument??

 

do
redunits = mist.makeUnitTable({'[red][vehicles]'})
targets = mist.getUnitsInZones(redunits,{'N'} , 'cylinder')

for k, v in pairs(targets) do

	local targetunit = targets[k]		
	local targetgroup = targetunit:getGroup():getName()	
	
	
	do 
	trigger.action.smoke(gmist.getAvgPos(mist.makeUnitTable([b]targetgroup[/b])), "Orange")
	end	

end
end

 

First off what is gmist.getAvgPos()? I assume its a typo.

 

mist.makeUnitTable() requires the use of the "constructors" to work correctly. The function accepts only a table, you are passing it a string. So {tostring('[g]'.. targetroup)}. However the makeUnitTable() is most useful when you are wanting to get the data for multiple groups. Getting the same data for a single group is rather easy...

 

local targetgroup = targetunit:getGroup():getUnits()

for i = 1, #targetgroup do

targetgroup = Unit.getName(targetgroup)

end

 

Today I have had this error, came out of nowhere?

 

5782 line?

 

gpId = mist.DBs.MEgroupsByName[groupIdent].groupId

 

Whenever you get an error the DCS.log will show a lot more useful information than whatever is in the popup. Generally it will include a traceback allowing you to see the functions and lines used to get to the error. For example:

 

12961.881 ERROR   DCS: Mission script error: : [string "C:\Users\me\AppData\Local\Temp\DCS.openbeta\/~mis0000458F"]:909: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: ?
[C]: in function 'pairs'
[string "C:\Users\me\AppData\Local\Temp\DCS.openbeta\/~mis0000458F"]:909: in function 'updateWarehouses'
[string "C:\Users\me\AppData\Local\Temp\DCS.openbeta\/~mis0000458F"]:2979: in main chunk

 

This is one of the functions I added some extra error checking on with the latest mist release. Since I have updated mist the lines don't match up so I don't know exactly which function you are using, but I can say that the functions that use a line like that will only work with groups placed in the mission editor. For dynamically spawned groups stuff like payload, routes, etc aren't fully accessible so it doesn't check those.

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 did a quick test and for me it was toggling the flag on/off as needed. Its possible if the aircraft is still alive it would end up returning positional information. Helicopters have a nasty habit of crash landing without being "destroyed". Aside for that are you sure there are no other aircraft in the zone at the time?

 

.

 

Hello, Grimes AGAIN ME¡¡¡

 

It is really annoying, it seems that my script works well with human player, and with AI aircrafts UNTIL one is destroyed. Then it seems that the scripit is blocked, and the SAMs does not switch off.

 

The scripit is as follows...

 

IF aircrafts are detected by EWR radar and are helicopters or Planes, AND are inside a moving zone, the SAM units goes to AUTO (ON)

And, if there is not aircrafts or planes inside the moving zone the SAM goes to GREEN (off)

 

It works perfect when I do the test, but when I put some extra IA in the test, they activated well, but once destroyed, they stay ON until you are well outside its range.

 

this is my script (it is some simple IADS... hehehe since I cant make your script to work in 1.5)

 

function findTargets()

function getGroupCategory(unit) -- THIS FUNCTION TO GET AROUND CLIENT GROUPS NOT ACCESSABLE IF USING IN A MULTIPLAYER ENVIRONMENT
   local unitDB = mist.DBs.unitsById[tonumber(unit:getID())]
    if unitDB ~= nil and unitDB.category then
       return unitDB.category
   end

   return nil
end

local samsites = {'sam1','sam2','sam3'}
local ewrsites = {'ewr1','ewr2'}


for i,j in pairs(ewrsites) do
           ewr = ewrsites[i]

   local unit = Unit.getByName(ewr)
	if unit ~= nil then
		local unitController = unit:getGroup():getController() --be careful, I'm not sure if the bug where client groups are not accessable will stuff this up if a player is in the vehicle at the time
		local detectedTargets = unitController:getDetectedTargets(Controller.Detection.RADAR)
		-- Controller.Detection.RADAR is the type of detection (radar in this case)
		-- leave it blank for all types (it includes RWR if the unit has one ie AWACS)
		-- for a list of detection types see here: http://wiki.hoggit.us/view/DCS_func_getDetectedTargets
		
		for k,v in pairs (detectedTargets) do
			if v["object"]:getCategory() == Object.Category.UNIT then --ensure the detected object is a unit, ive had it detect weapons
				local category = getGroupCategory(v["object"]) -- pull category using workaround
					if category == "plane" or category == "helicopter" then --check category as returned by MIST
					trigger.action.setUserFlag('400',1) 
					detectedblue = v["object"]:getName() 
					
						for f,c in pairs(samsites) do
						sam = samsites[f]
						
						mist.flagFunc.units_in_moving_zones{
						units = {detectedblue},
						zone_units = {sam},
						flag = tostring(sam),
						radius = 10000,
						stopflag = 9999,
						req_num = 1,
						zone_type = 'cylinder',
						interval = 1,
						toggle = true
						}

							if  trigger.misc.getUserFlag('400') == 1  and -- if planes or helos are detected
								trigger.misc.getUserFlag(tostring(sam)) == 1     -- and are inside a moving SAM zone
							then
								_group = Group.getByName(sam)
								_controller = _group:getController()
								_controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)-- we change the status to ON
								--trigger.action.outText(detectedblue  .. " detected by "  ..  sam .. ewr, 5)
							   
							end								
						end
					end
			end
		end
	end
end

for f,c in pairs(samsites) do
           sam = samsites[f]
		
		mist.flagFunc.units_in_moving_zones{
			units = {'[blue][plane]','[blue][helicopter]',},
			zone_units = {sam},
			flag = tostring(sam),
			radius = 10000,
			stopflag = 9999,
			req_num = 1,
			zone_type = 'cylinder',
			interval = 1,
			toggle = true
			}
		
		if
			trigger.misc.getUserFlag(tostring(sam))== 0 
		then
			_group = Group.getByName(sam)
			_controller = _group:getController()
			_controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.GREEN )-- we switch off the SAM
			trigger.action.setUserFlag('400',0) 
		end
	
end
timer.scheduleFunction(findTargets, {}, timer.getTime() + 3)-- scan the function every 10 seconds
end

findTargets ()

Link to comment
Share on other sites

Dear Grimes,

 

I have another problem. I am spawning/respawning a vehicle group which has their own set of waypoints by road then off road (two waypoints) and expect them to follow their route from place where they are to re/spawn. They spawn/respawn properly, but they never start moving to follow the waypoints, just sit where they have spawned (wp:0).

 

EDIT: I will disable entirely DAWS script and see if this is related, as it might be deleting their way-points when saving the mission. This is strange, as server hasn't loaded yet saved-state mission.


Edited by Shaman

51PVO Founding member (DEC2007-)

100KIAP Founding member (DEC2018-)

 

:: Shaman aka [100☭] Shamansky

tail# 44 or 444

[sIGPIC][/sIGPIC] 100KIAP Regiment Early Warning & Control officer

Link to comment
Share on other sites

I believe there is a bug currently with WP's of dynamically spawned units, but cause you're respawning ME placed units, I guess this isn't the issue. However, I had the same issue a while back when fiddling around with DAWS and fixed my problem by reassigning the route to the group after the group had spawned.

-16AGR- 16th Air Guards Regiment is always looking for pilots - http://www.16agr.com

 

EWRS - Early Warning Radar Script

 

Specs:

 

 

Gigabyte Sniper Z5-S

Intel i5-4670k 3.4GHz OC'd 3.9GHz w/ Thermaltake 120mm Water 3.0 Pro Liquid CPU Cooler

16GB RAM

Gigabyte GTX 1080

TM Hotas Warthog: SN: 06976

Saitek Pro Flight Combat Rudder Pedals

TrackIR5 with TrackClipPro & Oculus Rift

2x 28" 4k UHD Monitors (3840x2160 each) + 1280x1024

 

 

Link to comment
Share on other sites

Dear Grimes,

 

 

 

I have another problem. I am spawning/respawning a vehicle group which has their own set of waypoints by road then off road (two waypoints) and expect them to follow their route from place where they are to re/spawn. They spawn/respawn properly, but they never start moving to follow the waypoints, just sit where they have spawned (wp:0).

 

 

 

EDIT: I will disable entirely DAWS script and see if this is related, as it might be deleting their way-points when saving the mission. This is strange, as server hasn't loaded yet saved-state mission.

 

 

 

 

 

I have the same problem. Find the bug report here:

 

 

 

http://forums.eagle.ru/showthread.php?p=2802059

 

Sent from mTalk

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

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