This part is the problem:
---------------------------------------------------------------------------------------
//Here, you grab the location of the PC that is about to be attacked
lTarget = GetLocation(oTarget);
//Now, you move to the location of the PC.
//Note that the AI tends to not cast when it will provoke an AOO.
//Casters need to stay back. Don't tell them to charge.
ActionMoveToLocation(lTarget,TRUE);
//ActionAttack is used to force the NPC to melee attack.
//Since they were just ordered to charge, it makes sense to stab.
//This, however, doesn't work well for mages.
AssignCommand (oNPC, ActionAttack(oTarget));
//This flag is used in the standard AI scripts
//which may not be getting called if the creatures are simply being told to charge and stab.
SetCombatCondition(X0_COMBAT_FLAG_RANGED);
------------------------------------------------------------------------------------
My conclusion is that you need to remove the lines telling the NPC to charge and attack on spawn.
As it is, any time the NPC spawns in the same area as a PC, they will charge and stab.
If you want to trigger your combat AI immediately, you need to do a check to search for enemies nearby and then execute your AI scripts.
You may be able to get away executing your HB script one time at the end of your OnSpawn script.
IE:
---------------------------------------------------------------------------------------
#include "x0_i0_anims"
#include "nw_i0_plot"
#include "NW_I0_GENERIC"
void main()
{
SetAILevel(OBJECT_SELF, AI_LEVEL_HIGH);
SetCombatCondition(X0_COMBAT_FLAG_RANGED);
SetLocalInt(GetArea(OBJECT_SELF), "X2_L_WILD_MAGIC", TRUE);
ExecuteScript("MyHBScript", OBJECT_SELF);
}
------------------------------------------------------------------------------------
Just replace MyHbScript with whatever you're using on HB. That generally checks for enemies nearby and reacts.
Modifié par wyldhunt1, 12 novembre 2011 - 04:11 .