SRL Archive - Outdated / Broken

Decrabbenizer [Reflection]


n3ss3s

2008-09-11 15:11:03

This is my rock crab fighter which uses reflection, fights at the eastern crabs.








Then a small progress report for you, tell me if the image doesn't load, I didn't build in a text proggie. The image should be below.





Credits for JuKKa and Ben for WindPath and WebWalk.


Program DeCrabbenizer;
{.include SRL/SRL/Misc/SMART.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Reflection/Reflection.scar}
{.include SRL/SRL/Misc/Users.scar}



//* Notes:
//*** It's the Eastern Crabs!
//*** Set the FightMode manually.


Const
SpecX1 = 572;
SpecY1 = 417;
SpecX2 = 713;
SpecY2 = 428;

Const
UseSpec = False; // If you use weapon other than dds, d mace, d long, you
// might have to change the time between specs...

Const
MaxSleep = 10;
UseSleep = True;

// Set this to true if you want the MaxSleep to be in effect.
// If you use this, instead of just a logout and a few minute wait the script
// will sleep for max MaxSleep minutes.


Var
SpecTime, Specs, InActive, Runs, Tab, Crabs: Integer;



Function ClientSolveBox: Boolean;

Var
TPA: TPointArray;
TPAA: T2DPointArray;
I: Integer;
Begin
FindColorsTolerance(TPA, 4803916, 107, 277, 431, 322, 10);
If GetArrayLength(TPA) < 1 Then Exit;
TPAA := TPAToATPAEx(TPA, 70, 30);
SetArrayLength(TPA, 0);
TPA := TPAA[GetBoxAnswer];
I := GetArrayLength(TPA);
Mouse(TPA[Random(i)].x, TPA[Random(i)].y, 0, 0, True);
Result := True;
End;


Function FindNormRandoms: Boolean;

Var
I: Integer;
Begin
For i := 1 To 8 Do
Begin
Case I of
1: SolveNonTalkingRandoms;
2: Respond;
3: Result := FindTalk;
4: Result := FindDead;
5: Result := FindLamp(LampSkill);
6:
If FindBox Then
Begin
Result := OpenBox;
If Result Then
Result := ClientSolveBox;
End;
7: Result := RC;
8: Result := FindMod;
End;
If Result Then
Break;
//Wait(1);
End;
End;


Function MeInFight: Boolean;

Var
Me: TMe;
Begin
Me := GetMe;
Result := Me.InFight;
End;


Function Specialize: Boolean;

Begin
If Not UseSpec Then Exit;
GameTab(1);
// If CountColorTolerance(3703606, SpecX1, SpecY1, SpecX2, SpecY2, 20) > 0 Then
If SimilarColors(GetColor(707, 425), 3440179, 50) Then
Begin
Mouse(SpecX1, SpecY1, SpecX2 - SpecX1, SpecY2 - SpecY1, True);
Result := True;
SpecTime := GetSystemTime;
End;
End;


Procedure RandomGameTab;

Begin
GameTab(1 + Random(14));
If Random(3) = 0 Then
MMouse(MIX1, MIY1, MIX2, MIY2);
Wait(500 + Random(1000));
GameTab(4);
Tab := GetSystemTime;
End;


Function WindPath(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended): TPointArray;

