Game Development

Blog 820: Use the Tools Available

My bots in Exon have been annoying me for a while. They’ve been totally serviceable, they’ve just not been using the Energy Thrower — the ranged EMP stun gun that can be picked up in the Arena. They have been picking it up, just never using it. They’ve been charging with the Rocket Boosters. They’ve beem pinging away with the Shard Rifle and zapping with the Laser Rifle. But not the Energy Thrower. It’s a powerful piece of equipment! They should be using it!

Maybe one month before releasing the demo is a poor time to completely annihilate and rebuild your bots’ equipment/ability usage logic, but on the other hand, bots using their abilities against you is kinda the whole game. Also I put loads of effort into that electric stun effect, I want you to see it more often.

Use the Tools Available

So let’s go back to basics and try again. The old system was too convoluted anyway.

The requirement: bots need to use the equipment they have when engaging an opponent (picking up new equipment is a separate non-combat subsystem).

When I put it like that, sure, it sounds like nothing at all, but it’s actually pretty fundamental. The same logic actually functions for every unit in existence — whether that’s a Rust Mite wild animal with only a fake “mandible” melee weapon, or a guard with two rifles and and a rocket launcher you’ll be able to steal once you’ve destroyed it.

If a unit only has one ability, then there’s not much of a problem here. The movement logic tries to get it into a “comfortable” range (neither too close nor too far away), and if it’s facing the right direction then it’ll start shooting. But if a unit has more than one ability…

I’ve put in a decision point whenever that ability is “done”. That is, when one sword slash has finished, or when one bullet has been shot, and so on. The question of whether a unit can use two different abilities simultaneously is a bit difficult so we’ll come back to that.

There are limitations to the use of most abilities. Every ability is treated as firing forwards, so the unit (and/or its turret) must be facing its target. Every ability has a range, so the unit must be close enough to its target. Every ability has a cooldown, so the ability must be ready for use. Many abilities require ammunition or mana, so there must be ammo or mana available. Between all of these, the number of viable ability choices is actually quite limited at any given moment, so this choice isn’t as difficult as it seems (at least, for a human being to reason about).

For example, take the Rocket Charge boosters. When a target has just been spotted and you’re at long range, you’re in perfect position to charge. The boosters have a minimum range and a long cooldown, so in any given engagement it’s naturally only used once — the first use brings the target inside its minimum range, so it’s no longer worth looking at. Some other ability will be selected for use next.

Their aim with the Rocket Boosters is still delightfully spotty.

There are some spanners I’d like to throw into these works. Some bots might have multiple ability choices, but should prefer to use ranged weapons over melee weapons. This adds some more texture to Arena matches as every combatant is no longer slaved to an identical decision tree, and will determine whether guards and wild animals in the campaign close in or try to keep their distance. (There are some drones you have to chase down in the Gauntlet, tee hee.)

So I have the concept of a “main” ability. Before trying to work out if something fancier can be used, the bot will select its main ability. If the bot prefers melee, fine, leave it as the swords — but if the bot prefers ranged weapons (and has one, with ammo), it’ll take that instead. Once a main ability has been selected, the ensuing movement logic works off its range requirements to ensure the bot either keeps its distance or closes in. If the bot detects that it’s in range, and facing the right direction, it starts hammering its internal ability button, and might stop moving entirely now it’s in a good position.

Okay, fine, nobody got to use the Energy Thrower within sight in this test match, so I had to do it myself. (I heard the noises from off-screen though, so somebody else definitely DID use it.)

That works fairly well, give or take a thousand irritating little edge cases. If a bot has an Energy Thrower, it will use it in between sword strikes, then wait a few more strikes for it to cool down, then use it again, until it has no mana left. Perfect.

Next up comes the cleverer bots: the ones who should attempt to engage in melee combat but use other abilities while running around. For example, while Onyx is all about ranged weapons and will attempt to keep its distance, Adjantus prefers melee but will still pick up any other weapons he can find. So while Adjantus wants to be in your face, hacking at it with his sword, he also wants to be pumping that Shard Rifle on the way.

So I have a second ability-firing routine, which does not affect the bot’s pathing but does check facing and range and whatnot. So Adjantus’ movements are determined by his desire to be in your face, but while he’s approaching you, he’s probably facing you, and the Shard Rifle has a decent range, so he’ll just hold down the button while he runs over — just like a real player might. (Hint: this is a very good strategy, the Shard Rifle is possibly a touch imba.)

As you can see by the postive kill:death ratios, these changes have made the bots that are meant to be competent… actually competent.

This is where some difficulty-related squeamishness creeps in.

I don’t know about you, but there are only so many buttons I can hold down or click at the same time — it’s nice to have options but they’re not really meant to be used all at once. The fanciest mechs have five abilities: one primary melee attack and four pieces of equipment (Spin Attack is still off the books at the moment). The Arena starts you with two of those, a Sword (primary attack) and a Rocket Booster (first ability), and spawns two further pieces of equipment for the taking (rifles, second ability; Energy Thrower, third ability). There is no fourth ability item spawn, because when I tried to build a Redeemer I broke a load of stuff. Don’t worry, we’ll get there eventually.

Anyway, imagine the situation where a perfect machine with instantaneous reflexes is running at you and firing all of those abilities simultaneously; it’s simply not a fair fight, or rather, not an interesting or particularly fun fight. I’ve tried to put in a limiter so that most bots can only use “one ability at a time” — so when Adjantus finally gets in melee range, he will stop using that Shard Rifle and effectively “swap” his concentration to his sword and occasional blasts with an Energy Thrower if he has one. (There is also a small delay between usages of the main ability, such as sword strikes, to simulate the fallible human mistiming against their mech’s stamina meter.)

Characters that are meant to be more powerful, however, can and will unload everything they have as often as possible and have prefect reflexes… But there are fewer of those.

So I’m fairly happy that’s all mostly working again, and if nothing else, the bots are using the Energy Thrower now. Which means I’m stil on course for the demo to come out in December. Phew!

And you tell me...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.