This leads to bugs even in vanilla BB e.g. the perk_inspiring_presence
never working for AI even though characters such as standard_bearer
have them.
Cause:
In the end of the function spawn( _properties )
of tactical_entity_manager
, you only iterate over the instances of the player faction to call the player.nut
onCombatStart
function. This has the consequence that the onCombatStarted()
function of skills and items is never called for AI characters on the battlefield.
Solution:
Add a base function to actor.nut
called onCombatStart
which does the following to mirror the basic functionality from the respective player.nut function:
function onCombatStart()
{
this.m.Skills.onCombatStarted();
this.m.Items.onCombatStarted();
this.m.Skills.update();
}
Then, in the spawn
function of tactical_entity_manager
, instead of iterating only over the instances of the player faction, you iterate over all instances:
foreach (faction in this.getAllInstances())
{
foreach (actor in faction)
{
actor.onCombatStart();
}
}
Bonus:
The vanilla perk_inspiring_presence
contains the following line in its onCombatStarted()
function, which makes me believe that at some point even the Overhype dev ran into the issue of why this perk isn’t running for the AI, showing that this is a real problem:
this.logInfo("inspiring presence: on combat started!");