var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
lastX, lastY: integer;
sqrt2, sqrt3, sqrt5: extended;
begin
if not(LoggedIn) then Exit;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
while hypot(xs - xe, ys - ye) > 1 do
begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
if (maxStep < 3) then
begin
maxStep:= random(3) + 3.0;
end else
begin
maxStep:= maxStep / sqrt5;
end;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) / 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[ High(Result) ] := Point(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
lastdist:= dist;
end;
end;


Function WebWalk(TileX, TileY: Integer): Boolean;

Var
I: Integer;
M: TPoint;
CTRLPoints: TPointArray;
Begin
if not(LoggedIn) then Exit;
Repeat
M := GetMyPos;
CtrlPoints := WindPath(M.x, M.y, TileX, TileY, 5.0, 2.5, 0.0, 0.0, 4.5, 2.5);
For I:= High(CtrlPoints) DownTo 0 Do
if WalkToTile(CtrlPoints[i],0, 10) Then
Begin
Result := I = High(CtrlPoints);
Break;
End;
Until(Result);
End;


Function InsultCrabsMothers: Boolean;
// Not really, just walks to south and back.

Begin
SetRun(True);
If Not WebWalk(RandomRange(2702, 2710), RandomRange(3672, 3665)) Then
Exit;
Wait(3000 + Random(3000));
If Not WebWalk(RandomRange(2702, 2710), RandomRange(3708, 3716)) Then
Exit;
Result := True;
InActive := 0;
End;


Function FightCrab: Boolean;

Var
Rock: TNPC;
Time: Integer;
Begin
If MeInFight Then
Exit;
If GetMMLevels('run', Players[0].Strings[0]) > 50 Then
SetRun(True);
Result := FindNPC('Rocks', Rock);
If Result Then
Begin
Result := False;
If Rock.Tile.X < 2692 Then Exit;
Writeln('Crab in Area.');
If Not TileOnMS(Rock.Tile, 0)
Or (iAbs(Rock.Ms.X - MSX1) < 50)
Or (iAbs(Rock.Ms.Y - MSY1) < 50)
Or (iAbs(Rock.Ms.X - MSX2) < 50)
Or (iAbs(Rock.Ms.Y - MSY2) < 50) Then
Begin
WalkToTile(Rock.Tile, 1, 0);
Exit;
End;
Mouse(Rock.Ms.x, Rock.Ms.y, 10, 10, True);
r_Flag;
Time := GetSystemTime;
Repeat
Wait(50);
If Random(100) = 0 Then
MMouse(MSX1, MSY1, MIX2, MIY2);
If GetSystemTime - Time > 5000 Then
Begin
InActive := InActive + 1;
Writeln('Hippie crabs.');
Exit;
End;
Until(MeInFight);
Time := GetSystemTime;
Result := True;
Repeat
Wait(200 + Random(100));
If Random(85) = 0 Then
MMouse(MSX1, MSY1, MIX2, MIY2)
Else
If Random(200) = 0 Then
RandomRClick;
If FindNormRandoms Then
Break;
If GetSystemTime - Time > 45000 Then
Break;
If GetSystemTime - SpecTime > (300000 + Random(100000)) Then
If Specialize Then Specs := Specs + 1;
If GetSystemTime - Tab > 45000 + Random(35000) Then
If Random(2) = 0 Then RandomGameTab;
Until(Not(meInFight));
End;
End;


Function GetPaintBitmap(Color, sX, sY: Integer; Text: TStringArray; Dist: Integer): Integer;

Var
TPA: TPointArray;
H, Q, B: Integer;
Begin
Result := BitmapFromString(sX, sY, '');
For B := 0 To High(Text) Do
Begin
TPA := LoadTextTPA(Text[b], SmallChars, H);
For Q := 0 To High(TPA) Do
FastSetPixel(Result, TPA[q].x, TPA[q].y + B * Dist, Color);
End;
End;


Procedure ClearSMARTCanvas;

Var
BMP: Integer;
SMARTCanvas, Canvas: TCanvas;
Begin
BMP := BitmapFromString(765, 503, '')
SMARTCanvas := GetBitmapCanvas(BMP);
Canvas := GetBitmapCanvas(BMP);
SMARTCanvas.handle := SmartGetDebugDC;
CopyCanvas(Canvas, SMARTCanvas, 0, 0, 765, 503, -1000, -1000, 1000, 1000);
FreeBitmap(BMP);
End;


Procedure ProgressReportCanvas(X, Y: Integer);

Var
SCanvas, Canvas: TCanvas;
BMP, Sec: Integer;
Text: TStringArray;
Begin
Sec := GetTimeRunning Div 1000 + 1;
ClearSMARTCanvas;
BMP := BitmapFromString(765, 503, '');
SCanvas := GetBitmapCanvas(BMP);
SCanvas.handle := SmartGetDebugDC;
Text := [
'Ran for : ' + TimeRunning,
'Killed : ' + IntToStr(Crabs)+ ' Crabs',
'Gained : ' + IntToStr(Crabs * 200) + ' Primary Exp',
'Gained : ' + IntToStr(Crabs * 200 / 3 )+ ' HP Exp',
'Crabs per hour : ' + IntToStr(Round(3600*Crabs/Sec)),
'Actived Crabs : ' + IntToStr(Runs) + ' Times',
'Special Attacks: ' + IntToStr(Specs)];
Canvas := GetBitmapCanvas(GetPaintBitmap(65280, 765, 503, Text, 25));
CopyCanvas(Canvas, SCanvas, 0, 0, 765, 503, X, Y, X + 765, Y + 503);
FreeBitmap(BMP);
End;


Function DeCrab: Integer;

Var
A, B: Integer;
Begin
A := 20 + Random(20);
B := GetSystemTime;
Repeat
If Random(80) = 0 Then
MMouse(MSX1, MSY1, MIX2, MIY2);
If FindNormRandoms Then
Begin
Writeln('Random');
If Not LoggedIn Then Exit;
End;
If GetSystemTime - SpecTime > (5 + Random(8) * 60000) Then
If Specialize Then Specs := Specs + 1;
Try
If FightCrab Then
Begin
Crabs := Crabs + 1;
Result := Result + 1;
End;
Except End;
If InActive > 2 Then
Begin
If InsultCrabsMothers Then Runs := Runs + 1;
InActive := 0;
End;
Wait(200 + Random(500));
If GetSystemTime - B > 20000 + Random(10000) Then
Begin
B := GetSystemTime;
If Random(25) = 0 Then
RandomRClick
Else
RandomMovement;
End;
Try
ProgressReportCanvas(6, 25);
Except
Writeln('DIB handle fuckup');
End;
Until(Result >= A);
End;


Var
B: Boolean;
I: Integer;

begin
SmartSetup('world137', True, True, False);
SetTargetDC(SmartGetDC);
SetupSRL;
SRLPlayerForm(True, [], [], [], []);
SpecTime := GetSystemTime;
Repeat
LoginPlayer;
SetAngle(True);
Writeln('We have just killed ' + IntToStr(DeCrab) + ' Crabs.');
B := LoggedIn;
Logout;
I := I + 1;
If I > 3 + Random(7) Then
Begin
If UseSleep Then
Wait(60000 + Random(MaxSleep * 60000) + Random(35000))
Else
Wait(60000 + Random(180000));
End Else
Wait(25000 + Random(35000));
NextPlayer(B);
Until(False);
end.


Enjoy ;)


