Plugin Request: Better Enemy AI Targetting

(I'm going to explain in as much detail what I am requesting in this post. I'm not trying to be rude or demanding, just, as someone who's taken requests before, I myself much prefer having TONS of details, rather than vagueness, so that's what I'm gonna write here.)


I am requesting a plugin that will improve enemy AI's, specifically, how they target their actions. As oppose to other enemy AI scripts, such as Yanfly's AI Core, what I am requesting does not override the default enemy move selection system, but instead builds upon it. This makes it more newcomer friendly, easier to read, and I think also will make on the whole smarter AIs. I will explain below.


In VX Ace, I have used for years a modified version of this script, by Shad3Light:




(I've wanted to thank him for this script for years, but he hasn't logged on in so long!)


This is a great, and very easy to use, system. In my time with it, I've also improved upon the few problems I saw with it, namely with its sorting and randomizing methods.


I am asking for essentially a system like this, but improved in a few spots.


My algorithm goes as such:
> Enemy picks an action from their action list, based on how skills are normally selected (turn, rate, switch, etc.)
> Find all potential targets for this selected skill.
> Shuffle, randomizing all these targets.
> Sort them based on the notetags (Examples and explanations below in spoiler).
> Choose the target based on what was sorted to the top.
> Use that skill on that target.


Example Enemy:

Spoiler
Enemy Moves:



Edward Slayer, used every 3x turns, rate 9
Default attack, used every turn, rate 1
MP Drain, used when switch 3 is on, rate 2
Speed Buster, used every 1 + 3x turns, rate 5


Pretend Notetags:


<action_target: 1>
    if((b.state?(5) || b.state?(3))
        return 0;


    if(b.name == "Edward")
        return 2;
    else
        return 1;
</action_target>
//This checks to see if there is any actor named Edward on the team, prioritizing them. However, states 5 and 3 grant physical damage immunity, so anyone with those 2 states are prioritized the lowest, even if they're named Edward.
//Due to the 2nd part of the algorithm, shuffling all the targets, if 2 equally valid targets are selected at once, say 2 team members named Edward, a random one will be picked. However, if there is only 1 Edward, then that 1 will always be sorted to the top.
//Sorted: An Edward if he doesn't have states; Everyone else not with states; Everyone else with either of those 2 states.


<action_target: 2>
    if(!b.state(5) && !b.state(3)){
        return (1 - (b.hp / b.maxhp));}
    else{
        return 0;}
</action_target>
//Going with before, this will try to avoid actors with those 2 physical immunity states.
//However, after finding someone who's not in those states, it'll sort for the one with the least HP percent.
//Sorted: Lowest HP to Highest; Has State 3 or 5.


<action_target: 3>
    return b.mp;
</action_target>
//Sorted: Most current MP.


<action_target: 4>
    if(a.spd > b.spd)
        return 1;
    else
        return 0;
</action_target>
//Checks all targets based on their speed compared to the enemy's. Selects a target with a higher speed, if one exists.
//Sorted: Higher Speed; Everyone else.



That's my plugin request. An extension of the default enemy AI, as oppose to an overhaul of it. If it can be compatible with Yanfly's AI Core, that's great, but not needed. This is a pretty different AI system than Yanfly's, after all!


So, thank you for your help!


And thank you Shad3Light for a brilliant little Ruby script!
Alright, I've edited the original post. There was a part about changing enemy Action Rating variances that really would be suited for a different plugin. It was pretty unrelated, really! As such, I've removed it, and shortened this post.
Bump.


I hope I'm not the only one interested in this. I swear, it does have a lot of good use potential, heh!
Bump!
Not sure how much longer this'll be bumped. Maybe its too complex for just a request, and would be more realistic for a commission.
This might set you on the right course, though if you really need it to be that specific then I don't know who might be willing to help you, but good luck!
Yeah, that's what I'm currently using. It's just... a little limiting. It works, but it has a lot of problems. Like, only 1 condition on each skill, instead of as many as wanted. Yanfly usually gives crazy wonderful Lunatic Mode stuff, but its not there in the AI Plugin. You only can do the pre-set single checks, no like "Doesn't have this state AND has this other state" or "Target is at Low HP AND isn't immortal". It works, and if I have to use it its most certainly better than without it, but it has several spots for improvement.


...Not to be harsh on Yanfly! He provides an astronomically huge amount of great free content! It's just this one I feel isn't up to his usually amazing quality.
If you have any experience with Javascript it shouldn't be too hard to tweak if you have the time, just very tedious.


But yeah, this is a pretty complex request to just put out there and expect someone to be able to do. And if this is how complicated you want the enemy AI to be, then I can only imagine what else you're going to implement in your project. Check out Project Recruitment, and see if you can find someone who would be willing to work with you as a scripter. Stuff like this takes a lot of dedication.
I have thought bout attempting to write some code myself, as I DO have some javascript experience. Notetags are an absolute nightmare for me, though.


Truth be told, I didn't REALLY expect anyone to make this. But... I don't see any harm in making the request. Worst case scenario, no one makes it. As for the Project Recruitment, I'll keep it in mind for the future, but, as of now, I'm not sure if even I'M committed to my game, much less asking others to help. I'm doing this in my spare time between working full time. It would be disingenuous to ask for help from others when I can't guarantee even myself.
Galv also have a plugin for enemy ai. Mabye you want to use it.


https://galvs-scripts.com/2016/08/28/mv-enemy-ai/
That's a very good plugin for dynamically generated enemies, as it puts the AI on the skill rather than the enemy. It's not really what I[m looking for, but for different types of games, it could be great.

Original thread: https://forums.rpgmakerweb.com/threads/plugin-request-better-enemy-ai-targetting.65998/