• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 1.X+ How to have attack speed scalling with skill level?

Tofame

Advanced OT User
Joined
Aug 17, 2021
Messages
191
Solutions
5
Reaction score
168
Location
Poland
Hi,
I've found this thread:
I changed:
LUA:
uint32_t getAttackSpeed() const;
for
Code:
uint32_t getAttackSpeed() const {
            int32_t SpeedAttack;
            SpeedAttack = vocation->getAttackSpeed() - (getSkill(SKILL_FIST, SKILL_LEVEL) * 10);

            if (SpeedAttack < 500) {
                return 500;
            } else {
                return (uint32_t) SpeedAttack;
            }
        }
My tfs is 1.4.2 and I got errors during compilation:
1661528662521.png
Any solution?
 
Solution
Compiler is saying that getAttackSpeed() already has a body, so we can assume that func is being declared on player.cpp in this case

Leave player.h untouched, go to player.cpp and replace the whole function
C++:
uint32_t Player::getAttackSpeed() const
{
    uint32_t extraSpeed = getSkillLevel(SKILL_FIST) * 10;
    const Item* weapon = getWeapon(true);

    if (!weapon || weapon->getAttackSpeed() == 0) {
        return (vocation->getAttackSpeed() - extraSpeed);
    }

    return (weapon->getAttackSpeed() - extraSpeed);
}
Compiler is saying that getAttackSpeed() already has a body, so we can assume that func is being declared on player.cpp in this case

Leave player.h untouched, go to player.cpp and replace the whole function
C++:
uint32_t Player::getAttackSpeed() const
{
    uint32_t extraSpeed = getSkillLevel(SKILL_FIST) * 10;
    const Item* weapon = getWeapon(true);

    if (!weapon || weapon->getAttackSpeed() == 0) {
        return (vocation->getAttackSpeed() - extraSpeed);
    }

    return (weapon->getAttackSpeed() - extraSpeed);
}
 
Solution
Compiler is saying that getAttackSpeed() already has a body, so we can assume that func is being declared on player.cpp in this case

Leave player.h untouched, go to player.cpp and replace the whole function
C++:
uint32_t Player::getAttackSpeed() const
{
    uint32_t extraSpeed = getSkillLevel(SKILL_FIST) * 10;
    const Item* weapon = getWeapon(true);

    if (!weapon || weapon->getAttackSpeed() == 0) {
        return (vocation->getAttackSpeed() - extraSpeed);
    }

    return (weapon->getAttackSpeed() - extraSpeed);
}
Thank you very much, I compiled and it works.
edited:
Could you tell me that if I wanted to limit speed would this be okay?
C++:
uint32_t Player::getAttackSpeed() const
{
    uint32_t extraSpeed = getSkillLevel(SKILL_FIST) * 10;
    const Item* weapon = getWeapon(true);
    
    if (extraSpeed > 1400) {
        extraSpeed = 1400;
    }

    if (!weapon || weapon->getAttackSpeed() == 0) {
        return (vocation->getAttackSpeed() - extraSpeed);
    }

    return (weapon->getAttackSpeed() - extraSpeed);
}
 
Last edited:
Thank you very much, I compiled and it works.
edited:
Could you tell me that if I wanted to limit speed would this be okay?
C++:
uint32_t Player::getAttackSpeed() const
{
    uint32_t extraSpeed = getSkillLevel(SKILL_FIST) * 10;
    const Item* weapon = getWeapon(true);
 
    if (extraSpeed > 1400) {
        extraSpeed = 1400;
    }

    if (!weapon || weapon->getAttackSpeed() == 0) {
        return (vocation->getAttackSpeed() - extraSpeed);
    }

    return (weapon->getAttackSpeed() - extraSpeed);
}
If you are only seeking to limit AttackS value coming from fist skill, then yes its totally fine
 
Back
Top