Glloq Posted October 2, 2022 Posted October 2, 2022 (edited) Hello, I'm trying on the Caucasus map to get a list of scenery objects in a specific zone to choose randomly one of them to be the player ground target. Using world.searchObjects I was able to get the list of scenery objects in this zone. The problem is I have no way with those data to know what type of building or object my sceneryObject is, its location or if it's destroyed or not. Here is a sample of what I get for each sceneryObject: { life= 0, attributes= { Buildings= "true", }, _origin= "", category= 4, typeName= "146867008", displayName= "", } It's quite hard to check if it is a bridge, a specific building or whatever. Am I missing something? I can't get the object position in the zone I'm checking so I don't know where to strike to check the object life but I would guess that life = 0 is the default value for a scenery object? Thanks for your help Edited October 2, 2022 by Glloq
toutenglisse Posted October 3, 2022 Posted October 3, 2022 @Glloq you can apply several functions on found objects. The sample you get seems to come from getDesc() but with strange results. example attached : at mission start you get by message the description (position, life, typename etc...) of objects from a bridge (inside 'test' zone). Note that some scenery objects (including some bridges) are not found by world.searchObjects. test-sceneryDatas.miz
Glloq Posted October 3, 2022 Author Posted October 3, 2022 Thanks! You were right I was using later after the world.searchObject a call to SceneryObject.getDescByName on one of the found object before trying to display its data so obviously I only have the object desc part. Changing the world.searchObject handler by something quite similar to what you send I'm now able to see more data and find some bridges (MOST in russian ) with those data : { y= 12.411687850952, x= -267516.02490234, name= 72450049, z= 606664.90625, desc= { life= 500, attributes= { Buildings= "true", }, _origin= "", category= 4, typeName= "MOST(ROAD)BIG", displayName= "", }, } So now I can filter bridge objects by looking for a typeName starting with "MOST", I know their location and for each bridge section its specific name ("72450049" here ). I can choose randomly between them, I just need to check when the bridge is destroyed for what I need. Do you feel I will have more luck with listening to a dead event or can I create by script a zone including this bridge and just check with mist.flagFunc.mapobjs_dead_zones ? Anyway thanks a lot and merci !
toutenglisse Posted October 3, 2022 Posted October 3, 2022 1 hour ago, Glloq said: ...Do you feel I will have more luck with listening to a dead event or can I create by script a zone including this bridge and just check with mist.flagFunc.mapobjs_dead_zones ? Anyway thanks a lot and merci ! knowing the name (unique number) or the names (if made from several objects like bridge) of the target it will be more simple to use dead event and compare initiator name with target name/names (mist.flagFunc.mapobjs_dead_zones don't name-check dead map objects, but how many died in zone, how to size correctly the dynamically created zone ?...).
Glloq Posted October 5, 2022 Author Posted October 5, 2022 Indeed using an eventHandler for world.event.S_EVENT_DEAD and checking that event.initiator['id_'] match the selected found unit name make me able to manage when the selected target is destroyed. I just need to tune my random target selection from the scenary objects found to have an appropriate target (like a bridge or warehouse or whatever) and I will finally be able to use this like I want for my mission. Thanks for your help! Glloq over
Grimes Posted October 6, 2022 Posted October 6, 2022 In the mission editor you can right click on world objects and "assign as". This creates a trigger zone with the current id and object type name in the zone properties, however there are potential problems with both of these. The typename is formatted with string.lower, so it might not precisely match the actual typename string. The object ID is not a fixed value from patch to patch. Specifically if the map updates then the object IDs can change, either by representing an entirely other object or is simply no longer in use. So it is best to look for a certain object type at specific coordinates. 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
Glloq Posted October 8, 2022 Author Posted October 8, 2022 I barely use scenery object ID. I use the typeName of the unit found using the world.searchObject at the beginning of the mission to check if this is a valid target (bridge or warehouse for example) and then I only use its object id to check if its destroyed or not during the mission. So as long as the scenery object ID change during one instance of the mission I'm good. The downside of my solution is I have to check first ( I mean before running the mission with my friends) to check all the scenery objects typeName in the area I want to strike to know which one to use or which one to filter: I don't want to order a strike on light pole ^^ . So if i want to reuse this code on another map or area I will have to check all available scenery first and choose which I one to use or filter for the upcoming mission. I can't use the ME "assign as" since I want random target and the zone where I can select is too wide to add then all through the mission editor. I will try to post a working lua script once done but right now I'm trying to task those strike on scenery objets with Moose TASK_A2G_DISPATCHER but I can't get a way to add it in a Detection. If I can't I will add some radios menus to repeat the target coordinates and launch a smoke on them.
Glloq Posted December 5, 2022 Author Posted December 5, 2022 Hello everyone! It's been a long time but I've been busy with some IRL issues and the scope of my work has been a bit extended as you will see. Thanks to you I was able a script called Strategic Target Strike Dispatcher (lua provided as attached files and examples mission too (soon as a DCS user file) ). But let's start with some infos about this first: **** STRATEGIC TARGET STRIKE DISPATCHER by Glloq (Caucasus and Syria compatible) The strategic target strike dispatcher mission is more kind of a template mission you can customize than a mission. It will allow you to strike a group of scenery objets (like bridges, factories or buildings) already included in the map in circular zones you have selected (by default a single circular zone called "targetZone"). Selected targets area will be marked on the F10 minimap and the mission briefing will pop with coordinates and target list (You can ask for a summary anytime via the F10 radio menu) Feel free to move the zone or add more, add or change aircrafts/helicopters types or add enemy units. Don't forget to bring the heavy weapons because some targets are tough to destroy Thanks to toutenglisse for helping me to understand how to get full SceneryObject data Thanks to everyone behind MIST and MOOSE Frameworks that made this possible Thanks to everyone from my virtual squadron "8TH Rapaces" for being the boldest and greatest beta testers Using the F10 Radio Menu you will find the "Strategic targets strike" menu. Inside it you can : - ask for the mission briefing with target area coordinates and description of all the remaining targets to destroy - pop a smoke (Green, orange, red or white at will) - skip to next strategic targets. It will cancel the current strategic targets list and select after a few seconds another list of strategic targets to strike Restrictions: - Only work on the Caucasus and Syria map right now but there are enough debug tools to expand it to others maps - Menu is for blue coalition by default but you can change it by calling setDispatcherForBlueCoalition() or setDispatcherForRedCoalition() before the startDispatcher function - Once the lua file loaded you can use addCircularZone(zoneName) to add zones where you want to scan for "strategic targets" to strike. Then use startDispatcher() to launch the selection. It should be done in mission start due to how long the process take - Obviously the bigger the zone, the more time it will take to evaluate "strategic targets group" when a new one is requested - You can choose to strike only one scenery object of a time instead of a group around X meters from the first one to bypass the freeze at strategic target selection. For this you need to comment the call to getLocalStrategicTargetsInArea(strategicTarget, 1000). checkForAdditionalStrategicTargetsInArea method is then useless too. Known bugs: - {typeName = "PLATFORMA_AKACYA", description ="Railway wagon with artillery tank"}, --Railway wagon with artillery tank on it //FIXME WHY OTHER RAILWAY WAGON ARE NOT FOUND ? DCS Caucasus Issue ? - Scenery objetcs wih null typeName on Caucasus Scenery objects are grouped by custom theme and you can choose to pick from one or not in insertFoundUnitInStrategicTargetListIfNeeded method. Choose wisely and don't commit war crimes ! Scenery objects are only added in the list of available strategic targets only if they are valid targets. A scenery object has the validTarget property set to true if visible, can be destroyed, and visually identify it among others. If I keep improving this code next features would be adding defenses to target area (depending strategic value?) but don't expect anything before at least "Two weeks©" **** So, as said above with this I'm now able to make players strike any scenery objects already included on the map like bridges, warehouses, power plants, etc... I keep track of destroyed buildings and once all the targeted scenery objects in a area are destroyed the script will provide you another list of scenery objects to destroy. And if you feel it's not the right kind of targets or location you can skip this list and ask for another one. I use this script for a Vietnam-like mission (not the one provided here) on the Caucasus map to offer pilots some variety in targets choice over enemy territory. I don't provide a specific protection for those targets but there is already a lot of AAA, SAM and enemy aircrafts that can destroy then while flying to targets. Obviously they are still free to engage targets of opportunity but pilots from my squadron like shiny "All targets destroyed" and "Mission done" messages during our flying nights. There is room for tuning for the scripts since scenery objects are sorted by custom categories like hotels, airport stuff, railway stuff, warehouses, etc... So I put whatever appropriate targets I feel for my mission. Missions provided here are kind of templates to start a mission with this script on Caucasus and Syria maps. Since I use scenery objects typenames that means that for each map I have to identify and sort every type of scenery objects, check if they can be destroyed (lot of indestructible objects on Syria unlike the Caucasus map), and sort them by categories. That's why only Caucasus and Syria are supported right now (Syria took me one additional month but it was worth to see how I should sort scenery objects) and I will look to expand it in the future on the maps I own. Aside compatibility with other maps I don't know yet what else to do about it. I think a great step would be to provide an appropriate defense for those targets depending their strategic values but defense vary a lot whether you are flying in 1970 or 2020... Another think to do would be to check with some other scripts that allow you to progress with territory taken and how strategic targets can provide you bonus if you keep them safe or if you destroy the opponent ones. Lastly, I'm more an oriented object developer and my lua skills are still low so maybe I can find some ways to better sort all thoses scenery objects. Feel free if you have any question or suggestions and thanks again for your help ! Glloq StrategicTargetStrikeDispatcher.lua StrategicTargetStrikeDispatcherCaucasus_v1p0.miz StrategicTargetStrikeDispatcherSyria_v1p0.miz
Recommended Posts