# Bughunting

Yes! YES!! OH GOD, YES!!!

I mean … uhm …

While browsing throught the E3 reports, I was moderately pleased to see the Aliens versus Predator series (of games, not movies) is getting another sequel.

I've always had a soft spot for xenomorphs. This extends to the Aliens versus Predator games that have been released on the PC. The first AVP came out in 1999 and I think this was one of the first PC games I ever bought. While not really as popular or as rich in storyline as, say, HalfLife, I still think it has many redeeming qualities even today. For example …

An Alien on the ceiling watching dinner walk by: I seeee you.

You can play as Human, Alien, or Predator, each with very different styles of play. This was pretty unique back then for FPSs. Actually, I think it still is. The Alien in particular was unusual: very quick, able to walk on walls and ceilings and a strange fish-eye lens point of view. It also had no ranged attack, which meant you had to get up close and personal to attack. Moreover, the alien did not have much in the way of hitpoints, which effectively meant that you had to not only get close, but get close undetected. You had to hide in dark corners and on ceilings waiting for people to walk by and then bite their heads off.

Most games will put you as the Hero Marine against bug-like critters to be slaughtered en-masse. This game gives you the opportunity to see what it looks like from the other side, which is definitely an educational experience. One thing that comes very clear, for example, is why fire and flamethrowers are not your friend. Bullets could often be avoided (except from turrets), but flamethrowers put up an entire wall of fire and one hit would keep burning for quite some time which, for creatures with few hitpoints, would fit nicely into the bad things category.

Playing against the aliens was also a different-than-usual experience. Able to hide anywhere (how many FPSs require you to check the ceilings?), nearly invisible against the background, fast and very, very deadly.

And … oh yeah! They bleed acid. Yeah.

They also had a very peculiar reaction to being shot: exploding and scattering themselves over a wide area. All while bleeding acid. If you remember your physics classes, you should be aware of this thing called inertia: things in motion will continue in the same direction. You know which direction the Aliens will usually be moving towards when you shoot them? You. You know in which direction all the parts and blood will be moving? You!

In other words: even when you kill them, there's a good chance they'll kill you right back.

 Acid rain. (click for details) Spliiiish. AKA AARRGH!GETITOFF!GETITOFF!GETITOFF!!!.

The game's also quite hard. I'd almost say Nintendo Hard. AVP 1 had no in-level saving. I don't think there's ever been a PC FPS that didn't allow you to save at will. Combined with the fact that the characters were realistically weak (a rocket jump, would only get parts of you to far-off distances or heights; on average you remain in the same spot), the lack of saving increased the tension considerably.

Of course a sizable group of gamers, cowardly pussies that they are, complained and eventually a save feature was added later. Shame, really; the levels are short enough for it to work, and it's actually way more fun to play when you're running for dear life.

And then there's the motion tracker. If you've seen the movie Aliens, you'll know what I'm talking about. Basically, it's a device that measures how deep the shit you're in is. If it emits a low bup, you're safe; if it starts giving off a high-pitched beep (or worse, multiple beeps), you're in trouble.

This truly is the stuff of nightmares. There's actually something worse than darkness: darkness and having a reminder that you're probably going to die in the next few steps if you're not careful. This feeling was enhanced by the night vision goggles which turn off the tracker. So now you only know where something was, roughly, and you have to find it again. The motion tracker is without a doubt the single most evil and mind-screwing feature ever put in a game. For those who want to argue in favor of, say, Resident Evil or Silent Hill or other horror games: No! You're wrong! It really is that simple.

On second thought, there is something worse. It's called a facehugger. The spiderlike critters from the Alien series that jump you from out of nowhere and basically rape your face. The game has those too. To show just how bad these are, here's a little anecdote about my first encounter with one.

#### Why facehuggers are evil

It's the third Marine mission: Invasion. You have to get to the top of the tower for a rescue. Up to this point I had done what I'd always done in an FPS: make slow but steady progress to avoid any nasty surprises. From this level onward that strategy doesn't work anymore. At all.

The reason for that is that now the aliens start to respawn at semi-random locations. So not only am I a puny hooman faced with very quick aliens that can come from out of nowhere trying to take my head off, now there's an endless supply of them too and only one of me. Oh and did I mention there's no save? Not that it'd matter because they'd spawn at a different location anyway, but still.

In any case, at some point you'd clue in to the fact that the only way this is gonna work is to just make a blind run for it and hope pray curse for the best. Amazingly, this worked out pretty well. That is, until I took an elevator down to face this:

An open Alien egg. Initialize panic mode.

