henesua wrote...
I have not tested it yet, but I am fairly confident that that approach would work. Its just that I haven't figured out the cleanest method to implement it. I already use the Custom Combat AI, and so this would require that I dynamically swap in the Pursuit AI in a particular instance, then switch the Custom Combat AI back to what it was previously when the Pursuit is complete.
Yes, I was rushed before. I originaly intended to cover this case.
Simplest solution is to run Both. You just need to make sure that your Chase AI is added after your normal Sp-AI. For this example I am going to assume that the SP-AI is add on Spawn or OnEnter and not at a random time after the creature enters the area. So your OnAreaEnter script could contain code like the following:
#include "x2_inc_switches"
const string AI_FOLLOW_SCRIPT_NAME = "sp_ai_Follow"; // or what ever.
const string SECONDARY_SP_AI_SCRIPT = "SECONDARY_SP_AI_SCRIPT";
// just because it is missing from x2_include-switches
string GetCreatureOverrideAIScript(object oCreature)
{
return GetLocalString(oCreature,CREATURE_VAR_CUSTOM_AISCRIPT);
}
// To allow a chain
void SetSecondaryOverrideAIScript(object oCreature , string sScriptName)
{
SetLocalString(oCreature,SECONDARY_SP_AI_SCRIPT,sScriptName);
}
// To allow a chain
string GetSecondaryOverrideAIScript(object oCreature)
{
return GetLocalString(oCreature,SECONDARY_SP_AI_SCRIPT);
}
// A delayed function so that the the Follow AI is not added before the original.
void AddFollowSpAI ( object oCreature)
{
string sSpAIScript = GetCreatureOverrideAIScript(oCreature);
if (sSpAIScript != "" && sSpAIScript != AI_FOLLOW_SCRIPT_NAME )
SetSecondaryOverrideAIScript( oCreature, sSpAIScript);
SetCreatureOverrideAIScript( oCreature, AI_FOLLOW_SCRIPT_NAME);
}
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)/*&& And other checks if they can following */)
DelayCommand ( 0.5,AddFollowSpAI (oPC));
}
This would change your follow script to look like.
#include "x2_inc_switches"
#include "NW_I0_GENERIC"
const string SECONDARY_SP_AI_SCRIPT = "SECONDARY_SP_AI_SCRIPT";
// To allow a chain
string GetSecondaryOverrideAIScript(object oCreature)
{
return GetLocalString(oCreature,SECONDARY_SP_AI_SCRIPT);
}
void main()
{
object oTarget = GetCreatureOverrideAIScriptTarget();
if ( GetArea(oTarget) != GetArea(OBJECT_SELF) )
{
location nTransloc = GetLocalLocation( oTarget,"Last_Trans_From");
if (GetAreaFromLocation(nTransloc) == GetArea(OBJECT_SELF))
{
ClearAllActions();
SetLocalObject( OBJECT_SELF, "CurrChaseTarget", oTarget);
ActionMoveToLocation(nTransloc);
float fWait = 0.5; // Guess here. It will need to be at least
//as long as your Transition delay.
ActionWait(fWait );
ActionDoCommand( DetermineCombatRound(oTarget));
SetCreatureOverrideAIScriptFinished();
return;
}
}
ExecuteScript( GetSecondaryOverrideAIScript(OBJECT_SELF),OBJECT_SELF);
}
I also need to create a script which determines when the Pursuit AI is needed.
It is handled in the AI script. If the Creature was a target, It was in the same area. since the target is now in a different area it needs to follow.
THEN on top of all of that, the behavior is different than the default game behavior with transitions. So I can modify this default game behavior with this custom combat AI, or I can add way points for my seamless area transitions. At present there are benefits and costs to each of these solutions, and I'm not sure which one I want to implement in the long term.
As long as your Transistion script will allow the creature to transistion I do not see a problem with the above AI.
The only thing not handled yet by the AI script is if the PC hops to an area then back. That would need to be handled in the OnPerception script.
if ( GetLastPerceived() == GetLocalObject( OBJECT_SELF, "CurrChaseTarget"))
{
ClearAllActions();
DetermineCombatRound(GetLastPerceived());
}
Just to stop them from transistioning to the area the PC just came back from.