1 /*
2 ===========================================================================
3 Copyright (C) 1999 - 2005, Id Software, Inc.
4 Copyright (C) 2000 - 2013, Raven Software, Inc.
5 Copyright (C) 2001 - 2013, Activision, Inc.
6 Copyright (C) 2013 - 2015, OpenJK contributors
7 
8 This file is part of the OpenJK source code.
9 
10 OpenJK is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License version 2 as
12 published by the Free Software Foundation.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 ===========================================================================
22 */
23 
24 /*****************************************************************************
25  * name:		be_ai_chat.h
26  *
27  * desc:		char AI
28  *
29  * $Archive: /source/code/botlib/be_ai_chat.h $
30  * $Author: osman $
31  * $Revision: 1.4 $
32  * $Modtime: 10/05/99 3:32p $
33  * $Date: 2003/03/15 23:43:59 $
34  *
35  *****************************************************************************/
36 
37 #pragma once
38 
39 #define MAX_MESSAGE_SIZE		256
40 #define MAX_CHATTYPE_NAME		32
41 #define MAX_MATCHVARIABLES		8
42 
43 #define CHAT_GENDERLESS			0
44 #define CHAT_GENDERFEMALE		1
45 #define CHAT_GENDERMALE			2
46 
47 #define CHAT_ALL					0
48 #define CHAT_TEAM					1
49 #define CHAT_TELL					2
50 
51 //a console message
52 typedef struct bot_consolemessage_s
53 {
54 	int handle;
55 	float time;									//message time
56 	int type;									//message type
57 	char message[MAX_MESSAGE_SIZE];				//message
58 	struct bot_consolemessage_s *prev, *next;	//prev and next in list
59 } bot_consolemessage_t;
60 
61 //match variable
62 typedef struct bot_matchvariable_s
63 {
64 	char offset;
65 	int length;
66 } bot_matchvariable_t;
67 //returned to AI when a match is found
68 typedef struct bot_match_s
69 {
70 	char string[MAX_MESSAGE_SIZE];
71 	int type;
72 	int subtype;
73 	bot_matchvariable_t variables[MAX_MATCHVARIABLES];
74 } bot_match_t;
75 
76 //setup the chat AI
77 int BotSetupChatAI(void);
78 //shutdown the chat AI
79 void BotShutdownChatAI(void);
80 //returns the handle to a newly allocated chat state
81 int BotAllocChatState(void);
82 //frees the chatstate
83 void BotFreeChatState(int handle);
84 //adds a console message to the chat state
85 void BotQueueConsoleMessage(int chatstate, int type, char *message);
86 //removes the console message from the chat state
87 void BotRemoveConsoleMessage(int chatstate, int handle);
88 //returns the next console message from the state
89 int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm);
90 //returns the number of console messages currently stored in the state
91 int BotNumConsoleMessages(int chatstate);
92 //selects a chat message of the given type
93 void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);
94 //returns the number of initial chat messages of the given type
95 int BotNumInitialChats(int chatstate, char *type);
96 //find and select a reply for the given message
97 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);
98 //returns the length of the currently selected chat message
99 int BotChatLength(int chatstate);
100 //enters the selected chat message
101 void BotEnterChat(int chatstate, int clientto, int sendto);
102 //get the chat message ready to be output
103 void BotGetChatMessage(int chatstate, char *buf, int size);
104 //checks if the first string contains the second one, returns index into first string or -1 if not found
105 int StringContains(char *str1, char *str2, int casesensitive);
106 //finds a match for the given string using the match templates
107 int BotFindMatch(char *str, bot_match_t *match, unsigned long int context);
108 //returns a variable from a match
109 void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size);
110 //unify all the white spaces in the string
111 void UnifyWhiteSpaces(char *string);
112 //replace all the context related synonyms in the string
113 void BotReplaceSynonyms(char *string, unsigned long int context);
114 //loads a chat file for the chat state
115 int BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
116 //store the gender of the bot in the chat state
117 void BotSetChatGender(int chatstate, int gender);
118 //store the bot name in the chat state
119 void BotSetChatName(int chatstate, char *name, int client);
120