Jump to content

already placed objects like building bridge


Maxime

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

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 by wraith70
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

trigger0.thumb.JPG.5a0d7c131b607761f391a3bda79f1991.JPG

trigger1.thumb.JPG.c1ea491e80bf73751a9e19d6c585e6aa.JPG

trigger2.thumb.JPG.55f285446e03895f7ed36f89913e1c70.JPG

Link to comment
Share on other sites

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 - MSI RTX 4080 Gaming X Trio - 32GB DDR5 6200 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + Acer XB271HU - TrackIR5 - Rift S

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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?

Link to comment
Share on other sites

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 - MSI RTX 4080 Gaming X Trio - 32GB DDR5 6200 - VPC MongoosT-50CM3 - VKB GF pro - MFG Crosswind - Msi MPG321UR-QD + Acer XB271HU - TrackIR5 - Rift S

Link to comment
Share on other sites

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

Link to comment
Share on other sites

 

 

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

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...