Jeepnaked95 Posted June 28, 2022 Share Posted June 28, 2022 New to game and mission building I'm trying to do a simple BFM mission to fly with my brother, but the only thing I'd like to add is to have smoke come on whenever one of us gets hit. so Trigger 1 -> unit hit -> smoke on / Message "Hit" Trigger 2 -> time sense flag x - 3 sec -> smoke off Not sure if I use triggers or scripts for this sort of thing, I can get that to work only once a question is how do I make it loop so we can continue the fight and smoke comes back on with another hit ? any help would be great. Link to comment Share on other sites More sharing options...
Rudel_chw Posted June 28, 2022 Share Posted June 28, 2022 4 minutes ago, Jeepnaked95 said: I can get that to work only once a question is how do I make it loop so we can continue the fight and smoke comes back on with another hit ? The DCS trigger logic is not like a traditional programming language, as it does not have the typical control flow instructions like IF THEN ELSE or DO LOOP. Instead, the triggers are a linear sequence of sentences, that are executed from first to last sequentially, once per second. Each sentence has two main parts: a condition, and an action. The action gets executed only if the condition is true. Now, the fun part, is that when a condition is true, the action gets executed, and then the whole trigger is REMOVED from the execution sequence, its action only works the first time the condition is true (which is your current case) .. this type of trigger, that only are executed once, is the ONCE trigger. There are other types available, for example the type REPETITIVE ACTION is a trigger that is never removed from the execution sequence, its condition is evaluated once per second, and each time its true, its Action gets executed. A third trigger type is the SWITCHED CONDITION, this trigger executes its action each time its condition is evaluated as true, and its previous evaluation was false. This is like a flip flop, the action gets executed the first time the condition is true, if the next second the condition is still true the action will not be executed ... then if at some point its condition should be false, then the trigger is ready to do its action the next time it becomes true. Finally, the fourth trigger type is MISSION START .. these triggers get evaluated only at the start of the mission, even before you are actually seated at your aircraft .. it is used to setup the mission the way you need at its start. For your case, you should use either REPETITIVE ACTION or SWITCHED CONDITION, as they are the only triggers that can perform its action more than once. 3 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 More sharing options...
kontiuka Posted June 28, 2022 Share Posted June 28, 2022 56 minutes ago, Jeepnaked95 said: New to game and mission building ... 35 minutes ago, Rudel_chw said: Finally, the fourth trigger type is MISSION START .. these triggers get evaluated only at the start of the mission, even before you are actually seated at your aircraft .. it is used to setup the mission the way you need at its start. Good explanation. And I would just add, if it isn't obvious, that no conditions need to be provided for MISSION START since the mission starting is the condition. Also, if you don't want to wait a second for a trigger to execute, you can setup event listeners using lua scripting. 1 Link to comment Share on other sites More sharing options...
Jeepnaked95 Posted June 28, 2022 Author Share Posted June 28, 2022 Good explanation. And I would just add, if it isn't obvious, that no conditions need to be provided for MISSION START since the mission starting is the condition. Also, if you don't want to wait a second for a trigger to execute, you can setup event listeners using lua scripting.Thanks! I’ve tried a few set ups that I’ve found on here regarding the “loop” setting but I can only trigger the smoke on first hit after that it won’t come back on… as far as the lua scripting I’m still new to that! Sent from my iPhone using Tapatalk Link to comment Share on other sites More sharing options...
kontiuka Posted June 28, 2022 Share Posted June 28, 2022 32 minutes ago, Jeepnaked95 said: Thanks! I’ve tried a few set ups that I’ve found on here regarding the “loop” setting but I can only trigger the smoke on first hit after that it won’t come back on… as far as the lua scripting I’m still new to that! If you post your mission file here, I'm sure someone would be happy to take a look. Link to comment Share on other sites More sharing options...
Jeepnaked95 Posted June 28, 2022 Author Share Posted June 28, 2022 If you post your mission file here, I'm sure someone would be happy to take a look.Ah didn’t think about that… I’ll try to upload it tomorrow Sent from my iPhone using Tapatalk Link to comment Share on other sites More sharing options...
Mistermann Posted June 28, 2022 Share Posted June 28, 2022 I think you can do this, but it will take some advanced (to me) trigger formatting. There are events that can be associated with triggers. Most of the time triggers are created with "NO EVENT" - at least in my missions that's often the case. BUT, if you associate an event with "ON SHOT", I think you can craft the type of results you're looking for. You'll have to play around with the trigger, but I THINK, you establish a Repetitive Action trigger with the ON SHOT event. Then in your conditions, you have to check to see who was damaged with the UNIT DAMAGED condition. Once you know who was damaged, you can trigger smoke. Its been a while since I've done something like this, so this is all a bit fuzzy to me. If you post the mission, I am sure others will assist in getting this figured out. System Specs: Spoiler Processor:13th Gen Intel(R) Core(TM) i9-13900K - RAM: 64GB - Video Card: NVIDIA RTX 4090 - Display: Pimax 8kx VR Headset - Accessories: VKB Gunfighter III MCG Ultimate, Thrustmaster TWCS (modified), Thrustmaster TPR Pedals, Simshaker JetPad, Predator HOTAS Mounts, 3D Printed Flight Button Box Thrustmaster TWCS Mod Link to comment Share on other sites More sharing options...
Jeepnaked95 Posted June 28, 2022 Author Share Posted June 28, 2022 I think you can do this, but it will take some advanced (to me) trigger formatting. There are events that can be associated with triggers. Most of the time triggers are created with "NO EVENT" - at least in my missions that's often the case. BUT, if you associate an event with "ON SHOT", I think you can craft the type of results you're looking for. You'll have to play around with the trigger, but I THINK, you establish a Repetitive Action trigger with the ON SHOT event. Then in your conditions, you have to check to see who was damaged with the UNIT DAMAGED condition. Once you know who was damaged, you can trigger smoke. Its been a while since I've done something like this, so this is all a bit fuzzy to me. If you post the mission, I am sure others will assist in getting this figured out.Correct… I’ve tried to play with it a few different ways, I can get it go on and off after a few seconds. Just can’t figure out how to get the trigger to reset and smoke go on again on another hit once’s fight is back on. wonder if it has to do with me having the aircraft place to immortal… Sent from my iPhone using Tapatalk Link to comment Share on other sites More sharing options...
Mistermann Posted June 28, 2022 Share Posted June 28, 2022 (edited) If the aircraft is immortal it will never be "damaged", so make sure you're using the proper condition. I think it's called UNIT HIT. If you're using UNIT DAMAGED, it'll never trigger. Also, there's some great information on ME trigger's here in @Reflected thread. Edited June 28, 2022 by Mistermann 1 System Specs: Spoiler Processor:13th Gen Intel(R) Core(TM) i9-13900K - RAM: 64GB - Video Card: NVIDIA RTX 4090 - Display: Pimax 8kx VR Headset - Accessories: VKB Gunfighter III MCG Ultimate, Thrustmaster TWCS (modified), Thrustmaster TPR Pedals, Simshaker JetPad, Predator HOTAS Mounts, 3D Printed Flight Button Box Thrustmaster TWCS Mod Link to comment Share on other sites More sharing options...
toutenglisse Posted June 28, 2022 Share Posted June 28, 2022 (edited) 23 hours ago, Jeepnaked95 said: ...how do I make it loop so we can continue the fight and smoke comes back on with another hit ?... You can use this script (copy - Ctrl C - and paste - Ctrl V - in a "do script" action box at mission start : Spoiler AllPlaneUnits = {} function PlanesTable() for i = 1, 2 do local allGroups = coalition.getGroups(i, 0) if #allGroups > 0 then for j = 1, #allGroups do local gpUnits = allGroups[j]:getUnits() if #gpUnits > 0 then for k = 1, #gpUnits do table.insert(AllPlaneUnits, gpUnits[k]) end end end end end end PlanesTable() function Smoke_Off(unit) SmokeOff = { id = 'SMOKE_ON_OFF', params = { value = false } } unit:getController():setCommand(SmokeOff) trigger.action.ctfColorTag(unit:getName() , 0) table.insert(AllPlaneUnits, unit) end AllEvents = {} function AllEvents:onEvent(event) if event.id == world.event.S_EVENT_HIT and event.initiator and event.target then for i = 1, #AllPlaneUnits do if event.target == AllPlaneUnits[i] then table.remove(AllPlaneUnits, i) SmokeOn = { id = 'SMOKE_ON_OFF', params = { value = true } } event.target:getController():setCommand(SmokeOn) trigger.action.ctfColorTag(event.target:getName() , (event.target:getCoalition() == 1 and 2 or 5)) timer.scheduleFunction(Smoke_Off, event.target, timer.getTime() + 5) trigger.action.outText((event.target:getPlayerName() and event.target:getPlayerName() or event.target:getTypeName()) ..' got hit by '..(event.initiator:getPlayerName() and event.initiator:getPlayerName() or event.initiator:getTypeName()), 5) end end elseif event.id == world.event.S_EVENT_BIRTH then if event.initiator:getDesc()["category"] == 0 then table.insert(AllPlaneUnits, event.initiator) end end end world.addEventHandler(AllEvents) Also .miz example attached (red AI vs blue AI, plus a client F18) test-smoke-on-hit-script.miz Edited June 28, 2022 by toutenglisse fix on script 1 1 Link to comment Share on other sites More sharing options...
Jeepnaked95 Posted June 28, 2022 Author Share Posted June 28, 2022 1 hour ago, toutenglisse said: You can use this script (copy - Ctrl C - and paste - Ctrl V - in a "do script" action box at mission start : Hide contents AllPlaneUnits = {} function PlanesTable() for i = 1, 2 do local allGroups = coalition.getGroups(i, 0) if #allGroups > 0 then for j = 1, #allGroups do local gpUnits = allGroups[j]:getUnits() if #gpUnits > 0 then for k = 1, #gpUnits do table.insert(AllPlaneUnits, gpUnits[k]) end end end end end end PlanesTable() function Smoke_Off(unit) SmokeOff = { id = 'SMOKE_ON_OFF', params = { value = false } } unit:getController():setCommand(SmokeOff) trigger.action.ctfColorTag(unit:getName() , 0) table.insert(AllPlaneUnits, unit) end AllEvents = {} function AllEvents:onEvent(event) if event.id == world.event.S_EVENT_HIT and event.initiator and event.target then for i = 1, #AllPlaneUnits do if event.target == AllPlaneUnits[i] then table.remove(AllPlaneUnits, i) SmokeOn = { id = 'SMOKE_ON_OFF', params = { value = true } } event.target:getController():setCommand(SmokeOn) trigger.action.ctfColorTag(event.target:getName() , (event.target:getCoalition() == 0 and 2 or 5)) timer.scheduleFunction(Smoke_Off, event.target, timer.getTime() + 5) trigger.action.outText((event.target:getPlayerName() and event.target:getPlayerName() or event.target:getTypeName()) ..' got hit by '..(event.initiator:getPlayerName() and event.initiator:getPlayerName() or event.initiator:getTypeName()), 5) end end elseif event.id == world.event.S_EVENT_BIRTH then if event.initiator:getDesc()["category"] == 0 then table.insert(AllPlaneUnits, event.initiator) end end end world.addEventHandler(AllEvents) Also .miz example attached (red AI vs blue AI, plus a client F18) test-smoke-on-hit-script.miz 10.25 kB · 0 downloads THANKS!! now does this work for AI Aircraft only or will it work for client aircraft? Link to comment Share on other sites More sharing options...
Jeepnaked95 Posted June 28, 2022 Author Share Posted June 28, 2022 2 hours ago, toutenglisse said: You can use this script (copy - Ctrl C - and paste - Ctrl V - in a "do script" action box at mission start : Hide contents AllPlaneUnits = {} function PlanesTable() for i = 1, 2 do local allGroups = coalition.getGroups(i, 0) if #allGroups > 0 then for j = 1, #allGroups do local gpUnits = allGroups[j]:getUnits() if #gpUnits > 0 then for k = 1, #gpUnits do table.insert(AllPlaneUnits, gpUnits[k]) end end end end end end PlanesTable() function Smoke_Off(unit) SmokeOff = { id = 'SMOKE_ON_OFF', params = { value = false } } unit:getController():setCommand(SmokeOff) trigger.action.ctfColorTag(unit:getName() , 0) table.insert(AllPlaneUnits, unit) end AllEvents = {} function AllEvents:onEvent(event) if event.id == world.event.S_EVENT_HIT and event.initiator and event.target then for i = 1, #AllPlaneUnits do if event.target == AllPlaneUnits[i] then table.remove(AllPlaneUnits, i) SmokeOn = { id = 'SMOKE_ON_OFF', params = { value = true } } event.target:getController():setCommand(SmokeOn) trigger.action.ctfColorTag(event.target:getName() , (event.target:getCoalition() == 0 and 2 or 5)) timer.scheduleFunction(Smoke_Off, event.target, timer.getTime() + 5) trigger.action.outText((event.target:getPlayerName() and event.target:getPlayerName() or event.target:getTypeName()) ..' got hit by '..(event.initiator:getPlayerName() and event.initiator:getPlayerName() or event.initiator:getTypeName()), 5) end end elseif event.id == world.event.S_EVENT_BIRTH then if event.initiator:getDesc()["category"] == 0 then table.insert(AllPlaneUnits, event.initiator) end end end world.addEventHandler(AllEvents) Also .miz example attached (red AI vs blue AI, plus a client F18) test-smoke-on-hit-script.miz 10.25 kB · 1 download it works perfectly! is it possible you could give me a quick rundown of what the script means? is there a way to change the color for red air and blue air independently? Link to comment Share on other sites More sharing options...
toutenglisse Posted June 28, 2022 Share Posted June 28, 2022 (edited) 2 hours ago, Jeepnaked95 said: it works perfectly! is it possible you could give me a quick rundown of what the script means? is there a way to change the color for red air and blue air independently? Line 41 ( event.target:getController():setCommand(SmokeOn) ) activates smoke from smoke pod. Color is set by the pod you mount on plane. It only seems to work for AI I don't know why (for client / player, smoke pod can only be activated with a keypress. Trigger or script don't work). So I also added next line. Line 42 ( trigger.action.ctfColorTag(event.target:getName() , (event.target:getCoalition() == 1 and 2 or 5)) ) activates smoke without pod, by default comes from exhaust. It's set like this : "2" (red smoke) for coalition "1" (red), and "5" (blue smoke) for other coalitions (blue or neutral). Color numbers are described here : DCS func ctfColorTag - DCS World Wiki - Hoggitworld.com (I corrected the script in previous post because I wrote 0 instead of 1 for red coalition - 0 is neutral) The script makes a table of planes at mission start, and does add to table planes when they eventually spawn later (AI or client/player). When one of them is hit it does activate the smokes for 5 seconds, with a message giving plane types (or player names). During the 5 seconds the target is removed from table and added again after to detect further hits. Edited June 28, 2022 by toutenglisse Link to comment Share on other sites More sharing options...
Jeepnaked95 Posted June 29, 2022 Author Share Posted June 29, 2022 Line 41 ( event.target:getController():setCommand(SmokeOn) ) activates smoke from smoke pod. Color is set by the pod you mount on plane. It only seems to work for AI I don't know why (for client / player, smoke pod can only be activated with a keypress. Trigger or script don't work). So I also added next line. Line 42 ( trigger.action.ctfColorTag(event.target:getName() , (event.target:getCoalition() == 1 and 2 or 5)) ) activates smoke without pod, by default comes from exhaust. It's set like this : "2" (red smoke) for coalition "1" (red), and "5" (blue smoke) for other coalitions (blue or neutral). Color numbers are described here : DCS func ctfColorTag - DCS World Wiki - Hoggitworld.com (I corrected the script in previous post because I wrote 0 instead of 1 for red coalition - 0 is neutral) The script makes a table of planes at mission start, and does add to table planes when they eventually spawn later (AI or client/player). When one of them is hit it does activate the smokes for 5 seconds, with a message giving plane types (or player names). During the 5 seconds the target is removed from table and added again after to detect further hits.Thanks! Very helpful I’m new to this so trying to learn is very interesting Sent from my iPhone using Tapatalk Link to comment Share on other sites More sharing options...
Recommended Posts