Tag Archives: PHP

More Mods and Modding

Epic Games Mod Music

In a continuing effort to further perfect my mod music library, I’ve been redoing my conversions of the music from several of my favorite Epic MegaGames soundtracks, specifically Unreal, Unreal Tournament, and Jazz Jackrabbit 2.

My previous efforts were all plagued with improper volume levels as I naively thought that music should just be normalized and that’s it, job done. Since then, I’ve come to understand about loudness levels and limiters that can increase the volume without clipping. To be fair, normalizing is still the most appropriate way to level audio as it doesn’t alter the dynamic range. The only problem is that normalizing alone is impractical as all other music these days is boosted to a loudness of around -10 LUFS, and you don’t want to constantly adjust your speaker volume to account for the variance in volume. It seems mod music is particularly susceptible to being problematic in this regard as well since many tracks were made to just slam up against 0dB and let the player’s Auto-Gain Control sort it out.

Unfortunately, the automated mod conversion process that I mentioned last post has one major flaw in that it just kinda makes all the tracks the same volume. -10 LUFS loudness is fine for most lively music, but for softer tracks (like that of Unreal’s ambient music), you might want the volume up to 10 LUFS quieter. You really have to listen to each track and decide on an appropriate loudness. So, that’s what I did. You can download all three game soundtracks and listen to some samples from the Epic Games Tracker Music project page.

The majority of the three soundtracks were converted in the automated way using FFmpeg’s OpenMPT library and built-in audio filters. Some of the tracks were ones that I selectively recorded/remastered and then released here back in 2008, but just with the fixed volume levels. Luckily, I still had all the wave files available to use. And a few tracks I actually remastered recently in the same way that I did for the Deus Ex Soundtrack remaster. So, it’s kind of a hodge-podge of different conversion methods, unfortunately, but I wanted to just make it available for people as-is and hopefully add more remastered tracks later. It’s still very listenable, though, as long as you don’t mind some clicking and pops from bad samples and sudden track ends.

There’s also a bit of an issue with much of the Unreal music included as it only contains the ambient sections of each track. It wasn’t until after I had everything ready for upload that I finally figured out how to get FFmpeg to convert the other sections of the tracks. These sections are often referred to as “subsongs” (at least in contemporary mod players), but the mod formats don’t have a specific mechanism in place to define these sections. Instead, they merely use the Bxx effect command to jump to different patterns in the song. These can be used to loop different sections of the song and be programmatically switched between, e.g. in a video game. The OpenMPT library actually has a process included that can identify these sections, and it’s also available as an option in FFmpeg by utilizing the option -subsong. However, I couldn’t find a single example of how this option is used anywhere online and only later (through shear persistence… or maybe just dumb luck, I forget) discovered that the subsong option has to go before the input file is given (-i). Maybe that makes sense because it’s technically modifying what the input is…? I dunno, it seems pretty stupid to me, especially undocumented.

Regardless, I need to reconvert a lot of the Unreal soundtrack as such. I would have just gone ahead and done it, but many of the sections are rather long and perhaps need to be a separate track. Some people always complain about how I did the Deus Ex soundtrack remaster with every section included in one track, and I still think that was the right choice for Deus Ex, but it’s making me hesitant to repeat that arrangement for Unreal. It just needs further consideration.

And honestly, Unreal is probably the weaker of the three soundtracks. There’s definitely some great tracks in there, but UT and Jazz 2 just have some seriously bangin’ tracks. Alex Brandon really did some amazing mod compositions back then. I actually also realized that the versions of the Jazz 2 soundtrack that I had (from Lori Central) were slightly different from the game versions, so I converted all the Jazz 2 music a second time to see which versions I should include in my compilation. I ended up writing a whole PHP script to extract the mod format files from the j2b files that come with the game, and then found out that OpenMPT will just open the j2b files as is. 😄

Borderlands Modding

I’ve been playing a lot of Borderlands 2 recently. There’s just something about that game that makes it probably the best “looter shooter” AKA first-person action RPG—it’s probably the very satisfying visuals combined with the endlessly-humorous dialogue. Seeing damage numbers fly out of enemies as you shoot, punctuated by the occasional “CRITICAL” hit really prods those dopamine receptors. And all of the characters being just such over-the-top caricatures with the most irreverent dialogue—Scooter’s incestuousness, Moxxi’s innuendos, Brick’s insatiable bloodlust, all the bandits’ ridiculous one-liners, etc.—it always lifts my spirits.

