[autrealm-devel] Combat system design
Status: Pre-Alpha
Brought to you by:
cdsmith
|
From: Chris S. <cd...@tw...> - 2006-08-28 16:55:27
|
Well, I'm using the mailing list, even though there are only two of us here.
This is a proposal for a replacement of the combat system. I am trying to
keep things simple.
I suggest removing maximum hit points as a statistic for a character.
Instead, a character will just have a health level that ranges from 0% to
100%, and the range doesn't improve. Instead, you just increase your
defense attribute.
First off, I need to define a function, which I'll call k(x).
g(x) = (1/2) * (1 + (x / sqrt(1 + x^2)))
The important things about it are that it is continuous and monotonically
increasing for all real numbers and has the range (0, 1). That makes it
very convenient for converting monster and character attributes into
probabilities.
Each turn, the following steps happen:
1. Choose a combatant to attack. This is done by subtracting the monster's
speed from the player's speed. The probability that the player attacks is:
g(k_speed * (s_player - s_monster))
where:
g = the function described above
k_speed = a constant, 0.175
s_player = the player's speed attribute
s_monster = the monster's speed attribute
The probability that the attacker misses is:
g(k_hit * (d_defender - a_attacker))
where:
g = the function described above
k_hit = a constant, 0.2
d_defender = the defense attribute of the defender
a_attacker = the attack attribute of the attacker
When determining whether the attack succeeds, we remember the amount by
which the attack succeeds. That will be a number between 0 and 1 - g(k_hit
* (d_defender - a_attacker)). It will be called t.
The damage done from the attack is:
t * k_dmg + 0.05
k_dmg is a constant, set to 1.17. The extra factor of 0.05 ensures that all
successful attacks do at least a noticable amount of damage (for example,
it's not possible to see a hit message, but that have the hit do 0.000001
damage).
The battle ends when someone is dead, or someone flees.
I tested this by writing a program that runs a million random battles
between characters with randomly chosen attributes, and determined the
following interesting results:
For characters all of whose stats are within 10 points of each other, an
average battle is 15 turns long. However, that is misleading, as it is
heavily skewed by a few extreme results when both players end up with a huge
defense and a very small attack. In reality such battles would rarely
happen, and would end with someone fleeing out of boredom. The quartiles
are:
0%: 1 turn
25%: 4 turns
50%: 7 turns
75%: 15 turns
100%: 560 turns
So a median battle is actually 7 turns long. The rare battles up to 560
turns are anomolies that skew the mean.
86.5% of battles are won by the statistically superior or equal combatant.
13.5% of battles are won by the statistically inferior combatant.
The following are correlations factors between various attributes and
success in battle:
speed: 0.4565
attack: 0.4567
defense: 0.4575
total: 0.7917
So all three attributes are approximately equal in importance for battles
where attributes are within 10 units. The correlation between total of all
attributes and success looks fine.
As a side note, the importance of speed varies depending on how close the
battles are. For battles where attributes vary by at most 5, speed
correlates at 0.3945, while attack is at 0.4139 and defense is 0.4141. (The
lower correlations are normal; for closer battles, luck plays a greater
role.) When attributes differ by up to 20, the speed correlation is 0.4852
while attack is 0.4518 and defense is 0.4518. For the most part, though,
this is close enough. Speed also gains one the additional advantage of
having more opportunity to flee, which makes up for its lower weight in
close battles.
Unless there's objection, I'll probably implement this soon. This will
change the formats for mns.txt and ply.txt, since there will no longer be
such a thing as hit points.
--
Chris Smith
|