Jump to content

St3v3f ? - Specific a/c detection in a static zone


Wrecking Crew

Recommended Posts

St3v3f -

 

You provided me with a script to turn a flag on/off when any blue a/c entered a moving zone around ships.

http://forums.eagle.ru/showthread.php?t=109684&page=2

 

I'm trying to modify that to detect when a *specific* red a/c enters a specific static cylindrical zone to turn a flag on, and if/when the a/c leaves the zone the flag turns off.

 

I'm getting an error at the beginning of the mission. I don't understand the lua scripting well enough -- can you help me?

 

This is my latest attempt. The mission is attached.

 

local units = mist.makeUnitTable({'RDR AGrp01 Pilot'})
local flag = 10107
local zones = {'Gudauta Zone'}

local function acInAirbaseZoneOnOff(result)
local ret = mist.acInAirbaseZoneOnOff ( units, zones )
if #ret == 0 and result == true then
	trigger.action.setUserFlag(flag, 0)
	result = false
elseif #ret > 0 and result == false then
	trigger.action.setUserFlag(flag, 1)
	result = true
end
mist.scheduleFunction (acInAirbaseZoneOnOff, {result}, timer.getTime() + 1)
end

acInAirbaseZoneOnOff(false)

 

---

 

I saw your post today about the tanker regen, and was curious about your comments about detecting when the tanker has parked.

http://forums.eagle.ru/showthread.php?t=112170

 

This script that I am asking help for is going to be joined with more events or script to do essentially the same ^^^ with cargo aircraft, detect when it has parked - see the attached mission; the following events do work if Flag 10107 is set to indicate that the a/c is within the Gudauta Cargo Zone.

 

The event named Off.mist does make it all work but is disabled with a Time More (10000). The problem with this working script is that the ac will/can fly out of the Gudauta zone and could well get killed before parking, so that's why I need the In Zone flag to go false if the a/c leaves the zone. If the a/c gets killed before parking I do not want the cargo to be unloaded.

 

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.

Link to comment
Share on other sites

You are probably better at this than me crew but I will mention that if you look at the error code it generally gives you a line number... if you go to that line number in NP++ it should get you close to the error... usually just a missing comma or something silly. Caps or no caps... etc. You know how it often is.

 

You likely already know this but I know I've had my struggles with such things. This is the "bottom level" help- hopefully someone can come in with something more substantial.

 

Why not something straight out of mist- you'd just need to assign the "moving zone." This is taken from "MIST." Just fill in the particulars...

 

mist.flagFunc.units_in_zones{

units = {'Chevy11', 'Chevy12', 'Chevy13', 'Chevy14'},

zones = {'Mozdok', 'Krymsk', 'Anapa', 'Mineral'},

flag = 100,

zone_type = 'sphere'

}

 

 

That helps show how to write in the units... the following shows the moving zones:

 

mist.flagFunc.units_in_moving_zones{

units = {'[blue]'},

zone_units = {'[red]'},

flag = 500,

radius = 10000,

stopflag = 9999,

req_num = 4,

zone_type = 'sphere',

interval = 10,

}

--[[Once run, this function will start a process that will set flag 500

true when at least 4 blue units are within 10000 meters of any blue

units. The process will run once every 10 seconds unless flag 9999

becomes true.]]

 

Page 16 in the MIST guide...

 

 


Edited by ENO
  • Like 1

"ENO"

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

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

All you need to do is to stick with the first of the two scripts I've posted and change the first four lines:

 

local units = mist.makeUnitTable({'[blue][plane]'})

local flag = 50207

local zones = {'1 Sphere Zone'}

local zone_type = 'sphere'

 

local units = mist.makeUnitTable({'RDR AGrp01 Pilot'})
local flag = 10107
local zones = {'Gudauta Zone'}
local zone_type = 'cylinder'

local function unitsInZonesOnOff(result)
local ret = mist.getUnitsInZones(units, zones, zone_type)
if #ret == 0 and result == true then
	trigger.action.setUserFlag(flag, 0)
	result = false
elseif #ret > 0 and result == false then
	trigger.action.setUserFlag(flag, 1)
	result = true
end
mist.scheduleFunction (unitsInZonesOnOff, {result}, timer.getTime() + 1)
end

unitsInZonesOnOff(false)

 

 

 

In my tanker script, the detection of 'parking' is done by checking if it's speed is less than 1 m/s, irrelevant of where he is. So even if he just came off the runway and holds on the taxiway because of traffic, the script will detect this as parking and spawn the new tanker. That is perfectly fine for that purpose. The problem with a 'proper' detection of parking is that you don't know which airfield it will land at and even if you know, you don't know which parking spot he will take. That may be easy for large aircraft in Gudauta as there is only the one ramp suitable for them, but other airports have the large pads all over the place.

Since the script was intended to be easy to implement, I decided to go with that implementation, rather than having to place a triggerzone over every possible parking spot in the Caucasus.

 

Why not something straight out of mist

The reason the mist functions are not suitable in this situation is that they only set the flag to true when the conditions are met, they don't set them to false if they are not met.

If you have a unit move through a zone, the flag will stay on when the aircraft is out of the zone again. The scripts I've provided WC with, work similar to mist.flagFunc.units_in_zones and mist.flagFunc.units_in_moving_zones, but they also set the flag off when the conditions are not met anymore


