Re-Ordering the Enemy Book?

Joined
Apr 26, 2019
Messages
5
Reaction score
1
First Language
English
Primarily Uses
RMMV
I'm a little surprised I can't find this question anywhere through Google, so I guess I'll ask it. :p

I'm using the base game's Enemy Book plugin and I honestly prefer it to the other user-made plugins I've found, but I was wondering if there was any way to re-order the entries without re-ordering my whole Enemies tab. I've got over 200 enemies and a good chunk of my game finished, so that would be an insane amount of work, not to mention if I got the urge to add something later, I'd have to do it all over again.

Any solutions / ideas?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,082
Reaction score
7,052
First Language
German
Primarily Uses
RMMV
you can't do that without rewriting the plugin.

and what order would you want?
The ONLY possible way to reorder is to base it on a static property when reprogramming the plugin.
so you can say "I want the enemies sorted by ATK" or "I want them sorted by alphabetic name".

The only way to give a custom order would be to implement that order in the database.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,976
Reaction score
3,985
First Language
English
Primarily Uses
RMMV
You need to modify the plugin.

@Andar The way I do it is that I create an array that gets the order I want by storing the enemy ID in that order.

Code:
var enemyOrder = [
    4, 6, 12, 17,
    2, 5, 8, 59,
]
So in that example the enemy #4 would have an artificial ID of 1, enemy #6 would be ID of 2, enemy 12 would have an ID of 3, etc. It's a lot of hassle, but it's the only way to truly have a customizable enemy order without filtering by stat, name, or anything else. And of course, it requires modifying the plugin.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
559
Reaction score
272
First Language
German
Primarily Uses
As others mentioned, you need to modify the plugin to allow for alternate ordering. I'd generally recommend against modifying the original plugin, but instead rewrite the parts in question in a second plugin placed after the original (this allows for easy removal/modification of your addition and avoids confusion when you forgot which of your plugins were modified later on).

In this case you probably only have to modify one function.

If you only want to change the position of some enemies, you could try this:
This allows you to add
<bookorder: 24>
to an enemies notebox to place it directly before the original position of another enemy (#24 in this case)
Code:
(function() {
 
   var orderFunction = function(enemy1, enemy2) {
       if (enemy1.meta["bookorder"] === undefined) {
           var pOrder1 = enemy1.id;
           var sOrder1 = Number.MAX_VALUE;
       } else {
           var pOrder1 = Number(enemy1.meta["bookorder"]);
           var sOrder1 = enemy1.id;
       }
       if (enemy2.meta["bookorder"] === undefined) {
           var pOrder2 = enemy2.id;
           var sOrder2 = Number.MAX_VALUE;
       } else {
           var pOrder2 = Number(enemy2.meta["bookorder"]);
           var sOrder2 = enemy2.id;
       }
       return (pOrder1 === pOrder2) ? sOrder1 - sOrder2 : pOrder1 - pOrder2;
   };

    Window_EnemyBookIndex.prototype.refresh = function() {
        this._list = [];
        for (var i = 1; i < $dataEnemies.length; i++) {
            var enemy = $dataEnemies[i];
            if (enemy.name && enemy.meta.book !== 'no') {
                this._list.push(enemy);
            }
        }
        this._list.sort(orderFunction);
        this.createContents();
        this.drawAllItems();
    };

})();

If you want to thoroughly change the enemy order and prefer Mushroomcake28's solution you could probably try something like this:
(Change the enemy list in line 3 of the plugin)
Code:
(function() {
 
   var enemyOrder = [ 4, 6, 12, 17, 2, 5, 8, 59,    ];
 
 
   Window_EnemyBookIndex.prototype.refresh = function() {
        this._list = [];
        for (var i = 1; i < enemyOrder.length; i++) {
            var enemy = $dataEnemies[enemyOrder[i]];
            if (enemy && enemy.name && enemy.meta.book !== 'no') {
                this._list.push(enemy);
            }
        }
        this.createContents();
        this.drawAllItems();
    };

})();

Not that experienced in Javascript yet, so I just hope it works out.
 
Last edited:
Joined
Apr 26, 2019
Messages
5
Reaction score
1
First Language
English
Primarily Uses
RMMV
If you only want to change the position of some enemies, you could try this:
This allows you to add
<bookorder: 24>
to an enemies notebox to place it directly before the original position of another enemy (#24 in this case)
This worked! Although it seems to take the notetag number and add one to it, so to put an enemy in the first spot, you'd put <bookorder: 0>. Maybe this is what you meant and I'm misreading, but that method works anyway, so hooray! I haven't tested the second method yet, but it seems like it'd work to me.

Also, for anyone who finds this thread in the future and is a Javascript noob like me, keep in mind you need to paste this bit of code within the lines that say "(function() {" and the last "})();" to work. It took me a second to figure that out. ^.^;

Thanks a ton, everybody!
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
559
Reaction score
272
First Language
German
Primarily Uses
Have to admit I didn't actually test the code above ingame, so there may be problems in there I overlooked the first time.
In this case I forgot that the "bookorder" is interpreted as text internally instead of a number, which confuses the comparison in line 18. This shouldn't break the plugin though, apart from the issue you discovered where monsters will now be sorted in before or after a position depending on their original database ID.

Modified the previous post for future reference.
Glad to hear it worked. :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

If you had some musical requests in line with me.. feel free to re post! Corona has killed me and have recently got my internet back <3
I'm now working on procedural generated World Maps for my own project.
Is there anyone who's interested in having this Plugin for his own game?
I have a dream where RMer are not blinded and too dependant on published script / plugins...
RM MV ACE? 2020? Super? Legends? Sword and Shield? 2.5D? RM Pixel? RM 2: Revenge of Squared RTP tiles? Don't mind me, I'm just wondering about what will be the name of the next engine.


So I came up with a new look for the paths, and along the way realized health bars are so overrated, so now a crazy red light trail follows her and gets shorter as her life decreases. :LZSexcite:

Forum statistics

Threads
98,211
Messages
950,358
Members
129,506
Latest member
TakuPlayz
Top