MV Show dropped loot count instead of each individual items?

By default, when you finish a battle you see each item dropped in a list, like this:
[Item A, Item A, Item A, Item B, Item B]

But that isn't exactly easy to read. So is there a way to make it combine the dropped items into something like this instead?
[ Item A x3, Item B x2]

I don't know if there's a way to do it without plugins or if there's an existing plugin already, but searching hasn't turned up anything. If there is and I missed it, please let me know. Thanks in advance!
I believe Yanfly's Victory Aftermath does what you want. And it's part of their free plugins.
I believe Yanfly's Victory Aftermath does what you want. And it's part of their free plugins.
It does, thanks! But it also replaces the aftermath screen and I prefer to use Moghunter's version of that for the aesthetics if possible. I'm trying to extract the segment of code in Yanfly's plugin that just stacks the items, but no luck so far. Is there another plugin, or can anyone help me edit Yanfly's to just stack the items? Thanks again!
I just wrote a small plugin, see the attached file (full code in spoiler below). It should display 1 message per item using the Database -> Terms -> Obtain Item text, with:
  • %1 = item name (as usual), and
  • %2 = item quantity
I tested with Obtain Item = %1 x%2 found!. It seemed to work with no other plugins active; hopefully it'll work with whatever stuff you're using~
Spoiler: full plugin code
JavaScript:
/*:
 * @plugindesc Show one message per drop item, with item count.
 * @help Database -> Terms -> Obtain Item:
 *    %2 will be replaced with the item count.
 * 
 * Terms of use: free to use and/or modify for any project.
 */

// Override!
BattleManager.displayDropItems = function() {
    var drops = [], count = [];
    for (var item of this._rewards.items) {
        if (drops.indexOf(item) < 0) drops.push(item);
        count[item.id] = (count[item.id] || 0) + 1;
    }
    if (drops.length > 0) {
        $gameMessage.newPage();
        for (var item of drops) {
            $gameMessage.add(TextManager.obtainItem.format(item.name, count[item.id]));
        }
    }
};
I just wrote a small plugin, see the attached file (full code in spoiler below). It should display 1 message per item using the Database -> Terms -> Obtain Item text, with:
  • %1 = item name (as usual), and
  • %2 = item quantity
I tested with Obtain Item = %1 x%2 found!. It seemed to work with no other plugins active; hopefully it'll work with whatever stuff you're using~
Spoiler: full plugin code
JavaScript:
/*:
 * @plugindesc Show one message per drop item, with item count.
 * @help Database -> Terms -> Obtain Item:
 *    %2 will be replaced with the item count.
 *
 * Terms of use: free to use and/or modify for any project.
 */

// Override!
BattleManager.displayDropItems = function() {
    var drops = [], count = [];
    for (var item of this._rewards.items) {
        if (drops.indexOf(item) < 0) drops.push(item);
        count[item.id] = (count[item.id] || 0) + 1;
    }
    if (drops.length > 0) {
        $gameMessage.newPage();
        for (var item of drops) {
            $gameMessage.add(TextManager.obtainItem.format(item.name, count[item.id]));
        }
    }
};
Thanks for the plugin! Unfortunately it doesn't work with Moghunter's plugin. I'm not familiar with scripting, but it looks like Mog's plugin defines items drops in a different way and that might be causing incompatibilities. I tried moving the plugin in the load order, editing it and your plugin to make them work together, but can't get it to work. If it helps, I attached Mog's plugin and maybe you can see what the issue is.

On a side note, when I disabled Mog's plugin, your plugin does consolidate the dropped items but doesn't show the amount. Not sure if that's a bug on my end, but thought I should point it out. Thanks again!
As mentioned, you need to add %2 somewhere in the Obtain Item message on the Terms tab in the database. E.g. %1 x%2 found! will display like Potion x4 found! in-game. 👋

It looks like Mog's plugin completely replaces the default display so it will need a totally different patch. I updated the plugin code I posted previously for compatibility, see the attached file~
Spoiler: plugin code v2 (MOG_BattleResult compatible)
JavaScript:
/*:
 * @plugindesc Show one message per drop item, with item count.
 * @help Database -> Terms -> Obtain Item:
 *    %2 will be replaced with the item count.
 * E.g. use "%1 x%2 found!" to show "Potion x2 found!".
 * 
 * If using MOG_BattleResult, load this plugin after Mog's.
 * This plugin will use the Obtain Item message for each drop.
 * 
 * Terms of use: free to use and/or modify for any project.
 */

