241 lines
6.5 KiB
Plaintext
241 lines
6.5 KiB
Plaintext
// oracle_h - This function will handle everything that is needed
|
|
// for the conversation with the oracle.
|
|
// By Deva Bryson Winblood. 05/02/2005
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
string fnOracleStrip(string sIn)
|
|
{ // PURPOSE: To strip inconsequentials and set it all to lower-case
|
|
string sRet="";
|
|
int nPos=0;
|
|
string sChar;
|
|
while(nPos<GetStringLength(sIn))
|
|
{ // build return string
|
|
sChar=GetSubString(sIn,nPos,1);
|
|
if (sChar!="."&&sChar!="?"&&sChar!=","&&sChar!="!") sRet=sRet+sChar;
|
|
nPos++;
|
|
} // build return string
|
|
sRet=GetStringLowerCase(sRet);
|
|
return sRet;
|
|
} // fnOracleStrip()
|
|
|
|
int fnOracleExpand(string sIn)
|
|
{ // PURPOSE: If this word is a contraction such as you're it
|
|
// will expand it into two words like you are.
|
|
int nCount=1;
|
|
object oMe=OBJECT_SELF;
|
|
int nCur=GetLocalInt(oMe,"nNumWords");
|
|
string sWord1=sIn;
|
|
string sWord2="";
|
|
if (sIn=="i'll")
|
|
{ // i will
|
|
sWord1="i";
|
|
sWord2="will";
|
|
nCount=2;
|
|
} // i will
|
|
else if (sIn=="you're")
|
|
{ // you are
|
|
sWord1="you";
|
|
sWord2="are";
|
|
nCount=2;
|
|
} // you are
|
|
else if (sIn=="we're")
|
|
{ // we are
|
|
sWord1="we";
|
|
sWord2="are";
|
|
nCount=2;
|
|
} // we are
|
|
else if (sIn=="can't")
|
|
{ // cannot
|
|
sWord1="can";
|
|
sWord2="not";
|
|
nCount=2;
|
|
} // cannot
|
|
else if (sIn=="won't")
|
|
{ // will not
|
|
sWord1="will";
|
|
sWord2="not";
|
|
nCount=2;
|
|
} // will not
|
|
else if (sIn=="haven't")
|
|
{ // have not
|
|
sWord1="have";
|
|
sWord2="not";
|
|
nCount=2;
|
|
} // have not
|
|
else if (sIn=="hasn't")
|
|
{ // has not
|
|
sWord1="has";
|
|
sWord2="not";
|
|
nCount=2;
|
|
} // has not
|
|
else if (sIn=="i'm")
|
|
{ // i am
|
|
sWord1="i";
|
|
sWord2="am";
|
|
nCount=2;
|
|
} // i am
|
|
if (nCount==1)
|
|
{ // single word
|
|
nCur=nCur+1;
|
|
SetLocalString(oMe,"sWord"+IntToString(nCur),sWord1);
|
|
} // single word
|
|
else if (nCount==2)
|
|
{ // two words
|
|
nCur=nCur+1;
|
|
SetLocalString(oMe,"sWord"+IntToString(nCur),sWord1);
|
|
nCur=nCur+1;
|
|
SetLocalString(oMe,"sWord"+IntToString(nCur),sWord2);
|
|
} // two words
|
|
return nCount;
|
|
} // fnOracleExpand()
|
|
|
|
void fnOracleParse(string sIn)
|
|
{ // PURPOSE: This will parse the sIn into separate words stored
|
|
// as sWord# on the oracle. The number of words will be stored as
|
|
// nNumWords.
|
|
object oMe=OBJECT_SELF;
|
|
string sMaster=fnOracleStrip(sIn);
|
|
int nCount;
|
|
string sParse;
|
|
int nPos=0;
|
|
string sChar;
|
|
int nRet;
|
|
while(nPos<GetStringLength(sMaster))
|
|
{ // build parsed words
|
|
sChar=GetSubString(sMaster,nPos,1);
|
|
if (sChar!=" ") sParse=sParse+sChar;
|
|
else
|
|
{ // word break
|
|
nRet=fnOracleExpand(sParse);
|
|
nCount=nCount+nRet;
|
|
SetLocalInt(oMe,"nNumWords",nCount);
|
|
sParse="";
|
|
} // word break
|
|
nPos++;
|
|
} // build parsed words
|
|
if (GetStringLength(sParse)>0)
|
|
{ // word remains
|
|
nRet=fnOracleExpand(sParse);
|
|
nCount=nCount+nRet;
|
|
SetLocalInt(oMe,"nNumWords",nCount);
|
|
} // word remains
|
|
} // fnOracleParse()
|
|
|
|
int fnOracleNumWords()
|
|
{ // PURPOSE:return number of words
|
|
return GetLocalInt(OBJECT_SELF,"nNumWords");
|
|
} // fnOracleNumWords()
|
|
|
|
string fnOracleWord(int nWordNum)
|
|
{ // PURPOSE: To return specific word
|
|
return GetLocalString(OBJECT_SELF,"sWord"+IntToString(nWordNum));
|
|
} // fnOracleWord()
|
|
|
|
void fnOracleProfanity()
|
|
{ // PURPOSE: To handle responses to any statement or question
|
|
// that contains profanity
|
|
} // fnOracleProfanity()
|
|
|
|
string fnGetPID(object oPC)
|
|
{ // PURPOSE: Return the player ID
|
|
return GetPCPlayerName(oPC)+GetPCPublicCDKey(oPC)+GetName(oPC);
|
|
} // fnGetPID()
|
|
|
|
void fnOracleYou()
|
|
{ // PURPOSE: To handle reactions to statements that begin with
|
|
// the word you
|
|
} // fnOracleYou()
|
|
|
|
void fnOracleGreetings()
|
|
{ // PURPOSE: To handle response to what appear to be greetings
|
|
// statements
|
|
} // fnOracleGreetings()
|
|
|
|
void fnOracleWhat()
|
|
{ // PURPOSE: To handle responses to questions beginning with what
|
|
} // fnOracleWhat()
|
|
|
|
void fnOracleWhy()
|
|
{ // PURPOSE: To handle responses to questions beginning with why
|
|
} // fnOracleWhy()
|
|
|
|
void fnOracleHow()
|
|
{ // PURPOSE: To handle responses to question beginning with how
|
|
} // fnOracleHow()
|
|
|
|
void fnOracleWho()
|
|
{ // PURPOSE: To handle responses to questions beginning with who
|
|
} // fnOracleWho()
|
|
|
|
void fnOracleWhen()
|
|
{ // PURPOSE: To handle responses to questions beginning with when
|
|
} // fnOracleWhen()
|
|
|
|
void fnOracleWhere()
|
|
{ // PURPOSE: To handle responses to questions beginning with where
|
|
} // fnOracleWhere()
|
|
|
|
void fnOracleI()
|
|
{ // PURPOSE: To handle responses to statements beginning with I
|
|
} // fnOracleI
|
|
|
|
void fnOracleMy()
|
|
{ // PURPOSE: To handle responses to statements beginning with my
|
|
} // fnOracleMy()
|
|
|
|
void fnOracleWe()
|
|
{ // PURPOSE: To handle responses to statements beginning with we
|
|
} // fnOracleWe()
|
|
|
|
void fnOracleWill()
|
|
{ // PURPOSE: To handle responses to questions beginning with will
|
|
} // fnOracleWill()
|
|
|
|
void fnOracleTell()
|
|
{ // PURPOSE: To handle responses to questions beginning with tell
|
|
} // fnOracleTell()
|
|
|
|
void fnOracleActions()
|
|
{ // PURPOSE: To handle responding to any statements telling the
|
|
// oracle to do something that is plainly not possible
|
|
} // fnOracleActions()
|
|
|
|
void fnOracleDo()
|
|
{ // PURPOSE: To handle responses to questions beginning with do
|
|
} // fnOracleDo()
|
|
|
|
void fnOracleConfusion()
|
|
{ // PURPOSE: To handle things the oracle does not understand
|
|
} // fnOracleConfusion()
|
|
|
|
void fnOracle(string sStatements)
|
|
{ // PURPOSE: The main oracle function
|
|
object oMe=OBJECT_SELF;
|
|
string sWord;
|
|
int nCount;
|
|
AssignCommand(oMe,fnOracleParse(sStatements));
|
|
nCount=fnOracleNumWords();
|
|
sWord=fnOracleWord(1);
|
|
if (sWord=="go"||sWord=="walk"||sWord=="jump"||sWord=="open") fnOracleActions();
|
|
else if (sWord=="you") fnOracleYou();
|
|
else if (sWord=="i") fnOracleI();
|
|
else if (sWord=="we") fnOracleWe();
|
|
else if (sWord=="what") fnOracleWhat();
|
|
else if (sWord=="where") fnOracleWhere();
|
|
else if (sWord=="why") fnOracleWhy();
|
|
else if (sWord=="when") fnOracleWhen();
|
|
else if (sWord=="tell") fnOracleTell();
|
|
else if (sWord=="will") fnOracleWill();
|
|
else if (sWord=="hello"||sWord=="hi"||sWord=="greetings") fnOracleGreetings();
|
|
else if (sWord=="how") fnOracleHow();
|
|
else if (sWord=="my") fnOracleMy();
|
|
else if (sWord=="do") fnOracleDo();
|
|
else if (sWord=="eat"||sWord=="talk"||sWord=="shout"||sWord=="run"||sWord=="climb") fnOracleActions();
|
|
else if (sWord=="swim"||sWord=="fart"||sWord=="scream") fnOracleActions();
|
|
else if (sWord=="fuck"||sWord=="shit"||sWord=="damn"||sWord=="bitch"||sWord=="ass"||sWord=="asshole") fnOracleProfanity();
|
|
else if (sWord=="pussy"||sWord=="shithead"||sWord=="cunt") fnOracleProfanity();
|
|
else { fnOracleConfusion(); }
|
|
} // fnOracle()
|
|
|
|
//void main(){}
|