But even for all its good qualities, the game isn’t without its faults. And I’m apparently perpetually drawn to attempting to fix such faults in the form of game modding. However, I specifically remember trying to find some BL2 modding tools several years back and coming up empty-handed. But after a recent playthrough, I looked again and was delighted to see that a modding community has sprung up around the game after a couple of different modding methods were devised.

The first modding method is quite straightforward and intrinsic to the Unreal engine that the game is built on, and thus I am surprised there weren’t more mods made for the game sooner. It relies on the console being enabled and then using two console commands to override game settings. The first being the set command, which changes any variable to some given value. And the second being the exec command, which reads a text file in and executes whatever commands it finds. These allow one to change as many game settings as necessary and then package the changes all in one convenient text file. There’s even a tool made to help format and merge multiple mods into one file called OpenBLCMM.

The other method I only started looking into recently, but it is very powerful if you have enough motivation to figure it all out. It’s of the variety of DLL-injected code wrappers that can load any number of external scripts and is called succinctly-enough PythonSDK. Unfortunately for me, I’ve been neglecting to learn Python for years (mainly because of my illness to be fair). Mostly I just find Python to only be popular because of this one gimmick it has where text indentation and line breaks also control code blocks. It is nice that all Python code looks really clean and uniform (boy, do I hate people that put beginning curlies as the only thing on a whole line in other languages), but it really doesn’t seem so groundbreaking that everyone needs to switch to it as the new hotness. But that’s probably just my uninformed and biased position as a newcomer. 😛 I also thought Half-Life 2 was overrated at first. 🤐

Anyways, I’ve already fixed a number of small nagging issues with BL2 and have a basic framework for a larger change mostly figured out. One thing that’s always annoyed me about Borderlands games is their inclusion of an accuracy attribute on all weapons. So, you can have your crosshair directly over an enemy and the shot just plain misses or hits but isn’t a critical hit. It removes a lot of the skill from the game and replaces it with luck, which feels less satisfying.

I’ve changed the game to always be completely accurate when aiming down the sights, and to also have slightly better accuracy control when hip-firing. It’s totally revitalized the game for me, making me rely much less on sniper rifles (which were always close to 100% accurate when aiming down the sights) and experimenting more with the other types of weapons. I’ve also been tweaking some of the recoil characteristics of the guns to make them more controllable, especially for the SMGs, which I could never quite put my finger on as to why they felt so bad to spray, but have since realized that it’s because they recoil mostly only horizontally—try keeping the reticle on-target when it constantly bounces left and right randomly.

I’d like to release my BL2 mods, of course, but the weapon handling mod will need a lot more testing and tweaking until it’s to a point where I’m satisfied with the feel and game balance. I guess it does make the game easier, provided your aim and recoil control is good, so that’s something I have to look into as well. Check back later to see if it gets completed and released. 😛

Deus Ex Soundtrack Videos

One thing I like to do these days when I’m feeling only-slightly crappy is edit videos. It requires only a modest level of thought and creativity while being mostly an engaging yet repetitive task—make a small timeline tweak, rewatch to see how it looks, repeat. My CPU is over 10 years old now, so it chugs a lot when editing HD video, but it’s bearable I suppose.

One project to come out of this video editing recently has been a series of music videos to accompany my remastered versions of the Deus Ex Soundtrack. I really wanted to expose a wider potential audience to the remasters, and I thought YouTube was a good platform for that, being so open and also having a huge library of music already. I thought about just putting a static image, the cover image, for the video portion (as so many people do for music videos on YouTube), but that seemed too lame and uninteresting for someone that was watching on anything with a screen. But I also didn’t want to have a lot of fast-moving gameplay captures since that would massively increase the file-size (for variable bit-rate video compression at least, which is what YouTube uses) for users only listening. So I decided on a compromise of in-game capture with a stationary camera to keep the motion down.