An open Alien egg. And I could hear the pitter-patter of tiny feet down the corridor to the right, which also lit up on the tracker. When turning round the corner, the sound became louder. But still, I could not actually see the little bastard yet. “Well. Shit.” is something of an understatement at this point.

But then I hear something above me as well: an Alien was climbing down to the room in the image. “Well. Shit.” has now become completely inappropriate and I headed back to the elevator room to kill it. I basically sprayed the whole room with fire, hoping I'd catch it at some point. And I did. I continued to dance around to avoid it until it burst. And then all was quite again. I didn't even hear the face hugger moving around anymore in the distance. Thinking all was safe, I turned round to hunt down the face hugger again an…

SSSSSSSSSSKKKKKKKKKKKKKKRRRRREEEEEEE
EEEEEEEEEEEEEEEAAAAAAAAAAAAAARRRRRRR
RRRGGGGGGGHHHHHHHHHHHHHHWITHTHEHURTING
ANDTHEPAINANDTHEDYINGOHBLOODYFUCKINGHELL
WHATWASTHAT?!?!?!!!ELEVENTYONE!!?!!

Turns out the reason I didn't hear the facehugger anymore wasn't that I'd killed it or that it had moved too far away, but because it was already in mid-jump. Not only did it get me, it got me completely by surprise and the blood-curdling scream it emitted actually made me fall off my chair. Literally. It scared me so much that I actually leaped out of my chair. It took about a minute before I could even hold the mouse again because my hands were shaking so much. No game has ever had that strong of an effect before or since. This was just awful. And yet awesome at the same time.

Facehuggers are just plain evil. Just hearing one moving in the area is enough to give me hives.

The only really bad thing about the game is that it won't play on current computers – some graphics and sound glitches that made crashed the game or made it unplayable. However, this has actually been remedied recently. People have been tinkering with the source code and fixed the most important issues. See forumplanet.gamespy.com/tech_support/b49029/1049364 for details and links to patches.

Compared to AVP 1, its sequel was, well, ultimately something of a let-down. It's still good playing, but I felt that it could have been so much more. Sure, it had better graphics. Well, more detailed models and textures anyway; unfortunately, the textures also looked really coarse and flat, and decals would often seem to be placed over the polygons, rather than on it, which just looked awful. AVP 1 had destructable light sources – something the Alien could make use of very well – but AVP 2 didn't. It also did not have adjustable gamma settings, which really hurt because often I literally could not see anything. And they took out the cheat modes and skirmish *sigh*.

The Aliens had also changed in some very bad ways. In the original, they were fast and furious, but in AVP 2 it often seemed thay they were just hobbling along on their way too skinny legs. Instead of looking like the vicious and fast killing machines, they came off more as clumsy puppies. Okay, yes, puppies with really sharp claws and teeth, but not the terrors they're supposed to be.

They also didn't explode into parts with that delightful crackling sound anymore, or bleed over everything (mostly you). Mostly they just flopped down. Also, there seemed to be only one or two death poses and I think only a single animation timer for all critters. Often you'd find yourself in a field of dead aliens which lay down in exactly the same way. I know it doesn't sound like a big deal, but little things like this can spoil the mood completely. Worst of all though was what they did with the facehuggers: they took away the scream when they kill you. This completely removed the scare factor :(

Having said that, it also did some things very right. There was one interconnected story line, with the threads of the three playmodes intersecting at several instances. Very nicely done. Also, as the Alien you actually played through the facehugger and chestburster stages. This was also fun.

 Ugly texturing (click for details). Synchonized dying. Chestburster finding its way out. Intersecting story line - Alien. Intersecting story line - Marine. Intersecting story line - Predator.

And now there's gonna be a third installment. Like in AVP 2, there will be an interwoven story, so that's good. From the pictures I've seen, the graphics are going to be awesome. Textures are crips, motion looks fluid – it just looks right again. It also looks like it's not going to be for the faint of heart, with lovely gratuitous displays of blood and guts and trophy-taking and everything (see here for video).

I was somewhat surprised to see Sega as the publisher for the game. It seemed a little odd at first, but if you take into account that they're a bunch of fucking sadists, I think it is actually quite fitting.

So yeah, I'm looking forward to this one.

# new and improved geshi

With Tonc I pretty much did all the syntax highlighting of code manually. As you might expect, this experience was – well, the proper description is something not suitable for anyone under the age of several thousand, so let's keep it at “somewhat less than pleasant”. So the first thing I looked when starting this whole blogging gig for was something that could do that automatically. In my case, that was codesnippet, which was build on the very awesome Geshi. There were some small problems with number formatting and whitespace handling, but overall it's served me well.

