-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraw-svo.skeleton.lua
2360 lines (1964 loc) · 71.3 KB
/
raw-svo.skeleton.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
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
-- Svof (c) 2011-2015 by Vadim Peretokin
-- Svof is licensed under a
-- Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
-- You should have received a copy of the license along with this
-- work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
-- misc functions
function errorf(...)
error(string.format(...))
end
function echon(...)
local function wrapper(...) decho(string.format(...)) end
local status, result = pcall(wrapper, ...)
if not status then error(result, 2) end
echo("\n")
end
function contains(t, value)
assert(type(t) == "table", "svo.contains wants a table!")
for k, v in pairs(t) do
if v == value then
return k
end
end
return false
end
#if skills.healing then
-- used by 'normal' cure functions to see if we should ignore curing this aff
-- returns true - Healing will *not* cure, use normal
-- returns false - Healing *will* cure, don't use normal
function sk.wont_heal_this(aff)
if type(conf.usehealing) ~= "string" or conf.usehealing ~= "full" or not can_usemana() then return true end
if sk.healingmap[aff] and sk.healingmap[aff]() then
return false
end
return true
end
#end
function sk.checking_herb_ai()
return (doingaction"checkparalysis" or doingaction"checkasthma" or doingaction"checkimpatience") and true or false
end
force_send = send
-- balances
bals = bals or {
herb = true, sip = true, moss = true,
purgative = true, salve = true,
balance = true, equilibrium = true, focus = true,
tree = true, leftarm = "unset", rightarm = "unset",
dragonheal = true, smoke = true,
#if skills.voicecraft then
voice = true,
#end
#if class == "druid" then
hydra = true,
#end
#if skills.domination then
entities = true,
#end
#if skills.healing then
healing = true,
#end
#if skills.chivalry or skills.shindo or skills.kaido or skills.metamorphosis then
fitness = true,
#end
#if skills.chivalry then
rage = true,
#end
#if skills.venom then
shrugging = true,
#end
#if skills.physiology then
humour = true, homunculus = true,
#end
#if skills.terminus then
word = true,
#end
}
-- new incoming balances that are tracked between the lines and the prompt
newbals = {}
-- checks
-- sip check
local healthchecks = {
healhealth = {p = dict.healhealth},
healmana = {p = dict.healmana}
}
-- build a table of all the things we need to do with their priority numbers,
-- sort it, and do the topmost thing.
check_sip = function(sync_mode)
-- can we even sip?
if not bals.sip or usingbal("sip") or affs.stun or affs.unconsciousness or affs.sleep or affs.anorexia then
return
end
-- get all prios in the list
local prios = {}
local function check(what)
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.sip and j.p.sip.isadvisable() and not ignore[i] then
prios[i] = (not sync_mode) and j.p.sip.aspriority or j.p.sip.spriority
end
end
end
check(affs)
check(healthchecks)
-- have nada?
if not next(prios) then return end
-- otherwise, do the highest!
if not sync_mode then
doaction(dict[getHighestKey(prios)].sip) else
return dict[getHighestKey(prios)].sip end
end
-- purgative check: needs to be asynced as well
check_purgative = function(sync_mode)
-- can we even sip?
if not bals.purgative or usingbal("purgative") or affs.stun or affs.unconsciousness or affs.sleep or affs.anorexia then
return
end
-- get all prios in the list
local prios = {}
local function check(what)
local gotsomething = false
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.purgative and j.p.purgative.isadvisable() and not ignore[i]
#if skills.healing then
and sk.wont_heal_this(i)
#end
then
prios[i] = (not sync_mode) and j.p.purgative.aspriority or j.p.purgative.spriority
gotsomething = true
end
end
return gotsomething
end
check(affs)
if sys.deffing or conf.keepup then
check(dict_purgative)
end
-- have nada?
if not next(prios) then return end
-- otherwise, do the highest!
if not sync_mode then
doaction(dict[getHighestKey(prios)].purgative) else
return dict[getHighestKey(prios)].purgative end
end
-- salve check
check_salve = function(sync_mode)
-- can we even use salves?
if not bals.salve or usingbal("salve") or
affs.sleep or affs.stun or affs.unconsciousness or affs.slickness then
return
end
-- get all prios in the list
local prios = {}
local function check(what)
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.salve and j.p.salve.isadvisable() and not ignore[i]
#if skills.healing then
and sk.wont_heal_this(i)
#end
then
prios[i] = (not sync_mode) and j.p.salve.aspriority or j.p.salve.spriority
end
end
end
check(affs)
if sys.deffing or conf.keepup then check(dict_salve_def) end
-- have nada?
if not next(prios) then return false end
-- otherwise, do the highest!
if not sync_mode then
doaction(dict[getHighestKey(prios)].salve) else
return dict[getHighestKey(prios)].salve end
end
-- herb check
-- build a table of all the things we need to do with their priority numbers,
-- sort it, and do the topmost thing.
check_herb = function(sync_mode)
-- can we even eat?
if not bals.herb or usingbal("herb") or affs.sleep
or affs.stun or affs.unconsciousness or sacid or affs.anorexia
or (conf.aillusion and conf.waitherbai and sk.checking_herb_ai()) then
return
end
-- get all prios in the list
local prios = {}
local function check (what)
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.herb and j.p.herb.isadvisable() and not ignore[i]
-- make sure that we can outrift things, or if we can't, we have the herb in our inventory
and (sys.canoutr or sk.can_eat_for(j.p.herb))
#if skills.healing then
and sk.wont_heal_this(i)
#end
then
prios[i] = (not sync_mode) and j.p.herb.aspriority or j.p.herb.spriority
end
end
end
check(affs)
if sys.deffing or conf.keepup then check(dict_herb) end
-- have nada?
if not next(prios) then return false end
-- otherwise, do the highest!
if not sync_mode then
doaction(dict[getHighestKey(prios)].herb) else
return dict[getHighestKey(prios)].herb end
end
-- misc check
-- build a table of all the things we need to do with their priority numbers,
-- sort it, and do the topmost thing.
-- this is just in case we're checking amnesia only
local amnesias = {
amnesia = {p = dict.amnesia},
fear = {p = dict.fear},
}
check_misc = function(sync_mode, onlyamnesia)
-- we -don't- check for sleep here, but a bit lower down - so waking can be on a misc
if affs.stun or affs.unconsciousness then
return
end
-- get all prios in the list
local prios = {}
local function check(what)
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.misc and j.p.misc.isadvisable() and not ignore[i] and not doingaction (i) and (not affs.sleep or j.p.misc.action_name == "sleep")
#if skills.healing then
and sk.wont_heal_this(i)
#end
then
prios[i] = (not sync_mode) and j.p.misc.aspriority or j.p.misc.spriority
end
end
end
if not onlyamnesia then
check(affs)
check(dict_misc)
if sys.deffing or conf.keepup then check(dict_misc_def) end
else
check(amnesias)
end
-- have nada?
if not next(prios) then return end
-- otherwise, do the highest! Also go down the list in priorities in case you need to dontbatch
if not sync_mode then
local set = index_map(prios)
local highest, lowest = getBoundary(prios)
local dontbatch
for i = highest, lowest, -1 do
if set[i] then
if not dict[set[i]].misc.dontbatch or not dontbatch then
doaction(dict[set[i]].misc)
if dict[set[i]].misc.dontbatch then dontbatch = true end
end
end
end
else
-- otherwise, do the highest!
return dict[getHighestKey(prios)].misc
end
end
local check_for_asthma = {
checkasthma = {p = dict.checkasthma}
}
check_smoke = function(sync_mode)
if not bals.smoke or affs.stun or affs.unconsciousness or affs.sleep or affs.asthma or affs.mucous then
return
end
-- get all prios in the list
local prios = {}
local function check(what)
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.smoke and j.p.smoke.isadvisable() and not ignore[i] and not doingaction(i)
#if skills.healing then
and sk.wont_heal_this(i)
#end
then
prios[i] = (not sync_mode) and j.p.smoke.aspriority or j.p.smoke.spriority
end
end
end
check(affs)
if affsp.asthma then check(check_for_asthma) end
if sys.deffing or conf.keepup then check(dict_smoke_def) end
-- have nada?
if not next(prios) then return end
if not sync_mode then
local set = index_map(prios)
local highest, lowest = getBoundary(prios)
for i = highest, lowest, -1 do
if set[i] then
doaction(dict[set[i]].smoke)
end
end
else
-- otherwise, do the highest!
return dict[getHighestKey(prios)].smoke
end
end
check_moss = function(sync_mode)
-- can we even sip?
if not conf.moss or usingbal("moss") or affs.stun or affs.unconsciousness or not bals.moss
or affs.sleep or affs.anorexia then
return
end
-- get all prios in the list
local prios = {}
local function check(what)
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.moss and j.p.moss.isadvisable() and not ignore[i] then
prios[i] = (not sync_mode) and j.p.moss.aspriority or j.p.moss.spriority
end
end
end
if not conf.secondarymoss then check(healthchecks) end
-- have nada?
if not next(prios) then return end
-- otherwise, do the highest!
if not sync_mode then
doaction(dict[getHighestKey(prios)].moss) else
return dict[getHighestKey(prios)].moss end
end
check_focus = function(sync_mode)
-- can we even focus?
if not next(affs) or usingbal("focus") or affs.stun or affs.unconsciousness or not bals.focus
or affs.sleep or not can_usemana() or not conf.focus or stats.currentwillpower <= 75
or affs.impatience or affs.inquisition or (affs.cadmus and not conf.focuswithcadmus) then
return
end
#if skills.healing then
local wont_heal_this = sk.wont_heal_this
#end
-- get all prios in the list
local prios = {}
for i, j in pairs(affs) do
if not (conf.serverside and serverignore[i]) and j.p.focus and (not affs.cadmus or (conf.focuswithcadmus and me.cadmusaffs[i])) and j.p.focus.isadvisable() and not ignore[i]
#if skills.healing then
and wont_heal_this(i)
#end
then
prios[i] = (not sync_mode) and j.p.focus.aspriority or j.p.focus.spriority
end
end
-- have nada?
if not next(prios) then return end
-- otherwise, do the highest!
if not sync_mode then
doaction(dict[getHighestKey(prios)].focus) else
return dict[getHighestKey(prios)].focus end
end
-- lifevision system
-- if something was added here, that means it was validated via other
-- means already - all we need to do now is to check if we had lifevision
-- catch the line or no.
-- other_action means do something else than default when done
-- arg is the argument to pass either to the default action
-- lineguard is how many lines this should be across - ineffective with vconfig batch
function lifevision.add(what, other_action, arg, lineguard)
lifevision.l:set(what.name, {
p = what,
other_action = other_action,
arg = arg
})
if lineguard and (not sys.lineguard or sys.lineguard > lineguard) then -- remember the smallest one, because if we have two conflicts, the smallest one is most valid
sys.lineguard = lineguard
end
#if DEBUG_lifevision then
debugf("lifevision: %s added with '%s' call (%s)%s", tostring(what.name), other_action and other_action or "default", tostring(arg), (lineguard and " lg: "..lineguard or ""))
#end
if not sys.sync then return end
if actions[what.name] and what.balance ~= "aff" and what.balance ~= "gone" and color_table[conf.slowcurecolour] then
selectCurrentLine()
fg(conf.slowcurecolour)
resetFormat()
deselect()
end
end
-- special: adds something where required, ie, first position in the queue
-- was necessary to have blackout be above everything else so stun AI doesn't slow it down 'till next prompt
function lifevision.addcust(what, where, other_action, arg)
assert(what, "svo.lifevision.addcust wants an argument")
lifevision.l:insert(where, what.name, {
p = what,
other_action = other_action,
arg = arg
})
#if DEBUG_lifevision then
debugf("lifevision: %s added (pos %d) with '%s' call (%s)", tostring(what.name), where, other_action and other_action or "default", tostring(arg))
#end
end
-- returns the current lineguard that's set or nil
function lifevision.getlineguard()
return sys.lineguard
end
function lifevision.clearlineguard()
sys.lineguard = nil
end
local function run_through_actions()
for i,j in lifevision.l:iter() do
if not sk.stopprocessing then
actionfinished(j.p, j.other_action, j.arg)
else
actionclear(j.p)
end
end
end
function lifevision.validate()
-- take a line off the paragraph_length if the game's curing went off, as it is a "meta" message and shouldn't be counted
local paragraph_length = paragraph_length
if sk.sawcuring() then paragraph_length = paragraph_length - 1 end
-- batch needs to disable lineguard, as commands come at once then. Plus, illusions aren't as prevalent anymore since serverside curing is completely immune to them
if sys.flawedillusion or (not conf.batch and sys.lineguard and paragraph_length > sys.lineguard) then
if sys.not_illusion then
debugf("cancelled illusion")
run_through_actions()
moveCursor(0, getLineNumber()-1)
moveCursor(#getCurrentLine(), getLineNumber())
insertLink(" (!i)", '', (type(sys.not_illusion) == "string" and sys.not_illusion or "Cancelled detected 'illusion' due to script override."))
sys.not_illusion = false
else
debugf("got an illusion")
for i,j in lifevision.l:iter() do
actionclear(j.p)
end
if sys.lineguard and not sys.flawedillusion then
debugf("lifevision.validate: paragraph_length %d, sys.lineguard %d", paragraph_length, sys.lineguard)
moveCursor(0, getLineNumber()-1)
moveCursor(#getCurrentLine(), getLineNumber())
insertLink(" (i)", '', "Ignored this whole illusion because the line(s) present need to be in their own.")
moveCursorEnd()
end
end
sys.flawedillusion, me.haveillusion = false, false
else
run_through_actions()
end
lifevision.l = pl.OrderedMap()
sk.stopprocessing = nil
sys.lineguard = false
end
checkanyaffs = function (...)
local t = {...}
for i=1,#t do
local j = t[i]
if affs[j.name] then
return j end
end
end
-- balanceful check
check_balanceful_acts = function(sync_mode)
if affs.sleep or affs.stun or affs.unconsciousness or not bals.balance or not bals.equilibrium or not bals.rightarm or not bals.leftarm
#if class == "druid" then
or not bals.hydra
#end
then return end
-- get all prios in the list
local prios = {}
local function check(what)
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.physical.balanceful_act and j.p.physical.isadvisable() and not ignore[i] then
prios[i] = (not sync_mode) and j.p.physical.aspriority or j.p.physical.spriority
end
end
end
check(dict_balanceful)
if sys.deffing or conf.keepup then
check(dict_balanceful_def)
end
-- have nada?
if not next(prios) then return false end
-- otherwise, do the highest!
if not sync_mode then
doaction(dict[getHighestKey(prios)].physical) else
return dict[getHighestKey(prios)].physical end
return true
end
-- balanceless check
check_balanceless_acts = function(sync_mode)
if affs.sleep or affs.stun or affs.unconsciousness or not bals.balance or not bals.equilibrium or not bals.rightarm or not bals.leftarm
#if class == "druid" then
or not bals.hydra
#end
then return end
-- get all prios in the list
local prios = {}
local function check(what)
local gotsomething = false
for i, j in pairs(what) do
if not (conf.serverside and serverignore[i]) and j.p.physical.balanceless_act and j.p.physical.isadvisable() and not ignore[i] then
prios[i] = (not sync_mode) and j.p.physical.aspriority or j.p.physical.spriority
gotsomething = true
end
end
return gotsomething
end
check(dict_balanceless)
if sys.deffing or conf.keepup then
check(dict_balanceless_def)
end
-- have nada?
if not next(prios) then return end
-- otherwise, do the highest!
if not sync_mode then
local set = index_map(prios)
local highest, lowest = getBoundary(prios)
for i = highest, lowest, -1 do
if set[i] then
doaction(dict[set[i]].physical)
end
end
else
return dict[getHighestKey(prios)].physical
end
return true
end
local balanceless = balanceless or {}
local balanceful = balanceful or {}
function sk.balance_controller()
if sys.balanceid == sys.balancetick then return end
if not (bals.balance and bals.equilibrium) or (affs.webbed or affs.bound or affs.transfixed or affs.roped or affs.impale or affs.paralysis or affs.sleep) then return end
-- loop through all balanceless functions
for k, f in pairs(balanceless) do
f()
end
-- loop through balanceful actions until we get one that takes bal or eq
local r
for k,f in pairs(balanceful) do
r = f()
if r then
if sys.actiontimeoutid then killTimer(sys.actiontimeoutid) end
if type(r) == "number" then
sys.actiontimeoutid = tempTimer(r, function () sys.balancetick = sys.balancetick + 1; make_gnomes_work() end)
elseif conf.lag and conf.lag == 4 then
-- 24 does it right away!
sys.actiontimeoutid = tempTimer(60*60*23, function () sys.balancetick = sys.balancetick + 1; make_gnomes_work() end)
else
sys.actiontimeoutid = tempTimer(sys.actiontimeout, function () sys.balancetick = sys.balancetick + 1; make_gnomes_work() end)
end
sys.balanceid = sys.balancetick
break
end
end
end
function addbalanceless(name, func)
assert(name and func, "$(sys).addbalanceless: both name and function are required")
assert(type(func) == 'function', "$(sys).addbalanceless: function needs to be an actual function, while you gave it a "..type(func))
balanceless[name] = func
end
function removebalanceless(name)
balanceless[name] = nil
end
function addbalanceful(name, func)
assert(name and func, "$(sys).addbalanceful: both name and function are required")
assert(type(func) == "function", "$(sys).addbalanceful: second argument has to be a function (you gave it a "..type(func)..")")
balanceful[name] = func
end
function removebalanceful(name)
balanceful[name] = nil
end
function clearbalanceful()
balanceful = {}
addbalanceful("svo check do", sk.check_do)
raiseEvent("svo balanceful ready")
end
function clearbalanceless()
balanceless = {}
addbalanceless("svo check dofree", check_dofree)
raiseEvent("svo balanceless ready")
end
tempTimer(0, function ()
raiseEvent("svo balanceless ready")
raiseEvent("svo balanceful ready")
end)
-- svo Got prompt
-- DO WORK!
-- utils
local function find_highest_action(tbl)
local result
local highest = 0
for _,j in pairs(tbl) do
if j.spriority > highest then
highest = j.spriority
result = j
end
end
return result
end
local workload = {check_salve, check_focus, check_sip, check_purgative,
check_smoke, check_herb, check_moss, check_misc,
check_balanceless_acts, check_balanceful_acts}
-- real functions
local function work_slaves_work()
-- in async, ask each bal to do its action
check_misc(false, true) -- amnesia & fear only
check_focus()
check_salve()
check_sip()
check_purgative()
check_smoke()
check_herb()
check_misc() -- fails for amnesia, but works for Priest Healing...
check_moss()
check_balanceless_acts()
-- if the system didn't use bal, let it be used for other things.
if not check_balanceful_acts() and not will_take_balance() then sk.balance_controller() end
-- serverside prios: eat, apply, smoke, focus
end
make_gnomes_work_async = function()
if conf.paused then return end
signals.sysdatasendrequest:block(cnrl.processusercommand)
if conf.commandecho and (conf.commandechotype == "fancy" or conf.commandechotype == "fancynewline") then
send = fancysend
-- insert expandAlias (used in dofree, dor and similar) into the current batch, breaking the batch up in the process
local oldexpandAlias = expandAlias
if conf.batch then
expandAlias = function(command, show)
sendc({ func = oldexpandAlias, args = {command, show} })
end
end
work_slaves_work()
-- commands are echoed by fancysendall() in onpromptr() in case of a prompt from the game, otherwise echo them right away if from a forced make_gnomes_work()
if not sk.processing_prompt then fancysendall() end
send = oldsend
if conf.batch then
expandAlias = oldexpandAlias
end
else
work_slaves_work()
end
signals.sysdatasendrequest:unblock(cnrl.processusercommand)
end
make_gnomes_work_sync = function()
sk.syncdebug = false
if conf.paused or sacid then return end
signals.sysdatasendrequest:block(cnrl.processusercommand)
-- if we're already doing an action that is not of an "waitingfor" type, don't do anything!
-- logic: if next returns nil,
local result
for balance,actions in pairs(bals_in_use) do
if balance ~= "waitingfor" and balance ~= "gone" and balance ~= "aff" and next(actions) then result = select(2, next(actions)) break end
end
if result then
#if DEBUG then
debugf("doing %s, quitting for now", result.name)
#end
sk.syncdebug = string.format("[%s]: Currently doing: %s", getTimestamp(getLineCount()):trim(), result.name)
signals.sysdatasendrequest:unblock(cnrl.processusercommand)
return
end
sk.gnomes_are_working = true
local action_list = {}
result = false
--... check for all bals.
-- in sync, only return values
for i,j in pairs(workload) do
result = j(true)
if result then action_list[result.name] = result end
end
local actions = pl.tablex.keys(action_list)
table.sort(actions, function(a,b)
return action_list[a].spriority > action_list[b].spriority
end)
sk.syncdebug = string.format('[%s]: Feasible actions we\'re currently considering doing (in order): %s', getTimestamp(getLineCount()):trim(), (not next(action_list) and '(none)' or concatand(actions)))
-- nothing to do =)
if not next(action_list) then
sk.gnomes_are_working = false
signals.sysdatasendrequest:unblock(cnrl.processusercommand)
return
end
if conf.commandecho and conf.commandechotype == "fancy" then
send = fancysend
local oldbatch = conf.batch
conf.batch = false
doaction(find_highest_action(action_list))
-- commands are echoed by fancysendall() in onpromptr() in case of a prompt from the game, otherwise echo them right away if from a forced make_gnomes_work()
if not sk.processing_prompt then fancysendall() end
send = oldsend
conf.batch = oldbatch
else
doaction(find_highest_action(action_list))
end
sk.gnomes_are_working = false
signals.sysdatasendrequest:unblock(cnrl.processusercommand)
end
-- default is async
signals.aeony:connect(function()
if sys.sync then
make_gnomes_work = make_gnomes_work_sync
else
make_gnomes_work = make_gnomes_work_async
end
end)
sk.checkaeony()
signals.aeony:emit()
function send_in_the_gnomes()
-- at first, deal with lifevision.
lifevision.validate()
signals.after_lifevision_processing:emit()
make_gnomes_work()
end
function update_rift_view()
local status, msg = pcall(function () mm_create_riftlabel() end)
if not status then error(msg) end
end
-- retrieve all lines until the last prompt, not including it
function sk.getuntilprompt()
-- lastpromptnumber would include the prompt, -1 doesn't
return getLines(lastpromptnumber+1, getLastLineNumber("main"))
end
function sk.makewarnings()
sk.warnings = {
lowwillpower = {
time = 30,
msg = "Warning: your <253,63,73>willpower is too low"..getDefaultColor().."! Need to regen some - otherwise you can't fight well (no clot, focus, and so on)."
},
somewhatreavable = {
time = 10,
msg = "Warning: you have two humours - an Alchemists <253,63,73>Reave"..getDefaultColor().." will take 10s",
},
nearlyreavable = {
time = 5,
msg = "Warning: you have three humours - an Alchemists <253,63,73>Reave"..getDefaultColor().." will take 8s",
},
reavable = {
time = 5,
msg = "Warning: you have all four humours - an Alchemists <253,63,73>Reave"..getDefaultColor().." will only take 4s",
},
dismemberable = {
time = 5,
msg = "Warning: you're bound and impaled - you can be instakilled! (dismember)"
},
cantclotmana = {
time = 10,
msg = "Going temporarily pause clotting your mana bleeding, your health is below corruptedhealthmin"
},
golemdestroyable = {
time = 5,
msg = "Warning: your flesh is melting - you can be instakilled! (golem destroy)"
},
pulpable = {
time = 5,
msg = "Warning: prone and serious concussion - you can be installed! (pulp)"
},
badaeon = {
time = 5,
msg = function()
echof("Warning: your aeon situation is looking bad, you might want to %swalk out%s",
(not conf.blockcommands and '' or "tsc off and "),
(conf.org == "Ashtan" and " and ask for an empress") or
(conf.org == "Targossas" and " and ask for a deliver") or
(conf.org == "Cyrene" and " and ask for a deliver") or
""
)
end
}
}
if conf.curemethod == "transonly" then
sk.warnings.noelmid = {
time = 20,
msg = "Warning: need to use your <31,31,153>cinnabar"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.novalerianid = {
time = 20,
msg = "Warning: need to use your <31,31,153>realgar"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.noskullcapid = {
time = 20,
msg = "Warning: need to use your <31,31,153>malachite"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.emptyvalerianpipe = {
time = 10,
msg = "Warning: need to refill your <31,31,153>realgar"..getDefaultColor().." pipe and it's empty! Don't chase balance for a bit",
}
sk.warnings.emptyvalerianpipenorefill = {
time = 10,
msg = "Warning: need to refill your <31,31,153>realgar"..getDefaultColor().." pipe, it's empty, but can't due to blocking afflictions :(",
}
elseif conf.curemethod == "preferconc" then
sk.warnings.noelmid = {
time = 20,
msg = "Warning: need to use your <31,31,153>elm"..getDefaultColor().."/<31,31,153>cinnabar"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.novalerianid = {
time = 20,
msg = "Warning: need to use your <31,31,153>valerian"..getDefaultColor().."/<31,31,153>realgar"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.noskullcapid = {
time = 20,
msg = "Warning: need to use your <31,31,153>skullcap"..getDefaultColor().."/<31,31,153>malachite"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.emptyvalerianpipe = {
time = 10,
msg = "Warning: need to refill your <31,31,153>valerian"..getDefaultColor().."/<31,31,153>realgar"..getDefaultColor().." pipe and it's empty! Don't chase balance for a bit",
}
sk.warnings.emptyvalerianpipenorefill = {
time = 10,
msg = "Warning: need to refill your <31,31,153>valerian"..getDefaultColor().."/<31,31,153>realgar"..getDefaultColor().." pipe, it's empty, but can't due to blocking afflictions :(",
}
elseif conf.curemethod == "prefertrans" then
sk.warnings.noelmid = {
time = 20,
msg = "Warning: need to use your <31,31,153>cinnabar"..getDefaultColor().."/<31,31,153>elm"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.novalerianid = {
time = 20,
msg = "Warning: need to use your <31,31,153>realgar"..getDefaultColor().."/<31,31,153>valerian"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.noskullcapid = {
time = 20,
msg = "Warning: need to use your <31,31,153>malachite"..getDefaultColor().."/<31,31,153>skullcap"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.emptyvalerianpipe = {
time = 10,
msg = "Warning: need to refill your <31,31,153>realgar"..getDefaultColor().."/<31,31,153>valerian"..getDefaultColor().." pipe and it's empty! Don't chase balance for a bit",
}
sk.warnings.emptyvalerianpipenorefill = {
time = 10,
msg = "Warning: need to refill your <31,31,153>realgar"..getDefaultColor().."/<31,31,153>valerian"..getDefaultColor().." pipe, it's empty, but can't due to blocking afflictions :(",
}
else
sk.warnings.noelmid = {
time = 20,
msg = "Warning: need to use your <31,31,153>elm"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.novalerianid = {
time = 20,
msg = "Warning: need to use your <31,31,153>valerian"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.noskullcapid = {
time = 20,
msg = "Warning: need to use your <31,31,153>skullcap"..getDefaultColor().." pipe and you don't have one!",
}
sk.warnings.emptyvalerianpipe = {
time = 10,
msg = "Warning: need to refill your <31,31,153>valerian"..getDefaultColor().." pipe and it's empty! Don't chase balance for a bit",
}
sk.warnings.emptyvalerianpipenorefill = {
time = 10,
msg = "Warning: need to refill your <31,31,153>valerian"..getDefaultColor().." pipe, it's empty, but can't due to blocking afflictions :(",
}
end
end
signals.systemstart:add_post_emit(sk.makewarnings)
signals.orgchanged:add_post_emit(sk.makewarnings)
signals.curemethodchanged:connect(sk.makewarnings)