Yanfly's Battle AI Edits and Bugfixes

Edit 1: Yanfly AI is in serious need of more than 1 condition when writing a skill on an enemy. It happened to me multiple times where I had to use other ways to get 2 conditions like sealing the skill with a state. Multiple people also suggested it to Yanfly's. Unfortunately, he refuse to take on requests even if very needed.


Edit 2: A precise index targeting is missing. Example: you can't do something like Always: Skill 1083, Index 2. It can be very useful in some situations.


Fix 1: There is a bug when using TP, if you use only TP without the %(or TP rate), the game will crash. Example: Always: Skill 1083, Highest TP


Now, I won't mind at all if you rather make an AI plugin that can do script calls instead of all that restrictive content.
Fix 1... I'm surprised that Yanfly won't fix it since it does crash the game. She usually fix any bugs like that.


Edit 2 : I agree, myself got this problem and in the end gave up on that idea. Grandblue fantasy (mobile) handle in a simple way about condition, only when the enemy TP is full it will perform a special action but enemies don't have TP in Mv...
Fix 1... I'm surprised that Yanfly won't fix it since it does crash the game. She usually fix any bugs like that.


Edit 2 : I agree, myself got this problem and in the end gave up on that idea. Grandblue fantasy (mobile) handle in a simple way about condition, only when the enemy TP is full it will perform a special action but enemies don't have TP in Mv...

Enemies does have TP, I'm using something similar that give enemies an extra action when theyre full TP


There is just no way to see it without a plugin.
Oh, that's pretty cool, thank you for the tip.


And yeah, that's unfortunate that we can't show TP bar for enemies...


Edit :


@Fisherolol Do you think it's possible to make a state when the enemy TP is full ? If we can't have a TP bar, maybe we can at least have a state ? XD
Oh, that's pretty cool, thank you for the tip.


And yeah, that's unfortunate that we can't show TP bar for enemies...


Edit :


@Fisherolol Do you think it's possible to make a state when the enemy TP is full ? If we can't have a TP bar, maybe we can at least have a state ? XD

Probably using Lecode Autostate


<auto_trigger>


a.tpRate() === 1


</auto_trigger>
3 days
Can you give a (as specific as possible) example of what you would like to do with the AI plugin but cannot?
The eval should be able to take && and || for more than 1 condition.


Eval user.name() === 'Bat A' && user.isStateAffected(10): Skill 10, Highest HP%
Can you give a (as specific as possible) example of what you would like to do with the AI plugin but cannot?



 Eval ($gameParty.averageLevel() > 5 && !target.isStateAffected(10)): Sleep, Random


This code was supposed to let me make an enemy that will only cast sleep if the party is lvl 5+


But it never worked.


I tried the normal code that the plugin let us use:


<AI Priority>


Average Party Level <= 5: Attack


State !== State 10: Sleep


</AI Priority>


But it never read the first line, only the second, so some people suggested me to use some "eval" instead but unfortunaly, the plugin doesn't like Eval code.


Source of my test :
The eval should be able to take && and || for more than 1 condition.


Eval user.name() === 'Bat A' && user.isStateAffected(10): Skill 10, Highest HP%

@Fisherolol


I tried this eval


<AI Priority>
Eval user.name() === 'Bat' && user.isStateAffected(17): Skill 25, Highest HP%
</AI Priority>


and it seems to be working correctly. It tests both conditions.


One possible issue is that isStateAffected may not evaluate correctly if the state is a passive state.


But it doesn't have anything to do with && or || never working.


If you are using a state that is passive, use user.isPassiveStateAffected(x) instead of user.isStateAffected(x).


If you want to check for a state that can be passive or not passive, try this: (user.isPassiveStateAffected(x) || user.isStateAffected(x)).


Example:


<AI Priority>
Eval user.name() === 'Bat' && (user.isPassiveStateAffected(19) || user.isStateAffected(19)): Skill 25, Highest HP%
</AI Priority>



Eval ($gameParty.averageLevel() > 5 && !target.isStateAffected(10)): Sleep, Random



@Chaos17 target cannot be used like that in Yanfly's plugin unedited because target doesn't exist at the time that the eval code is processed.


I made a small extension to Yanfly's plugin so you can narrow down targets when using eval.


https://raw.githubusercontent.com/DreamXRMMV/Rpg-Maker-MV/master/DreamX_Ext_BattleAICore.js


In your case, you'll want to use


<AI Priority>
Eval $gameParty.averageLevel() > 5 && AIManager.targetCondition("!target.isStateAffected(10)"): Sleep, Random
</AI Priority>


A note on the code: Using > 5 means the average level must be above level 5. If you want level 5 or above, use >= 5 instead.


A note on Yanfly's plugin: I suggest using an ai level of 100 so the enemy doesn't sometimes use the wrong skill.
Okay, ill retry an eval with 2 conditions, l may have done a typo.


How about 2 and 3?
Okay, ill retry an eval with 2 conditions, l may have done a typo.


How about 2 and 3?

Edit 2: Use my extension and


AIManager.targetCondition("$gameParty.battleMembers()[x] === target")


In arrays indices begin at 0 instead of 1, so the first index is 0, the second is 1, etc.


Fix 1: Have you reported this to Yanfly yet? This seems to be a genuine bug as I was able to reproduce it.
Edit 2: Use my extension and



AIManager.targetCondition("$gameParty.battleMembers()[x] === target")


In arrays indices begin at 0 instead of 1, so the first index is 0, the second is 1, etc.


Fix 1: Have you reported this to Yanfly yet? This seems to be a genuine bug as I was able to reproduce it.

He's ignoring me.


Someone else would need to report it.


Thanks for the addon, ill try it as soon as i'm home and i'll let you know if there is anything else.
Fix 1: There is a bug when using TP, if you use only TP without the %(or TP rate), the game will crash. Example: Always: Skill 1083, Highest TP

What plugin does that ?


@DreamXThanks! Gonna test it now.
What plugin is that ?

That's Yanfly's AI Core plugin.
That's Yanfly's AI Core plugin.

Can you give me the code you tried so I can try too and make a video, please ?
Can you give me the code you tried so I can try too and make a video, please ?

Do you mean the TP thing? You can replicate the crash with this:


<AI Priority>
Always: AISkill, Highest TP%
</AI Priority>


Change AISkill to the name of a skill.


I already mentioned the bug in Yanfly's thread, though, so you may want to just wait.
I probably did something wrong, l know the right skill is being used but the target is still randomized instead of targeting the index 1


Here's what l wrote:


Eval user.isStateAffected(14): Skill 44, AIManager.targetCondition("$gameParty.battleMembers()[0] === target")
I probably did something wrong, l know the right skill is being used but the target is still randomized instead of targeting the index 1


Here's what l wrote:


Eval user.isStateAffected(14): Skill 44, AIManager.targetCondition("$gameParty.battleMembers()[0] === target")

It's a function call, so you put it in the same section as user.isStateAffected


Eval user.isStateAffected(14) && AIManager.targetCondition("$gameParty.battleMembers()[0] === target") : Skill 44, Random
Yeah, it works now unless l have terrible luck.


Thanks

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-battle-ai-edits-and-bugfixes.60458/