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

C++ Tfs 1.2 New attribute key

Hidroponica

Member
Joined
Feb 16, 2016
Messages
75
Reaction score
8
Hello everyone, Im editing my sources trying to add a new attribute to the game using example like this post Feature - [TFS 1.2] Reflection attribute

but the effect of the attribute only works when i relog my character

here are some of my editions
could someone tell me what i can do to proceed

enums.h
C++:
    ITEM_ATTRIBUTE_EXTRAMELEE = 1 << 27,

player.h
C++:
        int32_t getExtraMelee() const {
            if (hasAttribute(ITEM_ATTRIBUTE_EXTRAMELEE)) {
                return getIntAttr(ITEM_ATTRIBUTE_EXTRAMELEE);
            }
            return items[id].extraMelee;
        }

player.cpp
C++:
case ATTR_EXTRAMELEE: {
            int32_t extraMelee;
            if (!propStream.read<int32_t>(extraMelee)) {
                std::cout << "ATTR_EXTRAMELEE: " << "READ ERRORi: " << ATTR_READ_ERROR << std::endl;
                return ATTR_READ_ERROR;  
            }
            std::cout << "setIntAttr: " << extraMelee << std::endl;
            setIntAttr(ITEM_ATTRIBUTE_EXTRAMELEE, extraMelee);
            break;
        }


    if (hasAttribute(ITEM_ATTRIBUTE_EXTRAMELEE)) {
        std::cout << "hasAttribute(ITEM_ATTRIBUTE_EXTRAMELEE)" << std::endl;
        propWriteStream.write<uint8_t>(ATTR_EXTRAMELEE);
        propWriteStream.write<int32_t>(getIntAttr(ITEM_ATTRIBUTE_EXTRAMELEE));
    }

player.h
C++:
changed this place :
uint16_t getSkillLevel(uint8_t skill) const {
            int v = (int) getVocationId();
            if (v != 4 && v != 5 && v != 7 && v != 8 && v != 11 && v != 12) {
                return std::max<int32_t>(0, skills[skill].level + varSkills[skill]);
            }
            return std::max<int32_t>(0, skills[skill].level + varSkills[skill] + getExtraMelee());
        }

player.cpp
C++:
int32_t Player::getExtraMelee() const
{
    int32_t melee = 0;
    static const slots_t all[] = {CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING, CONST_SLOT_RIGHT, CONST_SLOT_LEFT};

    for (slots_t slot : all) {
        Item* inventoryItem = inventory[slot];
        if (inventoryItem)
            melee += inventoryItem->getExtraMelee();
    }

    return melee;
}
 
Back
Top