I need help with particular enemy AI behavior

So hello, I'm back here and in making RPG Maker after a long hiatus and complicated sequence of events and I'm trying to relearn everything. During my long hiatus I was conceptualizing my next big game idea and while trying to make some of the Enemies I come to a hurdle. Let me break it down.

So I have a Wolf enemy that can do two things: Attack and Howl. Howl basically increases all ally's Attack by 25% (made it into a state instead of a standard parameter increase) and can stack. My goal is to do the following:
  • Make the wolf have a 50/50 chance of using either Attack or Howl, but Howl can only trigger every 2+3*x turns, so that means they can't use it on Turn 3 for example.
  • Make it so that the wolf will NOT use Howl if it and other wolves in the troop has already used it or if they all have the Howl buff present already.
  • Make it so that no two or more wolves will use Howl on the same exact turn.
I tried many methods like experimenting with switches and troop events but it won't work the way I want it. At my best attempt, the wolves seem to have no longer howl at the same turn, but at the next turn (and it's not even the designated turn yet) a wolf kept on howling despite already having the Howl buff active on everyone.

So can someone give me advise on this? Maybe I did something wrong, or maybe what I'm aiming for is impossibe. Just let me know.

Oh yeah, I also happen to have Yanfly's BattleAICore Plugin and if someone have tips on how to do the following above using that plugin, let me know.
a 50/50 chance means that you need both skills on the same rating in the action pattern.

and you need them multiple times for different cases.

the action pattern rules means that only the highest active rating and the two number below will count.
so you have one attack on rating 3, together with one how on your turn restriction also on rating 3.

you then need a second pair at rating 6 (which is the lowest that ignores rating 3), but never use always here, both skills need to be conditioned to a state.

and that state you set on the troop events, end of the previous turn with a duration of 2 turns to determine which skills will be available next turn after checking everything.

