In Battle AI, the enemies go through various AI nodes to finally choose few combatants from player group as Found targets (depends on their attack range, in which row the combatants are, if they are invisible/hidden etc.).
At the end, the enemies have several potential targets (0-4) from the player group. But then, they always select the first player combatant on the list, no matter what I do. Is there any way how the nemies would choose random combatant from the group of Found targets? I tried to use for example "Change Selected Target" at the end of the AI schematic (Index: Random set to 0-2 and Remove Target checked - I hoped it will randomly remove one combatant from the Found targets but I obviously don't understand how this works at all :-D).
Also - how to easily find what is the index number of combatant in the battle? Does it work similar to index number of combatants in player group, where the number stays the same is set as the combatant is added to the group, so first combatant has index number 0, the second has 1, third 2 etc.?
NOTE - I use turn-based combat, first-person view in style of Legend of Grimrock / Dungeon Master, with combatants placed in front or back row (this is set via Status Effect).
Thanks!
An action node in your battle AI will provide the found targets for the action and get the actual target based on the AI settings. So, if your battle AI has all player combatants as found targets and the action targets a single combatant, the user having Attack Last Target enabled will use the last target if it's part of the list, otherwise falling back to other settings (e.g. nearest target), or use a random one out of the list of found targets.
You can randomize this in your battle AI via selected data (e.g. doing this in a separate battle AI to make it reuseable wherever needed):
1) Select Combatant node to store all found targets into selected data:
- use all combatants: enabled
- combatant scope: current
- combatant origin: combatant
- user: found targets
2) Select Selected Data node to store a random combatant from the selected data of #1 into selected data (either same data key to replace it or a new one, doesn't matter).
3) Clear Found Targets node to remove all found targets.
4) Use Combatant node to use the random combatant from selected data (from #2).
As for the battle index number - that's not really available as a metric :)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
So the Battle AI to select 1 random target from previously found targets looks like this:
And it looks like this in simple AI for melee combatant:
Also, for new user of ORK - if you have very complex battle system and combatant behaviours with tens or hundreds of combatant types, I would recomend to use the system like it's shown above. I'm creating many many smaller and specific Battle AI for specific purpose, for example if the combatant should use healing potion, cast support spell on his ally, move to different position etc. Each of this "chunk of AI" can be very complex since it tests many conditions, so I create individual Battle AI for it.
Then, I create Battle AIs starting with name "AI PACKAGE" where I add various of these special-purpose Battle AIs, one after another, as needed for this specific combatant. Something like "Only melee combatant" or "Supporting caster and melee combatant" or "Shooter - coward". So each enemy combatant in ORK has assigned only one specific "AI PACKAGE" which makes it very easy to manage and also to later adjust.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!