camsr Posted December 29, 2013 Posted December 29, 2013 I am working on my wingtip idea, so I want to use wing tipping in a zone (or possibly distance from receiving unit (possibly checking LOS also)). I need to have a function called while the player's unit is in a trigger zone. It also needs to be scheduled to run at 100 times a second (maybe), because I will be using some differentiation for the detection. Then the function needs to end when a value is above a threshold for a given time. First things first, how do I start a scheduled function by entering a trigger zone?
camsr Posted December 29, 2013 Author Posted December 29, 2013 Okay, I have figured that out, using mist.scheduleFunction() Now I need a way to call removeFunction() while leaving the zone, so as to not call it unnecessarily outside the zone. I tried using a switch condition trigger, but the function still runs. I don't understand this switch condition. Any advice? I would like to see it work something like this: Unit flies into zone, function starts iterating. If task does not get completed in time, nothing happens until flying into the zone again, in which case the function restarts. Once a value is greater than another for some amount of time, the task is completed and the function does not get called again.
MagicBra Posted December 29, 2013 Posted December 29, 2013 have your tried something like that : 1.Put your function in a mist schedule. 2.Inside your function, add a condition that activates the actions when a flag is true. 3.Activate the flag when when the wanted units are in the wanted zone, deactivate if not (it could also be a second scheduled function or a simple ingame trigger). it's not very optimized because it will use cycles to do nothing but it should simple to implement :) VEAF - Virtual European Air Force- www.veaf.org Association européenne de simulation évoluant sur DCS, BMS et ArmA3. Nous rejoindre : http://www.veaf.org/fr/association/formulaire-de-contact
Wrecking Crew Posted December 29, 2013 Posted December 29, 2013 So you want this event to be triggered by Blue aircraft? All of the resulting actions that you want can be set up using regular events or put into some script. The matter at hand, as I see it, is to set a flag to true when the Blue aircraft are in the zone. And, if it is a small zone, say < 100 radius, then planes flying through it may be in and out faster than one second so you will need to check the status more often -- 0.01 second will work, so probably will 0.05 and may be less load... This will set Flag 50007 True for Blue planes in a bunch of spherical zones detecting at 0.05 seconds; another regular event turns Flag 50007 to False -- mist.flagFunc.units_in_zones{ units = {'[blue][plane]'}, zones = {'A Zone', 'B Zone', 'C Zone' }, flag = 50007, zone_type = 'sphere', interval = .05, } Here's code that has the toggle option so Flag 10117 goes True / False when Red plane unit 'RDR AGrp01-1' is in / out of the 'Gudauta' cylinder zone -- mist.flagFunc.units_in_zones{ units = {'RDR AGrp01-1'}, zones = {'Gudauta'}, flag = 10117, zone_type = 'cylinder', toggle = true, } You can find these in the Mist v3_2 Guide on about Page 14. 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.
camsr Posted December 30, 2013 Author Posted December 30, 2013 (edited) What I am trying to do is call mist.removeFunction when the player leaves the trigger zone. The task (wing tipping) is accomplished while in the zone and when it is accomplished it must set a flag so re-entry does not call the task again. It's a little complicated, so I am hoping someone can help me understand flags or how to organize this. All I know is flags are a two value vector with the second element true above zero or false. I don't know how the first element, the flag enum, is organized within the game. Here is my wing tipping function for you guys to try out! You can aileron roll all day and it won't trip it. It works with the a10c so far. To use it, set entry into a trigger zone to evaluate: wingtiphandle = mist.scheduleFunction(wingtip, {}, 0, (1/30), nil) Don't change (1/30) or the filter's tuning is screwed. And just load this script at mission start, don't enter the zone before it loads! -- vars local x0 = 0 local x1 = 0 local x2 = 0 local y0 = 0 local y1 = 0 local y2 = 0 local y3 = 0 local y4 = 0 local outi = 0 local bufi = 0 local f1 = .014661816193 local f2 = 1 / (1 + f1) local input = 0 local playerunit = Unit.getByName('PUT THE UNITS NAME HERE') trigger.action.outText("LOADED", 5) function wingtip() -- getroll input = mist.getRoll(playerunit) -- normalize input = input / math.pi -- waveshape input = 2 * math.pi * input * (math.cosh(2 * math.pi * input ^ 8) / math.cosh(2 * math.pi * input ^ 2) ^ 8) -- filter x0 = x1 x1 = x2 x2 = input / 1.435117008e+02 y0 = y1 y1 = y2 y2 = y3 y3 = y4 y4 = (x0 + x2) - 2 * x1 + ( -0.8607361667 * y0) + ( 3.5479473301 * y1) + ( -5.5117763941 * y2) + ( 3.8243485969 * y3) input = y4 -- rectify input = math.abs(input) -- integrate outi = (f1 * input + bufi) * f2 bufi = f1 * (input - outi) + outi -- -- test output trigger.action.outText((outi), 1) if outi > .5 then mist.removeFunction(wingtiphandle) end end EDIT: Updated tunings, should be much easier. Edited December 30, 2013 by camsr
camsr Posted January 5, 2014 Author Posted January 5, 2014 Are any flags reserved for use by the game? Or I just need to keep track of them? Has anyone tried my script? Would be great to hear some feedback.
Wrecking Crew Posted January 6, 2014 Posted January 6, 2014 Are any flags reserved for use by the game? Or I just need to keep track of them? No flags are reserved. My guide re flags -- http://forums.eagle.ru/showthread.php?t=114492 WC 1 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.
camsr Posted January 6, 2014 Author Posted January 6, 2014 Thank you, it seems easy enough. Is there a way to check LOS between units?
Wrecking Crew Posted January 7, 2014 Posted January 7, 2014 With Mist there is, I believe. I have not used it that functionality. 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.
Recommended Posts