MZ iVillain Plugins (MZ but some work in MV as well)

So… This thread has been years in coming. I kept saying, “Oh yeah I’ll make a YouTube video explaining how to use these plugins.” And well I never did. :LZSlol: In fact I long ago moved onto another engine. However it seems a shame to not share these anyway, and who knows if there’s interest I may release the other ones, or even update these.

As a side note, I didn't design these plugins with the intentions of others using them. So while they work for anybody, you'll most assuredly have to use script commands (which are insanely more memory efficient than plugin commands anyway). These were made for pure power for my own projects.

Terms:
These plugins are free to use commercially and non-commercially inside of your games. You may not resell, repackage, redistribute it or modifications of them. I don’t require credit, though you are of course welcome to do so.

Examples:
I haven’t made specific videos for their usage here’s some clips of my games where I only used them for everything but the particle effects…


Plugin List:
iVillain Visual: (Works for both MV and MZ)
This plugin allows you to display huge numbers of pictures at any height (parallax, timemap, picture layers), the images can be bound to the player, events or the screen.

Notes:
1. So grossly efficient that it's literally doing an image every other frame for each character animated in those examples.
2. Can be used to make images automatically shuffle to be either in front or behind the player based on the player’s Y coordinate.
3. Injector: This plugin "lives in the update cycle" to avoid the travesty that is MV/MZ's programming. By default images aren't permanent and will vanish if the scene is switched. There is an option to make it permanent though in the script commands.

iVillain Message: (MZ only)
This plugin allows you to display custom pixi text at any height (parallax, tilemap, picture layers), the images can be bound to the player, events or the screen. These messages will not stop the game from progressing.
You can visit http://www.pixijs.io/pixi-text-style in order to create a PIXI style, don't worry this plugin will make use of any of the options there, and whatever custom font(s) you want.

Notes:
1. Due to switching how fonts are handled from MV to MZ, this won't work in MV.
2. Can be used to inject code into the update cycle forcing it to repeat every frame with significantly more efficiency than executing a script command every frame.
3. Injector: This plugin "lives in the update cycle" to avoid the travesty that is MZ's programming. By default messages aren't permanent and will vanish if the scene is switched. There is an option to make it permanent though in the script commands.
you'll most assuredly have to use script commands (which are insanely more memory efficient than plugin commands anyway).
How so?
I'd expect plugin commands have to be translated to their script equivalent which would be an extra step instead of going directly. But I am curious myself, I rarely use plugin commands and just run blocks of script commands/functions at a time.
I'd expect plugin commands have to be translated to their script equivalent which would be an extra step instead of going directly.
Plugin commands are translated to function calls. The options selected/input as arguments are passed through to whichever function in the plugin corresponds to that plugin command. I don't see how that creates any memory overhead.

But I am curious myself, I rarely use plugin commands and just run blocks of script commands/functions at a time.
That's less efficient. The eval() function is the slowest thing to do in JavaScript, because all of the code you type in is parsed as a string, then fed back through the JavaScript interpreter to turn into code, which is then executed.

In fact, the language's documentation for eval() says "Don't use this" - both because it's a security risk in Web sites, and also because it's slower than running prewritten code.

But again, I don't see how any of that has to do with memory usage. Thus my original question.
Hello. I am copying the iVillian.visual.add(filename, spriteObj) and pasting it into the Script of an event. The event is set to trigger: parallel. However, it is not working for me. Could you give more detail on how to add the iVillain code into an event, or where it should be placed? Thank you so much.
Hello. I am copying the iVillian.visual.add(filename, spriteObj) and pasting it into the Script of an event. The event is set to trigger: parallel. However, it is not working for me. Could you give more detail on how to add the iVillain code into an event, or where it should be placed? Thank you so much.
Sure, filename is a string. You can use a variable there if you wish, as long as that variable contains a string. So when writing the filename, write it as “filename” or ‘filename’ or `filename`. Personally I prefer the last method as it’s a different type of string but that’s another conversation.

The spriteObj is an object. So it’s written as {property: value, property: value, property: value} as it’s just a regular JS object you may have any number of properties, or if you just put {} it will use the plugin’s default options. An example of what to write there is {eId: `p`, zLayer: `same`}

So if you wished to put an image file above the player called “star” but at the tilemap level you would type…

iVillain.visual.add(`star`, {eId: `p`, zLayer: `same`})

You may call this code from wherever.

