Pifafa
Well-Known Member
- Joined
- Nov 9, 2010
- Messages
- 108
- Reaction score
- 51
Good morning dear friends, how can I prohibit the use of fast attack scripts on my server? Players who use them attack slightly faster than normal, which is detrimental to the game.
I tried a few improvements but nothing has worked yet.
I tried a few improvements but nothing has worked yet.
C++:
// 3. PROTEÇÃO ANTI-FAST ATTACK (Aqui está a mudança)
if (creature) {
g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID())));
// Calcula quanto tempo passou desde o último ataque
int64_t diff = OTSYS_TIME() - lastAttack;
// Se o tempo que passou for MAIOR que a velocidade, pode atacar agora.
if (diff >= getAttackSpeed()) {
g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID())));
}
// Se for MENOR (está no cooldown), nós AGENDAMOS o ataque para o futuro.
// Isso impede o exploit, mas garante que o ataque saia na hora certa sem travar o char.
else {
g_scheduler.addEvent(createSchedulerTask(getAttackSpeed() - diff, std::bind(&Game::checkCreatureAttack, &g_game, getID())));
}
}
return true;
}