I'm a student in computer sciences, I've been coding in C++ for about 6 years now, and I'm familiar with elementary design patterns. I've also coded in Java, C#, vb, vbs, lua, php, xhtml/css and a few others. I can make 3d models, textures, drawings, sounds, web stuff. However, those aren't my forte. I'm experienced with modding for the source engine mostly. I'm currently working on a starfox based mod for the source engine. And as soon as all my planning and design docs are done, it'll go public.

Report RSS The joys of the Alien Swarm SDK

Posted by on

Hi there, I think I'll try to write a development blog, so I can rant about stuff :)

So for my first post I'll talk about the my experience at trying to turn Alien Swarm back into a 1st/3rd person game.

The Goods and the Bads :
As you may know, alien swarm is pretty much an RTS really. The marines you control are actually "npcs" that receive player input. The player is not doing much beside being a floating camera following the active marine. This system is fine for ASW since you can control more than one marine in the same game, and rapidly switch between each of them. The main disadvantage is that its a big complex system built through the usual structure of the source engine. Its also fairly costly in resources( compared to the typical source player ). And it wasn't pulled off very cleanly, with tons of references directly to the marines npcs, even to their private members variables. Personally if I'd redo it, I'd have encapsulated all the marine stuff in the player, and worked a proper abstraction for the npcs that you control.
Anyways, for a mod in which you'll be pretty much controlling only one character the whole time, it looses the few advantages it got. First, most of the code and help around the community assumes you're working on the typical source player, not on the marine npc. Second, first person view models, and source vehicles would need some work before they'd work properly with the marines. The jeep that comes in the ASW SDK doesn't count, since the whole thing was meant to run client side....

The conversion back to an HL like player :
I've actually tackled the problem from two angles:

First, the quick way, I just sabotaged the whole marine system, throwing NULL each time something would request the current marine from my player. And I also easily modified the spawning code so that it wouldn't try to spawn marines, and would actually spawn the player at the right place. Now this is a very naive approach in the sense that you have to be sure the devs are actually validating the marine data, and kept the alternative that there are no marines in mind. Hopefully, they did :D So if you want to do a very quick rough conversion, you may want to try this.
But keep in mind that not much will work properly without tweaking, the camera, the hud, the animations, the weapons, etc.. They all can't work without some tweaks, but most imply deleting the method overrides the asw classes made to the base source classes. Like for the camera, and button input, in CASWInput, just remove or modify appropriately all overrides of the base class's functions and the camera and input will work like a regular source game. However going the destructive way may sacrifice features like the deathcam and such.

The second way, is a big undertaking. It basically involve, deleting asw_marine.h, asw_marine.cpp, c_asw_marine.h, and c_asw_marine.cpp. Then you try rebuilding, and fix all the 6 000 errors that will popup. This has the advantage of not leaving anything interfering with the player, at least it shouldn't. And also it won't leave you wondering why npcs don't attack the player, because you'll see that the player is set to be invisible to npcs, and that npcs seek marines. :)

I tried both, the first one first, then the second. And I think I'll stick with the second, since it will be more thorough and less of a patch job. Plus in the end, you'll probably spend the same time tweaking the whole thing.

The result so far :

Here a vid of what I managed to do with the first option I tried, since I'm not done with the second yet :) As you can see, having previous knowledge of the hlmp animstate system helps, because I don't and I've got the system messed up somehow... :/
The asw weapons can be fixed for player use, since they're base on CBaseWeapon, but they re-routed lots of functions so the marines could use them. I won't go too much into detail on this since, I'm still learning how it works.

*EDIT* : Suggestions as to how to make the anims working would be very welcome. :)

*EDIT2* : I got a solution from the sdk help forums from a guy called Sandern. Basically, I only needed to add "m_flCycle" and "m_nSequence" to the prediction table.
Its pretty weird though that it needed prediction, since those two vars aren't being sent from the server at all, since they were excluded in the asw player send table... Oh well.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: