gerauchert
2007-08-04 12:25:13
Ok this is sorta a weird problem im having with the script…
ive been running heavy testing on this to kink out minor bugs and such…and i have been makin good progress on it but all of a sudden it is refusing to work…
i have writeln('starting " " procedure');
at the begining of every procedure in the main loop so i can see where it gets stuck at. this would normally go through atleast half of my procedures and i was currently getting stuck at the CorrectStuff function. I made some minor changes in the function and restart the script. Heres my probelm it will start up the MerchIt procedure fine and Writeln('starting Merchit Procedure'); BUT! When some1 trades me it will go into the OpenTrade function, completely skip doing the Writeln('OpenTrade function');, Open the trade fine, and just sit there and then revert to MerchIt procedure. It was working fine and could make it past this EVERY time but now it wont even do my Writeln's……
Heres my script:
I was hoping some1 could test this out and see if the same thing happens to them….if you want to test it with me just send me a pm and we can simulate a trade so you dont have to actually try to find sum noob to trade :p
if theres anything else stickin outa there that looks like it could be causing this just let me know plz
thanks! :D
EDIT: I just realized that B4 isnt an official SRL include yet so ill post the findcoins function by Boreas….and the quick fix for the tradescreen function is in line 51 of Amount include change the 194 to a 193…
ive been running heavy testing on this to kink out minor bugs and such…and i have been makin good progress on it but all of a sudden it is refusing to work…
i have writeln('starting " " procedure');
at the begining of every procedure in the main loop so i can see where it gets stuck at. this would normally go through atleast half of my procedures and i was currently getting stuck at the CorrectStuff function. I made some minor changes in the function and restart the script. Heres my probelm it will start up the MerchIt procedure fine and Writeln('starting Merchit Procedure'); BUT! When some1 trades me it will go into the OpenTrade function, completely skip doing the Writeln('OpenTrade function');, Open the trade fine, and just sit there and then revert to MerchIt procedure. It was working fine and could make it past this EVERY time but now it wont even do my Writeln's……
Heres my script:
program GerauchertMerchanter;
{.include SRL/SRL.scar}
{.include SRL\SRL\misc\Trade.scar}
{.include SRL\SRL\misc\B4.scar}
var TheItems, FinalItems, FinalMoney, OT, TS, TSA, FT, Price, Adj,
MerchTime, WaitTime: Integer;
TheMoney: Tpoint;
Msg, TheDifference: String;
Money: Array [0..9] of Integer;
const
PriceA= 200; // price of the item you are buying/selling
MsgA= 'sellin saphires '; //message that you will type (dont type the price in this) it will do it for you =p
MsgTime= 4000; //time between messages + random 3000 ms
ItemName='Sapphire'; //EXACT item name you are buying/selling. First letter
//MUST be capitalized
ItemColor= 9508114; // Color of the item you are buying/selling
Buying= False; //Buying or selling?
Adjust= True; //Do you want the script to lower/raise the price if it isnt
// buying/selling quickly?
AdjustTime= 10; // Time in minutes before it adjusts the price
PriceAdj= 10; // How much do you want the price to be adjusted?
AdjCap=3; // Limits how many times it will adjust the price
procedure LoadDTMs;
begin
Money[0]:= DTMFromString('78DA6314616060006124B0699218830E23030' + // 1 coin
'31031FC07024671204390010D302291401A242F44408D00909020' +
'A006649738E56A007BFE068C');
Money[1]:= DTMFromString('78DA6314646060906440019B268931E830323' + // 2 coins
'00011C37F206004A9116340038C482490E60212D204D448000979' +
'026A6430DD83AE060097560674');
Money[2] := DTMFromString('78DA6394656060906240019B268931E830323' + //3 coins
'00011C37F20605405324418D000231209A4D5818424013520BBE4' +
'08A8110612A204D408000919FC6A00AA4A06D4');
Money[3] := DTMFromString('78DA6394626060906440019B268931E830323' + //4 coins
'00011C37F206004A9116440038C482490560712A204D428000929' +
'026A84818434116A4408A8E1C5F417BA1A00937F06E7');
Money[4] := DTMFromString('78DA6314646060906140019B268931E830323' + //5 coins
'00011C37F206094C55403918591405A0148281250A306242408A8' +
'9104126204D4F0020939FC6A00A54606D4');
Money[5] := DTMFromString('78DA6354616060306040019B268931E830323' + //25 coins
'00011C37F2060D402329419D000231209A441E6281150230724D4' +
'09A81103127A04D4A8020913026A407ED2C1AF0600F9D907BD');
Money[6] := DTMFromString('78DA6354666060D06040019B268931E830323' + //100 coins
'00011C37F2060D401326419D000231209A4F58084220135069876' +
'61A85105124604D48803095D026AA480840A0135F284DD0C0019B' +
'E07EF');
Money[7] := DTMFromString('78DA63D4606060506740019B268931E830323' + //250 coins
'00011C37F20605405325419D000231209A441E6C81350A3072414' +
'09A83101126A04D41803095D22DC634C408D2C903020A04612486' +
'812502345D85F008FBA08AF');
Money[8] := DTMFromString('78DA635463606050624001B737CB30E830323' + //1000 coins
'00011C37F20603400326418D000231209A40D81843A0135169876' +
'61A8D102129A04D4C801090D026A6481841C01356A84FD0500746' +
'50847');
Money[9]:= DTMFromString('78DA631465606010634001F7B74A32FC02D28' + //10000 coins
'C40FC1F081815810C410634C0884402692520214D400D1F905022' +
'A0861548881250C30E241488708F3C7E350089510804');
end;
//ANTIRANDOMZ//
Function FindFastRandoms: Boolean; // By WT-Fakawi.
Var
i: Integer;
Begin
For I := 1 To 11 Do
Begin
Case I Of
1: If FindDead Then
Result := True;
2: If FindMod Then
Result := True;
3: If FindMime Then
Result := True;
4: If FindMaze Then
Result := True;
5: If FindQuiz Then
Result := True;
6: If FindDemon Then
Result := True;
7: Begin
If NoGameTab Then
Begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
End;
End;
8 : If RC Then
Result := True;
9 : If FindFight Then
Begin
Result := True;
RunTo('S', True);
End;
10: If FindTalk Then
Result := True;
11: If FindTrade Then
Result := True;
End;
Wait(1);
End;
End;
procedure Randomz;
begin
FindFastRandoms;
FindNormalRandoms;
end;
procedure AntiBannage;
begin
case random(1000) of
0: MakeCompass('n');
1: MakeCompass('s');
2: MakeCompass('e');
3: MakeCompass('w');
4: MouseBox(MSX1,MSY1,MSX2,MSY2,3);
5: PickUpMouse;
6: RandomRClick;
7: SleepAndMoveMouse(5000 + random(2000));
8: BoredHuman;
9: MouseBox(MMX1,MMY1,MMX2,MMY2,3);
10: HoverSkill('random',False);
11: GameTab(0 + random(11));
end;
end;
procedure Respond;
var Say: String;
begin
if(FindChatText('declined'))then
begin
case random(36) of
1: Say:= 'noob';
2: Say:= '...';
3: Say:= 'wtf...';
4: Say:= '*sigh*';
5: Say:= 'wow';
6: Say:= 'ehh?';
7: Say:= '???';
8: Say:= 'whatever...';
9: Say:= 'omg';
10: Say:= 'lol?';
11: Say:= 'lolz';
12: Say:= 'lmao';
13: Say:= 'lmfao!';
14: Say:= 'rofl';
15: Say:= 'gah';
16: Say:= 'boo';
17: Say:= 'roflz';
18: Say:= 'idiot...';
end;
FT:= FT + 1;
TypeSend(Say);
end else
if(FindChatText('ccepted'))then
begin
case random(13) of
0: Say:= 'ty';
1: Say:= 'ty';
2: Say:= 'thx';
3: Say:= 'thanks';
4: Say:= 'tyvm';
5: Say:= 'thank you';
6: Say:= 'tyvm!';
7: Say:= 'thx!';
8: Say:= 'yw';
9: Say:= 'ty =p';
10: Say:= 'tyvm =0';
11: Say:= 'thanks =)';
12: Say:= 'wewt ty';
end;
TSA:= TSA + 1;
TS:= TS + 1;
TypeSend(Say);
end;
end;
Function Time2Adjust: Boolean;
begin
if(TimeFromMark(MerchTime) > (AdjustTime * 60000)) and (TS = 0)then
begin
MarkTime(MerchTime);
Result:= True;
end else
begin
if(Adj = AdjCap) or (TimeFromMark(MerchTime) < (AdjustTime * 60000))then
Result:= False;
Exit;
end;
end;
procedure AdjustIt;
begin
if(Time2Adjust = True)then
begin
if(Buying = True)then
begin
Writeln('Its been over ' + IntToStr(AdjustTime) + ' minutes with no sales...'
+'raising price by ' + IntToStr(PriceAdj));
Price:= (PriceA + PriceAdj);
Adj:= Adj + 1;
TS:= 0;
end else
begin
Writeln('Its been over ' + IntToStr(AdjustTime) + ' minutes with no sales...'
+'lowering price by ' + IntToStr(PriceAdj));
Price:= (PriceA - PriceAdj);
Adj:= Adj + 1;
TS:= 0;
end;
end;
end;
procedure MerchIt;
begin
Writeln('MerchIt procedure');
repeat
Msg:= MsgA + IntToStr(Price) + 'ea';
if(not(LoggedIn))then
LogInPlayer;
if (SomeoneTrades) then
Break;
TypeSend(Msg);
MarkTime(WaitTime);
while (TimeFromMark(WaitTime) < (MsgTime + random(3000))) do
begin
Randomz;
AntiBannage;
if(Adjust = True)then
begin
AdjustIt;
end;
end;
until(SomeoneTrades);
Writeln('some1 traded me!');
end;
//Opens trade
Function OpenTrade: Boolean;
begin
Writeln('OpenTrade Function');
if FindColorSpiralTolerance(x,y, 8388736, MCX1, MCY1, MCX2, MCY2,50) then
begin
Mouse(x,y,0,0,True);
MarkTime(WaitTime);
Writeln('Waiting for tradescreen');
repeat
Wait(500 + random(200));
if(TimeFromMark(WaitTime) > 7000)then
begin
Writeln('Timed out');
Result:= False;
Exit;
end;
until(TradeScreen);
Writeln('Were at the tradescreen');
OT:= OT + 1;
Result:= True;
end;
end;
procedure PutUpItems;
var i: Integer;
begin
Writeln('Starting putupitems procedure');
if(TradeScreen)then
begin
for i:= 0 to 5 do
begin
if FindColorSpiralTolerance(x,y,ItemColor,MIX1,MIY1,MIX2,MIY2,i) then
begin
MMouse(x,y,3,3);
Wait(500 + random(300));
Mouse(x,y,3,3,False);
ChooseOption(x,y,'All');
end;
end;
end;
end;
procedure PutUpGold;
var i: integer;
begin
if(TradeScreen)then
for i:= 0 to 9 do
begin
if(FindDTM(Money[i],x,y,MIX1,MIY1,MIX2,MIY2))then
begin
MMouse(x,y,3,3);
Wait(500 + random(300));
Mouse(x,y,3,3,False);
ChooseOption(x,y,'All');
end;
end;
end;
//Puts up items or gold
procedure PutItUp;
begin
if(Buying = True)then
begin
Writeln('putting up cash');
PutUpGold;
end else
if(Buying = False)then
begin
Writeln('putting up items');
PutUpItems;
end;
end;
//checks for correct items on the trade screen for other player
Function CorrectStuff: Boolean;
var i: Integer; Found: Boolean;
begin
Writeln('Correct Stuff Function');
if(TradeScreen)then
begin
if(Buying = True)then
begin
MarkTime(WaitTime);
repeat
Wait(500 + random(200));
if(TimeFromMark(WaitTime) > 20000)then
begin
Writeln('took too long to put up items...declining');
Decline;
Result:= False;
Exit;
end;
until(FindColorSpiralTolerance(x,y,ItemColor,262,58,503,328,10));
Writeln('They got the goods...');
Result:= True;
end else
begin
MarkTime(WaitTime);
repeat
for i:= 0 to 9 do
begin
if(FindDTM(Money[i],x,y,262,58,503,328))then
Writeln('Found the cash');
Found:= True;
if(TimeFromMark(WaitTime) > 20000)then
begin
Writeln('took too long to put up cash...declining');
Decline;
Result:= False;
Exit;
end;
end;
until(Found = True);
Result:= True;
Writeln('they got the cash');
end;
end;
end;
//Checks if the quantities are correct
Function CheckPerfectTrade: Boolean;
begin
if(not(TradeScreen))then
Exit;
if(Buying = True)then
begin
TheItems:= AmountColor('trade',ItemColor,10);
TheMoney:= FindCoins('lefttrade');
begin
if(TheMoney.y = (TheItems * Price))then
begin
Result:= True;
end;
end;
end else
begin
TheItems:= AmountColor('your trade',ItemColor,10);
TheMoney:= FindCoins('righttrade');
begin
if(TheMoney.y = (TheItems * Price))then
begin
Result:= True;
end;
end;
end;
end;
Function TheyHaveTooMuch: Boolean;
begin
if(not(TradeScreen))then
Exit;
if(Buying = True)then
begin
TheItems:= AmountColor('trade',ItemColor,10);
TheMoney:= FindCoins('lefttrade');
begin
if(TheMoney.y < TheItems)then
begin
Result:= True;
end;
end;
end else
begin
TheItems:= AmountColor('your trade',ItemColor,10);
TheMoney:= FindCoins('righttrade');
begin
if(TheMoney.y < TheItems)then
begin
Result:= True;
end;
end;
end;
end;
Function WeHaveTooMuch: Boolean;
begin
if(not(TradeScreen))then
Exit;
if(Buying = True)then
begin
TheItems:= AmountColor('trade',ItemColor,10);
TheMoney:= FindCoins('lefttrade');
begin
if(TheMoney.y > TheItems)then
begin
Result:= True;
end;
end;
end else
begin
TheItems:= AmountColor('your trade',ItemColor,10);
TheMoney:= FindCoins('righttrade');
begin
if(TheMoney.y > TheItems)then
begin
Result:= True;
end;
end;
end;
end;
Function NotEnough: Boolean;
begin
Writeln('not enough function...');
if(Buying = True)then
begin
TheMoney:= FindCoins('lefttrade');
if(TheMoney.y < Price)then
begin
Result:= True;
Writeln('dont have enough money to go on...logging out');
NextPlayer(False);
end;
end else
begin
TheMoney:= FindCoins('righttrade');
if(TheMoney.y < Price)then
begin
Writeln('They dont have enough to buy 1 item...declining');
Decline;
Result:= True;
end;
end;
end;
//Adjusts how much we put up to make the trade successful
procedure AdjustItems;
var i: Integer;
begin
Writeln('adjusting items function');
if(not(TradeScreen))then
Exit;
if(WeHaveTooMuch = True)then
begin
if(Buying = True)then
begin
TheItems:= AmountColor('trade',ItemColor,10);
TheMoney:= FindCoins('lefttrade');
TheDifference:= IntToStr(TheMoney.y - (TheItems * Price));
for i:= 0 to 9 do
begin
if(FindDTM(Money[i],x,y,23,58,257,328))then
begin
Mouse(x,y,5,5,False);
ChooseOption(x,y,'X');
TypeSend(TheDifference);
end;
end;
end;
end else
begin
TheItems:= AmountColor('your trade',ItemColor,10);
TheMoney:= FindCoins('righttrade');
TheDifference:= IntToStr(TheMoney.y - (TheItems * Price));
if(FindColorSpiralTolerance(x,y,ItemColor,23,58,257,328,10))then
begin
Mouse(x,y,5,5,False);
ChooseOption(x,y,'X');
TypeSend(TheDifference);
end;
end;
end;
//Checks 2nd trade screen
Function CheckTradeScreen2: Boolean;
begin
Writeln('TradeScreen2 check!');
if(not(TradeScreen2))then
Exit;
if(Buying = True)then
begin
FinalItems:= (CheckItem(False,ItemName));
FinalMoney:= (CheckItem(True,'Coins'));
if(FinalItems = FinalMoney)then
begin
Result:= True;
end;
end else
begin
FinalItems:= (CheckItem(True,ItemName));
FinalMoney:= (CheckItem(False,'Coins'));
if(FinalItems = FinalMoney)then
begin
Result:= True;
end;
end;
end;
//Performs checks and adjustments until it times out or you are at the 2nd tradescreen
procedure HandleTheTrade;
begin
Writeln('handle trade procedure');
if(not(TradeScreen))then
Exit;
if(CheckPerfectTrade = True)then
Writeln('perfect trade = true...accepting');
Accept;
begin
if(TheyHaveTooMuch)then
Writeln('they have too much');
MarkTime(WaitTime);
repeat
Wait(500 + random(200));
if(TimeFromMark(WaitTime) > 20000)then
begin
Writeln('timed out declining...');
Decline;
end;
until(CheckPerfectTrade = True);
Writeln('CheckPerfect trade = True...acCepting');
Accept;
MarkTime(WaitTime);
repeat
Wait(500 + random(200));
if(TimeFromMark(WaitTime) > 20000)then
begin
Writeln('timed out other player didnt accept');
Decline;
Respond;
end;
until(TradeScreen2);
end;
if(WeHaveTooMuch)then
Writeln('We have too much...adjusting');
begin
AdjustItems;
MarkTime(WaitTime);
repeat
Wait(500 + random(200));
if(TimeFromMark(WaitTime) > 20000)then
begin
Writeln('timedout...DECLINE');
Decline;
end;
until(CheckPerfectTrade = True);
Writeln('ITs TRU..accepting');
Accept;
MarkTime(WaitTime);
repeat
Wait(500 + random(200));
if(TimeFromMark(WaitTime) > 20000)then
begin
Writeln('timed out other player didnt accept');
Decline;
Respond;
end;
until(TradeScreen2);
end;
end;
Function Finished: Boolean;
var i: Integer;
begin
if(Buying = True)then
for i:= 0 to 9 do
begin
if(not(FindDTM(Money[i],x,y,MIX1,MIY1,MIX2,MIY2)))then
begin
Writeln('No more money left =(');
Result:= True;
Logout;
end;
end else
begin
if(not(FindColorSpiralTolerance(x,y,ItemColor,MIX1,MIY1,MIX2,MIY2,10)))then
begin
Writeln('No more items left to sell =(');
Result:= True;
Logout;
end;
end;
end;
procedure Proggy;
begin
SRLRandomsReport;
Writeln('====================================');
Writeln('********** PROGRESS REPORT *********');
Writeln('====================================');
Writeln('Ran for: ' + TimeRunning);
Writeln('Opened: ' + IntToStr(OT) + ' trades');
Writeln('Made: ' + IntToStr(TSA) + ' successful trades');
Writeln('Had: ' + IntToStr(FT) + ' failed trades');
Writeln('Adjusted price: ' + IntToSTr(Adj) + ' times');
Writeln('====================================');
Writeln('********** HAPPY AUTOING!! *********');
Writeln('====================================');
end;
procedure ScriptSetup;
begin
SetupSRL;
LoadDTMs;
StartPlayers(True,'');
ActivateClient;
MouseSpeed:= 1;
Price:= PriceA;
DisguiseScar('iTunes');
ClearDebug;
end;
procedure Setup;
begin
HighestAngle;
GameTab(4);
SetChat('hide',1);
SetChat('friends',2);
SetChat('on',3);
MarkTime(MerchTime);
end;
//MAINLOOP
begin
ScriptSetup;
repeat
if(not(LoggedIn))then
LogInPlayer;
Setup;
MerchIt;
if(OpenTrade = True)then
PutItUp;
if(CorrectStuff = True)then
begin
if(NotEnough = False)then
HandleTheTrade;
if(CheckTradeScreen2 = True)then
Accept;
repeat
Wait(500 + random(200));
until(not(TradeScreen2));
Respond;
Proggy;
end;
until(Finished);
end.I was hoping some1 could test this out and see if the same thing happens to them….if you want to test it with me just send me a pm and we can simulate a trade so you dont have to actually try to find sum noob to trade :p
if theres anything else stickin outa there that looks like it could be causing this just let me know plz
thanks! :D
EDIT: I just realized that B4 isnt an official SRL include yet so ill post the findcoins function by Boreas….and the quick fix for the tradescreen function is in line 51 of Amount include change the 194 to a 193…
//B4//
type
BlackList = array of integer;
type
BlackListNet = array of Tpoint;
var MyList:BlackListNet;
function BankSlot(WhichSlot:integer):integer;
begin
result:=Whichslot;
end;
function InvSlot(WhichSlot:integer):integer;
begin
result:=Whichslot+48;
end;
function ShopSlot(WhichSlot:integer):integer;
begin
result:=Whichslot+48+28;
end;
function LeftTradeSlot(WhichSlot:integer):integer;
begin
result:=Whichslot+48+28+40;
end;
function RightTradeSlot(WhichSlot:integer):integer;
begin
result:=Whichslot+48+28+40+28;
end;
{*******************************************************************************
function CreateCustomNet(Num:integer):TPointArray;
By: Boreas
Note: Purely an internal function, used in setup.
Description: Returns a TPointArray containing the relative (to x1,y1 of a BSlot)
for a custom amount of points. Only needs to be done once, to create
the list of points to check for 65536. Only takes like 15ms, and I didn't
feel like typing them all out.
Num=1 will check every point
Num=2 will make a net with 1x1 holes
Num=4 will make a net with 3x3 holes
*******************************************************************************}
function CreateCustomNet(Num:integer):BlackListNet;
var Counter,hx,hy,tAL:integer;
var TPointsToCheck:array of TPoint;
begin
repeat
hy:=15;
hx:=hx+1;
repeat
hy:=hy+1;
if (((hx mod Num)=0) or ((hy mod Num)=0)) then
begin
tAL:=tAL+1;
setarraylength(TPointsToCheck,tAL);
TPointsToCheck[Counter].x:=hx;
TPointsToCheck[Counter].y:=hy;
Counter:=Counter+1;
end;
until hy=31;
until hx=31;
result:=TPointsToCheck;
end;
{*******************************************************************************
function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
By: Boreas
Description: Looks at the points in the list for an item, and returns an array
contatining the indexes of the points that are black.
Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
containing positions relative to the x1,y1 of a bankslot which you want to check
*******************************************************************************}
function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
var TmpArray:array of integer;
begin
Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
if WhichBankSlot > 48 then //inv
begin
Tmpx1:=569+(((((WhichBankSlot-48)+3)mod 4))*42);
Tmpy1:=213+(((((WhichBankSlot-48)-1)/4))*36);
end;
if WhichBankSlot>(48+28) then //shop
begin
Tmpx1:=80+(((((WhichBankSlot-(48+28))+7)mod 8))*47);
Tmpy1:=69+(((((WhichBankSlot-(48+28))-1)/8))*47);
end;
if WhichBankSlot>(48+28+40) then //left trade
begin
Tmpx1:=36+(((((WhichBankSlot-(48+28+40))+3)mod 4))*42);
Tmpy1:=75+(((((WhichBankSlot-(48+28+40))-1)/4))*33);
end;
if WhichBankSlot>(48+28+40+28) then //right trade
begin
Tmpx1:=325+(((((WhichBankSlot-(48+28+40+28))+3)mod 4))*42);
Tmpy1:=73+(((((WhichBankSlot-(48+28+40+28))-1)/4))*33);
end;
ListLength:=getarraylength(WhichList)-1;
setarraylength(tmparray,1);
for Counter:= 0 to ListLength do
begin
if GetColor(Tmpx1+WhichList[Counter].x,Tmpy1+WhichList[Counter].y)=65536 then
begin
TmpArray[Counter2]:=Counter;
Counter2:=Counter2+1;
setarraylength(TmpArray,Counter2+1);
end;
end;
setarraylength(TmpArray,Counter2-1);
result:=TmpArray;
end;
{*******************************************************************************
function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
By: Boreas
Description: Returns true if an items blacklist matches the one in the parameters
*******************************************************************************}
function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
var Counter,Tmpx1,Tmpy1,ListLength:integer;
var TheBoolean:boolean;
begin
Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
ListLength:=getarraylength(WhichBlackList)-1;
TheBoolean:=true;
repeat
if not(getcolor(Tmpx1+Whichlist[WhichBlacklist[Counter]].x,
Tmpy1+Whichlist[WhichBlacklist[Counter]].y)=65536) then
TheBoolean:=false;
Counter:=Counter+1;
until ((not(TheBoolean)) or (Counter=(ListLength+1)));
result:=TheBoolean;
end;
{*******************************************************************************
function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
By: Boreas
Description: Returns true both arrays are the same
******************************************************************************}
function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
var Counter:integer;
begin
if not(getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
result:=false;
if (getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
begin
result:=true;
repeat
if not(FirstIntArray[Counter]=SecondIntArray[Counter]) then
result:=false;
Counter:=Counter+1;
until ((Counter=getarraylength(FirstIntArray)) or (result=false));
end;
end;
{*******************************************************************************
function LoadBlackListFromString(BlackListString: string): BlackList;
By: Boreas/moparisthebest
Description: Loads a BlackList from a string given by WriteBlackList. Basically
string -> array or integer
*******************************************************************************}
function LoadBlackListFromString(BlackListString: string): BlackList;
var
i, spacePos: Integer;
begin
repeat
SetArrayLength(Result, i + 1);
spacePos := Pos(' ', BlackListString);
if (not (spacePos = 0)) then
begin
Result[i] := StrToInt(Copy(BlackListString, 1, spacePos - 1));
end
else
begin
Result[i] := StrToInt(Copy(BlackListString, 1, Length(BlackListString)));
break;
end;
Delete(BlackListString, 1, spacePos);
i := i + 1;
until (False)
end;
function FindCoins(Where:string):tpoint;
var
//BL_Coins1, BL_Coins2, BL_Coins3, BL_Coins4, BL_Coins5,
//BL_Coins25, BL_Coins100, BL_Coins250, BL_Coins1000, BL_Coins10000,
tmplist:Blacklist;
CoinBLs:array of Blacklist;
i,i2:integer;
done:boolean;
begin
SetArrayLength(CoinBLs,10);
CoinBLs[0] := LoadBlackListFromString('9 10 11 12 24 32 3' +
'8 48 51 62 75 86 99 110 128 129 133 145');
CoinBLs[1] := LoadBlackListFromString('9 10 11 12 24 32 3' +
'8 48 51 62 75 86 99 110 128 129 133 134 135 145 148 1' +
'54 160 169 172 177 184 193 196 202 208 217 226 231 242');
CoinBLs[2] := LoadBlackListFromString('9 10 11 12 24 32 3' +
'8 48 51 62 75 86 99 110 128 129 133 134 135 145 148 1' +
'54 160 169 172 177 184 193 196 200 201 202 208 231 24' +
'3 253 277 300 320 321');
CoinBLs[3] := LoadBlackListFromString('9 10 11 12 24 32 3' +
'8 48 51 62 75 86 99 110 133 134 135 145 148 154 160 1' +
'69 172 184 193 196 201 202 208 231 243 253 277 300 320 321');
CoinBLs[4] := LoadBlackListFromString('10 11 12 13 27 32 ' +
'39 48 63 87 96 104 105 111 123 134 135 136 146 162 17' +
'3 186 197 203 209 233 243 244 253 277 301 320 321 322 323');
CoinBLs[5] := LoadBlackListFromString('11 12 13 14 25 33 ' +
'40 52 56 64 72 76 80 88 100 104 105 112 135 136 146 1' +
'62 173 186 197 203 210 233 243 244 254 267 278 291 29' +
'6 302 312 321 322 323');
CoinBLs[6] := LoadBlackListFromString('8 9 11 12 13 14 25' +
' 40 52 64 76 88 100 105 112 135 136 146 162 173 186 1' +
'97 210 233 243 244 254 267 278 291 302 312 315 322 323 324');
CoinBLs[7] := LoadBlackListFromString('1 2 17 29 42 53 66' +
' 77 90 101 110 111 112 113 114 115 123 126 140 165 18' +
'9 213 221 222 232 257 281 305 315 316 320 325 336 345 346 347');
CoinBLs[8] := LoadBlackListFromString('2 3 4 16 28 40 52 ' +
'64 65 66 72 73 74 80 81 82 83 91 115 138 147 148 157 ' +
'161 185 186 187 198 209 213 216 217 220 227 228 229 2' +
'30 232 237 240 244 250 251 252 253 254 255 256 257 25' +
'8 259 260 269 283 307 320 331 337 338 339 340');
CoinBLs[9] := LoadBlackListFromString('1 5 11 12 13 14 18' +
' 29 42 53 65 66 67 72 78 80 81 82 92 102 116 126 139 ' +
'147 148 149 158 162 173 174 186 187 189 197 199 210 2' +
'14 220 221 223 224 225 231 234 238 241 242 243 245 24' +
'8 249 250 251 252 253 254 255 256 257 258 259 260 270' +
' 285 309 333 336 337 338 339 340 341');
MyList:=CreateCustomNet(2);
if Where='bank' then
begin
for i:=1 to 48 do
begin
tmplist:=CreateItemBlackList(i,MyList);
for i2:=0 to 9 do
begin
if CompareIntArrays(tmplist,CoinBLs[i2])then
begin
result.x:=i;
done:=true;
break;
end;
end;
if done then break;
end;
result.y:=Amount(Where,result.x);
end;
if Where='inv' then
begin
for i:=1 to 28 do
begin
tmplist:=CreateItemBlackList(InvSlot(i),MyList);
for i2:=0 to 9 do
begin
if CompareIntArrays(tmplist,CoinBLs[i2])then
begin
result.x:=i;
done:=true;
break;
end;
end;
if done then break;
end;
result.y:=Amount(Where,result.x);
end;
if Where='lefttrade' then
begin
for i:=1 to 28 do
begin
tmplist:=CreateItemBlackList(LeftTradeSlot(i),MyList);
for i2:=0 to 9 do
begin
if CompareIntArrays(tmplist,CoinBLs[i2])then
begin
result.x:=i;
done:=true;
break;
end;
end;
if done then break;
end;
result.y:=Amount('your trade',result.x);
end;
if Where='righttrade' then
begin
for i:=1 to 28 do
begin
tmplist:=CreateItemBlackList(RightTradeSlot(i),MyList);
for i2:=0 to 9 do
begin
if CompareIntArrays(tmplist,CoinBLs[i2])then
begin
result.x:=i;
done:=true;
break;
end;
end;
if done then break;
end;
result.y:=Amount('trade',result.x);
end;
if not(done) then
begin
writeln('no coins in '+where);
result.x:=0;
result.y:=0;
end;
end;
{*******************************************************************************
function GetNameOfItemInBank: string;
By: Boreas, bases off of Ron's Replace
Description: Takes item name from uptext in bankscreen, and changes spaces
to underscores
*******************************************************************************}
function GetNameOfItemInBank: string;
var
a : LongInt;
TheString:string;
begin
TheString:=GetUptext;
a := Pos('Withdraw 1 ', TheString);
if(a = 0)then
begin
// Do nothing..
end else
begin
Delete(TheString, a, Length('Withdraw 1 '));
Insert('', TheString, a);
a := Pos(' /', TheString);
delete(thestring,a,Length(TheString));
repeat
a := Pos(' ', TheString);
if a<>0 then
begin
Delete(TheString, a, 1);
Insert('_', TheString, a);
end;
until a=0;
repeat
a := Pos(chr(39), TheString);
if a<>0 then
begin
Delete(TheString, a, 1);
end;
until a=0;
Result := TheString;
end;
end;
{*******************************************************************************
function LongTextBreakDown(TheString):string;
By: Ron and Boreas
Description: Formats a long string so that it looks like the result of
DTM to text. Pretty much only useful for BlackList to Text
*******************************************************************************}
function LongTextBreakDown(TheString:string):array of string;
var iter:integer;
tmpstring:string;
begin
tmpstring:=TheString;
if length(tmpstring) > 62 then
begin
setarraylength(result,iter+1);
result[iter]:=copy(tmpstring, 1, 61)+chr(39)+' +';
delete(tmpstring, 1, 61);
while length(tmpstring) > 69 do
begin
iter:=iter+1;
setarraylength(result,iter+1);
result[iter]:=' '+chr(39)+copy(tmpstring, 1, 53)+chr(39)+' +';
delete(tmpstring, 1, 53);
end;
iter:=iter+1;
setarraylength(result,iter+1);
result[iter]:=' '+chr(39)+tmpstring;
end else
begin
setarraylength(result,1);
result[0]:=tmpstring;
end;
end;
{*******************************************************************************
procedure WriteBlackList(TheBlackList: BlackList);
By: Boreas/moparisthebest
Description: Displays a BlackList as a string in debug box. Basically
array of integer -> string and DTM editor's DTM to Text put together
*******************************************************************************}
procedure WriteBlackList(TheBlackList: BlackList);
var
i, arrayLength: Integer;
mystr,tmpresult:string;
aos:array of string;
begin
arrayLength := GetArrayLength(TheBlackList);
repeat
tmpresult := tmpresult + IntToStr(TheBlackList[i]);
if (not (i = (arrayLength - 1))) then
tmpresult := tmpresult + ' ';
i := i + 1;
until (i = arrayLength)
mystr:=GetNameOfItemInBank;
if mystr='' then mystr:='BlackList';
tmpresult:=' BL_'+mystr+' := LoadBlackListFromString('+chr(39)+tmpresult+chr(39)+');';
aos:=LongTextBreakDown(tmpresult);
for i:=0 to getarraylength(aos)-1 do
writeln(aos[i]);
end;