Mods, Mods, Mods: A few updates

I’ve been publishing some small projects lately, so I thought it was a good time for an update on them and how things are going.

My health is still not good. I think the progression of my illness has slowed slightly as I’ve become more aware of how it functions and how to manage it.  However, I’m still not aware of what it is.  I’m still researching and analyzing and fighting to figure it out, though.  But it is probably some kind of rare genetic metabolic disorder.  Regardless, I have to take things slow and put any energies into smaller, less-intense projects.

Mod Music Conversion

One such project was converting all my old mod music into MP3s so I could listen to them more conveniently.  I’ve been manually converting small batches of mods for years and found through that process that many automated ways of transcoding mods had issues.  Either metadata would be left out or certain bits wouldn’t sound right or the volume was too low or the frequency balance would be muddy sounding.  This is why I would always just playback the mod in ModPlug Player (my player of choice) and directly record the output into Audition, tweak the volume, save to MP3, and done.  You can’t reasonably do this for a library of over 400 songs, though.

The first problem I wanted to tackle was getting as much metadata out of a module file as possible and putting it into an MP3 file’s ID3 tags. I started looking into libOpenMPT as a way to open the four major mod formats and grab their metadata in a standardized way.  It’s a decent library, but the documentation could use some work. I had to read through its source code for hours until realizing that it returns strings at UTF8. This was only a problem because .Net can only marshal strings from unmanaged memory that are ANSI or UTF16 by default, which seems pretty weird given UTF8 is so common.  But one custom UTF8 marshaling function later and I was in business.

The next problem was that the mod metadata ended up being not the greatest. Almost all mods have a title and a field for what tracker software was used, but modification date only became a feature by the Impulse Tracker format, and none of the main formats have artist fields.  I had to use a lot of regex magic to even get a fraction of the date and artist metadata from the song comments.  The comments, by the way, are another quirk of the mod formats.  Artists typically put notes about their work in the comments; however, only Impulse Tracker had a specific field for this. The earlier formats used either sample names or instruments for these notes.  Being that I wanted to preserve all of this in the extracted metadata, I just concatenated all three fields together with some delimiters between them.

Luckily, getting the extracted metadata into an MP3 file is a bit more simple as there are a number of ID3 libraries for .Net.  TaglibSharp is the most popular one, but it is not without its quirks as well.  Particularly, trying to delete specific user text frames (TXXX) is not the least bit straightforward.  But in the end, I came up with an imperfect little tool to copy module metadata to an MP3 file (or output to text if necessary for your purposes) that I put up on Github.  Thankfully, ID3 is a much better tagging format than what module files used. 😄

As I was trying to figure out how to work with libOpenMPT, though, I discovered that ffmpeg also uses this library to load module audio. Given that libOpenMPT was basically the evolution of ModPlug, I thought that the playback might be comparable between the two. I did some test runs converting a few songs to MP3 and found the results to be promising.  Obviously, the aforementioned muddiness of the sound persists, but I then found that ffmpeg has quite a vast library of audio filters to utilize. One EQ later and that issue is fixed right up.

What was more of a struggle was how to balance the volume of the songs.  Naturally, you don’t want to risk clipping the audio data by doing a straight up amplify.  ffmpeg does include a hard limit filter to avoid clipping, but how do you know how much to amplify?  You can’t normalize a song’s audio without having the whole song to analyze and ffmpeg only works in streams of audio data.  It’s a problem I have yet to find a straightforward way to tackle. In the end, I used the loudnorm filter to extract the loudness of the song, calculated the amplitude needed to reach about -10 LUFS, and then did a second pass including the desired hard limit.  More information on the whole conversion process can be found on the Github page for the metadata extractor.

Ultimately, I’m fairly pleased with the results of this project. I did get my entire mod library converted to MP3 with some snazzy album art and good sound.  But I also did end up having to manually adjust a lot of the artist names and titles in MusicBrainz Picard to catch all the missing artists and make them all uniform, so that was a bit of a drag. Also, there are a few songs that seem to have minor issues with conversion accuracy, primarily Necros songs coincidentally.  I may still end up manually recording a number of the songs ultimately, but what I’ve got so far is pretty damn good.

