• 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++ Ammunition from bag

Geekbuddys

Member
Joined
Mar 15, 2014
Messages
164
Reaction score
19
Anyone know whats need to be changed for make ammunation been taken directly from the bag and not need to be pushed up to arrow slot.

Thanks in advance.
 
For TFS 1.4.2

C++:
Item* Player::getWeapon(slots_t slot, bool ignoreAmmo) const
{
    Item* item = inventory[slot];
    if (!item) {
        return nullptr;
    }

    WeaponType_t weaponType = item->getWeaponType();
    if (weaponType == WEAPON_NONE || weaponType == WEAPON_SHIELD || weaponType == WEAPON_AMMO) {
        return nullptr;
    }

    if (!ignoreAmmo && weaponType == WEAPON_DISTANCE) {
        const ItemType& it = Item::items[item->getID()];
        if (it.ammoType != AMMO_NONE) {
            // Najpierw sprawdź, czy amunicja jest w slocie amunicji
            Item* ammoItem = inventory[CONST_SLOT_AMMO];
            if (!ammoItem || ammoItem->getAmmoType() != it.ammoType) {
                // Jeśli nie, przeszukaj plecak
                Container* backpack = dynamic_cast<Container*>(inventory[CONST_SLOT_BACKPACK]);
                if (backpack) {
                    for (Item* backpackItem : backpack->getItemList()) {
                        if (backpackItem && backpackItem->getAmmoType() == it.ammoType) {
                            ammoItem = backpackItem;
                            break;
                        }
                    }
                }
            }
            if (!ammoItem) {
                return nullptr;
            }
            item = ammoItem;
        }
    }
    return item;
}
 
Back
Top