Saturday, January 21, 2017

mathematics - 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.




Answer



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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...