Jump to content

Recommended Posts

Posted (edited)

mist.flagFunc.units_in_zones{

units = {'[blue][plane][helicopter]'},

zones = {'GOT'},

flag = 10000,

req_num = 1

}

 

 

I've got this script running in an area that overlaps some other ground positions- some are dynamically added... some are just normal mission items.

 

I've tried it as is, moved it over normal mission items (jtac vehicles) as a test... then moved it over nothing at all. The only time it works as designed is the latter.

 

 

Is this a common problem poeple are having?

 

(LATE EDIT: and by common problem "poeple" are having" I mean being idiots lol)

Edited by ENO

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted (edited)
mist.flagFunc.units_in_zones{

units = {'[blue][plane][helicopter]'},

zones = {'GOT'},

flag = 10000,

req_num = 1

}

 

 

I've got this script running in an area that overlaps some other ground positions- some are dynamically added... some are just normal mission items.

 

I've tried it as is, moved it over normal mission items (jtac vehicles) as a test... then moved it over nothing at all. The only time it works as designed is the latter.

 

 

Is this a common problem poeple are having?

I'm not exactly sure what your problem is- what do you mean by "The only time it works as designed is the latter." Define "works". Also, define not working. Anyway, the reason I don't understand what you're trying to do is because you're not using the unit table shortcuts correctly, see below. So I don't know what you're expecting to happen, so I don't know what "works" means.

 

But secondly, [blue][plane][helicopter] is not a valid category. So it recognizes [blue], but it doesn't recognize what [plane][helicopter] means. What are you trying to detect, when a V-22 Osprey comes into zone?! :D

 

Anyway, unless Grimes has changed it, from what I can tell, since it doesn't recognize "[plane][helicopter]", then it should just default to everything blue.

 

Edit- this is a list of all the Unit table shortcuts-

--[[
Prefixes:
"[-u]<unit name>" - subtract this unit if its in the table
"[g]<group name>" - add this group to the table
"[-g]<group name>" - subtract this group from the table
"[c]<country name>"  - add this country's units
"[-c]<country name>" - subtract this country's units if any are in the table

Stand-alone identifiers
"[all]" - add all units
"[-all]" - subtract all units (not very useful by itself)
"[blue]" - add all blue units
"[-blue]" - subtract all blue units
"[red]" - add all red coalition units
"[-red]" - subtract all red units

Compound Identifiers:
"[c][helicopter]<country name>"  - add all of this country's helicopters
"[-c][helicopter]<country name>" - subtract all of this country's helicopters
"[c][plane]<country name>"  - add all of this country's planes
"[-c][plane]<country name>" - subtract all of this country's planes
"[c][ship]<country name>"  - add all of this country's ships
"[-c][ship]<country name>" - subtract all of this country's ships
"[c][vehicle]<country name>"  - add all of this country's vehicles
"[-c][vehicle]<country name>" - subtract all of this country's vehicles

"[all][helicopter]" -  add all helicopters
"[-all][helicopter]" - subtract all helicopters
"[all][plane]" - add all  planes
"[-all][plane]" - subtract all planes
"[all][ship]" - add all ships
"[-all][ship]" - subtract all ships
"[all][vehicle]" - add all vehicles
"[-all][vehicle]" - subtract all vehicles

"[blue][helicopter]" -  add all blue coalition helicopters
"[-blue][helicopter]" - subtract all blue coalition helicopters
"[blue][plane]" - add all blue coalition planes
"[-blue][plane]" - subtract all blue coalition planes
"[blue][ship]" - add all blue coalition ships
"[-blue][ship]" - subtract all blue coalition ships
"[blue][vehicle]" - add all blue coalition vehicles
"[-blue][vehicle]" - subtract all blue coalition vehicles

"[red][helicopter]" -  add all red coalition helicopters
"[-red][helicopter]" - subtract all red coalition helicopters
"[red][plane]" - add all red coalition planes
"[-red][plane]" - subtract all red coalition planes
"[red][ship]" - add all red coalition ships
"[-red][ship]" - subtract all red coalition ships
"[red][vehicle]" - add all red coalition vehicles
"[-red][vehicle]" - subtract all red coalition vehicles


Country names to be used in [c] and [-c] short-cuts:
"Turkey" 
"Norway"
"The Netherlands"
"Spain"
"UK"
"Denmark"
"USA"
"Georgia"
"Germany"
"Belgium"
"Canada"
"France"
"Israel"
"Ukraine"
"Russia"
"South Osetia"
"Abkhazia"
"Italy"
]]

Edited by Speed
  • Like 1

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Posted

LOL... good to have you back Speed.

 

 

You're right- I've evidently misread how to show all blue planes and helicopters... and by "works" I meant that it actually doesn't set a flag until a blue aircraft / helicopter (or anything for that matter as it turns out) goes into the zone.

 

 

So is it just a matter of doing blue plane in one part of the script and blue helicopter in a clone with the same flag result? In reading that section of the guide I'd noticed that it had lined up a few different items and that you could list off all the things that you wanted on or off the list.

 

{'[blue][plane]', '[-c]Georgia', '[-g]Hawg 1'}

 

But what I see now is that each should be separated... so {'[blue][plane]', '[blue][helicopter]'} would work?

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

But what I see now is that each should be separated... so {'[blue][plane]', '[blue][helicopter]'} would work?

 

Correct, that means "all blue planes + all blue helicopters".

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Posted

Hmmm, that's nice that you can combine them with a comma.

 

Check out the toggle = true feature, too -- very handy. I typically use these Mist scripts to set the embedded flag (10000), then in the next event I will use Flag 10000 True to set another flag that the rest of the functions trigger from (10001, let's say),,, and I can use 10001 as a Stop Flag to prevent the Flag 10000 from firing on off on off until I'm ready. I'm also putting commas after every line including the last one, because when I add a new line I typically forget to add that comma.

 

mist.flagFunc.units_in_zones{
units = {'[blue][plane], [blue][helicopter]'},
zones = {'GOT'},
flag = 10000,
toggle = true,
stopflag = 10001,
req_num = 1,
}

 

WC

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.

Posted
FYI, you don't need req_num = 1.

 

WC

 

 

I typically have that set to a different number but I was using that for testing is all.

 

I haven't dabbled with the toggle but thanks for reminding me about it- there are a couple things I've been wanting to do with it.

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

I am having trouble getting this to work for me.

 

I am trying to detect when a helicopter unloads infantry in a zone and set a flag. This only needs to detect this once. As far as I can see this can only be achieved using scripting, as the infantry group being tested for do not exist until spawned by CTTS. Here is what I am trying to use:

 

mist.flagFunc.units_in_zones{

units = {'[blue][vehicle]', '[-g]Convoy 1 #001', '[-g]Convoy 1 #002', '[-g]Convoy 1 #003'},

zones = {'Ambush 1 Red LZ'},

flag = 2081,

stopflag = 3081,

zone_type = 'sphere'

}

 

The only reason, I am assuming, it does not work is because the mist.flagFunc.units_in_zones function is looking for the units crossing the zone boundary, which never happens as they are created inside the zone (so never cross the zone boundary). Either this or the units when the function is called do not exist so will not be in the units table.

 

I have even tried putting this function call into the CTTS script after the units are spawned in the UnitTroopsCommand function where the troops are dropped/created.

 

Any ideas or suggestions would be most welcome?

Rig: MSI Mag X570 Tomahawk| AMD 5600 | 32 GB DDR3 | M2 NVME Gen4 1TB SSD | Samsung EVo 850 2TB, 500 & 256 GB SSD | Gigabyte AORUS GTX 1080Ti | Samsung 24" (1920x1200) |

2 x Iiyama 22" T2250MTS touch screen (1920x1080) | 2 x 6.4" LCD | Cougar MFDs | Thrustmaster Warthog | CH Pro Pedals | Windows 10

 

[sIGPIC][/sIGPIC]

Posted

Try removing this -

, '[-g]Convoy 1 #001', '[-g]Convoy 1 #002', '[-g]Convoy 1 #003'

 

Because maybe the [blue][vehicle] would cover the infantry... But it may help to try taking out those groups for testing. That's an interesting issue about if the groups are created in the zone vs crossing the boundary.

 

Make sure the zone is spelled right :-) and you are indenting lines 2-6.

 

WC

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.

Posted

What about changing this -->

units = {'[blue][vehicle]', '[-g]Convoy 1 #001', '[-g]Convoy 1 #002', '[-g]Convoy 1 #003'},

 

To -->

units = {'[blue][helicopter]'},

 

WC

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.

Posted

Thanks WC.

 

I will try removing the subtraction of the other units/groups for testing.

 

I am already testing for specific helicopters in the zone, using:

 

mist.flagFunc.units_in_zones{

units = {'[g]HeliAssault1 (Red)', '[g]HeliAssault2 (Blue)', '[g]HeliAssault3 (Green)', '[g]HeliAssault4 (White)'},

zones = {'Ambush 1 Red LZ'},

flag = 81,

stopflag = 3081,

zone_type = 'sphere'

}

 

Which works OK. Unfortunately, it only detects if a helicopter flies into the zone and not if it successfully landed and disembarked troops.

Rig: MSI Mag X570 Tomahawk| AMD 5600 | 32 GB DDR3 | M2 NVME Gen4 1TB SSD | Samsung EVo 850 2TB, 500 & 256 GB SSD | Gigabyte AORUS GTX 1080Ti | Samsung 24" (1920x1200) |

2 x Iiyama 22" T2250MTS touch screen (1920x1080) | 2 x 6.4" LCD | Cougar MFDs | Thrustmaster Warthog | CH Pro Pedals | Windows 10

 

[sIGPIC][/sIGPIC]

Posted (edited)

Ran into that issue before and grimes supplied me with a work around. It's because ctts isn't configured to broadcast the dynamically spawned units. Brb- gotta find it.

 

(From GRIMES):

The way mistv3 would accept that same example looks like this with changes in red:

 

group = {
[color="Red"]        country = "USA"
       category = "GROUND_UNIT"[/color]
       units = {
       [1] = {
           ["x"] = apcpos.x - 5 * math.cos(apcheading),
           ["y"] = apcpos.z - 5 * math.sin(apcheading),
           ["type"] = "Soldier M4",
           ["heading"] = apcheading - math.pi,
               },
       [2] = {
           ["x"] = apcpos.x - 6 * math.cos(apcheading),
           ["y"] = apcpos.z - 6 * math.sin(apcheading),
           ["type"] = "Soldier M4",
           ["heading"] = apcheading - math.pi,
               },
       [3] = {
           ["x"] = apcpos.x - 7 * math.cos(apcheading),
           ["y"] = apcpos.z - 7 * math.sin(apcheading),
           ["type"] = "Soldier M249",
           ["heading"] = apcheading - math.pi,
               },
           },
       }

[color="red"]mist.dynAdd(group)[/color]

 

The category entry in mist has been "overloaded" to also accept "vehicle" and "ground" as valid values. Basically if you use 'vehicle' or 'ground' mist.dynAdd() will change the value to GROUND_UNIT.

 

 

 

http://forums.eagle.ru/showpost.php?p=1856664&postcount=14

Edited by ENO

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted (edited)

I also dug up a script that detects when a chopper lands in a zone- ill have to go find it... Brb.

 

 

Enter this as a LUA Predicate in a "switched condition" trigger- edit names as necessary.

 

local HeliGroup = {'HeliAssault1 (Red)', 'HeliAssault2 (Blue)', 'HeliAssault3 (Green)', 'HeliAssault4 (White)', 'HeliAssault5 (Red)', 'HeliAssault6 (Blue)', 'HeliAssault7 (Green)', 'HeliAssault8 (White)'} --Enter the list of groups to be tested from the ME here

local group = ''

 

for i = 1, #HeliGroup do

group = Group.getByName(HeliGroup)

if group ~= nil then --If Group exists

group = group:getUnits()[1]

if group:inAir() then

return false --Group is in air

else

return true --Group is not in air (has landed)

end

else --If Group does not exist

return true

end

return false

end

 

Add a condition for the unit being in the desired zone... since the trigger will fire as soon as the chopper hits the ground and not necessarily when it deploys troops from the dynamic CTTS group... Or just use MIST to rule out the helicopters and go "blue" in zone. With the script above (CTTS / MIST dynadd) you should be able to make that work.

Edited by ENO

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

Okay- I have another problem:

 

I was working on this awhile ago, filed it away during 127 beta and now am working on it again. Concept is patrols are moving through an area along the road and certain roadside ambushes spawn in randomly- though not dynamically per se. I have a variety of different groups placed on the map and they are activated via a flag set random value trigger. There are 10 combinations available... This part works okay.

 

The groups patrolling are invisible provided a certain user flag is turned off. When the group enters a zone- provided an enemy coalition unit has been detected in it when it spawns in- another flag random value is generated on a switched condition. If it is more than a certain value, then the user flag controlling the patrol invisibility is turned on (and makes the patrol visible) and an attack should occur.

 

It is set up this way to add some randomness on a broad scale to the mission.

 

My issue is that nobody EVER shoots?

 

Even if I set the flag random value between 1 and 10 and set flag more than 1... nothing happens.

 

I have checked and double checked the flags with the areas with the patrols... (each patrol goes through 2-3 potential ambush zones)- and I'm confident I have those lined up properly.

 

I'm curious as to whether or not once a flag value is established- if it is anchored in this way... if in a switched condition the flag is set to a random value of 6, the next time a unit enters that zone and that flag random value is established again... will it be 6? Or will it reset to another random number within given parameters?

 

I'm attaching the mission in the event it helps.

Georgia Peach ambush.1.2.7.b.miz

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted (edited)

@ENO

 

Thanks for the pointers. I thought I recognised that bit of the code you put up, it was taken from one of my earlier posts. I had already updated CTTS with the mist.dynAdd(group) call in the ConfigGroup function.

 

I have now managed to detect troops disembarking in zone by modifying the CTTS script, by using the CTTS function UnitInZone. In the function UnitTroopsCommand I have added this:

 

local zone1 = {ZoneName = "Ambush 1 Red LZ"}

if UnitInZone(unit, zone1) then

trigger.action.setUserFlag(2081, true)

end

 

So by combining this with the helicopters in zone above Post #11 it now gives me what I was after.

 

See the full revised UnitTroopsCommand function in CTTS below.

 

function UnitTroopsCommand(unitName)
local radius = maxDistDrop
   local unit = Unit.getByName(unitName)
    
   if unit == nil then
       return
   end
   
local unitpos = unit:getPoint()
   local unitId = unit:getID()
   local group = unit:getGroup()
   local groupName = group:getName()
local groupside = group:getCoalition()
local newGroup = nil	
local destination = nil	
local gid = group:getID()	
local flying = unit:inAir()	
   local playerName = unit:getPlayerName()

if playerName == nil then
       playerName = "Ground Commander"
   end 
		    
   local pickupZone = UnitInAnyPickupZone(unit)
local nearestGroup = FindNearestGroup(unit, groupside)
local extgroup = nil

UnitAutoAction[unitName] = false -- disables auto load/unload for AI when action has been activated by player	

   if pickupZone ~= nil then
	if UnitLoadTable[unitName] == false then
		trigger.action.outTextForCoalition(groupside, playerName .. " loaded troops at pickup zone", 5)
		
		UnitLoadTable[unitName] = true
		UnitCargoCount[unitName] = defCargoNum
								
		if nearestGroup ~= "NONE" then -- if there´s a spawned group nearby deletes it
			extgroup = Group.getByName(nearestGroup)
			UnitCargoCount[unitName] = #extgroup:getUnits()
			UnitCargoName[unitName] = nearestGroup
			extgroup:destroy()
		end
	else
		trigger.action.outTextForCoalition(groupside, playerName .. " returned troops to base", 5)
		
		UnitLoadTable[unitName] = false
		
		destination = FindNearestEnemy(unitpos, radius, groupside)
		newGroup = DropoffGroupDirect(UnitCargoCount[unitName], 15, unitpos.x, unitpos.z, destination.x, destination.y, groupside, UnitCargoName[unitName]) -- spawns a group
	
	end		
   else
	if flying == false then
           if UnitLoadTable[unitName] == true then
			trigger.action.outTextForCoalition(groupside, playerName .. " dropped troops", 5)
			
			UnitLoadTable[unitName] = false
			
			destination = FindNearestEnemy(unitpos, radius, groupside)
			newGroup = DropoffGroupDirect(UnitCargoCount[unitName], 15, unitpos.x, unitpos.z, destination.x, destination.y, groupside, UnitCargoName[unitName]) -- spawns a group
			
			[color="Red"]local zone1 = {ZoneName = "Ambush 1 Red LZ"}
			if UnitInZone(unit, zone1) then
				trigger.action.setUserFlag(2081, true)
			end[/color]
			
           else
			if nearestGroup ~= "NONE" then -- if there´s a spawned group nearby deletes it
				trigger.action.outTextForCoalition(groupside, playerName .. " extracted troops", 5)
				
				UnitLoadTable[unitName] = true
				
				extgroup = Group.getByName(nearestGroup)
				UnitCargoCount[unitName] = #extgroup:getUnits()
				UnitCargoName[unitName] = nearestGroup
				extgroup:destroy()					
			else
				trigger.action.outTextForGroup(gid, "You don't have any extractable troops or pickup zone nearby", 5)					
			end				
           end
	end
   end      	
end

Edited by nebuluski

Rig: MSI Mag X570 Tomahawk| AMD 5600 | 32 GB DDR3 | M2 NVME Gen4 1TB SSD | Samsung EVo 850 2TB, 500 & 256 GB SSD | Gigabyte AORUS GTX 1080Ti | Samsung 24" (1920x1200) |

2 x Iiyama 22" T2250MTS touch screen (1920x1080) | 2 x 6.4" LCD | Cougar MFDs | Thrustmaster Warthog | CH Pro Pedals | Windows 10

 

[sIGPIC][/sIGPIC]

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...