I ended up creating a little library of shortcuts and console commands to help simplify the process. Luckily, Deus Ex has all its scripts easily editable from inside UnrealEd (the original one still runs if you have all the ActiveX library files installed) unlike Borderlands 2. Here are the edits I made to the “DeusExPlayer” class.

var bool bToggleHud;
var bool bToggleGhost;
var bool bToggleInvisible;

// ----------------------------------------------------------------------
// ToggleHud - Snake Modification
// ----------------------------------------------------------------------

exec function ToggleHud()
{
    if (!bToggleHud)
        ShowHud(false);
    else
        ShowHud(true);
        
    bToggleHud = !bToggleHud;
}

// ----------------------------------------------------------------------
// ToggleGhost - Snake Modification
// ----------------------------------------------------------------------

exec function ToggleGhost()
{
    if (!bToggleGhost) {
        Ghost();
    } else {
        Walk();
        ClientMessage("Walking");
    }
        
    bToggleGhost = !bToggleGhost;
}

// ----------------------------------------------------------------------
// ToggleInvisible - Snake Modification
// ----------------------------------------------------------------------

exec function ToggleInvisible()
{
    bToggleInvisible = !bToggleInvisible;
    Invisible(bToggleInvisible);
}

// ----------------------------------------------------------------------
// SpawnMassPawn - Snake Modification
//
// Spawns a bunch of pawns around the player with an optional number, alliances, and weapons
// ----------------------------------------------------------------------

exec function SpawnMassPawn(Name ClassName, optional int TotalCount, optional Name Allies, optional Name Enemies, optional string WeaponPackage)
{
    local ScriptedPawn spawnee;
    local vector       spawnPos;
    local vector       center;
    local rotator      direction;
    local int          maxTries;
    local int          count;
    local int          numTries;
    local float        maxRange;
    local float        range;
    local float        angle;
    local class        spawnClass;
    local string       holdName;
    local float        rnd;
    local int          i;

    if (!bCheatsEnabled)
        return;

    if (!bAdmin && (Level.Netmode != NM_Standalone))
        return;

    if (instr(ClassName, ".") == -1)
        holdName = "DeusEx." $ ClassName;
    else
        holdName = "" $ ClassName;  // barf

    spawnClass = class(DynamicLoadObject(holdName, class'Class'));
    if (spawnClass == None)
    {
        ClientMessage("Illegal pawn actor name "$GetItemName(String(ClassName)));
        return;
    }

    if (totalCount <= 0) totalCount = 10; if (totalCount > 250)
        totalCount = 250;
    maxTries = totalCount*2;
    count = 0;
    numTries = 0;
    maxRange = sqrt(totalCount/3.1416)*4*SpawnClass.Default.CollisionRadius;

    direction = ViewRotation;
    direction.pitch = 0;
    direction.roll  = 0;
    center = Location + Vector(direction)*(maxRange+SpawnClass.Default.CollisionRadius+CollisionRadius+20);
    while ((count < totalCount) && (numTries < maxTries))
    {
        angle = FRand()*3.14159265359*2;
        range = sqrt(FRand())*maxRange;
        spawnPos.X = sin(angle)*range;
        spawnPos.Y = cos(angle)*range;
        spawnPos.Z = 0;
        spawnee = spawn(SpawnClass,,,center+spawnPos, Rotation);
        if (spawnee != None) {
            if (WeaponPackage != "") {
                //clear the default inventory
                for (i=0; i<8; i++) {
                    spawnee.InitialInventory[i].Inventory = None;
                    spawnee.InitialInventory[i].Count = 0;
                }
                switch (Caps(WeaponPackage)) {
                    case "PISTOL":
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponPistol');
                        spawnee.AddInitialInventory(Class'DeusEx.Ammo10mm', 2);
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponCrowbar');
                        break;
                    case "MELEE":
                        rnd = Rand(3);
                        if (rnd == 0)
                            spawnee.AddInitialInventory(Class'DeusEx.WeaponCrowbar');
                        else if (rnd == 1)
                            spawnee.AddInitialInventory(Class'DeusEx.WeaponCombatKnife');
                        else
                            spawnee.AddInitialInventory(Class'DeusEx.WeaponBaton');
                        break;
                    case "ASSAULT":
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponAssaultGun');
                        spawnee.AddInitialInventory(Class'DeusEx.Ammo762mm', 12);
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponAssaultShotgun');
                        spawnee.AddInitialInventory(Class'DeusEx.AmmoShell', 12);
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponCombatKnife');
                        break;
                    case "FLAME":
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponFlamethrower');
                        spawnee.AddInitialInventory(Class'DeusEx.AmmoNapalm', 8);
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponCombatKnife');
                        break;
                    case "NONLETHAL":
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponProd');
                        spawnee.AddInitialInventory(Class'DeusEx.AmmoBattery', 6);
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponPepperGun');
                        spawnee.AddInitialInventory(Class'DeusEx.AmmoPepper', 2);
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponBaton');
                        break;
                    case "PLASMA":
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponPlasmaRifle');
                        spawnee.AddInitialInventory(Class'DeusEx.AmmoPlasma', 20);
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponNanoSword');
                        break;
                    case "SWORD":
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponNanoSword');
                        break;
                    case "STUN":
                        spawnee.AddInitialInventory(Class'DeusEx.WeaponProd');
                        spawnee.AddInitialInventory(Class'DeusEx.AmmoBattery', 50);
                        break; 
                }
            }
            spawnee.InitializePawn();
            if (Allies != '')
                spawnee.SetAlliance(Allies);
                spawnee.ChangeAlly(Allies, 1, True);
            if (Enemies != '')
                spawnee.ChangeAlly(Enemies, -1, True);
            count++;
        }
        numTries++;
    }

    ClientMessage(count$" actor(s) spawned");

}

