• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Loot Refference

Status
Not open for further replies.

AlexeWarr

Epic Member
Lets say we do a loot template for one npc, example npc id : 20000

- How do I create a group only for armors and never drop more than 3 items from that group even if the drop rate is 100%
- How do I create a group for weapons and never drop more than 1 item from that group even if the drop rate is 100%
- How to set chance for each item correctly?

also what is this "Rate.Drop.Item.ReferencedAmount = 1" used for?
 

Tommy

Founder
Lets say we do a loot template for one npc, example npc id : 20000

- How do I create a group only for armors and never drop more than 3 items from that group even if the drop rate is 100%
- How do I create a group for weapons and never drop more than 1 item from that group even if the drop rate is 100%
- How to set chance for each item correctly?

also what is this "Rate.Drop.Item.ReferencedAmount = 1" used for?

Is this what DndTheTroll wanted? Well, it is quite similar.


Never seen this option on TC, seeing I haven't fully went through TrinityCore's library yet. As far as I know, this is used for loot referencing when it processes the loot:

Code:
// Rolls for every item in the template and adds the rolled items the the loot
void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId) const
{
    if (groupId)                                            // Group reference uses own processing of the group
    {
        if (groupId > Groups.size())
            return;                                         // Error message already printed at loading stage

        if (!Groups[groupId - 1])
            return;

        Groups[groupId-1]->Process(loot, lootMode);
        return;
    }

    // Rolling non-grouped items
    for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i)
    {
        LootStoreItem* item = *i;
        if (!(item->lootmode & lootMode))                       // Do not add if mode mismatch
            continue;

        if (!item->Roll(rate))
            continue;                                           // Bad luck for the entry

        if (item->mincountOrRef < 0)                            // References processing
        {
            LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-item->mincountOrRef);
            if (!Referenced)
                continue;                                       // Error message already printed at loading stage

            uint32 maxcount = uint32(float(item->maxcount) * sWorld->getRate(RATE_DROP_ITEM_REFERENCED_AMOUNT));
            for (uint32 loop = 0; loop < maxcount; ++loop)      // Ref multiplicator
                Referenced->Process(loot, rate, lootMode, item->group);
        }
        else                                                    // Plain entries (not a reference, not grouped)
            loot.AddItem(*item);                                // Chance is already checked, just add
    }

    // Now processing groups
    for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i)
        if (LootGroup* group = *i)
            group->Process(loot, lootMode);
}

It is called before the group processes their loot. And as you see, the maxcount is multiplied by the rate. This might be what you're looking for, not sure. You have another rate similar to this: RATE_DROP_ITEM_REFERENCED

It is used here:

Code:
bool LootStoreItem::Roll(bool rate) const
{
    if (chance >= 100.0f)
        return true;

    if (mincountOrRef < 0)                                   // reference case
        return roll_chance_f(chance* (rate ? sWorld->getRate(RATE_DROP_ITEM_REFERENCED) : 1.0f));

    ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid);

    float qualityModifier = pProto && rate ? sWorld->getRate(qualityToRate[pProto->Quality]) : 1.0f;

    return roll_chance_f(chance*qualityModifier);
}

All I can say is try it out and see what happens. :p
 

AlexeWarr

Epic Member
Is this what DndTheTroll wanted? Well, it is quite similar.


Never seen this option on TC, seeing I haven't fully went through TrinityCore's library yet. As far as I know, this is used for loot referencing when it processes the loot:

Code:
// Rolls for every item in the template and adds the rolled items the the loot
void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId) const
{
    if (groupId)                                            // Group reference uses own processing of the group
    {
        if (groupId > Groups.size())
            return;                                         // Error message already printed at loading stage

        if (!Groups[groupId - 1])
            return;

        Groups[groupId-1]->Process(loot, lootMode);
        return;
    }

    // Rolling non-grouped items
    for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i)
    {
        LootStoreItem* item = *i;
        if (!(item->lootmode & lootMode))                       // Do not add if mode mismatch
            continue;

        if (!item->Roll(rate))
            continue;                                           // Bad luck for the entry

        if (item->mincountOrRef < 0)                            // References processing
        {
            LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-item->mincountOrRef);
            if (!Referenced)
                continue;                                       // Error message already printed at loading stage

            uint32 maxcount = uint32(float(item->maxcount) * sWorld->getRate(RATE_DROP_ITEM_REFERENCED_AMOUNT));
            for (uint32 loop = 0; loop < maxcount; ++loop)      // Ref multiplicator
                Referenced->Process(loot, rate, lootMode, item->group);
        }
        else                                                    // Plain entries (not a reference, not grouped)
            loot.AddItem(*item);                                // Chance is already checked, just add
    }

    // Now processing groups
    for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i)
        if (LootGroup* group = *i)
            group->Process(loot, lootMode);
}

It is called before the group processes their loot. And as you see, the maxcount is multiplied by the rate. This might be what you're looking for, not sure. You have another rate similar to this: RATE_DROP_ITEM_REFERENCED

It is used here:

Code:
bool LootStoreItem::Roll(bool rate) const
{
    if (chance >= 100.0f)
        return true;

    if (mincountOrRef < 0)                                   // reference case
        return roll_chance_f(chance* (rate ? sWorld->getRate(RATE_DROP_ITEM_REFERENCED) : 1.0f));

    ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid);

    float qualityModifier = pProto && rate ? sWorld->getRate(qualityToRate[pProto->Quality]) : 1.0f;

    return roll_chance_f(chance*qualityModifier);
}

All I can say is try it out and see what happens. :p

Thanks Tommy, I was meaning to the DB loot table, really weird combinations of ids and stuff to do something I have asked on tc forums too but they didnt answer :/
 

Tommy

Founder
Thanks Tommy, I was meaning to the DB loot table, really weird combinations of ids and stuff to do something I have asked on tc forums too but they didnt answer :/

They never answer. Database loot table? Erm, haven't tried it really. Have you actually tried it to see?
 

Rochet2

Moderator / Eluna Dev
Read the documentation and try Alexe.
The documentation tells of grouped references that might work for your advantage.
From what I briefly read (didnt read it all), you could create a reference loot for your armor for example.
Then make loot for your creature that has a grouped reference with maxcount possibly at 3
Or if I understood that wrong, then possibly you could add 3 rows that have the same reference and groupID.
Since it says a grouped ref should always add only one (or 0) items to the loot, having 3 rows would add 3 items.
If the item is random picked from the ref loot you have with your armor, 3 pieces will randomly drop from the ref.
 
Status
Not open for further replies.
Top