if (Imported.MOG_BattleResult) {    // Patch MOG's plugin
    
    (function(alias) {
        // determine & store item counts
        BattleManager.getResultData = function() {
            alias.apply(this, arguments);
            var count = $gameTemp._bResult[3].reduce(function(a, c) {
                a[c.id] = (a[c.id] || 0) + 1;
                return a;
            }, []);
            var memId = [];
            $gameTemp._bResult[3] = $gameTemp._bResult[3].map(function(item) {
                item = Object.assign({}, item);  // shallow clone so name change does not persist
                item.name = TextManager.obtainItem.format(item.name, count[item.id]);
                return item;
            }).filter(function(item) {  // cannot filter directly on cloned references
                if (memId.indexOf(item.id) < 0) {
                    memId.push(item.id);
                    return true;
                }
                return false;
            });
        };
    })(BattleManager.getResultData);

} else {    // Patch core-script

    BattleManager.displayDropItems = function() {
        var drops = [], count = [];
        for (var item of this._rewards.items) {
            if (drops.indexOf(item) < 0) drops.push(item);
            count[item.id] = (count[item.id] || 0) + 1;
        }
        if (drops.length > 0) {
            $gameMessage.newPage();
            for (var item of drops) {
                $gameMessage.add(TextManager.obtainItem.format(item.name, count[item.id]));
            }
        }
    };

}
As before, this will replace the name of each unique drop item with the Obtain Item message on the Terms tab in the database. For example, you can edit it to something like %2x %1 to have items show as 4x Potion.

I did a quick test and it worked for me, so fingers crossed! (If you see no change then remember to save your project to apply Plugin Manager changes before testing.)

[Edit: modified Mog-patch code to shallow-clone reward items before renaming. Attachment updated!]

[Edit 2025-01-11: it seems this still has a problem - it only counts by ID, so 1x Item 1 and 1x Weapon 1 will display as 2x each. I posted a fix for this over here: https://forums.rpgmakerweb.com/posts/1492937/]
You're right, I forgot to edit the terms in the database, and now the new plugin works! Thank you so much! ^^

EDIT: Sorry to bring it back up after saying it works, but for some reason the plugin seems to change the item name in the inventory screen to the term I put for finding the item in the terms database, like so:
93Xco53.png


In the screenshot I'm using Mog's inventory screen, but the issue remains even if I don't use it. It seems to rename the item in the database completely, as every time I get the same item in battle again it shows "biomass x8 extracted! x3 extracted!", and it stacks every time I get the item in battle. Any way to fix this? Thanks again!
Oops, my mistake! 😴 (I was just a bit careless with references: should make a separate copy of each drop item for display purposes before renaming it.)

I've updated the my previous post's code/attachment with a fix, let me know if you spot any other problems! 👋
It works perfectly now! Thank you so much for all the help! 😍
I know enough to successfully patch the @caethyril code further to show the icon before the item name in normal RMMV, but have no idea what's going on the Mog plugin patch. So I left that part alone.

Spoiler: Javascript replacing BattleManager.displayDropItems
JavaScript:
    BattleManager.displayDropItems = function() {
        var drops = [], counts = [], theIcon = null;
        for (var item of this._rewards.items) {
            if (drops.indexOf(item) < 0) drops.push(item);
            counts[item.id] = (counts[item.id] || 0) + 1;
        }
        if (drops.length > 0) {
            $gameMessage.newPage();
            drops.forEach(function(item) {
                if ( DataManager.isItem(item) ) theIcon = $dataItems[item.id].iconIndex;
                else if ( DataManager.isWeapon(item) ) theIcon = $dataWeapons[item.id].iconIndex;
                else if ( DataManager.isArmor(item) ) theIcon = $dataArmors[item.id].iconIndex;
                else theIcon = 0;
                $gameMessage.add(TextManager.obtainItem.format("\\I[" + theIcon + "]" + item.name, counts[item.id]));
            });
        }
    };
Yea, the \I[n] text code would be the way to go for showing the item icon. I don't see the need for the extra stuff, though, since you already have the item reference.

I think you could just replace both cases of this in my code:
JavaScript:
TextManager.obtainItem.format(item.name, count[item.id]);
...with this:
JavaScript:
TextManager.obtainItem.format("\\I[" + item.iconIndex + "]" + item.name, count[item.id]);
Either way, since it looks like OP's question was solved nearly 3 years ago, so~

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/show-dropped-loot-count-instead-of-each-individual-items.143812/