codemp/game/be_ai_chat.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2000 Id Software, Inc.
00002 //
00003 /*****************************************************************************
00004  * name:                be_ai_chat.h
00005  *
00006  * desc:                char AI
00007  *
00008  * $Archive: /source/code/botlib/be_ai_chat.h $
00009  * $Author: osman $ 
00010  * $Revision: 1.4 $
00011  * $Modtime: 10/05/99 3:32p $
00012  * $Date: 2003/03/15 23:43:59 $
00013  *
00014  *****************************************************************************/
00015 
00016 #define MAX_MESSAGE_SIZE                256
00017 #define MAX_CHATTYPE_NAME               32
00018 #define MAX_MATCHVARIABLES              8
00019 
00020 #define CHAT_GENDERLESS                 0
00021 #define CHAT_GENDERFEMALE               1
00022 #define CHAT_GENDERMALE                 2
00023 
00024 #define CHAT_ALL                                        0
00025 #define CHAT_TEAM                                       1
00026 #define CHAT_TELL                                       2
00027 
00028 //a console message
00029 typedef struct bot_consolemessage_s
00030 {
00031         int handle;
00032         float time;                                                                     //message time
00033         int type;                                                                       //message type
00034         char message[MAX_MESSAGE_SIZE];                         //message
00035         struct bot_consolemessage_s *prev, *next;       //prev and next in list
00036 } bot_consolemessage_t;
00037 
00038 //match variable
00039 typedef struct bot_matchvariable_s
00040 {
00041         char offset;
00042         int length;
00043 } bot_matchvariable_t;
00044 //returned to AI when a match is found
00045 typedef struct bot_match_s
00046 {
00047         char string[MAX_MESSAGE_SIZE];
00048         int type;
00049         int subtype;
00050         bot_matchvariable_t variables[MAX_MATCHVARIABLES];
00051 } bot_match_t;
00052 
00053 //setup the chat AI
00054 int BotSetupChatAI(void);
00055 //shutdown the chat AI
00056 void BotShutdownChatAI(void);
00057 //returns the handle to a newly allocated chat state
00058 int BotAllocChatState(void);
00059 //frees the chatstate
00060 void BotFreeChatState(int handle);
00061 //adds a console message to the chat state
00062 void BotQueueConsoleMessage(int chatstate, int type, char *message);
00063 //removes the console message from the chat state
00064 void BotRemoveConsoleMessage(int chatstate, int handle);
00065 //returns the next console message from the state
00066 int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm);
00067 //returns the number of console messages currently stored in the state
00068 int BotNumConsoleMessages(int chatstate);
00069 //selects a chat message of the given type
00070 void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);
00071 //returns the number of initial chat messages of the given type
00072 int BotNumInitialChats(int chatstate, char *type);
00073 //find and select a reply for the given message
00074 int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);
00075 //returns the length of the currently selected chat message
00076 int BotChatLength(int chatstate);
00077 //enters the selected chat message
00078 void BotEnterChat(int chatstate, int clientto, int sendto);
00079 //get the chat message ready to be output
00080 void BotGetChatMessage(int chatstate, char *buf, int size);
00081 //checks if the first string contains the second one, returns index into first string or -1 if not found
00082 int StringContains(char *str1, char *str2, int casesensitive);
00083 //finds a match for the given string using the match templates
00084 int BotFindMatch(char *str, bot_match_t *match, unsigned long int context);
00085 //returns a variable from a match
00086 void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size);
00087 //unify all the white spaces in the string
00088 void UnifyWhiteSpaces(char *string);
00089 //replace all the context related synonyms in the string
00090 void BotReplaceSynonyms(char *string, unsigned long int context);
00091 //loads a chat file for the chat state
00092 int BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
00093 //store the gender of the bot in the chat state
00094 void BotSetChatGender(int chatstate, int gender);
00095 //store the bot name in the chat state
00096 void BotSetChatName(int chatstate, char *name, int client);
00097