GSoC Week 6: Harcourt Fenton Mudd, have you been drinking again?

Mission 4: “Love’s Labor Jeopardized”, is an odd one. You don’t really need to do very much to complete the mission; most of the challenge comes from getting the maximum number of points possible by discovering as much as you can about an alien ship.

There is only one way to die, which involves waiting for 25 minutes with plenty of warnings, and there aren’t even any redshirt deaths! Lt. Buchert must be the luckiest security officer in the crew.

Though, he has to deal with Harry Mudd, so I guess he breaks even. Honestly, the best part about this mission is talking to the crewmembers and getting their reactions to Mudd.

Mission oddities

This mission follows familiar patterns; there are pieces of unused audio, despite clearly having places to fit in. For instance, there was an instance where McCoy and the redshirt had the same line, but the redshirt played McCoy’s voice clip when his textbox came up. That was easily fixed, since his voice clip still exists in the game data.

I also encountered invalid actions, which was a first. For example, there was an action defined for “using a viewscreen on Kirk”. Obviously, that’s supposed to go the other way.

What’s great is that, if the text exists, it’s voice-acted. They were thorough with that, even if the text was unused for one reason or another.

Aside from that, there is one very, very, very obvious bug in this mission. Basically, Mudd goes completely insane after inhaling some alien aromas, and you’re supposed to help him out. (Or you can leave him as-is.)

However, you can just go straight back to the first room, and he’ll still be there, cheerfully bantering with the crew as if nothing happened. Then you can go back to the previous room, and he’s insane again.

I’m still finishing up the mission, but I’ll be sure this gets fixed in ScummVM.

A detour into Mac OS 8

Earlier this week, I took a quick break from mission logic to take a look at the Mac port. Since I was convinced at that point that the mission logic was hand-written assembly, I wanted to see what they did with the different processor architectures.

I spent two days trying to read from almost-dead floppy disks, searching for obscure unmaintained programs to read from a file’s so called “resource fork” (a feature of the mac filesystem), figuring out how to use Mac OS 8, and looking for an appropriate emulator to run it. (The program is called Sheepsaver, it’s pretty swell.)

This was what my Monday evening looked like.

And, what did I find when I finally dumped the files? x86 assembly in the mission logic. Now, I haven’t done any serious reverse-engineering on the main executable file, but since the Macs of that day ran on 68k processors, it’s quite obvious that emulation was going on.

The Amiga was apparently based on the 68k processor as well, so, perhaps this is related to the complaints of sluggishness in the Amiga port that I’ve heard about. That being said, mission logic would take only a very small fraction of the total execution time, so perhaps there are other reasons for the sluggishness. Or perhaps even parts of the engine code are emulated as well. That’s just speculation, though.

A fun side-note: I was running Mac OS 8 when installing this version, which ran on PowerPCs. So, my x86 computer was emulating a PowerPC for MacOS, emulating a 68k for Star Trek, emulating an x86 for the mission logic. Ahh, the circle of life is beautiful.

PS

I was mentioned on Github’s blog in a feature on ScummVM! It’s great to know that people are paying attention. It motivates me to make these posts as interesting as possible.

GSoC Week 5: Star Trek Teaches Chemistry: How to Make Laughing Gas

Mission 3: Love’s Labor Jeopardized. It’s about 90% finished.

The mission starts with a rather ear-grating computer voice. Thank god they got Majel Barrett for the sequel.

That said, this is a neat mission. You’re given information about various chemical compounds that may be useful in the mission, then you need to figure out which ones are important and mix up some ingredients to cure a virus that’s running loose through the station.

Or you can just, you know, inhale some laughing gas instead.

Mission bugs

Last week, I promised there would be bugs in this mission. There’s nothing mission-breaking that I’ve found, though, mostly text stuff.

The most eggregious is a weird textbox I encountered in my casual playthrough. As far as I know, you’ll always encounter this if you take long enough during the mission.

I also encountered this following bug while writing this blog post. This is part of the 10% of the mission I haven’t rewritten yet, though, so I can’t explain what it’s about.

Aside from that, there are a couple of cases where voice acting doesn’t play when it should. And, if you look at Dr. Marcus when she’s tied up, it plays the wrong file entirely; only narrating the first half of the textbox. There was an unused audio file that narrated the entire textbox, so I replaced it with that.

The one thing that might be considered a bug in the mission mechanics, is the way you can give water to the Romulans. Apparently you can get a point in your mission score for doing that. But, sometimes, if they’re unconscious, nothing happens. You lose the water, you don’t get any points, and not even a textbox is shown. It’s honestly kind of odd. I’m still debating what to do about that; for now I’ve made it so you can’t give water to them while they’re unconscious.

