Tuesday, March 15, 2016

Game Combat Basics

I find myself building a small thing with combat as a creative exercise. It's not something I'd ever want to share, especially on here, but talking a little bit about specifics helps. If nothing else, writing about it helps clarify things for me, so even if no one reads this, I've still benefited from it.

Let's start with the basics. The goto basic combat system is the Dungeons and Dragons combat system, specifically version 3.5. Why? It's basic, understandable, and easy to calculate. You don't want to use a calculator for tabletop gaming, nor do you want too many numbers in the way. It works like this: Roll a d20 (a die with 20 sides, with values 1-20) and add your attack value. If this sum is greater than your opponent's defense, you hit and then deal with damage. Simple, straightforward, and easy to implement. So you drop it into your game, try it out, and find that it isn't a very good system at all for a computer game.

There's a few reasons it doesn't work well in a computer game. Chief among them is that DnD is designed around rolling dice. Rolling a die and seeing the result is an intrinsically fun action. Having a computer roll the dice for you and it's not nearly as fun. Whereas in a DnD setting you'd watch that die bounce and either come up short and succeed for you, all you see on the computer is your character whiffing or hitting, and if you're using values like those found in DnD, he'll be doing a lot of whiffing. Now you're wasting time watching the computer duke it out with itself as both parties whiff ~40% of the time. What fun.

There's other issues too, mostly relating to how offense versus defense scales. The main defense in this system has you avoiding full damage more often. Specifically, each point of defense makes you 5% less likely to be hit. Each point of attack increases your chance to hit by 5%, effectively cancelling out a point of defense. Which means if your attack scales at the same rate your opponent's defense scales, nothing will change in this system, even as both of you get stronger and stronger. Actual damage dealt and maximum health might scale as well, but the fight still looks similar. There's also issues when attack and defense values vary widely from each other. What happens if you have 100% chance to hit? 0% to hit? Could I reasonably make a monster that still stands a chance if it only hits 5% of the time? If you hit most of the time anyway, why still have this system?

(Note: DnD also has the suggested house rule that a natural 1 always misses and a natural 20 always hits. Setting a minimum and a maximum like that certainly works as a solution, but is not necessarily a solution that solves the problem)

This system as a basis for making things work doesn't do well in a computer game setting. Luckily, there are other alternatives. Instead of hitting or missing, we can take that out entirely and have defenses reduce damage. Again, we keep things simple and deduct our armor amount from any damage we take. 10 damage against 5 armor means that 5 real damage is dealt. This system works, but runs into other funky problems. Most notably that damage taken depends heavily on how much damage the opponent does per shot relative to the amount of armor. If the rate of attack can vary, slower attacks will be much stronger relative to smaller but quicker attacks. Designing a proper fight from the developer's perspective can be odd too.

Say I wanted to double the damage taken from my last example. I can't double the original damage, that'd result in the target taking triple damage instead of double. (20-5=15 or 5x3) Instead, I want to add 5 damage. As well, I need to keep damage relatively similar to armor levels. High damage makes small amounts of armor relatively useless. If I'm taking 30 damage already, would 2 more armor really help? The reverse is also problematic. Going back to the original problem, if I add 2 armor there, I'm only taking 3 damage a shot, or a 40% reduction.

All that may not be a problem though. If I have numbers setup right, things should (repeat, should) work fine. It's still a funky system though, and I might prefer some flexibility. Next attempt is percentage damage reduction. It works regardless of rate of attack, works on any number equally well, and dealing with relative increases of power are straightforward. Of course, it has its own issues.

First, it's more complex than the others. I don't need to worry about computational complexity because the computer will handle it, but I do need to worry that the player understands how much his shiny new piece of armor actually helps. I also need to get the math right. Two pieces of armor, each with 10% damage reduction, should not add up to 20% damage reduction. If they do, that means that later pieces of armor are much more valuable than they appear, and lead to silliness. Using terms like "10% damage reduction" also look silly; ideally I'd like to have a term like "armor" that turns into damage reduction after the fact, for which I'll need to tell the player somehow. Or not, and leave it to the wiki.

There's the other problem of small numbers. If I deal 10 damage, anything less than 10% damage reduction doesn't do anything, because it'd reduce by less than 1. I can keep the number as a decimal, but that looks strange if I'm using small numbers in the first place. (And leads to one of the few legitimate times where 2+2=5) It can also seem worse than it is. The rules I originally used had attack and defense values change in increments of 5%. If I'm at 50% damage reduction, an additional 5% damage reduction would reduce damage by 5%, but it'd look like it's only doing 2.5% (assuming I tell the player the total damage reduction from armor) If you don't know math, it then looks like armor gets worse and worse the more you get, even though that's far from the case.

Maybe I'll do another post sometime looking at other problems or issues. Maybe not. If you have any questions, especially about the math in this, please be sure to leave a comment and I'll get back to you.

No comments:

Post a Comment