As some of you know, i've been working on a mod called Half-Life Enhanced (no relation to the ModDB version).
So far it's been mostly code cleanup, documentation and bug fixes.
However, today i've added Angelscript scripting support to it.
It's just bare bones stuff at the moment, but the essentials are there. You can create map scripts and load them by specifying the script name in worldspawn's "Map Script" keyvalue, and use the exposed API for simple things.
At the moment it has core library features like strings, dictionaries and arrays, but also the scheduler and limited reflection support.
The library version is newer than Sven Co-op's, so there are some differences and bug fixes not available to them. Given the nature of the changes, i doubt they'll be upgrading their version any time soon.
As i said before, they can use the code i've written if they want to. It's well documented and has some good example code already, and is much more efficient than their existing implementation.
I've eliminated unnecessary memory allocations in wrapper classes, duplicate pointers and generalized some special case code, like hook execution. If they have the time and skill, they should upgrade to this.
I added it mostly to field test the new utility code i've been working on this week, but that doesn't mean it isn't already quite powerful. Once i've added the entity base class CBaseEntity you'll be able to manipulate any entity in the map, and once custom entities have been added, you can do even more.
If anybody's interested, here's the latest (debug) build: https://dl.dropboxusercontent.com/u/46048979/hlenhanced.rar
You can also check out the Github repository: https://github.com/SamVanheer/HLEnhanced
If you ever wanted to see how a scripting language could be implemented, this is a fairly well documented version. The starting point for Angelscript itself can be found in this file: https://github.com/SamVanheer/HLEnhanced/blob/master/game/shared/Angelscript/CHLASManager.cpp
The utility library i wrote handles most of the hard stuff, so you won't see much low level code in the actual game codebase. Its repository is under the same account, called AngelscriptUtils.
I'm still in the middle of cleaning up the SDK, so lots of stuff is subject to change. I can't promise that maps and scripts made for this will continue to work. Documentation will have to wait until i've finalized the code it's supposed to be documenting, so if it seems a bit barren, that's why.
There is a lot of work to do in this codebase, and scripting is only a small part of that. However, once it's done, it should provide you with enough customization support to do just about anything (within the engine's limits).
I'm planning to add support for custom player classes, so CBasePlayer instances specific to a map. The CBasePlayer interface would still be used, but you'd be able to add your own stuff, and solve problems that SC's version just couldn't allow for, like special case player model animations. If you want to add a set of animations to make players kick enemies, you'll be able to, as long as the player models have the animations.
Again, that code will probably need some cleaning up first, since it's hardcoded to a set of constants.
You'll also be able to create your own gamerules instances. Gamerules classes govern things like item respawn rules, player respawn delays and respawn spots. As with everything, it'll need cleanup.
Basically the idea is to be fully generic with low to zero overhead, with maximum customization.
Client side scripting is possible, but largely dependent on getting the list of scripts from the server to the client.
There is no 100% reliable way to do this that can't be used to break clients, but the new design it's using should make it easier than SC's version.
Since this version only loads 1 script, not many, and doesn't allow entities to load additional scripts, voiding the need to preprocess the map's entity data, it's as simple as sending the one script filename to clients.
I'm planning to convert this codebase to CMake at some point to allow for easier cross-platform compilation. The AngelscriptUtils repository uses it, and now that i've got the hang of it, it's relatively easy to take care of.
Note to anyone trying to compile this: i haven't committed all of the code it references. I'm using Source SDK code, which strictly speaking can't be used in any non-Source engine mod projects. Unless there's an exemption, or if it plain doesn't matter, i'll have to find another way to sort that out.
It's used by VGUI2 code, which i'm going to use to replace the UI. It has much better support for UI design, and since the engine provides support for it, i don't see why i shouldn't. It should also allow me to access UI elements defined in GameUI.dll, like the Options menu. Being able to get to that code would be a great advantage.
I'd love to hear any suggestions and/or feedback, but remember that i've got a lot of work on my plate already. This isn't the only project i'm working on, and i've got exams in August to worry about, so if i take some time to reply or get something done, that's why.