G-Engine #1: Introduction

I’ve always wanted to write a game engine. But building a game engine without a game can be difficult to do! The needs of the game drive the engine’s features. Plus, without art assets, how do you show off the engine’s features?

To get around this problem, I thought it’d be cool to build a game engine that’s capable of running a game that I played when I was in my teens: Gabriel Knight 3: Blood of the Sacred, Blood of the Damned. In late 2017, I took the dive and started working on it!

This post (and those following it) document my progress. In this introductory post, I’ll explain what Gabriel Knight is, why I’m excited about it, and what I hope to accomplish.

The Gabriel Knight Series

Sierra On-Line (later Sierra Studios) released the Gabriel Knight series of point-and-click adventure games from 1993 to 1999. In the late 80s and early 90s, Sierra was a PC game developer most well known for their popular and iconic “Quest” adventure games, such as King’s Quest, Space Quest, and Police Quest.

Sierra Logo

Sierra adventure games had (and still have) a passionate fanbase. They were known for their characters, storytelling, humor, and charm. They were also notorious for their high levels of difficulty, tough puzzles, and gruesome (but funny) deaths if you lead your character astray.

Gabriel Knight is not Sierra’s most iconic series, but it certainly represents some of their best output as a developer. In almost every aspect - character development, storytelling, puzzle quality, graphics, music, innovation - they are some of the highest quality adventure games ever made. Ok, so the third entry may have one or two unfortunate puzzles, but overall it’s all quite enjoyable!

Let’s quickly recap the three games in the series and the context in which they were developed.

Gabriel Knight: Sins of the Fathers (1993)

In the early 90s, Sierra was one of the biggest and most influential developers in the games industry. Sins of the Fathers was one of the last Sierra games made in their “classic” 2D style, and their mastery of the format shows in this critically acclaimed murder-mystery adventure.

GK1 Gameplay

The game follows a struggling author named (wait for it…) Gabriel Knight as he researches a new Voodoo-inspired mystery novel in New Orleans. However, his research eventually puts him in harms way, entangling him in a series of ritualistic murders, a criminal underworld, and his own family’s surprising history (in other words…the sins of his fathers). His assistant, Grace, becomes an unwilling accomplice, while his friend Detective Mosely provides insider info about the murders.

This first entry establishes a hallmark of the series: the blending of real-world locations, events, and facts with supernatural/horror fiction. The backdrop of New Orleans, Voodoo, and the slave trade heighten a compelling story of good vs. evil, ancient Voodoo curses, and grisly murder mystery.

Gabriel Knight: The Beast Within (1995)

When the second game entered production, industry trends were being heavily influenced by the sudden availability of CD-ROM drives with multimedia capabilities, including video playback. Games like Myst and The 7th Guest became huge hits with their realistic graphics and live actors. During this time, many adventure games shifted to using live actors and video playback to tell their stories, rather than hand-painted graphics, believing this would enhance the experience - such games were referred to as FMV (Full Motion Video) games.

The Beast Within is often cited as one of the best, if not THE best, FMV adventure games. Many FMV games suffered from poor game design, a lack of interactivity (too many cutscenes!), poor acting, and low production value. The Beast Within manages to avoid most of these issues to deliver a compelling experience.

After the events of the first game, Gabriel has decided to take on his family mantle of “Shadow Hunter” and move to the family castle in Germany. He faces his first case, and an opportunity to prove himself, when he’s hired to investigate a string of “mutilation killings” in Munich, ostensibly caused by escaped zoo wolves, though his client believes it may be werewolves. As Gabe and Grace investigate, this initially outlandish claim seems less and less ridiculous. Gabe’s investigation leads him to a secretivie hunting society with some very dark secrets, and Grace discovers similar events in Germany’s past that may provide answers to solve this case.

In this entry, the live actor performance are obviously quite different from the hand-drawn backgrounds and pixel art of the first game. Players also have the ability to play as Grace during certain chapters. As before, real-world locations and German history are used to build a compelling supernatural mystery. A fictional “secret” history of King Ludwig, Richard Wagner, and the myths and legends surrounding werewolves are used to spin a tale of primal instinct and fighting to stay human.

Gabriel Knight 3: Blood of the Sacred, Blood of the Damned (1999)

Around 1996, the FMV fad dissipated and people realized it was actually generally not that great! The future of adventure games felt uncertain. Frenetic 3D shooters like Doom, Quake, Unreal, and Half-Life dominated the market. Many gamers felt that adventure games were antiquated and tedious. A litmus test at the time was the release of Grim Fandango, which received good reviews, but poor sales.

With the seemingly waning interest in adventure games came huge changes at Sierra: the owners retired and sold the company, employees were laid off, and games were canceled. Anticipated titles like Space Quest 7 were canceled. Other titles (like King’s Quest 8) released, but tried to appeal to the growing first-person shooter and action markets.

As all this was happening, Blood of the Sacred, Blood of the Damned was in development. Despite the turbulent atmosphere surrounding its development, the game somehow released, it was critically well received, and it stayed true to the series and its point-and-click adventure game roots.

