Grimes Posted July 22, 2013 Share Posted July 22, 2013 (edited) Since I cannot edit the wiki at the moment, here are the changes to the scripting engine with 1.2.5. Changelog: AI.Skill enum was added Unit.getDescByName() function added Controller.setOnOff() function was added Controller.isTargetDetected() function was added Functions for some trigger actions was added: trigger.action.activateGroup(), trigger.action.deactivateGroup(), trigger.action.setGroupAIOn(), trigger.action.setGroupAIOff(), trigger.action.groupStopMoving(),trigger.action.groupContinueMoving(). StopRoute AI Command was added. Simplified function documentation: trigger.action.activateGroup() trigger.action.deactivateGroup() trigger.action.setGroupAIOn() trigger.action.setGroupAIOff() trigger.action.groupStopMoving() trigger.action.groupContinueMoving() These are all scripting engine versions of the relevant trigger actions. Each accepts a group table and some of them are already accessible to the group class. For example: trigger.action.activateGroup(Group.getByName('myGroup')) is the same as: Group.getByName('myGroup'):activate() AI.skill enum is simply a table of skill constants AI.Skill = { AVERAGE, GOOD, HIGH, EXCELLENT, PLAYER, CLIENT } Controller.setOnOff(Controller self, boolean value) Sets the AI on or off based on the value passed. ONLY works on ground and naval groups. Unit.getDescByName(TypeName typeName) Returns the description of the related type name. The follow is a copy/paste of the detection entry. Conroller.Detection = { VISUAL, OPTIC, RADAR, IRST, RWR, DLINK } function boolean detected, boolean visible, ModelTime lastTime, Vec3 lastPos, Vec3 lastVel Controller.isTargetDetected(Controller self, Object target, [Conroller.Detection detection1, Conroller.Detection detection2, ... Conroller.DetectionN] or nil) checks if the target is detected or not. If one or more detection method is specified the function will return true if the target is detected by at least one of these methods. If no detection methods are specified the function will return true if the target is detected by any method. *target Target to check. *detection1 - detectionN Detection methods of interest. Return values: *detected True if the target is detected. *visible Has effect only if detected is true. True if the target is visible now. *lastTime Has effect only if visible is false. Last time when target was seen. *lastPos Has effect only if visible is false. Last position of the target when it was seen. *lastVel Has effect only if visible is false. Last velocity of the target when it was seen. edit. Also Group.getSize() returns the current size of the group, NOT the initial size as stated in the documentation. An initial size related function should be added in a future patch. Edited July 22, 2013 by Grimes The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting 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 More sharing options...
galevsky06 Posted July 22, 2013 Share Posted July 22, 2013 YES :thumbup: Link to comment Share on other sites More sharing options...
Bushmanni Posted July 23, 2013 Share Posted July 23, 2013 Good stuff! DCS Finland: Suomalainen DCS yhteisö -- Finnish DCS community -------------------------------------------------- SF Squadron Link to comment Share on other sites More sharing options...
chromium Posted July 23, 2013 Share Posted July 23, 2013 AI on/off, ok, that's great! :) 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 More sharing options...
St3v3f Posted July 23, 2013 Share Posted July 23, 2013 Thanks aka: Baron [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
IADC Posted July 24, 2013 Share Posted July 24, 2013 Group Activate Problems Since 1.25 some of my triggers in the latest build of Rotar Head are not working. The one that is driving me made is Group Activate. I cannot get the COLT AH1 group to spawn anymore on late activation. Trigger is called Spawn Cobras. Can someone please look at this and see if they can figure it out. ThanksRotor Head Multi Player rev.2.0.miz Link to comment Share on other sites More sharing options...
SNAFU Posted September 19, 2013 Share Posted September 19, 2013 Since I couldn´t find any further documentation concerning these functions in the WIKI I am just asking here... Would this be the right Snytax for the "Controller.isTargetDetected()" function? lcoal possibleblueintruder = Unit.getByName('testintruder') local redEWRgroup = Group.getByName('testEWR') local redEWRgroupcontroller = redEWRgroup:getController() possibleblueintrudergroupdetected = Controller.isTargetDetected(redEWRgroupcontroller, possibleblueintruder, [Conroller.Detection.RADAR]) I want possibleblueintrudergroupdetected to be a boolean, which returns true if the unit with the name "testintruder" is detected by the radar of the group "testEWR". [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
SNAFU Posted September 20, 2013 Share Posted September 20, 2013 After some testing I finally found the right syntax. For all the clueless scripters like me, here an Example that works: --EWR unit to be named 'testEWR' --Unit to be detected named 'testintruder' function checkifunitdetected() possibleblueintrudergroupdetected = false local possibleblueintruder = Unit.getByName('testintruder') local redEWRgroup = Group.getByName('testEWR') local redEWRgroupcontroller = redEWRgroup:getController() possibleblueintrudergroupdetected = Controller.isTargetDetected(redEWRgroupcontroller, possibleblueintruder, RADAR) if possibleblueintrudergroupdetected == true then trigger.action.outText("Intruder detected", 2) elseif possibleblueintrudergroupdetected == false then trigger.action.outText("Intruder NOT detected", 2) end return timer.getTime() + 5 end timer.scheduleFunction(checkifunitdetected, nil, timer.getTime() + 2) [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
chromium Posted September 20, 2013 Share Posted September 20, 2013 Interesting! as typed above your script simply create the output messages if anything is detected by EWR unit, correct? Do you think it's possible to add a polygon zone of detection (or simply range) limit to simulate effective intrusion in predefined boundaries (one EWR provide alert on enemy in air with messaging, another trigger the response)? 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 More sharing options...
SNAFU Posted September 20, 2013 Share Posted September 20, 2013 (edited) Yes, I just wrote this to test, how the function works. You can replace the "trigger.outTest" with anything else, which shall happen when the unit is detected. I want to use the detect-funciton for a dynamic CAP/INTERCEPT script, I am currently working on. This script shall spawn or task free interceptors to engage the planes entering the polygon area and which are detected by the EWR radars. So far it works (surprisingly), but I still have to send the interceptors back to base after the intruder leaves the polygon area or is shot down. The spawned interceptors go rampage across the map otherwise after they have completed their task. To combine the detect-function with the polygon this would be an example which works for me: This creates points for the border: bluebordergroupname = 'blueborder' -- Name of group which waypoints define the blue border blueborderline = mist.getGroupPoints(bluebordergroupname) --table of points defining blue borderline blueborderlinevec3 = {} for r = 1, #blueborderline do blueborderlinevec3[#blueborderlinevec3 + 1] = { z = blueborderline[r].y, x = blueborderline[r].x, y = land.getHeight({x = blueborderline[r].x, y = blueborderline[r].y}) } --trigger.action.smoke({x=blueborderline[r].x, y=land.getHeight({x = blueborderline[r].x, y = blueborderline[r].y}), z=blueborderline[r].y}, trigger.smokeColor.Green)--check smoke --trigger.action.smoke({x=blueborderlinevec3[r].x, y=land.getHeight({x = blueborderlinevec3[r].x, y = blueborderlinevec3[r].z}), z=blueborderlinevec3[r].z}, trigger.smokeColor.Red)--check smoke end And with this you check the units inside this polygon: ... blueborderviolationcheck = mist.pointInPolygon(possibleredintruderpos3, blueborderlinevec3) if blueborderviolationcheck == true and intrudergroupdetected == true then ... Edited September 20, 2013 by SNAFU [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
chromium Posted September 24, 2013 Share Posted September 24, 2013 Hi all, using MIST and the AI on/off scripting function I found an easy way to deactivate or set AI Off all the groups that have a particoular tag in their name. For example, given that in my scenery all te groups that belong to Abkhazia country coded with a name that contain "Abh" as a tag (i.e. "Abh_STR_Gudauta armybase"), I prepared a first script that create some global variables such as: --BLUE FACTION FILTER Russia_OUT_Scenery = false Russia_AI_Off = true Georgia_OUT_Scenery = false Georgia_AI_Off = true USA_OUT_Scenery = false USA_AI_Off = true Italy_OUT_Scenery = true Italy_AI_Off = true Ossetia_OUT_Scenery = true Ossetia_AI_Off = true --RED FACTION FILTER Circassia_OUT_Scenery = true Circassia_AI_Off = true KarachayCherkessia_OUT_Scenery = false KarachayCherkessia_AI_Off = true KabardinoBalkaria_OUT_Scenery = true KabardinoBalkaria_AI_Off = true Ingushetia_OUT_Scenery = true Ingushetia_AI_Off = true Abkhazia_OUT_Scenery = true Abkhazia_AI_Off = true than, to execute the filter I have a script that effectively contains a series of chunk like this: --Abkhazia units type "ABh" tag if Abkhazia_OUT_Scenery then local groupName local groupData local group_tag = "ABh" for groupName, groupData in pairs(mist.DBs.groupsByName) do --List of groups by name if string.find(groupName,group_tag) then --searches for prefix within group names local grp = Group.getByName(groupName) if grp then trigger.action.deactivateGroup(grp) else env.info(groupName) end end end end if Abkhazia_AI_Off then local groupName local groupData local group_tag = "ABh" for groupName, groupData in pairs(mist.DBs.groupsByName) do --List of groups by name if string.find(groupName,group_tag) then --searches for prefix within group names local grp = Group.getByName(groupName) if grp then trigger.action.setGroupAIOff(grp) else env.info(groupName) end end end end My question: is there a way to deactivate (not AI off) all the static structures that have the tag "Abh"? (enourmus credit to one of mine squadron mate that know some lua) 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 More sharing options...
chromium Posted September 27, 2013 Share Posted September 27, 2013 After some testing I finally found the right syntax. For all the clueless scripters like me, here an Example that works: [font=Verdana]--EWR unit to be named 'testEWR'[/font] [font=Verdana]--Unit to be detected named 'testintruder'[/font] [font=Verdana] function checkifunitdetected()[/font] [font=Verdana] possibleblueintrudergroupdetected = false[/font] [font=Verdana] local possibleblueintruder = Unit.getByName('testintruder')[/font] [font=Verdana] local redEWRgroup = Group.getByName('testEWR')[/font] [font=Verdana] local redEWRgroupcontroller = redEWRgroup:getController()[/font] [font=Verdana] possibleblueintrudergroupdetected = Controller.isTargetDetected(redEWRgroupcontroller, possibleblueintruder, RADAR) [/font] [font=Verdana] if possibleblueintrudergroupdetected == true[/font] [font=Verdana] then[/font] [font=Verdana] trigger.action.outText("Intruder detected", 2)[/font] [font=Verdana] elseif possibleblueintrudergroupdetected == false[/font] [font=Verdana] then[/font] [font=Verdana] trigger.action.outText("Intruder NOT detected", 2)[/font] [font=Verdana] end[/font] [font=Verdana]return timer.getTime() + 5 [/font] [font=Verdana]end[/font] [font=Verdana]timer.scheduleFunction(checkifunitdetected, nil, timer.getTime() + 2)[/font] Hi all, do you think that this function would work also if there are multiple groups from each side (groups that works as EWR and groups that works as Intruder)? I'm trying to understand if it's a good effort to try to include a groupname table instead of a unit name, to make the script valid for my purposes. thanks in advance 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 More sharing options...
SNAFU Posted September 30, 2013 Share Posted September 30, 2013 (edited) Should be possible. Here is the function I use to define the "detectors". I use the type of the unit to define all "red" units of the type "55G6 EWR" or "1L13 EWR" as "detectors": -- lists all red EWR groups in a table local function getallredEWR()--ok local RedEWRtable = nil local RedEWRtable= {} local RedEWRtable = {'[red]'} local allredEWRstart = nil local allredEWRstart = {} local allredEWRstart = mist.makeUnitTable(RedEWRtable) allredEWRunits = nil allredEWRunits = {} for a = 1, #allredEWRstart do local possibleredEWRunit = Unit.getByName(allredEWRstart[a]) local possibleredEWRunittype = Unit.getTypeName(possibleredEWRunit) if possibleredEWRunittype == "55G6 EWR" or possibleredEWRunittype == "1L13 EWR" --or possibleredEWRunittype == "A-50" then local RedEWRgroup = Unit.getGroup(possibleredEWRunit) allredEWRunits[#allredEWRunits + 1] = { group = RedEWRgroup } end end local allredEWRunitsTable = mist.utils.tableShow(allredEWRunits) --trigger.action.outText("Red EWR on map table:" ..allredEWRunitsTable, 5)--ok return timer.getTime() + 60, allredEWRunits end timer.scheduleFunction(getallredEWR, nil, timer.getTime() + 15) This regularly creates a table of in which all groups are listed, which act as EWR "detectors". Then I use the following lines with the function: . .. ... blueintrudergroupdetected = false if #allredEWRunits > 0 then for j = 1, #allredEWRunits do local possibleblueintruder = Unit.getByName(allblueairunits[i].name)--table of all blue units of type airplane and helicopter local redEWRgroup = allredEWRunits[j].group local redEWRgroupcontroller = redEWRgroup:getController() blueintrudergroupdetected = Controller.isTargetDetected(redEWRgroupcontroller, possibleblueintruder, RADAR) end end ... .. . This sets the boolean "blueintrudergroupdetected" to true and you can use it for other parts... When I finished the script to a reasonable degree (I know, they are never finished) I will post it here, so you can see how I tried it. ;) (So far it works, still some issues with interceptors going crazy...) Note that Controller.isTargetDetected - function does not seem to work with AWACS units. It only works with ground radar, don´t ask me why... Edited September 30, 2013 by SNAFU [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
galevsky06 Posted September 30, 2013 Share Posted September 30, 2013 I use mist.flagFunc.units_LOS instead. Works fine. Link to comment Share on other sites More sharing options...
SNAFU Posted September 30, 2013 Share Posted September 30, 2013 (edited) units_LOS should do the same more or less. I just like the idea that that RCS, RWR and if sensor activated is coupled to this and you can define the type of sensor used, not only straight line. PS: units_LOS might be a good workaround to simulate AWACS radars, which I didn´t get to function. But you need to know the detecting range of AWACS types... Edited September 30, 2013 by SNAFU [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
galevsky06 Posted September 30, 2013 Share Posted September 30, 2013 For my tests, RWR alert begins when unit_LOS becomes True, so it is OK for my needs. :) Link to comment Share on other sites More sharing options...
Recommended Posts