Tell me if you get problems with evil chickens or swarms, and I will make failsafes for them…

Using special attack is not suggested if you aren't using DDS, D Long or D Mace, or other 4 special weapon.

Naike

2008-09-11 15:15:15

You want a competition then bring it on booooy !! ;)

Going to look it over…

Looks good.. A bit short :o

Can you teach me the Canvas client painting thingy? :o

mastaraymond

2008-09-11 15:40:07

Love tha main loop ^_^. Confused me for a while ;d.

Why did you put in paypal stuff xD.

Scaper

2008-09-11 16:18:48

nice ill have to put this to use now :)

Bobarkinator

2008-09-11 16:27:26

From: mastaraymond
Love tha main loop ^_^. Confused me for a while ;d.

Why did you put in paypal stuff xD.


Haha, I agree with you. Kinda weirds you out for a second.

I also agree with the paypal statement.

Haxor

2008-09-11 19:55:48

only problem so far is that, A) right after its ran away, it came back and sat next to a rock crab and let the rock crab attack attack him. after that first crab it runs away again and again after every single rock crab it kills. this happens randomly but sometimes its right in the middle of a fight with a rock crab.

haxor

n3ss3s

2008-09-12 08:19:10

Haha, don't worry about the PayPal, it's just non-direct begging :p

Ashur2Good

2008-09-12 10:03:51

Does it eat food? :o



-Ashur

n3ss3s

2008-09-12 10:18:58

No, I'm 20 def and don't need any…

mastaraymond

2008-09-12 10:33:28

From: n3ss3s
Haha, don't worry about the PayPal, it's just non-direct begging :p

Stop begging and get a job ;)

n3ss3s

2008-09-12 11:01:57

They won't accept people of my age to work…

Markus

2008-09-12 11:04:17

Horeca pl0x
Anyways, lol @ mainloop indeed :D

n3ss3s

2008-09-12 13:12:14

What's wrong with moi loop? :<

Narcle

2008-09-13 01:42:04

InsultCrabsMothers

YES YES!

DaWu

2008-09-26 08:33:21

Insultcrabsmother :D

Gave me a smile, nice looking script, wonder why didnt people wan't reflection when KYAB was around, everyone used to boycott it xd

n3ss3s

2008-09-26 08:49:30

By the way, don't try to use this one, I have one with fixes, including fixed InsultCrabsMother…

Haxor

2008-09-27 01:21:41

could you possibly release it:P, if that would be possible.

haxor

Mr.Klean

2008-09-27 13:38:45

Oh god, I love the name of this script. So much I may have to get a members account just to use it :)



We have to squat on public toliets here, the crabs here jump 3 feet.

Zezi

2008-10-05 07:47:13

how does this thing work? in the main loop you don't call anything? :S!
it logs in and out ? :S wth? xD

n3ss3s

2008-10-12 03:47:11

It logs in and out because you failed to read my post -

By the way, don't try to use this one, I have one with fixes, including fixed InsultCrabsMother…


But apparently I'll just release that version now…

The new version also can solve the box, reflection pls.

Anyhow, at some point of the script you might start getting

    Try
ProgressReportCanvas(6, 25);
Except
Writeln('DIB handle fuckup');
End;

Launched all the time, I have no idea what is it…