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

Xellath

Member
Joined
Jul 4, 2007
Messages
46
Best answers
0
Reaction score
8
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.
 

WarOfTheTitans

Active Member
Joined
Feb 3, 2012
Messages
430
Best answers
0
Reaction score
35
WOOWOWOOO! I've been waiting for this for long time!! HOPE THIS WORKS :)

- - - Updated - - -

It worked as i wanted, thanks rep+ :)
 

Schten

Member
Joined
Jun 26, 2012
Messages
49
Best answers
0
Reaction score
2
Location
Sweden
Awesome! I've been searching for this!

-- Thanks!
 

Vrotz

Active Member
Joined
Apr 7, 2011
Messages
1,071
Best answers
0
Reaction score
7
Location
Brazil
this is for bug of "auto 200 attack target" of elfbot?

sorry my ignorance and bad english to understood the post
 

tatanxx

Excellent OT User
Joined
Jan 5, 2009
Messages
61
Best answers
0
Reaction score
1
Location
Chile
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:

adif1

Well-Known Member
Joined
Mar 20, 2010
Messages
42
Best answers
0
Reaction score
0
This fix its for tfs 3884?
 

margoh

{{ user.title }}
Joined
Apr 1, 2013
Messages
689
Best answers
9
Reaction score
229
Tried it with blink spell and tp rune and.. still player is delayed, is there some way to bypass it?
 

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
Adding it to the server, Thank you it's a usefull function.

Only downside. When u add this paralyze will be useless.
 
Last edited:

gurden

i need support for my server, good scripter!
Joined
May 19, 2009
Messages
520
Best answers
0
Reaction score
4
Location
Sweden
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();
        }
    }
}
 

Shadowman321

Member
Joined
Mar 27, 2010
Messages
182
Best answers
0
Reaction score
11
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
 

God Triaca

Excellent OT User
Joined
Dec 13, 2008
Messages
23
Best answers
0
Reaction score
1
Ok, I did the change but... what I need to do to rebuild?
Never did this before, one friend did for me before
 

MartK

Member
Joined
Dec 6, 2018
Messages
42
Best answers
1
Reaction score
14
Yes rebuild all. and all works good 100%
 
Top