DCS Mission Idea: Trains and Tunnels

Can’t really do a proper Vietnam without F-4s…Navy and USAF…just say’n.

…but more to the subject…this conversation got me thinking and I came up with a mission idea.

Essentially some “bad guys” in Iran have been cooking some CW precursor chemicals which they are going to sell to “other bad guys”. They’ve made a lot of the stuff. Enough to fill several railroad tank cars, which, coincidentally, is how they are going to ship to the “other bad guys”.

Now these chemicals, by themselves are not very toxic…well, I wouldn’t like to bath in them or use one as a mixer for some good Vodka…bad Vodka, maybe…but…you get the point. However, mix them together and they produce a very nasty nerve toxin…in fact the aforementioned CW.

So how do the “good guys” (that’s us) stop the delivery? If we just strike the train, we run the risk of the tank cars breaking open in the resulting train wreck, the nerve agent forming, and killing many, many innocent civilians.

What to do? The “good guys” come up with an ingenious plan. We will sneak through Iranian IADS, follow the train and when it enters a tunnel we will strike the exit and then the entrance with GBU-10s, this sealing the nasty chemicals in the tunnel with no chance of inadvertent exposure tho the locals. and in the process making the world a better place. :slightly_smiling_face: OK the train engineer and his team get buried but maybe they can get them out like they did those Peruvian miners a few years back…so…

…all is well and I’ve developed a mission that we can safely say meets the highest moral standards…

…but…it seams that DCS trains don’t stop for destroyed/sealed tunnels…kind of just plow on through…so looks like I’ll have to bomb the train anyway…bummer. :neutral_face:


If you can’t detect the tunnel as a scenery object to trigger the train to stop, perhaps add a small building or AAA emplacement as a “guard” to the tunnel, which can be damaged when the tunnel is hit and act as a trigger to stop the train.

1 Like

Deactivate the train if the tunnel is sealed/destroyed, replace with another train that has no waypoints. Or since it’s within a tunnel, no need to do anything other than deactivate.


I understand the limitations and it may end up being the only viable solution but for me that would defeat the purpose of the mission if the train always stopped. I would want the train to continue on its merry way if the tunnel entrance was not destroyed.


1 Like

No need to as we can link deactivation via trigger. So if tunnel exit destroyed and train is inside tunnel zone, then deactivate train; otherwise, wait or pass through depending on status.


Nice thinking there, see, there’s plenty ways to tell heroic stories that everybody would want their kids to play.


All good ideas! That is likely the way to go.

That said, I have had issues with trains before.

If an administrator is reading this, I am now going to get technical with ME mechanics. A move to a more appropriate thread may be in order.

I tried to have a train pull up to a station and simulate off loading something. I placed a convoy of trucks on an adjacent road with a trigger to start a couple of minutes after the train arrived. It didn’t work. In my efforts to fix it, this is what I learned about DCS trains added from the ME.

  1. They travel at 32 kits, no matter what you set their speed to
  2. They “bounce” back and forth between your first and last WPs.
  3. They are not recognized as “entering” a zone (unit or part of a group)
  4. The cannot “attach” a zone; i.e. you cannot do a UNIT IN MOVING ZONE with a train unit as the moving unit.
  5. The do not respond to a SET WAYPOINT - probably has something to do with Nbr 2 above.

I seem to recall having trouble with DEACTIVATE GROUP…but that may have been more about their not being detected in a zone.

What I have not tried:

Mucking about with WPs. Theoretically I could set a bunch of WPs very close to each other and have a train sort of jiggle in one place…noticeable from the air?

What I do know. Taking out any rail car stops the train.

Trains, derailment. Eh. Business as usual :smile:



Damnit! We should have seen it coming, two-fold. :rofl:


This seems to be the key. I have chosen my tunnel (see screen shot) and have the OBJECT ID for the North and South Entrance…

…next…OK, here is where I’m a bit lost.

I know from another of @Franze’s posts on another thread (or by now perhaps out kind administrators have moved this to that other thread) …

where the function of getLife Returns the current “life” of a unit. Also referred to as “hit points”.…if this value is less than 1 the unit is considered “dead”.

So, one should be able to write a short Lua Predicate script (Trigger condition) that checks the life of a Tunnel Entrances (using their OBJECT ID?) and returns a True Boolean if it is less that 1.

Except that’s not the way the Hoggit Wiki says to do it. They introduce something called getLife0 which is just the Unit’s initial HPs. Their example for determining the % “Life” left in a Tank

local tank = Unit.getByName(‘tank1’)
local life = tank:getLife()/tank:getLife0()

I assume the next step is to add a line:

if local life == 0.00 then return true.

Where I get lost is with “Controllers” (I keep seeing the Controller from STALKER), although I don’t think we need Controllers for this since we know the OBJECT ID…which I assume would go into the Unit.getByName(‘164593665’)?

Or do we?

The only problem is getLife0 only applies to the unit class, nothing else. So you can getLife for a scenery object, but you can’t getLife0 for a scenery object. In this case, so as long as you’re not using some kind of destructive trigger at mission start, you can getLife at the start and save that value as the full HP for the object for later comparisons.

local staticinitlife = SceneryObject.getLife(164593665) -- note, no quotes needed around IDs!

Controllers refer to systems that handle a group and unit’s AI routines via the tasking system. Doesn’t apply for a scenery object.

No need to fly inverted trough the tunnel?
I’m seriously disappointed by your mission design!

Apart from jokes sims a nice mission that would require perfect timing!


Actually it requires doing barrel rolls through the tunnels…in staggered echelon right formation…I thought that was obvious… :wink:



I get it now…in the detection script, the EW radar unit is part of a group, and the group’s name was what was identified in the script, so we needed a controller…

…but this is just an object with no real AI attributes.

Maybe I was making this too hard…

local staticinitlife = SceneryObject.getLife(164593665) -- note, no quotes needed around IDs!
  if staticinitlife <= 1 then return true end
return false

or something like that…I feel like I’m missing a “end” before return…

Then another trigger for the other end of the tunnel scenery object …if both are dead and the train is inside the tunnel…sticky wicket may be to get the train recognized as inside a zone…I’ve had issues with that before…if push comes to shove I can use TIME IS MORE and TIME IS LESS trigger conditions…

I’ll have to ponder a bit on how to take care of all the possibilities…the entrance tunnel destroyed before the train gets there…or not destroyed so the train can just back out…a bit more complicated than I first thought… :thinking:


I’m not a LUA espurt but, that 2nd ‘local’ statement may cause an issue. Just a WAG.

1 Like

I’ve never used LUA at all. But that never stops me!

Don’t most scripts use “else”? As in…

if (condition)

____Do Something else


I would say yes, but in those cases you would leave the else statement blank so it does nothing, which wastes space. LUA by comparison to something more structured like Java (which I have done) based on what @Franze told me, is very unstructured so you get advantages like this but it also is horrendous to read when you are not used to it.

1 Like

Thanks - fixed it. :slightly_smiling_face:

Yeah you can say that again. Ick. C was my first ‘love’. And yes, you can make C look ugly but I hold to the old notion that a pages’ worth of C code should be a joy to read. But I’m old.

1 Like

Hmmm. Flash from the past