-
Notifications
You must be signed in to change notification settings - Fork 9
/
Interfaces.simba
1223 lines (1076 loc) · 28.3 KB
/
Interfaces.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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{$include_once Internal/Reflection.simba}
{$include_once Constants.simba}
{$include_once Chat.simba}
{$include_once Menu.simba}
{$include_once Inventory.simba}
{$include_once Mouse.simba}
{$include_once Timing.simba}
type
//Emotes
TEmote = (
EMOTE_YES = 0,
EMOTE_NO,
EMOTE_BOW,
EMOTE_ANGRY,
EMOTE_THINK,
EMOTE_WAVE,
EMOTE_SHRUG,
EMOTE_CHEER,
EMOTE_BECKON,
EMOTE_LAUGH,
EMOTE_JUMP_FOR_JOY,
EMOTE_YAWN,
EMOTE_DANCE,
EMOTE_JIG,
EMOTE_SPIN,
EMOTE_HEADBANG,
EMOTE_CRY,
EMOTE_BLOW_KISS,
EMOTE_PANIC,
EMOTE_RASPBERRY,
EMOTE_CLAP,
EMOTE_SALUTE,
EMOTE_GOBLIN_BOW,
EMOTE_GOBLIN_SALUTE,
EMOTE_GLASS_BOX,
EMOTE_CLIMB_ROPE,
EMOTE_LEAN,
EMOTE_GLASS_WALL,
EMOTE_IDEA,
EMOTE_STAMP,
EMOTE_FLAP,
EMOTE_SLAP_HEAD,
EMOTE_ZOMBIE_WALK,
EMOTE_ZOMBIE_DANCE,
EMOTE_SCARED,
EMOTE_RABBIT_HOP,
EMOTE_SIT_UP,
EMOTE_PUSH_UP,
EMOTE_STAR_JUMP,
EMOTE_JOG,
EMOTE_ZOMBIE_HAND,
EMOTE_HYPERMOBILE_DRINKER,
EMOTE_SKILL_CAPE,
EMOTE_AIR_GUITAR,
EMOTE_URI_TRANSFORM,
EMOTE_SMOOTH_DANCE,
EMOTE_CRAZY_DANCE,
EMOTE_PREMIER_SHIELD,
EMOTE_EXPLORE);
//Anvil
TAnvil = (
ANVIL_DAGGER = 0,
ANVIL_SWORD,
ANVIL_SCIMITAR,
ANVIL_LONG_SWORD,
ANVIL_TWO_H_SWORD,
ANVIL_AXE,
ANVIL_MACE,
ANVIL_WARHAMMER,
ANVIL_BATTLE_AXE,
ANVIL_CLAWS,
ANVIL_CHAIN_BODY,
ANVIL_PLATE_LEGS,
ANVIL_PLATE_SKIRT,
ANVIL_PLATE_BODY,
ANVIL_NAILS,
ANVIL_MED_HELM,
ANVIL_FULL_HELM,
ANVIL_SQ_SHIELD,
ANVIL_KITE_SHIELD,
ANVIL_EXCLUSIVE1,
ANVIL_DART_TIPS,
ANVIL_ARROW_HEADS,
ANVIL_KNIVES,
ANVIL_EXCLUSIVE2,
ANVIL_JAVELIN_HEADS,
ANVIL_BOLTS,
ANVIL_LIMBS);
//Multi-Skill
TMultiSkill = (
SKILL_OPTION_1 = 0,
SKILL_OPTION_2,
SKILL_OPTION_3,
SKILL_OPTION_4,
SKILL_OPTION_5,
SKILL_OPTION_6,
SKILL_OPTION_7,
SKILL_OPTION_8,
SKILL_OPTION_9);
//Furnace Crafting
TRing = (
RING_GOLD = 7,
RING_SAPPHIRE,
RING_EMERALD,
RING_RUBY,
RING_DIAMOND,
RING_DRAGONSTONE,
RING_ONYX,
RING_SLAYER,
RING_ZENYTE);
TNecklace = (
NECKLACE_GOLD = 21,
NECKLACE_SAPPHIRE,
NECKLACE_EMERALD,
NECKLACE_RUBY,
NECKLACE_DIAMOND,
NECKLACE_DRAGONSTONE,
NECKLACE_ONYX,
NECKLACE_ZENYTE);
TAmulet = (
AMULET_GOLD = 34,
AMULET_SAPPHIRE,
AMULET_EMERALD,
AMULET_RUBY,
AMULET_DIAMOND,
AMULET_DRAGONSTONE,
AMULET_ONYX,
AMULET_ZENYTE);
TBracelet = (
BRACELET_GOLD = 46,
BRACELET_SAPPHIRE = 48,
BRACELET_EMERALD = 49,
BRACELET_RUBY = 50,
BRACELET_DIAMOND = 51,
BRACELET_DRAGONSTONE = 52,
BRACELET_ONYX = 53,
BRACELET_ZENYTE = 54);
TNPCContact = (
NPC_HONEST_JIMMY = R_NPC_CONTACT_HONEST_JIMMY.Child,
NPC_BERT_THE_SANDMAN = R_NPC_CONTACT_BERT_THE_SANDMAN.Child,
NPC_ADVISOR_GHRIM = R_NPC_CONTACT_ADVISOR_GHRIM.Child,
NPC_DARK_MAGE = R_NPC_CONTACT_DARK_MAGE.Child,
NPC_LANTHUS = R_NPC_CONTACT_LANTHUS.Child,
NPC_SPRIA = R_NPC_CONTACT_SPRIA.Child,
NPC_TURAEL = R_NPC_CONTACT_TURAEL.Child,
NPC_MAZCHNA = R_NPC_CONTACT_MAZCHNA.Child,
NPC_VANNAKA = R_NPC_CONTACT_VANNAKA.Child,
NPC_CHAELDAR = R_NPC_CONTACT_CHAELDAR.Child,
NPC_NIEVE = R_NPC_CONTACT_NIEVE.Child,
NPC_DURADEL = R_NPC_CONTACT_DURADEL.Child,
NPC_KRYSTILIA = R_NPC_CONTACT_KRYSTILIA.Child,
NPC_KONAR = R_NPC_CONTACT_KONAR.Child,
NPC_MURPHY = R_NPC_CONTACT_MURPHY.Child,
NPC_CYRISUS = R_NPC_CONTACT_CYRISUS.Child,
NPC_SMOGGY = R_NPC_CONTACT_SMOGGY.Child,
NPC_GINEA = R_NPC_CONTACT_GINEA.Child,
NPC_WATSON = R_NPC_CONTACT_WATSON.Child,
NPC_BARBARIAN_GUARD = R_NPC_CONTACT_BARBARIAN_GUARD.Child,
NPC_AMY = R_NPC_CONTACT_AMY.Child
);
const
//VARBITS
VARBIT_BLAST_FURNACE_BAR_DISPENSER = 936;
VARBIT_MOTHERLOAD_SACK_NUMBER = 5558;
VARBIT_MOTHERLOAD_SACK_UPGRADED = 5556;
VARBIT_TITHE_FARM_POINTS = 4893;
VARBIT_TITHE_FARM_SACK_AMOUNT = 4900;
VARBIT_TITHE_FARM_SACK_ICON = 5370;
{*
R_WidgetIsHidden
~~~~~~~~~~~~~~~~
Returns true if a widget is hidden.
Example:
if R_WidgetIsHidden(R_PrayerIDs[0]) then
...
*}
Function R_WidgetIsHidden(Constant: RWidget): Boolean;
var
Widget: RSWidget;
begin
Result := True;
Widget := RSWidget.Get(Constant.Group, Constant.Child);
if Widget.ref <> nil then
begin
Result := Widget.IsHidden;
Widget.Free;
end;
end;
Function R_WaitUntilVisible(Constant: RWidget; WaitTime: Int32 = 1000): Boolean;
begin
Result := WaitUntil(not R_WidgetIsHidden(Constant), RandomRange(100, 324), WaitTime);
end;
{*
EMOTES
~~~~~~
Functions for using emotes.
*}
{*
R_Emotes
~~~~~~~~
Returns true if a widget is valid.
Example:
if R_Emotes then
...
*}
Function R_Emotes: Boolean;
begin
Result := RSWidget.IsValid(R_EMOTE_CONTAINER.Group, R_EMOTE_CONTAINER.Child);
end;
{*
R_WaitEmotes
~~~~~~~~~~~~
Returns true if a widget is valid within the time specified.
Example:
if R_WaitEmotes(300) then
...
*}
Function R_WaitEmotes(timeout: UInt32): Boolean;
begin
Result := WaitUntil(R_Emotes, 50, timeout);
end;
{*
R_EmoteToBox
~~~~~~~~~~~~
Utility function that converts a given Emote in the Emotes Gametab
to mainscreen coordinates.
Example:
R_EmoteToBox(EMOTE_YES);
*}
Function R_EmoteToBox(Emote: TEmote): TBox;
var
Widget: RSWidget;
begin
Widget := RSWidget.Get(R_EMOTE_CONTAINER_CHILD.Group, R_EMOTE_CONTAINER_CHILD.Child, Ord(Emote));
Result := Widget.Bounds;
Widget.Free;
end;
{*
R_ScrollToEmote
~~~~~~~~~~~~~~~
Scrolls to the proper emote in the emote tab.
Example:
R_ScrollToEmote(EMOTE_SHRUG, RSScroll.SCROLLBAR);
*}
Function R_ScrollToEmote(Emote: TEmote; ScrollType: RSScroll = RSScroll.SCROLLWHEEL): Boolean;
var
ScrollBar, ScrollArrow, ListContainer: RSWidget;
ListContainerBounds: TBox;
T: Timer;
Direction: Boolean;
P: TPoint;
begin
ListContainer := RSWidget.Get(R_EMOTE_CONTAINER.Group, R_EMOTE_CONTAINER.Child);
if ListContainer.ref = nil then
Exit(False);
ListContainerBounds := ListContainer.Bounds;
ListContainer.Free;
if ListContainerBounds.Contains(R_EmoteToBox(Emote)) then
Exit(True);
Direction := ListContainerBounds.Middle.Y > R_EmoteToBox(Emote).Middle.Y;
//Scroll the interface using the mouse-wheel
if ScrollType = RSScroll.SCROLLWHEEL then
begin
Mouse.Move(ListContainerBounds);
T.Start;
while not ListContainerBounds.Contains(R_EmoteToBox(Emote).Middle) do
begin
if T.ElapsedTime > 5000 then
Exit(False);
Mouse.Scroll(1, Direction);
end;
Exit(ListContainerBounds.Contains(R_EmoteToBox(Emote).Middle));
end;
//Scroll the interface using the scroll-bar
if ScrollType = RSScroll.SCROLLBAR then
begin
ScrollBar := RSWidget.Get(R_EMOTE_SCROLL_BAR.Group, R_EMOTE_SCROLL_BAR.Child, R_EMOTE_SCROLL_BAR.Index);
if ScrollBar.ref = nil then
Exit(False);
Mouse.Move(ScrollBar.Bounds);
Mouse.Hold(MOUSE_LEFT);
ScrollBar.Free;
T.Start;
while not ListContainerBounds.Contains(R_EmoteToBox(Emote).Middle) do
begin
if T.ElapsedTime > 5000 then
begin
Mouse.Release(MOUSE_LEFT);
Exit(False);
end;
P := Mouse.Position;
if Direction then
Mouse.Move(P.X + RandomRange(-1, 1), P.Y - RandomRange(3, 7))
else
Mouse.Move(P.X + RandomRange(-1, 1), P.Y + RandomRange(3, 7));
end;
Mouse.Release(MOUSE_LEFT);
Exit(ListContainerBounds.Contains(R_EmoteToBox(Emote).Middle));
end;
//Scroll the interface using the arrows
if ScrollType = RSScroll.SCROLLARROWS then
begin
if Direction then
ScrollArrow := RSWidget.Get(R_EMOTE_SCROLL_ARROW_UP.Group, R_EMOTE_SCROLL_ARROW_UP.Child, R_EMOTE_SCROLL_ARROW_UP.Index)
else
ScrollArrow := RSWidget.Get(R_EMOTE_SCROLL_ARROW_DOWN.Group, R_EMOTE_SCROLL_ARROW_DOWN.Child, R_EMOTE_SCROLL_ARROW_DOWN.Index);
if ScrollArrow.ref = nil then
Exit(False);
Mouse.Move(ScrollArrow.Bounds);
Mouse.Hold(MOUSE_LEFT);
ScrollArrow.Free;
T.Start;
while not ListContainerBounds.Contains(R_EmoteToBox(Emote).Middle) do
begin
if T.ElapsedTime > 20000 then
begin
Mouse.Release(MOUSE_LEFT);
Exit(False);
end;
end;
Mouse.Release(MOUSE_LEFT);
Exit(ListContainerBounds.Contains(R_EmoteToBox(Emote).Middle));
end;
end;
{*
R_DoEmote
~~~~~~~~~
Returns true if the emote is clicked.
Example:
if R_DoEmote(EMOTE_YES) then
...
*}
Function R_DoEmote(Emote: TEmote): Boolean;
var
Widget: RSWidget;
begin
R_OpenGametab(GAMETAB_EMOTES);
Writeln(R_ScrollToEmote(Emote, RSScroll.SCROLLWHEEL));
Widget := RSWidget.Get(R_EMOTE_CONTAINER_CHILD.Group, R_EMOTE_CONTAINER_CHILD.Child, Ord(Emote));
if Widget.ref <> nil then
begin
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
Result := True;
Widget.Free;
end;
end;
{*
ANVIL
~~~~~
Functions for using an anvil.
*}
Function R_AnvilIDs: Array of RWidget;
begin
Result := [
R_ANVIL_SMITH_DAGGER,
R_ANVIL_SMITH_SWORD,
R_ANVIL_SMITH_SCIMITAR,
R_ANVIL_SMITH_LONG_SWORD,
R_ANVIL_SMITH_TWO_H_SWORD,
R_ANVIL_SMITH_AXE,
R_ANVIL_SMITH_MACE,
R_ANVIL_SMITH_WARHAMMER,
R_ANVIL_SMITH_BATTLE_AXE,
R_ANVIL_SMITH_CLAWS,
R_ANVIL_SMITH_CHAIN_BODY,
R_ANVIL_SMITH_PLATE_LEGS,
R_ANVIL_SMITH_PLATE_SKIRT,
R_ANVIL_SMITH_PLATE_BODY,
R_ANVIL_SMITH_NAILS,
R_ANVIL_SMITH_MED_HELM,
R_ANVIL_SMITH_FULL_HELM,
R_ANVIL_SMITH_SQ_SHIELD,
R_ANVIL_SMITH_KITE_SHIELD,
R_ANVIL_SMITH_EXCLUSIVE1,
R_ANVIL_SMITH_DART_TIPS,
R_ANVIL_SMITH_ARROW_HEADS,
R_ANVIL_SMITH_KNIVES,
R_ANVIL_SMITH_EXCLUSIVE2,
R_ANVIL_SMITH_JAVELIN_HEADS,
R_ANVIL_SMITH_BOLTS,
R_ANVIL_SMITH_LIMBS
];
end;
{*
R_AnvilScreen
~~~~~~~~~~~~~
Returns true if the anvil screen is valid.
Example:
if R_AnvilScreen then
...
*}
Function R_AnvilScreen: Boolean;
begin
Result := RSWidget.IsValid(R_ANVIL_CONTAINER.Group, R_ANVIL_CONTAINER.Child);
end;
{*
R_WaitAnvilScreen
~~~~~~~~~~~~~~~~~
Returns true if the anvil screen is valid within the time specified.
Example:
if R_WaitAnvilScreen(200) then
...
*}
Function R_WaitAnvilScreen(timeout: UInt32): Boolean;
begin
Result := WaitUntil(R_AnvilScreen, 50, timeout);
end;
{*
R_SmithAnvil
~~~~~~~~~~~~
Returns true if the specified item was smithed.
Example:
if R_SmithAnvil(ANVIL_DAGGER) then
...
*}
Function R_SmithAnvil(AnvilObject: TAnvil): Boolean;
var
ID: RWidget;
Widget: RSWidget;
begin
ID := R_AnvilIDs[Ord(AnvilObject)];
if (not R_AnvilScreen) or (R_WidgetIsHidden(ID)) then
Exit(False);
Widget := RSWidget.Get(ID.Group, ID.Child);
if Widget.ref <> nil then
begin
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
Result := True;
Widget.Free;
end;
end;
{*
R_AnvilSetAmount
~~~~~~~~~~~~~~~~
Chooses the amount of items to smith using the anvil.
Amount = 0: All
Example:
if R_AnvilSetAmount(14) then
...
*}
Function R_AnvilSetAmount(Amount: Integer): Boolean;
var
Widget: RWidget;
AnvilWidget, InputText: RSWidget;
T, Retries: Integer;
begin
if not R_AnvilScreen then
Exit(False);
if ((Amount = 0) or (Amount = 1) or (Amount = 5) or (Amount = 10)) then
begin
Case Amount of
0: Widget := R_ANVIL_AMOUNT_MAKE_ALL;
1: Widget := R_ANVIL_AMOUNT_MAKE_1;
5: Widget := R_ANVIL_AMOUNT_MAKE_5;
10: Widget := R_ANVIL_AMOUNT_MAKE_10;
end;
AnvilWidget := RSWidget.Get(Widget.Group, Widget.Child);
if AnvilWidget.ref = nil then
Exit(False);
if (RSWidget.Get(Widget.Group, Widget.Child, 0).TextureID = R_BUTTON_CENTER_UNSELECTED_ANVIL) then
Mouse.Click(AnvilWidget.Bounds, MOUSE_LEFT);
Result := RSWidget.Get(Widget.Group, Widget.Child, 0).TextureID <> R_BUTTON_CENTER_UNSELECTED_ANVIL;
AnvilWidget.Free;
end else if (IntToStr(Amount) in RSWidget.Get(R_ANVIL_AMOUNT_MAKE_CUSTOM_TEXT.Group, R_ANVIL_AMOUNT_MAKE_CUSTOM_TEXT.Child, R_ANVIL_AMOUNT_MAKE_CUSTOM_TEXT.Index).Text) then
begin
AnvilWidget := RSWidget.Get(R_ANVIL_AMOUNT_MAKE_CUSTOM.Group, R_ANVIL_AMOUNT_MAKE_CUSTOM.Child, R_ANVIL_AMOUNT_MAKE_CUSTOM.Index);
if AnvilWidget.ref = nil then
Exit(False);
if (RSWidget.Get(Widget.Group, Widget.Child, 0).TextureID = R_BUTTON_CENTER_UNSELECTED_ANVIL) then
Mouse.Click(AnvilWidget.Bounds, MOUSE_LEFT);
Result := RSWidget.Get(Widget.Group, Widget.Child, 0).TextureID = R_BUTTON_CENTER_UNSELECTED_ANVIL;
AnvilWidget.Free;
end else
begin
AnvilWidget := RSWidget.Get(R_ANVIL_AMOUNT_MAKE_X.Group, R_ANVIL_AMOUNT_MAKE_X.Child);
if AnvilWidget.ref = nil then
Exit(False);
Mouse.Click(AnvilWidget.Bounds, MOUSE_LEFT);
WaitUntil(R_ChatInput, 50, 2000);
if (RSWidget.Get(R_CHATBOX_INPUT_TITLE.Group, R_CHATBOX_INPUT_TITLE.Child).Text.Startswith("Enter amount:")) then
begin
InputText := RSWidget.Get(R_CHATBOX_INPUT_FULL.Group, R_CHATBOX_INPUT_FULL.Child);
if InputText.ref = nil then
Exit(False);
T := GetTickCount;
while (Retries < 3) and (GetTickCount - T < 5000) do
begin
if InputText.Text <> '*' then
begin
Keyboard.KeyDown(VK_BACK);
while InputText.Text <> '*' do
begin
Wait(50 + RandomRange(50, 100));
end;
Keyboard.KeyUp(VK_BACK);
end;
Keyboard.Send(IntToStr(Amount));
Result := InputText.Text = IntToStr(Amount) + '*';
if Result then
begin
Keyboard.PressKey(VK_ENTER);
InputText.Free;
AnvilWidget.Free;
Exit(True);
end;
Inc(Retries);
end;
end;
AnvilWidget.Free;
end;
end;
{*
MULTI-SKILL
~~~~~~~~~~~
Functions for interacting with skills that have options that appear in
the chat box. (Crafting, Fletching, Herblore, Cooking, Etc.)
*}
Function R_OptionIDs: Array of RWidget;
begin
Result := [
R_MULTI_OPTION_1,
R_MULTI_OPTION_2,
R_MULTI_OPTION_3,
R_MULTI_OPTION_4,
R_MULTI_OPTION_5,
R_MULTI_OPTION_6,
R_MULTI_OPTION_7,
R_MULTI_OPTION_8,
R_MULTI_OPTION_9
];
end;
Function R_OptionKeyIDs: Array of RWidget;
begin
Result := [
R_MULTI_OPTION_1_KEY,
R_MULTI_OPTION_2_KEY,
R_MULTI_OPTION_3_KEY,
R_MULTI_OPTION_4_KEY,
R_MULTI_OPTION_5_KEY,
R_MULTI_OPTION_6_KEY,
R_MULTI_OPTION_7_KEY,
R_MULTI_OPTION_8_KEY,
R_MULTI_OPTION_9_KEY
];
end;
{*
R_SkillMenu
~~~~~~~~~~~
Returns true if the multi-skill menu is open.
Example:
if R_SkillMenu then
...
*}
Function R_SkillMenu: Boolean;
begin
Result := RSWidget.IsValid(R_MULTI_CONTAINER.Group, R_MULTI_CONTAINER.Child);
end;
{*
R_ChooseSkillOption
~~~~~~~~~~~~~~~~~~~
Selects the desired skill option.
Example:
R_ChooseSkillOption(SKILL_OPTION_1);
*}
Function R_ChooseSkillOption(Option: TMultiSkill): Boolean;
var
Widget, WidgetKey: RSWidget;
Widgets: Array of RSWidget;
OptionButton, OptionKey: RWidget;
begin
OptionButton := R_OptionIDs[Ord(Option)];
OptionKey := R_OptionKeyIDs[Ord(Option)];
if (not R_SkillMenu) or (R_WidgetIsHidden(OptionButton)) then
Exit(False);
WidgetKey := RSWidget.Get(OptionKey.Group, OptionKey.Child, -1);
if WidgetKey.ref <> nil then
begin
Widgets += WidgetKey;
if (WidgetKey.Text = '') or (Lowercase(WidgetKey.Text) = 'space') then
begin
Keyboard.PressKey(VK_SPACE);
RSTypeArray(Widgets).Free;
Exit(True);
end else
begin
Widget := RSWidget.Get(OptionButton.Group, OptionButton.Child);
if Widget.ref <> nil then
begin
Widgets += Widget;
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
Result := True;
RSTypeArray(Widgets).Free;
end;
end;
end;
end;
{*
R_ChooseSkillOption
~~~~~~~~~~~~~~~~~~~
Selects the desired skill option.
Example:
R_ChooseSkillOption(['Oak Longbow'], False);
*}
Function R_ChooseSkillOption(Options: Array of String; CaseSensitive: Boolean = True): Boolean; overload;
var
Widget: RSWidget;
Widgets: Array of RSWidget;
I, J: Integer;
Name: String;
begin
if (not R_SkillMenu) then
Exit(False);
for I:=0 to High(R_OptionKeyIDs) do
begin
Widget := RSWidget.Get(R_OptionIDs[I].Group, R_OptionIDs[I].Child, R_OptionIDs[I].Index);
if Widget.ref <> nil then
begin
Widgets += Widget;
For J:=0 to High(Options) do
begin
Name := Widget.Name;
if (CaseSensitive and (Pos(Options[J], Name) > 0)) or (not caseSensitive and (Pos(Lowercase(Options[J]), Lowercase(Name)) > 0)) then
begin
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
RSTypeArray(Widgets).Free;
Exit(True);
end;
end;
end;
end;
RSTypeArray(Widgets).Free;
end;
{*
CRAFTING JEWELRY
~~~~~~~~~~~~~~~~
Functions for crafting jewelry at the furnace.
*}
{*
R_JewelryScreen
~~~~~~~~~~~~~~~
Returns true if the jewelry screen is valid.
Example:
if R_JewelryScreen then
...
*}
Function R_JewelryScreen: Boolean;
begin
Result := RSWidget.IsValid(R_CRAFTING_CONTAINER.Group, R_CRAFTING_CONTAINER.Child);
end;
{*
R_WaitJewelryScreen
~~~~~~~~~~~~~~~~~~~
Returns true if the Jewelry screen is valid within the time specified.
Example:
if R_WaitJewelryScreen(200) then
...
*}
Function R_WaitJewelryScreen(timeout: UInt32): Boolean;
begin
Result := WaitUntil(R_JewelryScreen, 50, timeout);
end;
{*
R_JewelrySetAmount
~~~~~~~~~~~~~~~~~~
Chooses the amount of jewelry items to craft using the furnace.
Amount = 0: All
Example:
if R_JewelrySetAmount(14) then
...
*}
Function R_JewelrySetAmount(Amount: Integer): Boolean;
var
JewelryWidget, InputText: RSWidget;
T, Retries: Integer;
begin
if (not R_JewelryScreen) or (R_WidgetIsHidden(R_CRAFTING_AMOUNT_CONTAINER)) then
Exit(False);
if ((Amount = 0) or (Amount = 1) or (Amount = 5) or (Amount = 10)) then
begin
Case Amount of
0: JewelryWidget := RSWidget.Get(R_CRAFTING_MAKE_ALL.Group, R_CRAFTING_MAKE_ALL.Child);
1: JewelryWidget := RSWidget.Get(R_CRAFTING_MAKE_1.Group, R_CRAFTING_MAKE_1.Child);
5: JewelryWidget := RSWidget.Get(R_CRAFTING_MAKE_5.Group, R_CRAFTING_MAKE_5.Child);
10: JewelryWidget := RSWidget.Get(R_CRAFTING_MAKE_10.Group, R_CRAFTING_MAKE_10.Child);
end;
if JewelryWidget.ref = nil then
Exit(False);
Mouse.Click(JewelryWidget.Bounds, MOUSE_LEFT);
Result := True;
JewelryWidget.Free;
end else if (IntToStr(Amount) in RSWidget.Get(R_CRAFTING_MAKE_CUSTOM_TEXT.Group, R_CRAFTING_MAKE_CUSTOM_TEXT.Child, R_CRAFTING_MAKE_CUSTOM_TEXT.Index).Text) then
begin
JewelryWidget := RSWidget.Get(R_CRAFTING_MAKE_CUSTOM.Group, R_CRAFTING_MAKE_CUSTOM.Child, R_CRAFTING_MAKE_CUSTOM.Index);
if JewelryWidget.ref = nil then
Exit(False);
Mouse.Click(JewelryWidget.Bounds, MOUSE_LEFT);
Result := True;
JewelryWidget.Free;
end else
begin
JewelryWidget := RSWidget.Get(R_CRAFTING_MAKE_X.Group, R_CRAFTING_MAKE_X.Child);
if JewelryWidget.ref = nil then
Exit(False);
Mouse.Click(JewelryWidget.Bounds, MOUSE_LEFT);
Wait(260, RandomRange(560, 730));
if (RSWidget.Get(R_CHATBOX_INPUT_TITLE.Group, R_CHATBOX_INPUT_TITLE.Child).Text.Startswith("Enter amount:")) then
begin
InputText := RSWidget.Get(R_CHATBOX_INPUT_FULL.Group, R_CHATBOX_INPUT_FULL.Child);
if InputText.ref = nil then
Exit(False);
T := GetTickCount;
while (Retries < 3) and (GetTickCount - T < 5000) do
begin
if InputText.Text <> '*' then
begin
Keyboard.KeyDown(VK_BACK);
while InputText.Text <> '*' do
begin
Wait(50 + RandomRange(50, 100));
end;
Keyboard.KeyUp(VK_BACK);
end;
Keyboard.Send(IntToStr(Amount));
Result := InputText.Text = IntToStr(Amount) + '*';
if Result then
begin
Keyboard.PressKey(VK_ENTER);
InputText.Free;
JewelryWidget.Free;
Exit(True);
end;
Inc(Retries);
end;
end;
JewelryWidget.Free;
end;
end;
{*
R_CraftJewelry
~~~~~~~~~~~~~~
Returns true if the specified item was crafted.
Acceptable Inputs:
RING_GOLD
RING_SAPPHIRE
RING_EMERALD
RING_RUBY
RING_DIAMOND
RING_DRAGONSTONE
RING_ONYX
RING_SLAYER
RING_ZENYTE
Example:
if R_CraftJewelry(RING_RUBY) then
...
*}
Function R_CraftJewelry(Jewelry: TRing): Boolean;
var
Widget: RSWidget;
begin
if (not R_JewelryScreen) then
Exit(False);
Widget := RSWidget.Get(R_INTERFACE_CRAFTING_FURNACE, Ord(Jewelry));
if Widget.ref <> nil then
begin
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
Result := True;
Widget.Free;
end;
end;
{*
R_CraftJewelry
~~~~~~~~~~~~~~
Returns true if the specified item was crafted.
Acceptable Inputs:
NECKLACE_GOLD
NECKLACE_SAPPHIRE
NECKLACE_EMERALD
NECKLACE_RUBY
NECKLACE_DIAMOND
NECKLACE_DRAGONSTONE
NECKLACE_ONYX
NECKLACE_ZENYTE
Example:
if R_CraftJewelry(NECKLACE_EMERALD) then
...
*}
Function R_CraftJewelry(Jewelry: TNecklace): Boolean; overload;
var
Widget: RSWidget;
begin
if (not R_JewelryScreen) then
Exit(False);
Widget := RSWidget.Get(R_INTERFACE_CRAFTING_FURNACE, Ord(Jewelry));
if Widget.ref <> nil then
begin
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
Result := True;
Widget.Free;
end;
end;
{*
R_CraftJewelry
~~~~~~~~~~~~~~
Returns true if the specified item was crafted.
Acceptable Inputs:
AMULET_GOLD
AMULET_SAPPHIRE
AMULET_EMERALD
AMULET_RUBY
AMULET_DIAMOND
AMULET_DRAGONSTONE
AMULET_ONYX
AMULET_ZENYTE
Example:
if R_CraftJewelry(AMULET_DIAMOND) then
...
*}
Function R_CraftJewelry(Jewelry: TAmulet): Boolean; overload;
var
Widget: RSWidget;
begin
if (not R_JewelryScreen) then
Exit(False);
Widget := RSWidget.Get(R_INTERFACE_CRAFTING_FURNACE, Ord(Jewelry));
if Widget.ref <> nil then
begin
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
Result := True;
Widget.Free;
end;
end;
{*
R_CraftJewelry
~~~~~~~~~~~~~~
Returns true if the specified item was crafted.
Acceptable Inputs:
BRACELET_GOLD
BRACELET_SAPPHIRE
BRACELET_EMERALD
BRACELET_RUBY
BRACELET_DIAMOND
BRACELET_DRAGONSTONE
BRACELET_ONYX
BRACELET_ZENYTE
Example:
if R_CraftJewelry(BRACELET_DRAGONSTONE) then
...
*}
Function R_CraftJewelry(Jewelry: TBracelet): Boolean; overload;
var
Widget: RSWidget;
begin
if (not R_JewelryScreen) then
Exit(False);
Widget := RSWidget.Get(R_INTERFACE_CRAFTING_FURNACE, Ord(Jewelry));
if Widget.ref <> nil then
begin
Mouse.Click(Widget.Bounds, MOUSE_LEFT);
Result := True;
Widget.Free;
end;
end;
{*
NPC CONTACT
~~~~~~~~~~~
Functions for crafting jewelry at the furnace.
*}
{*
R_NPCContact
~~~~~~~~~~~~
Returns true if NPC Contact interface is open.
Example:
if R_NPCContact then
...
*}
Function R_NPCContact(): Boolean;
begin
Result := RSWidget.IsValid(R_NPC_CONTACT_CONTAINER.Group, R_NPC_CONTACT_CONTAINER.Child);
end;
{*
R_CloseNPCContact
~~~~~~~~~~~~~~~~~
Closes the NPC Contact interface.
Example:
R_CloseNPCContact;
*}