marpis
2009-04-25 20:48:16
Autotalk(seconds: integer);
second is the minimum time between responds. 60 would respond max once in a minute.
You must declare TalkTimer as a global variable.
I made this for my upcoming MultiFighter, and this system seems to work very well. It ignores the lines you have written your self, or you have already responded. That's why you'll have to declare RespondedChatLines: TStringArray as a global variable. The name has to be exact.
It responds to level questions very smart way:
if you ask the bot "hi whats your att, prayer and def levels?"
it'll answer something like "att 31, prayer 23 defence 30", so the answer is rarely identical.
It doesn't have alot of triggers yet, just enough so i can say its working and very human.
Things it already answers:
- all levels
- max hit (things like 'i can 1 hit kalphite queen')
- words 'noob', 'nub', 'newb' and so on
- words 'macro', 'auto', 'bot' and so on
- compliments like 'nice gear', 'cool shield' and so on (doesn't contain enough words yet)
- greetings 'wazzup', 'whats up' and so on
If you want to be part of this project, you can send here triggers/responds like this:
I've made all skills already, so this is just an example
Note that MyLevels[skill] = player.skill[number] - 1 !!
So Runecrafting in GameTab-include is skill number 7, but in MyLevels[] it is 6.
Check it out and tell me what you think :)
Remember its on beta stage yet
EDIT:
second is the minimum time between responds. 60 would respond max once in a minute.
You must declare TalkTimer as a global variable.
I made this for my upcoming MultiFighter, and this system seems to work very well. It ignores the lines you have written your self, or you have already responded. That's why you'll have to declare RespondedChatLines: TStringArray as a global variable. The name has to be exact.
It responds to level questions very smart way:
if you ask the bot "hi whats your att, prayer and def levels?"
it'll answer something like "att 31, prayer 23 defence 30", so the answer is rarely identical.
It doesn't have alot of triggers yet, just enough so i can say its working and very human.
Things it already answers:
- all levels
- max hit (things like 'i can 1 hit kalphite queen')
- words 'noob', 'nub', 'newb' and so on
- words 'macro', 'auto', 'bot' and so on
- compliments like 'nice gear', 'cool shield' and so on (doesn't contain enough words yet)
- greetings 'wazzup', 'whats up' and so on
If you want to be part of this project, you can send here triggers/responds like this:
I've made all skills already, so this is just an example
// Runecrafting
if posexx(['runecraft','rc'], ChatLines[i])>11 then
begin
TSA:= ['rc ', 'runecrafting ', 'rclvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[6]);
end;
Note that MyLevels[skill] = player.skill[number] - 1 !!
So Runecrafting in GameTab-include is skill number 7, but in MyLevels[] it is 6.
Check it out and tell me what you think :)
Remember its on beta stage yet
EDIT:
var
RespondedChatLines: TStringArray;
TalkTimer: integer;
function posexx(substrarr: TStringArray; str: string): integer;
var
i: integer;
begin
for i:= 0 to High(SUBstrarr) do
begin
result:= pos(lowercase(substrarr[i]), lowercase(str));
if (result > 0) then
exit;
end;
end;
function GetChatboxLine(line: integer): string;
begin
result:= GetChatboxText(line, clBlack) + GetChatboxText(line, clChat) + GetChatboxText(line, clTrade) + GetChatboxText(line, clFriend);
end;
function Autotalk(seconds: integer): boolean;
var
i, ii: integer;
MyLevels: array [0..23] of integer;
ChatLines: array [0..7] of string;
TSA: TStringArray;
s: string;
responded: boolean;
begin
if (TimeFromMark(TalkTimer) < seconds*1000) then exit;
// Read messages in the chatbox
for i:= 1 to 8 do
ChatLines[i-1]:= GetChatboxLine(i);
// Find triggers
for i:= 7 downto 0 do
begin
if (pos(players[currentplayer].nick, Chatlines[i])>12) or (pos(players[currentplayer].nick, Chatlines[i])=0) then
if not InStrArr(ChatLines[i], RespondedChatLines, false) then
begin
{================================== LEVELS ===========================================================}
if (posexx(['att','att','str','def','rang','magi','healt', 'hp', 'pray'],lowercase(ChatLines[i]))>11) then
begin
responded:= true;
writeln('Answering: Levels');
GetAllLevels;
for ii := 0 to 23 do
Mylevels[ii] := players[currentplayer].Level[ii+1];
// Attack
if pos('att', lowercase(ChatLines[i]))>11 then
begin
TSA:= ['att ', 'attack ', 'attlvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[0]);
end;
// Strength
if pos('str', lowercase(ChatLines[i]))>11 then
begin
TSA:= ['str ', 'strength ', 'strlvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[1]);
end;
// Defence
if pos('def', lowercase(ChatLines[i]))>11 then
begin
TSA:= ['def ', 'defence ', 'deflvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[2]);
end;
// Ranged
if pos('rang', lowercase(ChatLines[i]))>11 then
begin
TSA:= ['rang ', 'ranged ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[3]);
end;
// Prayer
if pos('pray', lowercase(ChatLines[i]))>11 then
begin
TSA:= ['pray ', 'prayer ', 'praylvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[4]);
end;
// Magic
if pos('mag', lowercase(ChatLines[i]))>11 then
begin
TSA:= ['mag ', 'magic ', 'maglvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[5]);
end;
// Runecrafting
if posexx(['runecraft','rc'], ChatLines[i])>11 then
begin
TSA:= ['rc ', 'runecrafting ', 'rclvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[6]);
end;
// HP
if posexx(['hp', 'healt'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['hp ', 'healt ', 'health ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[7]);
end;
// Agility
if posexx(['agi'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['agi ', 'agility ', 'agilvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[8]);
end;
// Herblore
if posexx(['herb'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['herb ', 'herblore ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[9]);
end;
// Thieving
if posexx(['thiev', 'thief'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['thieving ', 'thief ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[10]);
end;
// Crafting
if posexx(['craft'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['crafting ', 'craft ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[11]);
end;
// Fletching
if posexx(['fletc'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['fletch ', 'fletching ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[12]);
end;
// Slayer
if posexx(['slay'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['slayer ', 'slaying ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[13]);
end;
// Mining
if posexx(['minin'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['mining ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[14]);
end;
// Smithing
if posexx(['smith'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['smith ', 'smithing ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[15]);
end;
// Fishing
if posexx(['fish'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['fish ', 'fishing ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[16]);
end;
// Cooking
if posexx(['cook'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['cooking ', 'cook ', 'cooklvl']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[17]);
end;
// Firemaking
if posexx(['fm', 'firemak'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['fm ', 'firemaking ', 'fmlvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[18]);
end;
// Woodcutting
if posexx(['wc', 'woodcut'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['wc ', 'woodcut ', 'woodcutting ', 'wclvl ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[19]);
end;
// Farming
if posexx(['farm', 'farmin'], lowercase(ChatLines[i]))>11 then
begin
TSA:= ['farm ', 'farming ']
s:=s + TSA[random(Length(TSA))] + IntToStr(MyLevels[19]);
end;
// S A Y T H E L I N E
s:= Trim(s);
writeln(s);
TypeSend(s);
end else
{================================== MAX HIT ====================================================}
if (posexx(['max hit', 'maxhit'], ChatLines[i])>11) then
begin
responded:= true;
writeln('Answering: Max hit');
TSA:= ['over 9000!!','more than yours nub','i can 1 hit kalphite queen','too much','you cant even imagine it','insane','not your business','wanna try on arena'];
Typesend(TSA[random(Length(TSA))]);
end else
{================================ BOT ACCUSE ===============================================}
if (posexx(['bot', 'auto', 'macro'], ChatLines[i])>11) then
begin
responded:= true;
writeln('Answering: Max hit');
TSA:= ['haha 8P','lololol','couldnt care less actually','ehmm lol','yea right'];
Typesend(TSA[random(Length(TSA))]);
end else
{================================== ABUSE ====================================================}
if (posexx(['noob', 'nuub', 'nob', 'newb'], ChatLines[i])>11) then
begin
responded:= true;
writeln('Answering: Abuse');
TSA:= ['phewt','pfft','yea right','could still pwn u'];
Typesend(TSA[random(Length(TSA))]);
end else
{================================= GREETINGS ===================================================}
if (posexx(['whatup', 'wazzup', 'wazup', 'watap', 'watup', 'what''s up', 'whatsup', 'whats up', 'wasup', 'wassup', 'hi ', 'hello'], ChatLines[i])>11) then
begin
responded:= true;
writeln('Answering: Greetings');
TSA:= ['hi there','yo yo','wasup','whatap','whats up','hello'];
Typesend(TSA[random(Length(TSA))]);
end else
{================================ COMPLIMENTS ================================================}
if (posexx(['nice', 'cool', 'kewl', 'great', 'awesome'], ChatLines[i])>11) and (posexx(['weapon', 'shield', 'armor', 'plate', 'pl8', 'cape', 'helm', 'staff', 'sword', 'gear', 'body', 'leg', 'name'], ChatLines[i])>11) then
begin
responded:= true;
writeln('Answering: Compliments');
TSA:= ['heh thanks','ty','thanks dude','yup','lol','not rly'];
Typesend(TSA[random(Length(TSA))]);
end;
// end of triggers
result:= responded;
if result then
begin
MarkTime(TalkTimer);
SetLength(RespondedChatLines, Length(RespondedChatLines)+1);
RespondedChatLines[High(RespondedChatLines)] := ChatLines[i];
exit;
end;
end;
end;
end;