Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attack scheduler #1305

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/player.cpp
Expand Up @@ -3383,16 +3383,18 @@ void Player::doAttacking(uint32_t)
Item* tool = getWeapon();
const Weapon* weapon = g_weapons->getWeapon(tool);
if (weapon) {
if (!weapon->interruptSwing()) {
uint32_t delay;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        if (weapon->interruptSwing() && !canDoAction()) {
            delay = getNextActionTime();
        } else {
            result = weapon->useWeapon(this, tool, attackedCreature);
            delay = getAttackSpeed();
        }

        SchedulerTask* task = createSchedulerTask(delay, std::bind(&Game::checkCreatureAttack,
                              &g_game, getID()));
        setNextActionTask(task);

Where this change affect distance weapons too :)

if (!weapon->interruptSwing() || canDoAction()) {
result = weapon->useWeapon(this, tool, attackedCreature);
} else if (!canDoAction()) {
uint32_t delay = getNextActionTime();
SchedulerTask* task = createSchedulerTask(delay, std::bind(&Game::checkCreatureAttack,
&g_game, getID()));
setNextActionTask(task);
delay = getAttackSpeed();
} else {
result = weapon->useWeapon(this, tool, attackedCreature);
delay = getNextActionTime();
}

SchedulerTask* task = createSchedulerTask(delay, std::bind(&Game::checkCreatureAttack,
&g_game, getID()));
setNextActionTask(task);
} else {
result = Weapon::useFist(this, attackedCreature);
}
Expand Down