this way you can have basically 3 completely different action patterns with different behaviour - the default at rate 3, one special at rate 6 and a second special at rate 9.
you can use states for rate 6 and for rate 9 to trigger them by troop events at turn end, and then decide which enemy should get which skill selection next turn (removing or adding skills to the groups of 6 or 9 where neccessary.
The only part of this that I'm not sure about is multiple wolves using Howl on the same turn. But we'll give it a go.

Using the Battle A.I. Core, here are the conditions you're asking for:
- 50/50 chance: RANDOM 50%

- every 2 + 3x turns: EVAL ($gameTroop.turnCount()-2) % 3 == 0

- every wolf already has the buff: EVAL $gameTroop.aliveMembers().length == $gameTroop.aliveMembers().filter(enemy => enemy.isStateAffected(x)).length
where x is the ID of the state

- not more than two wolves using it on the same turn, we're gonna try: EVAL $gameTroop.aliveMembers().filter(enemy => enemy._actions(0).item().id==x).length<2
where x is the ID of the skill

So you just string all those together using +++ per the plugin instructions. Underneath it list Attack as a default.
The only part of this that I'm not sure about is multiple wolves using Howl on the same turn. But we'll give it a go.

Using the Battle A.I. Core, here are the conditions you're asking for:
- 50/50 chance: RANDOM 50%

- every 2 + 3x turns: EVAL ($gameTroop.turnCount()-2) % 3 == 0

- every wolf already has the buff: EVAL $gameTroop.aliveMembers().length == $gameTroop.aliveMembers().filter(enemy => enemy.isStateAffected(x)).length
where x is the ID of the state

- not more than two wolves using it on the same turn, we're gonna try: EVAL $gameTroop.aliveMembers().filter(enemy => enemy._actions(0).item().id==x).length<2
where x is the ID of the skill

So you just string all those together using +++ per the plugin instructions. Underneath it list Attack as a default.
I tried this one and by the second turn (the first time the move should be done), both wolves used Howl. However in the following designated turns, they howl only one at a time and there's even a point at Turn 7 where both just attacked instead of either howling. So aside from the "multiple wolves using Howl" part, I think this advice is working for me.
So aside from the "multiple wolves using Howl" part, I think this advice is working for me.
Oh, sorry, I misread that. I read it as "not more than two" not "only one" using it per turn.

Change that condition to
Code:
EVAL $gameTroop.aliveMembers().some(enemy => enemy._actions(0).item().id==x)
where x is the ID of the skill

there's even a point at Turn 7 where both just attacked instead of either howling.
I don't really understand that bit - they should only be able to attack on turn 7. Along with turn 6 and any other turn that isn't 2 + 3*x, as you put it.
a 50/50 chance means that you need both skills on the same rating in the action pattern.

and you need them multiple times for different cases.

the action pattern rules means that only the highest active rating and the two number below will count.
so you have one attack on rating 3, together with one how on your turn restriction also on rating 3.

you then need a second pair at rating 6 (which is the lowest that ignores rating 3), but never use always here, both skills need to be conditioned to a state.

and that state you set on the troop events, end of the previous turn with a duration of 2 turns to determine which skills will be available next turn after checking everything.

this way you can have basically 3 completely different action patterns with different behaviour - the default at rate 3, one special at rate 6 and a second special at rate 9.
you can use states for rate 6 and for rate 9 to trigger them by troop events at turn end, and then decide which enemy should get which skill selection next turn (removing or adding skills to the groups of 6 or 9 where neccessary.
I also tried this method and I'm having a difficult time trying to understand the last part. Eitherway, I tried it and the wolves were still howling on the same turn, but then they howled together on the next turn where the turn condition wasn't even met. I might've got something wrong with this method so yeah please forgive me.
Oh, sorry, I misread that. I read it as "not more than two" not "only one" using it per turn.

Change that condition to
Code:
EVAL $gameTroop.aliveMembers().some(enemy => enemy._actions(0).item().id==x)
where x is the ID of the skill
I did the following, and it worked out quite okay until by (I think I counted Turn 16?) where both used Howl on the same exact turn.
I don't really understand that bit - they should only be able to attack on turn 7. Along with turn 6 and any other turn that isn't 2 + 3*x, as you put it.
I think I might've miscounted and it happened on Turn 8. Eitherway, I also want them to have a chance to just do an Attack on that turn which is why I stated above that both Attack and Howl have an even amount of chances to be used on the turns that Howl can be used.
I did the following, and it worked out quite okay until by (I think I counted Turn 16?) where both used Howl on the same exact turn.
Well, I did say it was a try. But if it works most of the time, I think that's pretty good - do you really expect your fight to take 16 turns or more? 😉

Eitherway, I also want them to have a chance to just do an Attack on that turn which is why I stated above that both Attack and Howl have an even amount of chances to be used on the turns that Howl can be used.
...which is why the Random 50% is one of the conditions. But if you have multiple wolves all checking at the same time, odds are good that one of them is going to make that 50% check of doing the howl, so I'm not very sure what you're getting at.
Well, I did say it was a try. But if it works most of the time, I think that's pretty good - do you really expect your fight to take 16 turns or more? 😉
Yeah, you're right. Wolf fights aren't expected to last 16 turns. I expect it to just last 2-4 turns, but I still wanted to check the chances. Besides, Howl won't be used by just these early game wolves.
...which is why the Random 50% is one of the conditions. But if you have multiple wolves all checking at the same time, odds are good that one of them is going to make that 50% check of doing the howl, so I'm not very sure what you're getting at.
Yeah, I get that part as well. If I ever need to adjust the frequency of Howl for game balance, I suppose I just needed to change the Random 50% part.

Anyway, thanks for the help! It's a really big one. 👍
I'm having a difficult time trying to understand the last part.
basically that is a way I came up with to have a purely evented but still complex AI where the troop event can control what the entire troop will do next turn.
I tried several times to write a tutorial about it, but unfortunately I'm bad at the required screenshots and it is difficult to understand wthout screenshots as everything has to fit together.

Original thread: https://forums.rpgmakerweb.com/threads/i-need-help-with-particular-enemy-ai-behavior.152618/