The first three functions just allow you to have a single key for each of the commands by toggling them. The last function is a modification of an existing function that lets you spawn a bunch of objects around the player, but I’ve expanded it so you can set alliances and give them weapons. This was handy for spawning two groups of characters and then having them fight so I could record it. 😄

To use all of these functions, you need to make some modifications to your Deus Ex keybinds in the User.ini file. Find the section [Engine.Input] and add the following commands to some keys.

L=legend
K=set deusex.jcdentonmale bcheatsenabled false
J=set deusex.jcdentonmale bcheatsenabled true
I=ToggleInvisible
H=ToggleHud
G=ToggleGhost
Tilde=type

As for what these keybinds all do: J will turn cheats (and the type command) on, K turns cheats back off. The game puts a “cheats enabled” watermark on save game screenshots to make you feel bad about cheating, so it’s helpful to be able to turn it back off. Tilde (~) opens the command line so you can type in commands like the SpawnMassPawn() defined above. H toggles hiding the HUD, useful, of course, for getting clean screenshots or video captures. G toggles “ghost mode”, which is basically just noclip plus fly, so you can position the camera wherever you need to get the best shot. I toggles invisibility, which is useful for making actors not respond to you. You’d think ghost would be enough, but they’ll still target you if not invisible. And L opens the in-game debug / “secret” menu. It’s useful for switching maps without having to type in the open console command. See the screenshots below.

So, utilizing all of these tools was how I was able to record all the b-roll footage for the YouTube videos. I guess it’s nothing special, but maybe it helps give people the nostalgia berries even more, really putting them into the levels, plus some silly fight scenes for the lulz. The response from YouTube comments and views has certainly been positive, at least. For the record, I only did videos for the tracks that I redid in the recent soundtrack update. I’m hoping to do the rest of the videos when I do the rest of the remasters.

What Else I’m Up To

As I spend most of my days feeling unwell, I end up watching a lot of gaming streams. I’m quite thankful that such lengthy forms of entertainment exist these days. There are three streamers that I watch pretty much exclusively. I got into ChocoTaco from my PUBG addiction, and I think he best mirrors what my playstyle would be if I weren’t sick–extremely calculated and with good instincts. Unfortunately, Choco’s sense of humor is a bit lacking, so for a dose of levity, I like to watch a British streamer called Platform32. I also discovered him through PUBG, but he plays a fair amount of other games that I enjoy as well, all laced with copious amounts of witty and raunchy banter. Finally, and this is bit of an odd one, but I really enjoy watching Felicia Day for some reason. She’s not the greatest of gamers, but she does okay, and the arc of her failing repeatedly before finally overcoming challenges is entertaining somehow—Felicia can be quite bombastic. That, and she talks a lot and is generally insightful enough to keep it interesting.

