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

TFS 1.X+ Fast attack based on fist fighting source edit--player.cpp edit TFS 1.5

tuduras

Well-Known Member
Joined
Jun 4, 2017
Messages
351
Solutions
2
Reaction score
59
Hello Otland!
I ve got on server Fast Attack system based on fist fighting. I followed this Tfs 0.4 0.4.6 & Otx Fast Attack by 2 Steps (Actualizado) (https://otland.net/threads/tfs-0-4-0-4-6-otx-fast-attack-by-2-steps-actualizado.258761/)
and with AI i create
LUA:
uint32_t Player::getAttackSpeed() const
{
    // 1. Critical safeguard: TFS 1.5 calls this function during object creation.
    // If there is no vocation or skill structure, return a safe default.
    if (!vocation || !skills) {
        return 1000;
    }

    // 2. Get base speed from vocation (vocation->getAttackSpeed() returns uint32_t)
    int32_t baseSpeed = static_cast<int32_t>(vocation->getAttackSpeed());

    // 3. Get skill level in a safe way for TFS 1.x
    // getSkillLevel returns the raw skill level (e.g., 10, 50, 100)
    int32_t fistLevel = static_cast<int32_t>(getSkillLevel(SKILL_FIST));

    // 4. Calculate the new interval
    int32_t calculatedSpeed = baseSpeed - (fistLevel * 10);

    // 5. Hardcap at 200 ms
    // Using std::max for better readability and safety
    return static_cast<uint32_t>(std::max<int32_t>(200, calculatedSpeed));
}

and when I login to the server, it crashes after few moments. What do I wrong?

Best Regards!
 
A null pointer in the attack system – for example, weapon/tool is already nullptr at player init, or getAttackSpeed returns an incorrect value and breaks the attack scheduler from the start. So, it's not about combat, but about the attack system being triggered in Player:onLogin / doAttacking and encountering a lack of weapons / fist system.
 
Back
Top