Help with Yanfly YEP_BattleAiCore

Hello!

I am wondering how I would go about using the Yep_BattleAICore plugin from Yanfly to cast an ally buff spell under the following two conditions:

Ally of a certain enemy type exists
Ally does not currently possess a state

So, let's say my Elf Enemy has a buff spell, which buffs allies but not himself. I would want him to Buff any Elves that are in the same battle, but not the eagles they fight alongside. Obviously, he shouldn't buff any elves that have already been buffed.

I think this should be workable with the plugin, or possibly a different yanfly plugin, but I can't seem to get it to work despite tinkering. Any help would be appreciated. Regards,

Laurence
This is not possible with the plugin as is.
I wrote an extension for that, you can find a link to it in my signature.
Thank you Astfgl66, that extension solves a problem of mine!
This is not possible with the plugin as is.
I wrote an extension for that, you can find a link to it in my signature.

Thanks a great deal. I have downloaded the plugin, but I am still unsure what command I would use for an enemy to check both that an enemy ally of theirs is the correct type [enemy 8, for example] and also not buffed [state 11, for example]. I am sorry, I am rather new to plugins.

As I understand this, the commands would form a part of the Ai Priority list in the enemy notebox, as detailed in the Yanfly BattleAiCore extension. Hopefully that's right. I am not sure of the formatting for having two conditions at the same time, or exactly how I would word either of the conditions. Any further help would be appreciated. Thanks again 🙂
Do you need help with states or buffs? Those are different things.
My extension allows you to add lines to check for buffs (like atk or def buffs), checking for states is a feature of the base plugin.
Do you need help with states or buffs? Those are different things.
My extension allows you to add lines to check for buffs (like atk or def buffs), checking for states is a feature of the base plugin.

To be honest, I understood and referred to buffs as states with a positive effect on the character. For example, if a state restores a percentage of HP per round, I would call it a buff. I suspect now it has a different meaning.

So, sorry, I mean a state. Just to clarify the situation -

I have an enemy type, let's say "Elf". The monster id is 8. This monster frequently fights in a troop with other types of monsters.

"Elf" has an ability, let's call it "improve". This ability grants one ally in the troop a particular state, call it "Fired up" [state id is 11].

I would like "Elf" to have a 60% chance of attacking each round, or a 40% chance of using this ability "Improve". However, it would only use "Improve" if both of the following conditions are met:

An "Elf" ally exists - the spell should not be castable on other monster types, or on the casting monster.
AND
The target does not already possess the state [11] granted by "Improve".

If either or both of these conditions are not met, the Elf would simply attack.

I hope that's clear now. Sorry if I confused things with my use of "buff".
So you want to combine the "doesn't have state" and "id = X" conditions.
Well, by default Battle AI core doesn't allow you to pass eval to targets individually. If you don't want my extension you're gonna have to use an invisible state on your elves enemies and combine "doesn't have state (improve)" and "has state (elf)". (write both conditions individually and use +++ between then IIRC the syntax properly).

My extension allows you to pass an eval to each fighter individually, but you wouldn't know about it unless you've read the code since I haven't documented it.
Code:
TARGETEVAL (!target.isStateAffected(improveId) && target._enemyId === elfId) : Skill X
That should do the trick.

I'd consider using the invisible state trick instead of adding a plugin in your game just for that though.
Success! Of a sort...

Turns out from what I read you cannot have multiple conditions [maybe using Eval, but I am not sure how to do that yet] with the battle AI Core. But there was an easy workaround using your invisible state idea. I had the "Improve" spell also add an invisible second state called "Immune to Improve", which I also give as a passive state to enemy types I do not wish to be improved. By doing that, using:

<AI Priority>

State !== Immune to Improve: Skill 37, Lowest HP%

</AI Priority>

works fine as far as enemies no longer use the skill on already improved enemies, nor on other enemy types. So thanks a lot!

However, enemies do sometimes still use the skill on themselves [when they haven't yet been improved]. I wish them only to be able to use the skill on allies, but not themselves. Any idea on this final point?

Edit: I thought I would be able to fix this final point myself using Yanfly's Target Core:

<Target: All Allies But User>

in the skill notetag. But it still sometimes acts on itself. Is this because of the Lowest HP% in the target? I thought that would apply within the allies but user parameter...
As per the plugin doc:
Code:
 * To add multiple conditions, simply insert a +++ between each condition like
 * the following examples:
 *
 *     Switch 1 on +++ Switch 2 on: Fire, Lowest HP%
 *     Turn 3 > 1 +++ Variable 5 <= 100 +++ Switch 3 on: Ice, Lowest HP%
 *     Random 50% +++ Highest Party Level > 50: Thunder, Highest HP%

So maybe:
Code:
EVAL ( user !== target) +++ State !== Immune to Improve: Skill 37, Lowest HP%
That should work.
As per the plugin doc:
Code:
 * To add multiple conditions, simply insert a +++ between each condition like
 * the following examples:
 *
 *     Switch 1 on +++ Switch 2 on: Fire, Lowest HP%
 *     Turn 3 > 1 +++ Variable 5 <= 100 +++ Switch 3 on: Ice, Lowest HP%
 *     Random 50% +++ Highest Party Level > 50: Thunder, Highest HP%

So maybe:
Code:
EVAL ( user !== target) +++ State !== Immune to Improve: Skill 37, Lowest HP%
That should work.

Thank you so much for your continued help with this. Gradually I understand more and more. It's still not working, though. :/

I tried what you suggested in the Note box for the enemy. I also tried:

<AI Priority>

EVAL ( user !== target) +++ State !== State 20: Skill 37, Lowest HP%

</AI Priority>

Neither work. If I remove the first part, for example:

State !== State 20: Skill 37, Lowest HP%

The skill works and they cast it, but obviously still giving the condition sometimes to themselves. The problem is in the EVAL, somewhere. The skill is definitely 37, and the state is definitely 20. I also tried with Eval instead of EVAL, with removing the gap after the first bracket, removing the brackets altogether, putting both parts in brackets... nothing.
My advice is to dodge the issue. Create a passive state using yanfly auto passive state and give it to your elf enemies (or add it turn 0 via a battle event).
Combine the conditions "has state elf" and does not have state "improve", see if it works.
If this doesn't combining conditions is broken and you should reproduce it in a minimal project and report to yanfly.

This still won't fix the problem on them casting it on themselves though...
I now remember why I made the target eval function in my extension. Try eval (user !== target) as a condition on its own, and I'm fairly sure it won't work. targeteval (user!==target) using my extension should work though.
Oh my God, it's working. Thank you so much.

Using your plugin and Yanfly's, this did it:

<AI Priority>

targeteval (user!==target) +++ State !== State 20: Skill 37, Lowest HP%

</AI Priority>

Original thread: https://forums.rpgmakerweb.com/threads/help-with-yanfly-yep_battleaicore.105918/