(Ok, So not a Peter F. Hamilton novel – but it could have been, if he’d been a developer…)
Since the last post, I’ve been slaving away ‘refactoring’ – yes, that developer exercise of making huge sweeping changes to the codebase which ultimately do not produce any changes to the game itself.
However, they are important, fundamental changes (aren’t they always?).
To make use of the new Boid logic in Dom, I had to apply the principal of ‘Separation of Concerns’ to the Vessel code, as the Vessel logic was responsible for docking, flocking, travelling about, and generally ‘behaving’ as an NPC would. This was fine until now, but makes no sense when you need to start applying AI and behaviour control. A ‘Vessel’ doesn’t decide when to dock, or how to follow other flight members. The Pilot does that. (Or in your case, the player 😉 )
So it was time to move behavioural logic out of the Vessel code, and into the (so far fairly barebones) Pilot code. This meant transferring all the state machine logic, and all the logic the state machines depended on. That was the first step. Then rewiring everything so that NPC’s (and player) could dock/undock again and testing everything through once more.
That is a major improvement in it’s own right. Now the logically correct Pilot instructs the Vessel to obey it’s commands, using the Autopilot as it wants to do the grunt work of acutally flying (like docking, or following Waypoints).
The Player tells the Pilot what to do (though really, the Player is the Pilot).
This means I’ve fulfilled my goal of ensuring the Player and NPC’s have exactly the same control over a Vessel – there is no unfair ‘superpowers’ which an NPC can take advantage of to thwart the Player (and of course, vice versa 😉 ).
Once that was all up and running, I could introduce the Boid into Dom. I’ve added it as a ‘module’ to the Pilot, which it now uses to simply provide a desired heading, given all the behaviours it wants to apply to the Boid itself (i.e. cohesion, avoidance, tracking). Wiring this into the existing scene octree, this means Pilots can now steer their way around objects in the scene, and also chase down other objects, or flock around them. That bit, was a doddle. You can sense something is going to go awry can’t you?
Yep, the biggest challenge has turned out to be getting a thrust based flight model to play ball with the Boids ‘direct velocity’ flight model. The Boid is set up to constantly change velocity on a pin – instant and fast micro-changes. This is fine at low speeds, as it all looks lovely and responsive, and ‘feels like a flying combat’ game.
However, with momentum and thrust involved, the whole Boid flight model has to suffer the delays caused by flying rapidly in Direction A and then having to re-orient to Direction B and alter it’s velocity.
Now don’t get me wrong – the Boid model already deals with this. But, it doesn’t deal with Drive Systems, Inertial Compensators, Helm, Power Levels and so on. Which a Dom Vessel does have to, and so does the Pilot. So I have to adapt the output from the Boid (think of the Boid as a ‘plugin’) and then decide how to get the Vessel to do what the Boid is suggesting.
I’ve made a lot of headway with this now, and given that the Vessels are travelling an order of magnitude faster than the original Boid implementation it’s looking pretty darned good. However, somewhere along the way I’ve bust the Cohesion and Separation behaviours. Enabling these results in the flights breaking up and each pilot zooming off out of the scene on their own private agenda.
Anyway, all the above means I’ve now got a fairly powerful toolset for the NPC AI, and I can easily change it with new rules and behaviours. It also means I can generate a wide range of Pilots – with different traits for Species or Role types, and they all have access to the same abilities the Player has, provided they are equipped (allowed) to use them.
You may yet get to drop out of FTL in your tooled up Lancer MkIII to encounter a pirate faction of the Badian Hegemony and decide that maybe turning tail and fleeing is a good idea 😉
Comments are closed.