Difference between revisions of "Combat AI"
Line 9: | Line 9: | ||
The skill conditions panel can be used to set conditions for casting a skill (e.g. prohibit using a skill if the caster is still full health), set flags for the skill, or apply a simple score modifier. | The skill conditions panel can be used to set conditions for casting a skill (e.g. prohibit using a skill if the caster is still full health), set flags for the skill, or apply a simple score modifier. | ||
<ul> | <ul> | ||
− | <li>AiFlags: AiFlags can be set on a [[#AiFlags|skill on a global level]], but they can also be set in the skill conditions. A list of the flags and what they do can be found [[ | + | <li>AiFlags: AiFlags can be set on a [[#AiFlags|skill on a global level]], but they can also be set in the skill conditions. A list of the flags and what they do can be found [[CombatAi_AiFlags|here]]</li> |
<li>MinimumImpact: The skill should impact at least this amount of characters in a <i>positive</i> way, or else it can not be used. Positive in this case means it's benefitial for the caster: e.g. healing an ally, or damaging an enemy</li> | <li>MinimumImpact: The skill should impact at least this amount of characters in a <i>positive</i> way, or else it can not be used. Positive in this case means it's benefitial for the caster: e.g. healing an ally, or damaging an enemy</li> | ||
<li>OnlyCastOnSelf: The skill can only be cast on self. Can be used, for example, to force a character to only use the bless skill on itself</li> | <li>OnlyCastOnSelf: The skill can only be cast on self. Can be used, for example, to force a character to only use the bless skill on itself</li> |
Revision as of 14:36, 11 September 2017
Contents
Introduction
Ai 2.0 or, as we'd like to call it, Jane (used to be an abbreviation, but we already forgot about it the next day) no longer uses a script for every single skill to reason about its usage. Almost all logic has been moved to code, and all that's left in script is starting the Ai calculation, stopping the Ai calculation, and executing the action that has been selected by Ai. This script logic can be found in DefaultBehaviour.charScript. The Ai now takes into account the properties of a skill, the statuses that are applied, the weapons that are used, the items nearby, etc. It (attempts) to simulate what's going to happen if it will use a certain skill at a certain target and assign a score to it. The action with the highest score will be executed. All this happens automatically, so a new skill or status can be used by Ai without any extra steps. Of course, there are exceptions, and you'd still like to guide or override the Ai from time to time. That's what this page tries to cover in detail.
Guiding Ai
There are multiple ways to guide Ai into certain actions or behaviour. Skill conditions, archetypes and modifiers, and AiHints are all supported by Ai and are used by Ai during the score calculation. Any other way to guide Ai might result in incorrect behaviour (but you're welcome to try).
Skill conditions
The skill conditions panel you get when adding a skill to a character The skill conditions panel can be used to set conditions for casting a skill (e.g. prohibit using a skill if the caster is still full health), set flags for the skill, or apply a simple score modifier.
- AiFlags: AiFlags can be set on a skill on a global level, but they can also be set in the skill conditions. A list of the flags and what they do can be found here
- MinimumImpact: The skill should impact at least this amount of characters in a positive way, or else it can not be used. Positive in this case means it's benefitial for the caster: e.g. healing an ally, or damaging an enemy
- OnlyCastOnSelf: The skill can only be cast on self. Can be used, for example, to force a character to only use the bless skill on itself
- StartRound: The skill can only be used from this round. Everything below and including 1 means it can be used from the start
- HasNoMagicalArmor: The skill can only be used if the source/target has no magical armor
- HasNoPhysicalArmor: The skill can only be used if the source/target has no physical armor
- MaximumHealthPercentage: The skill can only be used if the source/target has a health percentage lower or equal to this value
- MinimumHealthPercentage: The skill can only be used if the source/target has a health percentage higher or equal to this value
- Tags: The skill can only be used if the source/target has these tags
You may have noticed that the italic conditions in above list are listed twice in the skill conditions. It's possible to set these for both the source (the caster of the skill) and the target of the skill (if the skill has a direct target).
Tip: Tags can be used for any skill condition that is not part of the standard skill conditions. You can create a custom tag and a script that assigns/removes a tag based on scripted conditions.
The last skill conditions are the difficulty modes. These are simple checkboxes to enable/disable a skill on a certain difficulty. The very last thing on the list, the score modifier, is exactly what it says it is: a score modifier. If you want the Ai to use a skill more often, even if it's not that good at all, you could increase the score modifier. You could also use to, for example, force Ai to cast a certain skill after an event: set a high score modifier and set a source tag condition for a tag that you apply via script.
Archetypes and modifiers
AiHints
The EXTERN script variables AiHints and StayInAiHints You can assign a tag to the EXTERN AiHint parameter in the DefaultBehaviour script for the Ai to use. Ai will find AiHintAreaTriggers with this tag and use these during the calculation. The AiHintAreaTriggers with the specified tag (referred to ai AiHints from now on) are areas where the Ai would prefer to stand when attacking. You could use this when you, for example, want a ranger to prefer standing on some platforms in the back instead of on the lower ground. Keep in mind that it does not force the Ai to stay in the AiHint. For that you also need to enable the StayInAiHints parameter in the same DefaultBehaviour script. This forces the Ai to always stand in the AiHint, even if it blocks it from attacking. There's only 2 exceptions to this rule:
- All of the AiHints are filled with dangerous surfaces (all of them full of fire for example)
- The character has been moved outside of the AiHint (started outside of it or has been teleported for example) and is not able to attack anyone from any AiHints. In this case it will try to attack anyone without moving.