Archeia's Advanced AI Conditions

Advanced AI Conditions
Version 1.0d
​
What is this?
This script allows the developper to exert better control on how the AI handles the enemies' action patterns.

Script configuration is almost entirely made via noteboxes and no RGSS3 knowledge is required to use it.

Features and Instructions

qwuXSOl.png
PART 1: DEFAULT AI CONFIGURATION

- TGR settings
TGR determine the frequency a target will be chosen during random targeting rolls. The configuration module below allows you to set how damage and healing affects TGR to make a character more threatening to the eyes of the AI.

- Skill settings
Every skill can be given default AI *targeting* conditions all enemies will use. To do it, you have to create an "AI block" in the skill's notebox.

Notetags explanation:
Code:
<ai_conditions>
    Explanation: You always start the block with this one.

    target_hpgt: n
    Explanation: The target HP must be greater or equal to n%.

    target_hplt: n
    Explanation: The target HP must be lesser or equal to n%.

    target_states: n, n...
    Explanation: The target must have the specified states already inflicted.

    target_states_not: n, n...
    Explanation: The target must NOT have the specified states already inflicted.

    only_if_target
    Explanation: If no suitable target is found, the skill won't be used AT ALL.

</ai_conditions>
Explanation: You always end the block with this one.

PART 2: ENEMY AI CONFIGURATION

On top on a default AI, you can setup individual AI conditions for every different enemy. In case of conflict with the default targeting AI, these settings will take precedence.
All these settings make use of the enemy's notebox.

NOTE: the term "action index" refers to the order of the action pattern you enter for enemies in the database. For instance, if your list is like this:

Attack
Fire II
Poison

Attack will be index 1, Fire II will be index 2 and Poison index 3. And so on.

Notetags explanation:

Code:
<ai_conditions: n, n...>
Explanation: One way of starting an AI block. 
`n` must be an action index. If you include multiple indices (comma-separated), the conditions will apply to each one.

use_id 
Explanation: Same as above, but `n` refers to skill IDs instead of action indices. `n` must be a valid skill ID.

switches: n, n... 
Condition: The specified switches must be ON.

variables: x, y, x, y... 
Condition: Variables `x` must be equal to the corresponding values `y`.

states: n, n... 
Condition: The acting enemy must have *all* of the specified states.

hpgt: n 
Condition: Acting enemy has HP greater than or equal to `n%`.

hplt: n 
Condition: Acting enemy has HP less than or equal to `n%`.

mpgt: n 
Condition: Acting enemy has MP greater than or equal to `n%`.

mplt: n 
Condition: Acting enemy has MP less than or equal to `n%`.

party_level: n 
Condition: Party level is greater than `n`.

turns_order: a+bx 
Condition: Matches the turn formula as seen in the database (e.g., `a + b * x`).

target_hpgt: n 
Condition: Target HP must be greater than or equal to `n%`.

target_hplt: n 
Condition: Target HP must be less than or equal to `n%`.

target_states: n, n... 
Condition: The target must already have the listed states.

target_states_not: n, n... 
Condition: The target must *not* have the listed states.

only_if_target 
Condition: If no suitable target is found, the skill will not be used at all.

</ai_conditions>
Explanation: You must end the block with this one.

- Creating Turn Patterns

Turn patterns is a special AI setting which completely replace an action pattern with another one at the designated turns. During a turn pattern, the "normal" actions (the ones you entered into the database) won't be taken into consideration, ever. You need to create another block to make a Turn Pattern.

Code:
<turn_pattern: a+bx>
Used to define the turn pattern. 
- `a` is the first turn when the action will occur. 
- `b` is the interval between turns after the first.

skill: a, b 
- `a` is the skill ID to be used. 
- `b` is the rating (priority) of the skill.

</turn_pattern>
End the pattern.
NOTE 1: You can put as many skill tags as you want.
NOTE 2: In order to assign conditions to a skill inside a turn pattern, you have to create a new AI block with that skill's ID.

- Absolute Rating

The absolute rating is a special rating you assign to an action during databasing your enemy. An action with this rating will take absolute priority, ignoring all others (even higher ones) provided it can be used.
If you have several actions with an absolute rating, one will be chosen randomly.

Download and Terms of Use

  • Contact me for commercial usage.
  • I will not be giving support or fixing bugs for you. I don't have time for that.
  • Please do not distribute them in one huge zip/rar/.7z/whatever compression without my permission.
  • You may use or edit the code as you please as long as it has proper attribution. However, you cannot change the license for the script e.g. removing the permission to use for commercial projects.
  • Please add me in your credits either as Archeia Nessiah/Division Heaven. It can be in the ReadMe/Game Credits/etc.
  • I am not liable for any destructive behavior that the materials could have caused you, such as, but not limited to, computer damage, incontinence, explosion of user’s head, coma, death, and/or halitosis. So edit or use at your own risk.
This looks fantastic! I'm looking forward to designing complex encounters, now.
This is nice... not as extensive as a full RGSS3 powered AI setting as you're limited to what to use, but nonetheless good and easier to use. :3