Edited by St3v3f
  • Like 1

aka: Baron

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

The reason the mist functions are not suitable in this situation is that they only set the flag to true when the conditions are met, they don't set them to false if they are not met.

If you have a unit move through a zone, the flag will stay on when the aircraft is out of the zone again. The scripts I've provided WC with, work similar to mist.flagFunc.units_in_zones and mist.flagFunc.units_in_moving_zones, but they also set the flag off when the conditions are not met anymore

 

It can in mist v3 with the new "toggle" variable. I still gotta test a few new additions and finish writing the documentation for it, but hopefully soon. :music_whistling:

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

Yup, all of the SCT stuff will be integrated, there will be a name change though. sct.respawnGroup to mist.respawnGroup. There are still a bunch of sct type of functions I wanted to add for it, but haven't quite finished them yet. I want to release mist v3 asap, so I'll probably add all that stuff in with minor updates.

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

All you need to do is to stick with the first of the two scripts I've posted and change the first four lines:

 

local units = mist.makeUnitTable({'RDR AGrp01 Pilot'})
local flag = 10107
local zones = {'Gudauta Zone'}
local zone_type = 'cylinder'

local function unitsInZonesOnOff(result)
local ret = mist.getUnitsInZones(units, zones, zone_type)
if #ret == 0 and result == true then
	trigger.action.setUserFlag(flag, 0)
	result = false
elseif #ret > 0 and result == false then
	trigger.action.setUserFlag(flag, 1)
	result = true
end
mist.scheduleFunction (unitsInZonesOnOff, {result}, timer.getTime() + 1)
end

unitsInZonesOnOff(false)

 

 

 

In my tanker script, the detection of 'parking' is done by checking if it's speed is less than 1 m/s, irrelevant of where he is. So even if he just came off the runway and holds on the taxiway because of traffic, the script will detect this as parking and spawn the new tanker. That is perfectly fine for that purpose. The problem with a 'proper' detection of parking is that you don't know which airfield it will land at and even if you know, you don't know which parking spot he will take.

 

 

Thanks St3v3f, guys,

 

St3v3f - your modified script above provides the specific arguments that I need. I can't do just '[blue][plane]', as I have about a dozen cargo planes arriving at Gudauta over about three hours, and each one of the cargo planes unloads (activates) a different group of vehicles. Originally this occurred when a cargo plane entered the Gudauta zone that is centered on that airbase. BUT, :-) I want the Blue team to be able to kill the Red cargo plane before it parks, such that Blue can prevent the cargo from being unloaded even after the plane has landed and is still taxing. Also, sometimes the planes will enter the Gudauta zone and then exit and circle around - and the cargo should not be unloaded if that is the case.

 

In your following comment, you gave me another consideration. I've been testing this with a single plane in the test mission, certainly when multiple planes are involved the likelihood of a taxiing cargo plane to momentarily stop and wait is high. I will include a delay and then recheck the plane's speed to make sure it doesn't start up the taxi again.

 

What would work better, is if the script could detect when the plane's door/ramp goes down, or when it's engines shut off.

 

I do not care about testing for any particular parking spot. The Red cargo a/c has to be in the Gudauta zone and has to 'park' before it is destroyed by Blue.

 

---

 

Where you are including "local zone_type = 'cylinder'" in your script above, I was trying to pare down the script to its essentials, thinking that since 'cylinder' is the default that I would not need to state it.

 

 

FYI - the mission is Southern Wind for F-15Cs and A-10s.

 

After I get this done I will work on my flag and naming scheme document and post it.

 

Wrecking Crew


Edited by Wrecking Crew

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

All right - here is the test mission working with a single cargo a/c. It has the delay to help in the case of taxiing stops before parking; the delay here is four seconds in this test, I will increase that to about ~40... the Yak-40 in this mission takes ~35 seconds to shut engines down and lower the rear ramp.

 

For every cargo a/c in the mission there will be four events:

1. Detect if dead

2. Mist/script to detect in/out of the airbase zone

3. If in the zone and not dead, detect when speed < 1 then set the delay

4. If not dead, detect if delay is expired and speed is <1 then unload cargo

 

WC

 

attachment.php?attachmentid=86749&stc=1&d=1377732599

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

St3v3f,

 

Thank you again. I really appreciate how you define all the variables at the top of your functions. Makes it easy to copy the events.

 

---

 

Eno,

St3v3f made a script for the Pirates Of The Crimean that uses the moving zones and added the turning off of the flag as well.

 

I've used only events to 'try to determine' when In Zone flags should go false -- for vehicles vs aircraft. St3v3f's is the solution - and it is a good read to help me wrap my head around the lua language. What Grimes said about a 'toggle' should shorten this code further.

 

---

 

Can we detect when a cargo a/c has shut down its engines or lowered its ramp?

 

 

WC


Edited by Wrecking Crew
-- for vehicles vs aircraft

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

St3v3f,

 

Thank you again. I really appreciate how you define all the variables at the top of your functions. Makes it easy to copy the events.[/Quote]

Glad if I can help. That was exactly the intention of placing the variables on the top ;)

 

Can we detect when a cargo a/c has shut down its engines or lowered its ramp?

 

It might be, but I only tried using events once and that didn't work out well. Maybe someone else has some experience in this


Edited by St3v3f

aka: Baron

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • Recently Browsing   0 members

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