/////////////////////////////////////////////////////////////// // NPC ACTIVITIES 5.0 - Library Tool Header file //============================================================ // By Deva Bryson Winblood. 02/2003 Also used with // NPC ACTIVITIES 6.0 and did not require any modifications // MODIFIED FOR NPC ACTIVITIES 6.1 2/4/2006 /////////////////////////////////////////////////////////////// /* These functions are to be used to help you make your own library scripts as per the documentation section Creating your own commands. */ /////////////////////////////////////////////////////////////////// // CONSTANTS /////////////////////////////////////////////////////////////////// const int NPC_STATE_INITIALIZE = 0; // states in NPCACT_STATES const int NPC_STATE_CHOOSE_DESTINATION = 1; const int NPC_STATE_MOVE_TO_DESTINATION = 2; const int NPC_STATE_WAIT_TO_GET_THERE = 3; const int NPC_STATE_PROCESS_WAYPOINT = 4; const int NPC_STATE_INTERPRET_COMMAND = 5; const int NPC_STATE_WAIT_FOR_COMMAND = 6; const int NPC_STATE_PAUSE_BEFORE_NEXT = 7; const int NPC_BLOCKING_DEFAULT = 0; // Blocking Behaviors const int NPC_BLOCKING_RUN_AWAY_SHORT = 1; const int NPC_BLOCKING_RUN_AWAY_LONG = 2; const int NPC_BLOCKING_MOVE_RANDOM = 3; const int NPC_MODE_DEFAULT = 0; // Destination choice modes const int NPC_MODE_CLOSE_FIRST = 1; const int NPC_MODE_CLOSE_ONLY = 2; /////////////////////////////////////////////////////////////////// // PROTOTYPES /////////////////////////////////////////////////////////////////// // FILE: npcactlibtoolh FUNCTION: DLL_ParseSlash // This function will parse until it encounters the specified // delimiter. This function is intended to support people who are // designing custom libraries for NPC ACTIVITIES. string DLL_ParseSlash(string sIn,string sDelim="/"); // FILE: npcactlibtoolh FUNCTION: DLL_RemoveParsed // This function will remove sRemove from sOrig and will also consult // the delimiter that is specified to make sure any leading delimiter is // removed. This is a support function for people to create their own // custom libraries for NPC ACTIVITIES. It is typically used after // the DLL_ParseSlash function. string DLL_RemoveParsed(string sOrig,string sRemove,string sDelim="/"); // FILE: npcactlibtoolh FUNCTION: DLL_TokenizeParameters // This function will count how many parameters are passed and will store that // number in nArgc on the NPC. It will put each of the parameters in a string // variable on the NPC stored as sArgv# where # begins with 1. This function // is provided to help people create custom libraries for NPC ACTIVITIES. // Typically this function is called at the begining of the library to determine // what was asked of the library. Later DLL_FreeParameters can be called to // free any memory used to store these parameters. // So a typical library is setup similar to this // void main() // { // string sParmIn=GetLocalString(OBJECT_SELF,"sLIBParm"); // Declare variables // DLL_TokenizeParameters(sParmIn); // Actions to be taken by the library // DLL_FreeParameters(); // } // void DLL_TokenizeParameters(string sIn); // FILE: npcactlibtoolh FUNCTION: DLL_FreeParameters // This function frees variables and memory allocated for use with the // DLL_TokenizeParameters command. See that command for complete details. // This function is provided for people to create their own custom libraries // for use with NPC ACTIVITIES. void DLL_FreeParameters(); // FILE: npcactlibtoolh FUNCTION: DLL_SetDestination // This function will enable a person designing a custom library to set what // the next destination should be. This is intended for NPC ACTIVITIES // custom library design. void DLL_SetDestination(object oNPC,string sDestination); // FILE: npcactlibtoolh FUNCTION: DLL_CompleteActions // This function will tell the NPC that they have completed ALL actions // at this location. It is a way to get the NPC to stop what they are // doing and move onto the next waypoint. This function is provided for // people who are designing their own custom libraries for NPC ACTIVITIES. void DLL_CompleteActions(object oNPC); // FILE: npcactlibtoolh FUNCTION: DLL_AddCommand // This function will enable someone designing their own custom library // to insert additional commands in NPC ACTIVITIES format at the end of the // command queue for this waypoint. void DLL_AddCommand(object oNPC,string sCommand); // FILE: npcactlibtoolh FUNCTION: DLL_SetProcessingFlag // This function is to be used with custom libraries and scripts to let master // NPC ACTIVITIES know that something is successfully running. If your script // will need to run for awhile then you will want to use this function to keep // npc activities from thinking something is not working and taking over. void DLL_SetProcessingFlag(object oNPC); // FILE: npcactlibtoolh FUNCTION: DLL_SetNPCState // This function will set the state of the NPC in terms of how processing is // handled. This is used to create custom libraries and scripts. void DLL_SetNPCState(object oNPC,int nState); // FILE: npcactlibtoolh FUNCTION: DLL_NPCIsBusy // This function will return TRUE if the NPC is in conversation, in combat, // nGNBDisabled is set to TRUE, or the NPC is DM Possessed int DLL_NPCIsBusy(object oNPC); // FILE: npcactlibtoolh FUNCTION: DLL_GetRecentDestination // This function returns the most recent destination object for NPC ACTIVITIES // pathing that was reached by the NPC. object DLL_GetRecentDestination(object oNPC); // FILE: npcactlibtoolh FUNCTION: DLL_SetRecentDestination // This sets the recent destination reached by the NPC. It is provided for // custom library and script design. It should not be used without good reason. void DLL_SetRecentDestination(object oNPC,object oDest); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedLockedDoorMessage // This function will set the message that this NPC will speak when they // encounter a locked door. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when encountering a locked door. // This set's the variable sGNBLockedBlock void DLL_SetBlockedLockedDoorMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedDoorMessage // This function will set the random message that the NPC will say when they // encounter a door. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when encountering a door. // This set's the variable sGNBDoorBlock void DLL_SetBlockedDoorMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedAnimalMessage // This function will set the random message that the NPC will say when they // are blocked by an animal. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by an animal. // This set's the variable sGNBAnimalBlock void DLL_SetBlockedAnimalMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedVerminMessage // This function will set the random message that the NPC will say when they // are blocked by a vermin. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a vermin. // This set's the variable sGNBVerminBlock void DLL_SetBlockedVerminMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedPrejudicedMessage // This function will set the random message that the NPC will say when they // are blocked by a race other than their own or an animal or vermin. // The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a inferior race. // This set's the variable sGNBPrejudicedBlock void DLL_SetBlockedPrejudicedMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedMaleMessage // This function will set the random message that the NPC will say when they // are blocked by a male target. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a male. // This set's the variable sGNBMaleBlock void DLL_SetBlockedMaleMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedFemaleMessage // This function will set the random message that the NPC will say when they // are blocked by a female target. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a female. // This set's the variable sGNBFemaleBlock void DLL_SetBlockedFemaleMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedPCMessage // This function will set the random message that the NPC will say when they // are blocked by a PC target. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a pc. // This set's the variable sGNBPCBlock void DLL_SetBlockedPCMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedNPCMessage // This function will set the random message that the NPC will say when they // are blocked by a NPC target. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a NPC. // This set's the variable sGNBNPCBlock void DLL_SetBlockedNPCMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedCreatureMessage // This function will set the random message that the NPC will say when they // are blocked by a PC or NPC. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a PC or NPC. // This set's the variable sGNBCreatureBlock void DLL_SetBlockedCreatureMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedContainerMessage // This function will set the random message that the NPC will say when they // are blocked by a container. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a container. // This set's the variable sGNBContainerBlock void DLL_SetBlockedContainerMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockedPlaceableMessage // This function will set the random message that the NPC will say when they // are blocked by a placeable. The sMessage variable must be setup in the format // #/statement1/statement2/.. # is the number of statements. This will // support random statements when being blocked by a placeable. // This set's the variable sGNBPlaceableBlock void DLL_SetBlockedPlaceableMessage(object oNPC,string sMessage,int bScript=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetBlockingNehavior // This function will set how this NPC behaves to objects blocking it. // Valid settings are NPC_BLOCKING_DEFAULT, NPC_BLOCKING_RUN_AWAY_SHORT, // NPC_BLOCKING_RUN_AWAY_LONG, or NPC_BLOCKING_MOVE_RANDOM. // These values are stored on the nGNBBlockingBehavior variable. void DLL_SetBlockingBehavior(object oNPC,int nMode=NPC_BLOCKING_DEFAULT); // FILE: npcactlibtoolh FUNCTION: DLL_SetPerceptionNoEnemy // This function will set whether the perception event should ignore enemies. // This sets the variable bGNBNoPerceiveEnemy void DLL_SetPerceptionNoEnemy(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetPerceptionNoNeutral // This function will set whether the perception event should ignore neutrals. // This sets the variable bGNBNoPerceiveNeutral void DLL_SetPerceptionNoNeutral(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetPerceptionNoFriend // This function will set whether the perception event should ignore friends. // This sets the variable bGNBNoPerceiveFriend void DLL_SetPerceptionNoFriend(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetPerceptionNoNPC // This function will set whether the perception event should ignore NPCs. // This sets the variable bGNBNoPerceiveNPC void DLL_SetPerceptionNoNPC(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetPerceptionNoPC // This function will set whether the perception event should ignore PCs. // This sets the variable bGNBNoPerceivePC void DLL_SetPerceptionNoPC(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetConversationOnlyListenTo // This function will set a single target that this NPC should listen to. If // this value is not set the NPC will listen to all targets. This function sets // the variable oGNBListenOnlyTo void DLL_SetConversationOnlyListenTo(object oNPC,object oTarget); // FILE: npcactlibtoolh FUNCTION: DLL_SetConversationNoListenNPC // This will make this NPC not listen to other NPCs. This sets the variable // bGNBNoListenNPC void DLL_SetConversationNoListenNPC(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetConversationNoListenEnemy // This will make this NPC not listen to enemies. This sets the variable // bGNBNoListenEnemy void DLL_SetConversationNoListenEnemy(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetConversationNoListenNeutral // This will make this NPC not listen to neutrals. This sets the variable // bGNBNoListenNeutral void DLL_SetConversationNoListenNeutral(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetConversationNoListenFriend // This will make this NPC not listen to friends. This sets the variable // bGNBNoListenFriend void DLL_SetConversationNoListenFriend(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetConversationNoListenPC // This will make this NPC not listen to PCs. This sets the variable // bGNBNoListenPC void DLL_SetConversationNoListenPC(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetNPCDisabled // This function will set the variable nGNBDisabled void DLL_SetNPCDisabled(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetProfessionsEnabled // This sets the variable nGNBProfessions void DLL_SetProfessionsEnabled(object oNPC,int bFlag=TRUE); // FILE: npcactlibtoolh FUNCTION: DLL_SetProfessionsFailureLevel // This sets the variable nGNBProfFail which is documented in the NPC ACTIVITIES // documentation on designing your own profession. void DLL_SetProfessionsFailureLevel(object oNPC,int nFailNumber=15); // FILE: npcactlibtoolh FUNCTION: DLL_SetProfessionsProcessing // This function will set the variable nGNBProfProc to 1 which must be used // periodically within a profession to make NPC ACTIVITIES realize the function // has not failed. See NPC ACTIVITIES documentation for further information. void DLL_SetProfessionsProcessing(object oNPC); // FILE: npcactlibtoolh FUNCTION: DLL_GetArgument // This function will retrieve the sArgv# variable stored on the NPC. string DLL_GetArgument(object oNPC,int nArgumentNumber); // FILE: npcactlibtoolh FUNCTION: DLL_GetArgumentCount // This function will retrieve the number of arguments which are available to // be retrieved using DLL_GetArgument. This is from the nArgc variable stored // on the NPC. int DLL_GetArgumentCount(object oNPC); // FILE: npcactlibtoolh FUNCTION: DLL_SetCustomConversationOverride // This function will set the dialog this NPC should use. The dialog on the // NPC must be set to npcact_custom for this to work. This function sets the // sNPCConvOverride variable void DLL_SetCustomConversationOverride(object oNPC,string sDialog); // FILE: npcactlibtoolh FUNCTION: DLL_SetCustomConvesationNPCNode // This function will set the statements of the NPC in a dynamic conversation // It should be noted that the root node is nNode=0 and nSubNode=0 // nNode represents depth. nSubNode = portion of that node. This will set // the variable sNPCConvNode#_# where # = nNode and _# = nSubNode void DLL_SetCustomConversationNPCNode(object oNPC,int nNode,int nSubNode,string sText); // FILE: npcactlibtoolh FUNCTION: DLL_SetCustomConversationPCResponseNode // This function will set responses allowed for PCs. See the function // DLL_SetCustomConversationNPCNode for more information. This sets the // variable sNPCConvResp#_#_# void DLL_SetCustomConversationPCResponseNode(object oNPC,int nNode,int nSubNode,int nOption,string sText); // FILE: npcactlibtoolh FUNCTION: DLL_CleanCustomConversation // This function will delete variables used to define custom/dynamic // conversations. void DLL_CleanCustomConversation(object oNPC); // FILE: npcactlibtoolh FUNCTION: DLL_SetNPCStateSpeed // This function will set the nGNBStateSpeed variable void DLL_SetNPCStateSpeed(object oNPC,int nSpeed=6); // FILE: npcactlibtoolh FUNCTION: DLL_SetRandomDelay // This function will set the nGNBRandomizeDelay variable void DLL_SetRandomDelay(object oNPC,int nTenthsOfSecond=0); // FILE: npcactlibtoolh FUNCTION: DLL_SetQuickMoveEnabled // This will set the bGNBQuickMove variable void DLL_SetQuickMoveEnabled(object oNPC,int bFlag=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetAccuratePathingEnabled // This will set the bGNBAccuratePathing variable void DLL_SetAccuratePathingEnabled(object oNPC,int bFlag=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetStayInAreaEnabled // This will set the bGNBStayInArea variable void DLL_SetStayInAreaEnabled(object oNPC,int bFlag=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetCanOpenDoors // This will set the variable bGNBOpenDoors. If this is TRUE this NPC // will be able to open doors even if they are not the typical type of NPC // to be able to do this. void DLL_SetCanOpenDoors(object oNPC,int bFlag=FALSE); // FILE: npcactlibtoolh FUNCTION: DLL_SetVirtualTag // This will set the sGNBVirtualTag variable void DLL_SetVirtualTag(object oNPC,string sTag); // FILE: npcactlibtoolh FUNCTION: DLL_SetCloseMode // This will set the movement mode of the NPC. The valid settings // are NPC_MODE_DEFAULT, NPC_MODE_CLOSE_FIRST, and NPC_MODE_CLOSE_ONLY void DLL_SetCloseMode(object oNPC,int nMode=NPC_MODE_DEFAULT); // FILE: npcactlibtoolh FUNCTION: fake function - tutorial // This is a tutorial and is not an actual useable function. //============================================================================== // HOW TO MAKE CUSTOM DYNAMIC CONVERSATIONS //============================================================================== // STEP #1: the dialog for the NPC must be set to npcact_custom // STEP #2: - call DLL_CleanCustomConversation first to clean any existing // dynamic conversation // STEP #3: - Call DLL_SetCustomConversationNPCNode(oNPC,0,0,text) where text // is the very first conversation option. See later on what text should be set // to. // STEP #4: - Call DLL_SetCustomConversationPCResponseNode(oNPC,0,0,1,text) for // valid PC responses. You should increment 1 as needed. // STEP #5: - repeat steps #3 through #4 until the entire dialog tree is // constructed... simply increment the nodes, subnodes, and options as needed // to properly construct the conversation. // ============================================================================= // TEXT - This section explains the text portion of the functions // ============================================================================= // The text portion is broken into a string that has the following parts: // language # // text appears when // actions // what should be said // Each of these sections is delimited by a period. In standard notation it // is represented in documenation similar to this. // ... // Each of these sections will be explained. //============================================================================== // language # //============================================================================== // Language # would be the spoken language that it is using if languages are // enabled. However, this value if set to 0 will indicate no specific language //============================================================================== // Text Appears When //============================================================================== // If there is no special condition then set this to NA. Otherwise, you can // use the following criteria delimited by slashes / // @