HoS_PRC8/_mod/_module/nss/npcactdllnm.nss
Jaysyn904 e2f4ba74d5 Merged redundant hak files
Merged redundant hak files.  Moved hak scripts into module.  Updated gitignore.  Full Compile.  Added release folder & archive.
2024-12-12 15:02:17 -05:00

198 lines
7.1 KiB
Plaintext

/////////////////////////////////////////////////////////////////////////
// NPC ACTIVITIES 5.0 - MOVEMENT LIBRARY
// Version: 1.0
// Library name: NM
// Also used with NPC ACTIVITIES 6.0 but, did not require modification
//=======================================================================
// Author: Deva Bryson Winblood
// Date : 02/19/2003
//=======================================================================
// This library handles movement commands that are time sensitive and will
// also be used to store any new movement commands that are added after the
// core command set has been frozen.
//////////////////////////////////////////////////////////////////////////
#include "npcactlibtoolh"
// #Parm1 FUNCTION PARAMETERS
//------------------------------------------------------------------------
// 1 Walk circuit with no pause Start Point, End Point
// 2 Run circuit with no pause Start Point, End Point
// 3 Walk Circuit # times Start, End, Number Circuits (0=infinite)
// 4 Run circuit # times Start, End, Number Circuits (0=infinite)
// 5 Bizarre Random Walk Duration in seconds
// 6 Bizarre Random Run Duration in seconds
///////////////////////////////// PROTOTYPES //////////////////////////////
void MoveAroundCircuit(int nStartP,int nEndP,int nMode=FALSE);
void LIB3and4(int nStart,int nEnd,int nTimes,int nRun=FALSE);
void LIB5and6(int nRun=FALSE);
//=============================================[ M A I N ]=================
void main()
{
string sParmIn=GetLocalString(OBJECT_SELF,"sLIBParm");
DeleteLocalString(OBJECT_SELF,"sLIBParm");
fnTokenizeParameters(sParmIn);
int nArgC=GetLocalInt(OBJECT_SELF,"nArgc");
string sParm;
int nParm1;
int nParm2;
int nParm3;
int nParm4;
if (nArgC>0)
{ // parameters were passed
SetLocalInt(OBJECT_SELF,"nGNBDisabled",TRUE); // no interference
sParm=GetLocalString(OBJECT_SELF,"sArgv1");
nParm1=StringToInt(sParm);
switch (nParm1)
{ // function call switch
case 1: { // Walk circuit old style
sParm=GetLocalString(OBJECT_SELF,"sArgv2");
nParm2=StringToInt(sParm);
sParm=GetLocalString(OBJECT_SELF,"sArgv3");
nParm3=StringToInt(sParm);
MoveAroundCircuit(nParm2,nParm3);
ActionDoCommand(SetLocalInt(OBJECT_SELF,"nGNBDisabled",FALSE));
break;
} // walk Circuit old style
case 2: { // Run circuit old style
sParm=GetLocalString(OBJECT_SELF,"sArgv2");
nParm2=StringToInt(sParm);
sParm=GetLocalString(OBJECT_SELF,"sArgv3");
nParm3=StringToInt(sParm);
MoveAroundCircuit(nParm2,nParm3,TRUE);
ActionDoCommand(SetLocalInt(OBJECT_SELF,"nGNBDisabled",FALSE));
break;
} // Run circuit old style
case 3: { // Walk circuit # times
sParm=GetLocalString(OBJECT_SELF,"sArgv2");
nParm2=StringToInt(sParm);
sParm=GetLocalString(OBJECT_SELF,"sArgv3");
nParm3=StringToInt(sParm);
sParm=GetLocalString(OBJECT_SELF,"sArgv4");
nParm4=StringToInt(sParm);
LIB3and4(nParm2,nParm3,nParm4);
break;
} // Walk circuit # times
case 4: { // Run circuit # times
sParm=GetLocalString(OBJECT_SELF,"sArgv2");
nParm2=StringToInt(sParm);
sParm=GetLocalString(OBJECT_SELF,"sArgv3");
nParm3=StringToInt(sParm);
sParm=GetLocalString(OBJECT_SELF,"sArgv4");
nParm4=StringToInt(sParm);
LIB3and4(nParm2,nParm3,nParm4,TRUE);
break;
} // Run circuit # times
case 5: { // Bizarre Random Walk
sParm=GetLocalString(OBJECT_SELF,"sArgv2");
nParm2=StringToInt(sParm);
DelayCommand(IntToFloat(nParm2)*1.0,SetLocalInt(OBJECT_SELF,"nGNBDisabled",FALSE)); // return control
LIB5and6();
break;
} // Bizarre Random Walk
case 6: { // Bizarre Random Run
sParm=GetLocalString(OBJECT_SELF,"sArgv2");
nParm2=StringToInt(sParm);
DelayCommand(IntToFloat(nParm2)*1.0,SetLocalInt(OBJECT_SELF,"nGNBDisabled",FALSE)); // return control
LIB5and6(TRUE);
break;
} // Bizarre Random Run
default: { SetLocalInt(OBJECT_SELF,"nGNBDisabled",FALSE); break; }
} // function call switch
} // parameters were passed
}
//=============================================[ M A I N ]=================
///////////////////////////////////////////////////////////////////
// F U N C T I O N S
///////////////////////////////////////////////////////////////////
void MoveAroundCircuit(int nStartP,int nEndP,int nMode=FALSE)
{ // MoveAroundCircuit (from the old npcactdllmove library)
string sName="WP_"+GetTag(OBJECT_SELF)+"_";
object oDest;
string sTag;
int nLoop=nStartP;
//SendMessageToPC(GetFirstPC(),"DLL("+IntToString(nStartP)+","+IntToString(nEndP)+","+IntToString(nMode)+")");
while(nLoop<nEndP+1)
{ // run circuit
if(nLoop<10) sTag=sName+"0"+IntToString(nLoop);
else sTag=sName+IntToString(nLoop);
oDest=GetObjectByTag(sTag);
if (oDest!=OBJECT_INVALID)
{ // !OI
ActionForceMoveToObject(oDest,nMode,1.0,30.0);
} // !OI
nLoop++;
} // run circuit
} // MoveAroundCircuit()
//------------------------------------------------------------------------
void LIB3and4(int nStart,int nEnd,int nTimes,int nRun=FALSE)
{ // Move around circuit nTimes 0 = infinite
string sName="WP_"+GetTag(OBJECT_SELF)+"_";
object oDest;
string sTag;
int nLoop=nStart;
while (nLoop<nEnd+1)
{ // do circuit
if (nLoop<10) sTag=sName+"0"+IntToString(nLoop);
else sTag=sName+IntToString(nLoop);
oDest=GetObjectByTag(sTag);
if (oDest!=OBJECT_INVALID)
{ // !OI
ActionForceMoveToObject(oDest,nRun,1.0,30.0);
} // !OI
nLoop++;
} // do circuit
if (nTimes==1)
{ // done- return control to NPC ACTIVITIES
ActionDoCommand(SetLocalInt(OBJECT_SELF,"nGNBDisabled",FALSE));
} // done- return control to NPC ACTIVITIES
else if (nTimes>1)
{
ActionDoCommand(LIB3and4(nStart,nEnd,nTimes-1,nRun));
}
else // infinite
{
ActionDoCommand(LIB3and4(nStart,nEnd,nTimes,nRun));
}
} // LIB3and4()
//-------------------------------------------------------------------------
void LIB5and6(int nRun=FALSE)
{ // Bizarre Random Walk/Run
object oDest;
float fRange;
int nRnd;
nRnd=d4();
switch(nRnd)
{ // behavior
case 1: { // do weird facing actions
nRnd=Random(360);
ActionDoCommand(SetFacing(IntToFloat(nRnd)));
ActionWait(0.5);
nRnd=Random(360);
ActionDoCommand(SetFacing(IntToFloat(nRnd)));
ActionWait(0.5);
nRnd=Random(360);
ActionDoCommand(SetFacing(IntToFloat(nRnd)));
ActionWait(0.5);
break;
} // do weird facing actions
default: { // move towards location
nRnd=d10();
oDest=GetNearestObject(OBJECT_TYPE_ALL,OBJECT_SELF,nRnd);
if (oDest!=OBJECT_INVALID)
{ // find object
fRange=GetDistanceBetween(OBJECT_SELF,oDest);
nRnd=Random(FloatToInt(fRange))+1;
fRange=IntToFloat(nRnd)+0.5;
ActionMoveToObject(oDest,nRun,fRange);
} // find object
break;
} // move towards location
} // behavior
ActionDoCommand(LIB5and6(nRun)); // recursion until NPC activities takes over
} // LIB5and6()