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.

Tuesday, March 1, 2016

Alien Domesticated Animals

Today, I want to think about aliens. Not the usual aliens that think and act and somehow look like humans with funny foreheads, but the dumb ones. I'm talking about the domesticated kind. What would aliens look for in domesticated animals? Preferably, what would they look for that isn't almost exactly the same as what we have on Earth? Something alien, not a space dog, yet still similar. Why am I talking about this? Because I can. And because I watched this video from CGP Grey:


(If you watched, go watch! It's a good video)

Which got me thinking: "What traits might we want from an animal, if we could imagine animals as drastically different from what we have now. What might an alien want that is very different from a human?" So lets start with something easy. Everything living needs energy to survive and be active, so it's a reasonable assumption that sentient aliens would need to eat. (Except maybe those fancy green aliens that cheat). While it's true that turning grass into meat is inefficient calorie-wise, it's pretty useful if the grass is useless to us anyway. Some calories is better than none. It's also a big bonus if you get a taste boost in the bargain.

When we look at the chemical factories we call digestive systems in Animals on Earth, we see that specialization is key. More specialization in what we eat means more efficiency. You don't need to worry about specialization when your diet consists of calorie-rich fruit, meat, and vegetables like the diet humans tended to have. Yet, if you want to eat food like grass that is minimal in effective calories, specialization is the only hope. Rather than go through the hassle to turn grass into edible material, easier to have an animal already suited for the job do it for us. Other examples of inedible food include poisonous plants, food waste, and carrion. Perhaps we're looking purely for taste, ala honey (or aphids for ants).

I'd think it a no-brainer that aliens would have some form of domesticated animal that turned inedible food into something edible. The fun part is in imagining how the alien gets the calories from the animal after. On Earth, it's most efficient for animals to produce food continuously, rather than only slaughtering them once they've grown. The big two examples are milk and eggs. Making meat is expensive, it requires the animal spend calories to make the cells, then those cells must be maintained requiring more energy the longer the cell lives before butchering. Comparably, milk and eggs are a single energy expenditure, no energy maintenance required.

Maybe we find an animal that can compromise. Lizards are an animal that can continuously regrow lost limbs, with some even using it as a defense mechanism. Why not a domesticated animal that can consistently grow meat without needing to be butchered? Or get really alien. Have the male be an omnivore similar to humans, while the female has a diet more similar to a horse or perhaps cow. (Or reverse the roles, if that's your preference) Even better if they have some foods to share that both enjoy, such as high-sugar foods like honey. What would society be like if men and women didn't ever share meals, but had the occasional dessert together?

As well as making useful calories, animals produce other useful materials. Bone, fur, feathers, wool, ivory, leather, silk; there's a lot of useful materials we derive from animals, especially before more advanced methods of production are found. We've only recently (relatively) developed alternatives to some of these items that don't require animals to produce. I'd find it incredibly likely that alien civilizations would use animal products as well, in likely similar uses as in our past. Building materials, decoration, and especially temperature regulation are all too good to pass up. Always a great choice in a story when you need a material made is to have it be made by an animal. Which seems sillyat first, but considering that guano (aka bird/bat poop) can be easily refined to become the main ingredient in gunpowder, using animals as chemical factories doesn't seem so odd.

The last major usage for domesticated animals is as workers. Preferably, they have other purposes from those listed above to be as efficient as possible. The horse is the best example. It can be used to carry things we'd rather not carry, including us. It runs at high speeds, faster than we can. Even better, it runs off of food we don't eat, and can convert it to food we can eat. Milk and meat even. Other examples are great: oxen for heavy lifting, cats for killing vermin, dogs for herding and their enhanced senses, and others. Effectively, anything your alien can't do is good grounds for employment of animals, along with anything a sentient doesn't want to do but still needs doing. Humans can certainly pull along wagons, but the oxen whine less. Dogs have different senses than us, making them highly useful for compensating to obtain a fuller range of senses. Presumably, an alien that lacks in good eyesight could have a more literal seeing eye dog as a companion.

Effectively, if you ever find yourself imagining an alien species, try to look too at what domesticated animals they're likely to have. Look for holes in their biology, then think of ways other animals could help fill those holes. Don't forget to add some variation to the animals too. Most farm animals are pretty docile, but horses have an attitude and camels are jerks. Don't horse around by making the animal the same as a cow, except In Space! Unless of course, you're making a joke about how aliens seem to like our cows so much. Please remember to milk that joke as much as possible. Hope you enjoyed the read, it's time for me to get mooving to another project.