forked from Torwent/wasp-free
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaio_cooker.simba
371 lines (296 loc) · 8.02 KB
/
aio_cooker.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
{$IFNDEF SCRIPT_CHAIN}
{$DEFINE SRL_USE_REMOTEINPUT}
{$IFDEF WINDOWS}{$DEFINE SCRIPT_GUI}{$ENDIF}
{$I SRL/osr.simba}
{$I WaspLib/osr.simba}
begin
Login.PlayerIndex := 0;
AntibanEnabled := True; //Enables Most Antiban
BreaksEnabled := True; //Enables Short Breaks
SleepEnabled := True; //Enables Sleep Breaks
RemoteInputEnabled := True; //Enables Remote Input
ProgressReportEnabled := True; //Enables Graphical Progress Report
ScriptDebugEnabled := False; //Enables Script Debugging
end;
{$ENDIF}
var
Food: TRSItem = 'Lobster';
type
ECookerState = (
OPEN_BANK,
WITHDRAW_ITEMS,
DEPOSIT_ITEMS,
OPEN_COLLECT,
HANDLE_COLLECT,
CLOSE_INTERFACE,
DO_COOKING,
HANDLE_MAKE,
WAIT_COOKING,
LEVEL_UP,
CLOSE_CONTEXT,
END_SCRIPT
);
TCooker = record(TBaseBankScript)
State: ECookerState;
Ingredient: TRSBankWithdrawItem;
Products: array of TRSBankDepositItem;
Cooking: Boolean;
end;
function TRSMake.SelectHelper(Button: TRSButton; Quantity: Int32; UseKeyboard: Boolean = True): Boolean; override;
begin
Result := Self.SetQuantity(Quantity);
if Result then
begin
if UseKeyboard then
begin
Keyboard.PressKey(VK_SPACE)
end else
Mouse.Click(Button.Bounds, MOUSE_LEFT);
end;
end;
function TRSMake.Select(Index: Int32; Quantity: Int32; UseKeyboard: Boolean = True): Boolean; override;
var
Buttons: TRSButtonArray;
begin
Buttons := Self.GetItemButtons();
if Buttons <> [] then
Result := Self.SelectHelper(Buttons[Index], Quantity, UseKeyboard);
end;
procedure TAntiban.Setup; override;
begin
inherited;
Antiban.Skills := [ERSSkill.COOKING, ERSSkill.TOTAL];
Antiban.MinZoom := 15;
Antiban.MaxZoom := 60;
end;
procedure TCooker.Init(MaxActions: Int32; MaxTime: Int64); override;
begin
Name := 'AIO Cooker';
Version := 'v2.0.2';
inherited;
RSW.Setup('x1916y1841');
ScriptBank := @RSObjects.HosidiusKitchenBank;
Ingredient := [('Raw ' + ToStr(Food).Lower()), BANK_WITHDRAW_ALL, False];
Products := [
[Food, BANK_DEPOSIT_ALL],
['burnt ' + ToStr(Food).Lower, BANK_DEPOSIT_ALL]
];
ActionProfit := (
ItemInfo.GetAveragePrice(Products[0].Item) -
ItemInfo.GetAveragePrice(Ingredient.Item)
);
if not RSClient.IsLoggedIn then Login.LoginPlayer;
if ScriptDebugEnabled then
begin
DebugObjectArray += ScriptBank;
DebugObjectArray += @RSObjects.HosidiusKitchenOven;
end;
end;
function TCooker.HasIngredient: Boolean;
var
Slots: TIntegerArray;
begin
Result := Inventory.FindItem(Ingredient.Item, Slots);
end;
function TCooker.HasProducts: Boolean; overload;
var
Product: TRSBankDepositItem;
Slots: TIntegerArray;
begin
for Product in Products do
if not Inventory.FindItem(Product.Item, Slots) then
Exit(False);
Result := True;
end;
function TCooker.Withdraw: Boolean;
var
InvCount: Int32;
begin
if BankTab = -1 then
BankTab := Bank.FindItemTab(Ingredient.Item);
InvCount := Inventory.Count;
if Result := Bank.WithdrawItem(BankTab, Ingredient, True) then
WaitUntil(Inventory.Count > InvCount, 100, 3000);
if BankEmpty := (not Result and not Bank.FindItem(BankTab, Ingredient)) then
if CollectEmpty and CollectTimer.IsFinished then
CollectEmpty := False;
end;
function TCooker.Deposit: Boolean;
var
InvCount: Int32 := Inventory.Count;
Product: TRSBankDepositItem;
begin
TotalActions += InvCount;
for Product in Products do
begin
if not Bank.DepositItem(BankTab, Product, True) then
Exit(False);
WaitUntil((InvCount > Inventory.Count), 50, 2000);
InvCount := Inventory.Count;
end;
Result := True;
end;
function TCooker.HandleCollectBox: Boolean;
var
Slots: TIntegerArray;
begin
if CollectBox.FindItem(Ingredient.Item, Slots) then
begin
if Result := CollectEmpty := CollectBox.CollectToBank then
WaitUntil(not CollectBox.FindItem(Ingredient.Item, Slots), 100, 2000);
BankEmpty := not CollectEmpty;
end
else
CollectEmpty := True;
CollectTimer.Restart;
end;
function TCooker.DoCooking: Boolean;
begin
if RSObjects.HosidiusKitchenOven.WalkClick then
begin
Minimap.WaitPlayerMoving(300, 3000);
Result := Make.IsOpen(4000);
end;
end;
function TCooker.HandleMake: Boolean;
begin
if not Make.IsOpen then
Exit;
Cooking := Result := Make.Select(0, MAKE_QUANTITY_ALL, SRL.Dice(98.5));
end;
function TCooker.WaitCooking: Boolean;
begin
if Cooking then
Result := Cooking := Self.HasIngredient and XPDrop.WaitDrop(2500)
else
Result := Cooking := XPDrop.WaitDrop(2500);
end;
function TCooker.GetState: ECookerState;
begin
if WL.Activity.IsFinished then
Exit(ECookerState.END_SCRIPT)
else if ChooseOption.IsOpen then
Exit(ECookerState.CLOSE_CONTEXT)
else if XPDrop.FindDrop then
Exit(ECookerState.WAIT_COOKING)
else if Chat.LeveledUp then
begin
Cooking := False;
Exit(ECookerState.LEVEL_UP);
end
else if Make.IsOpen then
Exit(ECookerState.HANDLE_MAKE)
else if MainScreen.HasInterface then
begin
if Bank.IsOpen then
begin
if Self.HasProducts then
Exit(ECookerState.DEPOSIT_ITEMS)
else if BankEmpty or Self.HasIngredient then
Exit(ECookerState.CLOSE_INTERFACE)
else
Exit(ECookerState.WITHDRAW_ITEMS);
end
else if CollectBox.IsOpen then
begin
if CollectEmpty or Self.HasIngredient then
Exit(ECookerState.CLOSE_INTERFACE)
else
Exit(ECookerState.HANDLE_COLLECT)
end
else
Exit(ECookerState.CLOSE_INTERFACE);
end
else if Self.HasIngredient then
begin
if Cooking then
Exit(ECookerState.WAIT_COOKING)
else
Exit(ECookerState.DO_COOKING);
end
else
begin
if BankEmpty and CollectEmpty then
Exit(ECookerState.END_SCRIPT)
else if BankEmpty then
Exit(ECookerState.OPEN_COLLECT)
else
Exit(ECookerState.OPEN_BANK);
end;
end;
function TCooker.Terminate: Boolean; override;
begin
if inherited then
for 0 to 5 do
if Result := Bank.WithdrawItem(BankTab, [Products[0].Item, BANK_WITHDRAW_ALL, True], True) then
Break;
end;
procedure TCooker.Run(MaxActions: Int32; MaxTime: Int64);
begin
ClearDebug;
Self.Init(MaxActions, MaxTime);
while not Self.ShouldStop do
begin
State := Self.GetState;
Action := ToStr(State);
Self.ProcessWhileWaiting;
case State of
ECookerState.OPEN_BANK: Bank.WalkOpen(ScriptBank);
ECookerState.WITHDRAW_ITEMS: Self.Withdraw;
ECookerState.DEPOSIT_ITEMS: Self.Deposit;
ECookerState.OPEN_COLLECT: CollectBox.WalkOpen(ScriptBank);
ECookerState.HANDLE_COLLECT: Self.HandleCollectBox;
ECookerState.CLOSE_INTERFACE: MainScreen.CloseInterface;
ECookerState.LEVEL_UP: Chat.HandleLevelUp;
ECookerState.DO_COOKING: Self.DoCooking;
ECookerState.HANDLE_MAKE: Self.HandleMake;
ECookerState.WAIT_COOKING: Self.WaitCooking;
ECookerState.CLOSE_CONTEXT: ChooseOption.Close;
ECookerState.END_SCRIPT: Break;
end;
Self.DoAntiban;
if not RSClient.IsLoggedIn then Login.LoginPlayer;
end;
if not Self.Terminate then
TerminateScript('aio_cooker didn''t terminate properly. Stopping execution.');
end;
var
Cooker: TCooker;
type
TCookerConfig = record(TScriptConfig)
FoodSelector: TLabeledEdit;
end;
procedure TCookerConfig.StartScript(Sender: TObject);
begin
Self.Init(Sender);
Food := FoodSelector.Edit.getText;
end;
procedure TCookerConfig.Setup; override;
begin
inherited;
with FoodSelector do
begin
Init(ScriptSettingsPanel);
SetCaption('Food name (must be the exact name):');
SetLeft(ScriptSettingsLabel.getLeft + 5);
SetTop(ScriptSettingsLabel.getTop + ScriptSettingsLabel.getHeight + 5);
SetWidth(200);
SetText(Food);
end;
StartButton.setOnClick(@Self.StartScript);
end;
procedure TCookerConfig.Run; override;
begin
Self.Setup;
inherited;
end;
var
CookerConfig: TCookerConfig;
{$IFNDEF SCRIPT_CHAIN}
begin
{$IFDEF SCRIPT_GUI}
Sync(@CookerConfig.Run);
{$ENDIF}
Cooker.Run(MaxActions, MaxTime);
end.
{$ENDIF}