MV CGMV Encyclopedia and Yanfly Animated Sideview Enemies Compatibililty

I have been working on a way to show a battler image in CGMV Encyclopedia when using Yanfly's Sideview Animated Enemies.

So I have come up with a script that, so far seems to work.
JavaScript:
if ($dataEnemies[6].battlerName === '' && $dataEnemies.sideviewBattler != '') {
    $dataEnemies[6].battlerName = $dataEnemies[6].name;
}

What I am trying to do now is turn this into a loop that will check every enemy in the database and not just one enemy at a time.

I tried to make a for loop but I feel like I am getting errors.
Code:
for (let i = 0; i < $dataEnemies.length; i++) {
    if($dataEnemies[i].battlerName === '' && $dataEnemies[i].sideviewBattler != '') {
        $dataEnemies[i].battlerName = $dataEnemies.name;
    }
}
Spoiler: Error
1608407826742.png

I have not yet come to fully understand loops. I have looked at a few examples and I just don't understand how to check the battler name of each enemy while using a loop as opposed to running this script individually for each enemy.
Have you looked at $dataEnemies to see whether the first value ($dataEnemies[0]) is null?
RPG Maker has had a history of putting a null as the first element so the index matches with the id of the data elements.
Have you looked at $dataEnemies to see whether the first value ($dataEnemies[0]) is null?
RPG Maker has had a history of putting a null as the first element so the index matches with the id of the data elements.
@Zeriab Thank you!
Okay, that was one issue, if I say (let i = 1) then it doesn't throw an error, but now its not setting the image like it does as a simple script call. Looks like its back to the drawing board after work!
alot try to get this to work, and not sure when casper is able to do this.
because this could be interesting for the solution though =)
This script seems to be working:
Spoiler: Script
JavaScript:
for (let i = 1; i < $dataEnemies.length; i++) {
    if($dataEnemies[i].battlerName === '' && $dataEnemies[i].sideviewBattler !== '') {
        $dataEnemies[i].battlerName = $dataEnemies[i].name;
    }
}

I used this script in an event with a plugin command to show the bestiary entry I have been using for testing. Here's what that event looks like:
Spoiler: Event
1608435479893.png

-EDIT-
After interacting with this event and opening the bestiary, enemy 6 was discovered and displayed the image that is set in the editor, even though there is the <Sideview Battler: [filename]> notetag attached to the enemy.

-NOTE-
If you are using the <Sideview Battler: [filename]> notetag, the image you want to show in the bestiary and the enemy must share the same name for this to work. If your enemy is named 'Slime' in the editor, then the image file must also be named 'Slime'

I do plan to continue testing this as there are a couple other Yanfly plugins that reference 'obj.battlerName', those being Weak Enemy Poses and Swap Enemies and I want to make sure this doesn't break those.

If you do end up trying this, please let me know if it does or doesn't work!
even if it start with index 1 and command seems to be working, and this need to be placed
on each event, than I know maybe another way that might work 🙂

you need to test it though, try to run the scriptcall as an autorun event and than use battles,
(try with 3 different enemies in 3 different minimaps and use plugin command before or after
the enemy is defeated and see if it works, if it does, I might try to integrate it in the plugin 🙂
Okay, so I see where you're going with this.

I playtested with these two entries being added into the 'Bestiary' right away upon starting the game and both monsters DO show up.

My only issue is how to make practical use of this as I'm unsure how to use this for a 'Reveal' skill that I had been using in my game.

I think I could have the skill call a common event with a conditional branch and the plugin commands as the outcome but that seems extremely cumbersome.
even if it start with index 1 and command seems to be working, and this need to be placed
on each event, than I know maybe another way that might work 🙂

you need to test it though, try to run the scriptcall as an autorun event and than use battles,
(try with 3 different enemies in 3 different minimaps and use plugin command before or after
the enemy is defeated and see if it works, if it does, I might try to integrate it in the plugin 🙂
I will test this tonight after work, thank you for your feedback!

-EDIT-
@ShadowDragon So I've tested it like you recommended and everything works like it should. I have 3 different enemies with the <Sideview> notetag, on 3 separate maps.

I had the script set up as an auto run event. As I move from map to map battling the enemies, they show up properly in the bestiary. I also tested using the plugin command on 3 separate maps to force the entry after the script call and all the entries on appear like they should.

I also set the script to run on a button press event and fought the all 3 enemies on all 3 maps and then used the event to call the script and everything worked as well. I again used all the plugin commands and nothing changed. I even went back and fought all 3 enemies again and the battler image was still the sideview image from the notetag.
Thanks. The script works. I'm trying to fin a way to categorize Bosses with the plugin. any ideas on a scriptlet that would work ? Could I use something like this?

Code:
for (let i = 1; i < $dataEnemies.length; i++) {
    if($dataEnemies[i].battlerName + '(Boss)' === '' && $dataEnemies[i].sideviewBattler !== '') {
        $dataEnemies[i].battlerName = $dataEnemies[i].name;
    }
}
@OneManIndie if you want enemies and bosses seperately, you need
to create a custom entry (custom enties MUST be manually be tracked,
as this one does it not automatically.

@ThreeSixNine if you still need it, a nice work around is to add it
to a tiny plugin or common event (see my GetAllItems).

if you run the common event this way, it works as long the game is running,
I dont know if it still works after that, but while it load first, it should work
every time 🙂

(this is only a work around), you can delete the base code for all items,
but the scene_boot is required 🙂
I get that, but I'm talking about add the image for the Encyclopedia.
@OneManIndie if you want enemies and bosses seperately, you need
to create a custom entry (custom enties MUST be manually be tracked,
as this one does it not automatically.
@OneManIndie
there is a param to set the text (description) and sketch
to add it.

if this doesn't work, you probably need to the sketch "eval"
so you can use JS code instead to draw that image.

if it doesn't animate it by that, than I cannot really help you,
as more functions probably need to be added to make that work.
@OneManIndie
there is a param to set the text (description) and sketch
to add it.

if this doesn't work, you probably need to the sketch "eval"
so you can use JS code instead to draw that image.

if it doesn't animate it by that, than I cannot really help you,
as more functions probably need to be added to make that work.
Thanks I already got it. THIS REALLY was helpful.
This script seems to be working:
Spoiler: Script
JavaScript:
for (let i = 1; i < $dataEnemies.length; i++) {
    if($dataEnemies[i].battlerName === '' && $dataEnemies[i].sideviewBattler !== '') {
        $dataEnemies[i].battlerName = $dataEnemies[i].name;
    }
}

I used this script in an event with a plugin command to show the bestiary entry I have been using for testing. Here's what that event looks like:
Spoiler: Event

-EDIT-
After interacting with this event and opening the bestiary, enemy 6 was discovered and displayed the image that is set in the editor, even though there is the <Sideview Battler: [filename]> notetag attached to the enemy.

-NOTE-
If you are using the <Sideview Battler: [filename]> notetag, the image you want to show in the bestiary and the enemy must share the same name for this to work. If your enemy is named 'Slime' in the editor, then the image file must also be named 'Slime'

I do plan to continue testing this as there are a couple other Yanfly plugins that reference 'obj.battlerName', those being Weak Enemy Poses and Swap Enemies and I want to make sure this doesn't break those.

If you do end up trying this, please let me know if it does or doesn't work!
I tried what you suggested, and after the battle, I got this error
@Semolous29 Are you using MV or MZ? The script I used was only tested in MV, as that was all that was released at the time.

Original thread: https://forums.rpgmakerweb.com/threads/cgmv-encyclopedia-and-yanfly-animated-sideview-enemies-compatibililty.131174/