Behaviors
The AI plays based on different defined behaviors. At the start of the turn, the AI process all possible moves, then carry out an action according to various parameters. A delay time is called during the processing phase in order to avoid lags and freezes. The duration of this delay is defined by the parameter AI Process Delay
in the main plugin.
Set Up AI Actions
Your skills should have some parameters in order for the AI to properly use them. That's how the AI can tell when a skill should be seen as a healing skill, for instance. Use the ai tag for this purpose.
<letbs_AI>
type: string1, string2
...
</letbs_AI>
These are available types of skills that the AI can process:
offense
: Offensive skills. The Ai will tend to use them aggressively, targeted directly a battler.healing
: Healing skills.support
: Skills that apply states. The AI will use them right away then they are available, to buff or debuff itself or another battler.move
: Skills that change the position of the caster. They are used to reach a specific target or to flee.push
: Skills that push the targets. The AI may use them to flee.pull
: Skills that pull the targets. The AI may use them to be close to a target.summon
: Skills that summon entities.
Options
You can add some parameters, restrictions or additional information to the skills to help the AI to make logical choice. These are ai tags.
maximise_targets
:
Should be used if the skill is an AoE. The AI will use it by targeting the maximum of available targets.avoid_friendly_fire: number%
:
Used with AoE skills. It determines at wich rate the AI should avoid friendly fires. If that value is 100%, the AI will never use an AoE which target an ally. In the same way, enemies are avoided when using AoE healing skills.escape_condition: string
:
This ai tag should be used withmove
andpush
type skills. The string is evaluated to determine when that skill can be used to escape. Is there is no condition the AI will always use them. Beware. It's up to you to set up when a skill should be used to escape.
In the stringa
refers to the user ande
to the user's entity object.
Example:escape_condition: a.hpRate() <= 0.15
.
It means the AI will use this skill to escape once its HP is bellow 15% of the MHP.use_condition: string
:
That string is evaluated during the processing phase to determine if it is usable or not. This is usefull for healing skills to define the proper moment to use them.
b
refers to the target ande
to it's entity object.
Example:use_condition: b.hpRate() <= 0.6
.
The skill is used only if the target's HP is bellow or equal 60% of it's MHP.summon_near: string
:
Used with summon type skills to indicated where to summon. Nearcaster
,enemies
orallies
.
Behavior Order
This is the default behavior order:
- Heal
- Escape
- Summon
- Support
- Offense
The AI checks available behaviors in this order. The first available behavior if chosen and played.
Beware Of Always Available Skills
Following the behavior order, the AI uses available skills right away, and always, as long as they can be used. That's why using cooldown is mandatory here. For instance if a summon skill is always available and usable, the AI will uses it every turn. You need to set up a cooldown so that it can execute the other behaviors. Use Yanfly's CD plugin.
Creating Behaviors
AI behaviors are configured in the Lecode.S_TBS.Config.AI
module. A behavior is like an action sequence, a list of commands.
(WIP)
Extra Features
Make The AI Focuses an Entity
The tag focused_by_ai_for_[type]: priority
can make the AI focuses its actions on an entity. It can be applied on states and equipment. type
can be replaced by key words such as offense
, healing
, ect.
For instance, is focused_by_ai_for_offense: priority
is used, the AI will focus its offensive actions on the designated entity.
If there are many focused entities, the one with the higher priority will be selected.