As another example, if you wished for an event to put an image of an “exclamation” above it for 2 seconds, you would type out

iVillain.visual.add(`exclamation`, {eId: this._eventId, zLayer: `above`, time: 120})

If called directly from an event this will put the exclamation in the picture layer (where RM normally shows pictures) for 120 frames, or 2 seconds.

Properties can be any order, so if you wanted to do the same as…

iVillain.visual.add(`exclamation`, { zLayer: `above`, time: 120, eId: this._eventId,})

It would still do the same thing.


First of all…

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval

Much of which explains that you shouldn’t let users just enter code, and how it’s expensive to look up stuff. Though it does provide a different method of eval it deems indirect, which it talks about is better.

Sure. Eval does in fact provide security vulnerabilities mostly if you allow the user to directly input into it. Which isn’t the case here. However if you are afraid of using eval() in your game, I’ve got a surprise for you… RM uses it on 5 different occasions in rmmz_ojbects.js So your RM game is already vulnerable to a hacker.

So with the security vulnerability already talked about we get to speed… Let’s get the first part out of the way. If you run either one a handful of times it doesn’t matter, the speed difference is pointless in real world terms.

But if taken to extremes I originally tested plugin parameters when making the plugins, but the results were echelons worse to the point where I actually removed them for the most part. But you have to understand how often I was running them. I was literally animating characters by swapping images every other frame (RM needs exactly two frames to add and then remove an image, so anything beyond 30 animation frames a second was impossible). So in…


...from just the characters you see as many as 14 characters at some points. Meaning executing the code 420 times a second. That’s excluding all other things on the screen, just the characters. This is to help give a better idea of the scope we’re talking about.

With that being said, here are the reasons why plugin commands are just strictly worse…
1. You can’t put calculations, variables, or other such JS inside the plugin command.
This matters as you have to then do additional event commands (or script calls but that would obviously defeat the purpose since that’s another eval) to manipulate the data. Each use of those is largely the same as any other things in that you need to involve RM’s interpreter which then runs through a disgusting number of lines of code for even a simple calculation.

2. You can easily place script calls inside of other plugins, so you only need to have RM interpret a single script call but can initiate any number of them. This of course bypasses again the slowest worst part of the system, RM. As it won’t need multiple interpreters to accomplish the task, just one.

3. RM is excessively poorly coded, and thus doesn’t do a good job of emptying its memory unless you switch a map. This came about at what I used to refer to as the 7 minute rule when testing with MV way back when. I dubbed it that not because RM crashes in 7 minutes, but because my event spawner/HLOD system exposed that if taken to extremes it simply would all come crashing down which for a long time took 7 minutes (eventually I made it infinite, but that’s another story). Again it won’t matter for most people, but this is about extremes otherwise the whole conversation of speed is pretty pointless.

RM’s basically a lumbering behemoth, it’s not written to be modular one bit, and instead just keeps cramming references, on top of references, on top of references. So even the simplest object such as an event is a disgusting mountain of useless code. And the only time that gets emptied is pretty much during a map switch (it sort of tries when you open a menu, but it’s not a clean sweep).

RM’s interpreter system has the same kind of problem, and to parse a Plugin command it needs excessively more lines of code versus a script command which is mostly parsed by JS itself. Sure once it’s done parsing, it feeds back to RM but each time you’re saving countless lines of code. Not to mention having to make expensive calls to read the plugins.js file for a plugin command.

It’s been a couple of years since I bothered using this engine (I’m more concerned about if I can have 300+ 4k textures on the same map, and still maintain 60FPS in UE). So I no longer remember the exact number of lines of code it runs between the two. It was a pretty staggering difference though.

But at the end of the day this is all academic. Pretty much nobody here is running the commands as often as I was. I mean I used to build entire 200x200 maps out of events, then add and remove them in a bubble around the player to make RM able to handle it memory wise. So I’m used to running hundreds if not thousands of script commands a second. Nobody does that, seriously just use UE if you want to do that, it does it all that for you and doesn’t suffer from the unfortunate short falls of JS.

Anyway that’s most of my reasoning. I’d have to crack open all the old files and really go back through them to get more specific. Doing silly things in RM used to be my jam, but well UE is just an easier, more performant, and powerful engine to use. So I can’t really see a world I’d be interested in doing any more of a deep dive into the RM performance subject.
Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/ivillain-plugins-mz-but-some-work-in-mv-as-well.171056/