Randomized gold drops?

Heya! I'm kinda new to RPGMaker and coding in general, and I'm trying to make randomized gold drops for enemies. I looked it up, and found a formula, but found nowhere to put it. Anyone know how to add a formula for gold drops?
not by default as the default engine uses fixed gold numbers.

one way is to simply replace the default gold mechanism by events. However it is a lot of work to set all default gold to zero and place troop events to use control variable and change gold to give that random gold.

All other ways involve a plugin, and unfortunately I can't link you to any MZ plugin as I don't use MZ.
But with a plugin you can either use a dedicated plugin that gives a specific option for this (as said I don't know but Visustella Battlecore is said to have a lot of options, try to look there)
Or you can use a plugin that offers an eval notetag for <on enemy kill> and place the code there.
All other ways involve a plugin, and unfortunately I can't link you to any MZ plugin as I don't use MZ.
But with a plugin you can either use a dedicated plugin that gives a specific option for this (as said I don't know but Visustella Battlecore is said to have a lot of options, try to look there)
A quick glance at the plugin's page says that it doesn't even have any way to modify gold drops. All that would do is add a bunch of extra bloat to their project, too. (Unless they already use it, in which case...RIP)

Here's how you can actually add that kind of functionality to your game:

1. Make a new text document, call it RandomGold.js or whatever you want.
2. Paste this line into it and save.
3. Add as a plugin to your project.
4. Add the note tag <Extra Gold: x> to any enemy you want to drop a random amount of extra gold up to (but not including) the amount shown.

So if you have a goblin with <Extra Gold: 10>, and a base gold amount of 10 set in the editor, then each goblin will drop up to 9 extra gold. One could drop 11 gold, the next could drop 19 gold, a third could drop 10 gold, etc.

Code:
Game_Enemy.prototype.gold = function()
{
	const extraGold = Math.floor(Math.random() * (+this.enemy().meta["Extra Gold"] || 0));
    return this.enemy().gold + extraGold;
};
A quick glance at the plugin's page says that it doesn't even have any way to modify gold drops.
no, but that wasn't what I meant either.
it does implement action sequences and eval-type notetags, and if it has one for <on enemy kill> or so it can use javascript to modify anything then.
Action sequences seem like they have little to do with the question though. Some on enemy kill note tag could work, but I don't see that in the plugin's descriptions either. I'm not trying to be mean or rude or anything, but it seems like the norm here is for everyone to just suggest yanfly/vs as a generic solution to everything, even if it isn't the best solution. Or even a solution at all.
* (+this.enemy()
I didnt know you could cast a string to a number using a unary plus before this, but im definitely going to remember that now 🤣
It's a faster to type out and looks nicer than using Number(). The only difference (that I'm aware of) between it and Number() is when working with BigInts, but rpgmaker doesn't use those.
...but it seems like the norm here is for everyone to just suggest yanfly/vs as a generic solution to everything, even if it isn't the best solution. Or even a solution at all.

Well, a very large portion of the userbase uses them (if nothing else than for action sequences). Why go to extra trouble, if it's highly likely that they are using (or will start using) VS? Though I do agree that it'd be good to check if a plugin offers a certain functionality, but it wasn't their only suggestion. (Also, Core Engine has a gold notetag, though I don't think it accepts variables, but it was a good guess from them anyway 😀 )

Original thread: https://forums.rpgmakerweb.com/threads/randomized-gold-drops.174888/