MV Yanfly AI Core: Eval TP & eval State Resist

Hi!

I'm trying to make it so if an Actor has under # TP, it uses a skill. Something like:

User TP peram < 30: High TP Gain Attack, Lowest HP


I'm also trying to make it so if an enemy is resistant to a State, the Actor doesn't use it. Something like:

State !== Poison !++ State Poison Null: Poison Shot, Lowest HP%


I know the second one isn't even close. Basically just "If enemy State NOT equal Poison and NOT State Poison Null, use [Skill]." Does anyone know of an eval code I could use for these two? I know nothing about code stuff 🙁
well, for the first one you could write param instead of what you have but as far as i'm aware there's no TP option in the plugin.
You could try to store the actor's tp in a variable and in the script area you would write:
$gameActors.actor(actorid).tp
And if you need it for different actors aswell just make more variables.

Variable 3 < 30: High TP Gain Attack, Lowest HP

for the second option you could try this and see if it works

Eval !target.isStateResist(stateid): Poison Shot, Lowest HP%
well, for the first one you could write param instead of what you have but as far as i'm aware there's no TP option in the plugin.
You could try to store the actor's tp in a variable and in the script area you would write:
$gameActors.actor(actorid).tp
And if you need it for different actors aswell just make more variables.

Variable 3 < 30: High TP Gain Attack, Lowest HP

for the second option you could try this and see if it works

Eval !target.isStateResist(stateid): Poison Shot, Lowest HP%

The TP one worked perfect. For some reason, the Poison one doesn't.

Eval !target.isStateResist(4) +++ State !== 4: Enhanced Poison Shot, first

Eval !target.isStateResist(4): Poison Shot, first

The "Lowest HP%" wasn't working so I switched to "first" but dropping it entirely doesn't work either. I'm practicing on a training dummy that isn't Poison resistant and it's not using either skill at all. It just skips to the next section.

I've been having issues with States such as Actors not removing States from allies (Poison specifically but that's all I've been monitoring) so I'm wondering if it's something with that State or another Yanfly plugin changing things.

Thanks for the help with TP. That's one issue solved 😀
You could try to store the actor's tp in a variable and in the script area you would write:
There's no reason to use variables for this. You'd just make the condition:
Code:
Eval user.tp<30
Eval !target.isStateResist(4) +++ State !== 4: Enhanced Poison Shot, first

Eval !target.isStateResist(4): Poison Shot, first
No offense, but your JavaScript is way off - where the heck did you get +++ from? And just typing the word State doesn't mean anything. I'm not even sure what you're trying to say there.

Going off your first post, if you have an attack that poisons the target but you don't want them to use it on poison-resistant actors, that's:
Code:
Eval !target.isStateResist(4): Poison Shot, First
presuming your poison state is 4. I see you already tried that, but it should work. Perhaps having the invalid code above it broke the entire AI block. If you tell me what you're trying to achieve with that first one, I'll help.
Well, glad i could help more or less, damn i still can't believe i made such a silly mistake with the tp, well at least it has been taken care of.
We all do it, type out of our butts occasionally.
No offense, but your JavaScript is way off - where the heck did you get +++ from? And just typing the word State doesn't mean anything. I'm not even sure what you're trying to say there.

I got that from Yanfly's Battle A.I Core. That's how you enter the notetags and it works with other commands.

Perhaps having the invalid code above it broke the entire AI block.

Just removed it and tried. Still no luck. What I'm trying to do is have it use Poison Shot on an enemy that isn't poisoned as long as they're not also Poison resistant. Once that works I'll have it be the same for both lines. I made them different so I'd know if one code worked and the other didn't.

I also made the dummy Poison resistant, removed the ! from one line and it skipped both abilities. I added the eval code to a command I know works, and it stopped working. I wonder if there's another plugin that's messing with that code.

EDIT: I changed the command to be user instead of target and it started using the ability, so I know that the eval commands work. Now to find out why target doesn't.
I got that from Yanfly's Battle A.I Core. That's how you enter the notetags and it works with other commands.
I understand what you're saying, but I don't believe it will work with the Eval condition - once you type Eval, everything after it is evaluated as JavaScript, which +++ isn't.
What I'm trying to do is have it use Poison Shot on an enemy that isn't poisoned as long as they're not also Poison resistant.
Okay, so at this point we need to make sure that the commands in the plugin are actually functioning properly for you.

First thing: make sure you're testing all this by making changes, saving, then actually launching a new play test game. Do not attempt to test this with the battle test from a troop, because that doesn't always correctly work with all plugins.

Second thing: Turn off all plugins except the requirements for the A.I. Core.

Third thing: Test that the Eval condition is correctly evaluating JavaScript entered after it. Make it something straightforward like Eval target.name()=="Harold": where Harold is the name of one of your party members. Give it a unique skill (not your standard attack) and make sure that's working properly.

If it is, go back to some of the more complicated stuff - the JavaScript for what you want is:
Code:
Eval !target.isStateAffected(4) && !target.isStateResist(4):

If the targeting based on the name works but that one doesn't, we'll troubleshoot the functions about states. If the first test with the targeting doesn't work, we'll look at the plugin code to see how it's executing Eval conditions (and you'll include an actual screenshot of your enemy note area).
I understand what you're saying, but I don't believe it will work with the Eval condition - once you type Eval, everything after it is evaluated as JavaScript, which +++ isn't.

I was intrigued by this hypothesis as I myself also use BattleAiCore.

I can confirm though that chaining multiple conditions (including one or more Eval's) is possible.

For example this:

<AI Priority>
Eval user.isStateAffected(69) +++ Eval user.isStateAffected(59): Skill 1
</AI Priority>

The enemy with this notetag would ONLY use Skill 1 if he was affected by both state 69 and 59.



As for the original problem, my hunch is that you cannot use "target" in the eval as it is not defined at the moment the plugin checks the conditions.
I can confirm though that chaining multiple conditions (including one or more Eval's) is possible.
Thanks for testing that - Yanfly must have included it as an escape code in the Eval parser.
As for the original problem, my hunch is that you cannot use "target" in the eval as it is not defined at the moment the plugin checks the conditions.
Hm! I've been using it that way because that's how it works in the Selection Control plugin - target is used in the Eval parameters to perform evaluations on potential targets before actually adding them to the list of viable selections. So I assumed this functionality would be similar.

However, it appears that you're correct and Yanfly didn't write the two plugins to handle similar commands (which is kind of bizarre to me). I found this extension plugin that should make everything we've been talking about work correctly:

So you'd use the code I gave above, and encase it in AIManager.targetCondition
I found this extension plugin that should make everything we've been talking about work correctly:

Oh this is nice, I might also take a look at it. Thanks for sharing.

@Katevolution
So to solve your problem, you should add the extension that @ATT_Turan shared and put it below BattleAiCore in your plugin manager.

Then try putting this in your Notetag:

<AI Priority>
Eval AIManager.targetCondition("target.isStateAddable(4) && !target.isStateAffected(4)"): Enhanced Poison Shot, Lowest HP%
</AI Priority>
Yay! Thanks everyone for helping. 😀
Moved to: Plugin Support

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-ai-core-eval-tp-eval-state-resist.140192/