Irishlad200000 Posted October 8, 2020 Posted October 8, 2020 What is the cleanest way to have an action triggered when a scenery building is destroyed? Have tried various things but looking the cleanest way to do it. Sent from my SM-G981B using Tapatalk
Repth Posted October 8, 2020 Posted October 8, 2020 Depends, are you talking scripted mission with specifically assigned ordinance or open type mission?
Pikey Posted October 10, 2020 Posted October 10, 2020 I don't know of multiple ways, I only know that an event handler looking for th eunit ID would be the most direct. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
feefifofum Posted October 11, 2020 Posted October 11, 2020 (edited) Use the handy new right click tool to retrieve the object ID, then write a simple event handler to detect when it is destroyed. StaticHandler = {} function StaticHandler:onEvent(event) if event.id == world.event.S_EVENT_DEAD and event.initiator:getName() == 72455195 then trigger.action.setUserFlag('1', true) end end world.addEventHandler(StaticHandler) Edited October 20, 2020 by feefifofum THE GEORGIAN WAR - OFFICIAL F-15C DLC
Galwran Posted October 16, 2020 Posted October 16, 2020 Where and how this event handler should be ran?
feefifofum Posted October 20, 2020 Posted October 20, 2020 Paste that text into a DO SCRIPT container, and replace the object and flag IDs with the desired value. You can also create a .lua file using Notepad++ with that text, and use DO SCRIPT FILE instead. Here's an example using a building at SukhumiStatic Handler Example using DO SCRIPT.miz THE GEORGIAN WAR - OFFICIAL F-15C DLC
Mr_Burns Posted December 5, 2020 Posted December 5, 2020 I think the buildings need to be more interactive, perhaps even making more building objects so you can build a small village of friendly and hostile buildings youself so you can attack on and not damage others. Also, buildings that cars can enter, so perhaps a UAV tracking a UAZ or Ural triggers to attack this building in so many minutes before the target leaves. I suppose a mission scripter could have a checkpoint defended by Bluefor with attacking Redfor who they need defend or resupply with troops in helo mission... I just think the aircraft are solid, the weapons are awesome but the ground interaction is somewhat missing for us CAS and Ground Pounders!
cfrag Posted April 5, 2021 Posted April 5, 2021 On 10/20/2020 at 4:09 AM, feefifofum said: Paste that text into a DO SCRIPT container, and replace the object and flag IDs with the desired value. You can also create a .lua file using Notepad++ with that text, and use DO SCRIPT FILE instead. Here's an example using a building at Sukhumi Static Handler Example using DO SCRIPT.miz 8.29 kB · 38 downloads Thank you @feefifofum for kindly providing that example. I loaded it up to analyze and learn, only to find out that it does not work; after the building explodes there is no message. I added a plane so I could receive Message To All as player or client, but it seems that flag 1 is never set, i.e. the event handler is not executed. I'm running the latest DCS open beta. Thanks for any pointers what I'm doing wrong. 1
feefifofum Posted April 5, 2021 Posted April 5, 2021 (edited) Looks like there is some type of bug at the moment. The object ID should be visible in the "dead" event, but it appears it is not being passed to the scripting engine for some reason. Edited April 5, 2021 by feefifofum THE GEORGIAN WAR - OFFICIAL F-15C DLC
cfrag Posted April 5, 2021 Posted April 5, 2021 I ran more test. After some back and forth, I discovered that the object ID was a mismatch. In my version, that object has the ID 78385155 instead of 72455195. This has me worried - are object IDs subject to change? That would make writing missions for other people impossible. -ch
feefifofum Posted April 5, 2021 Posted April 5, 2021 This is probably a bug; I remember an instance recently where airfield IDs were accidentally swapped around. In the editor, you can right click on the object and click "assign as." This will show you the object ID. I'll fiddle around some more when time allows, only had 2 minutes to quickly run the existing .miz and begin wild speculation 1 THE GEORGIAN WAR - OFFICIAL F-15C DLC
cfrag Posted April 5, 2021 Posted April 5, 2021 (edited) Thank you! That is exactly what I did and how I discovered the ID mismatch. The question is now: is the mismatch specific to my copy of DCS, or is that object's ID different for all who have my version. Note: the building is destroyed (the explode action does that) - but it does not trigger the script since the ID with your kindly provided script mismatches. hence no setting flag to 1, hence no message to all. Edited April 5, 2021 by cfrag
feefifofum Posted April 5, 2021 Posted April 5, 2021 (edited) On my end, the object ID did match with the one in the script, but the script still didn't function properly due to the apparent absence of the object ID passed to the engine, as shown in my screenshot. Previously the ID number given by the "assign as" function in the ME would match the display in the after-action report in the "Initiator" field. Either something fundamental has changed with the SSE, or there is a bug in the current build. Given the active development state of the DCS core engine, either is a possibility! I also have a ton of mods enabled in my OB installation so I'd need to do some thorough prodding before I could definitively make a bug report. The fact that both of us are seeing some strange behavior here, though, is telling, and this definitely worked when I posted it! Edited April 5, 2021 by feefifofum THE GEORGIAN WAR - OFFICIAL F-15C DLC
toutenglisse Posted April 6, 2021 Posted April 6, 2021 It works with this script example : Dead zone condition - Mission Editor Discussion and Questions - ED Forums (eagle.ru)
Recommended Posts