Function will probably end up looking something like this.
Code:
bool Client::CheckDoubleAttack(bool tripleAttack) {
//Check for bonuses that give you a double attack chance regardless of skill (ie Bestial Frenzy/Harmonious Attack AA)
uint16 bonusGiveDA = aabonuses.GiveDoubleAttack + spellbonuses.GiveDoubleAttack + itembonuses.GiveDoubleAttack;
if(!HasSkill(DOUBLE_ATTACK) && !bonusGiveDA)
return false;
int chance = 0;
int8 classtype = GetClass();
uint16 skill = GetSkill(DOUBLE_ATTACK);
sint16 bonusDA = aabonuses.DoubleAttackChance + spellbonuses.DoubleAttackChance + itembonuses.DoubleAttackChance;
sint16 skillmod = 0; //TODO: Apply all worn skill mods, spell skill mods.
//Use skill calculations otherwise, if you only have AA applied GiveDoubleAttack chance then use that value as the base.
if (skill)
chance = ( (skill*(100+skillmod/100) + GetLevel()) * (100+bonusDA+bonusGiveDA /100)) /500
else
chance = bonusGiveDA + (bonusGiveDA * (100+bonusDA/100));
//Live now uses a static Triple Attack skill (lv 46 = 2% lv 60 = 20%) - We do not have this skill on EMU ATM.
//A reasonable forumla would then be TA = 20% * chance
if(tripleAttack) {
// Only some Double Attack classes get Triple Attack [This is already checked in client_processes.cpp]
sint16 triple_bonus = spellbonuses.TripleAttackChance + itembonuses.TripleAttackChance;
chance *= 20 + triple_bonus /100;
}
else
return false;
if((MakeRandomInt(0, 100) < chance)))
return true;
return false;
}