Monday, March 15, 2010

Sub Command: Missile Test mission

Something almost completely unrelated to my usual stuff today, but it is the reason I haven't posted for a while. If you aren't even remotely interested in program debugging or computer games you might as well stop reading here and go do something far more interesting instead, life is too short to read stuff you don't care about!

I recently took up playing/learning the subsim game Sub Command by Sonalysts Combat Simulations but only got three missions into the campaign when I hit a snag, I couldn't finish a mission successfully even though I had fulfilled all the mission criteria. So I did a Google search for the same problem and found there were a lot of other players with the same problem. Unfortunately there didn't appear to be a fix even though patch 1.05 was supposed to have addressed the problem. I even found a forum entry from one of the developers who said there was a problem with the goals system on this mission and that was what had caused Sonalysts to adopt scripting for the missions in their next game Dangerous Waters.


Anyway, the most up to date information I had was from 2007 (the game came out in 2001) and the bug was still not fixed as far as I could tell. So I decided to see if I could fix it - I used to do software support for a living but had never poked around a video game before and here was the perfect opportunity since Sub Command comes with a mission editor.

If you've come across this whilst searching for a solution to the same problem then you'll probably know some of the basics and you can skip to the solution at the end, for the rest of you I will wax lyrical about what to do and why - and the reason I'm posting it here is just as an example of applying some basic critical thinking and scientific methods to a pretty simple case. You don't have to be solving one of the great issues of our time to think logically and clearly!

The problem

