Added enablechatai config option and fixed various

bugs in Chat AI (more to come lol xD)
This commit is contained in:
Mini 2007-01-14 00:53:17 +00:00
parent 3cdc94d4fe
commit 863e8e7944
4 changed files with 11 additions and 24 deletions

View File

@ -7,23 +7,6 @@
#include "Chat.h" #include "Chat.h"
/*
int chatCallBackQuestionTypes(void *arg, int nColumns, char **sValues, char **sNames)
{
if (nColumns != 2)
{
log("Got wrong number of columns for table `talk_types`, columns was: ", nColumns, ", expected 2 columns.");
return -1;
}
ChatTypes[nChatTypes].type = sValues[0];
ChatTypes[nChatTypes].remove = atoi(sValues[1]);
nChatTypes++;
return 0;
}*/
// TODO: Rewrite class (Rewritten from old php code - i didn't knew anything else but very simple select, insert, delete statements when // TODO: Rewrite class (Rewritten from old php code - i didn't knew anything else but very simple select, insert, delete statements when
// the code was originaly written. :P // the code was originaly written. :P
@ -52,12 +35,13 @@ Chat::Chat(std::string sentence)
// 1. Find the type of sentence // 1. Find the type of sentence
// 2. Answer the sentence the right way // 2. Answer the sentence the right way
sentence = stringToLower(sentence);
result = ""; result = "";
Database chatDB("db/chat"); Database chatDB("db/chat");
Query query(chatDB); Query query(chatDB);
query.get_result("select type, remove from talk_types"); query.get_result("select type, remove from talk_types order by type DESC");
std::string type, part, resultSentence; std::string type, part, resultSentence;
int remove; int remove;
@ -70,13 +54,9 @@ Chat::Chat(std::string sentence)
Query query2(chatDB); Query query2(chatDB);
query2.get_result("select part from talk_types_parts where type='" + type + "'"); query2.get_result("select part from talk_types_parts where type='" + type + "'");
printf("Type: %s\n", type.c_str());
while (query2.fetch_row()) while (query2.fetch_row())
{ {
part = query2.getstr(); part = stringToLower(query2.getstr());
printf("Type: %s, Sentence: %s, Part: %s\n", type.c_str(), sentence.c_str(), part.c_str());
if (sentence.find(part) != std::string::npos) if (sentence.find(part) != std::string::npos)
{ {

View File

@ -260,6 +260,7 @@ void PseuInstanceConf::ApplyFromVarSet(VarSet &v)
showopcodes=atoi(v.Get("SHOWOPCODES").c_str()); showopcodes=atoi(v.Get("SHOWOPCODES").c_str());
enablecli=(bool)atoi(v.Get("ENABLECLI").c_str()); enablecli=(bool)atoi(v.Get("ENABLECLI").c_str());
allowgamecmd=(bool)atoi(v.Get("ALLOWGAMECMD").c_str()); allowgamecmd=(bool)atoi(v.Get("ALLOWGAMECMD").c_str());
enablechatai=(bool)atoi(v.Get("ENABLECHATAI").c_str());
// clientversion is a bit more complicated to add // clientversion is a bit more complicated to add
{ {

View File

@ -42,6 +42,7 @@ class PseuInstanceConf
uint8 showopcodes; uint8 showopcodes;
bool allowgamecmd; bool allowgamecmd;
bool enablecli; bool enablecli;
bool enablechatai;
}; };

View File

@ -394,7 +394,12 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
// some fun code :P // some fun code :P
if(type==CHAT_MSG_SAY && target_guid!=_myGUID && !isCmd) if(type==CHAT_MSG_SAY && target_guid!=_myGUID && !isCmd)
{ {
Chat *chat = new Chat(msg); if (GetInstance()->GetConf()->enablechatai)
{
Chat *chat = new Chat(msg);
SendChatMessage(CHAT_MSG_SAY, lang, chat->GetResult(), "");
delete chat;
}
SendChatMessage(CHAT_MSG_SAY, lang, chat->GetResult(), ""); SendChatMessage(CHAT_MSG_SAY, lang, chat->GetResult(), "");