nyallwynn

Villager
Member
Joined
Jul 27, 2022
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello! I'm using Yanfly Engine Plugins for my project, including Battle AI Core.

So I am trying to set a series of skills for my enemies, I want an elemental mage to check two conditions.
1.) Is there an actor with a weakness to Fire?
2.) Are one of the Mage's allies unaffected by State 204?

If yes, cast EnFire on the ally with the highest ATK.

But I am stumped on how to write this, I'm no good at Javascript yet, but I am trying. I just am unsure how to write it out where it's checking the conditions of two separate users at the same time.

Edited conditions for clarity.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,947
Reaction score
4,789
First Language
English
Primarily Uses
RMMV
But I am stumped on how to write this, I'm no good at Javascript yet, but I am trying.
There's often no JavaScript necessary, just use the conditions Yanfly wrote for you. However, your condition 2 is kind of weird.

You're saying the mage will only use EnFire if all the enemies have state 204?

So if I understand you correctly,
Code:
Eval !$gameTroop.members().some(enemy => enemy.isStateAffected(204)) +++ Element Fire Weakness: EnFire, Highest ATK
 
Last edited:

nyallwynn

Villager
Member
Joined
Jul 27, 2022
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
There's often no JavaScript necessary, just use the conditions Yanfly wrote for you. However, your condition 2 is kind of weird.

You're saying the mage will only use EnFire if all the enemies have state 204? You use the word "ally," but that's not a term in RPG Maker so I'm assuming you mean ally of the mage.

So if I understand you correctly,
Code:
Eval !$gameTroop.members().some(enemy => enemy.isStateAffected(204)) +++ Element Fire Weakness: EnFire, Highest ATK
Oh my apologies, I mean if there is an actor who has a weakness to fire, and if there are any allies to the mage unaffected by the state, to cast that state on said ally.

I'll try that code, thank you!

Edit: So the code is kinda working? The mage will cast Enfire on one of their allies, and it is the one with the highest ATK, but it's still triggering even if the first condition isn't met.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,947
Reaction score
4,789
First Language
English
Primarily Uses
RMMV
Edit: So the code is kinda working?
I don't know how it would, your explanation is very different from what I said my assumption was :stickytongue:

The problem is that you're trying to use a skill that targets an enemy but also consider something about a party member (I see where you're referring to Ally in the skill scope, I'm just being very clear).

The plugin instructions say that the conditions will only look at potential targets for the skill when evaluating their conditions.

So you're going to have to replace the Element condition with more JavaScript, otherwise it will evaluate whether any enemies are weak to fire.

You can try this.
Code:
Eval $gameTroop.aliveMembers().some(enemy => !enemy.isStateAffected(204)) && $gameParty.aliveMembers().some(actor => actor.elementRate(X)>1): EnFire, Highest ATK

replace X with the ID of your fire element, no leading zeros.
 
Last edited:

nyallwynn

Villager
Member
Joined
Jul 27, 2022
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
I don't know how it would, your explanation is very different from what I said my assumption was :stickytongue:

The problem is that you're trying to use a skill that targets an enemy but also consider something about a party member (I see where you're referring to Ally in the skill scope, I'm just being very clear).

The plugin instructions say that the conditions will only look at potential targets for the skill when evaluating their conditions.

So you're going to have to replace the Element condition with more JavaScript, otherwise it will evaluate whether any enemies are weak to fire.

You can try this.
Code:
Eval $gameTroop.aliveMembers().some(enemy => !enemy.isStateAffected(204)) && $gameParty.aliveMembers.some(actor => actor.elementRate(X)>1): EnFire, Highest ATK

replace X with the ID of your fire element, no leading zeros.
I really can't tell what it is that's wrong. I tried the code, made sure the Element ID is correct, double checked the state number, made sure the mage had MP to cast the spell, had the skill in their action patterns, double checked the spelling, but the mage won't cast the spell on any troop member, and skips down the list of priorities.

Here's what I have typed in the enemy notebox:
Code:
<Sideview Battler: 3_Actor1_5>
<Default Row: 3>
<AI Priority>
Eval $gameTroop.aliveMembers().some(enemy => !enemy.isStateAffected(204)) && $gameParty.aliveMembers.some(actor => actor.elementRate(2)>1): EnFire, Highest ATK
Always: Skill 496, Lowest HP%
</AI Priority>
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,947
Reaction score
4,789
First Language
English
Primarily Uses
RMMV
Sorry, I'm not sure what else to try. That code should return true if at least one enemy does not have state 204, and at least one actor has a State Rate over 100% for fire.

You can try hitting F8 during the game, going to the Console tab, and pasting in the code portion of the condition to see if it returns true. If it says false, then the problem is with your setup - one of the parts of your situation isn't correct. If it says true and it's not working with the Battle AI plugin, there could be a bug in there.
 

nyallwynn

Villager
Member
Joined
Jul 27, 2022
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
Sorry, I'm not sure what else to try. That code should return true if at least one enemy does not have state 204, and at least one actor has a State Rate over 100% for fire.

You can try hitting F8 during the game, going to the Console tab, and pasting in the code portion of the condition to see if it returns true. If it says false, then the problem is with your setup - one of the parts of your situation isn't correct. If it says true and it's not working with the Battle AI plugin, there could be a bug in there.
So I received back an error code, it's saying $gameParty.aliveMembers.some is not a function

Edit: So I figured it out! It was missing $gameParty.aliveMembers.some was missing a () afterMembers. It works now! Thank you very much for all your help!
 

Attachments

  • Untitled.png
    Untitled.png
    65.1 KB · Views: 1
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,947
Reaction score
4,789
First Language
English
Primarily Uses
RMMV
Shoot, that was my fault. Sorry for the typo.
 

nyallwynn

Villager
Member
Joined
Jul 27, 2022
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
Shoot, that was my fault. Sorry for the typo.
Nah you're all good, those things can be so tricky sometimes, thank you very much for all the help though I appreciate it!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,776
Reaction score
5,577
First Language
English
Primarily Uses
RMMZ
Nah you're all good, those things can be so tricky sometimes, thank you very much for all the help though I appreciate it!
Does it work with the missing brackets added?
 

Latest Threads

Latest Posts

Latest Profile Posts

Now that I have linklists on large trees and cars, is there any theme that would interest you?
Debugging multiplayer issues... I'm having fun, right?
yay_streaming.jpg

For just starting streaming on the 10th... Definitely not the worst. :LZScheeze:

Granted I need 333.34 hours a month on average to achieve money. So I don't really expect that, but it sure has helped my game dev go much faster.
Proud on how this map turned out.

FnmhDLIXgAAOvIC
I just finally fixed a huge problem that wouldn’t let my game load and would crash it.. I thought that I was gonna have to trash the project and start over lol

Forum statistics

Threads
128,327
Messages
1,193,646
Members
168,813
Latest member
jasper1hu
Top