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