-
Notifications
You must be signed in to change notification settings - Fork 14
/
wasp_enchanter.simba
461 lines (382 loc) · 12.3 KB
/
wasp_enchanter.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
{$DEFINE SCRIPT_ID := '242c8d26-e9c9-4de5-945b-5f0288307dfc'}
{$DEFINE SCRIPT_REVISION := '44'}
{$IFNDEF SCRIPT_CHAIN}
{$DEFINE SCRIPT_GUI}
{$I SRL-T/osr.simba}
{$I WaspLib/osr.simba}
{$ENDIF}
const
GEM_TYPE: TStringArray = [
'Opal', 'Jade', 'Red topaz', 'Sapphire', 'Emerald', 'Ruby',
'Diamond', 'Dragonstone', 'Onyx', 'Zenyte'
];
JEWELRY_TYPE: TStringArray = ['Ring', 'Necklace', 'Bracelet', 'Amulet'];
var
CurrentJewel: TRSItem = 'Ruby necklace';
type
EEnchanterState = (
LEVEL_UP,
CLOSE_CONTEXT,
OPEN_BANK,
WITHDRAW_TOOL,
WITHDRAW_MATERIAL,
DEPOSIT_PRODUCT,
OPEN_COLLECT,
HANDLE_COLLECT,
CLOSE_INTERFACE,
OPEN_MAGIC,
OPEN_INVENTORY,
CAST_SPELL,
ENCHANT_JEWEL,
CANCEL_SPELL,
WAIT_ENCHANT,
OUT_OF_SUPPLIES,
END_SCRIPT
);
TEnchanter = record(TBaseBankScript)
State: EEnchanterState;
Spell: ERSSpell;
CosmicRune, RegularJewel, EnchantedJewel: TRSBankItem;
Enchanting: Boolean;
end;
procedure TAntiban.Setup(); override;
begin
Self.Skills := [ERSSkill.MAGIC, ERSSkill.TOTAL];
Self.MinZoom := 15;
Self.MaxZoom := 85;
inherited;
end;
procedure TEnchanter.SetSpell();
var
itemStr: String;
begin
itemStr := ToStr(CurrentJewel);
if itemStr.ContainsAny(['Opal', 'Sapphire']) then
Spell := ERSSpell.LVL1_ENCHANT
else if itemStr.ContainsAny(['Jade', 'Emerald']) then
Spell := ERSSpell.LVL2_ENCHANT
else if itemStr.ContainsAny(['Topaz', 'Ruby']) then
Spell := ERSSpell.LVL3_ENCHANT
else if itemStr.Contains('Diamond') then
Spell := ERSSpell.LVL4_ENCHANT
else if itemStr.Contains('Dragon') then
Spell := ERSSpell.LVL5_ENCHANT
else if itemStr.Contains('Onyx') then
Spell := ERSSpell.LVL6_ENCHANT
else if itemStr.Contains('Zenyte') then
Spell := ERSSpell.LVL7_ENCHANT
end;
procedure TEnchanter.SetupJewels();
var
itemStr: String;
enchantedItem: TRSItem;
begin
itemStr := ToStr(CurrentJewel);
if itemStr.Contains('Opal') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of pursuit'
else if itemStr.Contains('necklace') then
enchantedItem := 'Dodgy necklace'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Expeditious bracelet'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of bounty';
end
else if itemStr.Contains('Jade') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of returning(5)'
else if itemStr.Contains('necklace') then
enchantedItem := 'Necklace of passage(5)'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Flamtaer bracelet'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of Chemistry';
end
else if itemStr.Contains('Topaz') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Efaritay''s aid'
else if itemStr.Contains('necklace') then
enchantedItem := 'Necklace of faith'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Bracelet of slaughter'
else if itemStr.Contains('amulet') then
enchantedItem := 'Burning amulet(5)';
end
else if itemStr.Contains('Sapphire') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of recoil'
else if itemStr.Contains('necklace') then
enchantedItem := 'Games necklace(8)'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Bracelet of clay'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of magic';
end
else if itemStr.Contains('Emerald') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of dueling(8)'
else if itemStr.Contains('necklace') then
enchantedItem := 'Binding necklace'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Castle wars bracelet(3)'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of defence';
end
else if itemStr.Contains('Ruby') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of forging'
else if itemStr.Contains('necklace') then
enchantedItem := 'Digsite pendant (5)'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Inoculation bracelet'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of strength';
end
else if itemStr.Contains('Diamond') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of life'
else if itemStr.Contains('necklace') then
enchantedItem := 'Phoenix necklace'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Abyssal bracelet(5)'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of power';
end
else if itemStr.Contains('Dragon') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of wealth'
else if itemStr.Contains('necklace') then
enchantedItem := 'Skills necklace'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Combat bracelet'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of glory';
end
else if itemStr.Contains('Onyx') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of stone'
else if itemStr.Contains('necklace') then
enchantedItem := 'Berserker necklace'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Regen bracelet'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of fury';
end
else if itemStr.Contains('Zenyte') then
begin
if itemStr.Contains('ring') then
enchantedItem := 'Ring of suffering'
else if itemStr.Contains('necklace') then
enchantedItem := 'Necklace of anguish'
else if itemStr.Contains('bracelet') then
enchantedItem := 'Tormented bracelet'
else if itemStr.Contains('amulet') then
enchantedItem := 'Amulet of torture';
end;
Self.RegularJewel := TRSBankItem.Setup(CurrentJewel, Bank.QUANTITY_ALL, False);
Self.EnchantedJewel := TRSBankItem.Setup(enchantedItem, Bank.QUANTITY_ALL, False);
end;
procedure TEnchanter.Init(maxActions: UInt32; maxTime: UInt64); override;
begin
inherited;
Self.RSW.SetupNamedRegion();
Self.CosmicRune := TRSBankItem.Setup('Cosmic rune', Bank.QUANTITY_ALL, False);
Self.SetSpell();
Self.SetupJewels();
Self.ActionProfit :=
ItemData.GetAverage(Self.EnchantedJewel.Item) -
(ItemData.GetAverage(Self.CosmicRune.Item) +
ItemData.GetAverage(Self.RegularJewel.Item));
end;
function TEnchanter.EnchantJewel(): Boolean;
begin
XPBar.EarnedXP();
if Inventory.ClickItem(Self.RegularJewel.Item, '>') then
Result := WaitUntil(Magic.IsOpen() or XPBar.EarnedXP(), 300, 6000);
Self.Enchanting := Result;
end;
function TEnchanter.WaitEnchanting(): Boolean;
begin
if Self.Enchanting then
Result := Inventory.ContainsAll([Self.CosmicRune.Item, Self.RegularJewel.Item]) and XPBar.WaitXP(5000)
else
Result := XPBar.WaitXP(5000);
Self.Enchanting := Result;
end;
function TEnchanter.Deposit(): Boolean;
var
itemCount: Int32;
begin
itemCount := Inventory.CountItem(Self.EnchantedJewel.Item);
if Bank.DepositItem(Self.EnchantedJewel, True) then
Result := WaitUntil(Inventory.CountItem(Self.EnchantedJewel.Item) = 0, 100, 3000);
if Result then
begin
Self.TotalActions += itemCount;
Self.TotalProfit := Self.TotalActions * Self.ActionProfit;
end;
end;
function TEnchanter.GetState(): EEnchanterState;
begin
if WL.Activity.IsFinished() then
Exit(EEnchanterState.END_SCRIPT);
if Chat.LeveledUp() then
begin
Self.Enchanting := False;
Exit(EEnchanterState.LEVEL_UP);
end;
if RSInterface.IsOpen() then
begin
Self.Enchanting := False;
Self.HoveringBank := False;
if Bank.IsOpen() then
begin
if Inventory.ContainsItem(Self.EnchantedJewel.Item) then
Exit(EEnchanterState.DEPOSIT_PRODUCT);
if BankEmpty or Inventory.ContainsAll([Self.CosmicRune.Item, Self.RegularJewel.Item]) then
Exit(EEnchanterState.CLOSE_INTERFACE);
if not Inventory.ContainsItem(Self.CosmicRune.Item) then
Exit(EEnchanterState.WITHDRAW_TOOL);
if not Inventory.ContainsItem(Self.RegularJewel.Item) then
Exit(EEnchanterState.WITHDRAW_MATERIAL);
end;
if CollectBox.IsOpen() then
begin
if Self.CollectEmpty or Inventory.ContainsAll([Self.CosmicRune.Item, Self.RegularJewel.Item]) then
Exit(EEnchanterState.CLOSE_INTERFACE);
Exit(EEnchanterState.HANDLE_COLLECT);
end;
Exit(EEnchanterState.CLOSE_INTERFACE);
end;
if Inventory.IsOpen() then
begin
if Inventory.ContainsAll([Self.CosmicRune.Item, Self.RegularJewel.Item]) then
begin
if MainScreen.IsUpText('>') then
Exit(EEnchanterState.ENCHANT_JEWEL);
if Self.Enchanting then
Exit(EEnchanterState.WAIT_ENCHANT);
Exit(EEnchanterState.OPEN_MAGIC);
end;
if MainScreen.IsUpText('>') then
Exit(EEnchanterState.CANCEL_SPELL);
if Self.BankEmpty and Self.CollectEmpty then
Exit(EEnchanterState.OUT_OF_SUPPLIES);
if Self.BankEmpty then
Exit(EEnchanterState.OPEN_COLLECT);
Exit(EEnchanterState.OPEN_BANK);
end;
if Magic.IsOpen() then
begin
if Self.Enchanting or Magic.IsSelected(SPELL) then
Exit(OPEN_INVENTORY);
Exit(CAST_SPELL);
end;
Exit(EEnchanterState.OPEN_MAGIC);
end;
function TEnchanter.Terminate(): Boolean; override;
begin
if inherited then
for 0 to 5 do
if Result := Bank.WithdrawItem(Self.EnchantedJewel, True) then
Break;
end;
procedure TEnchanter.Run(maxActions: UInt32; maxTime: UInt64);
begin
Self.Init(maxActions, maxTime);
repeat
Self.State := Self.GetState();
Self.SetAction(ToStr(Self.State));
case Self.State of
EEnchanterState.OPEN_BANK: Bank.WalkOpen();
EEnchanterState.WITHDRAW_TOOL: Self.Withdraw(Self.CosmicRune);
EEnchanterState.WITHDRAW_MATERIAL: Self.Withdraw(Self.RegularJewel);
EEnchanterState.DEPOSIT_PRODUCT: Self.Deposit();
EEnchanterState.OPEN_COLLECT: CollectBox.WalkOpen();
EEnchanterState.HANDLE_COLLECT: Self.HandleCollectBox([Self.RegularJewel.Item, Self.CosmicRune.Item]);
EEnchanterState.CLOSE_INTERFACE: RSInterface.Close();
EEnchanterState.WAIT_ENCHANT: Self.Enchanting := XPBar.WaitXP(5000);
EEnchanterState.LEVEL_UP: Chat.HandleLevelUp();
EEnchanterState.OPEN_MAGIC: Magic.Open();
EEnchanterState.OPEN_INVENTORY: Inventory.Open();
EEnchanterState.CAST_SPELL: Magic.CastSpell(SPELL);
EEnchanterState.ENCHANT_JEWEL: Self.EnchantJewel();
EEnchanterState.CANCEL_SPELL: Magic.Deselect();
EEnchanterState.OUT_OF_SUPPLIES, EEnchanterState.END_SCRIPT: Break;
end;
Self.DoAntiban();
until Self.ShouldStop();
if not Self.Terminate() then
TerminateScript(Self.Name + ' didn''t terminate properly. Stopping execution.');
end;
var
Enchanter: TEnchanter;
{$IFNDEF SCRIPT_CHAIN}
{$IFDEF SCRIPT_GUI}
type
TEnchanterConfig = record(TScriptForm)
GemSelector: TLabeledCombobox;
JewelSelector: TLabeledCombobox;
end;
procedure TEnchanterConfig.StartScript(sender: TObject); override;
begin
CurrentJewel := Self.GemSelector.getText().Replace('Red t', 'T') + ' ' + Self.JewelSelector.getText().ToLower();
inherited;
end;
procedure TEnchanterConfig.Run(); override;
var
tab: TTabSheet;
begin
Self.Setup('Wasp Enchanter');
Self.Start.SetOnClick(@Self.StartScript);
Self.AddTab('Script Settings');
tab := Self.Tabs[High(Self.Tabs)];
Self.CreateAccountManager(tab);
with Self.GemSelector do
begin
Create(tab);
SetCaption('Gem type:');
SetLeft(TControl.AdjustToDPI(50));
SetTop(TControl.AdjustToDPI(200));
SetStyle(csDropDownList);
AddItemArray(GEM_TYPE);
SetItemIndex(3);
end;
with Self.JewelSelector do
begin
Create(tab);
SetCaption('Jewel type:');
SetLeft(Self.GemSelector.GetRight() + TControl.AdjustToDPI(20));
SetTop(Self.GemSelector.GetTop());
SetWidth(TControl.AdjustToDPI(200));
SetStyle(csDropDownList);
AddItemArray(JEWELRY_TYPE);
SetItemIndex(0);
end;
Self.CreateAntibanManager();
Self.CreateBankSettings();
Self.CreateWaspLibSettings();
Self.CreateAPISettings();
inherited;
end;
var
EnchanterConfig: TEnchanterConfig;
{$ENDIF}
{$ENDIF}
{$IFNDEF SCRIPT_CHAIN}
begin
{$IFDEF SCRIPT_GUI}
EnchanterConfig.Run();
{$ENDIF}
Enchanter.Run(WLSettings.MaxActions, WLSettings.MaxTime);
end.
{$ENDIF}