-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwasp_kraken.simba
604 lines (476 loc) · 15.4 KB
/
wasp_kraken.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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
{$DEFINE SCRIPT_ID := 'a398a083-63fd-4f13-936b-3963354fb4c1'}
{$DEFINE SCRIPT_REVISION := '44'}
{$DEFINE SCRIPT_GUI}
{$I SRL-T/osr.simba}
{$I WaspLib/osr.simba}
{$I WaspLib/optional/handlers/combathandler.simba}
{$I WaspLib/optional/interfaces/mainscreen/fairyring.simba}
{$SCOPEDENUMS ON}
type
EKrakenState = (
WAIT_STATE,
EQUIP_STAFF, USE_FAIRYRING,
OPEN_BANK, DEPOSIT_LOOT, WITHDRAW_FOOD, HANDLE_PIN, CLOSE_INTERFACE,
//Outside
ENTER_COVE, ENTER_CREVICE,
HANDLE_CHAT, HANDLE_WARNING,
//Inside
WALK_BRIDGE,
CHECK_LOOT,
WAKE_KRAKEN, ATTACK_KRAKEN, SELECT_SPELL, CAST_BLOOD,
BOOST, EAT_FOOD, DRINK_PRAYER, ENABLE_QPRAY,
OUT_OF_FOOD,
ALCH_DROP,
EQUIP_GEAR, EQUIP_BRACELET,
END_SCRIPT
);
TKrakenKiller = record(TBaseScript)
State: EKrakenState;
Bridge: TPoint;
SleepyKraken, KrakenTPA: TPointArray;
Kraken: TRSNPCV2;
KrakenFinder: TRSObjectFinder;
Crevice, CaveEntrance: TRSObjectV2;
AnotherPLayer, IsAttacking, CheckedLoot, UseImbuedHeart,
HasBloodSpells: Boolean;
BloodSpell: ERSSpell;
Loot, Gear: TRSItemArray;
ImbuedHeart: TCountDown;
end;
procedure TAntiban.SetupBreaks(); override;
begin
if Self.Breaks <> [] then
Exit;
Self.AddBreak(30 * ONE_MINUTE, 2 * ONE_MINUTE, 0.33, 0.01);
Self.AddBreak(45 * ONE_MINUTE, 4 * ONE_MINUTE, 0.33, 0.15);
Self.OnBreaking := @OnBreakingTask;
end;
function TKrakenKiller.CanCastBloodSpells(): Boolean;
const
BLOOD_SPELLS: array of ERSSpell = [
ERSSpell.BLOOD_BARRAGE, ERSSpell.BLOOD_BLITZ,
ERSSPell.BLOOD_BURST, ERSSpell.BLOOD_RUSH
];
var
i: Int32;
begin
if not Magic.IsSpellBook(ERSSpellBook.ANCIENT) or not Magic.Open() then
Exit;
for i := 0 to 3 do
begin
if Magic.ContainsSpell(BLOOD_SPELLS[i]) then
begin
Self.BloodSpell := BLOOD_SPELLS[i];
Exit(True);
end;
end;
end;
procedure TKrakenKiller.Init(maxActions: UInt32; maxTime: UInt64); override;
var
i: Int32;
qPrayers: ERSPrayerArray;
begin
Antiban.Skills := [ERSSkill.MAGIC, ERSSkill.HITPOINTS, ERSSkill.TOTAL];
Antiban.MinZoom := 0;
Antiban.MaxZoom := 40;
inherited;
Map.SetupChunks([Chunk(Box(35,56,36,56), 0), Chunk(Box(35,156,35,156), 0), Chunk(Box(48,54,50,53), 0)]);
Objects.Setup(Map.Objects(), @Map.Walker);
Self.Crevice := Objects.Get('Crevice');
Self.CaveEntrance := Objects.Get('Cave Entrance');
Self.Kraken.Setup(14, 4, 14, [[5024, 10286]]);
Self.Kraken.SetupUpText('Kraken');
Self.Kraken.Finder.Colors += CTS2(14407349, 13, 0.13, 1.43);
Self.Bridge := [5024, 10304];
FoodHandler.Amount := -1;
Self.KrakenFinder.ClusterDistance := 3;
Self.KrakenFinder.Erode := 2;
Self.KrakenFinder.Grow := 4;
Self.KrakenFinder.Colors += CTS2(14407349, 13, 0.13, 1.43);
Self.KrakenFinder.MinShortSide := 70;
Self.UseImbuedHeart := True;
Self.ImbuedHeart.Setup(7 * ONE_MINUTE);
Options.SetNPCAttackOption(ERSAttackOption.ALWAYS_LEFT_CLICK);
Combat.SetAutoRetaliate(False);
CombatHandler.Setup(True, Self.Kraken, 5000, 4000);
Self.HasBloodSpells := Self.CanCastBloodSpells();
Self.Gear := Equipment.DiscoverAll();
i := Self.Gear.Find('expeditious bracelet');
if i > -1 then Delete(Self.Gear, i, 1);
i := Self.Gear.Find('bracelet of slaughter');
if i > -1 then Delete(Self.Gear, i, 1);
i := Self.Gear.Find('ring of recoil');
if i > -1 then Delete(Self.Gear, i, 1);
for i := 0 to High(LootHandler.Loot) do
begin
if LootHandler.Loot[i].Item = 'Shark' then Continue;
if LootHandler.Loot[i].Noted then
Self.Loot += 'noted ' + LootHandler.Loot[i].Item
else
Self.Loot += LootHandler.Loot[i].Item;
end;
if QuickPrayer.Open() then
begin
qPrayers := QuickPrayer.GetSelectedPrayers();
for i := 0 to High(qPrayers) do
begin
if qPrayers[i] = ERSPrayer.AUGURY then Continue;
if qPrayers[i] = ERSPrayer.MYSTIC_MIGHT then Continue;
if qPrayers[i] = ERSPrayer.MYSTIC_LORE then Continue;
if qPrayers[i] = ERSPrayer.MYSTIC_WILL then Continue;
QuickPrayer.DeselectPrayer(qPrayers[i]);
end;
qPrayers := [ERSPrayer.AUGURY, ERSPrayer.MYSTIC_MIGHT, ERSPrayer.MYSTIC_LORE, ERSPrayer.MYSTIC_WILL];
for i := 0 to High(qPrayers) do
if Prayer.CanActivate(qPrayers[i]) and QuickPrayer.SelectPrayer(qPrayers[i]) then
Break;
QuickPrayer.Close();
end;
end;
function TKrakenKiller.InsideBossRoom(): Boolean;
begin
Result := MainScreen.InMultiCombat();
if not Result then
Self.CheckedLoot := True;
end;
function TKrakenKiller.EnterCove(): Boolean;
begin
if Self.CaveEntrance.WalkSelectOption(['Enter']) then
begin
Minimap.WaitMoving();
Result := WaitUntil(not Minimap.OnGroundLevel(), 300, 5000);
end;
end;
function TKrakenKiller.EnterCrevice(): Boolean;
begin
if Self.Crevice.WalkSelectOption(['Private']) then
begin
Minimap.WaitMoving;
Result := WaitUntil(('Pay' in Chat.GetChatTitle()) or BankPin.IsOpen(), 300, 5000);
end;
end;
function TKrakenKiller.HandlePayment(): Boolean;
begin
Chat.ClickOption('Yes', BioHash);
Result := WaitUntil(Self.InsideBossRoom() or Chat.HasContinue(), 300, 8000);
end;
function TKrakenKiller.FindSleepyKraken(): Boolean;
var
ATPA: T2DPointArray;
begin
ATPA := MainScreen.FindObject(Self.KrakenFinder);
Result := ATPA <> [];
if Result then
Self.SleepyKraken := ATPA[0];
end;
function TKrakenKiller.FindRagingKraken(): Boolean;
var
MMDots: TPointArray;
cuboid: TCuboidEx;
KrakenDot: TPoint;
begin
MMDots := Minimap.GetDots(ERSMinimapDot.NPC);
Result := (Length(MMDots) >= 5) and not Self.FindSleepyKraken();
if not Result then
Exit;
Self.CheckedLoot := False;
MMDots.Sort(MMDots.Mean());
KrakenDot := MMDots[0];
cuboid := Minimap.GetCuboidMS(KrakenDot, [3, 3, 8], [-3, -3]);
Self.KrakenTPA := cuboid.ShapeFill();
end;
function TKrakenKiller.FinishedSlayerTask(): Boolean;
begin
Result := ('Lieve' in Chat.GetChat) or ('Lieve' in Chat.GetMessage(7));
if Result then
TerminateScript('FINISHED SLAYER TASK');
end;
function TKrakenKiller.WakeKraken(): Boolean;
begin
if MainScreen.IsUpText('>') then ChooseOption.Select('Cancel');
if not Inventory.SetSelectedItem('Fishing explosive') then Exit;
Mouse.Move(Self.SleepyKraken);
if MainScreen.IsUpText('Whirl') then
begin
Mouse.Click(MOUSE_LEFT);
if MainScreen.DidRedClick() then
begin
Result := WaitUntil(Self.FindRagingKraken() or Self.FinishedSlayerTask(), 100, 7000);
Self.IsAttacking := Result;
end;
end;
if Result then
WL.Activity.Restart();
end;
function TKrakenKiller.AttackKraken(): Boolean;
begin
Mouse.Move(KrakenTPA.Mean());
if MainScreen.IsUpText('Attack K') then
begin
Mouse.Click(MOUSE_LEFT);
Result := MainScreen.DidRedClick();
Self.IsAttacking := Result;
end;
end;
function TKrakenKiller.CastBlood(): Boolean;
begin
Mouse.Move(KrakenTPA.Mean());
if MainScreen.IsUpText('> K') then
begin
XPBar.EarnedXP();
Mouse.Click(MOUSE_LEFT);
Result := MainScreen.DidRedClick() and XPBar.WaitXP(1200);
if Result then
Self.IsAttacking := False;
end;
end;
function TKrakenKiller.BoostMagic(): Boolean;
var
slot: Int32;
begin
Self.UseImbuedHeart := Inventory.FindItem('Imbued heart', slot) or
Inventory.FindItem('Saturated heart', slot);
Result := Self.UseImbuedHeart;
if not Result then Exit;
Inventory.ClickSlot(slot);
ImbuedHeart.Restart(Random(3000, 35000));
IsAttacking := False
end;
function TKrakenKiller.CheckLoot(): Boolean;
var
rect: TRectangle;
begin
if MainScreen.IsUpText('>') then ChooseOption.Select('Cancel');
while Inventory.IsFull() and Inventory.ContainsConsumable(ERSConsumable.FOOD) do
Inventory.Consume(ERSConsumable.FOOD);
Self.CheckedLoot := True;
Result := True;
rect := Minimap.GetTileMS(Minimap.Center(), [1,1,0]);
while LootHandler.CheckLoot(rect) and Inventory.HasSpace(1) do
Wait(400, 600);
end;
function TKrakenKiller.EquipGear(): Boolean;
var
item: TRSItem;
begin
for item in Self.Gear do
if Inventory.ClickItem(item) then
Exit(True);
end;
function TKrakenKiller.InVarrock(): Boolean;
begin
Map.Position();
Result := Map.RegionIndex = 2;
end;
function TKrakenKiller.TeleportOut(): Boolean;
begin
if Magic.IsSpellBook(ERSSpellBook.STANDARD) then
Result := Magic.CastSpell(ERSSpell.VARROCK_TELEPORT)
else
Result := Inventory.ClickItem('Varrock teleport');
if not Result then
TerminateScript('Out of food and we failed to teleport out!');
Result := WaitUntil(Self.InVarrock(), 300, 5000);
end;
function TKrakenKiller.GetVarrockState(): EKrakenState;
begin
if Inventory.ContainsAny(Self.Loot) or not Inventory.IsFull() then
Exit(EKrakenState.OPEN_BANK);
if Inventory.ContainsAny(['Dramen staff', 'Lunar staff']) then
Exit(EKrakenState.EQUIP_STAFF);
Result := EKrakenState.USE_FAIRYRING;
end;
function TKrakenKiller.GetState(): EKrakenState;
var
health: Int32;
pos: TPoint;
begin
if WL.Activity.IsFinished() and not MainScreen.InCombat() then
Exit(EKrakenState.END_SCRIPT);
if RSInterface.IsOpen() then
begin
if BankPin.IsOpen() then
Exit(EKrakenState.HANDLE_PIN);
if Bank.IsOpen() then
begin
if Inventory.ContainsAny(Self.Loot) then
Exit(EKrakenState.DEPOSIT_LOOT);
if not Inventory.IsFull() then
Exit(EKrakenState.WITHDRAW_FOOD);
end;
Exit(EKrakenState.CLOSE_INTERFACE);
end;
pos := Map.Position();
if not Self.InsideBossRoom() then
begin
if 'Pay' in Chat.GetChatTitle ()then
Exit(EKrakenState.HANDLE_CHAT);
if Chat.HasContinue() then
Exit(EKrakenState.HANDLE_WARNING);
case Map.RegionIndex of
0: Exit(EKrakenState.ENTER_COVE);
1: Exit(EKrakenState.ENTER_CREVICE);
2: Exit(Self.GetVarrockState());
end;
end;
if (Minimap.GetPrayerLevel() <= 30) and Inventory.ContainsItem('Prayer potion(1..4)') then
Exit(EKrakenState.DRINK_PRAYER);
if CombatHandler.NeedBracelet() then
Exit(EKrakenState.EQUIP_BRACELET);
if Self.UseImbuedHeart and ImbuedHeart.IsFinished() then
Exit(EKrakenState.BOOST);
if not Minimap.IsPrayerEnabled() and (Minimap.GetPrayerLevel() > 0) then
Exit(EKrakenState.ENABLE_QPRAY);
if not pos.InRange(Self.Bridge, 5) then
Exit(EKrakenState.WALK_BRIDGE);
if Inventory.ContainsAny(Self.Gear) then
Exit(EKrakenState.EQUIP_GEAR);
if not Inventory.ContainsConsumable(ERSConsumable.FOOD) then
Exit(EKrakenState.OUT_OF_FOOD);
health := Minimap.GetHPLevel();
if Self.FindRagingKraken() then
begin
if health <= 40 then
begin
if Self.HasBloodSpells then
begin
if not MainScreen.IsUpText('Blood') then
begin
if health <= 25 then
Exit(EKrakenState.EAT_FOOD);
Exit(EKrakenState.SELECT_SPELL);
end;
Exit(EKrakenState.CAST_BLOOD);
end;
Exit(EKrakenState.EAT_FOOD);
end;
if Self.IsAttacking then
Exit(EKrakenState.WAIT_STATE);
Exit(EKrakenState.ATTACK_KRAKEN);
end;
if health <= 75 then
Exit(EKrakenState.EAT_FOOD);
if not Self.CheckedLoot then
Exit(EKrakenState.CHECK_LOOT);
if not Self.HasBloodSpells and Inventory.ContainsAny(RSAlchHandler.ItemArray) then
Exit(EKrakenState.ALCH_DROP);
if Self.FindSleepyKraken() then
Exit(EKrakenState.WAKE_KRAKEN);
end;
procedure TKrakenKiller.Run(maxActions: UInt32; maxTime: UInt64);
begin
Self.Init(maxActions, maxTime);
repeat
Self.State := Self.GetState();
Self.SetAction(ToStr(Self.State));
case Self.State of
EKrakenState.EQUIP_STAFF: FairyRing.HandleItem();
EKrakenState.USE_FAIRYRING: FairyRing.WalkTeleport('AKQ');
EKrakenState.OPEN_BANK: Banks.WalkOpen();
EKrakenState.HANDLE_PIN: BankPin.Enter(Login.GetPlayerPin());
EKrakenState.DEPOSIT_LOOT: Bank.DepositItems(Self.Loot, True);
EKrakenState.WITHDRAW_FOOD: Bank.WithdrawConsumable(ERSConsumable.FOOD);
EKrakenState.CLOSE_INTERFACE: RSInterface.Close();
//Outside
EKrakenState.ENTER_COVE: Self.EnterCove();
EKrakenState.ENTER_CREVICE: Self.EnterCrevice();
EKrakenState.HANDLE_CHAT: Self.HandlePayment();
EKrakenState.HANDLE_WARNING: Chat.ClickContinue(BioHash);
//Inside
EKrakenState.WALK_BRIDGE: Map.Walker.WebWalk(Self.Bridge, 5, 0.2);
EKrakenState.WAIT_STATE: WaitUntil(not Self.FindRagingKraken(), 100, 3000);
EKrakenState.CHECK_LOOT: Self.CheckLoot();
EKrakenState.WAKE_KRAKEN: Self.WakeKraken();
EKrakenState.SELECT_SPELL: Magic.CastSpell(Self.BloodSpell);
EKrakenState.CAST_BLOOD: Self.CastBlood();
EKrakenState.ATTACK_KRAKEN: Self.AttackKraken();
EKrakenState.BOOST: Self.BoostMagic();
EKrakenState.EAT_FOOD: Inventory.Consume(ERSConsumable.FOOD);
EKrakenState.DRINK_PRAYER: Inventory.Consume(ERSConsumable.PRAYER);
EKrakenState.ENABLE_QPRAY: Minimap.EnablePrayer();
EKrakenState.OUT_OF_FOOD: Self.TeleportOut();
EKrakenState.ALCH_DROP: RSAlchHandler.CastAlchemy(True, True);
EKrakenState.EQUIP_GEAR: Self.EquipGear();
EKrakenState.EQUIP_BRACELET: CombatHandler.EquipBracelet();
EKrakenState.END_SCRIPT: Break;
end;
Self.DoAntiban(not Self.FindRagingKraken(), False);
until Self.ShouldStop();
end;
var
KrakenKiller: TKrakenKiller;
function TRSInventory.Consume(ConsumableType: ERSConsumable; out Slots: TIntegerArray): Boolean; override;
begin
Result := inherited(ConsumableType);
if Result then
KrakenKiller.IsAttacking := False;
end;
function TConsumableHandler.FindInInventory(): TRSConsumableArray; override;
var
consumable: TRSConsumable;
item: TRSItem;
begin
Self.DebugLn('Setting up consumable of type: ' + ToStr(Self.ConsumableType));
for item in CONSUMABLE_ARRAYS[Self.ConsumableType] do
begin
if item = 'Sanfew serum(1..4)' then
Continue;
if Self.ConsumableArray.Contains(item) then //avoid resetting leftover items.
Continue;
if Inventory.ContainsItem(item) then
begin
Self.DebugLn('Consumable found: ' + ToStr(item));
consumable := Self.Setup(item);
Result += consumable;
end;
end;
end;
{$IFDEF SCRIPT_GUI}
type
TKrakenConfig = record(TScriptForm)
InfoText: TLabel;
end;
procedure TKrakenConfig.Run(); override;
var
tab: TTabSheet;
begin
Self.Setup('Wasp Kraken');
Self.Start.SetOnClick(@Self.StartScript);
Self.AddTab('Script Settings');
tab := Self.Tabs[High(Self.Tabs)];
Self.CreateAccountManager(tab);
with Self.InfoText do
begin
Create(tab);
SetCaption(
'Keep in mind this script doesn''t bank so Sang Staff is highly recommended.'
+ LINEENDING +
'If you have issues staying alive consider using magic and defense boosting prayers.'
+ LINEENDING +
'Overhead prayers have no effect on kraken.'
+ LINEENDING + LINEENDING +
'Also keep in mind this won''t stop when you have your inventory full of loot.'
+ LINEENDING +
'I recommend you check it every 40 mins or so to see if it needs banking.'
+ LINEENDING + LINEENDING +
'FISHING EXPLOSIVES ARE REQUIRED!'
);
SetLeft(TControl.AdjustToDPI(50));
SetTop(TControl.AdjustToDPI(200));
end;
LootHandler.Setup('Kraken', 5000);
Self.CreateLootManager();
Self.CreateAntibanManager();
Self.CreateWaspLibSettings();
Self.CreateAPISettings();
inherited;
end;
var
KrakenConfig: TKrakenConfig;
{$ENDIF}
begin
{$IFDEF SCRIPT_GUI}
KrakenConfig.Run();
{$ENDIF}
KrakenKiller.Run(WLSettings.MaxActions, WLSettings.MaxTime);
end.