As promised, I am doing things. I am, in fact, doing some very wacky things. The engine that makes these things possible is Valve’s Source Engine.
Freely distributed engines are a wonderful thing. They allow you to quickly prototype ideas without having to worry about all the underlying details; for example, how do I figure out what’s in front of my character? How can I limit what the player sees, in an efficient manner? Why the hell is OpenGL so complicated!?
In short, writing an engine is hard. Often, writing an engine will get in the way of designing your game. Of course, the two are not exclusive; often, you’re going to have some cool game mechanic that no one else has thought of, and you’ve got to write your own game engine or extensively modify someone else’s to get that to work. No getting around that. However, I have to come to grips with something that all designers, maybe all engineers, have struggled with since the beginning of time: it is much easier to come up with ideas than it is to implement (program) them.
Alright, that may seem obvious. Like I said, it’s something pretty much everyone knows, but what I’ve really been doing, what all of my projects are; they really aren’t designing anything. They are all about programming game engines, which is not what I wanted to do when I started them. There are myriad reasons to program an engine, of course, even one that does what’s been done before; I wouldn’t be me without the urge to figure out how, for example, that 3D stuff is actually done under the hood, and I’ve dabbled in a bit before. But right now, what I really want to do is make something. I want to design something.
I suppose you could argue that I was designing engines. However, there was nothing really new in them. I could have picked up any old 2D game maker and made JAGS. I could have picked up a rendering engine from somebody before implementing my terrain generator. There were no real new ideas in there, no game mechanics, nothing really new and inspired. Wiki World might be somewhat of an exception, and I’m hoping I can come back to work on that project someday, but I got tired of working in Javascript (which we might come back to in a later article).
Well, anyway, enough of my moping about. After watching this video, I got somewhat inspired (talk actually starts at around 2:34):
Thank you, Chet Faliszek, for that swift kick in the butt. If you didn’t watch the video, the overarching message is to start making stuff. Don’t wait. Start now, and actually finish it. That finished product will speak to employers more than anything on your resume.
Alright, so let’s start. After watching the video, I browsed around for engines to start with. I didn’t want to start with SDL again, since that’s a bit too low level for what I wanted to do. There was one student-made OpenGL engine that I can’t seem to find anymore, but it didn’t have a download link. After a while, I smacked myself in the head; why not use Valve’s own engine, the Source Engine?
I’ve worked in the Source Engine before, back in high school. My friend and I made a small game in it for AP English (it was for a project on Slaugherhouse 5). I’m familiar with a bit of the codebase, I know how to use the Hammer editor, and I’ve gotten some animations exported from Blender into it, so why not? Best of all, it’s in my best language: C++.
Now, you’re probably scratching your head and saying: “I thought you wanted to get away from programming?” Well, not entirely. I’m still a computer scientist at heart, not an architect or anything else. I’m rubbish at designing environments in Hammer and terrible at modelling in Blender, so I’ve got to stick with something I know how to do. The difference here is I’m modifying an existing engine, giving me more time to actually do cool things rather than finding and fixing problems such as wondering if the problem with bullets not showing up lies in what I just programmed, or my image filetype, or something I did months back when I made the engine.
First impressions: it gives me an error when I try to create a mod. A quick lookup says that, for some reason, you cannot create mods for Source 2009. Well, Valve Time, we meet again. So, I create a Source 2007 mod instead. It dumped a bunch of files and folders into C:/wat, as expected, which took a while. In the meantime, I installed Visual Studio 2010 and VsVim (this summer made me a vim convert, at least for programming). Finally, after everything was done, I opened up the source code.
Holy crap, there are a lot of files in there. I mean tons. Of course, I expected there’d be a lot - this is a big game, after all - but really, I never appreciated how much manpower goes into an engine like this. Working in a team like that, collaborating on a project like this - that’s my dream job, right there.
Right, enough fantasizing. I need to get to designing things. First thing’s first, though - we need to get this code compiled. Following this guide made compiling fairly easy… after reading the “discussion” page (tab at the top of the screen). A few important things are in there, like “make sure you run the game once” and “set the server project as a dependency of the client”.
Wait, but now I’ve got a Steam error. More investigation ensues until I find out that no game is a Source 2007 game anymore. I’m trying to modify something thatdoesn’t exist. All games have, in fact, been converted to Source 2009 games. Which you can’t create mods of.
Argh. More investigation. Ok, so I’ve got to switch the base game to Source SDK base 2007. Why, Valve, why? I switched to your engine to make things easier, not harder!
At least after doing that, I got the project compiled, and it presented me with the Lost Coast menu (the default for the SDKs). Nice. Time to start modifying some stuff. This article tells me about a bunch of stuff I mostly already know about, like source control and stepping through code, but it’s a neat little introduction to the codebase. It has you modifying the speed of the RPG rocket, and all you have to do is modify one little #define. I do that, and… wow! That rocket really is moving slower! I’m not being sarcastic, that change is really awesome.
You’ve got to understand; yes, the change is a bit underwhelming. This is the difference, though, in what I was talking about earlier; one little change in the code results in a real, tangible change in the way the game works. It’s an awesome feeling.
Ok, well, after firing a couple rockets, it got unexciting. What if we make the RPG shoot a banana? After fiddling around with Blender, UV texutring, Paint.net, and some smd exporter tools, here’s what I came up with:
Yes, that is a banana being launched out of a rocket launcher. The smoke trail and the ignition are still there (the picture was taken when the rocket/banana is yet to ignite), so I’m working on taking that out. All I really had to change in the code were a few strings referencing the rocket model.
This was a nice little experiment in getting things done. I’m going to try to continue on this line of thought and make some more absurd things in the source engine. At some point, I’ll post the code and the finished product here, on my blog - it’ll probably go into scraps, since this isn’t a project in full. I still have yet to see if I have time to dedicate to a project, since the school year is back in swing…