OK, mission three of the Seawolf (and all of what follows also applies to the 688i campaign as well I think, although the mission design is somewhat different and I haven't tested it yet) campaign in Sub Command is to sneak up on a Russian Udaloy which is going to test fire a new SAM at a remotely controlled target drone (an Airbus A300 in the game). Close to within three miles by 11:28am, raise the periscope, watch the missile launch, take a photo, wait two minutes, mission complete. Only the mission complete bit wasn't happening for everybody. Well, almost everybody. I came across a couple of people who said that they had finished the mission, and a couple who had said that success seemed to be when the missile hit first time. Every time I had played it so far the Russian ship had launched two.

My first thought was that this was time related since the first missile appeared to be firing at 11:27 game time. So I figured I had to alter the time in the mission goal and then it would work. Only I couldn't load the campaign game into the Mission Editor. Looking at the scenario folder in the Sub Command directory I noticed that the user edited missions had a file extension of '.mu' and what I assumed to be the campaign missions had a file extension of '.mc'. So I took a copy of the file MissileTestSW.mc and renamed it to MissileTestSW.mu and sure enough I could now load it in the mission editor. If I had read more of the forums on mission editing more carefully during my research I would have been saved some time since this is apparently well known in the modding community for this game. Doh. Always do your research carefully!

Then I played around with the mission editor until I got the hang of editing goals and finding the edited mission. The goals in question are goals 13 and 14 for this mission, both labelled Observe Missile Test (which one you have to complete depends on whether or not you were detected in campaign mission 2). I wasn't detected so figured out after running some debugging missions (I added some messages to goals to say which ones were being completed so I could find out which enemy ships I was facing, so I could find out which goal I had to play around with to get the mission to complete). Goal 14 was the one that wasn't completing for me. So I changed the start time of the goal to before 11:27 and figured I'd be good.

Tested the edited mission. Still didn't work.

Maybe it was the radius around the mission goal. Nope.

Maybe the goal precedence? Nope.

Max/min depth or speed? Nope.

After many frustrating test missions where I played around with all sorts of settings I finally remembered the fact that some people said it worked when the first missile hit. So I focused on that - why wasn't it hitting? Eventually I figured out that the first missile was out of range of the target when fired. The first missile was being fired when the A300 first enters the Udaloys radar coverage (I think) but well outside the range of the SAM, so it ran out of fuel almost everytime it was fired and didn't hit the target. I concluded that maybe the goal was somehow tied to the first missile in programming I didn't have access to through the mission editor. So I figured that if I altered speeds on all the elements concerned I could arrange it so that the Airbus would be hit by the first missile. It wasn't easy to do but I did it.

And it still didn't work.

I was almost at the point of giving up and was looking for a database editor I could use to fudge the range of the SAM so that it would hit the A300 when I came across the Doctrine Language - this is the language the developers use to fine tune the dynamic campaign missions in Sub Command. As mission editing software goes it is pretty powerful. But you don't have access to it by default, which is why it took me so long to find it. Anyway, for those of you who don't know this is how you get access to the Doctrine Language (which I found out about through fan site subguru.com):

In the SubCommand folder of the installation there will be a file called editor.ini provided you have made and saved at least one user created mission in the mission editor - just create something with one ship, save it and the file will be present. Open editor.ini and it will look something like this:


[FILE] "Test timingSW.mu"
[FILE] "Copy of MissileTestSW.mu"
[FILE] "testing doctrine MissileTestSW.mc"
[FILE] "fixed doctrine MissileTestSW.mu"
[FILE] "testing doctrine MissileTestSW.mu"
Now add a new line after the last one that reads:
 
[FULLOPTIONS] 1
There is a space between the 1 and the last square bracket. Save the file and go back into mission editor, you will have access to the doctrine language AND you will now be able to load and edit campaign missions without having to go through the process of changing the file extensions.
 
Stay with me, almost there.
 
Revelations
 
So now you could look at the fine detail of goals in the missions, and here is where I found what was wrong. To view the Doctrine Langauge for a particular goal select the goal, then go to page 2 of its properties. Select the Tick Box that reads Use Doctrine Language then go to page 3, you'll see the doctrines set for that particular goal. It is basically a crude macro system that allows you to set conditions to be met before the goal you are editing can be completed. For goal 14 this read as:
 
IF (CompletedGoal MissileTestSW.mc Goal 5: Start Collecting Data)
AND (CompletedGoal MissileTestSW.mc Goal 15: Kill Airbus 1)
AND (TimeSinceGoalTriggered MissileTestSW.mc Goal 15: Kill Airbus 1 > 00:00:02)
THEN GoalTriggered
 
All of which is macro speak for if goals 5 and 15 have been completed, and two minutes has passed since goal 15 was completed, then goal 14 can be completed if all the conditions associated with goal 14 have also been met.
 
And here's the problem:
 
You approach with your sub within 3 miles of the Udaloy satisfying mission goal 5 by about 11:22 let's say.
Raise your periscope at 11:26ish and observe the Udaloy.
First missile fires at 11:27 and approx 30 seconds.
It flies for a bit and misses.
Time is now roughly 11:28.
Some time passes and second missile is fired, this time hitting the airbus and killing it, satisfiying goal 15.
Time is now approaching 11:29
Two minutes pass since goal 15 is satisfied, time is now 11:31 and goal 14 can be triggered.
The end time set for goal 14 on page 2 of its parameters is 11:30.
 
The mission parameters mean that unless the first missile hits the A300 goal 14 cannot be triggered successfully. But the first missile won't hit the A300 9.5 times out of 10.
 
The Solution
 
I changed the end time of goal 14 to 11:32, saved it as the campaign mission and played through it and lo and behold the bloody thing worked. Only took me a week.
 
So there it is, the solution to the well infamous (in certain circles) Sub Command Missile Test mission problem.
 
And the slightly relevant to this blog bit is...?
 
Work up a hypothesis that you think explains your observations, test it. If it doesn't work refine it and throw out what failed. Test again. Repeat until successful. Then test it again. Then open it up for peer review and have others test it. If they can't replicate, find out why and then go back to the start. Well, go on then.
 
Let me know if this works/doesn't work for you.

7 comments:

  1. Worked fine for me - thanks!

    Just kidding - I haven't a clue what you're talking about.

    I'm glad your thought process was sound though and if I ever come up against a seemingly intractable problem in a ten year old game, I will do the logical thing.

    I'll ask you to fix it.

    ReplyDelete
  2. I have a question to post. In some missions you are not to be counter detected. I have tried copying the goal completely as in sri lanken cargo mission. In the mission I create immediately get told I have been counter detected. Can anyone assist please? lbuffoli@optonline.net Thank you

    ReplyDelete
  3. Anonymous - please pick a nickname to post under for future replies.

    In the drop down box labelled 'Comment as', which sits below the text box you write a comment in select Name/URL and just make up a name so you can be identified with your comments.

    As to your question, I am not that great at editing missions but there are a few possibilities:

    Check that the Counter Detect mission is linked to a platform - the one that you want to try detecting your sub. Also, check what conditions are associated with the counter detect goal. You can also set priority for goals too, so try adjusting the order they appear in if you don't want that to be fulfilled straight way. Also, check what the global mission goals are as well, often you need the platform specfic one AND a global one to help things play out the way you want.

    Study the counter detect mission goals in other missions to get a feel for how they are set up and try adding debug messages to your goals so you can see what is happening and which goals are firing.

    ReplyDelete
  4. i have had problems inserting commando and seal teams,, i have got to the rendezvous area in plenty of time and the teams just dont leave

    ReplyDelete
  5. Blah blah blah, you see the problem is I got up for a beer! Then the other problem is I had to take a piss! Then the other problem is I fell asleep trying to read all that bs and actually understand it! Man just get to the damn point and the fix! no one cares about all the other crap!

    ReplyDelete
  6. Run along now little one, the grown ups are talking. Do mummy and daddy know you've been online pretending to be a big boy again?

    I'm sorry there were too many big words in the explanation for the solution you were too stupid to figure out for yourself, but then the post was written for people who aren't arrogant morons, which is probably why you had so much trouble understanding it.

    Of course, if you were even half as smart as you apparently think you are you would have found the shortened version of this I posted on a couple of forums, wouldn't you?

    Twat.

    ReplyDelete
  7. Yes, it worked! Thank you.
    Although I found using a text editor accomplished the same thing I just added 120 to the figures in the script.
    i.e.41400 became 41520

    ReplyDelete