-
Notifications
You must be signed in to change notification settings - Fork 3
/
BarbFisher.simba
453 lines (397 loc) · 12.2 KB
/
BarbFisher.simba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
program BarbFlyFisher_V003;
{$I SRL/OSR.simba}
{$I SRL/utils/rsclient.simba}
{$I SRL/utils/rsclient_overrides.simba}
{$I RSWalker/Walker.simba}
{.$I WindowOverlay/WindowOverlay.simba}
{$H-}
{==============================================================================]
| Barbarian FlyFisher ™
|
| Steps to use:
| 1. For longer runs you need to declare user details bellow
| 2. Start the script wherever, just have fishing rod and feathers in your inv
|
| Any issues starting it: Re-target RS, and try again, may help if you log
| in manually before starting it.
|
| Banking might not work very well.
[==============================================================================}
type
TFisherStyle = (FishCookBank, FishCookDrop, FishDrop);
const
LOGIN_NAME = 'yourname';
LOGIN_PASS = 'yourpass';
RS_WORLD = -1; // preferred world, -1 = random world
IS_MEMBER = FALSE; // TRUE or FALSE
STYLE = FishCookBank; // FishCookBank or FishCookDrop, FishDrop
type
TFisher = record
StatsDebugTick: Int64;
Antiban: TAntiban;
end;
var
Bot: TFisher;
RSW: TRSWalker;
{$ifdecl TWindowOverlay}
Overlay: TWindowOverlay;
Debug: TMufasaBitmap;
{$endif}
var
SalmonDTM := DTMFromString('mrAAAAHic42BgYJjKxMDQD8RdQLwQiBcA8Swg7gDi6UD8DKjmAxC/BOLbQPwIiF8A8XsgvgvEp10lgCQjTizHgB/g1gnBMAAAzZcNRg==');
TroutDTM := DTMFromString('mrAAAAHic42BgYJjGxMDQAcQTmCDshUC8BIinA3E/EHMxMjAIAzEHEDMA8R8gxQykBYBYBIibstMgEjiwHAN+gFsnBMMAABHQB5c=');
BurntDTM := DTMFromString('mlwAAAHicY2dgYJjKxMAwDYg7ofRcIF4CxAuBOICRgcEDiGOAOAqIA4HYG4hdgNjSxASomxEHxg1w6UDSBQBl4wcl');
RawTrout := DTMFromString('mggAAAHicY2NgYJjKxMAwDYgXAvESKLsDiMsZGRhygDgDiPOBuA6I64F457q1QF2MWDB2gE0lQjUAQtcIfQ==');
RawSalmon := DTMFromString('mlwAAAHicY2dgYJjGBMELgXgJlN0BxL1ArMfIwKACxApArA7EZkBszggRX5efBNTNiAPjBrh0IOkCAEQMBvk=');
Feathers := DTMFromString('mlwAAAHicY2dgYHBmYmBwAGJvIHYBYlsgtgNiKyB+ApS/B8QPgfgNEH8G4hdA/BGIt69ZAyQZsWI5BtwAuw4IhgIAZtgKcg==');
FishingRod:= DTMFromString('m1gAAAHic42JgYMhiYmCIB+JsIC4E4gogLgPiAiDOAeJ0IE4F4qdAtW+A+A4Q3wDiq0B8H4ifAfE7IP4MxE+AONqZE0gyEsRyDMQBwiZBMAIAAO7FDhY=');
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// OVERRIDES AND METHODS FOR FATIGUE
procedure WaitFatigue(t: Double; Exp: Double=0.2);
begin
System.Wait(Trunc(2*t * (1-Power(System.Max(0.0001, Bot.Antiban.EnergyLevel()/100),Exp))));
end;
procedure Wait(min, max:Double; weight:EWaitDir=wdMean); override;
var t: Double;
begin
t := PerformanceTimer();
inherited(min, max, weight);
WaitFatigue(PerformanceTimer()-t);
end;
procedure WaitEx(mean, dev:Double); override;
var t: Double;
begin
t := PerformanceTimer();
inherited(mean, dev);
WaitFatigue(PerformanceTimer()-t);
end;
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// FISHER
procedure TFisher.DeclarePlayers();
begin
with Players.New()^ do
begin
LoginName := LOGIN_NAME;
Password := LOGIN_PASS;
IsActive := True;
IsMember := IS_MEMBER;
World := RS_WORLD;
end;
Players.SetCurrent(0);
end;
procedure TFisher.DoAntiban();
begin
srl.DismissRandom();
if Self.Antiban.DoAntiban() then
Players.GetCurrent()^.Login(); // if we got logged out, and not logged back in
end;
procedure TFisher.PostAction(AntiBan:Boolean=True);
begin
WaitEx(450,70);
if AntiBan then Self.DoAntiban;
end;
procedure TFisher.ProcessWhileWaiting();
begin
if GetTickCount() - StatsDebugTick > 2000 then
begin
ClearDebug();
ClearDebug();
WriteLn('+---| STATS |----------------------------------------');
WriteLn('|- Script Runtime : ', SRL.MsToTime(GetTimeRunning, Time_Short));
WriteLn('|- Time Since Break : ', SRL.MsToTime(Antiban.TimeSinceBreak(), Time_Short));
//WriteLn('|- Recent Break Len : ', SRL.MsToTime(Antiban.ResidualBreakValue(), Time_Short));
WriteLn('|- Energy Level : ', Round(Antiban.EnergyLevel,2));
WriteLn('+----------------------------------------------------');
Self.StatsDebugTick := GetTickCount();
end;
Self.DoAntiban;
end;
// Find fishingspots by finding the edges of the water, over and over again
// Then do some fancy stuff to remove land->water borders.
// what's left is an accurate TPA of the fishingspot
function TFisher.FindFishingSpot(scanTime: Int32=450): T2DPointArray;
var
i: Int32;
SUM,TPA: TPointArray;
R: TRectangle;
t: TCountDown;
begin
t.Init(scanTime);
while not t.IsFinished do
begin
srl.FindColors(TPA, CTS2(8875103,16,0.2,0.7), Mainscreen.GetBounds);
SUM += TPA.Edges();
end;
SUM.ClearDuplicates();
SUM := ClearTPAFromTPA(Sum, Sum.Edges());
SUM += Sum.Edges();
Result := SUM.Cluster(5);
Result.FilterSize(12, __GT__);
{$ifdecl TWindowOverlay}
Debug.Clear();
for i:=0 to High(Result) do
Debug.DrawTPA(Result[i], Random($FFFFFF));
{$endif}
end;
// Basically we find the fishingrod by checking the two tiles infront of
// our character. It can fail if your character covers most of the rod
function TFisher.IsFishing(): Boolean;
var
rect1,rect2: TRectangle;
TPA1,TPA2: TPointArray;
begin
Rect1 := Minimap.StaticToMsRect([646,84],1);
Rect2 := Minimap.StaticToMsRect([649,84],1);
{$ifdecl TWindowOverlay}
Debug.DrawRect(Rect1, $FFFFFF);
Debug.DrawRect(Rect2, $FFFFFF);
{$endif}
if srl.FindColors(TPA1, CTS2(6694,10), Rect1.Bounds) > 12 then
Result := srl.FindColors(TPA2, CTS2(6694,10), Rect2.Bounds) > 5;
end;
// Finds fishing spots, click one, and waits while we are fishing
//
function TFisher.Fish(): Boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
begin
if (not Inventory.Contains(FishingRod)) or
(not Inventory.Contains(Feathers)) then
TerminateScript('No feathers or fly fishing rod');
ATPA := Self.FindFishingSpot();
ATPA.SortByMiddle(mainscreen.GetMiddle);
for TPA in ATPA do
begin
mouse.Move(TPA.Bounds);
if not MainScreen.IsUpText(['Fishing spot']) then
Continue;
if mouse.Click(ctRed) then
begin
Wait(700,1000);
Minimap.WaitPlayerMoving();
Wait(1400,1700);
Self.FindFishingSpot(); //update drawing.
while Self.IsFishing() do
begin
Self.ProcessWhileWaiting();
Chatbox.HandleLevelUp();
WaitEx(70,10);
end;
Exit(True);
end else
begin
Wait(700,1200);
Minimap.WaitPlayerMoving();
Wait(700,1200);
Exit(False);
end;
end;
end;
// Waits while we are cooking.
// Cooking is determined by checking if the number of raw fish in our inventory
// is reducing. It must reduce by at least 1 within 5.5 seconds.
function TFisher.WaitCooking(): Boolean;
var
c, currCount: Int32;
t: TCountDown;
begin
c := Inventory.Count(RawTrout) + Inventory.Count(RawSalmon);
t.Init(5500);
repeat
if Chatbox.GotLevelUp then
Break;
currCount := Inventory.Count(RawTrout) + Inventory.Count(RawSalmon);
if currCount <> c then
begin
c := currCount;
t.Restart(50);
end;
Self.ProcessWhileWaiting();
Wait(70);
until t.IsFinished() or (c = 0);
Result := True;
end;
// Do the cooking!
// 1. Walks to a point near the eternal fire.
// 2. Searches for the fire and uses a fish on the fire
// If it fails to find the fire it rotates the screen and tries again.
// 3. Cooks it, and waits til we dont cook any more, or till we level up.
// Repeats #2->#3 until there are no more fish in our inventory.
function TFisher.Cook(): Boolean;
var
idx: Int32;
arr: TIntArray;
rect: TRectangle;
ATPA: T2DPointArray;
TPA: TPointArray;
FoundFire: Boolean;
begin
Inventory.Open();
if (not Inventory.Contains(RawTrout)) and (not Inventory.Contains(RawSalmon)) then
Exit;
if Distance(Point(4230,2718), RSW.GetMyPos) > 8 then
RSW.WebWalk(Point(4230,2718), 2);
while ((arr := Inventory.FindItem(RawTrout) + Inventory.FindItem(RawSalmon)) <> []) do
begin
FoundFire := False;
srl.FindColors(TPA, CTS2(12348,15), MainScreen.GetBounds);
ATPA := TPA.Cluster(5);
ATPA.FilterSize(16, __GT__);
ATPA.SortByMiddle(Mainscreen.GetMiddle);
Inventory.Use(arr[0]);
for TPA in ATPA do
begin
rect := TPA.MinAreaRect();
mouse.Move(rect);
Wait(60,100);
if MainScreen.IsUpText(['Fire']) then
mouse.Click(mouse_Left)
else if MainScreen.IsUpText(['options']) then
begin
if not ChooseOption.Select('Fire') then
begin
Wait(60,200);
Continue;
end
end else
continue;
FoundFire := True;
Chatbox.ClickButtonId('How many', 1, 'Cook', 3000);
if Self.WaitCooking() then
Break;
end;
if(not FoundFire) then
Minimap.SetCompassAngle([0,90,180,270][Random(4)]+Random(-15,15));
end;
end;
// Clear the inventory by dropping, or banking fish.
//
procedure TFisher.DoInventory();
var
dtms, slots: TIntArray;
dtm: Int32;
t: TCountDown;
// Deposits all the fish in our inventory, cooked, raw and burnt.
procedure Deposit();
begin
RSW.WebWalk(locEdgevilleBank, 3);
for 0 to 2 do
if BankScreen.Open(blEdgeville) then
Break
else
Wait(800,100);
if not BankScreen.IsOpen() then
TerminateScript('No bank');
dtms := [SalmonDTM, TroutDTM, BurntDTM, RawTrout, RawSalmon];
for dtm in dtms do
begin
slots := Inventory.FindItem(dtm);
if Length(slots) > 0 then
begin
BankScreen.DepositItem(slots[0], True);
t.Init(2000);
while (not t.IsFinished) and Inventory.IsSlotUsed(slots[0],False) do
Wait(70,160);
end;
end;
end;
// drop all the fish in our inventory, cooked, raw and burnt.
procedure Drop();
var
Ptrn: TIntArray;
i: Int32;
begin
dtms := [SalmonDTM, TroutDTM, BurntDTM, RawTrout, RawSalmon];
for dtm in dtms do
slots += Inventory.FindItem(dtm);
for i:=0 to 27 do
if slots.Find(i) <> -1 then
Ptrn += i;
Inventory.DropItems(Inventory.ErrorPattern(ptrn));
end;
begin
if STYLE in [FishCookDrop, FishDrop] then
Drop()
else
Deposit();
end;
// Runs the bot
//
procedure TFisher.Run();
begin
MainScreen.SetAngle(True);
while srl.isLoggedIn() do
begin
if Inventory.IsFull() then
begin
if STYLE <> FishDrop then
begin
self.Cook();
self.PostAction();
end;
self.DoInventory();
self.PostAction();
end;
if not self.Fish() then
begin
if RSW.GetMyPos.DistanceTo([4245, 2716]) > 20 then
RSW.WebWalk(Point(4245, 2716),3)
else
RSW.WebWalk(Point(4223, 2748),3);
Wait(700,1200);
end;
{$ifdecl TWindowOverlay}
Debug.Clear();
{$endif}
Self.ProcessWhileWaiting();
end;
end;
procedure TFisher.SetupAntiban();
begin
Antiban.Init(SKILL_FISHING, 4);
Antiban.AddTask([@Antiban.LoseFocus, ONE_MINUTE*5]);
Antiban.AddTask([@Antiban.HoverPlayers, ONE_MINUTE*8]);
Antiban.AddTask([@Antiban.CheckSkill, ONE_MINUTE*9]);
Antiban.AddTask([@Antiban.CheckStats, ONE_MINUTE*10]);
Antiban.AddTask([@Antiban.OpenRandomTab, ONE_MINUTE*10]);
Antiban.AddTask([@Antiban.VeryShortBreak,ONE_MINUTE*25]);
Antiban.AddTask([@Antiban.DoMiscStuff, ONE_MINUTE*25]);
Antiban.AddTask([@Antiban.RandomCompass, ONE_MINUTE*45]);
Antiban.AddBreak([45 * ONE_MINUTE, 05 * ONE_MINUTE, 0.05]);
Antiban.AddBreak([02 * ONE_HOUR, 10 * ONE_MINUTE, 0.15]);
Antiban.AddBreak([04 * ONE_HOUR, 45 * ONE_MINUTE, 0.85]);
Antiban.AddBreak([17 * ONE_HOUR, 07 * ONE_HOUR, 0.99]);
end;
procedure TFisher.Init();
begin
RSW.Init('world.png');
{$ifdecl TWindowOverlay}
Overlay := TWindowOverlay.Create();
Overlay.PaintInterval(100);
Debug := Overlay.ToMufasaBitmap();
{$endif}
self.DeclarePlayers();
self.SetupAntiban();
Inventory.ShiftDrop := True;
Players.GetCurrent()^.Login();
end;
procedure TFisher.Free();
begin
RSW.Free();
{$ifdecl TWindowOverlay}
Overlay.Free();
Debug.Free();
{$endif}
FreeDTMs([SalmonDTM, TroutDTM, BurntDTM, RawTrout, RawSalmon, Feathers, FishingRod]);
end;
begin
srl.SetupForClient([]);
srl.Options := [soDebugAntiban];
RSClient.SetFocus();
bot.Init();
AddOnTerminate(@bot.Free);
bot.Run();
end.