# Determining the probability of a successful attack based on the equipped weapon?

Take this example, a player has a sword composed of the handle and a blade. Together, they generate a strength of X and that combination adds qualitative attributes (induce more damage to fire creatures). If the player encounter 2 enemies, both at same defence level, but one is made of fire. Then, I need to calculate the probability of hitting the enemies, knowing that it may be higher for the fire creature.

Given the example, I need to calculate the:

• Weapon's strength, by combining different parts?
• Probability of the outcome of an encounter?
• Inclusion of qualitative attributes in the calculation?

So far, I though of the following and I am not sure if it is good enough.

• For the weapon, I would associate a value to each component. Then, I would determine that the handle represents 25% of the total strength; allowing me to calculate the total strength

• The enemy will get a defence value.

• For the encounter, I would generate a random number between 1 and the (player strength)+(enemy defence). If that number is higher than the enemy's defence, than it's a hit. This means that if they are equal, then it's 50% chance of success.

• For the physical attributes, if the enemies has a weakness towards an elements, then I would deduct a certain value of he's defence before calculating the probability.

Is this a viable approach? If not, what would be a suitable implementation? or where can I find more ressources on these kinds of problems.

-
Are you going to factor in the friction coefficient of the handle's grip material? – erjiang Nov 11 '10 at 2:42

There is no "one-way-to-rule-them-all" to handle combat resolution and damage. The most important thing is that the resolution is understandable by the player.

In general you want to separate three elements.

• Chance to Hit
• Damage Applied
• Attack Rate

This gives you the ability to make a wide range of weapons.

Chance to Hit - tends to be calculated from a combination of player skill (agility or similar), enemy skill (agility/dodge or similar), weapon quality and weapon type. Sometimes elemental matching or magic effects are a part of this calculation.

Damage - tends to include a player skill, weapon type, enemy armor type/quality. Elemental matching or magic effects are often applied at the damage level. So a flaming sword may "hit" a flaming enemy and then do no damage or only do the base damage of the weapon but fail to apply the flaming damage effect.

Attack Rate - tends to be derived primarily from weapon type and player skill

Reference

If you want some good references go grab a bunch of different D&D style rule books and look at all their combat systems.

-
Thanks for the description and using the provided nomenclature, I will be able to find more ressources on it. – Pran Nov 10 '10 at 4:07

I think you need to start with the questions, who am I making this game for? and what kind of experience do I want my players to have?

• Is this an online game or not?
• Are you trying to make a realistic simulation of mêlée combat or something that's unrealistic but fun?
• Are you making a game for a broad or "casual" market, or for hard-core gamers?
• Are you trying to create strategically interesting player-vs-player combat?
• Are you making something for people who like to study a system of rules in detail, or for people who are probably just going to run around and mash on the X button?
• Why do you need combat to be probabilistic? What would go wrong if it were deterministic?

Only once you know the answers to these questions, can you start to figure out what kinds of solutions will be appropriate.

-
Totally right. There are often questions about how a combat system "should" work, as if there are some intrinsic rules, but in fact everything in the game, not just combat but every system, needs to be weighted and balanced to produce the results that the designer has decided they want. – Kylotan Nov 11 '10 at 0:56

As a reference, you may also interested in checking how the Fire Emblem games calculate their possibilities of hit, damage, speed,... You can find all the formulas, stats and explanations here:

http://serenesforest.net/fe10/calc.html

-