Mods MP3 library in Dark Audio Station

Mods MP3 library in Dark Audio Station

Deus Ex Soundtrack v2

Given that I was already binging old mods, my conversion of the Deus Ex Soundtrack—which was originally in the mod format—kept coming up on shuffle.  However, I was getting pretty annoyed at how quiet the songs were as I had stupidly only normalized the volume instead of hard limiting it.  I thought it would be a quick couple day project of loading up the original wave recordings and tweaking the volume levels, but I soon found lots of other lingering issues with those recordings.  It was mainly just clicking from bad sample loops or poorly recorded/encoded samples.  I imagine this was due to a combination of time crunch and crude audio tools during the soundtrack’s original creation, so I can’t fault Alex Brandon too much.  Coincidentally, if you need to go insane, try finding the right loop points that make an audio sample not click and sound decent. 😛

Eventually, I ended up re-doing from scratch about a third of the soundtrack as I had also stupidly not saved the intermediate mod files from the original conversion. 😄  So, every one of the those bad 8-bit samples had to be cleaned up again.  To be fair, I think I did an even better job with that as audio editors have gotten a bit more advanced in the interim.  I’d like to redo the entire soundtrack, but many of the songs were pretty decent already and I’m kinda burnt out on it for now. But maybe in the future…

At this time, I’ve already uploaded the MP3 version of the new soundtrack conversion to its page.  I’m still working on getting a new FLAC version done as it has a different tagging format.  And I’m also thinking about making the intermediate mod files available for download, although obviously that would only include the tracks I redid recently.  These files would be Impulse Tracker format with all the samples cleaned up and other fixes and new outros included.  Additionally, I’m also exploring the possibility of copying the cleaned up samples back to the original UMX files to improve the game music as well.

Deus Ex Soundtrack Cover Art

Deus Ex Soundtrack Cover Art

Diablo 2 Mods

And in another kind of modding, Diablo 2 mods!  Yes, I am still modding this old ass, janky game.  However, that may be changing soon with the imminent release of the Remastered version of the game.  Blizzard said modding is still possible in the new release, but I highly doubt it’s as comprehensive.  I would be delighted to hear they switched the data format away from TSV text tables, though.  I’d think something more object-oriented where you could define a default item, inherit and change what needs to in child items, and modify some of the raw functions would be the dream.  But, I’d be pleased with at least a switch to JSON for the data definitions.

Regardless, I haven’t done too much modding this time around. I just overhauled how the respec and socketing mod works.  I realized that I could just add the Token of Absolution—an item which resets your skill and stat point allocation—right to a vendor instead of continuing to use the Horadric Cube recipe.  It’s a little janky this way as I had to change its item type to that of a potion to get the tooltip to work, but right-clicking on the ToA still gives the desired result, albeit with the drawback that the game crashes if you try to give the vendor more than one to sell, it can be put on your belt, and its cost changes based on what level the character is.

I also realized that I should include a recipe for adding sockets to items in the mod as there already is one but it’s crazy high-level and convoluted.  Tangent, but, isn’t it lame how you have to “remember” all these cube recipes to play the game.  We’re all looking them up on a wiki anyways and that’s not fun.  I’m glad Diablo 3 got rid of that aspect.  Anyways, I changed the recipe that adds sockets to something more reasonable but still balanced.  And I also discovered that there was an unused recipe function that allowed gems to be removed from sockets without destroying them, so I added a new recipe for that as well.  However, both of these recipes require gems to perform.  I’ve been thinking about adding a new rare crafting material that could be used in the socket recipes, but it seems like a lot of work plus would take valuable inventory space even if the mats stacked.

I’m also thinking about removing the Magic Find attribute from my drops mod.  It’s kind of a counter-productive stat to have on items, like it doesn’t help you survive or kill monsters but you want it maxed out so you can find the best loot.  I just feel like the loot drops should always be good—in a fun and balanced way.  So I might just remove magic find and increase the drop chances even more, but it’s a tough one because it needs lots of testing before release.

Final Thoughts

