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

slot check

Raveyard

Banned User
Joined
May 11, 2025
Messages
29
Reaction score
7
C++:
    // Check for healing element buff
        if (casterPlayer && damage.primary.type == COMBAT_HEALING) {
            int32_t extraHealing = 0;
       
            // Check all equipped items for healing bonus
            for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) {
                Item* item = casterPlayer->getInventoryItem(static_cast<slots_t>(slot));
                if (!item) {
                    continue;
                }

                // Check if item is in the correct slot type "the big hack"
                const ItemType& it = Item::items[item->getID()];
                if (it.slotPosition != 0 && !(it.slotPosition & (1 << slot))) {
                    continue; // Skip items not in their correct slot type
                }

                int32_t value = item->getExtraHealing(COMBAT_HEALING);
                if (value > 0) {
                    // Calculate healing as percentage of the primary healing
                    int32_t primaryHealing = std::abs(damage.primary.value);
                    int32_t extraHealingValue = (primaryHealing * value) / 100;
                    extraHealing += extraHealingValue;
               
                    // Consume a charge if the item has charges
                    uint16_t charges = item->getCharges();
                    if (charges > 0) {
                        g_game.transformItem(item, item->getID(), charges - 1);
                        // We only need to consume one charge total for healing, so break after first charge use
                        break;
                    }
                }
            }
       
            // Apply the extra healing
            if (extraHealing > 0) {
                CombatDamage extraHealingDamage;
                extraHealingDamage.primary.type = COMBAT_HEALING;
                extraHealingDamage.primary.value = extraHealing;
                extraHealingDamage.secondary.type = COMBAT_NONE;
                extraHealingDamage.origin = damage.origin;
           
                g_game.combatChangeHealth(caster, target, extraHealingDamage);
            }
        }
im using extra healing system I added it to item abilities to give % bonus on healing but when i wear items in hands its giving me the bonus and additinally this "solution " makes rings not work in ring slots but i can put armor in armor and in shield slot im pissed af because i get double the bonus despite item not being in its right slot yet giving the ability bonus because of the for loop on top 🤓
ring lefthand not working in ringslot
armor lefthand and armor slot
legs in both hands work does not work in legs slot
boots only in lefthand slot
helmet only in lefthand slot works bonus not in head
necklace in both hands not in necklace

Important: i really wanna keep classicequipmentslots as is. as changing it to false made no difference anyways why are slots so complicated?
Post automatically merged:

