Thursday, July 5, 2012

The Combat Engine

I knew going into this project that the hardest part to creating an old-school style CRPG would be getting the combat engine to work just the way that I wanted.  A lot of complex coding goes into the combat, which has to track variables for all sorts of things.  Here's a short example of what it has to keep track of in the average turn (this doesn't even scratch the surface):

  •  What are the stats of the current character?
  •  Does that character have a condition we need to know about?
  •  If the character is affected by a condition, how long does that condition last?
  •  What weapon are we holding?  What armor are we wearing?
  •  Can this character cast spells?  What kind of spells?
  •  How many Life Points do we have left?

Overall, creating the combat engine has had the slowest development.  The good news, though, is that it's coming along nicely, despite my attempts to get it wrong several times.

So, what's it like?  That's the first question I would be asking.

In order to answer that, I need to go back in time to a game created by SSI, called "Phantasie," which came out in 1985.  I remember watching a friend play that game for hours, and being captivated by the combat engine, which was the first graphical CRPG engine I had ever seen (prior to that, games like "The Bard's Tale" used text to relay what was going on in combat).

It looked something like this:

"Phantasie" on the Commodore 64.

By today's standards, it's a bit primitive.  But it's effective, and it still works well.  I played the game last year, and found the layout to be intuitive (even though the controls were somewhat clunky).  The party was at the bottom, and the enemies they faced appeared at the top.  The look of the combat screen is what I like the most.  It's simple...and that's really important.

What I didn't like, though, was that you had to select everything you were going to do with your characters before the turn started, and you had to hope that you picked right.  If someone got seriously hurt during that turn and you didn't choose a healing spell, they were screwed until the next round began, and you had to hope they didn't get hit again.

My engine, while taking some ideas from Phantasie in layout, allows you to actually do things when your turn comes up.  You don't have to select everything before the round starts.  So, I kept the simplicity, but added in some flexibility.

But, enough of me, let's take a look at it:

We've come a long way in 27 years, but I still like the retro feel...

One thing I will point out about these screenshots is that they don't actually do the combat engine justice.  These screenshots don't show off the animations that happen when you hit an opponent or cast a spell at them.  You can't hear the sound effects.  You don't get the sense of satisfaction that comes when you hit an enemy and kill them and watch them leave the combat.

So, keep that in mind as you look at them.

The flash of healing that is usually present can't be seen here.

There are a lot of systems working already.

Attacking, which was the easiest thing to do, got done on day one.  Both the monsters and PCs are capable of attacking each other.  The game also allows for a chance of scoring a critical hit, allowing a character (or monster) to do double damage on a single hit.  Even better, Scouts sometimes trigger a special attack that gives them double damage as well...and if they critical at the same time, they get four times the normal damage that they would be able to do.

Ouch!

Characters can access their inventories to use items (like healing potions, for example) or swap weapons or armor pieces when necessary.  They can even trade during combat, allowing them to give someone in need a potion of healing or something else of importance.

Of the spells, only the priest spells are implemented (I haven't actually begun coding the Sorcerer spells yet).  In fact, spells are the toughest thing so far.  It takes time to create code for all the special things that can happen due to spells.  And each spell has a sound effect and an animated graphic.

Really, the only button with no functionality is the Flee button, allowing a character to attempt to escape a combat.  But, that will come.

A goblin has been entangled by a spell.

All in all, it's coming along pretty well.  The engine even knows when the PCs win and gives out experience points.  And it knows when the monsters win too...which puts you right back at the main menu (it's a good idea not to let that happen).

I'll add more updates as the engine comes along.  I'm hoping to finish it soon.  Once it's done, everything else should be easier...and I imagine the game will come along much faster after that point.


No comments:

Post a Comment