MZ Loot++: My first Plugin, now as Alpha-Version available.

So, after a bit of learning JavaScript and some questions in various forums, my first Plugin is now in the Alpha-Version!
It's free, so don't be shy and give it a try.

This plugin gives you more control over enemy drops and gives you an efficient way to produce masses of common loot.

I wrote this plugin mainly to increase the loot in relation to the enemy level (which is also the reason why it is currently still dependent on the Visustella engine, I will remove this dependency as soon as I figure out how exactly).

Features I want to add:
- minimum and maximum loot for the common loot table
- a separate way to drop rarer drops.
- the possibility to increase the drops per level multiplicatively instead of just with a flat modifier.
- the ability to change certain formulas that are currently hard-coded in the plugin.
- a small variance value similar to the damage calculations for a little more realism.

Congratulations on your first plugin! 😀
Hey my friend,

I appreciate everyone who wants to learn how to write RPG Maker plugins, hence I want to give you some tips:

- First, you should use console.log only when it's useful. Developers use that for e.g. warnings and errors. If every plugin were verbose, then the console would become quickly overloaded. I recommend you to learn the debugger in RPG Maker (Press F12 in-game testing, go to "sources," and put breakpoints!) Take your time to learn this technique.

- Could it be that your code is a bit influenced by Java? In Java, there are collections such as Array and Map, in JS, however, every object is a Map itself, so you can shortcut like this:

Code:
const map = { }
const array = []

To read and write values, you can use this:
Code:
map["key"] = value
const value = map["key"]

array[0] = value
const value = array[0]

- I suggest not using special characters in a js file name. The + symbol could work, but it could also crash your game when, e.g., exported as a browser, android, or iOS game.

- In JS, you don't need a specific is null-check. You may shortcut if (!item) ...

The journey to becoming a plugin developer is long, like really, really long. Even for me who is a 5-year professional programmer.
In additions to the suggestions from @Aerosys :
As far as removing the VisuStella dependency, why don't you just reference the player's level if they're not using enemy levels?

For example, you could do something like replacing line 142 with:
Code:
let level = this._level || $gameActors._data.reduce(a, b => Math.max(a, b));

That would reference the highest level actor if enemy levels aren't defined. You can, of course, change it to be the average level of the actors or something, or provide the user with a few options for how it's calculated in a plugin parameter.

For me, I don't really understand the whole point of you referencing the level at all. If the drop list is defined on the enemy via notetags...and the enemy level is defined on the enemy via notetags...then why does any math need to be done?

It seems like the only time that matters is if the user is choosing to have the levels dynamically change during the game. Since that's not what most people do, it means your plugin is only potentially useful for that minority.

I would suggest it makes more sense for you to have the user construct their loot table notetags with the drop chances/weight they want, end stop. That will be the most useful for the most people.

If you don't want to do that and you want to keep the assumption that you can encounter the same enemy with different levels, then don't talk about trying to get rid of the VisuStella requirement, just market it as an extension to their Enemy Levels plugin and describe clearly that its functionality depends on the user choosing those options.

The console.log calls are a huge thing - I would not want any plugins spamming my console. That's for me to use when I'm actually troubleshooting 😉
Hey my friend,

I appreciate everyone who wants to learn how to write RPG Maker plugins, hence I want to give you some tips:

- First, you should use console.log only when it's useful. Developers use that for e.g. warnings and errors. If every plugin were verbose, then the console would become quickly overloaded. I recommend you to learn the debugger in RPG Maker (Press F12 in-game testing, go to "sources," and put breakpoints!) Take your time to learn this technique.
I started getting used to the debugger, what bothers me a little bit at the moment is that I no longer have access to the content of the variable as soon as an error is thrown.
- Could it be that your code is a bit influenced by Java? In Java, there are collections such as Array and Map, in JS, however, every object is a Map itself, so you can shortcut like this:
Yes! (And find it really impressive that you recognized that) I started with java and now I try javascript out of necessity. My uncle teached me some tricks with java, especially the stream api. He is personally not a big fan of javascript due to the lack of type security, and now where i started finding sneaky bugs with strings that actually should be numbers, I really start to get why.
- I suggest not using special characters in a js file name. The + symbol could work, but it could also crash your game when, e.g., exported as a browser, android, or iOS game.
Will change it as soon as I find out how do I change the name of a file in consensus with the GitHub repository.
- In JS, you don't need a specific is null-check. You may shortcut if (!item) ...
Ok, sounds good.
As far as removing the VisuStella dependency, why don't you just reference the player's level if they're not using enemy levels?
Mainly because I simply don't know how I differentiate between the both cases (other plugin present vs not present) in my code. The possibility that a particular method or field of an object just isn't there isn't something that I've often dealt with before.
It seems like the only time that matters is if the user is choosing to have the levels dynamically change during the game. Since that's not what most people do, it means your plugin is only potentially useful for that minority.
True, and that's kinda the reason why I wrote this plugin in the first place, because I am part of that minority who needed that. Also the Enemy_Levels_Plugin has a kinda irritating way of enhancing drops with level ups, as it does only increase the chance, not the amount.
I would suggest it makes more sense for you to have the user construct their loot table notetags with the drop chances/weight they want, end stop. That will be the most useful for the most people
There will be a seperate loot table who does exactly that. the first loot table is for common mass drops, like ingredients.
The console.log calls are a huge thing - I would not want any plugins spamming my console. That's for me to use when I'm actually troubleshooting 😉
I have to admit that I'm not the most tidy person in general, and unfortunately that's reflected in my code. ironically I'm a big fan of structure because it makes it easier for me to work quicker, but unfortunately I'm not good at maintaining it.
Mainly because I simply don't know how I differentiate between the both cases (other plugin present vs not present) in my code. The possibility that a particular method or field of an object just isn't there isn't something that I've often dealt with before.
The method I showed you (which is something that Aerosys also mentioned in a different context) works in any C-based language. Simply asking if (some property) will return true if the object being referenced has that property defined.

There's no reason here you need to specifically care or know that another entire plugin is involved (although if you look at how other authors have written their material, that's why they declare global constants with the name of their plugin so you can do external checks).
The console.log calls are a huge thing - I would not want any plugins spamming my console. That's for me to use when I'm actually troubleshooting 😉
Realized now how huge they actually are. enemy deaths are now far less laggy XD

Original thread: https://forums.rpgmakerweb.com/threads/loot-my-first-plugin-now-as-alpha-version-available.154031/