• 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
873
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
Weapons.xml "can" have things to do with how attackspeed works. Don't be so fast to be rude to people, he was trying to help.
As for your issue, I am at a loss, honestly it should be working even with the earlier code and maybe even your original code.

The scheduler either does 50 ms or your attackspeed, which means you should be attacking super-fast even standing still.
Are you sure after you compile, you are copying the new TFS.exe over, and running the new server file?

What are you using to compile? Are you running your server on Windows or Linux?
I can only think you are doing something wrong, because if you are following the steps correctly it should be working.
I'm not rude just saying :D copying the new tfs? Ammmm, i dont rly know what you mean by this. But if i add something new to server i exit tfs.exe and run it again. I'm using notepad++ to compile . Running on windows.
 
I'm not rude just saying :D copying the new tfs? Ammmm, i dont rly know what you mean by this. But if i add something new to server i exit tfs.exe and run it again. I'm using notepad++ to compile . Running on windows.

You cannot use Notepad++ to compile.

After saving your changes in Notepad++, you have to "Compile" the server using Visual Studio or another compiler.
This will create a brand new TFS.exe file, which will be what you use when running your server.
 
You cannot use Notepad++ to compile.

After saving your changes in Notepad++, you have to "Compile" the server using Visual Studio or another compiler.
This will create a brand new TFS.exe file, which will be what you use when running your server.
Rofl so that means it might be everything okay if i compile with correct software. So what programs can i use? Because my visual studio just ended free trial :D
 
I don't think the problem has to do with the function, rather that the function is called only when the creature in question "thinks" as can be seen in game.cpp
Code:
creature->onAttacking(EVENT_CREATURE_THINK_INTERVAL);
the onAttacking function in creature.cpp in turn calls the doAttacking function
Code:
if (g_game.isSightClear(getPosition(), attackedCreature->getPosition(), true)) {
    doAttacking(interval);
}

Why did you guys ignore his post? He's right, that's where the attack speed issue is. onAttacking is executed once per second, because thats EVENT_CREATURE_THINK_INTERVAL value.

otland/forgottenserver
otland/forgottenserver
 
Why did you guys ignore his post? He's right, that's where the attack speed issue is. onAttacking is executed once per second, because thats EVENT_CREATURE_THINK_INTERVAL value.

otland/forgottenserver
otland/forgottenserver
Well yea i saw his msg but i though if Flatlander saying nothing about it maybe that dude is wrong. But i'll try to change value but anyway i need software to compile creature.h file.
 
Why did you guys ignore his post? He's right, that's where the attack speed issue is. onAttacking is executed once per second, because thats EVENT_CREATURE_THINK_INTERVAL value.

otland/forgottenserver
otland/forgottenserver
In the onAttacking function, it schedules another "creatureCheck" in the scheduler.

This is exactly like doing an addEvent.

So there are 3 ways onAttacking can be called.
  1. Every time your creature thinks (onThink)
  2. Every time you, or a nearby creature moves. (onWalk)
  3. Scheduled event - repeats at your AttackSpeed interval.

The below function schedules an event to happen in the future.
g_scheduler.addEvent(task);

You can create a task using the following function:
SchedulerTask* task = createSchedulerTask(interval, function);

So TFS schedules the following:
SchedulerTask* task = createSchedulerTask(std::max<uint32_t>(SCHEDULER_MINTICKS, delay), std::bind(&Game::checkCreatureAttack, &g_game, getID()));

So I will break this down into details:
  • std::max<uint32_t>(SCHEDULER_MINTICKS, delay)
    • This function picks whichever number is higher. It's purpose is to make sure you cannot attack faster than SCHEDULER_MINTICKS, to avoid people causing lag with 1 ms attackspeeds.
  • std::bind(&Game::checkCreatureAttack, &g_game, getID())
    • This function tells the server to check if you can attack again. We use this instead of "doAttacking" to make sure the creature still exists when the function is called.
 
Ey Flatlander, are you a DEVELOPER?

I have been working on OT Servers for like.... 10+ years?

I'm not an official contributor to the TFS Project, but I know my way around the code pretty well, the reason we weren't able to accurately test my solutions to his problem was because he was not compiling correctly. (I'm not amazing at programming the source code of TFS 1.X, I haven't used it much and am way more used to TFS 0.X)
Also, I think the doAttacking script he originally posted should have worked, I am unsure on if the current version of TFS he is running his server on was built form the source code he has.
 
I have been working on OT Servers for like.... 10+ years?

I'm not an official contributor to the TFS Project, but I know my way around the code pretty well, the reason we weren't able to accurately test my solutions to his problem was because he was not compiling correctly. (I'm not amazing at programming the source code of TFS 1.X, I haven't used it much and am way more used to TFS 0.X)
Also, I think the doAttacking script he originally posted should have worked, I am unsure on if the current version of TFS he is running his server on was built form the source code he has.
I'm using this downgraded version.
[8.60] The Forgotten Server 1.2
 
Solution
I just checked the Source Code from that and it doesn't match what you gave me for your doAttacking function in Player.cpp.
[8.60] The Forgotten Server 1.2
ninjalulz/forgottenserver
ninjalulz/forgottenserver

if you are going to compile, I would download the newest sources from this distro and use it: It looks like he is keeping it up-to-date at least a little bit.
ninjalulz/forgottenserver
Thanks i'll try to compile tomorrow. Stupid Quick question. My protocol will change or it will stay how it is 8.60?
 
Thanks to @Flatlander now we can close this thread. Solution is replace your old void Player::doAttacking(uint32_t) to this one
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);
        uint32_t delay = getAttackSpeed();

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

        SchedulerTask* task = createSchedulerTask(std::max<uint32_t>(SCHEDULER_MINTICKS, delay), std::bind(&Game::checkCreatureAttack, &g_game, getID()));
        g_scheduler.addEvent(task);

        if (result) {
            lastAttack = OTSYS_TIME();
        }
    }
}
And the most important after you replaced. Compile your source.
 
Back
Top