Code:
bool Client::CheckDoubleAttack(bool tripleAttack) {
// If you don't have the double attack skill, return
if(!HasSkill(DOUBLE_ATTACK) && !(GetClass() == BARD || GetClass() == BEASTLORD))
return false;
// You start with no chance of double attacking
int chance = 0;
// Used for maxSkill and triple attack calcs
int8 classtype = GetClass();
// The current skill level
uint16 skill = GetSkill(DOUBLE_ATTACK);
// Discipline bonuses give you 100% chance to double attack
sint16 buffs = spellbonuses.DoubleAttackChance + itembonuses.DoubleAttackChance;
// The maximum value for the Class based on the server rule of MaxLevel
int16 maxSkill = MaxSkill(DOUBLE_ATTACK, classtype, RuleI(Character, MaxLevel));
// AA bonuses for the melee classes
int32 aaBonus =
GetAA(aaBestialFrenzy) +
GetAA(aaHarmoniousAttack) +
GetAA(aaKnightsAdvantage)*10 +
GetAA(aaFerocity)*10;
// Bard Dance of Blades Double Attack bonus is not cumulative
if(GetAA(aaDanceofBlades)) {
aaBonus += 500;
}
// Half of Double Attack Skill used to check chance for Triple Attack
if(tripleAttack) {
// Only some Double Attack classes get Triple Attack
if((classtype == MONK) || (classtype == WARRIOR) || (classtype == RANGER) || (classtype == BERSERKER)) {
// We only get half the skill, but should get all the bonuses
chance = (skill/2) + buffs + aaBonus;
}
else {
return false;
}
}
else {
// This is the actual Double Attack chance
chance = skill + buffs + aaBonus;
}
// If your chance is greater than the RNG you are successful! Always have a 5% chance to fail at max skills+bonuses.
if(chance > MakeRandomInt(0, (maxSkill + itembonuses.DoubleAttackChance + aaBonus)*1.05)) {
return true;
}
return false;
}
While trying to properly implement the AA's for double attack, I came to conclusion the entire function is rather flawed but being such a vital part of the attack code, I don't want to change anything without bring it up for review in the event that I am really tired and missing something.
Essentially its written as you have at any skill level a 95% chance to double attack as long as your skill = maxskill for that level.
Ie at level 15, maxskill is 85, so if your 85/85 you hit 95%, therefore making the actual skill level irrelevant.
Beast/Bard skill level on live is capped at 25. However if we use our formula as long as your 25/25 your at 95%. Flawed.
Further more, this makes all AA and Worn Effects (ferocity) 100% null because they are canceled out in the calculation.
Finally it assumes any spell bonuses = 100% chance which is just totally incorrect because the ranges of spell values for double attack in the dbase range from 4% to 10000% ect.
The bottom line calculation is.
Skill + itembonus + AAbonus + spellbonus >
Rand(0,MaxSkill + itembonus + AAbonus *1.05)
As you can see item bonuses and AA bonuses are in all cases negated from both sides of the equation. Assuming you have no spellbonuses you are left with your 95% chance.
After doing some searching I found that live uses a formula:
(skill*skillmod) + level * (100 + totalfocus/100) / 500;
Unless there is some objection I would like to change it to use something like this.