The Geshi that came with it was … 1.0.7.20, I think. In any case, Geshi's is now at 1.0.8.3, so I figured it was time for an upgrade. Most notable was that the way numbers were parsed has been greatly modified, with different types of representations now being parsed separately – and correctly to boot. Right now, it's almost fully correct, as you can see from the list below:

// Regular int
123
123l
123L
123ll       // fail
123LL       // fail
123u        // fail
123U        // fail
+123
-123

// Octal
0123

// Hex
0x12
0x123
0x123.4

// Float
123.4
123.4f
123.4F
+123.4
-123.4
1.2e3
1.2E3
1.2e+3
1.2e-3

// Inner
(1.23)
abc123de

Only some of the more special integer literals aren't parsed correctly, specifically the unsigned (-U) and long long (-LL) suffixes aren't accepted. I don't suppose hex floats will work either, but that's a GCC extension anyway.

To fix this, you need to modify geshi a little; specifically the GESHI_NUMBER_INT_CSTYLE regular expression:

GESHI_NUMBER_INT_CSTYLE =>
'(?<![0-9a-z_\.%])(?<![\d\.]e[+\-])([1-9]\d*?|0)l(?![0-9a-z\.])',

… yeah. I'm not sure why it's formulated like that either. I'd have thought '\b' would have worked just as well, but alright. Anyway, notice the single 'l' character in there? That needs to be extended to something that matches a potential single 'u', possibly followed by one or two 'l's. In other words: 'u?l{0,2}'.

GESHI_NUMBER_INT_CSTYLE =>
'(?<![0-9a-z_\.%])(?<![\d\.]e[+\-])([1-9]\d*?|0)\<b\>u?l{0,2}\</b\>(?![0-9a-z\.])',

#### HTML in code

An astute readed may have noted the bold in the previous snippet. Normally, you can't do that in Geshi.. One of the things that Geshi does is translate HTML entities like '<' into things like "&lt;" so that it'll turn up right on the resulting page. This, of course, is one of the things Geshi is expected to do. However, in this case it also makes it impossible to add HTML parts in the code snippet, which at times can be very useful.

So what do we do now? Well, we can use escaped HTML tags. Much like "\n" doesn't actually mean backslash + 'n' but a newline character, "\<" can be used for the actual '<'. And to unescape that, a double backslash can be used, much like it is in C.

\\<b\\>BOLD\\</b\\>    becomes     \<b\>BOLD\</b\>

There are several ways to implement this. One would be to modify it in the geshi code. I haven't tried that route yet because I expect it could get messy. That's arguably how it should be done, but it's easier to do it after the fact: when all the conversions have been done. Basically, you need something like this:

// Initialize geshi with the text to convert and language file to use.
$geshi = new GeSHi($text, $lang,$this->geshi_path);

// This does the actual work.
$text=$geshi->parse_code();

// Replace (un)escaped html entities.
$text= str_replace( array( // Normal entities '\\\&lt;', '\\\&gt;', '\\\&amp;', // In-string escapes get crap added, gaddammittohell >_<. '<span class="es0"><</span>', '<span class="es0">></span>', '<span class="es0">&</span>', // Unescaped entities '\\\&', '\\\<', '\\\>'), array( '<' , '>' , '&', // Normal entities '<' , '>' , '&', // In-string entities. '\\\&amp;', '\\\&lt;', '\\\&gt;' // Unescaped entities ),$text);

There are three sets of items to search & replace here. The first two are the basic escaped tag delimiters, so that they'll actually result in HTML tags, and unescaped delimiters, so that you can print the combination itself. The third category are for HTML in string literals. Since the backslash has a specific meaning there as well, Geshi puts some highlighting stuff around it that would make the standard search fail. So that whole thing would need to be searched for and destroyedreplaced.

It's ugly, I know, but it seems to work. It'd be nicer if this could be done in the parser itself, but I have a feeling that'd take changes in multiple places. Since I don't know the code that well yet, I'm not touching that one with a ten-foot pole.

Lastly, let's test the ARM asm highlighter:

// Regular int
123
123l
123L
123ll
123LL
123u
123U
+123
-123

// Binary
0b01100110
0B10101010

// Octal
0123

// Hex
0x12
0x123
0x123.4

// Float
123.4
123.4f
123.4F
+123.4
-123.4
1.2e3
1.2E3
1.2e+3
1.2e-3

// Inner
(1.23)
abc123de

Still works too. Bitchin'.