marc2333
2012-12-26 01:44:56
I made a script for a Rsps. What it does is read first line of chat and search up for commands. The commands are "!Roll", "!Under", "!Over", "!Lucky", "!Total", "!Blackjack", "Addcard" and "!Stay". They are all made with bipmap and work well. The whole script works kinda well (even if i need to add alot of things..). I am looking for help to clear my shit a bit. Its the first time i make a bot with 100+ lines and its starting to be hard to follow, even for myself. I try to follow as much as i can the standarts but its kinda hard with the tab button and yea.
Anyway, i am looking for tips to improve my standarts and if anyone got tricks to make my script shorter ! :)
here it is :
Anyway, i am looking for tips to improve my standarts and if anyone got tricks to make my script shorter ! :)
here it is :
program DiceBot;
{$i srl/srl.simba}
var
X,Y,Roll,Count,DoWeUnder,DoWeLucky,DoWeOver,oroll,DoWeTotal,CountL,CountW,counter,Blackj,DAdding,ACard,CardNumber,CardCounter,CC1,CC2:integer;
procedure TypeSendExx(Text: string; PressEnter: Boolean);
var
I: Integer;
begin
for i := 1 to Length(Text) do
begin
{$IFDEF SIMBAMAJOR980}
SendKeys(Text[i], 1 + Random(1));
{$ELSE}
SendKeys(Text[i], 1 + Random(1), 1 + Random(1));
{$ENDIF}
Wait(1);
end;
if (PressEnter) then
TypeByte(VK_ENTER);
end;
function Under:boolean;
begin
DoWeUnder := BitmapFromString(35, 10, 'meJztUUEOACAI8v+fpku1Jcqc8x' +
'iHZgSyEWwD9sBdBYpK0PCDpoJwTl4I4kPG2UVQqGEye0Uuq9gb5GB' +
'QVp22NIIYojFRafjvmrzDAlqPV6k=');
if FindBitMapToleranceIn(DoWeUnder,X,Y,23,416,227,432,10)then
begin
result:=true;
end else
begin
result:=false;
end;
FreeBitMap(DoWeUnder);
end;
function Over:boolean;
begin
DoWeOver := BitmapFromString(28, 10, 'meJz7z4AC/oMRheA/NjaFxuIyhx' +
'JjB8RMrIHDAAt5TNn/5JqJS/A/bmVYdeFxMFYTyDATl9+pYiNB7bj' +
'SPFZb0JwKZwAA8/M+wg==');
if FindBitMapToleranceIn(DoWeOver,X,Y,23,416,227,432,10)then
begin
result:=true;
end else
begin
result:=false;
end;
FreeBitMap(DoWeOver);
end;
function Lucky:boolean;
begin
DoWeLucky := BitmapFromString(33, 14, 'meJz7zwAF/xnIBAQ1/sdgjFpBqh' +
'X/cbP/Y9OI1SisKvFbgUsZfvdQbsV/DBGCbFKtwG8stQIKq8mYsYZ' +
'HkAGbdjwuwSNCdTB0raA8OxNpC9x8AMP3ULA=');
if FindBitMapToleranceIn(DoWeLucky,X,Y,23,416,227,432,10)then
begin
result:=true;
end else
begin
result:=false;
end;
FreeBitMap(DoWeLucky);
end;
function DaTotal:boolean;
begin
DoWeTotal := BitmapFromString(28, 10, 'meJz7zwAC/1ERJQDNBIKmEWPd8D' +
'ATM3iJF8FqJlY2pqVY1VBiJrI7SbKXzu4k1UwGDE/h0oLpdwD3M0u1');
if FindBitMapToleranceIn(DoWeTotal,X,Y,23,416,227,432,10)then
begin
result:=true;
end else
begin
result:=false;
end;
FreeBitMap(DoWeTotal);
end;
Procedure DoWeRoll;
Begin
Roll := BitmapFromString(21, 10, 'meJz7zwAF/5EQfvAfifEfQ5CBkA' +
'mDWft/DMX/cRj+H4ONqRerLly2k6odjywZtpNkPjEhjz/oAFNfQb8=');
End;
function DaRoll:boolean;
begin
DoWeRoll
if FindBitMapToleranceIn(Roll,X,Y,23,416,227,432,10)then
begin
result:=true;
end else
begin
result:=false;
end;
FreeBitMap(Roll);
end;
procedure Rolling;
begin
if(DaRoll=true)then
begin
repeat
roll:=1+random(100);
if (roll>=60)then
begin
wait(100);
inc(CountW);
typesendexx('green:The roll is -' + inttostr(roll) + '- you won',true);
end else
begin
wait(100);
inc(CountL);
typesendexx('red:The roll is -' + inttostr(roll) + '- you lost',true);
end;
inc(count);
inc(counter);
wait(100);
until(count=1);
end;
begin
wait(10)
end;
if(Under=true)then
begin
inc(counter);
oroll :=2+random(6)+random(6);
if(oroll<7)then
begin
inc(countW)
TypeSendexx('green:The under-over roll is -' + IntToStr(oroll) + '- you won',true);
end;
if(oroll>=7)then
begin
inc(countL)
TypeSendexx('red:The under-over roll is -' + IntToStr(oroll) + '- you lost',true);
end;
end;
if(Over=true)then
begin
inc(counter);
oroll :=2+random(6)+random(6);
if(oroll<=7)then
begin
inc(countL)
TypeSendexx('red:The under-over roll is -' + IntToStr(oroll) + '- you lost',true);
end;
if(oroll>7)then
begin
inc(countW)
TypeSendexx('Green:The under-over roll is -' + IntToStr(oroll) + '- you won',true);
end;
end;
if(Lucky=true)then
begin
oroll :=2+random(6)+random(6);
if(oroll>7)or(oroll<7)then
begin
TypeSendexx('red:The under-over roll is -' + IntToStr(oroll) + '- you lost at trying x4',true);
end;
if(oroll=7)then
begin
TypeSendexx('Green:The under-over roll is -' + IntToStr(oroll) + '- you won x4 !!!',true);
end;
end;
if(DaTotal=true)then
begin
TypeSendexx('white:Total rolls: ' + IntToStr(Counter) + ' - Total wins: ' + IntToStr(CountW) + ' - Total loss: ' + inttostr(CountL),true);
end;
end;
function Black:boolean;
begin
Blackj := BitmapFromString(124, 14, 'meJztV8EWgzAI897//1532HtdJ' +
'xBCYdMDeR6UxlQj0DrGB0cRxjd+wVfj53IyDzlKIsrnpdbnL7Q9pB' +
'adl/EcBxm05wy/PS/3fNJu9zwpZTVSGXyfX14cdGBXEA9hvjoF38/' +
'lqAySH2tDSs1zK3iJ48SzKkiScUTOksxzsgpOI56XCnm+6rhNKeP5' +
'oRVgYW+RhaAaZWV4UuqZnu/l+UTnuUt+cm/hh3h+dA1VL13PVUH3d' +
're35NdQsLCC/6lCqQaJ9u1v2N7qN7bRnt8CsIHk8QJ2+KGe');
if FindBitMapToleranceIn(Blackj,X,Y,23,416,227,432,20)then
begin
result:=true;
end else
begin
result:=false;
end;
FreeBitMap(Blackj);
end;
function DoneAdding:boolean;
begin
DAdding := BitmapFromString(97, 16, 'meJztV0EOwyAMy2n//3F2mDQh7D' +
'gE2KEDn2hIk+IaC8wucrwa/KLmSNmJfBp3eHSaV0TbbiNLpWrVviM' +
'UeTyo4i8pomycQNE3raQiERlEZAIY/Iy77xTukRbUUzqftkAv6h4d' +
'aMQIjqmKomAX17810icm6wh2GbRrk7rSxmWzFLUt0h26QpExeU9QZ' +
'NKgHIT0IIrmVEQRUfR0FS1uNL1kPYXSqtq1XkWUQAumr6cbTdg1PT' +
'dGdr33kHAOLkUpLkUU67eVE7Dr8nsO3i4aUKQ=');
if FindBitMapToleranceIn(DAdding,X,Y,23,416,227,432,25)then
begin
result:=true;
end else
begin
result:=false;
end;
FreeBitMap(DAdding);
end;
function AddCard:boolean;
begin
ACard := BitmapFromString(117, 11, 'meJztVUEOgCAM48b/X4wHE8Wt6' +
'2BAIsbGg9S6aRlbzjfSJOQnVughX9SyQB0SEzKGM1T9qRMd7orWm7' +
'fF3oJIS8zJGD5sry5jInbJGLaz95LtZS9sepo878U/km7pBuSPuB6' +
'mqO0Vl5C1kI1MoqFg9Vqk4Hk5WedCizmjs4xUL9RoUpexpbdyBeyt' +
'47hdZcTehI7VuL0Bn0UcUcDuPr7T3lj1Xlhhb4vs2/Yurd6wvV2jD' +
'S5de2FA93W3OZDRBvlkzDtOEhncBTg6f6zAAV8niBU=');
if FindBitMapToleranceIn(ACard,X,Y,23,416,227,432,15)then
begin
result:=true;
writeln('true');
writeln('true');
writeln('true');
end else
begin
result:=false;
writeln('false');
end;
FreeBitMap(ACard);
end;
procedure AddACard;
begin
CardNumber:=(random(52)+1)
case(CardNumber)of
1:
begin
CardCounter:=CardCounter+11
TypeSendExx('You pick the ace of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
2:
begin
CardCounter:=CardCounter+2
TypeSendExx('You pick the 2 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
3:
begin
CardCounter:=CardCounter+3
TypeSendExx('You pick the 3 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
4:
begin
CardCounter:=CardCounter+4
TypeSendExx('You pick the 4 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
5:
begin
CardCounter:=CardCounter+5
TypeSendExx('You pick the 5 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
6:
begin
CardCounter:=CardCounter+6
TypeSendExx('You pick the 6 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
7:
begin
CardCounter:=CardCounter+7
TypeSendExx('You pick the 7 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
8:
begin
CardCounter:=CardCounter+8
TypeSendExx('You pick the 8 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
9:
begin
CardCounter:=CardCounter+9
TypeSendExx('You pick the 9 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
10:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the 10 of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
11:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the jack of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
12:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the queen of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
13: begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the king of hearts, total is ' + inttostr(CardCounter) + '.',true)
end;
14:
begin
CardCounter:=CardCounter+11
TypeSendExx('You pick the ace of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
15:
begin
CardCounter:=CardCounter+2
TypeSendExx('You pick the 2 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
16:
begin
CardCounter:=CardCounter+3
TypeSendExx('You pick the 3 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
17:
begin
CardCounter:=CardCounter+4
TypeSendExx('You pick the 4 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
18:
begin
CardCounter:=CardCounter+5
TypeSendExx('You pick the 5 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
19:begin
CardCounter:=CardCounter+6
TypeSendExx('You pick the 6 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
20:
begin
CardCounter:=CardCounter+7
TypeSendExx('You pick the 7 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
21:
begin
CardCounter:=CardCounter+8
TypeSendExx('You pick the 8 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
22:
begin
CardCounter:=CardCounter+9
TypeSendExx('You pick the 9 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
23:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the 10 of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
24:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the jack of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
25:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the queen of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
26:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the king of diamonds, total is ' + inttostr(CardCounter) + '.',true)
end;
27:
begin
CardCounter:=CardCounter+11
TypeSendExx('You pick the ace of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
28:
begin
CardCounter:=CardCounter+2
TypeSendExx('You pick the 2 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
29:
begin
CardCounter:=CardCounter+3
TypeSendExx('You pick the 3 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
30:
begin
CardCounter:=CardCounter+4
TypeSendExx('You pick the 4 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
31:
begin
CardCounter:=CardCounter+5
TypeSendExx('You pick the 5 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
32:
begin
CardCounter:=CardCounter+6
TypeSendExx('You pick the 6 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
33:
begin
CardCounter:=CardCounter+7
TypeSendExx('You pick the 7 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
34:
begin
CardCounter:=CardCounter+8
TypeSendExx('You pick the 8 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
35:
begin
CardCounter:=CardCounter+9
TypeSendExx('You pick the 9 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
36:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the 10 of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
37:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the jack of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
38:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the queen of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
39:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the king of spades, total is ' + inttostr(CardCounter) + '.',true)
end;
40:
begin
CardCounter:=CardCounter+11
TypeSendExx('You pick the ace of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
41:
begin
CardCounter:=CardCounter+2
TypeSendExx('You pick the 2 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
42:
begin
CardCounter:=CardCounter+3
TypeSendExx('You pick the 3 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
43:
begin
CardCounter:=CardCounter+4
TypeSendExx('You pick the 4 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
44:
begin
CardCounter:=CardCounter+5
TypeSendExx('You pick the 5 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
45:
begin
CardCounter:=CardCounter+6
TypeSendExx('You pick the 6 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
46:
begin
CardCounter:=CardCounter+7
TypeSendExx('You pick the 7 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
47:
begin
CardCounter:=CardCounter+8
TypeSendExx('You pick the 8 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
48:
begin
CardCounter:=CardCounter+9
TypeSendExx('You pick the 9 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
49:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the 10 of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
50:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the jack of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
51:
begin
CardCounter:=CardCounter+10
TypeSendExx('You pick the queen of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
52:
begin
CardCounter:=CardCounter+11
TypeSendExx('You pick the king of clubs, total is ' + inttostr(CardCounter) + '.',true)
end;
end;
end;
procedure blackjackDealer;
begin
TypeSendExx('The dealer can start adding cards',true);
repeat
if(AddCard=true) then
begin
AddACard;
end;
wait(100);
Until(DoneAdding=true)or(CardCounter>21)or(CardCounter>CC1);
end;
procedure blackjackBetter;
begin
if (Black = true) then
begin
TypeSendExx('The better can start adding cards',true);
repeat
if(AddCard=true) then
begin
AddACard;
end;
wait(100);
Until(DoneAdding=true)or(CardCounter>21);
end;
end;
procedure BBlackjack;
begin
if(Black=true)then
begin
repeat
blackjackBetter;
wait(100);
until(DoneAdding=true)or(CardCounter>21);
CC1:=CardCounter;
CardCounter:=0;
if(CC1>21)then
begin
TypeSendExx('red:Better busted with ' + inttostr(CC1) + ', dealer wins.',true);
end else
begin
TypeSendExx('white:Your total is ' + inttostr(CC1) + ', dealer needs to beat it.',true);
wait(2000);
repeat
blackjackDealer;
wait(100);
until(DoneAdding=true)or(CardCounter>21)or(CardCounter>CC1);
CC2:=CardCounter;
CardCounter:=0;
if (CC2>21) then
begin
TypeSendExx('green:Dealer busted with ' + inttostr(CC2) + ', better wins.',true);
end else
if (CC1>CC2)then
begin
TypeSendExx('green:Dealer total is ' + inttostr(CC2) + ', better beats dealer.',true);
end else
TypeSendExx('red:Dealer total is ' + inttostr(CC2) + ', dealer wins.',true);
end;
end;
end;
begin
cleardebug;
wait(2000);
repeat
cleardebug;
count:=0
rolling;
BBlackjack
until(iskeydown(27));
end.