Like I said earlier, I’m doing a fair bit of video and audio editing. I’ve become rather decent at it, frankly. I’m also doing a lot of home improvement since it allows me to not have to think so much. Plumbing, electrical, woodworking, HVAC repair, painting—I’ve been dabbling in it all. Getting people to come out on my schedule and fix things has become quite inconvenient and expensive these days, so DIY almost seems like a necessity as long as it’s not an emergency repair.

And I’m still playing some video games, though not for as long or as wide a variety as I would like. I played a lot of Vampire Survivors and Ooblets last year. And, of course, I have my yearly replay of Slime Rancher and Stardew Valley to occupy me.

Well, this is an epicly-long post, so I better end it already. I do appreciate the comments everyone leaves; sometimes they do encourage me to poke around with a project again.

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

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

We have explosive.

(i.e. Lightboxes)

I’ve been really into web development lately, especially anything requiring a lot of JavaScript control of the DOM and CSS control over layout and style. I’ve spent a solid week (at least) working on adding lightboxes to replace some of my lighter scripts: image viewing and downloads. I’ve been pretty fascinated by lightboxes ever since I saw them on addons.mozilla.org. The idea to actually employ one on this site didn’t come to me until I was doing the remake of the content system and thought it would be awesome to combine a lightbox with the ability to preview the contents of archives (rar and zip files).

Although there are tens if not hundreds of lightbox implementations, I felt like creating my own to avoid all the code bloat and because I’m that much of a control freak. The first hurdle was figuring out how the hell these other lightboxes could be triggered on the click of a link without navigating to the link URL immediately after the script finishes. Googling didn’t turn up any leads, but I eventually found out the answer by just reading the code comments of another lightbox. It’s simple and makes sense but isn’t obvious: the onclick function must return false. It kinda works like a message chain in Windows.

