MV Yanfly AI Core help

Hey all,
Was hoping someone could help me with this. I'm using Yanfly's AI Core plugin for my enemies and by and large it works well. Only issue I'm having is that sometimes, the enemies decide that NO action is fine and will just basically skip their turn. I haven't checked to see if all enemies in a battle will skip together, or if one will while the others attack, etc. This failure isn't consistent, happens with most enemies I have at one time or another, always seems random and if they skip a turn, they usually do something on their next turn.
As an example, here's one of the simpler AI notetags from a bandit in my game:


<AI Level: 50>
<AI Priority>
Random 25%: Skill 148, Lowest HP
ALWAYS: SKILL 25
</AI Priority>

I keep the AI level lower on my enemies because I don't want them simply going down the list as my battles have multiples of the same enemy (so if you pick a fight with bats, you're only fighting bats, fight with rats, you only fight rats, etc.) and having each enemy perform the same attack is...anyway, I want some degree of randomness, but increasing/decreasing the AI level doesn't seem to have any effect on the problem I'm having.
The most common reason why enemies "skip" their turn are probably these two:

- The enemy has no skill available for use
-> AI Level basically means what % chance the enemy has to follow your defined AI patterns instead of going with the default action pattern
-> That's why you have to make sure the enemy actually has all these skills in their default action pattern

- The enemy doesn't have enough MP (or other restrictions in place) to use the chosen skill or any available skill
The enemy doesn't have enough MP (or other restrictions in place) to use the chosen skill or any available skill
This is to the extent of my knowledge not entirely accurate. If I remember correctly, an enemy will never choose a skill that they cannot pay the cost for. Of course, when they cannot pay the cost of any skill, they will choose none. But take this example:

Code:
<AI Priority>
  Always: Fireball
  Always: Attack
</AI Priority>
The enemy will always choose Fireball as long as they have the MP for it. But when they run out of MP, they will not be stuck on Fireball, but rather default to attack.

Apart from that minor nitpick, I agree that the reasons you mentioned are the main ones for OP's problem though.
The most common reason why enemies "skip" their turn are probably these two:

- The enemy has no skill available for use
-> AI Level basically means what % chance the enemy has to follow your defined AI patterns instead of going with the default action pattern
-> That's why you have to make sure the enemy actually has all these skills in their default action pattern

- The enemy doesn't have enough MP (or other restrictions in place) to use the chosen skill or any available skill
I was under the impression that the lower the AI level, the more randomness in the attacks the enemies choose, but they still pull the attacks from the pre-defined list instead of just going top to bottom to find a condition that's met. The Action Patterns box for all my enemies is blank, and they all do the attacks that are in the list I define for them, so I don't think this is the problem.

As for the MP issue, I have had that pop up before (assigning skills with MP cost to an enemy that doesn't have MP), but these 2 attacks are both physical and have no MP cost. In fact, skill 25 is just a duplicate of skill 1, a regular old attack, only difference being the action sequences they have where 25 is set up specifically for the movement of the enemies during the attack and 1 is for use by the player, and again, when they skip a turn, they almost always will perform some action or other on the next.


Edit: Just for kicks, I tried adding these 2 skills to the enemy's action pattern box, and, at least for this first battle test, I didn't see any skipped turns. Not sure why that is when it works MOST of the time with the action pattern box being empty, but if it works, it works. I'm going to do some more testing on this.
I was under the impression that the lower the AI level, the more randomness in the attacks the enemies choose, but they still pull the attacks from the pre-defined list instead of just going top to bottom to find a condition that's met.
Where did you get that impression? According to Yanfly's documentation (and my experience) the plugin does in fact go from top to bottom through each step and sees if the conditions are fulfilled.

According to that documentation, setting an AI level of 50 is more or less equivalent to adding a Random 50% condition to each skill in the pattern.

With your setup there is first a 50% * 25% = 12.5% chance for skill 148 followed by a 50% chance for skill 25. This leaves a (100% - 50% - 12.5% =) 37.5% chance that no skill is selected. In this case the AI plugin will revert to the default action pattern of the maker.

Since you said there is no action pattern, they will skip their turn.
To see for yourself, try setting the AI level to 0. They should now skip almost every turn. And with an AI level of 100 they should never skip a turn.
Where did you get that impression? According to Yanfly's documentation (and my experience) the plugin does in fact go from top to bottom through each step and sees if the conditions are fulfilled.
Based on the documentation, it sounded like 100% AI level = check the first skill - conditions are met - execute skill, or check first skill - conditions not met - check second skill - conditions are met - execute skill, etc. whereas a lower AI level would pull a random skill from the list and execute that if conditions are met.

Trying your suggestion of setting AI level to 0 without any action patterns set does indeed confirm that they won't do anything that way.

I guess I should ask, will it still respect the conditions I set for the skills when the AI is so low or it's pulling from the action patterns and not the notetags? Example, a stiletto causes bleeding, but if the target is already bleeding, stiletto won't be used (per the notetag), but there's no such condition in the action patterns, will it still prevent stiletto being used if target is already bleeding? Not a HUGE issue as it still does damage on its own aside from the bleeding state, but would be good to know.
I guess I should ask, will it still respect the conditions I set for the skills when the AI is so low or it's pulling from the action patterns and not the notetags? Example, a stiletto causes bleeding, but if the target is already bleeding, stiletto won't be used (per the notetag), but there's no such condition in the action patterns, will it still prevent stiletto being used if target is already bleeding?
It took me a minute to puzzle through this, but I think I understand the question.

The AI Core plugin is completely separate from the enemy's action pattern as entered in the database. Any AI notetags you put are irrelevant to conditions in the pattern, and vice versa.

I suggest you will be happier if you get rid of the AI level tag and just add random conditions as you like throughout the rest of the AI notetags. Then you have perfect control over what ultimately happens and complete understanding of the process.
From the documentation:
An AI Level
of 80 means it has an 80% chance of following the prioritized action on the
AI Priority list before moving onto the next one where there will be another
80% chance and so on.

Even if you use AI levels, it will still move through the priority list top to bottom.

What @ATT_Turan said is correct. The conditions from the plugin and the Maker are completely different and will not respect each other. I never really got why AI level would be useful. In my projects I just use a default level of 100 for every enemy and control random skill selection just with the Random condition. I still normally give my enemies a pattern in the maker of always attack. That way they have something to fall back on when I somehow mess up my conditions.
I suggest you will be happier if you get rid of the AI level tag and just add random conditions as you like throughout the rest of the AI notetags. Then you have perfect control over what ultimately happens and complete understanding of the process.
After tinkering around a bit, I think this is indeed the way to go. Thanks for your help, I'm off to tinker some more and get these AI patterns the way I want.
This thread is being closed due to being solved. If you would like it reopened, report the thread to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-ai-core-help.157145/