Categories
BattleTech

Building a Mech Editor

About a decade ago, I started writing my own mech editor for BattleTech as a side project. At the time, I was working on Silverlight, so I wrote it as a Silverlight out-of-browser app. I finished enough that it could handle all of the BattleMechs in Technical Readouts 3025, 3050, 3055, 3058, and 3060, but I didn’t really finish the app. I ended up moving on to other side projects and Silverlight was abandoned as a platform.

Fast-forward to a few months ago when I stumbled upon my old project files and decided to see what could be salvaged. Luckily, I had written most of the app as a pretty standard C# library that wasn’t coupled to Silverlight. That meant that getting that library moved to modern .Net Core was pretty straightforward. At that point, I had a core engine that could manipulate mech objects with support for a good portion of the equipment from the tabletop game. It also included an XML-based file format for saving and loading data files with mech designs.

With that going well, I decided to keep working on it. My first goal was just expanding support for equipment and construction options so that it could handle more and more of the game’s many mech designs. I also spent some time to get battle value calculations working. I built a super simple editor UI that is just a textbox for xml that is parsed as it changes so that a Technical Readout style view of the mech can be shown. It isn’t user-friendly, but it was enough to help me write test files as I added support for more designs.

Because all of my core logic is in a library that doesn’t care about a user interface at all, I was also able to wrap it in a command line tool. This let me quickly implement bulk operations on files as well as making it very easy to run tests to ensure that the core logic kept working for all of my existing data files as I added more to the code.

My favorite of the command line tools is a summary builder that generates markdown files based on the mech data files. I like these summaries as a way to get a quick overview of a mech’s capabilities without all of the details of a Technical Readout entry or record sheet. As an example, here is what the summary looks like for a Grand Titan:

Grand Titan T-IT-N10M

  • Role: Brawler
  • Tech Base: Inner Sphere (3054)
  • Chassis: 100 tons (Endo Steel)
  • Movement: 4 / 6 / 0, XL
  • Armor: 288
  • Heat Sinks: 12 (24)
  • Weapons:
    • Large Pulse Laser × 2
    • LRM 15 w/ Artemis IV (ammo: 16)
    • SRM 6 w/ Artemis IV × 2 (ammo: 30)
    • Medium Pulse Laser × 2
    • Small Pulse Laser × 2
  • Equipment:
    • Anti-Missile System (ammo: 12)
  • Battle Value: 1817

Before Easter, I took a week off of work as a staycation and ended up spending a good amount of time working on a parser for MegaMek’s mech files since that offered me a collection of data files for almost all of the mechs from the game. If you’re not familiar with it, MegaMek is an implementation of the BattleTech board game for online play. It’s open source with all of the files, including the mtf files for mech designs, available on GitHub.

In my week of time off, I was able to implement a parser and start generating summaries for the designs in MegaMek’s files. In that week, I got enough implemented to handle parsing and summarizing about 84% of the 3,600ish designs in the MegaMek repo. At that point, I decided to go ahread and share the generated summaries as I continued to work on the project. If you’re interested, you can take a look at them in the scottboehmer/megamek-unit-digest repo on GitHub. In the week since then, I’ve continued working in my spare time, and the repo now has summaries generated for more than 90% of MegaMek’s mech designs.

I plan to continue working on the project to add support for what it is missing, and I’ll update that repo as it’s able to handle more of MegaMek’s files. I don’t think I’m going to work on building the UI for an editor any time soon though. I’m less interested in building custom mechs than I am in building tools to work with existing designs. I think the first real app that I’ll focus on is a force builder for calculating battle value of a group of mechs and determining which formation types they are eligible to use.

The missile mech icon used in this post is by Lorc under CC BY 3.0. It is available at Game-icons.net.

By Scott Boehmer

A game enthusiast and software engineer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s