Game Design, Programming and running a one-man games business…

Range Modifiers

This is something I really like, and comes in reply to feedback about how people hate having to guess what the underlying numbers are in tower defense games. I got it implemented today *still needs optimising…*. It’s a way to show easily the effects of a range boost augmentation for a unit. The units in GTB are built from GSB-style modules but some are ‘augmentations’ that apply to any module, such as ‘boost range by 10%’. I thought it might be cool, if such an aug is fitted, to show it as a distinct band on the range indicator when you select a unit. It’s the slightly separated strip around the edge of the range indicator for the selected riflemen.

The brighter triangle represents the firing field-of-view for that soldier. Some units have 360, like mechs, but infantry can’t swivel their hips like that :D

Thoughts?

Programming AI in a tower defense game

This is not an easy task. It is for most Tower Defense games, because they are simply scripted. The level has a set number of enemies of certain types and times, and they appear as attackers. And of course, most TD games don’t let you play as the attacker, so programming the defense AI is not needed. I need both of these to be non-scripted for Gratuitous Tank Battles.

I need attacking AI that ideally adapts mid battle to your decisions, and this is harder than it sounds. The first approach I took was to have a system with 3 types of placement timing mode (steady placement, or hoard points for a big attack or spam the current unit) and two types of unit selection (random, and select the one that has been most effective so far…with some variation).

The AI would switch randomly between these combinations and it looked pretty convincing. Sudden waves of identical units followed up by who-knows what. The problem was, it obviously did so with little care as to what it was up against.The ‘most effective unit’ code was good, because it meant totally useless designs which charged into a hail of bullets would not see much repeat business, but something major was lacking. That was the anticipating of future events.

If the defender has placed 6 machine-gun turrets (rubbish, but devastating to infantry) you shouldn’t place down infantry, regardless how well they did earlier in the battle. If they have lots of laser turrets, place down shielded units to get past them…etc.

So today, at the end of a long day of video rendering and editing, and tweaking, and bug fixing, I’m starting work on a more generic system for opponent army composition analysis, that can take snapshots of the enemy forces and realise that its 63.2% anti-shield units, and thus we should de-prioritise shielded unit selection etc.

This is annoying, fiddly, long winded code that nobody will ever see, as such, but will make Gratuitous Tank Battles a convincing challenge, which is well worth spending time on.

Working on tweaking the mechanics

It’s easy to get caught up with features, graphics, optimising and going through a checklist of items to do when you work on a game, and not set aside time to keep fiddling with the mechanics. There are an absolute ton of variations to the mechanics of any game. The only real way you know if the mechanics are right, is by trial and error.

If you wonder what the hell I’m on about with ‘game mechanics’, it’s basically the rules and systems by which the game is played. For example, in chess, the pieces all move in different ways. Some can only move forwards, some can only move 1 square at a time… None of the chess mechanics are obvious. Imagine designing it from scratch. We take for granted the idea of a knight moving over other units, or castleing, or units like bishops having infinite ‘range’, but none of them is ‘obvious’.

Right now, my bugbear is support units. GTB has repair trucks and ambulances for attackers, hospitals and repair yards for defenders. My current mechanic is this:

The support units pulse out ‘waves’ of effect at a certain interval and radius. Any damaged vehicle (repair) or soldier (hospital) within that radius at the time gets X of their health replaced.


Look! Neither side is bothering with hospitals or repair units…

This seems ineffective, and there is little real incentive to use these units. I might have just set the costs for them too high or the effect too small, but in fact i think it’s more fundamental. By the time people are losing health, they are a lost cause, and the interval between lost health and death is too slow to enable a health pulse to really do much good.

Possible solutions:

  • Ultra-rapid health pulses to ensure timing not an issue,
  • Reduce armor and shields and increase health of all units
  • Make support units dirt cheap so they are worth it anyway
  • Allow recently destroyed / killed units to be revived by the pulses.
  • Change the mechanic entirely so that the units don’t use pulses, but act as damage modifiers to protect everyone within their radius, effectively making them mobile buffs.

I’m planning on trying out the last option. It involves a lot of fiddly code, but what doesn’t eh?

BTW, stuff like this takes AGES, and it’s why I REALLY hate clones of games, where some talentless drone comes along and just copies an existing game design but slaps on some new textures. Yes, it really is easy to copy the mechanics of a popcap game, but coming up with those mechanics took a ton of work. This stuff is never obvious, and I personally don’t think it can be reliably learned from books. I think you have to just keep trying stuff.

Debug Tools and defensive AI.

Life is so much simpler when you bunch up all your hotkeys and toggles for debugging the game into a single menu. I feel like I have a rough idea what’s going on now. I also feel more confident about coding decent defensive AI when you play as the attacker:

The code for defending basically needs to manage three things. The play style (Is it spamming units, hoarding points, or steadily placing), The choice of units (Does the enemy have units weak Vs lasers? Are there lots of infantry needing flamethrowerising?) And the choice of unit placement. I’ve been concentrating on the unit placement debug UI today, so I can see what the AI is thinking when it chooses to place a turret at X rather than Y. More work to do, but currently it evaluates proximity to enemies, their size, victory-point value, closeness to the exit and proximity to the placement, plus it also has bonuses for being able to cover multiple paths from a single location.

It all needs lots of tweaking and balancing obviously, but it’s getting there. Attacking AI is much simpler.

After getting this stuff done, I’m thinking of experimenting with a unit ‘cooldown timer’ beyond a certain level to prevent spamming the same unit everywhere. Essentially there are supply delays if you plonk down 4 heavy tanks all very quickly, as new ones need to be dispatched from your offscreen HQ. I think it might be a good mechanic that encourages variety.

Regimental colors

Today I got a decent chunk of work done for the regimental colors editor for GTB. GSB only had your user name, which didn’t really add a feeling of connection to the other player, so GTB will have your regimental logo (like a cap-badge insignia) associated with your maps and armies, so hopefully players will feel more like they are really fighting against proper opponents.

I plan to support user-designed, uploaded logos too, but because 95% of players won’t be arsed to do that, there is a simple editor that arranges a logo out of 3 layers and renders it to disk as your profile logo. The rendering isn’t done yet, but the rest is:

You can choose between a bunch of graphics and the three layers get combined, with a choice of some colors, plus you can move elements up and down and scale them. It’s the bare minimum that will give me an assurance that you will generally see fairly unique logos for all your opponents when playing other players armies. Plus it was fun to do :D

The problem with code like this is you can get *too* into it. I could happily spend a week doing a fully featured military insignia designer with a ton of features, but you can’t have that attitude with a game as huge as GTB if it’s ever going to ship :D I really hope the game does well enough for people to get into designing really cool logos. GSB has a great modding community and I’d love to see them go to town with stuff like this.