Staying with the times, GK3 moves the series from 2D to 3D. As an early 3D game, the graphics are somewhat primitive, but they have a certain amount of late-90s nostalgic charm. The game is also notable for the amount of expressiveness they eek out of facial features with relatively primitive 3D technology.

GK3 Gameplay

The game was innovative in its attempt to translate the 2D point-and-click adventure experience to 3D. The control system is rather novel: the player controls a first-person camera independently of the main character. Clicking on objects in the world “instructs” the character to move to that location or interact with an object. As a result, the game acts somewhat as a third-person/first-person point-and-click hybrid.

In this game, Gabriel and Grace are hired by a Scottish royal family to protect their infant child from kidnappers and other attackers. Though a seemingly odd request at first, members of the family have been attacked before, with odd markings appearing on their necks. Sure enough, Gabe and Grace are taken unawares one night, and the child is kidnapped. The duo pursues the culprits to a small French town called Rennes-le-Chateau. A tour group visiting the area hosts a number of colorful individuals - some are suspicious, all are suspects. Several years before The Da Vinci Code became a best-selling novel, this game scratched the surface of that very same historical mystery, filled with religious symbolism, riddles, and conspiracies.

By the way, the game ends on a bit of a cliffhanger…kind of tragic for a game that never got a sequel!

A Hidden Puzzle

Anyway, enough backstory! What does this have to do with engine development!?

GK3 contains an in-game console that can be activated by pressing Shift + Tab + ~. I knew about this because this was also the way that you’d enable certain easter eggs and cheat codes.

But the console is primarily a game development tool. If you type Extract() into the console, a file named !!!README.TXT would quietly appear in the game’s installation folder. It begins as follows:

GK3 is a data-driven game, meaning that very little of it is hard coded, requiring changes to the EXE. The majority of its scenes are completely run by scripts and configuration files. For the player, this means that much of GK3 can be customized or even rewritten… Interested?

The readme also specifies other Extract() commands you could use to extract technical and design documents that were bundled with the game. It appears the developers hoped that industrious players might modify the game in various ways.

As a teenager aspiring to make video games, I thought this was extremely cool - a hidden message straight from the game developers! And internal design and tech docs!? I thought it would be fun to do some modding, but I didn’t have the technical know-how to make any progress at the time.

In 2000, Gamasutra published a postmortem of the game’s development, written by an engineer on the project, Scott Bilas - the same guy who wrote the readme! It’s a pretty interesting read from a technical perspective, but also to get a sense of the trials and tribulations surrounding the game’s release.

A Puzzle Revisited

18 years later, after college and shipping a few games, my technical know-how has increased substantially. Maybe I have a chance to actually mod something now? Occasionally, I’d think back to GK3’s “hidden puzzle.” Could GK3 be modded? Would anyone even be interested in that?

GK3’s engine is a bit outdated these days. The game only runs on Windows. The max resolution is fairly low. The game also has some technical problems on newer machines: failure to start if no CD drive is present, graphical artifacts if you minimize and maximize the game window, issues playing video files, and sometimes it just crashes! A recent playthrough required me to skip most in-game movies and watch them on YouTube because the game would crash if you tried to watch videos in-engine.

I am also now looking to build a game engine, primarily as a learning exercise. What if, rather than modding the game, I were to rewrite the engine entirely, and only reuse the data assets? Theoretically, I could create a modern, cross-platform engine that can read and interpret the same data files the original game used. Now THAT’S a compelling goal to drive engine development! Plus, all the art, SFX, and game design are already done - a programmer’s dream, really.

Since GK3 is heavily data-driven, most of the game’s logic is not compiled into the machine code in the EXE - it’s instead encoded in various assets bundled with the game. The engine itself loads and interprets those assets to create and drive the gameplay.

Some assets are the obvious types: textures, 3D meshes, and audio files. Others, however, are more interesting: the game’s scene data is stored in “Scene Initialization” files, the interaction data is stored in “Noun/Verb/Case” files, and the game’s actual logic is mostly stored in “Sheep” scripting files. Much of this data is stored in plain text, making it easily human-readable. Some is in binary, but still usable if you can reverse engineer the file format.

My initial goal is to recreate the original game using a new engine. From there, there are a lot of cool things that could be done. I could add support for more platforms. I could add support for new features, such as better lighting or higher resolution. I could add support for new asset types, or replace existing assets with higher-fidelity ones. It would even be possible to create entirely new gameplay using some of the asset formats originally created for GK3.


My primary motivation is to learn. By writing a 3D game engine from scratch, I will surely learn a lot more than I currently know about 3D math, graphics APIs, C++, and game engine architecture. For this reason, I’ll be focusing a lot of attention on understanding how things are working. For example, I’d rather write a math library than use a pre-existing one.

My secondary motivation is to do something cool and interesting with a game I’ve enjoyed over the years!

What About You, Dear Reader?

My plan is to chronicle my trials and tribulations on this blog! With any luck, those posts will provide some guidance and insight into topics of interest to a game engine programmer or someone interested in the technical details of a game like GK3.

I’m posting this in October of 2018, and I’ve been working on the engine for about 10 months already. But I will be going back and writing some posts about the work that I’ve already done up to this point.

comments powered by Disqus