Monthly Archive for September, 2009

SourceScript?

I’ve already told a few people on Steam about it, but now it’s official. I’ve picked up the SourceScript project again. For those who are not yet familiar with it, here’s a summary:

Most of you already know about the integration of Lua in the Half-Life 2 mod Garry’s Mod. What if you could use Lua to mod for other Source games instead of having to learn complicated languages like C++? SourceScript provides a server plugin to take care of just that. It’s aiming to enable Lua in all EP1 and Orange Box based games currently in the Steam Store.

The last time I talked about SourceScript I mentioned really simple hooks and a non-streamlined integration in the Source Dedicated Server. To start off, I’ve completely rewritten the whole thing, since I have a lot more experience with C++ now. Back then, I didn’t even know what the difference between a const char* and char* is. This will ensure a faster and more stable development process.

I’ve decided to first write all the event hooking code, perfect it and then work on the functions with which you respond to said events. It’s still all very rough, by which I mean it’s almost a perfect port of the C++ events, but here’s the implemented hooks:

RoundStart( TimeLimit, FragLimit, Objective )

RoundFreezeEnd()

RoundEnd( Winner, Reason, Message )

PlayerConnect( Nick, IPAddress )

PlayerDisconnect( Nick, UserID, SteamID, IPAddress )

PlayerInitialSpawn( UserID )

PlayerSpawn( UserID )

PlayerDeath( UserID, Attacker )

PlayerDamage( UserID, Attacker, Health, Armor, DmgHealth, DmgArmor, Hitgroup )

PlayerChangedTeam( UserID, Team, OldTeam, Disconnected )

PlayerPickedUpItem( UserID, Item )

PlayerFootstep( UserID )

PlayerJump( UserID ) <- Yes, GMod doesn’t have this!

PlayerShootWeapon( UserID, Weapon )

PlayerWeaponHit( UserID, x, y, z )

PlayerWeaponReload( UserID )

PlayerWeaponZoom( UserID )

PlayerBombPickup( UserID )

PlayerBombDropped( UserID )

PlayerBombBeginPlant( UserID, Site )

PlayerBombPlanted( UserID, Site, x, y )

PlayerBombBeginDefuse( UserID, HasKit )

PlayerBombDefused( UserID, Site )

ConVarChange( name, value )

As you can see, clearly the arguments of some hooks don’t make any sense, like PlayerBombBeginDefuse (What the fuck is up with that name) having a HasKit argument and PlayerBombDefused not. The only actually hooked Source Engine function so far is Msg, which is pretty useless since it does the same as print. When I’ve polished the hooks, I’m first doing global stuff like a server library with GetMap() and all that jazz, and then the entity commands like SetPos()/Ignite(). Polishing the hooks includes using a Vector object instead of X, Y and Z parameters.

Now that we’ve had the wall of text, let’s look at some more exciting (?) stuff. To start off, lua_run, just like in Garry’s Mod:

Also notice ‘Running script hooktest.lua’ at the top which is called from autoexec.cfg as:

lua_openscript hooktest.lua

Here’s a more interesting example:

Yes, it is a little lame, just showing the UserID, but it demonstrates how well the hook and lua_run system already work!

I’d love to hear any argument suggestions for the hooks I’ve shown here, however I’ll probably steal the arguments from Garry’s Mod where appropriate. I hope you guys are just as enthusiastic as I am, looking forward to the outcome of this thing. It might just become a great success and introduce a lot of new people to the great world of Source modding.

Other work and procedurally generated content

Aside from my known projects like Evolve and Motion Tracker, I’ve also worked on some other stuff lately. I’ll talk about the noteworthy ones in this post and then talk about my new area of interest: procedurally created content.

GMod Lua search

For those who don’t code Lua for Garry’s Mod, basically, the built in wiki search is seriously lacking. It doesn’t do bad at some things, but it sucks at searching methods, functions and hooks. To practice with PHP regular expressions and because I wanted to find these kind of things easier, I started developing what is now known as “GMod Lua Search”. Here’s a screenshot of its current layout:

Looks a lot better than the good sucky ol’ wiki search, doesn’t it? You can try it out yourself here!

CakePhysics or… Sandbox?

