void Player::doAttacking(uint32_t interval)
{
if(!lastAttack)
lastAttack = OTSYS_TIME() - getAttackSpeed() - 1;
else if((OTSYS_TIME() - lastAttack) < getAttackSpeed())
return;
if(hasCondition(CONDITION_PACIFIED) && !hasCustomFlag(PlayerCustomFlag_IgnorePacification))
{
lastAttack = OTSYS_TIME();
return;
}
Item* tool = getWeapon();
if(const Weapon* weapon = g_weapons->getWeapon(tool))
{
if(weapon->interruptSwing() && !canDoAction())
{
SchedulerTask* task = createSchedulerTask(getNextActionTime(), boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
setNextActionTask(task);
}
else if((!weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) && weapon->useWeapon(this, tool, attackedCreature))
lastAttack = OTSYS_TIME();
}
else if(Weapon::useFist(this, attackedCreature))
lastAttack = OTSYS_TIME();
}