• 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+ Bug with dodge system

bertosso

Member
Joined
Apr 27, 2024
Messages
13
Solutions
1
Reaction score
5
Location
Brasil
Twitch
bertosso
YouTube
KBertosso
Hello, Im having a really strange bug on my server.

When i put the dodge system i got 2 bugs that happens:

1st: My task module stop working.

1745445675494.webp


2nd: When dying the character just stands there.

1745445725360.webp

The client show this errors:

1745445767212.webp

If I disable the dodge system both things work normaly, and i cant think how this things are related, but its what happens.

This is my dodge scripts:

condition.cpp

Code:
        case CONDITION_PARAM_SPECIALSKILL_DODGECHANCE: {
            specialSkills[SPECIALSKILL_DODGECHANCE] = value;
            return true;
        }

tools.cpp

Code:
std::string getSpecialSkillName(uint8_t skillid)
{
    switch (skillid) {
        case SPECIALSKILL_CRITICALHITCHANCE:
            return "critical hit chance";

        case SPECIALSKILL_CRITICALHITAMOUNT:
            return "critical extra damage";

        case SPECIALSKILL_LIFELEECHCHANCE:
            return "hitpoints leech chance";

        case SPECIALSKILL_LIFELEECHAMOUNT:
            return "hitpoints leech amount";

        case SPECIALSKILL_MANALEECHCHANCE:
            return "manapoints leech chance";

        case SPECIALSKILL_MANALEECHAMOUNT:
            return "mana points leech amount";
        
        case SPECIALSKILL_DODGECHANCE:
            return "dodge chance";

        default:
            return "unknown";
    }
}

luascript.cpp

Code:
registerEnum(CONDITION_PARAM_SPECIALSKILL_DODGECHANCE)

registerEnum(SPECIALSKILL_DODGECHANCE)

items.h

Code:
ITEM_PARSE_DODGECHANCE,

items.cpp

Code:
"dodgechance", ITEM_PARSE_DODGECHANCE},

case ITEM_PARSE_DODGECHANCE: {
    abilities.specialSkills[SPECIALSKILL_DODGECHANCE] = pugi::cast<int32_t>(valueAttribute.value());
    break;
}
                
{"dodgechance", ITEM_PARSE_DODGECHANCE},

game.cpp

Code:
    if (Player* targetPlayer = target->getPlayer()) {
        int32_t dodgeChance = targetPlayer->getSpecialSkill(SPECIALSKILL_DODGECHANCE);

        if (dodgeChance > 0) {
            int32_t roll = uniform_random(0, 100);

            if (roll < dodgeChance) {
                g_game.addMagicEffect(targetPlayer->getPosition(), 174);
                // targetPlayer->sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dodged an attack!");
                return true;
            }
        }
    }

enums.h

Code:
CONDITION_PARAM_SPECIALSKILL_DODGECHANCE = 64

enum SpecialSkills_t {
    SPECIALSKILL_CRITICALHITCHANCE,
    SPECIALSKILL_CRITICALHITAMOUNT,
    SPECIALSKILL_LIFELEECHCHANCE,
    SPECIALSKILL_LIFELEECHAMOUNT,
    SPECIALSKILL_MANALEECHCHANCE,
    SPECIALSKILL_MANALEECHAMOUNT,
    SPECIALSKILL_DODGECHANCE,

    SPECIALSKILL_FIRST = SPECIALSKILL_CRITICALHITCHANCE,
    SPECIALSKILL_LAST = SPECIALSKILL_DODGECHANCE
};
 
Solution
Your bytes are not matching.
You can either edit TFS source to not send your dodge chance bytes to OTC
or edit OTC to read the additional bytes it gets from dodgechance.

OTC related method:
C++:
void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg)
I think probably adding enum in here will work? Well, obviously if otc gets sent new skill, you gotta manage it, so might be more.
C++:
    enum Skill {
        Fist = 0,
        Club,
        Sword,
        Axe,
        Distance,
        Shielding,
        Fishing,
        CriticalChance,
        CriticalDamage,
        LifeLeechChance,
        LifeLeechAmount,
        ManaLeechChance,
        ManaLeechAmount,
        LastSkill
    };

TFS (worse, workaround tbh):
C++:
void...
Your bytes are not matching.
You can either edit TFS source to not send your dodge chance bytes to OTC
or edit OTC to read the additional bytes it gets from dodgechance.

OTC related method:
C++:
void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg)
I think probably adding enum in here will work? Well, obviously if otc gets sent new skill, you gotta manage it, so might be more.
C++:
    enum Skill {
        Fist = 0,
        Club,
        Sword,
        Axe,
        Distance,
        Shielding,
        Fishing,
        CriticalChance,
        CriticalDamage,
        LifeLeechChance,
        LifeLeechAmount,
        ManaLeechChance,
        ManaLeechAmount,
        LastSkill
    };

TFS (worse, workaround tbh):
C++:
void ProtocolGame::AddPlayerSkills(NetworkMessage& msg) const
(the SPECIALSKILL_LAST in this method can be swapped to e.g. SPECIALSKILL_MANALEECHAMOUNT or SPECIALSKILL_LAST - 1
 
Solution
Your bytes are not matching.
You can either edit TFS source to not send your dodge chance bytes to OTC
or edit OTC to read the additional bytes it gets from dodgechance.

OTC related method:
C++:
void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg)
I think probably adding enum in here will work? Well, obviously if otc gets sent new skill, you gotta manage it, so might be more.
C++:
    enum Skill {
        Fist = 0,
        Club,
        Sword,
        Axe,
        Distance,
        Shielding,
        Fishing,
        CriticalChance,
        CriticalDamage,
        LifeLeechChance,
        LifeLeechAmount,
        ManaLeechChance,
        ManaLeechAmount,
        LastSkill
    };

TFS (worse, workaround tbh):
C++:
void ProtocolGame::AddPlayerSkills(NetworkMessage& msg) const
(the SPECIALSKILL_LAST in this method can be swapped to e.g. SPECIALSKILL_MANALEECHAMOUNT or SPECIALSKILL_LAST - 1


Tried to add dodge to the enum but it broke the client, so yeah i guess i gonna need to make more changes like you mentioned.

Gonna try it later to see if i manage to fix
 
Back
Top