For henchman you can stop their progress several ways.
One way is to just use the ClearActions(TRUE); requires the include script *_*_Henai as ClearActions is a wrapper function of ClearAllActions, but the latter can be buggy sometimes.
By using the TRUE, it will break the henchman combat, where as FALSE ignores the state of combat.
The most effective is to include a section in the OnHeartBeat:
//This is what I use.
// If not runnning normal or better AI then exit for performance reasons
if(GetAILevel() == AI_LEVEL_VERY_LOW)
{
return;
}
// If doing any of these actions, do nothing.
int iAct;
iAct = GetCurrentAction();
if(iAct==ACTION_CASTSPELL || iAct==ACTION_HEAL || iAct==ACTION_ITEMCASTSPELL || iAct==ACTION_WAIT
|| iAct==ACTION_REST || (GetAssociateState(NW_ASC_IS_BUSY, OBJECT_SELF)==TRUE) || (GetIsDead(OBJECT_SELF)))
{
return;
}
The main key to have and use is the: (GetAssociateState(NW_ASC_IS_BUSY...
In your script you can SET the associate state to busy after the ClearActions function.
The henchman will stay busy and
any other scripts that would normally fire will fail because the busy command stops them, and things like perceived or even damage wont change the state because they are marked as busy.
Just make sure after the script you want to fire has happened you set them not being busy (set to false) or they will not even talk to the player or anything else. Easy to do with a DelayCommand, just have a few seconds set for the script to run and poof they become non-busy and act as normal. Honestly, it probably isnt needed in the onheartbeat event to return, just having it work on the script you want is probably enough, but i use it for completeness sake.
As to why I have the GetIsDead used there, I use Tony K's AI in several mods, inclluding the one I'm building. NPC's will still "taunt" even when dead with out it, unless their corpses fade, which mine dont..
Modifié par Xovian, 28 février 2011 - 06:49 .