Zayets Posted April 12, 2019 Share Posted April 12, 2019 I'm sorry, but you are wrong. I did the test by hitting only the runway and worked. And when I hit only a base object the flag does not activate. Do the test by yourself and you are gonna see the same results. This print that I did was to show that the unguided bombs are captured by HIT and trying to understand what @Hardcard was trying to say when he said “bomb don't generate HIT events” and if we are understand each other. I'm attaching a mission as an example where I only hit the runway and the code works. Press "F-10" in the mission and choose if you wanna hit only the runway or the base object and see by yourself the results. Tks again You are not saying anything different than what I have said. I did not said it was not working but merely stating that I don't know if category 4 (BASE) is seen as runway only or anything within the circle defining the airfield. [sIGPIC]OK[/sIGPIC] Link to comment Share on other sites More sharing options...
Bruce_D Posted April 12, 2019 Author Share Posted April 12, 2019 You are not saying anything different than what I have said. I did not said it was not working but merely stating that I don't know if category 4 (BASE) is seen as runway only or anything within the circle defining the airfield. Ok, now I understood what you are trying to say. I did the test, the category 4 is runway. I hit and killed the “BLOCK_WALL” object and other objects close to the runway and the flag was not activated. The mission that I’ve sent shows that, and I use it to hit other parts close to the runway. Sorry for the miss understood. I've changed the code with no successes. local Event_Handler = {} function Event_Handler:onEvent(Event) if Event.id == 2 and Event.target ~= nil then -- If it's a DEAD Event and the initiator is reachable local TargetObject = Event.target local TargetName = TargetObject:getName() local TargetCategory = TargetObject:getCategory() if TargetName == "Batumi" and TargetCategory == 4 then -- If the name and type of the object that has been destroyed match those of the specified runway trigger.action.setUserFlag("1", 1) -- sets the desired flag to a value of 1 end end end world.addEventHandler(Event_Handler) Link to comment Share on other sites More sharing options...
Bruce_D Posted April 12, 2019 Author Share Posted April 12, 2019 Ok, I believe that when I put the “event.target” nothing happens because when you hit the runway it does not generate an event. Am I correct by assuming that? Link to comment Share on other sites More sharing options...
Zayets Posted April 12, 2019 Share Posted April 12, 2019 Try to print on the screen or in the log the target name. That will tell you if you use the right one. [sIGPIC]OK[/sIGPIC] Link to comment Share on other sites More sharing options...
Bruce_D Posted April 12, 2019 Author Share Posted April 12, 2019 Try to print on the screen or in the log the target name. That will tell you if you use the right one. Tks for the tip. I followed your advise and printed on the screen the "event.target". When I hit anything on the map it shows the name and id, but when I hit the runway it does not show, confirming that it does not generate an event. Link to comment Share on other sites More sharing options...
Hardcard Posted April 12, 2019 Share Posted April 12, 2019 (edited) Guys, I'm trying things out right now. So far I've discovered that bomb impacts on the runway simply don't generate any HIT events. HIT events are only generated when the bombs hit lights and other objects located on the runway. DEAD events, however, are triggered every time the runway is hit after being "destroyed" (that's my best guess anyway). You'll see none of this in the briefing log, you need to get the event data real time in order to see it. I'll get back to it now. EDIT: Ok, so, since HIT events ignore runway impacts, and since there's no way (that I know of) to get a real time "damage/life reading" directly from the runway or to track bomb coordinates, I think a compromise is needed. For instance, you could place small static objects (like tiny flags) along the desired runway, then use them to raise HIT events as bombs hit them. That way you could trigger the ME flag before the runway is "destroyed". Edited April 12, 2019 by Hardcard [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Bruce_D Posted April 12, 2019 Author Share Posted April 12, 2019 (edited) Guys, I'm trying things out right now. So far I've discovered that bomb impacts on the runway simply don't generate any HIT events. HIT events are only generated when the bombs hit lights and other objects located on the runway. DEAD events, however, are triggered every time the runway is hit after being "destroyed" (that's my best guess anyway). You'll see none of this in the briefing log, you need to get the event data real time in order to see it. I'll get back to it now. Same results that I had. What I know is that when you hit the runway it stops work for a period of time (at least for the AI). So there is a command to AI saying that the runway is not working. If we can discover this command we can solve the problem. Edited April 12, 2019 by Bruce_D 1 Link to comment Share on other sites More sharing options...
Bruce_D Posted April 12, 2019 Author Share Posted April 12, 2019 EDIT: Ok, so, since HIT events ignore runway impacts, and since there's no way (that I know of) to get a "damage/life reading" directly from the runway or to track bomb coordinates, I think a compromise is needed.. The function getDesc() generates a Table and this function is accept for airbases. One of the outputs of this table is the life of an object. Question: How can I isolate one of this contents from a table to show as a text on a log? I'm trying to isolate the life from the table. Link to comment Share on other sites More sharing options...
Delta99 Posted April 12, 2019 Share Posted April 12, 2019 Same results that I had. What I know is that when you hit the runway it stops work for a period of time (at least for the AI). So there is a command to AI saying that the runway is not working. If we can discover this command we can solve the problem. If its not exposed through EVENTS you won't be able to discover it. Lots of stuff like this is internal to the DCS engine only. My Missions: Valley Patrol Mission :: Valley Escort Mission :: A2A Engagements Link to comment Share on other sites More sharing options...
Hardcard Posted April 12, 2019 Share Posted April 12, 2019 (edited) The function getDesc() generates a Table and this function is accept for airbases. One of the outputs of this table is the life of an object As I said, there's no way to get a real-time "life reading" from runways. That only works with units, statics and some scenery. When you run :getDesc() you're simply accessing a fixed table of attributes. If you do :getDesc().life, you're only getting the theoretical max life of the runway "on paper", so to speak. It's not the real-time life value, which is why I told you it can't be done (as far as I know). It's looking more and more like your best bet is to either stick with the script as is or to place tiny static objects on the runway, so HIT events can be generated. Edited April 12, 2019 by Hardcard [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Bruce_D Posted April 12, 2019 Author Share Posted April 12, 2019 It worked!!!!! I discovered that Batumi has a life of 3600 before I hit it with a missile and a life of 2 when it is dead!!!! Give me a few minutes so I can write a code and see if it works Link to comment Share on other sites More sharing options...
Hardcard Posted April 12, 2019 Share Posted April 12, 2019 (edited) It worked!!!!! I discovered that Batumi has a life of 3600 before I hit it with a missile and a life of 2 when it is dead!!!! The "life 2" value is what I get from the runway description table, it's not a real-time "life reading". I think you got the life value from the description table of another object (your plane maybe), when it initiated a different event (a SHOOT event, for instance). That might be where the 3600 came from. :getLife() is the method we'd use to get the real-time "life reading" of objects, but it only works for units, statics and some scenery... afaik, it doesn't work for airbases/runways. EDIT: Ok, I stand corrected, the following line does return a value of 3600: local BatumiLife = Airbase.getByName("Batumi"):getDesc().life But again, I don't think this is a real-time "life reading", I believe it's still reading from a fixed table. Edited April 12, 2019 by Hardcard [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Bruce_D Posted April 13, 2019 Author Share Posted April 13, 2019 (edited) Sorry, I was working. If you use this code before you hit the Runway you will get 3600 as a result: function repetir(repete) local teste = Airbase.getDescByName("Batumi").life trigger.action.outText(teste, 50) end But if you use the same code after you hit the Runway you will get 2 as a result. The problem is once you use it, the mission will generate a table and every time that you use it for the select airbase it will use the data from the table instead of generate a new table. Edited April 13, 2019 by Bruce_D Link to comment Share on other sites More sharing options...
Hardcard Posted April 13, 2019 Share Posted April 13, 2019 @Bruce_D It's a pity that :getLife() won't work with runways. As I said, you can try placing tiny statics on the runway in order to achieve the desired behaviour. Other than that, I'm out of ideas :doh: [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Bruce_D Posted April 13, 2019 Author Share Posted April 13, 2019 (edited) Yeap, the :getLife() would be perfect! Tks for your help. I'm gonna use your code for destruction and the function repetir(repete) local teste = Airbase.getDescByName("Batumi").life trigger.action.outText(teste, 50) end For a reconnaissance mission for after the attack. Anyway, it was fun to play with this script, hope that ED change the :getLife() I will travel for at least a month, but as soon as I'm back, I'm gonna post the code Tks Edited April 13, 2019 by Bruce_D Link to comment Share on other sites More sharing options...
Bruce_D Posted April 15, 2019 Author Share Posted April 15, 2019 Hi, I’ve manage to finish the script before my trip. Thank you for the help!Runway.lua Link to comment Share on other sites More sharing options...
Bruce_D Posted September 9, 2019 Author Share Posted September 9, 2019 Hi guys, I came back to this tread because I managed to create a function that checks when the runway is damage and you can use it during the entire mission. Function CheckBase: function CheckBase(Check) -- Damage runway local base = Airbase.getByName(Check):getLife() -- Check the airbase's life if base ~= 3600 then trigger.action.setUserFlag("28", 1) -- sets the desired flag to a value of 1 end end And here is an example on how to use it on a script: local Event_Handler = {} function Event_Handler:onEvent(Event) if Event.id == 1 and Event.initiator ~= nil then -- If it's a Shot Event and the initiator is reachable local PlaneShoot = Event.initiator:getName() local WeaponShoot = Event.weapon:getName() if PlaneShoot == "Player 1" or PlaneShoot == "Player 2" or PlaneShoot == "RA-1" or PlaneShoot == "RA-2" then if string.find(WeaponShoot, 167) == nil then -- first 3 numbers for A2A Missiles, LUU-2B, GBUs (except GBU-24) and ADM-141A for the F-14 and F/A-18 if string.find(WeaponShoot, 168) == nil then -- first 3 numbers for A2A Missiles, LUU-2B, GBUs (except GBU-24) and ADM-141A for the F-14 and F/A-18 CheckBase('Bandar-e-Jask airfield') end end end end end world.addEventHandler(Event_Handler) function CheckBase(Check) -- Damage runway local base = Airbase.getByName(Check):getLife() -- Check the airbase's life if base ~= 3600 then trigger.action.setUserFlag("28", 1) -- sets the desired flag to a value of 1 end end I’ve attached a mission for the Persian Gulf as an example.Runway attack test.miz Link to comment Share on other sites More sharing options...
brontolo Posted December 8, 2020 Share Posted December 8, 2020 Hi bruce, good work, very helpful! I've a question: which is the flag that becomes true when the runway is damaged? Is it in the file "teste2"? Tks Brontolo VIAF Link to comment Share on other sites More sharing options...
Chump Posted December 8, 2020 Share Posted December 8, 2020 @Bruce_D So getLife() does work with Airbase objects? Link to comment Share on other sites More sharing options...
Bruce_D Posted December 9, 2020 Author Share Posted December 9, 2020 Hi @Chump, Good question. I've only tried for the runway. But I'm creating a dynamic campaign and I'll try for other objects on the airbase. But one bomb may destroy other areas of the airbase. Hi @brontolo, yes! Teste2 is the lua file for the mission. Open the misson with winrar and you will find the teste2.lua file. Best regards Link to comment Share on other sites More sharing options...
brontolo Posted December 9, 2020 Share Posted December 9, 2020 (edited) 1 hour ago, Bruce_D said: Hi @brontolo, yes! Teste2 is the lua file for the mission. Open the misson with winrar and you will find the teste2.lua file. Best regards Hi Bruce, thanks, I did it, I've find the file but I'm a beginner, I don't know which flag (27, 29, 31, 28) becomes true if the runway is damaged (I would use it to give a message like "Good hit!") Thanks a lot again Brontolo Edited December 9, 2020 by brontolo Brontolo VIAF Link to comment Share on other sites More sharing options...
Bruce_D Posted December 9, 2020 Author Share Posted December 9, 2020 Hi, Long time that I saw this file, but I thing is 28. I have changed it a lot. Open the lua file and search for the word "if base ~= 3600". Below that you are going to see the flag number. Link to comment Share on other sites More sharing options...
ElementLT Posted December 9, 2020 Share Posted December 9, 2020 On 9/9/2019 at 7:24 PM, Bruce_D said: Hi guys, I came back to this tread because I managed to create a function that checks when the runway is damage and you can use it during the entire mission. Function CheckBase: Reveal hidden contents function CheckBase(Check) -- Damage runway local base = Airbase.getByName(Check):getLife() -- Check the airbase's life if base ~= 3600 then trigger.action.setUserFlag("28", 1) -- sets the desired flag to a value of 1 end end And here is an example on how to use it on a script: Reveal hidden contents local Event_Handler = {} function Event_Handler:onEvent(Event) if Event.id == 1 and Event.initiator ~= nil then -- If it's a Shot Event and the initiator is reachable local PlaneShoot = Event.initiator:getName() local WeaponShoot = Event.weapon:getName() if PlaneShoot == "Player 1" or PlaneShoot == "Player 2" or PlaneShoot == "RA-1" or PlaneShoot == "RA-2" then if string.find(WeaponShoot, 167) == nil then -- first 3 numbers for A2A Missiles, LUU-2B, GBUs (except GBU-24) and ADM-141A for the F-14 and F/A-18 if string.find(WeaponShoot, 168) == nil then -- first 3 numbers for A2A Missiles, LUU-2B, GBUs (except GBU-24) and ADM-141A for the F-14 and F/A-18 CheckBase('Bandar-e-Jask airfield') end end end end end world.addEventHandler(Event_Handler) function CheckBase(Check) -- Damage runway local base = Airbase.getByName(Check):getLife() -- Check the airbase's life if base ~= 3600 then trigger.action.setUserFlag("28", 1) -- sets the desired flag to a value of 1 end end I’ve attached a mission for the Persian Gulf as an example. Runway attack test.miz 10.37 kB · 93 downloads thank you so much for the @Bruce_D !!! this was so much needed! Coming Soon... The Fraternity Returns : https://thefraternitysim.com/ Link to comment Share on other sites More sharing options...
Bruce_D Posted December 9, 2020 Author Share Posted December 9, 2020 6 minutes ago, ElementLT said: thank you so much for the @Bruce_D !!! this was so much needed! Pleasure. If you want I can post a new function that it is more useful. Link to comment Share on other sites More sharing options...
ElementLT Posted December 9, 2020 Share Posted December 9, 2020 6 minutes ago, Bruce_D said: Pleasure. If you want I can post a new function that it is more useful. yes PLEASE! I am currently working on my next multiplayer server development now and this would be a great addition! Thank you for your hard work sir! Coming Soon... The Fraternity Returns : https://thefraternitysim.com/ Link to comment Share on other sites More sharing options...
Recommended Posts