-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathwasp_tab_maker.simba
More file actions
449 lines (359 loc) · 11.4 KB
/
wasp_tab_maker.simba
File metadata and controls
449 lines (359 loc) · 11.4 KB
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
{$DEFINE SCRIPT_ID := 'b15f8a8b-1a7e-457c-9e69-87dc70e90480'}
{$DEFINE SCRIPT_REVISION := '20'}
{$DEFINE SCRIPT_GUI}
{$I SRL-T/osr.simba}
{$I WaspLib/osr.simba}
{$I WaspLib/optional/interfaces/mainscreen/lectern.simba}
{$I WaspLib/optional/handlers/house/house.simba}
type
ERSNPC = (PHIALS, SERVANT);
var
CurrentNPC: ERSNPC = ERSNPC.PHIALS;
CurrentLectern: ERSLecternType = ERSLecternType.STANDARD;
CurrentTablet: TRSItem = 'Teleport to house';
type
ETabMakerState = (
LEVEL_UP,
WAIT_SERVANT, WAIT_TABS, FINISHED_TABS,
ENTER_HOUSE, EXIT_HOUSE, CLOSE_INTERFACE,
OPEN_LECTERN, HANDLE_TAB_UI,
TALK_TO_PHIALS, HANDLE_PHIALS_CHAT,
CALL_SERVANT, TALK_SERVANT, HANDLE_SERVANT,
END_SCRIPT
);
TTabMaker = record(TBaseWalkerScript)
State: ETabMakerState;
Phials, ServantNPC: TRSNPCV2;
IsTabbing, UsePhials, WaitingServant: Boolean;
LecternObj: EHouseObject;
SpellTab, SoftClay, NotedSoftClay: TRSItem;
NotesSlot, SoftClayCount: Int32;
end;
procedure TTabMaker.SetupNPC();
begin
case CurrentNPC of
ERSNPC.PHIALS:
begin
Self.Phials := TRSNPCV2.Setup(10, 1, 6, [[7704, 37582]]);
Self.Phials.SetupUpText(['Phials']);
Self.Phials.Finder.Colors += CTS2(4803153, 19, 0.12, 0.19);
Self.Phials.Finder.Colors += CTS2(5538225, 19, 0.02, 0.80);
Self.Phials.Walker := @Map.Walker;
Self.UsePhials := True;
end;
ERSNPC.SERVANT:
begin
Self.ServantNPC.SetupUpText(['Talk-to']);
Self.ServantNPC.Filter.Finder := False;
Self.ServantNPC.Filter.Walker := False;
Self.ServantNPC.Filter.Minimap := True;
end;
end;
end;
procedure TTabMaker.SetupItems();
begin
Self.SoftClay := 'Soft clay';
Self.NotedSoftClay := 'Noted soft clay';
Self.SpellTab := CurrentTablet;
end;
procedure TTabMaker.Init(maxActions: UInt32; maxTime: UInt64); override;
begin
Antiban.Skills := [ERSSkill.MAGIC, ERSSkill.TOTAL];
Antiban.MinZoom := 0;
Antiban.MaxZoom := 20;
inherited;
for Self.LecternObj in STUDY_LECTERNS do
if House.Objects[Self.LecternObj].Coordinates <> [] then
Break;
if Self.LecternObj > High(EHouseObject) then
TerminateScript('Your house doesn''t seem to have a lectern. Please configure your house layout in the house builder tab!');
if House.Objects[EHouseObject.EXIT].Coordinates = [] then
TerminateScript('Your house doesn''t seem to have a exit portal added. Please configure your house layout in the house builder tab!');
Map.SetupChunk(Chunk([45,51,47,49], 0));
Self.SetupNPC();
Self.SetupItems();
Self.ActionProfit := ItemData.GetAverage(Self.SpellTab) - ItemData.GetAverage(Self.SoftClay);
end;
function TTabMaker.CallServant(): Boolean;
begin
if ServantNPC.Click then
begin
Minimap.WaitMoving;
Result := WaitUntil(Chat.GetChatTitle = 'Repeat last task?',
SRL.TruncatedGauss(50, 1500), 5000);
end
else
Result := Options.CallServant();
end;
function TTabMaker.PhialsGetSoftClay(): Boolean;
begin
if not Self.Phials.IsVisible() and not Map.InRange(Self.Phials.Coordinates, 8) then
Map.Walker.WebWalk(Self.Phials.Coordinates, 15, 0.2);
if Inventory.SetSelectedSlot(Self.NotesSlot) and
Self.Phials.SelectOption(['Use', '>']) then
begin
Minimap.WaitFlag();
Result := WaitUntil(Chat.GetChatTitle() = 'Select an option', 100, 15000);
end;
end;
function TTabMaker.FinishPhialsChat(): Boolean;
var
count, newCount: Int32;
begin
count := Inventory.Count();
if Chat.ClickOption('All') then
Result := WaitUntil(count <> (newCount := Inventory.Count()), 300, 3000);
if Result then
Self.SoftClayCount := newCount - count;
end;
function TTabMaker.TalkServant(): Boolean;
begin
if ServantNPC.Click then
begin
Minimap.WaitMoving;
Result := WaitUntil(Inventory.IsFull, 100, 5000);
end;
WaitingServant := not Result;
end;
function TTabMaker.HandleServant(): Boolean;
begin
Result := Chat.ClickOption('Fetch', BioHash);
if Result then
begin
WaitingServant := True;
WaitUntil(Chat.GetChatTitle() <> 'Repeat last task?', 200, 3000)
end;
end;
function TTabMaker.OpenLectern(): Boolean;
begin
if House.Objects[Self.LecternObj].WalkClick() then
begin
Minimap.WaitMoving();
Result := Lectern.IsOpen(8000);
end;
end;
function TTabMaker.HandleLectern(): Boolean;
begin
Result := Lectern.MakeTablet(CurrentTablet) and XPBar.WaitXP(5000);
Self.IsTabbing := Result;
end;
function TTabMaker.WaitTabs(): Boolean;
begin
Result := XPBar.WaitXP(2800);
Self.IsTabbing := Result;
end;
procedure TTabMaker.FinishedTabs();
begin
Self.IsTabbing := False;
Self.TotalActions += Self.SoftClayCount;
Self.TotalProfit := Self.TotalActions * Self.ActionProfit;
Self.SoftClayCount := 0;
end;
function TTabMaker.GetState(): ETabMakerState;
var
s: String;
begin
if WL.Activity.IsFinished() then
Exit(ETabMakerState.END_SCRIPT);
if Chat.LeveledUp() then
Exit(ETabMakerState.LEVEL_UP);
if Self.IsTabbing then
begin
if Inventory.ContainsItem(Self.SoftClay) then
Exit(ETabMakerState.WAIT_TABS);
Exit(ETabMakerState.FINISHED_TABS);
end;
s := Chat.GetChatTitle();
if s.Contains('Select') then
Exit(ETabMakerState.HANDLE_PHIALS_CHAT);
if s.Contains('Repeat') then
Exit(ETabMakerState.HANDLE_SERVANT);
if RSInterface.IsOpen() then
begin
if Lectern.IsOpen() then
Exit(ETabMakerState.HANDLE_TAB_UI);
Exit(ETabMakerState.CLOSE_INTERFACE);
end;
if not Minimap.InPOH() then
begin
if not Self.UsePhials or Inventory.IsFull() then
Exit(ETabMakerState.ENTER_HOUSE);
if not Inventory.ContainsItem(Self.NotedSoftClay) then
Exit(ETabMakerState.END_SCRIPT);
Exit(ETabMakerState.TALK_TO_PHIALS);
end;
if Inventory.ContainsItem(Self.SoftClay) then
begin
Self.WaitingServant := False;
Exit(ETabMakerState.OPEN_LECTERN);
end;
if Self.UsePhials then
Exit(ETabMakerState.EXIT_HOUSE);
if WaitingServant then
begin
if Self.ServantNPC.IsVisible() then
Exit(ETabMakerState.TALK_SERVANT);
Exit(ETabMakerState.WAIT_SERVANT);
end;
Exit(ETabMakerState.CALL_SERVANT);
end;
procedure TTabMaker.Run(maxActions: UInt32; maxTime: UInt64);
begin
Self.Init(maxActions, maxTime);
repeat
Self.State := Self.GetState();
Self.SetAction(ToStr(Self.State));
case Self.State of
ETabMakerState.LEVEL_UP:
begin
Self.IsTabbing := False;
Chat.HandleLevelUp();
end;
ETabMakerState.OPEN_LECTERN: Self.OpenLectern();
ETabMakerState.HANDLE_PHIALS_CHAT: Self.FinishPhialsChat();
ETabMakerState.HANDLE_TAB_UI: Self.HandleLectern();
ETabMakerState.HANDLE_SERVANT: Self.HandleServant();
ETabMakerState.CLOSE_INTERFACE: RSInterface.Close();
ETabMakerState.CALL_SERVANT: Self.CallServant();
ETabMakerState.TALK_SERVANT: Self.TalkServant();
ETabMakerState.EXIT_HOUSE: House.Leave();
ETabMakerState.TALK_TO_PHIALS: Self.PhialsGetSoftClay();
ETabMakerState.ENTER_HOUSE: House.Enter();
ETabMakerState.WAIT_SERVANT: Wait(7000, 8000);
ETabMakerState.WAIT_TABS: Self.WaitTabs();
ETabMakerState.FINISHED_TABS: Self.FinishedTabs();
ETabMakerState.END_SCRIPT: Break;
end;
Self.DoAntiban();
until Self.ShouldStop();
end;
var
TabMaker: TTabMaker;
procedure TRSMinimap.SetCompassAngleEx(degrees, accuracy: Double); override;
begin
if MainScreen.IsUpText('>') then
ChooseOption.Select('Cancel');
inherited;
end;
{$IFDEF SCRIPT_GUI}
type
TTabMakerConfig = record(TScriptForm)
LecternSelector: TLabeledCombobox;
NPCSelector: TLabeledCombobox;
TabletSelector: TLabeledCombobox;
TabMakerInfo: TLabel;
ImagePanel: TPanel;
Config: TConfigJSON;
end;
procedure TTabMakerConfig.StartScript(sender: TObject); override;
begin
CurrentNPC := ERSNPC(Self.NPCSelector.GetItemIndex());
CurrentTablet := Lectern.TABLETS[CurrentLectern][Self.TabletSelector.GetItemIndex()];
Self.Config.Put('npc', Ord(CurrentNPC));
Self.Config.Put('lectern', Ord(CurrentLectern));
Self.Config.Put('tablet', ToStr(CurrentTablet));
inherited;
end;
procedure TTabMakerConfig.LecternSelectorOnChange(sender: TObject);
var
combobox: TComboBox;
begin
combobox := sender;
CurrentLectern := ERSLecternType(combobox.getItemIndex() + 1);
Self.NPCSelector.SetVisible(CurrentLectern = ERSLecternType.STANDARD);
Self.TabletSelector.SetItemIndex(Lectern.TABLETS[CurrentLectern].Find(LowerCase(CurrentTablet)));
end;
procedure TTabMakerConfig.NPCSelectorOnChange(sender: TObject);
var
combobox: TComboBox;
begin
combobox := sender;
case combobox.getItemIndex() of
0: Self.TabMakerInfo.SetCaption(
'Make sure you have noted soft clay with you, coins and the spell available.'
);
1: Self.TabMakerInfo.SetCaption(
'Make sure you have soft clay in your bank and you have previously' +
LineEnding +
'asked the buttler to fetch it for you. I recommend you fetch a ' +
LineEnding +
'number that has no left overs. You also need money in your servant''s' +
LineEnding +
' money bag and you need to replenish it MANUALLY once in a while.'
);
end;
end;
procedure TTabMakerConfig.Run(); override;
var
tab: TTabSheet;
i: Int32;
begin
Self.Setup('Wasp TabMaker');
Self.Config.Setup('wasp-tab-maker');
if Self.Config.Has('lectern') then
CurrentLectern := ERSLecternType(Self.Config.GetInt('lectern'));
if Self.Config.Has('npc') then
CurrentNPC := ERSNPC(Self.Config.GetInt('npc'));
if Self.Config.Has('tablet') then
CurrentTablet := Self.Config.GetString('tablet');
Self.Start.SetOnClick(@Self.StartScript);
Self.AddTab('Script Settings');
tab := Self.Tabs[High(Self.Tabs)];
Self.CreateAccountManager(tab);
with Self.LecternSelector do
begin
Create(tab);
SetCaption('Lectern:');
SetLeft(TControl.AdjustToDPI(20));
SetTop(TControl.AdjustToDPI(150));
SetStyle(csDropDownList);
AddItemArray(['Standard', 'Ancient', 'Lunar', 'Arceuus']);
Combobox.SetOnChange(@Self.LecternSelectorOnChange);
SetItemIndex(Ord(CurrentLectern)-1);
SetEnabled(False);
end;
with Self.NPCSelector do
begin
Create(tab);
SetCaption('Method:');
SetLeft(Self.LecternSelector.GetLeft());
SetTop(Self.LecternSelector.GetBottom() + TControl.AdjustToDPI(10));
SetStyle(csDropDownList);
AddItemArray(['Phials', 'Demon butler']);
SetItemIndex(Ord(CurrentNPC));
Combobox.SetOnChange(@Self.NPCSelectorOnChange);
end;
with Self.TabletSelector do
begin
Create(tab);
SetCaption('Spell tab:');
SetTop(Self.LecternSelector.GetTop());
SetLeft(Self.LecternSelector.GetRight() + TControl.AdjustToDPI(15));
SetStyle(csDropDownList);
for i := 0 to High(Lectern.TABLETS[CurrentLectern]) do
AddItem(ToStr(Lectern.TABLETS[CurrentLectern][i]).SentenceCase());
end;
with Self.TabMakerInfo do
begin
Create(tab);
SetLeft(Self.NPCSelector.GetLeft());
SetTop(Self.NPCSelector.GetBottom() + TControl.AdjustToDPI(15));
SetHint('NPC mode instructions.');
end;
Self.CreateHouseBuilder();
Self.CreateAntibanManager();
Self.CreateWaspLibSettings();
Self.CreateAPISettings();
Self.NPCSelectorOnChange(Self.NPCSelector.ComboBox);
Self.LecternSelectorOnChange(Self.LecternSelector.ComboBox);
inherited;
end;
var
TabMakerConfig: TTabMakerConfig;
{$ENDIF}
begin
{$IFDEF SCRIPT_GUI}
TabMakerConfig.Run();
{$ENDIF}
TabMaker.Run(WLSettings.MaxActions, WLSettings.MaxTime);
end.