Other oddities

There are a number of cases where a single line is read multiple times by the actors, simply because the same textbox is shown in multiple different rooms. For example, if you scan the air with the medical tricorder, McCoy says the exact same line, but with a different voice clip depending on the room. I can just imagine the cast complaining about why they have to record the same voice clip three times.

Anyway, this mission should be completable in ScummVM within the next day or two. Next week will feature the return of Harry Mudd in one of this game’s weirder missions.

GSoC Week 4: Dammit Jim, I’m a doctor, not a QA tester!

Star Trek’s second mission, “Hijacked”, is finished. It’s very short, only consisting of 4 rooms. Despite this, the devs didn’t fail to insert a number of bugs into the mission, most of them in the final room.

Let’s start simple: if you talk to McCoy at a specific time, he has no text.

However, there is an audio file which fits perfectly for this situation. So, I whipped up some corresponding text to go along with it, and inserted it appropriately. Honestly, how could I let DeForest Kelley’s wonderfully snarky voice acting go to waste?

It’s not the only voice clip that’s unused, either. There are a surprising number of cases where they clearly intended for some dialogue to be said, but there’s problems in the implementation causing it to not occur; for example, when you try to shoot the Masada crewman, he’s supposed to say something, but due to a bug(?), he didn’t in the original.

There’s also an oversight with the mission scoring system. You’re supposed to combine some inventory items together to progress through the mission, but you only get points for this if you do it in a specific room! This is the consequence of each room having entirely separate codebases; the code needed to be copied for each room, and clearly, they must have forgotten that the code was duplicated when they made some changes to it.

Lastly, the final room is pretty buggy. Don’t read any further if you want to avoid spoilers.

So, there are three ways to end the mission; either you shoot the Elasi, they surrender, or they attempt to deorbit the ship. But… these aren’t mutually exclusive. In fact, all three can happen, and the devs clearly didn’t think this through properly.

Consider scenario #1: You shoot the Elasi. This aggros them, and they immediately kill your redshirt, followed by Kirk. However, you can still talk to the Elasi if you’re fast enough. If you convince them to surrender… they don’t actually surrender, despite saying so, they just keep killing you. If they deorbit the ship, you can call Sulu, stabilize the orbit, and beam out, WHILE THEY’RE STILL SHOOTING YOU.

Scenario #2: You talk to the Elasi, and you choose the worst option, causing them to both deorbit the ship and start shooting you. This one’s funny, because there’s no way to finish the mission in a way that makes sense. You can do one of two things:

Scenario #2a: Shoot the Elasi. This is sensible since you only have a few seconds before they kill you. After this, the mission is “successful”, even though you never save the Masada from deorbiting. I guess the security team that beams over dies when the ship goes down…

Scenario #2b: Call Sulu to prevent the ship from deorbiting. This results in the same issue as scenario #1.

It’s a mess. I’ve tried to fix things as best I can, by requiring that if the ship is being deorbited, shooting the elasi doesn’t end the mission, and vice-versa; saving the ship from deorbiting doesn’t end the mission if the Elasi are still a threat. Also, if the Elasi say they surrender, they actually do surrender now.

There are many more minor bugs, such as the Elasi guards freezing up if you shoot one of them at a specific time; but I’d be here all day if I listed them all. I’ve put down “BUGFIX” tags in the source code whenever something like this comes up. I’ve no doubt I’ll encounter more while working on the next mission.

GSoC Week 3: R̶e̶b̶e̶l̶ Elasi Scum

The main task of this last week was to implement saving. This had a surprising amount of nuance to it, since I need to provide ScummVM with various metadata, including a thumbnail of the savefile, the savegame description, etc… fortunately it wasn’t too difficult to use other engines as templates on how to accomplish this. I’m quite glad I found out about ScummVM’s built-in serializer before starting on this, as it reduces the amount of redundant code by a lot (saving and loading is done with the same code).

The main issue I encountered, was a portability concern. I can’t simply memcpy a data structure to save it, since there are no guarantees about struct packing, or endianness, etc… so, I need to specify each individual variable that goes into the savefile. This is a huge pain to do, since each individual room has its own set of variables, and I’m still figuring out what they are. I’ve mostly held off on saving room-specific variables for now. Hopefully I’ll find a better solution, but obviously I must eventually solve this for saves to work properly.

In the meantime, the next mission is coming along, in which Kirk faces off against the Elasi – some kind of “rebel alliance”, except, they’re the bad guys.