-
Notifications
You must be signed in to change notification settings - Fork 0
/
Kal-new.lua
561 lines (471 loc) · 12.1 KB
/
Kal-new.lua
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
-- M1
-- G1 Start
-- G10 Leczenie off
-- G11 Leczenie - cure
-- G12 Leczenie - group cure
-- M2 zapisywanie pozycji
-- G1 Pozycja Inkaska - wylaczone
-- G2 Pozycja FOD 1
-- G3 Pozycja FOD 2
-- G4 Pozycja Prist 1
-- G5 Pozycja Prist 2
-- G6 Pozycja Prist 3
-- G7 Pozycja Prist 4
-- G8 Pozycja Prist 5
-- G9 Pozycja MA w party
-- G10 MA Active Skill
-- G11 Pozycja Gienek1 PT
-- G12 Pozycja Gienek2 PT
-- M3
-- G1 Uzyj Inkaskiej
-- G2 Uzyj FOD1
-- G3 Uzyj FOD2
-- G4 Rzuc shni na prista 1
-- G5 Rzuc shni na prista 2
-- G6 Rzuc shni na prista 3
-- G7 Rzuc shni na prista 4
-- G8 Rzuc shni na prista 5
-- G9 Uzyj Medytacji
-- G10 Rzuc Buffy
--uzadzenie = "kb"
uzadzenie = "lhc"
avgGlobalX = 40.985023809524
avgGlobalY = 72.881376984127
hits = 0
eXecute = true
msgDelay = 5000
msgTime = 0
inkaskaUse = false
inkaskaTime = 0
inkaskaDelay = 5000
inkaskaX = 64481
inkaskaY = 48792
fodDelay = 20 * 60 * 1000 + 1000
fod1Use = true
fod1X = 40515
fod1Y = 43482
fod1Time = 0
fod2Use = true
fod2X = 16394
fod2Y = 43669
fod2Time = 0
pristDelay = 2 * 60 * 1000 + 30 * 1000
pristTime = 0
pristActive = 1
prist1Use = false
prist1X = 27791
prist1Y = 21928
prist2Use = false
prist2X = 42272
prist2Y = 18555
prist3Use = false
prist3X = 49141
prist3Y = 16056
prist4Use = false
prist4X = 60422
prist4Y = 14431
prist5Use = false
prist5X = nil
prist5Y = nil
maTime = 0
maActiveSkillN = 0
maActiveSkillX = 22834
maActiveSkillY = 2545
maActiveSkillTime = 0
skillBarDiff = 42 * avgGlobalY
groupCureUse = false
groupCureDelay = 5000
groupCureMinDelay = 3100
groupCureTime = 0
groupCureN = 1
cureUse = false
cureDelay = 2600
cureMinDelay = 2250
cureTime = 0
cureCurrent = 2
cureN = 2
cureChar1X = nil
cureChar1Y = nil
cureChar2X = nil
cureChar2Y = nil
medytacjaUse = false
medytacjaDelay = 12 * 60 * 1000 + 30 * 1000 + 3000
medytacjaTime = 0
medytacjaN = 7
buffyDelay = 23 * 60 * 1000 + 500
buffyMinDelay = 3600
buffyUse = true
buffyTime = 0
buffyName = { "def", "agi", "hp", "speed"}
buffyNo = { 5, 6, 8, 4}
buffyTT = { 0, 0, 0, 0}
buffyActiveCharX = nil
buffyActiveCharY = nil
--currentX = nil
--currentY = nil
function RunScript()
ClearLCD()
local msg = GetDate("%X") .. " Program dziala - " .. GetRunningTime()
while true do
if not (GetMKeyState(uzadzenie) == 1) then
eXecute = false
break
end
for i = 1, 20 do
if (fod1Use) then
if (fod1Time + fodDelay < GetRunningTime()) then
RzucFod1()
end
end
if (fod2Use) then
if (fod2Time + fodDelay < GetRunningTime()) then
RzucFod2()
end
end
if (medytacjaUse) then
if (medytacjaTime + medytacjaDelay < GetRunningTime()) then
Medytacja()
end
end
if (inkaskaUse) then
if (inkaskaTime + inkaskaDelay < GetRunningTime()) then
Inkaska()
end
end
if (pristTime + pristDelay < GetRunningTime()) then
RzucNaPrista()
end
if (buffyUse) then
if (buffyTime + buffyDelay < GetRunningTime()) then
Buffy()
end
end
if (cureUse) then
if (maTime < GetRunningTime()) then
if (cureTime + cureDelay < GetRunningTime()) then
LeczPojedynczym()
end
end
elseif (groupCureUse) then
if (maTime < GetRunningTime()) then
if (groupCureTime + groupCureDelay < GetRunningTime()) then
GroupCure()
end
end
end
Sleep(50)
end
end
end
function LCDMessage(lMsg)
OutputLCDMessage(lMsg, 600000)
end
function OnEvent(event, arg)
--OutputLogMessage("event = %s, arg = %s, pause = %s, eXecute = %s\n", event, arg, tostring(pause), tostring(eXecute))
local mkey = GetMKeyState(uzadzenie)
if (eXecute == false and mkey == 1) then
eXecute = true
elseif (eXecute == false) then
LCDMessage("Please reurn to the execute state")
end
if (event == "G_RELEASED" and eXecute) then
if (mkey == 1) then
if (arg == 1) then
RunScript()
elseif (arg == 10) then
cureUse = false
groupCureUse = false
LCDMessage("Cure and GC Dsabled")
elseif (arg == 11) then
cureUse = true
groupCureUse = false
LCDMessage("Cure Enabled")
elseif (arg == 12) then
cureUse = false
groupCureUse = true
LCDMessage("Group Cure Enabled")
end
elseif (mkey == 2) then
if (arg == 1) then
-- inkaska
inkaskaX, inkaskaY = GetMousePosition()
LCDMessage("Inkaska (" .. inkaskaX .. ", " .. inkaskaY .. ")")
elseif (arg == 2) then
-- FOD1
fod1X, fod1Y = GetMousePosition()
LCDMessage("FOD1 (" .. fod1X .. ", " .. fod1Y .. ")")
elseif (arg == 3) then
-- FOD2
fod2X, fod2Y = GetMousePosition()
LCDMessage("FOD2 (" .. fod2X .. ", " .. fod2Y .. ")")
elseif (arg == 4) then
-- Prist 1
prist1Use = true
prist1X, prist1Y = GetMousePosition()
LCDMessage("Priest 1 (" .. prist1X .. ", " .. prist1Y .. ")")
elseif (arg == 5) then
-- Prist 2
prist2Use = true
prist2X, prist2Y = GetMousePosition()
LCDMessage("Priest 2 (" .. prist2X .. ", " .. prist2Y .. ")")
elseif (arg == 6) then
-- Prist 3
prist3Use = true
prist3X, prist3Y = GetMousePosition()
LCDMessage("Priest 3 (" .. prist3X .. ", " .. prist3Y .. ")")
elseif (arg == 7) then
-- Prist 4
prist4Use = true
prist4X, prist4Y = GetMousePosition()
LCDMessage("Priest 4 (" .. prist4X .. ", " .. prist4Y .. ")")
elseif (arg == 8) then
-- Prist 5
prist5Use = true
prist5X, prist5Y = GetMousePosition()
LCDMessage("Priest 5 (" .. prist5X .. ", " .. prist5Y .. ")")
elseif (arg == 9) then
-- PT Buffer Active Char
buffyActiveCharX, buffyActiveCharY = GetMousePosition()
LCDMessage("Buffy (" .. buffyActiveCharX .. ", " .. buffyActiveCharY .. ")")
OutputLogMessage("DiffX = %s, DiffY = %s\n", tostring(buffyActiveCharX), tostring(buffyActiveCharY))
elseif (arg == 10) then
-- MA Active Skill
maActiveSkillX, maActiveSkillY = GetMousePosition()
LCDMessage("MA Active Skill (" .. maActiveSkillX .. ", " .. maActiveSkillY .. ")")
elseif (arg == 11) then
-- PT Hercio
cureChar1X, cureChar1Y = GetMousePosition()
LCDMessage("Cure char 1 (" .. cureChar1X .. ", " .. cureChar1Y .. ")")
elseif (arg == 12) then
-- PT Freskos
cureChar2X, cureChar2Y = GetMousePosition()
LCDMessage("Cure char 2 (" .. cureChar2X .. ", " .. cureChar2Y .. ")")
end
elseif (mkey == 3) then
if (arg == 2) then
fod1Use = true
RzucFod1()
elseif (arg == 3) then
fod2Use = true
RzucFod2()
elseif (arg == 4) then
prist1Use = true
pristActive = 1
RzucNaPrista()
elseif (arg == 5) then
prist2Use = true
pristActive = 2
RzucNaPrista()
elseif (arg == 6) then
prist3Use = true
pristActive = 3
RzucNaPrista()
elseif (arg == 7) then
prist4Use = true
pristActive = 4
RzucNaPrista()
elseif (arg == 8) then
prist5Use = true
pristActive = 5
RzucNaPrista()
elseif (arg == 9) then
medytacjaUse = true
Medytacja()
elseif (arg == 10) then
buffyUse = true
Buffy()
end
end
end
end
function RzucFod1()
if (fod1X and fod1Y) then
ReturnTo(fod1X, fod1Y)
Sleep(100)
PressAndReleaseMouseButton(1)
--ClearLCD()
local msg = GetDate("%X") .. " - Rzucilem FOD1"
LCDMessage(msg)
fod1Time = GetRunningTime() + math.random( 30*1000 )
end
end
function RzucFod2()
if (fod2X and fod2Y) then
ReturnTo(fod2X, fod2Y)
Sleep(100)
PressAndReleaseMouseButton(1)
--ClearLCD()
local msg = GetDate("%X") .. " - Rzucilem FOD2"
LCDMessage(msg)
fod2Time = GetRunningTime() + math.random( 30*1000 )
end
end
function RzucNaPrista()
if (pristActive == 1) then
RzucLa(prist1Use, prist1X, prist1Y)
elseif (pristActive == 2) then
RzucLa(prist2Use, prist2X, prist2Y)
elseif (pristActive == 3) then
RzucLa(prist3Use, prist3X, prist3Y)
elseif (pristActive == 4) then
RzucLa(prist4Use, prist4X, prist4Y)
elseif (pristActive == 5) then
RzucLa(prist5Use, prist5X, prist5Y)
end
end
function RzucLa(pristUse, pristX, pristY)
if (pristUse and pristX and pristY) then
ReturnTo(pristX, pristY)
Sleep(100)
PressAndReleaseMouseButton(3)
local msg = GetDate("%X") .. " - Rzucilem na Prista: " .. tostring(pristActive)
LCDMessage(msg)
pristTime = GetRunningTime() + math.random( 60*1000 )
end
Sleep(300)
if (pristActive < 5) then
pristActive = pristActive + 1
else
pristActive = 1
end
end
function LeczPojedynczym()
if not (maActiveSkillN == cureN) then
if (maActiveSkillX and maActiveSkillY and cureN and skillBarDiff) then
local cureX = maActiveSkillX
local cureY = maActiveSkillY + (cureN * skillBarDiff)
ReturnTo(cureX, cureY)
Sleep(100)
PressAndReleaseMouseButton(1)
maActiveSkillN = cureN
end
end
if (maActiveSkillN == cureN) then
local cureCharX = nil
local cureCharY = nil
if (cureCurrent == 2 and cureChar1X and cureChar1Y) then
cureCharX = cureChar1X
cureCharY = cureChar1Y
cureCurrent = 1
elseif (cureCurrent == 1 and cureChar2X and cureChar2Y) then
cureCharX = cureChar2X
cureCharY = cureChar2Y
cureCurrent = 2
end
if (cureCharX and cureCharY) then
ReturnTo(cureCharX, cureCharY)
Sleep(100)
PressAndReleaseMouseButton(3)
cureTime = GetRunningTime()
maTime = cureTime + cureMinDelay
elseif (cureCurrent == 1) then
cureCurrent = 2
elseif (cureCurrent == 2) then
cureCurrent = 1
end
end
end
function Medytacja()
if (maActiveSkillX and maActiveSkillY and medytacjaN and skillBarDiff) then
local mX = maActiveSkillX
local mY = maActiveSkillY + (medytacjaN * skillBarDiff)
ReturnTo(mX, mY)
Sleep(100)
PressAndReleaseMouseButton(1)
local msg = GetDate("%X") .. "Urzylem medytacji"
LCDMessage(msg)
medytacjaTime = GetRunningTime() + math.random( 60*1000 )
end
end
function GroupCure()
if (maActiveSkillX and maActiveSkillY and groupCureN and skillBarDiff) then
local mX = maActiveSkillX
local mY = maActiveSkillY + (groupCureN * skillBarDiff)
ReturnTo(mX, mY)
Sleep(100)
PressAndReleaseMouseButton(1)
groupCureTime = GetRunningTime() + math.random( 2000 )
maTime = groupRunningTime + groupCureMinDelay
end
end
function Inkaska()
if (inkaskaX and inkaskaY) then
ReturnTo(inkaskaX, inkaskaY)
Sleep(100)
PressAndReleaseMouseButton(1)
local msg = GetDate("%X") .. "Urzylem inkaskiej"
LCDMessage(msg)
inkaskaTime = GetRunningTime()
end
end
function Buffy()
if (buffyActiveCharX and buffyActiveCharY and maActiveSkillX and maActiveSkillY and skillBarDiff) then
for i, bNo in ipairs(buffyNo) do
if (maTime > GetRunningTime()) then
Sleep(maTime - GetRunningTime())
end
local cureX = maActiveSkillX
local cureY = maActiveSkillY + (bNo * skillBarDiff)
ReturnTo(cureX, cureY)
Sleep(100)
PressAndReleaseMouseButton(1)
Sleep(100)
maActiveSkillN = bNo
ReturnTo(buffyActiveCharX , buffyActiveCharY)
Sleep(100)
PressAndReleaseMouseButton(3)
maTime = GetRunningTime() + buffyMinDelay + math.random( 2000 )
local msg = GetDate("%X") .. "Rzucilem: " .. buffyName[i]
LCDMessage(msg)
end
buffyTime = GetRunningTime() + math.random( 2*60*1000 )
end
end
function ReturnTo(pointX, pointY)
local currentX = 0
local currentY = 0
local diffX = 0
local diffY = 0
local moveX = 1
local moveY = 1
local textX = 0
local testY = 0
Sleep(100)
currentX, currentY = GetMousePosition()
diffX = math.floor((pointX - currentX)/avgGlobalX)
diffY = math.floor((pointY - currentY)/avgGlobalY)
if (diffX < 0) then
moveX = -1
end
if (diffY < 0) then
moveY = -1
end
diffX = math.abs(diffX)
diffY = math.abs(diffY)
if (diffY >= diffX) then
for i = 0, diffX do
MoveMouseRelative(moveX, moveY)
end
for i = diffX + 1, diffY do
MoveMouseRelative(0, moveY)
end
else
for i = 0, diffY do
MoveMouseRelative(moveX, moveY)
end
for i = diffY + 1, diffX do
MoveMouseRelative(moveX, 0)
end
end
Sleep(50)
testX, testY = GetMousePosition()
--OutputLogMessage("DiffX = %s, DiffY = %s\n", tostring(math.abs(testX - pointX)/avgGlobalX), tostring(math.abs(testY - pointY)/avgGlobalY))
if (hits < 4) then
if (((math.abs(testX - pointX)/avgGlobalX) > 3) or (math.abs(testY - pointY)/avgGlobalY) > 3) then
hits = hits + 1
ReturnTo(pointX, pointY)
end
else
hits = 0
end
end