• 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!

Fix/Patch Allow auto-attacking without exhaustion + Casting runes while running

Xellath

Member
Joined
Jul 4, 2007
Messages
46
Reaction score
11
I wanted the players on our server to be able to auto attack while still being able to deal damage with offensive spells and do this meanwhile running, so I sat down and looked through the source and turns out this was a rather simple procedure.

Here's how you do it:

Allow auto attacking without exhausting players (EXHAUST_COMBAT):

Open player.cpp and find:

Code:
void Player::doAttacking(uint32_t interval)

In this function you'll find an if statement just like the following:

Code:
else if(!weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) && weapon->useWeapon(this, tool, attackedCreature))

Remove or comment it like this:

Code:
else if(!weapon->hasExhaustion() && weapon->useWeapon(this, tool, attackedCreature))

else if(!weapon->hasExhaustion() /* || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) */ && weapon->useWeapon(this, tool, attackedCreature))

Save and rebuild and you're done.

Casting runes while running:

Easy fix as well -- start by opening player.cpp and find:

Code:
void Player::onWalk(Direction& dir)

You'll find a a function call like the following:

Code:
setNextAction(OTSYS_TIME() + getStepDuration(dir));

Remove or comment it like this:

Code:
//setNextAction(OTSYS_TIME() + getStepDuration(dir));

Save and rebuild and you may run and cast runes/spells without stopping.

Both fixes/changes are stable and thoroughly tested on the TFS 0.3.6pl1 distribution.
 
WOOWOWOOO! I've been waiting for this for long time!! HOPE THIS WORKS :)

- - - Updated - - -

It worked as i wanted, thanks rep+ :)
 
this is for bug of "auto 200 attack target" of elfbot?

sorry my ignorance and bad english to understood the post
 
you have to comment it like
(!weapon->hasExhaustion() && weapon->useWeapon(this, tool, attackedCreature))

but DON'T remove it, otherwise you won't be able to use weapons -_

the instructions are wrong made

else if(!weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT))

you have to remove "|| !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)"

leaving it this way

else if(!weapon->hasExhaustion() ) && weapon->useWeapon(this, tool, attackedCreature))
 
Last edited:
Tried it with blink spell and tp rune and.. still player is delayed, is there some way to bypass it?
 
Adding it to the server, Thank you it's a usefull function.

Only downside. When u add this paralyze will be useless.
 
Last edited:
How to do this for tfs 1.0 please help

Code:
        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();
        }
    }
}
 
How second fix works with paralyze? Basically while you have paral condition and move you can't use potions etc. How it works after fix?
Should I fix paral therfore? I mean, if it paral won't work after this fix, it should be fixed with some exhaustion which is taken separately.
Its not hard. But, you know, there can be someone who can't do this. Or even don't think about it. :p
 
Ok, I did the change but... what I need to do to rebuild?
Never did this before, one friend did for me before
 
Back
Top