Post news RSS Enemies, ECS, and Modding

Hello everyone! As we continue to work towards our Alpha build, I am also overhauling the existing systems from the prototype to allow for all the cool stuff we talked about during the campaign - mostly with respect to the modding stretch goal, since a lot of this stuff was “hidden under the hood” in the prototype and thus not easily modifiable from the outside.

Posted by on

More specifically, I am currently focusing on enemies and the systems that govern their behaviour. As I briefly mentioned during the campaign, I am taking a “composition” approach to everything, which means enemies (and by extent their behaviour) are defined by which components are applied to them.

So putting a “flocking component” on an enemy makes it congregate towards its peers and behave like a flock, whereas a “path component” will make the enemy pick a target location and use the pathfinding system to figure out how to get there. A “shooter component" will give it the ability to discharge its gun on its current target, whereas a “melee component" will enable it to use a melee attack when applicable.

And so on…

This design also applies to how enemies are built, namely out of “body parts” just like every other character / NPC in the game.

And here is where the “entity / component / systems” approach really shines:

Since enemies, NPCs, and characters all share the same systems, enemies and NPCs instantly gain every “ability” that was created for player characters.

For example enemies / NPCs with a “legs” body part will seamlessly adapt their leg movement when strafing or walking backwards, or when locked onto a target - such as a guard shooting at you, or a companion following you around.

Taking this one step further, since weapons are technically body parts, and again there is a single system that handles entities with a “weapon component” - no matter whether this entity is a player or an enemy - this means enemies and NPCs can equip and fire the same weapons as the player! (remember that bit in the campaign about enemy guards picking up discarded weapons if they run out of ammo?)

Of course the opposite holds true as well, any weapon created for enemies (this might sound odd at first, but under the hood a mutant spitting fire at you still technically has a flamethrower equipped, even if it's invisible) can also be picked up and used by the player!

Not that it would always make sense - see the aforementioned invisible weapon - but things like a NPC with a unique weapon which you can only obtain by killing him and prying it from his cold, dead, hands is definitely a possibility :)

And this is how we end up with missile-launcher-wielding-slimes (mind you this will not necessarily be in the final game, but hey I had to test with *something* ^_^)

All of this is “free”, in the sense that it doesn’t require any additional code: all these systems work on literally any entity with the right components - and all of these components are available through the editor for you to use and abuse!

So anybody who wants to mod the final game should be able to create his / her own enemies, complete with custom weapons and behaviour - to the extent of mixing and matching existing options.

Or, you know, grab a toilet, attach a tommy-gun to it, slap the right components on, and create a flock of sentient bullet-spewing-crappers-from-hell that chase you down the levels.

Whatever tickles your fancy ^_^


Thr111 - - 96 comments

Its very impressive, I think everyone just doesn't know what to say about such a versatile engine.

Reply Good karma Bad karma+2 votes
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.