Speedywrx Posted September 16, 2018 Share Posted September 16, 2018 I'm trying to create a multiplayer mission for a few friends. The premise is I'll have 30 vehicles on each side (blue and red). The objective is simple - destroy all 30 vehicles and you win. I'll have an A-10C spawn every 10 minutes that will go attack the other side's vehicles. Players can choose a variety of aircraft: A2A to escort their A-10C and shoot down the enemy A-10C (and other players); or A2G to push in and assist taking out the 30 vehicles. The problem is score keeping. I originally had 2 flags set (blue and red). For example: CONTINUOUS ACTION(Blue increment, ON DESTROY) // UNIT DEAD(Red vehicles) // FLAG INCREASE(1,1) paired with these other triggers: ONCE(Blue 5, NO EVENT) // UNIT DEAD(Red vehicles), FLAG EQUALS(1,5) // MESSAGE TO ALL(Blue team score: 5, 10, false) ONCE(Blue 10, NO EVENT) // UNIT DEAD(Red vehicles), FLAG EQUALS(1,10) // MESSAGE TO ALL(Blue team score: 10, 10, false) ONCE(Blue 15, NO EVENT) // UNIT DEAD(Red vehicles), FLAG EQUALS(1,15) // MESSAGE TO ALL(Blue team score: 15, 10, false) ... and so on until 30 points. It seems to act fine in the beginning, but if another vehicle that is not part of the "red vehicle" group nearby is hit, it will count that as well. At the end it will announce "30 kills" but there will still be 1 "red vehicle" left. What am I doing wrong? Is there a better, but simple, way of doing this? i7-7700k OC'd to 5.0 GHz, ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Valve Index HMD Link to comment Share on other sites More sharing options...
Wrench Posted September 16, 2018 Share Posted September 16, 2018 Are you at all familiar with scripting? This is exactly the kind of thing it's good at. Or you could create a triggerzone that covers the whole map and set a condition for your players win scenario to NONE OF COALITION IN ZONE. Carrier Script. Link to comment Share on other sites More sharing options...
Wrench Posted September 16, 2018 Share Posted September 16, 2018 (edited) Haven't tested this, but something like this should work. Bear in mind this uses Mist (a script you'll have to load, it's pretty easy to find in the mission editor's sub-forum.) deadunits = 0 redunits = mist.makeUnitTable('[red][vehicle]') function Wrench_table_contains(table, element) for _, value in pairs(table) do if value == element then return true else return false end end Wrench_DeadHandler = {} function Wrench_DeadHandler:onEvent(event) if event.id == world.event.S_EVENT_DEAD then local initr = event.initiator if Wrench_table_contains(redunits, initr) then deadunits = deadunits + 1 trigger.action.outText(tostring(deadunits .. 'have been killed!'), 10, false) if deadunits >= 30 then trigger.action.outText('Blue has Won!'), 10, false) end end end end end end world.addEventHandler(Wrench_DeadHandler) I might have made a mistake in there somewhere, but that should get you close. That'll create a table of all red ground units, and will create an event handler so that if anyone dies, it'll check if they're in that table. If they are, it'll tally up the number of total kills. If that reaches 30, it'll tell you that blue has won. Edited September 16, 2018 by Wrench Carrier Script. Link to comment Share on other sites More sharing options...
Speedywrx Posted September 17, 2018 Author Share Posted September 17, 2018 Awesome! I'm familiar with MIST in the sense that I have the necessary files and able to utilize already scripted material (not creating my own content yet). I have loaded MIST by: MISSION START "MIST" // // DO SCRIPT FILE (mist_4_3_74.lua) Then with your script, created a new trigger: CONTINUOUS ACTION (Check units, ON DESTROY) // // DO SCRIPT(*your script above*) However at the first red vehicle destroy, a pop up box comes up stating: [string "deadunits = 0...']:21: unexpected symbol near ',' I'm still trying to figure out how to debug that. i7-7700k OC'd to 5.0 GHz, ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Valve Index HMD Link to comment Share on other sites More sharing options...
Speedywrx Posted September 17, 2018 Author Share Posted September 17, 2018 On the other hand, if I wanted to keep it simple, your suggestion of using a trigger zone and "ALL OF GROUP OUT OF ZONE" works very well. I just can't display the score as they start dying - only the end result after they're all dead and it sends "Blue wins!" i7-7700k OC'd to 5.0 GHz, ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Valve Index HMD Link to comment Share on other sites More sharing options...
Speedywrx Posted September 17, 2018 Author Share Posted September 17, 2018 (edited) Ahh! With your "ALL OF GROUP OUT OF ZONE" suggestion, I also found the condition "GROUP ALIVE LESS THAN" for a percentage of the group. So it's probably not as pretty as MIST scripting, but I did this: CONTINUOUS ACTION (Check red units, ON DESTROY) // ALL OF GROUP OUT OF ZONE(Red vehicles, Red vehicle zone) // MESSAGE TO ALL (Blue wins!, 10, false) ONCE (Blue points 5, NO EVENT) // GROUP ALIVE LESS THAN (Red vehicles, 85) // MESSAGE TO ALL (Blue score: 5, 10, false) ONCE (Blue points 10, NO EVENT) // GROUP ALIVE LESS THAN (Red vehicles, 68) // MESSAGE TO ALL (Blue score: 10, 10, false) ONCE (Blue points 15, NO EVENT) // GROUP ALIVE LESS THAN (Red vehicles, 51) // MESSAGE TO ALL (Blue score: 15, 10, false) ...and so on until 30 points Edit: I just tested this out and it appears to work well. I can also destroy other vehicles nearby that are not part of the group and it does not affect the score (unlike my first attempt in the first post). I think for what I'm trying to do, this is a simple approach that works - I'm not creating a big fancy mission - just something quick and fun for a few friends. Thanks for the help and ideas, Wrench! Edited September 17, 2018 by Speedywrx i7-7700k OC'd to 5.0 GHz, ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Valve Index HMD Link to comment Share on other sites More sharing options...
Wrench Posted September 17, 2018 Share Posted September 17, 2018 Yup, that'll work too. Note that because that script uses an event handler, you only need to runs the script once, and it'll run the rest of the code automatically whenever you (or anyone if used in MP) scores a kill. So I took a look at the script, and I made some mistakes. (I did write that without even having DCS open) Here's a mission with a fixed version so you can see how it works. Note that on lines 25 and 27 there's a reference to the number 4, just change that to however many you want to have to kill.dead handler.mizwrench_dead_handler.lua Carrier Script. Link to comment Share on other sites More sharing options...
Speedywrx Posted September 18, 2018 Author Share Posted September 18, 2018 Yup, that'll work too. Note that because that script uses an event handler, you only need to runs the script once, and it'll run the rest of the code automatically whenever you (or anyone if used in MP) scores a kill. So I took a look at the script, and I made some mistakes. (I did write that without even having DCS open) Here's a mission with a fixed version so you can see how it works. Note that on lines 25 and 27 there's a reference to the number 4, just change that to however many you want to have to kill. Great! Maybe this will help me understand scripting a bit more - I really appreciate your advice and help, Wrench. i7-7700k OC'd to 5.0 GHz, ASUS 1080ti OC, 32 GB 3200 MHz G.Skill, Samsung 960 pro M.2, Thrustmaster Warthog, Saitek pedals, Valve Index HMD Link to comment Share on other sites More sharing options...
Wrench Posted September 18, 2018 Share Posted September 18, 2018 No problem. Let me know how it works out for you. Carrier Script. Link to comment Share on other sites More sharing options...
Recommended Posts