Complex enemy behaviour - best approach?

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
I'd like to gauge opinions on how to set up complex, or relatively complex, enemy behaviours. I've excluded monster action patterns because they're too limited - except the turn one, that is actually good, it's a shame that apparently it's bugged.

Example behaviour: boss monster with 2-5 standard actions per turn (explained).
So, the behaviour of the boss monster should be:

1-use Dispel Ray on target & infict state
THEN
2-use bite on same target of dispel ray, if the state connects
OR
3-use spell 1 on random target NOT affected by dispel ray
4-use spell 1 on random target NOT affected by dispel ray
5-use spell 1 on random target NOT affected by dispel ray
EXTRA (5% chance every turn)
6-Use a random skill from a pre-determined skill pool

Option 1: Troop Eventing.
This one seems the easiest and perhaps the one with most control thanks to abuse of "force action". But on the other hand, how to deal with conditions that affect skill usage?

Option 2: Action Sequence.
This one seems potentially very promising, but some of the same issues of option 1 apply (how to deal with silencing states, for example, or any debuff-impediment). Also, it doesn't specify if using different skills is possible at all. Nor any chance to understand percentages.

Option 3: notetags.
I have little confidence on how this this could work, at least with just VS notetags. It could work with a mix of strategic cooldowns, but otherwise I am not sure.

What do you think?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
38,500
Reaction score
10,916
First Language
German
Primarily Uses
RMMV
Somehow you seem to miss the most basic option:
Action Patterns, and especially action patterns controlled by troop events.

Basically at the end of each turn, use a troop event to determine what the enemy should do the next turn and then place a control state on that enemy.
At the beginning of the next turn, the enemy action pattern will then select the corresponding skill without any use of force action at all.

You just have to create a number of those control states (invisible states doing nothing and lasting exactly 2 turns) and have them as conditions in the action patterns.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
Somehow you seem to miss the most basic option:
Action Patterns, and especially action patterns controlled by troop events.

Basically at the end of each turn, use a troop event to determine what the enemy should do the next turn and then place a control state on that enemy.
At the beginning of the next turn, the enemy action pattern will then select the corresponding skill without any use of force action at all.

You just have to create a number of those control states (invisible states doing nothing and lasting exactly 2 turns) and have them as conditions in the action patterns.
Would you mind sharing a practical example of it? I've no idea how to make it work with control state.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
38,500
Reaction score
10,916
First Language
German
Primarily Uses
RMMV
I don't have much time, so I hope this is enough.

if the troop event assigns exactly one state to the enemy and removes all other states, the following action patter wil make the engine select the corresponding skill in the next turn.

you'll just have to check which skill is what for the enemies of any troop before writing the troop event controlling the enemy skills.
actionpattern.png
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
the troop event assigns exactly one state to the enemy and removes all other states, the following action patter wil make the engine select the corresponding skill in the next turn.

you'll just have to check which skill is what for the enemies of any troop before writing the troop event controlling the enemy skills.
I see, thank you. I appreciate you leaving this. But even with this method, I'm unsure of how this works with multiple actions in the same turn and/or different ailments, if all other states get removed.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
38,500
Reaction score
10,916
First Language
German
Primarily Uses
RMMV
in the troop event you can use conditional branches and other event commands to decide which skill to assign in different conditions.
you can even use random variables and so on.

but that is only one action per one enemy - if you want more actions you'll have no choice but to use force action for the second and following actions.
Those would have to be triggered either by common event or by another troop event that is conditioned to a switch or whatever else.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
but that is only one action per one enemy - if you want more actions you'll have no choice but to use force action for the second and following actions.
Those would have to be triggered either by common event or by another troop event that is conditioned to a switch or whatever else.
Thank you. Simply giving the enemy extra actions wouldn't work I guess. Troop eventing seems the best bet.
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,225
Reaction score
2,594
First Language
English
Primarily Uses
RMMV
I'd like to gauge opinions on how to set up complex, or relatively complex, enemy behaviours. I've excluded monster action patterns because they're too limited - except the turn one, that is actually good, it's a shame that apparently it's bugged.

Example behaviour: boss monster with 2-5 standard actions per turn (explained).
So, the behaviour of the boss monster should be:

1-use Dispel Ray on target & infict state
THEN
2-use bite on same target of dispel ray, if the state connects
OR
3-use spell 1 on random target NOT affected by dispel ray
4-use spell 1 on random target NOT affected by dispel ray
5-use spell 1 on random target NOT affected by dispel ray
EXTRA (5% chance every turn)
6-Use a random skill from a pre-determined skill pool

For something like this, I would just link their opening move to a Common Event, which is then used to force the boss to perform its next set of actions (use random variables if they need to perform an action at random, or if they should have a random number of actions per turn). It's not difficult, but it might take a bit of time to set up, depending on how much variables you're working with.
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,225
Reaction score
2,594
First Language
English
Primarily Uses
RMMV
Maybe something like your ACE system? :)

Yup, you could take a look at it if you like to do things by eventing. You can do a bunch of things with it.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
Yup, you could take a look at it if you like to do things by eventing. You can do a bunch of things with it.
I'm a bit confused however, does every enemy need its own event set?
 

TheAM-Dol

Randomly Generated User Name
Veteran
Joined
Feb 26, 2022
Messages
654
Reaction score
994
First Language
English
Primarily Uses
RMMV
Option 3: notetags.
I have little confidence on how this this could work, at least with just VS notetags. It could work with a mix of strategic cooldowns, but otherwise I am not sure.
Coincidentally I have been working on some boss logic recently, so I just wanted to drop something in here for your consideration.

