King of Knives
2007-10-29 17:44:41
This is the culmination of todays work.
I call the balloon animals "Dogs". Don't ask me why.
The script contains:
> Autocolor, of course.
> Good object-identifying of the turning statues.
> Good failsafes, probably needs more though.
> Everything is supported. Except for running away, though. I forgot to clear that part out before leaving the random-event myself.
> Dog-finding rates (Popping them on the mainscreen)
Fat Dog: 50%
Tiny Dog: 20%
Horn Dog: 95%
Cat Dog: 20%
If you incidently should be in possession of an account at this random, please run this script and tell me how it worked. Also post bugs, ideas for improving, etc.
Here are a few of the "progress reports":
Portals left: 3
TARGET: Fat dog
Portals left: 3
TARGET: Fat dog
Portals left: 2
TARGET: Fat dog
Portals left: 1
TARGET: Horn dog
Portals left: 0
Portals left: 3ยจ
TARGET: Tiny dog
Portals left: 3
TARGET: Tiny dog
Portals left: 2
TARGET: Tiny dog
Portals left: 1
TARGET: Horn dog
Portals left: 0
Portals left: 3
TARGET: Cat dog
Portals left: 3
TARGET: Tiny dog
Portals left: 3
TARGET: Cat dog
Portals left: 3
TARGET: Horn dog
Portals left: 2
TARGET: Fat dog
Portals left: 3
TARGET: Horn dog
Portals left: 3
TARGET: Tiny dog
Portals left: 3
TARGET: Cat dog
Portals left: 3
TARGET: Horn dog
Portals left: 2
TARGET: Horn dog
Portals left: 1
TARGET: Tiny dog
Portals left: 0
If you want to know more, just post your question here.
———
Code:
program Balloon_ScapeRune;
{.include SRL/SRL.scar}
var
srl_Dog: String;
srl_PortalsLeft: Integer;
srl_FatDog,srl_TinyDog,srl_HornDog,srl_CatDog: Integer;
ms_FatDog,ms_TinyDog,ms_HornDog,ms_CatDog: Integer;
function FindObjAdvUpText(var x,y: Integer; Boxsize,SBSize: Integer; UpText: String; Colors: TIntegerArray; Tol,MaxSkipBoxes: Integer): Boolean;
var
A,b: TIntegerArray;
Boxes: TBoxArray;
C,CsInBox,NB: Integer;
NBox: Boolean;
begin
SetArrayLength(a,GetArrayLength(Colors))
SetArrayLength(b,GetArrayLength(Colors))
if MaxSkipBoxes = 0 then MaxSkipBoxes:= 2;
SetArrayLength(Boxes,MaxSkipBoxes)
repeat
NBox:= False;
C:= 0;
CsInBox:= 0;
if FindColorSkipBoxArrayTolerance(A[C],B[C],Colors[C],MSx1,MSy1,MSx2,MSy2,Tol,Boxes)then
begin
repeat
Inc(C)
if FindColorTolerance(A[C],B[C],Colors[C],A[0]-BoxSize,B[0]-BoxSize,A[0]+BoxSize,B[0]+BoxSize,Tol)then
begin
Inc(CsInBox)
//Writeln('Found '+IntToStr(CsInBox+1)+' color in box')
end else NBox:= True;
until (CsInBox = GetArrayLength(Colors)-1) or (NBox)
end;
begin
if NB >= MaxSkipBoxes then Break;
if NBox then
begin
Boxes[NB]:= IntToBox(A[0]-SBSize,B[0]-SBSize,A[0]+SBSize,B[0]+SBSize)
Inc(NB)
end else
begin
MMouse(A[0],B[0],3,3)
Wait(120+random(70))
if IsUpText(UpText) then
begin
GetMousePos(x,y)
Result:= True;
Exit;
end else
begin
if NB >= MaxSkipBoxes then Break;
Boxes[NB]:= IntToBox(A[0]-SBSize,B[0]-SBSize,A[0]+SBSize,B[0]+SBSize)
Inc(NB)
end;
end;
end;
until(false)
end;
Procedure LoadDogDTMs;
begin
srl_FatDog := DTMFromString('78DA65CFC14A02510085E17B5F40B060C8664' +
'2891622BD450BA14DD0AA659B36BE820F106E0A2483705184826F' +
'60A241054EB531A195A29943816D8ADA16D45948F0CFBD8B33FFC' +
'0C730D79E18638606E778F1C864F5B4F3775BD70C6826FE88A6AA' +
'E9D29C7BA73435D74C83279A4813D284E96B9A8475CC2837A0196' +
'B1A348FA93ECD8275CCDBC68CE647734613F9139A6F4D93E6397E' +
'AF755595E66BF583A6A729D38C83D8BD3CD521CD8B3FA5D951EDD' +
'25492659A3D5581A6B5DCA429AA4A34EDB516CDBEEA80E63E7BEB' +
'FE4FCCB4572E5C53897D2713D26CAA3A34774B5D9A6DD525CD67F' +
'A9D26AF7AA0B9F1AE68B6547D9AD720FA37BF3A7F7A5A4991');
srl_TinyDog := DTMFromString('78DA633CC2C0C070930105DC95BEC5A001A41' +
'9A17CC6D3986A9EDB3E4555730F48AC4255B35B6E0BAA9AF74062' +
'25AA9A43F27B50D5B00059EB51D55C55BB88AA663790988DAAE68' +
'AC6595435EB80441FAA9ACBAA1750D52C0112EDA86A4EAB9F4055' +
'D300243251D55C5043B3AB1348E4A2AAB9A57B1D558D3A90750BC' +
'DCD929750D5E860AA7922FD10558D2A90F51055CD6DE99BA86AB4' +
'80ACA7A86A9E293EC674CF4734BB641E62BA074DCD330D34731C8' +
'1AC0DA86A0EA8A1C569082346DA38A37C12554D0C905580AAE6B8' +
'F4515435C98C18F1F550EA3EAA9A0E206B19AA9A238A0751D5CC0' +
'1B2D6A0AAB9A47C1EAEE63F100000F7AA47EE');
srl_HornDog := DTMFromString('78DA6DD23B4B03511005E0DD14A28D9548B2D' +
'9245B189074824110F1455A219595F80304416CACFD0176B1F109' +
'626B21826021480AD15D457C6C1E3E0326468C9BD829D8781AC13' +
'3E385E51E968F61B833E69A6918C3F8FE9CC7D89DD18BFBF7AFB9' +
'8D34C426701A6CB69052C224DFD8AC6A731F2BB35941B2D93CFCD' +
'78F30AD817736EB4821362F892A9B65A436361796C72687F449C4' +
'380B9FB0D9D0A69EAC69536753893FB1D9412AB0390A1FB2D9472' +
'AB2F1AC5336C7BA4ED9F2D914B479B62B6C1A48376C1AE95736DF' +
'DA0419318BAE90EAB99915A61DC667F331D16493D2A63515B0C9C' +
'07CB1F1A3576C46603A78EE7BDDBB6CC6617AD8B89698FB184C9A' +
'8D1771D94CC2E4B99FF33E617230076CAA83621633304B6C6AB6D' +
'8E769984536B791229B2CCC82D80DA7C46614665E1A51A75F9BEB' +
'C4251B0766964D292EEA74EA3A6E54BCF31CCCA6A863F33EFF00E' +
'26A66DE');
srl_CatDog := DTMFromString('78DA85D33D4BC3501805E07B7F82A0965A0B2' +
'EB185E2074AC182BAF90FFC030E2E3AB4839B8382835097226E82' +
'7470924645C40AD6A20E52B46AADD57E450D452C8A5B5DC4C523B' +
'89CF70E6638398187DC9BE48D3E554AB98A8E4B4F4E0571D67FD7' +
'3A8F68B0791D7B619343DCB279EAAAB339314DB6F3884D1AB1C9A' +
'63AFEC0C646AC0B33224C12B122F6335863B386586453EB2BB349' +
'2062C244848923A6D89406AED8FCAE33C9A6D873C3661E31C1A61' +
'C28B16922F6D89C5959365F88149B8CFF80CD3722CDE6C23A67D3' +
'867628F61CB8368D2DE6C712F31342DB6753098AE71A423BFEE75' +
'B8C9AFB71FA2B6C66D19ED9DCFB8A6C62A6F9F0BFB199416B8A67' +
'F716D8CCA1BDB371230E9B69B49698794F864D14ED53DC67F851C' +
'C185A924DC3E7B259D0C67FB1D3BECD66156D83CD5D6FC15C6B49' +
'7C0BAF78CF096DFC3B4EB82A661E2DCA66B7DB66B36C9A54C7169' +
'91F10366794');
ms_FatDog := DTMFromString('78DA635CC7C4C0708701054C92EB60D000D28' +
'C503EE316A09A5BA86A16C9CF4455B303A8E626AA9A2E8D2A5435' +
'DB816AEEA2AA69D7A84455B315A8E63EAA9A1D8AEB51D5EC04AAB' +
'98DAA66A72D1635E876C9D4A3A80100EAB21565');
ms_TinyDog := DTMFromString('78DA637CCAC0C060C0C8800C66CB4C66D000D' +
'23051C6BB986A3AAC6B50D55C0512FAA86AAA94F250D59C01127A' +
'68E6A8A399F31CD3AE4AA55C14350080810BD5');
ms_HornDog := DTMFromString('78DA63646162608865644006532CFA1934803' +
'44C949101A8261A554DB3593DAA9ADF40561CAA9A45EAF351D530' +
'01CD89475533CD6222AA9A7F40560CAA9A8D76EB50D57CC0B46BB' +
'DE23254355F81AC1054356D5AE5A86A3E61AAE9D4AEC2B42B1255' +
'4DBE4622AA9A8F405612AA9A09DA8D286A00242218FB');
ms_CatDog := DTMFromString('78DA637CCDC0C060C8C8800CDA95AB1934803' +
'44C94F1179030415533556F22AA1A46460C35D3FC26A1AA6103B2' +
'8C51D52C975E82AA8615C8D24355D36FD085A9C61C55CD4695752' +
'86A00AAF20C4F');
end;
Procedure FreeDogDTMs;
begin
FreeDTM(srl_FatDog)
FreeDTM(srl_TinyDog)
FreeDTM(srl_HornDog)
FreeDTM(srl_CatDog)
FreeDTM(ms_FatDog)
FreeDTM(ms_TinyDog)
FreeDTM(ms_HornDog)
FreeDTM(ms_CatDog)
end;
Function WaitUntilText(Text: String; MaxTime: Integer): Boolean;
var
a,b,Timer: Integer;
begin
MarkTime(Timer)
repeat
Wait(100+random(100))
if TimeFromMark(Timer) > MaxTime then
begin
Result:= False;
Exit;
end;
until FindText(a,b,Text,NPCChars,MCx1,MCy1,MCx2,MCy2)
Result:= True;
end;
Procedure ContConv(S: String);
begin
if WaitUntilText(S,10000) then ClickToContinue;
end;
Procedure PrisonPeteTalk;
begin
ContConv('happened')
ContConv('captured')
ContConv('Captured')
ContConv('stuck')
ContConv('captive')
ContConv('correct')
ContConv('contains')
ContConv('doors')
end;
Procedure FindLever;
var a,b,T: Integer;
begin
repeat
if FindObjAdvUpText(a,b,10,10,'ull',[1118484,8421770,3626083],10,100) then
begin
GetMousePos(a,b)
Mouse(a,b,0,0,true)
Break;
end else
begin
Mouse(717, 295,10,10,true)
FFlag(0)
if FindColorTolerance(a,b,195836,MMx1,MMy1,MMx2,MMy2,20) then
begin
Mouse(a,b,4,4,true)
FFlag(0)
Wait(500+random(200))
FindLever;
end;
end;
Wait(500+random(500))
until(false)
MarkTime(T)
repeat
Wait(100+random(100))
if FindText(a,b,'correct',SmallChars,MSx1,MSy1,MSx2,MSy2) then Break;
until(TimeFromMark(T) > 10000)
if TimeFromMark(T) > 10000 then FindLever;
end;
Function GetBalloonAnimal: Boolean;
var a,b: Integer;
begin
if FindDTM(srl_FatDog,a,b,MSx1,MSy1,MSx2,MSy2) then
begin
srl_Dog:= 'Fat'
Result:= True;
end;
if FindDTM(srl_TinyDog,a,b,MSx1,MSy1,MSx2,MSy2) then
begin
srl_Dog:= 'Tiny'
Result:= True;
end;
if FindDTM(srl_HornDog,a,b,MSx1,MSy1,MSx2,MSy2) then
begin
srl_Dog:= 'Horn'
Result:= True;
end;
if FindDTM(srl_CatDog,a,b,MSx1,MSy1,MSx2,MSy2) then
begin
srl_Dog:= 'Cat'
Result:= True;
end;
end;
Procedure GetTarget;
var Timer,TTimer,RandX: Integer;
begin
MarkTime(Timer)
MarkTime(TTimer)
case random(5) of
0: RandX:= 1000;
1: RandX:= 2000;
2: RandX:= 3000;
3: RandX:= 4000;
4: RandX:= 5000;
end;
repeat
Wait(10+random(10))
if TimeFromMark(Timer) > 10000+RandX then
begin
MMouse(4,4,700,450)
MarkTime(Timer)
case random(5) of
0: RandX:= 1000;
1: RandX:= 2000;
2: RandX:= 3000;
3: RandX:= 4000;
4: RandX:= 5000;
end;
end;
if TimeFromMark(TTimer) > 100000 then
begin
FreeDogDTMs;
LogOut;
end;
until(GetBalloonAnimal)
Writeln('TARGET: '+srl_Dog+' dog')
end;
Procedure RoomMiddle; Forward;
Procedure PopRight;
var
a,b,iTimer: Integer;
E: Extended;
FoundDog: Boolean;
begin
MouseSpeed:= 50+random(10)
case srl_Dog of
'Fat': begin
MarkTime(iTimer)
repeat
if FindDTMRotated(ms_FatDog,a,b,MSx1,MSy1,MSx2,MSy2,-20,20,0.1,E) then
begin
Mouse(a,b,2,2,true)
FFlag(0)
FoundDog:= True;
Break;
end;
until(TimeFromMark(iTimer) > 8000)
end;
'Tiny': begin
MarkTime(iTimer)
repeat
if FindDTMRotated(ms_TinyDog,a,b,MSx1,MSy1,MSx2,MSy2,-20,20,0.1,E) then
begin
Mouse(a,b,2,2,true)
FFlag(0)
FoundDog:= True;
Break;
end;
until(TimeFromMark(iTimer) > 8000)
end;
'Horn': begin
MarkTime(iTimer)
repeat
if FindDTMRotated(ms_HornDog,a,b,MSx1,MSy1,MSx2,MSy2,-20,20,0.1,E) then
begin
Mouse(a,b,2,2,true)
FFlag(0)
FoundDog:= True;
Break;
end;
until(TimeFromMark(iTimer) > 8000)
end;
'Cat': begin
MarkTime(iTimer)
repeat
if FindDTMRotated(ms_CatDog,a,b,MSx1,MSy1,MSx2,MSy2,-20,20,0.1,E) then
begin
Mouse(a,b,2,2,true)
FFlag(0)
FoundDog:= True;
Break;
end;
until(TimeFromMark(iTimer) > 8000)
end;
end;
MouseSpeed:= 20+random(6)
if not FoundDog then
begin
if FindColorTolerance(a,b,195836,MMx1,MMy1,MMx2,MMy2,20) then
begin
Mouse(a,b,4,4,true)
FFlag(0)
Wait(500+random(200))
RoomMiddle;
PopRight;
end;
end;
end;
Procedure RoomMiddle;
var a,b: Integer;
begin
if FindColorTolerance(a,b,229,MMx1,MMy1,MMx2,MMy2,40) then
begin
Mouse(a,b-40,10,10,true)
FFlag(0)
Wait(200+random(300))
end;
end;
Procedure ReturnKey;
var a,b,Key: Integer;
begin
Key := DTMFromString('78DA634C66626078CD80023435A518FE03694' +
'620FE0F048C3940350F18D000231209A40B806AEE115053045473' +
'93809A0A22D53C24A0261FA8E6090135B940356F09A8C904AA794' +
'7404D0A50CD47026AE2816ADE10509346849B13816A5EE0570300' +
'0A4716BC');
if WaitUntilText('key',10000) then
begin
if FindDTM(Key,a,b,MIx1,MIy1,MIx2,MIy2) then
begin
Mouse(a,b,5,5,true)
end;
end else
begin
PopRight;
ReturnKey;
end;
FreeDTM(Key)
end;
Procedure PP_KeyTalk;
var
a,b,T: Integer;
RightDog: Boolean;
begin
ContConv('thanks')
Wait(2000+random(2000))
MarkTime(T)
repeat
if TimeFromMark(T) > 20000 then Break;
if FindText(a,b,'wrong',NPCChars,MCx1,MCy1,MCx2,MCy2) then
begin
RightDog:= False;
Break;
end;
if FindText(a,b,'right',NPCChars,MCx1,MCy1,MCx2,MCy2) then
begin
RightDog:= True;
Break;
end;
until(false)
if RightDog then Dec(srl_PortalsLeft)
else Inc(srl_PortalsLeft)
if srl_PortalsLeft > 3 then srl_PortalsLeft:= 3;
ClickToContinue;
end;
Procedure EscapeTheRandom;
var a,b: Integer;
begin
if FindColorTolerance(a,b,1310462,MMx1,MMy1,MMx2,MMy2,20) then
begin
Mouse(a+30,b,10,10,true)
FFlag(0)
end;
end;
begin
SetupSRL;
ClearDebug;
LoadDogDTMs;
ActivateClient;
srl_PortalsLeft:= 3;
MakeCompass('N')
HighestAngle;
PrisonPeteTalk;
SetRun(True)
GameTab(4)
repeat
Writeln('Portals left: '+IntToStr(srl_PortalsLeft))
FindLever;
GetTarget;
Wait(1000+random(4000))
RoomMiddle;
PopRight;
ReturnKey;
PP_KeyTalk;
until(srl_PortalsLeft = 0)
Writeln('Portals left: '+IntToStr(srl_PortalsLeft))
FreeDogDTMs;
ContConv('before')
EscapeTheRandom;
ContConv('present')
ContConv('around')
end.-Knives