Official development blog

Projectile Deflection

Ever since my first design docs from Cogmind pre-alpha, written back in 2013, I always wanted a projectile deflection mechanic. Like it doesn’t get much cooler than that, being able to swat away bullets or even send beams back at an attacker, or redirect them into other targets.

Every few years I think about the concept again, and it finds its way into my ongoing notes in yet another location in some slightly-altered form or alongside some other content idea, begging to be implemented. At the same time, being so cool it’s likely one of those rarer abilities that ends up more suited to unique parts, and even after ten years of development had yet to find a proper home on Tau Ceti IV.

One day several months ago I decided the wait had gone on long enough and this mechanic needed to happen now. Who cares if I didn’t even have a specific use case yet?

This marks the first time in Cogmind history that I implemented a new mechanic before actually having a spot for it in game--I had no idea what item(s) or robot(s) would make use of this feature. But I did know that we’re now in the Era of Cool Expansions outside the core game, so I’d find a place before long, and unfortunately around that time I also need a smaller project to tackle while getting my health back on track after repeated concussions (seriously annoying and a huge drag on development for much of this year). The opportunity was ripe to implement something fun and compartmentalized, as opposed to the grand projects I was supposed to be working on at the time which would take a lot more brain power.

Not Recommended

In gamedev it’s generally a Bad Idea to do this, building mechanics for your game that you aren’t ready to apply anywhere. Having one or more detailed use cases helps you think through your specific needs and acceptable limitations, otherwise when it comes time to use a generically-implemented feature for an unplanned use case, you may either find there are problems or insufficiencies and have to rewrite it, or eventually discover that you did too much work because you’re never going to actually use all those features or options you built in anyway :P

I already know I’ve built a system that’s probably more flexible than I’ll make use of, based on a lot of hypotheticals as opposed to real world scenarios, but at least it includes a set of features I do know I want.

The main other aspect to worry about when prematurely constructing any non-simple system is that when it comes time to use it and you find the system doesn’t quite fit your real world needs, you then have to go back to make adjustments, which can easily be more time consuming than it would have been if the initial implementation happened at the same time, given complete familiarity with the system at the time. It’s just potential for extra overhead, really, but dammit I wanted to see projectiles bouncing around!

Aside: This whole section strongly reminds me of those who design, build, and expand game engines without actually using them to make a game, though that’s on a different scale altogether.

Flexible Deflection

So I tried to cover all the bases by building a flexible implementation for projectile deflection, identifying tweakable parameters in order to hopefully support a range of fairly different items, of course all still centered around the idea of making sure projectiles hit something other than their intended target ;)

Among the main features of this system:

  • random deflection within a specified relative arc
  • deflection that always counterattacks the source
  • redirecting projectiles to target nearby hostiles
  • categorization of projectiles for deflection purposes, and the ability to specify a category to deflect, or deflect all of them

Architecturally, deflection of projectiles is somewhat related to the penetration and guided waypoint systems, which served as a good starting point for implementation. The main requirement is to be able to give the projectile a new trajectory at the right time and let it continue on its way.

On that note, it’s nice that there were actually multiple indirect benefits of building a deflection system, improving the game in other areas along the way, including addressing the longstanding issue of guided projectiles always treating weapon ranges from the original source, rather than by measuring the actual path traveled, enabling them to exceed their maximum range in some cases. It wasn’t too much of an issue, hence why I’d left it like that for years, but this also factors into play with deflected projectiles, so it was about time to do something about it--projectiles traveling along a non-straight path now measure cumulative range for accurate distance calculations:


Firing a guided projectile to the left here and reversing its direction will not reach the targets on the right, but if firing to the right they are all in range. Before this update, firing to the left and circling back around would still work. Not a useful tactical situation by any definition, just demonstrating the difference in action :)

Shiny Applications

So while I had no spot in Cogmind for deflection just yet, or any plans to even include it in the next release, the soonest I saw it appearing was with the Unchained, a deadly group of hostile unique derelicts working for MAIN.C.

And no doubt beyond that as well, since there are a good number of ways to use this new tech. When we think of deflection, the obvious use case is in defensive shield technology, but most any item is allowed to have deflective properties, meaning we must have an energy sword that can deflect incoming projectiles. Because duh.

Below are some recordings made while I was building the system. Note they’re all just test shots with fake items I was using to make sure everything works as expected, so don’t read anything into that aspect. These are also not usually very realistic scenarios, either, just having a bit of fun :)

projectile deflection demo

The very first system test, deflecting grenades back in the direction they came from within a 90-degree arc.


projectile deflection into enemies

Similarly deflecting incoming shots within an arc, but sending them back into an enemy within that arc. Cogmind is not firing a shot here, just passing turns :P


projectile shedding deflection

Deflecting kinetic projectiles backwards, like shedding them off to the side.


missile deflection into enemies

A 360-degree deflection capability redirecting an incoming missile at a nearby group of Swarmers.


projectile bouncing ring

Spectating a dangerous game of hot grenade with the local opposing Demo squads.


projectile deflection animation

The system also supports per-item animations and SFX for the deflection, seen here using a random placeholder to confirm that it works. (You can also see there deflection benefiting from the cumulative projectile range limitation feature, unlike the earlier shots before that was implemented.)


projectile deflection in combat log

Also yes, deflection is recorded in the all-important revamped combat log coming to the next version.

Well I can finally cross deflection off my list!

Funny enough, back when I first wrote about building this feature on Patreon, there really was no intent to add any deflection-related items to the next release, which is already packed with so much other stuff. Fast forward to a couple months later and there are already no less than three different such items xD

This is the fifth and final post in a series on new item mechanics. I didn’t cover anywhere near everything (or even the coolest mechanics because I don’t like to spoil much :P), but some of these also offer a chance for relevant discussion of the bigger picture:

This entry was posted in Mechanics and tagged . Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Only the anti-spam entry is required. See here for the privacy policy.

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>