Mafia kill algorithm

I'm making an Omerta clone/mafia game and trying to work out a kill algorithm. Just a basic formula to decide how many bullets player A needs to kill player B.

The inputs are: players rank (out of 10), and a players kill skill (out of 100). The algorithm needs to return how many bullets are needed for that player to win.

If you're shooting someone a higher rank, or higher kill skill, it should require more bullets.

Anyone ever done anything like this and can offer some tips?

Example chart:

-
If you could explain what this is for (e.g. Do you want to let the user know how many bullets they need? Do all players have the same health, but bullets do less damage to you the higher the rank?) it'd be easier to help. – smoth190 Jul 23 '12 at 22:37
i want the script to know how many bullets you will need. The player decides how many bullets to fire, it does the algo on it and if your bullets are greater than what you needed, you win. Yeah all players have the same health – panchos Jul 23 '12 at 22:42

I'll give you a simple method you can use, and you can factor in your stats as needed:

First, you need the player getting shot at's health. Next, you'll need the damage of each bullet. Now we can do simple math to figure out how many bullets you need to fire:

``````bullets = ceil(health / damage)
``````

For example, if Player B has 87 health, and each bullet does 12 damage, we would do `87/12`, which is 7.25 and round that up to 8. This means to kill a player with 87 health, you need to fire 8 bullets that do 12 damage.

Now, let's factor in the Kill Skill and the Rank. As you did not provide how these affect the damage dealt/received, I'll do that myself. You can change it as you see fit. We have two players with the information we'll need:

Player A (Kill Skill 65, Bullet Damage 12)
Player B (Rank 6, Health 87)

We won't need any other information. Player A is firing at Player B. We'll say that Rank determines the amount of damage you'll receive. For each Rank, you receive 0.4 less damage (`DAMAGE_RECEIVED_PER_RANK`). We'll say that Kill Skill determines the amount of damage you deal. For each level, we'll say you do 0.1 more damage (`DAMAGE_DEALT_PER_KSLVL`). First off, we need to get the amount of damage a bullet will do to Player B factoring in our Rank and Kill Skill:

`damage = (DAMAGE_PER_BULLET - (rank * DAMAGE_RECEIVED_PER_RANK) + (killskill * DAMAGE_DEALT_PER_KSLVL))`

What this does is takes the original damage, and subtracts the amount blocked, which is Rank times `DAMAGE_RECEIVED_PER_RANK`. Next we add the extra damage, which is Kill Skill times `DAMAGE_DEALT_PER_KSLVL`). In this example, we have:

`damage = (12 - (6 * 0.4) + (65 * 0.1)) = 16.1`

The rest is simple, divide health by the damage:

`bullets = 87 / 16.1`, which is 5.4 and we'll round it up to 6. That means a player with a Kill Skill of 65 and Bullet Damage of 12 will need 6 bullets to kill a Rank 6 player with 87 Health. You can adjust the stats to balance it out. You can also fit the entire equation into one statement, but I broke it up for clarity. I hope I was of help, and good luck!

(Since I suck at math I tested this out in Visual Studio and got it to work as expected.)

-
Instead of simple factors as modifiers to bullet damage, you could also use logarithmic or exponential modifications. – BerndBrot Aug 25 '12 at 12:56