Member
- Joined
- Mar 7, 2023
- Messages
- 36
- Solutions
- 1
- Reaction score
- 12
Engine: TFS 1.5 (Nekiro Downgrade)
Tibia Version: 8.60
Is there any solution for the attack speed issue in TFS 1.5 version 8.60 downgraded by Nekiro? I ask because having the "classicAttackSpeed" boolean activated causes very high CPU usage, which causes lag on the server. When "classicAttackSpeed" is disabled, CPU usage drops by 70%.
The problem seems to come from the "doAttacking" function in the player.cpp file... This is the TFS 1.5 doAttacking:
And here is another type of "doAttacking" from OTX 2 (based on TFS 0.3.7, older version), I'm only putting it here because it's done differently:
I have no idea if the attack speed is better processed in OTX 2, I only know that TFS 1.5 does not have a good way of processing attacks, which causes very high CPU usage.
BUMP
Tibia Version: 8.60
Is there any solution for the attack speed issue in TFS 1.5 version 8.60 downgraded by Nekiro? I ask because having the "classicAttackSpeed" boolean activated causes very high CPU usage, which causes lag on the server. When "classicAttackSpeed" is disabled, CPU usage drops by 70%.
The problem seems to come from the "doAttacking" function in the player.cpp file... This is the TFS 1.5 doAttacking:
C++:
void Player::doAttacking(uint32_t)
{
if (lastAttack == 0) {
lastAttack = OTSYS_TIME() - getAttackSpeed() - 1;
}
if (hasCondition(CONDITION_PACIFIED)) {
return;
}
if ((OTSYS_TIME() - lastAttack) >= getAttackSpeed()) {
bool result = false;
Item* tool = getWeapon();
const Weapon* weapon = g_weapons->getWeapon(tool);
uint32_t delay = getAttackSpeed();
bool classicSpeed = g_config.getBoolean(ConfigManager::CLASSIC_ATTACK_SPEED);
if (weapon) {
if (!weapon->interruptSwing()) {
result = weapon->useWeapon(this, tool, attackedCreature);
} else if (!classicSpeed && !canDoAction()) {
delay = getNextActionTime();
} else {
result = weapon->useWeapon(this, tool, attackedCreature);
}
} else {
result = Weapon::useFist(this, attackedCreature);
}
SchedulerTask* task = createSchedulerTask(std::max<uint32_t>(SCHEDULER_MINTICKS, delay), std::bind(&Game::checkCreatureAttack, &g_game, getID()));
if (!classicSpeed) {
setNextActionTask(task, false);
} else {
g_scheduler.addEvent(task);
}
if (result) {
lastAttack = OTSYS_TIME();
}
}
}
And here is another type of "doAttacking" from OTX 2 (based on TFS 0.3.7, older version), I'm only putting it here because it's done differently:
C++:
void Player::doAttacking(uint32_t)
{
uint32_t attackSpeed = getAttackSpeed();
if(attackSpeed == 0 || (hasCondition(CONDITION_PACIFIED) && !hasCustomFlag(PlayerCustomFlag_IgnorePacification)))
{
lastAttack = OTSYS_TIME();
return;
}
if(!lastAttack)
lastAttack = OTSYS_TIME() - attackSpeed - 1;
else if((OTSYS_TIME() - lastAttack) < attackSpeed)
return;
if(const Weapon* _weapon = g_weapons->getWeapon(weapon))
{
if(!g_config.getBool(ConfigManager::CLASSIC_ATTACK_SPEED) && _weapon->interruptSwing() && !canDoAction())
{
SchedulerTask* task = createSchedulerTask(getNextActionTime(),
boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
setNextActionTask(task);
}
else
{
if((!_weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST)) && _weapon->useWeapon(this, weapon, attackedCreature))
lastAttack = OTSYS_TIME();
updateWeapon();
}
}
else if(Weapon::useFist(this, attackedCreature))
lastAttack = OTSYS_TIME();
}
I have no idea if the attack speed is better processed in OTX 2, I only know that TFS 1.5 does not have a good way of processing attacks, which causes very high CPU usage.
Someone who can help with this please

BUMP