Designing a battle system

Started by
5 comments, last by LorenzoGatti 7 months, 3 weeks ago

I am creating a game similar to the old browser game Batheo or the mobile game Three Kingdoms - Art of War. In short I have started with the battle system and don't know how to think about dealing/taking damage.

The hero will have some base stats for attackPower and defensePower respectively and they will be somewhere between 1 and 100 or so. The player can also train their heroes for better stats (troops and power e.g.), put on equipment with extra power, upgrade tech etc. I can probably come up with some way of calculating the attackPower and defensePower for the player with these, but any advice here is appreicated too.

The enemy will just have a attackPower and defensePower for simplicity, which will have all extra things included from the start. All enemies will have different stats and become harder of course.

Main issue
So now I come to the point of dealing damage. I am thinking of first doing something simple like:

damage = attackPower - defensePower

However I think I at least want some sort of floor and roof.

damage = Mathf.Clamp(damage, minDamage, maxDamage);

This will be a bit boring I think though. So I would like to have something that is less sensitive around 0 (when defense is much higher than attack) and also at max (when attack is much higher than defense). Maybe some sensitivity curve:

damage = Mathf.Sign(damage ) * Mathf.Pow(Mathf.Abs(damage ), sensitivity);

Any advice on how to create a nice system which will feel natural and always give some damage, but not too high or at least be less sensitive on the edges?

Advertisement

Hard for me to tell what exactly you want.

One way I've day it is as some randomness to the damage. Like:

int r = rand(0, 1000);

float f = r / 5000.0f;

int damage = (attack * (f+1.0f)) - defense;

That would give up to 20% higher attacks sometimes. Another thing I've done is simply like:

int r = rand(0, 10);

if r == 1 {

miss, critical hit, etc

}

None

@troutsneeze Thanks for the input. Yes I do have the block, crit, dodge etc which is a nice feature.

It is hard to explain so I will draw a nice paint graph which I hope helps, with real damage on the x-axis and what I want the damage output to be on y-axis. Sort of a sigmoid function but around 15 000 instead of around 0.

  1. If the real damage is≤ 0 then I want it to be some minimum value which is easy fix at the end with a Math.Max thing.
  2. I then want it to start more slowly until it goes more linear.
  3. Over say 30 000 I want it to increase more slowly again and keep rising slowly.

This is so I will always have some damage for the enemies, but it will never be “too big” either. IT doesn't have to be this extreme but somewhere along those lines.

Oh ok, it almost looks like a hermite curve but I'm not great at math. A math person will have to solve this. If you want to try hermite interpolation then use 0, 0, x, max I think as the parameters.

As you can see from the image on wikipedia for hermite spline interpolation (which is really easy and I can give you code for which is like 2 lines) the dark blue line looks kind of like what you want:

My code for this is on GitHub: shim4/src/interp.cpp at main · troutsneeze/shim4 (github.com)

None

Cheers! Will have a look at it, looks promising 🙂

Abstraction please. Your damage formulas are a means to an end (having “fun” combat in your game), but not the only one. An exchange of blows that ends when someone feels sufficiently hurt is a straightforward, understandable baseline; but what do you want from it?

  • How long should the fight be? Too few turns, and it becomes too brutal and too short to allow nontrivial tactics; too many turns, and it becomes boring as any tactical approach drowns in waiting and repetition.
  • What opponents and weapons should have shorter or longer fights? If “realistic” battle durations fall outside the sweet spot you should probably compensate by avoiding such bad fights altogether, or by stopping earlier or later than usual on the first blood - death spectrum.
  • What numerical range of damage and hit points values do you need? What are the weakest and strongest possible attacks, and the weakest and toughest creatures? Do you need headroom for special cases? Do you really want to distinguish similar creatures and attacks (e.g. rat vs. mouse, sabre vs. sword) with quantitatively different ratings?
  • How random should the combat be? Do you want the underdog to win once in a while? Generally, random damage increases tactical complexity (more states for the player to deal with become possible, and their probability needs to be estimated) and enables meaningful risk taking instead of just grinding away hit points faster or slower than the other party.
  • Why do you like minimum and maximum damage guarantees? Minimum damage will, for example, allow a band of terribly weak but numerous enemies to kill a powerful player character; maximum damage will take away the rewards from a player who tries to stack enough training and items to reliably defeat increasingly powerful monsters with one or two blows.
  • What tactical decisions are available for the player? Only two simple ones are implied in your description: increasing attack power or defense power (with different training and equipment) and retreating before seriously risking death. Regardless of how much damage is dealt, more complex rules, with more resources and more complications, seem necessary; traditional tactical dimensions include damage types and different defense effectiveness against them and combat maneuvers beyond a plain attack.

As for concrete formulas, they should be calibrated to interpolate and approximate some well chosen test cases, for example that a fighter with sword, shield and chain mail should defeat a brown bear with better than even odds, with a moderate number of sword hits and modest damage.

Relying on the difference between attack and defense scores makes very low damage situations unavoidable; you could, instead, make attacks random, either a significant amount of damage or a dangerous failure.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement