• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

For some reason attack speed didn't change

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
870
Solutions
2
Reaction score
49
Hi
so today i tried to balance vocation and first step was attack speed orginal was 2000 i changed to attackspeed="1200" with that much attackspeed i should attack really fast and i applied club fighting 175 and i attack really, really slow its like nothing changed from original. If u need some kind of code just say because now i have no idea where to check or what to send.
 
Solution
Player.cpp:
Change:
Code:
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);
        if (weapon) {
            if (!weapon->interruptSwing()) {
                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);
            } else {
                result = weapon->useWeapon(this, tool, attackedCreature);
            }
        } else {
            result = Weapon::useFist(this, attackedCreature);
        }

        if (result) {
            lastAttack = OTSYS_TIME();
        }
    }
}
To:
Code:
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);
        if (weapon) {
            if (!weapon->interruptSwing()) {
                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);
            } else {
                result = weapon->useWeapon(this, tool, attackedCreature);
            }
        } else {
            result = Weapon::useFist(this, attackedCreature);
        }

        g_scheduler.addEvent(createSchedulerTask(std::max<uint32_t>(SCHEDULER_MINTICKS, getAttackSpeed()), std::bind(&Game::checkCreatureAttack, &g_game, getID())));
        if (result) {
            lastAttack = OTSYS_TIME();
        }
    }
}
With this your attack speed should work without making creatures thinks too much(xD).

@Lopaskurwa
How the hell scheduling next attack after the previous might not work when you stand? Devs even added this in 1.3 for custom servers with "custom attack speed"
 
Last edited:
Player.cpp:
Change:
Code:
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);
        if (weapon) {
            if (!weapon->interruptSwing()) {
                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);
            } else {
                result = weapon->useWeapon(this, tool, attackedCreature);
            }
        } else {
            result = Weapon::useFist(this, attackedCreature);
        }

        if (result) {
            lastAttack = OTSYS_TIME();
        }
    }
}
To:
Code:
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);
        if (weapon) {
            if (!weapon->interruptSwing()) {
                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);
            } else {
                result = weapon->useWeapon(this, tool, attackedCreature);
            }
        } else {
            result = Weapon::useFist(this, attackedCreature);
        }

        g_scheduler.addEvent(createSchedulerTask(std::max<uint32_t>(SCHEDULER_MINTICKS, getAttackSpeed()), std::bind(&Game::checkCreatureAttack, &g_game, getID())));
        if (result) {
            lastAttack = OTSYS_TIME();
        }
    }
}
With this your attack speed should work without making creatures thinks too much(xD).
Thanks for answer but this script doesn't change exactly what i meant. So now it attacks faster if monster moves :D But i need the same attack speed when i stand, run, or monster run/stand. Because now i only attack fast if i run around or monster run around :D
 
Normally it should work, may you skiped something or take the original 8.6 and have fun.

God knows what and how they did that.
 
Normally it should work, may you skiped something or take the original 8.6 and have fun.

God knows what and how they did that.
Maybe creator of this downgraded tfs version did something i have no idea. I think i cant use original 1.2 player.cpp source file because mine is downgraded.
 
Back
Top