Monday, March 12, 2007

Basics of Combat, Volume 2, To Hit Chance

Because of the built in (and as I found out you can't disable it) mechanism that you always miss on a roll of a natural 1, this means, no matter what I do, there is a base 5% miss chance already in the system. This 5% would also mean there is no possibility of my script executing, simply because the weapon never hit the target and therefore never fired the On Hit Cast Spell mechanism. Taking this into account, the rest of the hit chance is going to be based out of 95 rather than 100. Although this isn't 100% accurate since two layer chances are multiplicative and I am making them additive, I really don't want to do the math and this is a heck of a lot easier. With that out of the way, on to a preview of how the ViM To-Hit system works...

Step one is to determine the miss chance due to level difference. This value forms the base that is then modified by the attacker's weapon skill and the defender's defense skill. This value is derived from a very simple chart:

Level Difference - Miss Chance
3 or more levels lower - 5%
2 levels lower - 7%
1 level lower - 12%
Same level - 15%
1 level higher - 25%
2 levels higher - 40%
3 levels higher - 70%
4 or more levels higher - 95%

Once you have the base miss chance, you then have to calculate the attacker's weapon skill. This is done the same method as all other skills in ViM. You take their skill value, then add associated attribute(s) value times 1.75, and then any modifiers from abilities, racial bonuses, items, etc. In this case, lets take a level 1 warrior that has no racial bonuses and is using a longsword. Let us also assume that he picked up the Weapon Focus ability in One-Handed Slashing. It is also assumed that the character has just been created and has not increased his skill level. The only attribute that we are concerned with is the warrior's Strength, in which he has an 18, since he is using the One-Handed Slashing skill.

So the numbers work out as follows:
Skill Level - 1
Weapon Focus Bonus - 10
Racial Bonus - 0
Attribute Bonus - 31.5
Item & Spell Bonuses - 0

No you take the total skill level 11 and divide that by 5 to get the base skill level. To that value you add the ability modifier, so the Warrior's total skill level in One-Handed Slashing is 33.7.

Now let's take a look at the poor Scar-Eyed Goblin Whelp that said warrior is beating on. Since the Whelp is a MOB (Monster OBject) he automatically has 10 times is effective level as a skill, so in this case it is 10. The two attributes associated with the Defense skill are Constitution, in which he has a 16, and Dexterity, in which he has a 14. So for defense you use the average of those two attributes and that result is then multiplied by 1.75 to get the attribute modifier, which gives us 26.25. Scar-Eyed Goblins are not lucky enough to have any bonuses to Defense.

So the numbers for the goblin are:
Skill level - 10
Racial Bonus - 0
Attribute Bonus - 26.25
Item & Spell Bonuses - 0

Start by dividing the goblin's skill by 5, giving you the base of 2 and then add the attribute modifier, so the goblin's total defense skill is 28.25.

Since the goblin and the warrior are the same level, 1, the base miss chance is 15%. The modifier to this base is determined by subtracting the attacker's final weapon skill from the defender's final defense skill. The result is then added to the base miss chance to get your final miss chance. So that would be:

15.0 + (28.25 - 33.7)

In other words the final miss chance would be 9.55%, which rounds down* to 9%. Since the engine has a build in 5% miss chance (which means it is the minimum miss chance allowed) then the script has to handle the top 4%. So this becomes the first section of the to-hit roll. The rest of the sections of the to hit roll are made up of parry, dodge, and finally critical chances. The calculations used to determine those values will be discussed later. :)

For those of you who like simple numbers, here is a basic run down:

1) For every attribute point your hit chance is modified up or down by 1.75%.
2) For every 5 skill points your hit chance is modified up or down by 1%.

I hoped that you enjoyed the first discussion of combat with numbers and I hope to see you in the game!

*The Electron engine, as far as I know, truncates fractions when converting from float to integer, so all formulas should assume that they are rounded down.

No comments: