ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
392
Reaction score
327
First Language
English
Primarily Uses
RMMV
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;
    }
}
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.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,308
Reaction score
1,512
First Language
English
Primarily Uses
Other
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.
 

ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
392
Reaction score
327
First Language
English
Primarily Uses
RMMV
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!
 
Last edited:

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,675
Reaction score
1,797
First Language
Dutch
Primarily Uses
RMMV
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 =)
 

ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
392
Reaction score
327
First Language
English
Primarily Uses
RMMV
This script seems to be working:
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:
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!
 
Last edited:

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,675
Reaction score
1,797
First Language
Dutch
Primarily Uses
RMMV
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 :)
 

Zakarijah

I love making maps!
Veteran
Joined
Aug 18, 2019
Messages
185
Reaction score
23
First Language
English
Primarily Uses
RMMV
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.
 

Attachments

  • Untitled.png
    Untitled.png
    194.5 KB · Views: 7

ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
392
Reaction score
327
First Language
English
Primarily Uses
RMMV
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.
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

1638170340913.png
Crossover Inn is getting very crowded, and I love it
Climbing to the top #mapping
1638160732198.png
I've started the first steps of the final few maps that I need to make for B:ms. I haven't been able to say that in a really, really long time. It'd probably be a good idea to blog about this or something.
Question for the Mods: What am I supposed to do when I can't make a synopsis 350 words long? (for project recruitment thread) @Shaz @mlogan
The game is meant to be more on the simple side in order to be achievable so I'm a bit stuck...

Forum statistics

Threads
117,043
Messages
1,104,082
Members
152,988
Latest member
mur2fer
Top