HoS_PRC8/_mod/_module/nss/lib_hos1_aisupp.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

56 lines
2.0 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// lib_hos1_aisupp - AI Support Library
// By Deva B. Winblood. December 5th, 2008
////////////////////////////////////////////////////////////////////////////////
#include "lib_hos2_shpath"
//////////////////////////////////////////
// PROTOTYPES
//////////////////////////////////////////
// FILE: lib_hos1_aisupp FUNCTION: AIMoveToLocation()
// This is a possessive function to move oNPC to lLoc and when it arrives set it
// to the proper state. This is used so NPCs can be spawned at the leader
// location and then they may move to their designated post instead of popping
// out of thin air at their guard location which can cause problems.
void AIMoveToLocation(object oNPC,location lLoc,int nMState,int nSState,object oDest=OBJECT_INVALID);
//////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////
void AIMoveToLocation(object oNPC,location lLoc,int nMState,int nSState,object oDest=OBJECT_INVALID)
{ // PURPOSE: Move to location and set states
int nN;
if (!GetIsObjectValid(oNPC)) return;
if (!IsInConversation(oNPC)&&!GetIsInCombat(oNPC)&&!GetIsDMPossessed(oNPC))
{ // continue
if (GetDistanceBetweenLocations(GetLocation(oNPC),lLoc)>7.0)
{ // move
SetAILevel(oNPC,AI_LEVEL_NORMAL);
AssignCommand(oNPC,ClearAllActions());
nN=MoveToLocation(oNPC,lLoc,TRUE);
DelayCommand(6.0,AIMoveToLocation(oNPC,lLoc,nMState,nSState,oDest));
} // move
else
{ // arrived
SetAILevel(oNPC,AI_LEVEL_DEFAULT);
SetLocalInt(oNPC,"nMState",nMState);
SetLocalInt(oNPC,"nSState",nSState);
SetLocalObject(oNPC,"oDestWP",oDest);
} // arrived
} // continue
else
{ // check again
DelayCommand(10.0,AIMoveToLocation(oNPC,lLoc,nMState,nSState,oDest));
} // check again
} // AIMoveToLocation()
//void main(){}