TFS checks for an attack on 3 occasions:
- When you select a target.
- Every 500 ms
- When you move
This means, if your attackspeed is below 500 ms. You can only get the full attackspeed by moving or re-selecting target over and over again (like hold target)
You can change the sources to fix this if you want.
It would be something like this:
Basically all you need to do is the following (I have not tested this, so let me know if it works 100% or if there are bugs)
Update the following function:
Code:
void Player::doAttacking(uint32_t)
{
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* item = getWeapon(false);
if(const Weapon* _weapon = g_weapons->getWeapon(item))
{
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, item, attackedCreature))
lastAttack = OTSYS_TIME();
updateWeapon();
}
}
else if(Weapon::useFist(this, attackedCreature))
lastAttack = OTSYS_TIME();
}
To the following:
Code:
void Player::doAttacking(uint32_t)
{
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* item = getWeapon(false);
if(const Weapon* _weapon = g_weapons->getWeapon(item))
{
if(_weapon->interruptSwing() && !canDoAction())
{
SchedulerTask* task = createSchedulerTask(getAttackSpeed(),
boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
setNextActionTask(task);
}
else
{
if(!_weapon->hasExhaustion() /* || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT))*/ && _weapon->useWeapon(this, item, attackedCreature))
{
lastAttack = OTSYS_TIME();
SchedulerTask* task = createSchedulerTask(getAttackSpeed(),
boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
}
updateWeapon();
}
}
else if(Weapon::useFist(this, attackedCreature))
{
lastAttack = OTSYS_TIME();
SchedulerTask* task = createSchedulerTask(getAttackSpeed(),
boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
}
}
(Basically, I added a SchedulerTask that will check if you can attack your target again when your attackspeed cooldown is over.
So if your attackspeed is 300, it will check if you can attack again in 300ms.
(This will only update players, so if you want creatures to have fast attackspeeds or spellcasts this does not work for that)