i’d say even that’s too complicated
consider this. Remove all of the ai-scripts from all those custom NPC blueprints and assign this to their heartbeats:
// 'combat_hb'
/*
Heartbeat script that executes DCR against the nearest threat.
*/
const string VAR_TARGET = "Target";
void main()
{
object oSelf = OBJECT_SELF;
int iAction = GetCurrentAction(oSelf);
if ( iAction != ACTION_ATTACKOBJECT
&& iAction != ACTION_CASTSPELL
&& iAction != ACTION_TAUNT)
{
ClearAllActions();
object oThreat = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY,
oSelf, 1,
CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN,
CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE);
if (GetIsObjectValid(oThreat))
{
SetLocalObject(oSelf, VAR_TARGET, oThreat);
ExecuteScript("dcr", oSelf);
DeleteLocalObject(oSelf, VAR_TARGET);
}
}
}
and this to their OnDamaged:
// 'combat_da'
/*
Damaged script that executes DCR against the damager.
*/
const string VAR_TARGET = "Target";
void main()
{
object oSelf = OBJECT_SELF;
int iAction = GetCurrentAction(oSelf);
if ( iAction != ACTION_ATTACKOBJECT
&& iAction != ACTION_CASTSPELL
&& iAction != ACTION_TAUNT)
{
ClearAllActions();
object oThreat = GetLastDamager(oSelf);
if (GetIsObjectValid(oThreat) && GetIsEnemy(oThreat, oSelf))
{
SetLocalObject(oSelf, VAR_TARGET, oThreat);
ExecuteScript("dcr", oSelf);
DeleteLocalObject(oSelf, VAR_TARGET);
}
}
}
and this is the support-script for those
// 'dcr'
/*
Executable script to avoid bloating the other AI-scripts with
calls to DetermineCombatRound().
Requires that a local object "Target" be set on OBJECT_SELF.
*/
#include "nw_i0_generic"
const string VAR_TARGET = "Target";
void main()
{
DetermineCombatRound(GetLocalObject(OBJECT_SELF, VAR_TARGET));
}
With that set up, all you should need to do is run your script that changes faction … I’m betting you’d get a pretty decent mass combat just from that. But there’s lots of room for tweaks, to prevent ganging up or to attack lastattacker, etc. The nice thing about DetermineCombatRound() is that it handles casters.
( leave the party with their regular ai-scripts ofc )
tested w/ 40 melee + 1 caster no lag at all