One thing I notice though is that this kind of script somehow would work better if we add an accompanying target selection script...
Ooooooooooooooooooh!!! Now this looks like this will be a lot of fun to mess around with. I've always wanted to have smarter AI enemies and bosses without having to rely on events to get things done. Excellent! Good show. 😀
Thank you for this awesomeness.
The target states function here is very convenient. The same can be done with Yanfly's scripts, but that requires adjusting individual skills. This way, everything can be done in the enemy pane. Awesome!
How do you make a group of enemies (Like wolves) target the actor with the lowest HP or the most negative states?
How do you make a group of enemies (Like wolves) target the actor with the lowest HP or the most negative states?
Download and Terms of Use

  • Contact me for commercial usage.
  • I will not be giving support or fixing bugs for you. I don't have time for that.
  • Please do not distribute them in one huge zip/rar/.7z/whatever compression without my permission.
  • You may use or edit the code as you please as long as it has proper attribution. However, you cannot change the license for the script e.g. removing the permission to use for commercial projects.
  • Please add me in your credits either as Archeia Nessiah/Division Heaven. It can be in the ReadMe/Game Credits/etc.
  • I am not liable for any destructive behavior that the materials could have caused you, such as, but not limited to, computer damage, incontinence, explosion of user’s head, coma, death, and/or halitosis. So edit or use at your own risk.
@Oddball - This is a script to determine what Action an enemy will do, not for choosing who to target... Those are different things

which is also why on my first post, I said

One thing I notice though is that this kind of script somehow would work better if we add an accompanying target selection script...
It has target controls to some extent but you would want to combine it with TGR.

not very straightforward though but only does it through conditions.

target_hpgt: nCondition: The target HP must be greater or equal to n%.
 
target_hplt: n
Condition: The target HP must be lesser or equal to n%.
 
target_states: n, n...
Condition: The target must have the specified states already inflicted.
 
target_states_not: n, n...
Condition: The target must NOT have the specified states already inflicted.
 
only_if_target
Condition: If no suitable target is found, the skill won't be used AT ALL.
But none of those are what i wanted. I'm not going to use this anyway, but i was talking about it comparing the HP of ALL the actors and targeting the one with the lowest, so that predatory animals like wolves seem to behave like real wolves. Eating the one's that are most likely to catch and spread a disease to the rest

your script only checks if a certain actors HP is below/above a certain point
I think there might be a misunderstanding here. The tag:

target_hpgt: n // Target HP must be greater than or equal to n%
target_hplt: n // Target HP must be less than or equal to n%

checks all potential targets' HP, not just one. It evaluates all the valid targets that can be attacked and helps identify which ones meet the specified HP conditions. So if you're using this to find who has the lowest HP within a certain threshold, it definitely works for that.

As for targeting by actor ID—unfortunately, that’s not something you can directly set.

If you’re referring to MAX HP instead of current HP, that’s a different use case. One workaround could be assigning a specific state to the character with the lowest MAX HP, which would then allow you to target them using target_states.

Honestly, it’s not too complex once you get the hang of how the system reads targets. I'm just responding to Engr. Adiktuzmiko’s comment about the limitations in target options. While it's true to a degree, I’m not entirely sure how much more control would be practical or necessary.
target_hpgt: nCondition: The target HP must be greater or equal to n%.
 
target_hplt: n
Condition: The target HP must be lesser or equal to n%.
Doesn't this just checks if the target HP is on a certain level? I think what he's asking is how to find the target with the LOWEST hp of them all
Thus why I proposed a workaround using either states or TGR based on their conditions.

Actually I do have a TGR script that does increase or decrease the target's TGR based on the condition of their HP or if they have a state, I can release that one too hm.
When I add:

<ai_conditions>

target_states_not: 49 <---- haste state id

</ai_conditions>

 

To a skill, I get the error message in the screenshot.

 

When I add the tag:

 

<ai_conditions 2>        action index 2, Skills: 1 = attack, 2 = haste

target_states_not: 49  <---- haste state id

</ai_conditions>

 

To an enemy, it still casts the buff on a target who has the state. What am I doing wrong?


1.png
Check the instructions and/or screenshots. You got the syntax wrong.
I don't see what I am doing wrong. I realize your busy, but according to the screenshot and your instructions, it says you have to create an AI block in the skill's notebox. The ai block has to start with <ai_conditions> and end with </ai_conditions>. There is no screenshot showing this in action. I am assuming you can do multiple commands inbetween.

So:

<ai_conditions>

target_hpgt: 5

only_if_target

</ai_conditions>

 

This should work, however it gives the error like before, saying num isn't a method or w/e. What syntax do I have wrong? I copied exactly from this thread from the instructions.


Can you show me an example of how it's working on a skill in your project please? I really want to use this script!
You create the AI on the enemy notebox. Not skill.
Oh..... Sorry, as posted above:

- Skill settings

Every skill can be given default AI *targeting* conditions all enemies will use. To do it, you have to create an "AI block" in the skill's notebox.
 
I read this and saw that it said skill's notebox. Thanks for the clarification!

So then, in the enemy notebox:
 

<ai_conditions 1>

target_states_not: 49

</ai_conditions>

 

This should only cast the skill when the target doesn't have the state, as you can see in the video, it just repeats haste on the same target.

 
You keep missing the : symbol. Here's an example use.

Code:
<ai_conditions: 4>
    target_hplt: 80
    target_states: 37
    only_if_target
</ai_conditions>

Are you using any other scripts? If you are test this first in a test project.
Like I said, I have to ask so many questions that I don't have time for support. Debug it first in an empty project and see if it still errors.

If it does then report, if it doesn't then check which script of yours is doing it.

But check the syntax like I said.

Original thread: https://forums.rpgmakerweb.com/threads/archeias-advanced-ai-conditions.36877/