Attack speed
See Weapon Speed for tables summarising this information.
When deciding between two different weapons, it can be helpful to understand exactly how attack speed works. Weapon speed in crawl is measured in units of delay. A character with a small attack delay will swing more frequently than a character with a high attack delay.
The base attack delay of a weapon is listed upon examination. For example, examining a handaxe shows that its speed is 130%. To convert this to base delay, simply chop off the last zero. So our handaxe has a base delay of 13.
Having points in a weapon's associated skill will decrease this delay. Take your weapon skill and divide it by two, rounding down. Subtract the result from the weapon's base delay to determine your adjusted delay. So if you have a skill of 2 in axes, your handaxe would have an adjusted delay of 12. As soon as you reach a skill of 4 in axes, the adjusted delay would decrease to 11.
Now, weapons can't just keep getting faster and faster. All weapons have a minimum delay. Once reached, more weapon skill won't decrease the delay any further. To find out the minimum delay for a particular weapon, take the base delay, divide by two, and truncate the remainder. So, our handaxe with a base delay of 13 has a minimum delay of 6. That means that our weapon skill can at most lop seven points off of the handaxe's base delay. Once you hit an axe skill of 14, that handaxe is going to be swinging as fast as it is going to get.
There are a couple of exceptions to the minimum delay calculation. First, if the weapon in question is a short blade and the calculated minimum delay is larger than five, then the minimum delay is adjusted to five. So that saber, even though it has a base delay of 12, has a minimum delay of 5 instead of 6.
The second exception is if the calculated minimum delay is larger than seven. In such a case, the minimum delay is set to seven. This mostly happens with big two handed weapons. Because of this exception, that executioner axe of yours with a base delay of 20 has a minimum delay of 7 instead of 10.
There is a hard-coded minimum player weapon delay of 3. If the calculated minimum delay is less than three it set to three.
The speed brand comes into effect after the check against the minimum attack delay is done. A weapon with the speed brand can actually attack faster than the calculated minimum delay. The speed brand halves delay, rounding up. So a handaxe of speed, at an axe skill of 14, would hit at a delay of 3 instead of 6. An executioner axe of speed would hit at a delay of 4 instead of 7 at an axe skill of 26.
A shield can potentially add extra delay to your attacks. To calculate the delay added, you first need to know your adjusted shield penalty.
(adjusted shield penalty) = (base shield penalty) - (shield skill)/(racial divider)
The base shield penalty is 1/3/5 for bucklers/shields/large shields, and the racial divider is 3/5/7/9 for ogres/humans/kobolds/spriggans. Throw away any remainder on the division. So a normal size race would have an adjusted shield penalty of 0 when wielding a buckler at shield skill 5, a medium shield at shield skill 15, and a large shield at shield skill 25.
If you are wielding a one handed weapon, two random integers are chosen between 1 and your adjusted shield penalty. The smaller one is used as the delay added by the shield. So your delay with a shield, on average, will be smaller when wielding a one handed weapon than when wielding a hand and a half weapon. In either case though, once your adjusted shield penalty reaches zero there is no added delay.
At this point, if the weapon delay plus the shield delay is less than three, it is set to three. There is no real way that this could happen though, as crawl is kind of funny like that. You'll never get something less than three out of the weapon delay calculation, since even a dagger of speed would spit out a delay of three.
So, now we have an adjusted speed, of our weapon, plus our shield. We aren't done yet. If we are slowed, this value is multiplied by 1.5. If we are hasted or berserked, it is divided by 1.5. If we are a statue, it is multiplied by 1.5. Under finesse, it is divided by 2. The result of this calculation is an integer, but the rounding is randomized, weighted by the reminder.
What does that mean, you ask? Say you are wielding a demon whip, and have enough mace skill to reach the minimum delay of 5. You berserk. The berserk divider is 1.5, so your delay value is 3.333. Delays must be integer values though, so 2/3 of the time your delay will be rounded to 3, and 1/3 of the time your delay will be rounded to 4. In effect, you get your delay of 3.333.
The smallest delay you are allowed to swing with is two. If the calculation spits out a value less than two it is set to two. This can happen when you finesse with weapons that have an adjusted weapon delay of three, assuming no any extra delay introduced from a shield. For example, this could happen with quickblades, any short blade of speed, demon whips of speed, and so on. That means that the speed bonus of finesse only works at partial effectiveness for attacks with these weapons. Finesse will reduce the delay from 3 to 2, and not to an average of 1.5.
The functions which calculate the delay can be found in melee_attack.cc. See melee_attack::calc_attack_delay and its sub-functions.
http://git.develz.org/?p=crawl.git;a=blob;f=crawl-ref/source/melee_attack.cc