mod-transmog icon indicating copy to clipboard operation
mod-transmog copied to clipboard

Suggestion: Add config to allow unlocks regardless of item bonding type

Open atrapalis opened this issue 2 years ago • 0 comments

It would be nice to have the option to unlock looted items regardless of whether they are soulbound / bind when picked up.

This seems relatively easy to implement. Just need to create a new setting and add it to the conditions on loot/create/store item. Some pseudo code / examples below:

Transmogrification.cpp

void Transmogrification::LoadConfig(bool reload)
{
...
    alwaysUnlock = sConfigMgr->GetOption<bool>("Transmogrification.AlwaysUnlock", false);
...
}

bool Transmogrification::GetAlwaysUnlock() const
{
    return alwaysUnlock;
}

transmog_scripts.cpp

    void OnLootItem(Player* player, Item* item, uint32 /*count*/, ObjectGuid /*lootguid*/) override
    {
        if (!sT->GetUseCollectionSystem() || !item)
            return;
        if (sT->GetAlwaysUnlock() || item->GetTemplate()->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
        {
            AddToDatabase(player, item);
        }
    }

    void OnCreateItem(Player* player, Item* item, uint32 /*count*/) override
    {
        if (!sT->GetUseCollectionSystem())
            return;
        if (sT->GetAlwaysUnlock() || item->GetTemplate()->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
        {
            AddToDatabase(player, item);
        }
    }

    void OnAfterStoreOrEquipNewItem(Player* player, uint32 /*vendorslot*/, Item* item, uint8 /*count*/, uint8 /*bag*/, uint8 /*slot*/, ItemTemplate const* /*pProto*/, Creature* /*pVendor*/, VendorItem const* /*crItem*/, bool /*bStore*/) override
    {
        if (!sT->GetUseCollectionSystem())
            return;
        if (sT->GetAlwaysUnlock() || item->GetTemplate()->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
        {
            AddToDatabase(player, item);
        }
    }

atrapalis avatar Sep 20 '23 17:09 atrapalis