Maxime Posted April 12, 2020 Posted April 12, 2020 Hi, On the DCS maps there are already placed objects like building bridge etc... my question is how to know in the logs if the deck has been destroyed we can find the shots but not the destruction
Mano Posted April 12, 2020 Posted April 12, 2020 I think static scenery items can't be really considered destroyed as targets... This is a long term missing thing in dcs imho. However I've seen that for static scenery items there are arguments and variables to assign. I've never tried them but I can assume they can be used to verify whether a building is destroyed or something else. Inviato dal mio CPH1877 utilizzando Tapatalk [sIGPIC][/sIGPIC]
toutenglisse Posted April 12, 2020 Posted April 12, 2020 This function works using M.I.S.T. Here a .miz working exemple (unit near bridge for you to observe, explosion occures on bridge at 3 seconds and destroys it, then the M.I.S.T. function detects the bridge destroyed in zone and triggers a text and green smoke) "Object.isExist" function with inbuilt DCS Scripting should also work but I don't know how.MIST-SceneryObject-destroyed.miz
Rudel_chw Posted April 12, 2020 Posted April 12, 2020 This function works using M.I.S.T. Here a .miz working exemple ... Very nice tip .. thank you :thumbup: For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra For Gaming: 34" Monitor - Ryzen 3600 - 32 GB DDR4 2400 - nVidia RTX2080 - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar Mobile: iPad Pro 12.9" of 256 GB
wraith70 Posted April 13, 2020 Posted April 13, 2020 (edited) I use the mist.flagFunc.mapobjs_dead_zones() function. It works for bridges, haven't tried it on anything else: Just put a trigger zone over the bridge (ie named 'BridgeZone') handler = {} handler.init = function() world.addEventHandler(handler) end handler.onEvent = function (self,event) local vars = {} vars.zones = { 'BridgeZone' } vars.flag = 1 mist.flagFunc.mapobjs_dead_zones(vars) end To use this code, call it like this in ME: DO SCRIPT mist.flagFunc.mapobjs_dead_zones{ zones = {'Bridge11'}, flag = 1, req_num = 1 } Edited April 14, 2020 by wraith70
nebsar Posted April 14, 2020 Posted April 14, 2020 I use the mist.flagFunc.mapobjs_dead_zones() function. It works for bridges, haven't tried it on anything else: Just put a trigger zone over the bridge (ie named 'BridgeZone') handler = {} handler.init = function() world.addEventHandler(handler) end handler.onEvent = function (self,event) local vars = {} vars.zones = { 'BridgeZone' } vars.flag = 1 mist.flagFunc.mapobjs_dead_zones(vars) end Excuse me but I am new to DCS. Where do you write and run this piece of code?
wraith70 Posted April 14, 2020 Posted April 14, 2020 Please see the 3 screenshots of how I did it for a bridge. First screenshot - Make sure you load the latest MIST first Second screenshot - Copy the code above Third screenshot - When bridge is destroyed, flag 1 is TRUE, do something like I did. Message to ALL Substitute Bridge11 in the code with the name of your trigger zone.
wraith70 Posted April 14, 2020 Posted April 14, 2020 My bad...I gave you the actual function. The snippet you put in the trigger is: mist.flagFunc.mapobjs_dead_zones{ zones = {'Bridge11'}, flag = 1, req_num = 1 }
Majinbot Posted April 14, 2020 Posted April 14, 2020 Without using MIST, you can use the last function of the editor. You right-click on a building/Bridge/.., the word "assign as" appears, if you click on the word, you create a trigger zone connected to the building, then you have to copy the object id value, es. 123456. ADD SCRIPT: Handler = {} function Handler:onEvent(event) if event.id == world.event.S_EVENT_DEAD and event.IniUnitName == [color="red"]123456 [/color]then trigger.action.setUserFlag('1', true) end end world.addEventHandler(Handler) PC: i7-13700K - Gigabyte RTX 5080 GAMING OC - 64GB DDR5 6400 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + LG OLED 32GS95UE - TrackIR5 - Quest 3
wraith70 Posted April 14, 2020 Posted April 14, 2020 Without using MIST, you can use the last function of the editor. You right-click on a building/Bridge/.., the word "assign as" appears, if you click on the word, you create a trigger zone connected to the building, then you have to copy the object id value, es. 123456. ADD SCRIPT: Handler = {} function Handler:onEvent(event) if event.id == world.event.S_EVENT_DEAD and event.IniUnitName == [color="red"]123456 [/color]then trigger.action.setUserFlag('1', true) end end world.addEventHandler(Handler) That is slick!! I never knew about the "assign as" Thanks for contributing.
GTFreeFlyer Posted April 14, 2020 Posted April 14, 2020 I've been using the MIST functions successfully, but does anyone know if there's a way to count the number of ALIVE objects in a zone? For example, if I put a triggerzone around a city, I'm looking for a function to return how many objects are in that city. Thanks. My DCS Missions: Band of Buds series | The End of the T-55 Era | Normandy PvP | Host of the Formation Flight Challenge server Supercarrier Reference Kneeboards IRL: Private Pilot, UAS Test Pilot, Aircraft Designer, and... eh hem... DCS Enthusiast
Veteran66 Posted June 7, 2020 Posted June 7, 2020 hi all i try this script but it will not fire Flag 111 Handler = {} function Handler:onEvent(event) if event.id == world.event.S_EVENT_DEAD and event.IniUnitName == 217416645 then trigger.action.setUserFlag('111', true) end end world.addEventHandler(Handler) what is wrong? German WW2 Radio calls Mod: https://www.digitalcombatsimulator.com/en/files/2161798/
Majinbot Posted June 7, 2020 Posted June 7, 2020 hi all i try this script but it will not fire Flag 111 Handler = {} function Handler:onEvent(event) if event.id == world.event.S_EVENT_DEAD and event.IniUnitName == 217416645 then trigger.action.setUserFlag('111', true) end end world.addEventHandler(Handler) what is wrong? When I wrote the script I had loaded Moose, to work without moose try this HandlerScenery = {} function HandlerScenery:onEvent(event) if event.id == world.event.S_EVENT_DEAD and event.initiator:getName() == 217416645 then trigger.action.setUserFlag('111', true) end end world.addEventHandler(HandlerScenery) PC: i7-13700K - Gigabyte RTX 5080 GAMING OC - 64GB DDR5 6400 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + LG OLED 32GS95UE - TrackIR5 - Quest 3
Veteran66 Posted June 7, 2020 Posted June 7, 2020 THX this will work :) German WW2 Radio calls Mod: https://www.digitalcombatsimulator.com/en/files/2161798/
Pizzicato Posted June 8, 2020 Posted June 8, 2020 Very naive question, but where is the function onEvent defined? Is that a MOOSE function, or an embedded DCS function? Is there any documentation I can reference around it? HandlerScenery = {} function HandlerScenery:onEvent(event) i7-7700K @ 4.9Ghz | 16Gb DDR4 @ 3200Mhz | MSI Z270 Gaming M7 | MSI GeForce GTX 1080ti Gaming X | Win 10 Home | Thrustmaster Warthog | MFG Crosswind pedals | Oculus Rift S
Majinbot Posted June 8, 2020 Posted June 8, 2020 Is there any documentation I can reference around it? https://wiki.hoggitworld.com/view/DCS_func_addEventHandler PC: i7-13700K - Gigabyte RTX 5080 GAMING OC - 64GB DDR5 6400 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + LG OLED 32GS95UE - TrackIR5 - Quest 3
Pizzicato Posted June 8, 2020 Posted June 8, 2020 https://wiki.hoggitworld.com/view/DCS_func_addEventHandler Thanks for responding, Majinbot. I'm not sure how that relates to my question, though. I understand the concept of Events and Event Handlers, but I'm not clear on is how the function Handler:onEvent(event) definition works: Handler = {} function Handler:onEvent(event) if event.id == world.event.S_EVENT_DEAD <...snip...> As far as I can tell, Handler is initially declared as a generic Lua table. In the next line, however, it's being used as an EventHandler to capture the Event Table from a DCS event in the parameter named event. I looked the SSE page you referenced, but that doesn't have any reference to the onEvent() method call that's being used as part of the function definition. Where is that coming from, and how does it "know" to catch a DCS event? Apologies if I'm being super-dense, but I really want to wrap my head around this. i7-7700K @ 4.9Ghz | 16Gb DDR4 @ 3200Mhz | MSI Z270 Gaming M7 | MSI GeForce GTX 1080ti Gaming X | Win 10 Home | Thrustmaster Warthog | MFG Crosswind pedals | Oculus Rift S
Recommended Posts