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

Certain Equip in each slot

Exura ATS

New Member
Joined
Feb 5, 2017
Messages
72
Reaction score
4
Hi everyone!

I was thinking about a script or variations that make equipments be equiped in your respective slots.
For example:

Helmets can be equiped only in head;
Swords, Wands, Bows only be equiped in left hand;
Shields only in right hand;
In ammo slot only can be equiped arrows and items that provide light;
etc...

If someone knows how to do that, can help me here?
 
this should already be implemented in the latest versions of tfs, in config.lua you can also change it if it does not work already
classicEquipmentSlots = true
 
Don't they do that already?
No, I can equip any items in ammo and both hands slots.

this should already be implemented in the latest versions of tfs, in config.lua you can also change it if it does not work already
classicEquipmentSlots = true
It's not working even with this variation on config.lua.
My tfs is 0.3.7
 
in player.cpp replace Player::__queryAdd with this:
C++:
ReturnValue Player::__queryAdd(int32_t index, const Thing* thing, uint32_t count, uint32_t flags, Creature* actor/* = NULL*/) const
{
    const Item* item = thing->getItem();
    if(item == NULL)
        return RET_NOTPOSSIBLE;

    bool childIsOwner = hasBitSet(FLAG_CHILDISOWNER, flags);
    bool skipLimit = hasBitSet(FLAG_NOLIMIT, flags);
    if(childIsOwner)
    {
        //a child container is querying the player, just check if enough capacity
        if(skipLimit || hasCapacity(item, count))
            return RET_NOERROR;

        return RET_NOTENOUGHCAPACITY;
    }

    if(!item->isPickupable())
        return RET_CANNOTPICKUP;

    ReturnValue ret = RET_NOERROR;
    const int32_t& slotPosition = item->getSlotPosition();
    if((slotPosition & SLOTP_HEAD) || (slotPosition & SLOTP_NECKLACE) ||
        (slotPosition & SLOTP_BACKPACK) || (slotPosition & SLOTP_ARMOR) ||
        (slotPosition & SLOTP_LEGS) || (slotPosition & SLOTP_FEET) ||
        (slotPosition & SLOTP_RING)) {
        ret = RET_CANNOTBEDRESSED;
    } else if(slotPosition & SLOTP_TWO_HAND) {
        ret = RET_PUTTHISOBJECTINBOTHHANDS;
    } else if((slotPosition & SLOTP_RIGHT) || (slotPosition & SLOTP_LEFT)) {
        if (!g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
            ret = RET_CANNOTBEDRESSED;
        } else {
            ret = RET_PUTTHISOBJECTINYOURHAND;
        }
    }

    switch(index)
    {
        case SLOT_HEAD:
        {
            if(slotPosition & SLOTP_HEAD)
                ret = RET_NOERROR;

            break;
        }

        case SLOT_NECKLACE:
        {
            if(slotPosition & SLOTP_NECKLACE)
                ret = RET_NOERROR;

            break;
        }

        case SLOT_BACKPACK:
        {
            if(slotPosition & SLOTP_BACKPACK)
                ret = RET_NOERROR;

            break;
        }

        case SLOT_ARMOR:
        {
            if(slotPosition & SLOTP_ARMOR)
                ret = RET_NOERROR;

            break;
        }

        case SLOT_RIGHT:
        {
            if(slotPosition & SLOTP_RIGHT)
            {
                if (!g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
                    //check if we already carry an item in the other hand
                    if(slotPosition & SLOTP_TWO_HAND) {
                        if(inventory[SLOT_LEFT] && inventory[SLOT_LEFT] != item)
                            ret = RET_BOTHHANDSNEEDTOBEFREE;
                        else
                            ret = RET_NOERROR;
                    }
                } else if (slotPosition & SLOTP_TWO_HAND) {
                    if (inventory[SLOT_LEFT] && inventory[SLOT_LEFT] != item) {
                        ret = RET_BOTHHANDSNEEDTOBEFREE;
                    } else {
                        ret = RET_NOERROR;
                    }
                } else if(inventory[SLOT_LEFT]) {
                    const Item* leftItem = inventory[SLOT_LEFT];
                    WeaponType_t type = item->getWeaponType(), leftType = leftItem->getWeaponType();
                    if(leftItem->getSlotPosition() & SLOTP_TWO_HAND)
                        ret = RET_DROPTWOHANDEDITEM;
                    else if(item == leftItem && count == item->getItemCount())
                        ret = RET_NOERROR;
                    else if(leftType == WEAPON_SHIELD && type == WEAPON_SHIELD)
                        ret = RET_CANONLYUSEONESHIELD;
                    else if(leftType == WEAPON_NONE || type == WEAPON_NONE ||
                        leftType == WEAPON_SHIELD || leftType == WEAPON_AMMO
                        || type == WEAPON_SHIELD || type == WEAPON_AMMO)
                        ret = RET_NOERROR;
                    else
                        ret = RET_CANONLYUSEONEWEAPON;
                } else {
                    ret = RET_NOERROR;
                }
            }
            break;
        }

        case SLOT_LEFT:
        {
            if(slotPosition & SLOTP_LEFT)
            {
                if (!g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
                    //check if we already carry an item in the other hand
                    if(slotPosition & SLOTP_TWO_HAND) {
                        if(inventory[SLOT_RIGHT] && inventory[SLOT_RIGHT] != item)
                            ret = RET_BOTHHANDSNEEDTOBEFREE;
                        else
                            ret = RET_NOERROR;
                    }
                } else if (slotPosition & SLOTP_TWO_HAND) {
                    if (inventory[SLOT_RIGHT] && inventory[SLOT_RIGHT] != item) {
                        ret = RET_BOTHHANDSNEEDTOBEFREE;
                    } else {
                        ret = RET_NOERROR;
                    }
                } else if(inventory[SLOT_RIGHT]) {
                    const Item* leftItem = inventory[SLOT_RIGHT];
                    WeaponType_t type = item->getWeaponType(), leftType = leftItem->getWeaponType();
                    if(leftItem->getSlotPosition() & SLOTP_TWO_HAND)
                        ret = RET_DROPTWOHANDEDITEM;
                    else if(item == leftItem && count == item->getItemCount())
                        ret = RET_NOERROR;
                    else if(leftType == WEAPON_SHIELD && type == WEAPON_SHIELD)
                        ret = RET_CANONLYUSEONESHIELD;
                    else if(leftType == WEAPON_NONE || type == WEAPON_NONE ||
                        leftType == WEAPON_SHIELD || leftType == WEAPON_AMMO
                        || type == WEAPON_SHIELD || type == WEAPON_AMMO)
                        ret = RET_NOERROR;
                    else
                        ret = RET_CANONLYUSEONEWEAPON;
                } else {
                    ret = RET_NOERROR;
                }
            }
            break;
        }

        case SLOT_LEGS:
        {
            if(slotPosition & SLOTP_LEGS)
                ret = RET_NOERROR;

            break;
        }

        case SLOT_FEET:
        {
            if(slotPosition & SLOTP_FEET)
                ret = RET_NOERROR;

            break;
        }

        case SLOT_RING:
        {
            if(slotPosition & SLOTP_RING)
                ret = RET_NOERROR;

            break;
        }

        case SLOT_AMMO:
        {
            if(slotPosition & SLOTP_AMMO || !g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS))
                ret = RET_NOERROR;

            break;
        }

        case SLOT_WHEREEVER:
        case -1:
            ret = RET_NOTENOUGHROOM;
            break;

        default:
            ret = RET_NOTPOSSIBLE;
            break;
    }

    if(ret == RET_NOERROR || ret == RET_NOTENOUGHROOM)
    {
        //need an exchange with source?
        if(getInventoryItem((slots_t)index) != NULL && (!getInventoryItem((slots_t)index)->isStackable()
            || getInventoryItem((slots_t)index)->getID() != item->getID()))
            return RET_NEEDEXCHANGE;

        if(!g_moveEvents->onPlayerEquip(const_cast<Player*>(this), const_cast<Item*>(item), (slots_t)index, true))
            return RET_CANNOTBEDRESSED;

        //check if enough capacity
        if(!hasCapacity(item, count))
            return RET_NOTENOUGHCAPACITY;
    }

    return ret;
}

in configmanager.cpp
under
C++:
m_confBool[ALLOW_CHANGEOUTFIT] = getGlobalBool("allowChangeOutfit", true);
put
C++:
m_confBool[CLASSIC_EQUIPMENT_SLOTS] = getGlobalBool("classicEquipmentSlots", false);

in configmanager.h
under
C++:
ALLOW_CHANGEOUTFIT,
put
C++:
CLASSIC_EQUIPMENT_SLOTS,
 
@Xeraphus Well, I don't have these archives. I have downloaded a OT pack already compiled.
How can I get these archives? (sorry, my first experience with ots, I'm a newcomer :x)
 
Back
Top