# Chance to hit

#### Squix

##### Diabloii.Net Member
Chance to hit

Is there a formula for chance to hit in pvp? Like taking into account both player's levels, my AR and their defence? (think those would be all the factors - don't care about blocking, that's easy to take into account).

#### Thrugg

##### Diabloii.Net Member
As far as I know it's the same as PvM.
% to hit = 100 * (AR / AR + DR) * 2 * (alvl / alvl + dlvl)
where alvl and dlvl are attacker level and defender level.

#### Squix

##### Diabloii.Net Member
Wait a sec... did you mean it like this? (square brackets added)

% to hit = 100 * (AR / [AR + DR]) * 2 * (alvl / [alvl + dlvl])
= 200 * (AR / [AR + DR]) * (alvl / [alvl + dlvl])

Otherwise, it simplifies to:

% to hit = 200 * (1 + DR) * (1 + dlvl)

#### Thrugg

##### Diabloii.Net Member
Yeah, fair enough, but I think you're bright enough to realise it is the first and we don't make formulae more complicated around here just for the heck of it
But don't go moving that *2 up to the front. All divisions in D2 are integer divisions, ie rounded down. Being completely precise it is
%chance = 100 * AR / (AR + DR) * 2 * alvl / (alvl + dlvl)
in that order, ignoring remainders after each division.

Example, clvl 60 attacker, 5432 AR, clvl 57 defender, DR 2345:

100 * 5432 / 7777 = 69 (rounded down)
69 * 2 * 60 / 117 = 70 (rounded down again)

If you move the *2 up to the front you would get
200 * 5432 / 7777 = 139
139 * 60 / 117 = 71 (rounded down)
It doesn't make a huge difference, but it does make a difference.

#### Squix

##### Diabloii.Net Member
OK, cool. Thanks for the formula and example (and reminding me of that darn integer math).