Yanfly's Battle AI core (and I assume by extension, the VS equivalent) allows you to use notetags to set skill conditions and priorities.
I'm a little bit tired so it's difficult for me to explain concisely, so instead, as an example, here is my boss's logic and I'll explain how this works after:
I added numbers next to each skill in the list to make it easier to determine which skill I am referring, however in the actual engine when adding notetags you do not place numbers at the start of skill priority check.

Code:
<AI Priority>
   1.   Variable 235 <= 0 +++ Random 55% +++ Troop Dead Members > 0 +++ Troop Alive Members < 3: Skill 87, Lowest LUK
   2.   Variable 235 <= 0 +++ Random 30% +++ Troop Alive Members === 3: Skill 87, Highest LUK
   3.   MP% param <= 30% +++ Troop Alive Members === 4: Skill 86
   4.   Eval user.isStateAffected(84) === true: Skill 92
   5.   Random 50% +++ State !== State 84 +++ Troop Alive Members >= 2: Skill 91
   6.   Random 15%: Skill 77, Lowest MP
   7.   Random 50% +++ Eval user.isStateAffected(84) === false: Skill 88, Lowest MP
   8.   Random 65%: Skill 90
   9.   Always: Skill 50, User
</AI Priority>

This notetag is attached to the enemy, so it makes it much more transportable than using troop events where you would need to copy troop event pages into each troop that contains the same enemy to enable consistent behavior.

The notetag above, at it's most fundamental level is just a priority list, with the top of the list being the most important to execute and the bottom being the least important to execute. Then you can specify a number of different conditions using either some of the preset conditions from the plugin, or you can add your own conditions using JS eval.
In my boss above, you can see the fourth skill uses an eval to determine if the boss is currently affected by a specific state. If the boss is affected by that state, then the boss has access to a special skill that overrides one of his other skills. If he isn't affected by that state, then he doesn't have access to the special skill.
(there is a "state affected" preset, but this preset condition checks the target scope. So in an offensive attack skill, the scope is the opposing target - the player. So if I used the preset to check the state, it would be checking if the player has the state. The state is a self-buff the boss applies, so the player should not ever be affected by this state. Therefore, I used this eval to check if the boss is affected by the state in order to use a skill that has a scope that targets the opposing party.)

If you look at the very first skill on the list, I use a variable condition. In this specific boss fight I am using that variable as a cool down. When the boss uses the skill, it runs a common event that sets a variable to 5. Then in the troop event for this boss battle, every turn that variable gets 1 subtracted from it. In the AI conditions, you can see it's waiting for that variable to reach 0 or less to determine if that skill is off cool down.



It's really quite a powerful plugin and I think simplifies messy troop events a lot. I bring this up too because not so long ago I was also creating a spaghetti mess of invisible states and troop events with way too many variable controls and conditionals used to create smarter monster behavior. When @woootbm recommended I use Yanfly's AI core, it just cleaned everything up and made it so much easier to manage things.

So whether this solves your problem or not, I still just highly recommend it (or an equivalent type of plugin) to clean up enemy AI and move away from spaghetti troop events. (You can still use troop events, of course, but it just cleans up a lot of spaghetti on every single troop)

spaghetti.jpg
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
Thank you for your post, it's very detailed.

I do have the Battle AI plugin, but the specific notetag you use appears to be missing from enemy side. There's plenty for skills, however. if it is more powerful, I have no idea how.

Does your boss have multiple actions?
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,225
Reaction score
2,594
First Language
English
Primarily Uses
RMMV
I'm a bit confused however, does every enemy need its own event set?

If there's a certain behaviour you want all enemies in your game to possibly be able to follow, you just have to create the eventing for enemy #1 to #8. Then if there are exceptions, you can tag them by using States or Switches.

My event system deals with 99% of the battle eventing through Common Events that are referenced in the same 2 Troop pages in every Troop, the first page for the start of an encounter and the other that runs at the end of each turn (helps to create a template Troop at the start of your project that you can copy/paste to save on time). The only time you have to manually add stuff to an individual Troop's event page is if you have enemies that behave differently, such as a boss.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
If there's a certain behaviour you want all enemies in your game to possibly be able to follow, you just have to create the eventing for enemy #1 to #8. Then if there are exceptions, you can tag them by using States or Switches.

My event system deals with 99% of the battle eventing through Common Events that are referenced in the same 2 Troop pages in every Troop, the first page for the start of an encounter and the other that runs at the end of each turn (helps to create a template Troop at the start of your project that you can copy/paste to save on time). The only time you have to manually add stuff to an individual Troop's event page is if you have enemies that behave differently, such as a boss.
I'll have to look more carefully at your system!
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
OK so, I have experimented a bit with Battle AI and this and, unless I'm wrong, they seem to work well with each bother - but I get inconsistent results when it comes to priority - sometimes the AI plugin, sometimes your system.
 

Latest Threads

Latest Posts

Latest Profile Posts


3d Yandere RPG maker game by labylin
With this map, I tried to emulate a Gameboy Color/Advance style.
Hacknet's a hypocritical game.
It's a game about hacking... that's been made in Net framework and the code was left unobfuscated.
So it's a game about hacking that's vulnerable to hacking.
The irony. :p
My message count stands at 999. I was going to ask if I get anything special for hitting 1,000 but then I looked at the post count of some other people who shall remain nameless. Now I don't feel special anymore. I need to either start posting a lot more or wipe my tears away and just focus on my game. Hopefully my keyboard is waterproof. ;_;

Forum statistics

Threads
131,766
Messages
1,223,170
Members
173,533
Latest member
joeyidc
Top