after crying in corner i came up with stuff like this
C++:
bool isItemInRightSlot(const Item* item, slots_t currentSlot)
{
    if (!item) {
        return false;
    }
    
    const ItemType& it = Item::items[item->getID()];
    
    // Get human-readable slot name
    std::string slotName;
    switch (currentSlot) {
        case CONST_SLOT_HEAD: slotName = "Head"; break;
        case CONST_SLOT_NECKLACE: slotName = "Necklace"; break;
        case CONST_SLOT_ARMOR: slotName = "Armor"; break;
        case CONST_SLOT_LEGS: slotName = "Legs"; break;
        case CONST_SLOT_FEET: slotName = "Feet"; break;
        case CONST_SLOT_RING: slotName = "Ring"; break;
        case CONST_SLOT_AMMO: slotName = "Ammo"; break;
        case CONST_SLOT_LEFT: slotName = "Left Hand"; break;
        case CONST_SLOT_RIGHT: slotName = "Right Hand"; break;
        case CONST_SLOT_BACKPACK: slotName = "Backpack"; break;
        default: slotName = "Unknown"; break;
    }
    
    // Get allowed slot positions based on item type definition
    uint16_t allowedSlots = it.slotPosition;
    
    // Check if current slot is allowed for this item
    bool result = false;
    
    // Map the current slot to the corresponding SLOTP flag
    uint16_t slotFlag = 0;
    switch (currentSlot) {
        case CONST_SLOT_HEAD:
            slotFlag = SLOTP_HEAD;
            break;
        case CONST_SLOT_NECKLACE:
            slotFlag = SLOTP_NECKLACE;
            break;
        case CONST_SLOT_ARMOR:
            slotFlag = SLOTP_ARMOR;
            break;
        case CONST_SLOT_LEGS:
            slotFlag = SLOTP_LEGS;
            break;
        case CONST_SLOT_FEET:
            slotFlag = SLOTP_FEET;
            break;
        case CONST_SLOT_RING:
            slotFlag = SLOTP_RING;
            break;
        case CONST_SLOT_AMMO:
            slotFlag = SLOTP_AMMO;
            break;
        case CONST_SLOT_LEFT:
            slotFlag = SLOTP_LEFT;
            // Only hand/weapon items should be allowed in hands
            // Check specifically for left hand, two-hand, or general hand flags
            // We DON'T want to allow items like boots in hands!
            if ((allowedSlots & SLOTP_LEFT) ||
                (allowedSlots & SLOTP_TWO_HAND) ||
                ((allowedSlots & SLOTP_HAND) && !(allowedSlots & (SLOTP_HEAD | SLOTP_NECKLACE | SLOTP_ARMOR | SLOTP_LEGS | SLOTP_FEET | SLOTP_RING | SLOTP_AMMO | SLOTP_BACKPACK)))) {
                result = true;
            }
            break;
        case CONST_SLOT_RIGHT:
            slotFlag = SLOTP_RIGHT;
            // Only hand/weapon items should be allowed in hands
            // Check specifically for right hand, two-hand, or general hand flags
            // We DON'T want to allow items like boots in hands!
            if ((allowedSlots & SLOTP_RIGHT) ||
                (allowedSlots & SLOTP_TWO_HAND) ||
                ((allowedSlots & SLOTP_HAND) && !(allowedSlots & (SLOTP_HEAD | SLOTP_NECKLACE | SLOTP_ARMOR | SLOTP_LEGS | SLOTP_FEET | SLOTP_RING | SLOTP_AMMO | SLOTP_BACKPACK)))) {
                result = true;
            }
            break;
        case CONST_SLOT_BACKPACK:
            slotFlag = SLOTP_BACKPACK;
            break;
        default:
            break;
    }
    
    // For all slots except hands, check if slot flag is present in allowed slots
    if (!result && currentSlot != CONST_SLOT_LEFT && currentSlot != CONST_SLOT_RIGHT) {
        if (allowedSlots & slotFlag) {
            result = true;
        }
    }
    
    // Debug output to show item slot information
    std::cout << ">> Item Slot Check: ID=" << item->getID()
        << ", Name='" << it.name << "'"
        << ", Equipped in=" << slotName << " (slot " << static_cast<int>(currentSlot) << ")"
        << ", AllowedSlots=0x" << std::hex << allowedSlots << std::dec
        << ", CurrentSlotFlag=0x" << std::hex << slotFlag << std::dec
        << ", Result=" << (result ? "PASS" : "FAIL")
        << std::endl;
    
    return result;
}
Post automatically merged:

solved.
C++:
bool isItemInRightSlot(const Item* item, slots_t currentSlot)
{
    if (!item) {
        return false;
    }
    
    const ItemType& it = Item::items[item->getID()];
    
    // Get human-readable slot name
    std::string slotName;
    switch (currentSlot) {
        case CONST_SLOT_HEAD: slotName = "Head"; break;
        case CONST_SLOT_NECKLACE: slotName = "Necklace"; break;
        case CONST_SLOT_ARMOR: slotName = "Armor"; break;
        case CONST_SLOT_LEGS: slotName = "Legs"; break;
        case CONST_SLOT_FEET: slotName = "Feet"; break;
        case CONST_SLOT_RING: slotName = "Ring"; break;
        case CONST_SLOT_AMMO: slotName = "Ammo"; break;
        case CONST_SLOT_LEFT: slotName = "Left Hand"; break;
        case CONST_SLOT_RIGHT: slotName = "Right Hand"; break;
        case CONST_SLOT_BACKPACK: slotName = "Backpack"; break;
        default: slotName = "Unknown"; break;
    }
    
    // Get allowed slot positions based on item type definition
    uint16_t allowedSlots = it.slotPosition;
    
    // Check if current slot is allowed for this item
    bool result = false;
    
    // First, determine if this is a non-weapon item meant for specific armor slots
    bool isArmorItem = (allowedSlots & (SLOTP_HEAD | SLOTP_NECKLACE | SLOTP_ARMOR | SLOTP_LEGS | SLOTP_FEET | SLOTP_RING)) != 0;
    bool isHandItem = (allowedSlots & (SLOTP_LEFT | SLOTP_RIGHT | SLOTP_TWO_HAND)) != 0;
    bool isWeapon = it.weaponType != WEAPON_NONE && it.weaponType != WEAPON_SHIELD && it.weaponType != WEAPON_AMMO;
    
    // Map the current slot to the corresponding SLOTP flag
    uint16_t slotFlag = 0;
    switch (currentSlot) {
        case CONST_SLOT_HEAD:
            slotFlag = SLOTP_HEAD;
            result = (allowedSlots & SLOTP_HEAD) != 0;
            break;
        case CONST_SLOT_NECKLACE:
            slotFlag = SLOTP_NECKLACE;
            result = (allowedSlots & SLOTP_NECKLACE) != 0;
            break;
        case CONST_SLOT_ARMOR:
            slotFlag = SLOTP_ARMOR;
            result = (allowedSlots & SLOTP_ARMOR) != 0;
            break;
        case CONST_SLOT_LEGS:
            slotFlag = SLOTP_LEGS;
            result = (allowedSlots & SLOTP_LEGS) != 0;
            break;
        case CONST_SLOT_FEET:
            slotFlag = SLOTP_FEET;
            result = (allowedSlots & SLOTP_FEET) != 0;
            break;
        case CONST_SLOT_RING:
            slotFlag = SLOTP_RING;
            result = (allowedSlots & SLOTP_RING) != 0;
            break;
        case CONST_SLOT_AMMO:
            slotFlag = SLOTP_AMMO;
            result = (allowedSlots & SLOTP_AMMO) != 0;
            break;
        case CONST_SLOT_LEFT:
            slotFlag = SLOTP_LEFT;
            // Simple rule: if it's an armor item in a hand slot, FAIL
            if (isArmorItem) {
                result = false;
            } else if (isWeapon || (allowedSlots & (SLOTP_LEFT | SLOTP_TWO_HAND)) != 0) {
                result = true;
            }
            break;
        case CONST_SLOT_RIGHT:
            slotFlag = SLOTP_RIGHT;
            // Simple rule: if it's an armor item in a hand slot, FAIL
            if (isArmorItem) {
                result = false;
            } else if (isWeapon || (allowedSlots & (SLOTP_RIGHT | SLOTP_TWO_HAND)) != 0) {
                result = true;
            }
            break;
        case CONST_SLOT_BACKPACK:
            slotFlag = SLOTP_BACKPACK;
            result = (allowedSlots & SLOTP_BACKPACK) != 0;
            break;
        default:
            break;
    }
    /*
    // Debug output to show item slot information with weapon type info for hand slots
    std::string debugInfo = ">> Item Slot Check: ID=" + std::to_string(item->getID()) +
        ", Name='" + it.name + "'" +
        ", Equipped in=" + slotName + " (slot " + std::to_string(static_cast<int>(currentSlot)) + ")" +
        ", AllowedSlots=0x" + [&]() { std::stringstream ss; ss << std::hex << allowedSlots; return ss.str(); }() +
        ", CurrentSlotFlag=0x" + [&]() { std::stringstream ss; ss << std::hex << slotFlag; return ss.str(); }();
        */
    // Add weapon type info for hand slots
    if (currentSlot == CONST_SLOT_LEFT || currentSlot == CONST_SLOT_RIGHT) {
        WeaponType_t weaponType = it.weaponType;
        std::string weaponTypeName;
        switch (weaponType) {
            case WEAPON_NONE: weaponTypeName = "None"; break;
            case WEAPON_SWORD: weaponTypeName = "Sword"; break;
            case WEAPON_CLUB: weaponTypeName = "Club"; break;
            case WEAPON_AXE: weaponTypeName = "Axe"; break;
            case WEAPON_SHIELD: weaponTypeName = "Shield"; break;
            case WEAPON_DISTANCE: weaponTypeName = "Distance"; break;
            case WEAPON_WAND: weaponTypeName = "Wand"; break;
            case WEAPON_AMMO: weaponTypeName = "Ammo"; break;
            default: weaponTypeName = "Unknown"; break;
        }
        /*debugInfo += ", WeaponType=" + weaponTypeName;
        debugInfo += ", IsArmorItem=" + std::string(isArmorItem ? "Yes" : "No");
        debugInfo += ", IsHandItem=" + std::string(isHandItem ? "Yes" : "No");
        debugInfo += ", IsWeapon=" + std::string(isWeapon ? "Yes" : "No");*/
    }
    
    //debugInfo += ", Result=" + std::string(result ? "PASS" : "FAIL");
    //std::cout << debugInfo << std::endl;
    
    return result;
}

}
 
Last edited:

Similar threads

Back
Top