I wrote earlier about the fact I recoded parts of CakePhysics to work with the library SFML to allow cross-platform support. Well, I haven’t only changed the rendering engine, but I pretty much rewrote the whole ins and outs of the engine itself. Everything is now derived from a class called CGameElement which has a virtual Initialize, Update, Draw and Destroy method. Each game element, like the world and the HUD, can specify how many times it should be updated, manages its own loading and all that. This makes it all tons easier to manage. I haven’t ported the GUI yet, but I have made some changes.

To start off, I’ve changed the WIP name to Sandbox instead of CakePhysics. Users in the programming subforum were confused by the name and it didn’t make any sense anyway. I don’t know if Sandbox will be the final name, but at least it makes more sense than CakePhysics. Here’s a screenshot of the new version in action:

The first thing you probably noticed is the fact that there’s now an actual ground, apart from that there’s not really anything interesting to notice. More info on this project soon.

Procedurally generated content

Some of you probably already know what this is about. For those who don’t, read this neat little description from wikipedia:

Procedural generation is a widely used term in the production of media, indicating the possibility to create content on the fly rather than prior to distribution. This is often related to computer graphics applications and video game level design.

So, basically, instead of shipping textures with the game, they are generated with complex mathematical formulas on the fly. Inspired by this technique, I started looking for good applications of it and I found some pretty exciting ones:

As you can see this technique allows you to do things which are unfeasable with the classic content approach. While this technique has been applied for years, not many developers have used it extensively like in the examples above. The only well known commercial game featuring heavy use of it, is the infamous game Spore. If you want to see more examples of it, just search ‘procedural generation’ on Google or YouTube. For those who want to read more about this, here is a link to a set of blog posts about the creation of the 2nd demo from the top.

Forgive me for skipping another week, it’s really hard to gather interesting subjects to write about, while being occupied with school work and all that jazz.

Work in progress

Wow, it’s been almost a month without updates, I’m ashamed. From now on I’ll make sure to post a new entry every week. Why did I let this blog slowly die for almost a month, you ask? Well, recently school’s started for me again and I haven’t made much progress on my projects recently. This is the first time I actually feel that I have something to write about.

Evolve

I’ve been working on Evolve for a few months (I think) now, but I hadn’t expected people to actually use it on their servers already. Lately I’ve seen videos with Evolve in it, I heard of servers running it and the admins on my own build server seem to like it. This activity activated me to start working harder on new commands and the menu.

I just noticed that I had just finished the base framework for the menu in the last post, so here’s what it looks like now:

When you close the menu, it remembers the players you selected and you can cancel the chosen command now. As you can see I’ve also started working on a Sandbox tab which currently looks like this:

The sliders apply the new setting as soon as you stop holding down the slider or click it and it’s currently Super Admin and Owner only. A decision I can’t make by myself is where I’m going to place the toggles like noclip and godmode. Do you guys have any idea?

One last thing I’d like to talk about is the fact it looks a lot like the NewAdmin menu. This is completely intentional since NewAdmin’s GUI has proven to be a success, even though the other stuff… failed. Another interesting design choice is the fact that messages in the chat area, which indicate the actions executed by admins, do not have a prefix like [EV] or [Admin]. The reason for this is to make the admin mod seem more like a part of Garry’s Mod itself.

Let me end this with a dumb moment of me in the Lua forum:

Things like sbox_godmode and sbox_noclip will be in the Server tab, since they’re not Sandbox specific.

Motion Kit

Motion Kit is pretty much tweaking the replayer to make the replay look good at the moment. My first idea was to set the initial position, angle, velocity and angular velocity and then correct it when it’s too far off. This resulted in horrible teleportation-like and unrealistic movement.

Then I realized what the obvious replay technique is; Correct whenever we have data about position, angle, etc. This results in a lot more authentic and good looking movement since it has little chance to go the wrong way with about 30 frames per second of movement data.

Unfortunately I don’t have time to make a new video about it at the moment, but I’m sure you’ll find this a lot more satisfying: The actual addon itself in its current state:

http://motion-tracker.googlecode.com/svn/trunk/beta/

CakePhysics

I would like to post more about this, but I’m afraid it’s a dead project at the moment. But instead of writing my own graphics engine, I’m going with the SFML library which does the window management for me and uses OpenGL for the graphics, so CakePhysics will be released for Windows and Linux.

I hope you enjoyed this post and don’t forget to bug me if I haven’t wrote a new one next week!