Category Archives: Modding

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

Brecourt Manor Progress

Brecourt Manor 11-17-13The gun trenches are more or less complete and work has started on the surrounding environs.  Creating realistic-looking hedgerows is a multi-step process: trees first, then the hedges themselves, bushes, and finally some scrub grass to smooth out the base.  Then repeat over and over because Normandy is nothing but hedgerows.

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

Brecourt Manor in CoH

A few months ago, I released my first singleplayer map for Company of Heroes.  I had a lot of fun scripting the scenario, which is done entirely in LUA, so I was eager for another map to work on.  And it didn’t take long until inspiration hit me in the form of re-watching Band of Brothers.  The prominent engagement in the second episode is the assault on the guns at Brecourt Manor.  The episode must have inspired others as well, since several video game recreations already exist; most notably in the first Call of Duty.

However, all the existing Brecourt Manor assault recreations have major accuracy flaws.  The CoD one has fairly accurate trenches (where the guns were located), but the context is very flawed (e.g. Easy Company did not subsequently attack the manor itself).  There is also another Brecourt map made for CoH, but being that it was made for multiplayer, balance concerns forced them to change almost all the geography other than the trenches.

So to distinguish my attempt from all the others, I decided to make what I hope is the most accurate portrayal of the battle.  To achieve this, I first gathered up as many maps as I could showing the fields and hedgerows where the battle occurred—present day Google maps, 1947 aerial map, D-Day recon map, and a map apparently provided by Maj. Winters.  I then layered and lined up the maps in an image editor to create a composite image of the most accurate map I could make.  That image appears below.

Brecourt Manor Assault Template Map

Brecourt Manor Assault Template Map

You can see on the above image that I’ve already established the playable area (red rectangle) and the map boundaries (green rectangle) for the CoH map, with the gun trenches located in the center.  But the next step is where the real magic happens in making this map as accurate as possible.  In a process I first used in my Ogledow map, I took a greyscale version of the composite image above, saved it to a bitmap, and then copied its raw bytes into a data format called a “stamp”.  The CoH WorldBuilder uses these stamps to let you copy map data between maps, but using this technique, one can also copy data from images into maps.  The result can be seen in the below images.

The result being an extremely accurate template by which to “draw” the actual map content.  This is about as far as I got when I first started working on the map since Serpent 3 was nearing the end of its life at the time.  But I just recently got back into it and I’ve made some pretty good progress, although I’m nowhere near done.  I’d say I’m to a point where it’s playable, though.  (Props to the guys at Relic that actually make these maps from scratch.  It takes forever to get them to look realistic.)

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

Removing Heartbeats from Sniper Elite v2

I finally got around to playing Sniper Elite v2 after buying it a while back and then finding out it required Windows 7.  Serpent 4 fixed that, of course.  And it’s pretty damn fun.  The multiplayer takes me back to the days of Delta Force sniper wars circa 2000.

Sniper Elite v2

Sniper Elite v2

The main problem I had with the game was the annoying—perhaps even disturbing—heartbeat sounds that play whenever you’re looking through the scope.  It really serves no gameplay purpose considering the sound just plays constantly.  And there’s naturally no way to turn the sound off through options or config tweaking.  So one must turn to modding, and that’s what I did.

A quick perusal of the installation directory for the game reveals a “Sounds” directory with three files in it, clearly archives given their size.  StreamingSounds.asr is probably music and GmSnd.en is probably speech, so that just leaves GmSnd.asr as the likely archive for the heartbeat sounds.  Opening the file in a hex editor shows no readable strings whatsoever except for the header of “AsuraZlb”.  The “Zlb” part is curious enough and could mean that the file is actually compressed using Zlib.  In fact that’s exactly what it means.

In order to do anything with this file, it first needs to be decompressed.  Googling around, I quickly found a nifty tool called offzip that can do exactly this.  It’s a command-line program, so extracting it into the Sniper Elite “Sounds” directory is the best way to work with it.  This tool has several operations but the one we’re interested in uses the -a switch to decompress any found data.  To do this, fire up a command prompt or batch file and run the following.

offzip -a GmSnd.asr . 0

This gives us a new file of larger size in the same directory.  Taking this new file back into a hex editor shows a lot of readable strings and many matches for “heartbeat”.  One match in particular is very interesting.  It has the path of a wav file heartbeat01.wav followed by a RIFF header.  Somewhere in this vicinity of the file is the start of the heartbeat sound’s waveform data.

If you decode the bytes out as I did in the screenshot below, you eventually get to a string of text that reads simply “data” and is followed by a 4-byte (32-bit) integer that is the size of the waveform data—in this case, 45920.  Immediately following that, you just pace out the 45920 bytes of data, which should end just before a “smpl” header, and you have the entirety of the sound data selected.

Modded Heartbeat Sound in GmSnd.asr

Modded Heartbeat Sound in GmSnd.asr

The thing about WAV files is that they’re uncompressed (or lightly compressed in the case of ADPCM).  So two bytes (16-bits) of zeros in the waveform data means silence for one sample in the 44100 samples per second of audio.  Using this knowledge, we can just change all the samples to zero to make the whole sound file only silence.  To do this, you’ll need to be using a hex editor that has a fill with zeros feature.

With that part done, we can now save and test our modded archive file.  Don’t forget to rename this modded file to the original filename of GmSnd.asr and backup the original file itself.  You may also be wondering why we haven’t tried to recompress the modded file with zlib; and this would be an astute observation.  Basically we’re hoping the game is smart enough to load both compressed and decompressed data.

Now with Sniper Elite loaded up, we can start a new game and then look through the scope of a rifle to test our mod.  You’ll notice that the heartbeat sound still plays but it pauses every four beats.  Apparently there is more than one sound file that makes up the heartbeat sound effect, but we’re on the right track since one of them is now silent.  We just have to go back into the hex editor and change the four more sounds that follow the one we’ve already done.

And that’s it.  No more listening to that droning heartbeat sound while you’re sniping.  Luckily, this mod doesn’t lock us out of multiplayer either.  Happy sniping!

UPDATE 9/9/13

It’s been said around the webs that merely changing the name of the sound files is enough to disable them.  This would make zeroing out the sound data unnecessary.  However, I have not tested this method.  And one still needs to decompress the archive as detailed above.

Posted in Gaming, Modding | Tagged , | 6 Comments