I hope you enjoyed this developer diary of a post.  My apologies for not doing more awesomeness in recent years, but… it’s something at least.  I think next I might try to give this site an overhaul; I’ve been neglecting to add proper mobile support for many years and the WordPress theme is like a decade old.  I’m still dreaming of doing an update to Cursor Lock, though; I think it’s passed about a half-million downloads across all sites now.  However, I’d really love to do a major update on File Lister as it’s the program of mine that I use the most.  It’s just so crazy useful for doing batch operations and management on files, and I’d like to extend that capability.

Take care, everyone.  Stay safe and don’t get the ‘rona!

Posted in Media, Miscellaneous, Modding, Programming | Tagged , , , , | Leave a comment

Using Cursor Lock with Steam Games in 2021

The instructions given for using Cursor Lock in games launched through Steam in a previous post were rather out of date. But I’ve become aware of a new and perhaps better method for using the two together. I say better because it doesn’t require creating shortcuts; however, there is still some command line tomfoolery to mess with.

Here’s what to do:

  1. Open the Cursor Lock Setup.
  2. Setup the options for Cursor Lock how you would normally, except put %command% in the Open Program field.  The field will turn red, but that’s okay, we’re not actually going to create a shortcut. (See the first image below.)
  3. Go to your Steam library and right-click on the game in question and select Properties.  Your should see a “Launch Options” field.
  4. Find the path to Cursor Lock.  The quickest way is probably to go to your Start Menu (or whatever Microsoft is passing off as a start menu these days) and find the Start User Mode shortcut. Right-click this shortcut and go to Properties.  You’ll find the path to Cursor Lock in the Target field under the Shortcut tab. Copy the part in quotes, including the quotes.
  5. Paste the path to Cursor Lock into the Launch Options field in Steam.  Then go back to Cursor Lock Setup and copy the command line options at the bottom.  Paste what you’ve copied at the end of that same Launch Options field.  (See the second image below.)
  6. You’re done. Just X out of the dialog and play your game.  Cursor Lock will open and close in tandem with your game. You’ll need to do this for every Steam game you wish to use with Cursor Lock, though.

As you may have guessed, the %command% pattern is replaced by Steam automatically with the path to the game. This useful feature allows us to wrap any commands we would want around our game command.  If you’re already making use of the Launch Options field for other commands, you can put those into the Open Program Args field (/P) for Cursor Lock to pass them along to your game—see the screenshots above for an example.

Posted in Gaming, Software | Tagged , | Leave a comment

Cursor Lock FAQ and Future

Q. Cursor Lock doesn’t work for X program.

I understand that the underlying concepts involved in getting Cursor Lock to function correctly in Program Mode possibly exceed the capabilities of some users, e.g. casual teenage gamer.  So, if your eyes are glazing over at the prospect of having to figure out what is meant by a “Lock Program” and an “Open Program”, just skip Program Mode altogether and bask in the simplicity of User Mode.  In User Mode, Cursor Lock runs in the background and you control it with hotkeys.  There’s even a handy shortcut to User Mode in your Start Menu. Just don’t forget your hotkeys. 😉

However, if you’re more of the advanced sort, you’ll appreciate that Program Mode only runs when you need it and thus doesn’t waste resources.  Most people get hung up on the difference between the “Open Program” and the “Lock Program”, thus it is useful (and perhaps necessary) to understand the general execution flow, which is as follows.

Cursor Lock FlowchartBy separating the program that is executed from the one that is “cursor-locked”, it allows for launcher programs to be supported. Many programs (games) use launchers, which are executables that are separate from but required to execute before the main program executable.  Steam can be considered a launcher.

Now if you’re grasping the operation of Program Mode but are still having problems, here’s what to do.

  1. You’ve got to select the appropriate executables for the Open/Lock Program fields, which can be tricky to figure out. Use Task Manager to help you see what processes go to what windows.
  2. If you’re having trouble finding the right launcher executable, you might try the forever-useful Procmon and setting it to monitor “Process and Thread Activity” before running the program in question.
  3. Next, try enabling the log file from Cursor Lock’s options.  Run a Cursor Lock shortcut or a “Test” and then read the log to help determine what happened.  You might find that Cursor Lock either closed before your desired program was locked or never locked at all, both of which suggest that the wrong executables were selected.
  4. Still not achieving a satisfactory cursor lock? Or something else weird happening?  At this point, I’d be glad to try to help you.  Leave a comment or send an email.

Q. The hotkeys won’t work.

This issue seems to be cropping up more and more, and I don’t really have a satisfactory answer as for why yet.  It also seems as though some programs will override all system hotkeys altogether, annoyingly enough.  The best advice I can give is as follows.

  1. Make sure Cursor Lock is actually running.  You should see cursorlock.exe in Task Manager.
  2. Try changing your hotkey combination to something else.  There may be conflicts with the current combination or perhaps it didn’t save correctly.
  3. If you’ve modified the hotkey combination used to toggle locking, make sure that change was saved to the configuration file, cursorlock.ini. If not, you may need to run Cursor Lock Setup with elevated permissions, i.e. Admin Mode, or try using the default hotkey combination of Ctrl-Alt-L instead.

Q. I can’t uninstall it.

That’s quite true.  There is no uninstall feature at present.  Although, there really isn’t much installed to be begin with, so I hope you’ll forgive my omission.  I do see the error in not including an uninstaller and will rectify this in future versions.  In the meantime, here’s how to uninstall Cursor Lock.

  1. Delete the directory that you installed Cursor Lock to.
  2. Delete the Start Menu folder for Cursor Lock (if enabled on installation).

Cursor Lock 3.0?

I’m frequently amazed that Cursor Lock is still relevant more than ten years after I first wrote it.  Although its focus was originally on correcting a multi-monitor support oversight, many users are now employing Cursor Lock for their windowed gaming needs instead.  This shift in audience from enthusiast gamers to gamers in general has had me thinking about how to further simplify Cursor Lock.

As mentioned in the FAQ above, Program Mode is great for efficiency but a pain for anyone but advanced users to figure out.  Personally, I loathe having yet another program running in the background on the off-chance that I might run a program that needed it.  But memory is cheap these days, so I must reluctantly deprecate Program Mode in favor of User Mode.  But, I’d like to make User Mode even better, so that all the user would need to do is select the window to lock from a list of all open windows using a systray icon, and that window will always be locked whenever you use it.  I might even add support for the often-requested but niche use case of restricting the cursor to a user-defined area.

However, I would have done this already a year ago if it weren’t for my health being in such a dubious state the last several years.  But, if good health ever returns, believe me that an update to Cursor Lock will be the first thing I do.  In the meantime, I hope the FAQ helps.  Also, I’m sorry if I don’t answer your messages and comments promptly; there are a lot of days where I can’t even put together a cogent and well-thought-out response.  So again: FAQ.  And I’ll help when I can.

Posted in Programming, Software, Troubleshooting | Tagged | 17 Comments

Diablo II Mods and Code Stuff

Hello all. My apologies for not updating this website more.  My life has become complicated lately, and in these uncertain times I find it difficult to want to write about it.  A shame really, as the site has never been more popular.  Seems like every time a new game comes out lacking multi-monitor support, I get hundreds of new visitors and users for Cursor Lock; a few weeks ago, it was Cites: Skylines.  And today with the announcement of another new Deus Ex game, my version of the soundtrack is hotter than ever.  It does make me feel good to know that I can produce things that people need, even if it’s only for video games.

Speaking of video game content, I spent a lot of time a few months ago working on a new class for Diablo II.  Well, it’s not really a completely new class, more like a subclass since I only changed one skill tree for the Amazon.  It just really bugged me how the Amazon felt so lame compared to the Diablo 3 Demon Hunter.  It’s really difficult to keep the monsters from swarming the Amazon, so I designed some Demon Hunter-inspired skills to help remedy the problem, such as caltrops, turrets, and smokescreens.  You can see these skills in action in the video below.

I also just wanted to fulfill my desire to do some really hardcore modding for Diablo II.  The game has a rather awkward system for making modifications.  If it were made today, we’d probably have XML files and LUA scripts to work with.  But since it was made 15 years ago, we instead have to settle for massive CSV files.  You can find the Demon Hunter mod on my Diablo II mod page.  And massive props to the Phrozen Keep for continuing to support D2’s modders.

Another thing that bothered me about Diablo II for so long is that when you die your corpse keeps all your equipment on it, and you respawn basically naked and unarmed.  Your only options are to run in, snatch everything off your corpse, and teleport back to town, or rage quit and hope that your corpse returns to town like it’s supposed to.  Obviously, this is almost always zero fun and is why no games handle death like this anymore.

Unfortunately, there’s no way to change this in the game’s CSV tables.  But I didn’t let that stop me.  Every now and then, a problem comes along which must be solved through assembler hacking, and this was one of those times.  But I didn’t really have a clue which function was involved in character death.  So, I just put breakpoints on every function in IDA and attached to the running process.  It took a while of breaking, disabling breakpoints, and resuming, but I eventually narrowed it down to several dozen functions involved in death.  Some functions did death animations, some saved character data, but then I found a suspicious bit of code that would loop 14 times—the number of equipment slots.  This was the code where the game looped through each equipment slot and moved the item from the player to the player’s dead body.  And then there was nothing left to do but some trial and error to figure out where I could safely jump over the offending code and re-enter.  Now the only problem is that this mod will have to be updated every time there’s a Diablo II patch. 😥

Here we see the fateful jump operation to bypass the character equipment being removed.

Here we see the fateful jump operation to bypass the character equipment being removed.

Since then, I’ve been turning back to more PHP/HTML/CSS/JS coding.  I’m working on a project that I can’t disclose at this time but which quite possibly could be my most epic work yet.  Wish me luck in completing it.

Recently, I’ve also been using PHP as my go to scripting language for everyday projects.  A couple days ago, I wanted to be able to pull all GPS image data from a directory and display it in Google Earth.  PHP has file IO, EXIF, and XML libraries, so it was real convenient to bash out a script using that.  Then I realized I had created an account on Github recently to comment on some projects and thought why not just put this code on there.  So I did.  Maybe I’ll add more small projects like this in the future.

Posted in Modding, Programming, Website | Tagged , , , , , | 2 Comments

Rise of Nations Script Maker 2.0 Preview

Rise of Nations Script Maker 2.0

Rise of Nations Script Maker 2.0

I’ve been working on a new version of my Script Maker for Rise of Nations since the release of the Extended Edition a few months ago.  I naively thought it just was going to be a matter of converting the code to .Net and updating a few routines to support EE.  However, once I saw the state of the code, I decided it was going to have to be completely rewritten.  After all, it was ten year old code written in VB6.  And I was really appalled by the “hackiness” of so much of the code—mostly because VB6 had so few built-in functions and relied on the Windows API so much.

So since I was rewriting the whole program anyways, I took the opportunity to make numerous improvements.  I won’t post the whole changelog, but here are some of the highlights:

  • Streamlined the interface significantly
  • Stat tables now support filtering, sorting, and better change highlighting
  • Broke the stat tables up by units, buildings, and techs while combining disabling and researching with stats
  • Scripts can now have descriptions
  • All data is loaded from the games now
  • Changed the script save format to XML
  • Dropped the use of the MSXML library in favor of .Net’s XML library

At this point, I’m mainly just doing testing and documentation. So, expect release within the next couple of weeks.  I may put a call out for beta testers before then, but I haven’t decided yet.

Posted in Gaming, Modding | Tagged , | Leave a comment

Brecourt Video Update

I’ve still been putting a lot of work into my Brecourt Manor map lately, and it feels like it’s over half complete.  I’ve got a lot of the hedgerows placed, so it’s mostly a matter now of filling in the fields and making everything look natural.  The map’s script has also come a long way (at over 700 lines so far) but still has a lot of tweaking left to go.  However, I’m feeling a lot more comfortable with LUA and the SCAR functions, so it should go quickly.

A couple weeks ago, I dabbled briefly with the Unity engine to see if it was viable for another project I’ve been longing to make.  There’s a lot to learn up-front about Unity before you can get anything even playable (take Quaternions for example), but then things start to come together.  In only a few days, I made from scratch a basic tank that drives around and shoots with (mostly) realistic physics.  I must say, though, that this is the most math I’ve done since college.  😕

Posted in Gaming, Modding | Tagged , , , | 1 Comment