From there, I just kept chugging out JavaScript. On DOM readiness, the script adds onclick events to trigger the lightbox to any existing links to image or download pages. On click, the script does the appropriate HTTP request (AJAX) for the content to fill the lightbox. On request received, it puts the HTML into a lightbox container that automatically enlarges to fit content. Meanwhile, the script is fading in the obligatory black overlay; I chose to fade it in not only because it looks awesome but it also helps your eyes to adjust to change in light. It’s all a delicate ballet of scripting, but surprisingly IE performs quite well with it and only minimal hassles (e.g. filter: alpha(opacity=#); instead of opacity: #.#; for overlay opacity in CSS).

It didn’t stop with lightboxes, though. I’ve also been wanting for a while to have a display of the most recent uploaded images on the front page but was underwhelmed by the prospect of cramming only a few images on there. Then I got to thinking about how I might make a scrolling marquee for the images and realized it wasn’t too hard to code. You simply need an inner container for the images with position: relative and an outer container with overflow-x: hidden and on button script events move the inner container’s style.left property by negative the amount to scroll. Then, obviously, you have to do some code to detect the beginning and end of the marquee to keep it within bounds among other things. Quite snazzy.

I also made another slight change to front page (beyond adding the latest blogs). I was a little displeased by my method of finding the most popular content given that it merely sorts the database by the total downloads. Thus, it’s not at all responsive to changing trends. For example, if file A gets 1000 downloads over five years but not much recently, and file B has only 300 downloads over a couple months but gets several hits a day, then file B is obviously more popular than file A. The best solution to calculate what’s more popular would be to log all the hits for a day for every file and calculate popularity trends often, but that’s a logistical nightmare and too much hassle for this small site. However, I came up with a simple solution that requires only one new field in the database (last_dl_count) and a monthly cron job to do UPDATE `content` SET `last_dl_count`=`dl_count`;. Finally, I switched the front page popular query to the following:

SELECT `id`, `title`, `sshots`, `dl_count`, (`dl_count`-`last_dl_count`) as `delta_count` FROM `content` WHERE `type` = '$type' ORDER BY `delta_count` DESC, `dl_count` DESC LIMIT 2;

It works fairly well, except at the beginning of the next period after the update cron runs. Since all the deltas are 0, you get only the all-time popular again until someone downloads something.

Well, I think that’s enough web developer theory for now. However, I’d like to point out three academic columns I recently added. There’s one from Fortran Programming class with all my source code and most of my documentation. The second is on the Parallel Programming with PVM project I did last year, including a Flash slideshow (first mentioned here), presentation notes, and source code. The last is a paper I wrote on the Aspects of Overpopulation, a subject that greatly concerns me; too bad the class it was for was completely worthless.

Posted in Academics, Programming, Website | Tagged , , , | Leave a comment

The Monolithic Procrastination Post

Yes, I’m aware that I’m a bastard for not posting for a whole two months despite not having any work obligations. I was honestly going to post last month following the release of the new Cursor Lock version, but got sidetracked with other projects. The story of my life really–project ADD.

news270

Cursor Lock 2.5 alpha

However, for anyone yearning for a new version of Cursor Lock, I can assure you that I will finish it soon as it’s practically complete already (as the screenshot at right will show). I’ve already completed a majority of the testing and just have a few more issues to resolve and documentation to update. I’ve also found a game that puts the new features to use: DX-Ball 2. The new window locking mode works perfectly in the game’s windowed mode to keep the paddle’s responsiveness from drifting out of the window with the mouse.

Another project that I wanted to post about alongside Cursor Lock last month is my newest Age of Empires 3 mod, Banner Army Reforms. It’s a relatively simple tweak that makes a big difference to the manageability of the Chinese civilization. It allows the player to train units individually instead of in unique groupings (Banner Armies). While a key facet of the Chinese, Banner Armies were just a strategic annoyance to me. Too bad the Chinese still suck.

Last post, I mentioned a PHP script that used PEAR’s Text_Highlighter package, but which I had some concerns about and thus wasn’t ready to go live with. Since then, I’ve been racking my brains trying to come up with a way to securely show external source code files (that have been parsed with Text_Highlighter) embedded inside a formatted page. My second implementation idea was to use my inflatable wrapper technique that places a formatting script inside the target source code file; however, that would force me to make the source code files have .php extensions. I also considered a database of IDs and associated code files, which would be secure but also a hassle and it would obfuscate the underlying source code files.

After much googling and frustration, I finally found a way to make certain file extensions be passed to a handler script. This obscure Apache manual page shows how to add an action to extension handlers. If the target of the action is a script, it will receive the originally called file as some sort of CGI parameter; in PHP, it’s placed in the ENV variable $PHP_SELF (don’t use $PATH_INFO, it can be spoofed).

Once I had all that snazzy handler business figured out and implemented in the script, I noticed a glaring oversight in the Text_Highlighter package. Since they place all the source code in a <pre> tag, no word-wrapping is done. Quite frankly, I never care enough to bother with manually line-breaking code and just let it run off as far as I need. However, on a webpage, horizontal scrolling is a cardinal sin. So, I spent more time than I’d like to admit rewriting the output module of Text_Highlighter to put the source code in a table which would allow it to wrap effectively while preserving line numbering and line indentations. I ended up actually having to put the indentation whitespace in a cell by itself. The script still needs a bit more polish, but can be seen in action on the files in this parallel program directory.

Those source code files are actually part of a column I’ve been working on lately to show off the parallel program I wrote for my final college project. Besides having beautified code, the column is also to have a web-based version of the Powerpoint slideshow I gave during my results presentation. I had originally made a simple PHP script that took a page number as a parameter and showed the appropriate slide image with all the formatting and such. I had two problems with this, however: there was no ability to copy the slide’s text and it was a bit underwhelming in this Web 2.0-hyped world. So, on a whim, I decided to have a go at making a Flash movie with all the typical play controls as well as Fullscreen and Copy Text buttons, which could load in an external SWF file with one slide per frame. Of course, it has all sorts of delicious alpha effects, too. The parallel presentation slideshow isn’t quite live yet, but you can see the new Flash in action on the lovable old Tony the Worm column. It still needs a smidgen of work yet, though, such as tooltips. I find Flash a decidedly quirky and frustrating format; finishing one button is enough for celebration.

Posted in Modding, Programming, Website | Tagged , , | Leave a comment

A Full Month of Doings

I’ve been working on so much stuff lately that it’s hard to decide what to devote each day to. Of course, practically everyone I know doesn’t give a shit about the awesome stuff I do and rather I just jump into the rat race. But anyways, here’s an overview of what I’ve been working on…

Not long after my last post, I updated my mod for the Age of Empires 3 expansion The Asian Dynasties called Gatling Guns for All!. Previously, you could only use the mod with a specific unmodified version of TAD, but I wanted the mod to be usable by all versions of both The Asian Dynasties and The Warchiefs expansions even if they’ve been previously modded. Thus, I had to create an installer (similar to the one I did for Stalker) that would modify only the aspects of the game that I changed. Originally (as I did in the Stalker mod installer), I tried to use regular expressions to find the appropriate setting to change. However, being that the game data is stored as XML, Regex had problems matching certain XML formatting quirks. So, I moved to a query language that I’d never used before called XPath, which is basically XML hierarchy-aware Regex. Though getting some of the nodes in AOE3’s settings files to match was still tricky, XPath in .Net did the job perfectly.

When I went to package the new version of the mod, I actually found out that I had incorrectly archived an essential file in the wrong path in the first versions of the mod. Thus, nobody that downloaded it would have gotten the mod to work as intended :( . And only one person called me on it, though I thought he was a noob at first. But all has been rectified now.

Next, I started working on a script for this site that would color-code programming language syntax and elements so I can attach beautified code to some columns. The script uses a PEAR PHP library called Text_Highlighter to do the color-coding on the fly. However, at the moment, my part of the script still presents certain security risks that I will have to mitigate before it goes live.

news269

Lego Indiana Jones

That project was interrupted by a visit from Kaylen that turned into non-stop gaming in the form of Lego Indiana Jones 😉 . Although the game was littered with some annoying little bugs (having just been released), we did manage to get 100% completion. As most reviews have said, it wasn’t really as fun as Lego Star Wars–how can you beat lightsabers and the force? Though bazookas and bushes you can jump into come close.

The next week, following a concern from a user, I began working on a major new feature for Cursor Lock. Though not really having anything to do with multimonitor gaming, the feature is a natural progression of the existing code. It allows the user to select whether to lock the cursor into the current screen (what it did originally), the selected window, or the selected window interior (client area). Locking the cursor into the window interior is particularly useful for playing windowed 3D games. While I was at it, I decided to completely overhaul the setup GUI to be much more intuitive, separating the selection of the different modes with pretty, graphical buttons. It’s looking rather nice already and should only take a few more days of testing and fixing bugs until public release.

Last week, I got distracted when randomly deciding to replay Deus Ex: Invisible War and then subsequently desiring to mod out some of the major flaws in the game. Only a few changes would make the game much more palatable to the PC fanbase. One of the mod ideas I had was to combine the various proximity and thrown variants of grenades (EMP, scrambler, gas, and concussion), which would return the grenades to their vanilla Deus Ex functionality and give the player a lot more inventory space. So apparently, the developer of Deus Ex, Ion Storm, only decided to release the Thief: Deadly Shadows editor and not the Invisible War one, even though the games were made concurrently on the same engine (Unreal Warfare). I tried for days to get the Thief editor to work for Invisible War, but I don’t see it ever working out easily; there are far too many hardcoded elements of the games in both the editor and the game executables. The best I could do was to get the DX2 packages to load in the Thief editor after it had loaded the core Thief packages first. Then, I could get the DX2 packages to save after some simple modifications, but that made it so there were both Thief and DX2 classes mixed together, making a good number of DX2 objects break ingame (e.g. inventory, particle emitters). In other words: Epic Fail. 😕

However, while I was poking around in Invisible War’s resources, I found the plaintext files containing the secret area’s developer quotes. I decided it’d make a good contribution to my Deus Ex column, despite not being from vanilla Deus Ex. Then, whilst I was formatting the quotes for HTML, I got the crazy notion of using the game’s font for the text. Unfortunately, the font was not in a TrueType or comparable format, but rather it was merely a texture and an accompanying text file (DX2_FONT.cel) of comma-delimited texture character widths (in pixels) that were ordered corresponding to their ASCII value. The texture character height was understood to be 23 pixels, so that a width of -1 in the text file meant to go to the next row. Using a quickly thrown together program, I turned the width values into a Paint Shop Pro script (macro) that would cut out all the characters into individual bitmaps. Finally, I manually pasted them into a font editor to complete the conversion. The font can be downloaded here, and then can be tested on the aforementioned DX2 quotes page.

Posted in Modding, Programming, Website | Tagged , , , , | Leave a comment

Keeping Busy

Posts have been slow to come lately, but of course, this doesn’t mean I haven’t been working on anything. In addition, school just ended at the beginning of the month–this time for good, or so I think. I haven’t actually gotten my diploma in the mail yet. But, I’m pretty sure I graduated.

And now I’m being bombarded with queries about what, when, and where I’m going to get a job. So far, I’ve taken a passive approach to finding employment and, even with that minimal effort, have had a couple offers already. I think once I decide I’ve rested enough and start looking in earnest, I won’t have much trouble finding a great job.

Naturally, now that I’m done with school, I have a bunch of academic papers that I’m wanting to add to the site. Previously, I would just upload a Word “Web Page” version of papers, link them, write a little blurb, and that’d be it. However, I’ve grown weary of the full-frame white document backgrounds of all my uploaded papers and the disconnected feeling it brings to the site’s style. At first, I went about rectifying this with another PHP script where you pass in an ID for a particular paper listed in a database. However, I ran into a snag with this method because Word always exports Web Page image paths (and also <a name> internal links) relative to the document, and the script’s path would differ. My first fix was a client-side workaround using the <base href> tag which forces a document’s path to whatever you want. This worked decently enough, but of course, you can never be too sure of client-side support for a rather obscure tag (though FF2 and IE6 did seem to support it). My final fix was to “include” the wrapper script in the document itself (thereby eliminating the need for the aforementioned fix), obtaining the calling document using the $SCRIPT_NAME environmental variable. From there, the wrapper script reads the calling document’s title, url, body contents, and style contents, outputting them where necessary and giving the page a clean, stylized, embedded document look.

So far, I’ve only applied the wrapper script to some of the existing academic papers. This is taking longer than it sounds because I’m having to redo the Web Page export from Word. Apparently, in Word 2003, there is an option to export a “Filtered” Web Page, which removes all the Word-specific markup and reduces the file size by about 4KB + 10% of the overall size. I’m also doing more robust linking, both internal and external to the document. It should be fairly impressive once everything, previously existing and new, has been updated and linked into databases–I’ve even got some source code to put in this time around.

I’ve been working on the Company of Heroes map mentioned last time some more. I haven’t made a lot of progress, but nevertheless, I’m almost done with the playable area of the map. Beyond the playable area is the “out of bounds” (OOB) area, which is mainly just for making the map setting look realistic and “not like a table-top” so they say. It’s basically the same idea as my wrapper script, smoothing out the differences between the playable area and the surrounding environment. The OOB won’t take nearly as long to construct as the playable area has, though, because it will mostly be low-poly pine tree groves and the stream and road rolling off into the distance. Anyways, here’s a screenshot of the area I have been working on lately–a raided German AA site. It looks a bit stylized because I’ve been playing around with filters for the final version’s loading screen.

news268

In other news, I did my first No-DVD crack for a game last week. Of course, I can’t give any more information about availability of the crack or what game it was for. But still, it’s a notably L33T personal achievement and a stepping stone in my learning assembler (or disassembler rather) through practical uses. Previously, I’ve already done a bug fix for a game in assembler and a mod for a game in pseudo-assembler. Besides a thorough disassembler (like IDA), I’ve learned the best tools are NOP (No Operation) and JMP (Jump) to either “comment out operations” or make conditional statements (various forms of Jump If) always or never take the jump. Even though I love this kind of reverse engineering programming/troubleshooting, sifting through millions of lines of assembler code takes a lot out of a person, and thus I don’t expect to be doing a lot of it in the near future.

Posted in Academics, Modding, Troubleshooting, Website | Tagged , , , | Leave a comment