-
Notifications
You must be signed in to change notification settings - Fork 0
/
fightwithmagic.cmd
1566 lines (1290 loc) · 57.1 KB
/
fightwithmagic.cmd
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
####################################################################################################
# .fight
# Selesthiel - Justin Doyle - [email protected]
# 2020/05/07
#
# USAGE
# .fight
#
# DEPENDENCIES: libsel.cmd, cast.cmd, loot.cmd
####################################################################################################
include var_mobs.cmd
include libmaster.cmd
include args.cmd
####################################################################################################
# CONFIG
####################################################################################################
var opts %1
var ammo.Crossbow $char.fight.ammo.Crossbow
var ammo.Bow $char.fight.ammo.Bow
var ammo.Sling $char.fight.ammo.Sling
var arrangeForPart $char.fight.arrangeForPart
var arrangeFull $char.fight.arrangeFull
var useArmor $char.fight.useArmor
var avoidDivineOutrage $char.fight.avoidDivineOutrage
var debil.use $char.fight.debil.use
var debil.spell $char.fight.debil.spell
var debil.prepAt $char.fight.debil.prepAt
var forceDebil $char.fight.forceDebil
var forceShield $char.fight.forceShield
var lootType $char.fight.lootType
var necroRitual $char.fight.necroRitual
var opts $char.fight.opts
var tmSpell $char.fight.tmSpell
var tmPrep $char.fight.tmPrep
var tmPause $char.fight.tmPause
var weapons.items $char.fight.weapons.items
var weapons.skills $char.fight.weapons.skills
var useAlmanac $char.fight.useAlmanac
var useAppraise $char.fight.useAppraise
var useBuffs $char.fight.useBuffs
var useHunt $char.fight.useHunt
var usePerc $char.fight.usePerc
var useSanowret $char.fight.useSanowret
var useSkin $char.fight.useSkin
var useStealth $char.fight.useStealth
var useCol $char.fight.useCol
var useMaf $char.fight.useMaf
var useObserve $char.fight.useObserve
var useSeer $char.fight.useSeer
var useShadowling $char.fight.useShadowling
var useShadows $char.fight.useShadows
var useShw $char.fight.useShw
var useSls $char.fight.useSls
var useTksh $char.fight.useTksh
var useCh $char.fight.useCh
var useIvm $char.fight.useIvm
var usePhp $char.fight.usePhp
var useQe $char.fight.useQe
var useUsol $char.fight.useUsol
####################################################################################################
var attacks
var doAnalyze 1
var lastAnalyzeTime 0
var nextHuntAt 0
var nextAppAt 0
var nextPercAt 0
var nextRogCastAt 0
var weapons.index 0
eval weapons.length count("%weapons.skills", "|")
var weapons.lastChangeAt 0
var weapons.targetLearningRate 5
var weapons.lastChangeAt $gametime
var armor.index 0
var armor.lastChangeAt 0
var armor.targetLearningRate 5
var stances.list shield|parry
var stances.skills Shield_Usage|Parry_Ability
var stances.targetLearningRate 5
eval stances.length count("%stances.list", "|")
var stances.index 0
var skillsToUseShield Crossbow|Slings|Bow|Twohanded_Blunt|Twohanded_Edged
var debilConditions sleeping|immobilized|writhing|webbed|stunned
action var doAnalyze 1 when ^Utilizing \S+ tactics
action var doAnalyze 0; var attacks $2 when ^(Balance reduction|Armor reduction|A chance for a stun) can be inflicted.* by landing (.*)
action var doAnalyze 1 when ^You can no longer see openings
action var doAnalyze 1 when You fail to find any
action var doAnalyze 1 when ^ then lies still\.$
#action put get my scimitar;put get my assassin blade;put get my sword when ^Wouldn't it be better if you used a melee weapon
var forceNextWeaponTactics 0
action var forceNextWeaponTactics 1 when ^Wouldn't it be better if you used a melee weapon
action send circle when ^Analyze what
action goto newBundle when ^Where did you intend to put that\? You don't have any bundles or they're all full or too tightly packed!
timer start
# Sometimes fails to get crossbow? Not sure, hack fix for now. - JD, 4/1/21
action send get %weapons.items(%weapons.index); send remove %weapons.items(%weapons.index); send load when ^You need to hold the.*in your right hand to load it.
action var useHunt 0 when ^You find yourself unable to hunt in this area.
action var useCollect 0 when any collecting efforts would be futile\.$
action var noAmmo 1 when ^You don't have the proper ammunition readily available
action var dissectFail 1 when You'll gain no insights from this attempt\.$
action send swap when ^You must hold the.*in order to throw it\.$
var communeMeraudActive 0
action var communeMeraudActive 1 when ^Meraud's power still holds your attention\.$
put #trigger {^You are now set to use your (\S+) stance} {#var lastStanceGametime \$gametime;#var stance \$1} {stance}
put #trigger {e/\$stance/} {#statusbar 7 Stance: \$stance} {stance}
action (expMods) var debuffSkills %debuffSkills|$2 when ^--(\d+)\(\d+%\) (.*?) \(\d+ effective ranks\)
###############################
### init
###############################
init:
put #class combat on
gosub awake
gosub sortWeaponSkillsByRank
gosub sortWeaponSkillsByLearningRate
put #echo >Debug [fight] LearningRate ord: %weapons.skills
var weapons.lowestLearningRateIndex 0
## Start with the weapon with the lowest learning rate
initLoop:
# Start with the weapon specified by the command line args, if present
eval args.startWeapon replace("%args.startWeapon", " ", "_")
if ("%weapons.skills(%weapons.index)" = "%args.startWeapon") then {
var weapons.lowestLearningRateIndex %weapons.index
goto initContinue
}
if ($%weapons.skills(%weapons.index).LearningRate < $%weapons.skills(%weapons.lowestLearningRateIndex).LearningRate) then {
var weapons.lowestLearningRateIndex %weapons.index
}
math weapons.index add 1
if (%weapons.index <= %weapons.length) then goto initLoop
goto initContinue
initContinue:
var weapons.index %weapons.lowestLearningRateIndex
var weapons.targetLearningRate $%weapons.skills(%weapons.index).LearningRate
math weapons.targetLearningRate add 5
if (%weapons.targetLearningRate > 34) then var weapons.targetLearningRate 34
put #unvar stance
goto loop
###############################
### loop
###############################
loop:
if ($standing != 1) then gosub stand
gosub releaseUnwantedSpells
gosub checkWeaponSkills
gosub checkStances
if (%useArmor = 1) then gosub checkArmorSkills
gosub prepNextSpell
gosub checkDeadMob
if ($char.loot.boxes = 1) then {
gosub runScript loot --boxes=1
} else {
gosub runScript loot
}
gosub manageCyclics
gosub buffs
gosub fight.observe
gosub huntApp
if ("$char.fight.usePray" = "1") then gosub pray.onTimer $char.fight.prayTarget
if (%useAlmanac = 1) then gosub almanac.onTimer
if (%useSanowret = 1 && $Arcana.LearningRate < 31 && $concentration = 100) then gosub gaze my sanowret crystal
if ($char.fight.useCommuneMeraud = 1) then {
if (!(%lastCommuneMeraudGametime > -1)) then var lastCommuneMeraudGametime 1
evalmath timeSinceLastCommune ($gametime - %lastCommuneMeraudGametime)
if ($Theurgy.LearningRate < 2 && %timeSinceLastCommune > 300) then {
gosub commune sense
if (%communeMeraudActive != 1) then gosub runScript commune --deity=meraud
var lastCommuneMeraudGametime $gametime
}
}
if ($char.fight.useTarantula = 1) then gosub fight.tarantula
# Use numMobs so that we can subtract non-combat "pets" (ex: dirt construct, shadow servant, etc.)
var numMobs $monstercount
if (contains("$roomobjs", (dirt construct)) then math numMobs subtract 1
if (contains("$roomobjs", (Shadow Servant)) then math numMobs subtract 1
if (contains("$roomobjs", (shadowling)) then math numMobs subtract 1
var attackContinue 1
if (%attackContinue = 1 && %numMobs = 0) then {
if (%useCollect != 0) then {
gosub collect dirt
} else {
pause 4
}
if (contains("$roomobjs", "a pile of")) then {
gosub kick pile
}
var attackContinue 0
}
if (%attackContinue = 1 && %numMobs = 1 && ($Evasion.LearningRate = 0 || $Parry_Ability.LearningRate = 0 || $Shield_Usage.LearningRate = 0 )) then {
gosub attack circle
gosub attack bob
var attackContinue 0
}
if (%attackContinue = 1 && %numMobs > 0) then {
var continue = 1
if (%continue = 1 && ("%weapons.skills(%weapons.index)" = "Targeted_Magic" || "%weapons.skills(%weapons.index)" = "Sorcery")) then {
gosub attackTm
var continue 0
}
if (%continue = 1 && "%weapons.skills(%weapons.index)" = "Light_Thrown" || "%weapons.skills(%weapons.index)" = "Heavy_Thrown") then {
gosub attackThrownWeapon
var continue 0
}
if (%continue = 1 && ("%weapons.skills(%weapons.index)" = "Crossbow" || "%weapons.skills(%weapons.index)" = "Bow" || "%weapons.skills(%weapons.index)" = "Slings")) then {
gosub attackCrossbow
var continue 0
}
if (%continue = 1 && "%weapons.skills(%weapons.index)" = "Offhand_Weapon") then {
if ("$lefthandnoun" != "nightstick") then {
if ("$righthandnoun" = "nightstick") then {
gosub swap
} else {
gosub stow right
gosub get nightstick
gosub swap
}
}
gosub debil
gosub attack slice left
var continue 0
}
if (%continue = 1) then {
#gosub analyze
if (evalmath($gametime - %lastAnalyzeTime) > 60) then {
gosub analyze
var lastAnalyzeTimeAt $gametime
}
if (%doAnalyze = 0) then gosub attackAnalyzed
}
var attackContinue 0
}
goto loop
###############################
### attackAnalyzed
###############################
attackAnalyzed:
eval attacks replace("%attacks", " and", ",")
eval attacks replace("%attacks", "a ", "")
eval attacks replace("%attacks", "an ", "")
eval attacks replace("%attacks", ",", "|")
eval attacks replace("%attacks", ".", "")
eval attacks replace("%attacks", " ", "")
eval length count("%attacks", "|")
var index 0
gosub debil
gosub checkHide
var doOffhand 0
var offhandWeapons Small_Edged|Small_Blunt|Staves|Heavy_Thrown|Light_Thrown
if ($char.fight.trainOffhand = 1 && $Offhand_Weapon.LearningRate < 32 && $Offhand_Weapon.LearningRate <= $%weapons.skills(%weapons.index).LearningRate) then {
if (matchre("%weapons.skills(%weapons.index)", "(%offhandWeapons)")) then var doOffhand 1
if (%doOffhand = 1 && "$lefthand" = "Empty") then gosub swap
}
attackLoop:
if (%doOffhand = 1) then {
if (%doOffhand = 1 && "$lefthand" = "Empty") then gosub swap
gosub attack %attacks(%index) left
} else {
gosub attack %attacks(%index)
}
math index add 1
if (%index > %length) then goto attackAnalyzedDone
goto attackLoop
attackAnalyzedDone:
if (%doOffhand = 1 && "$lefthand" != "Empty") then gosub swap
return
###############################
### attackCrossbow
###############################
attackCrossbow:
var crossbowRetreat 0
gosub stance shield
if ("%weapons.skills(%weapons.index)" = "Crossbow") then {
var ammo $char.fight.ammo.Crossbow
}
if ("%weapons.skills(%weapons.index)" = "Bow") then {
var ammo $char.fight.ammo.Bow
}
if ("%weapons.skills(%weapons.index)" = "Slings") then {
var ammo $char.fight.ammo.Slings
}
if %crossbowRetreat = 1 then gosub retreat
gosub load my %weapons.items(%weapons.index) with my %ammo
if (%noAmmo = 1) then return
if %crossbowRetreat = 1 then gosub retreat
gosub aim
gosub debil
if (%crossbowRetreat = 1) then {
gosub retreat
pause 2
gosub retreat
pause 2
gosub retreat
pause 2
} else {
var tmpAimPause $char.fight.aimPauseMin
if (!(%tmpAimPause > -1)) then var tmpAimPause 4
# Assume casting a debilitation spell takes 7 seconds (4 to prep and pause, 3 second RT to cast)
if (matchre("$monsterlist", "(%debilConditions)")) then {
evalmath tmpAimPause (%tmpAimPause - 7)
}
if (%tmpAimPause < 1) then var tmpAimPause 1
gosub attackCrossbow.aimPause %tmpAimPause
#pause %tmpAimPause
#pause 4
}
gosub cast
gosub checkHide
gosub fire
if ("%ammo" = "matte sphere") then gosub stow matte sphere
return
attackCrossbow.aimPause:
var tmpAimPause $1
matchre return ^You think you have your best shot possible now\.$
matchwait %tmpAimPause
return
###############################
### attackThrownWeapon
###############################
attackThrownWeapon:
if ("%weapons.items(%weapons.index)" != "Empty") then { # Empty thrown weapons means using throwing blades
if ("$righthand" != "%weapons.items(%weapons.index)" ) then {
gosub stow right
gosub stow left
gosub stow my %weapons.items(%weapons.index)
gosub get my %weapons.items(%weapons.index)
}
gosub debil
gosub checkHide
var doOffhand 0
var offhandWeapons Small_Edged|Small_Blunt|Staves|Heavy_Thrown|Light_Thrown
if ($char.fight.trainOffhand = 1 && $Offhand_Weapon.LearningRate < 32 && $Offhand_Weapon.LearningRate <= $%weapons.skills(%weapons.index).LearningRate) then {
if (matchre("%weapons.skills(%weapons.index)", "(%offhandWeapons)")) then {
var doOffhand 1
}
}
var throwCommand throw
if (%doOffhand = 1) then var throwCommand throw left
#if ("$righthandnoun" = "bola" || "$righthandnoun" = "hammer" || "$righthandnoun" = "hhr'ata" || "$righthandnoun" = "pan" || "$righthandnoun" = "wand" || "$righthandnoun" = "naphtha") then {
var fight.throwableItems bola|hammer|hhr'ata|pan|wand|naphtha|cuska
if (matchre("$righthandnoun", "(%fight.throwableItems)")) then {
if (%doOffhand = 1 && "$lefthand" = "Empty") then gosub swap
gosub attack %throwCommand
gosub get %weapons.items(%weapons.index)
if (%doOffhand = 1 && "$lefthand" = "Empty") then gosub swap
gosub attack %throwCommand
gosub get %weapons.items(%weapons.index)
} else {
gosub attack lob
gosub get %weapons.items(%weapons.index)
gosub attack lob
gosub get %weapons.items(%weapons.index)
}
if ("$righthand" != "%weapons.items(%weapons.index)" ) then {
if ("$lefthand" = "%weapons.items(%weapons.index)") then {
gosub swap
} else {
gosub get my %weapons.items(%weapons.index)
}
}
} else {
if (!contains("$righthand", "throwing blade")) then gosub stow right
gosub get throwing blades
gosub debil
gosub checkHide
gosub attack throw
if ("$righthand" != "Empty") then {
gosub attack throw
}
}
return
###############################
### attackTm
###############################
attackTm:
if ($mana > 80) then {
gosub target %tmSpell %tmPrep
gosub checkHide
pause %tmPause
gosub cast
} else {
gosub attack circle
pause 2
}
return
###############################
### buffs
###############################
buffs:
if (%useBuffs = 0) then return
if ($mana < 30) then return
# GENERAL
if ($char.fight.useMaf = 1 && ($SpellTimer.ManifestForce.active = 0 || $SpellTimer.ManifestForce.duration < 3)) then {
gosub runScript cast maf noCast
return
}
# CLERIC
if ($char.fight.useOm = 1 && $SpellTimer.OsrelMeraud.active = 1 && $SpellTimer.OsrelMeraud.duration < 50) then {
gosub runScript cast om orb
return
}
if ($char.fight.useMf = 1 && $SpellTimer.MurrulasFlames.active != 1) then {
gosub runScript cast mf
return
}
if ($char.fight.useAuspice = 1 && ($SpellTimer.Auspice.active != 1 || $SpellTimer.Auspice.duration < 3)) then {
gosub runScript cast auspice
return
}
if ($char.fight.useBenediction = 1 && ($SpellTimer.Benediction.active != 1 || $SpellTimer.Benediction.duration < 2)) then {
if (%buffCheckAgain = 1) then {
gosub runScript cast benediction
var buffCheckAgain 0
} else {
var buffCheckAgain 1
}
return
}
if ($char.fight.usePom = 1 && $SpellTimer.PersistenceofMana.active = 1 && $SpellTimer.PersistenceofMana.duration < 5)) then {
gosub runScript cast pom
return
}
if ($char.fight.useCentering = 1 && ($SpellTimer.Centering.active != 1 || $SpellTimer.Centering.duration < 3)) then {
gosub runScript cast centering
return
}
if ($char.fight.useGg = 1 && ($SpellTimer.GlythidesGift.active != 1 || $SpellTimer.GlythidesGift.duration < 3)) then {
gosub runScript cast gg
return
}
if ($char.fight.useMapp = 1 && ($SpellTimer.MajorPhysicalProtection.active != 1 || $SpellTimer.MajorPhysicalProtection.duration < 3)) then {
gosub runScript cast mapp
return
}
if ($char.fight.useMpp = 1 && ($SpellTimer.MinorPhysicalProtection.active != 1 || $SpellTimer.MinorPhysicalProtection.duration < 3)) then {
gosub runScript cast mpp
return
}
if ($char.fight.usePfe = 1 && ($SpellTimer.ProtectionfromEvil.active != 1 || $SpellTimer.ProtectionfromEvil.duration < 3)) then {
gosub runScript cast pfe
return
}
if ($char.fight.useSap = 1 && ($SpellTimer.SanctifyPattern.active != 1 || $SpellTimer.SanctifyPattern.duration < 2)) then {
gosub runScript cast sap debilitation
return
}
if ($char.fight.useSol = 1 && ($SpellTimer.ShieldofLight.active != 1 || $SpellTimer.ShieldofLight.duration < 2)) then {
if (%buffCheckAgain = 1) then {
gosub runScript cast sol
var buffCheckAgain 0
} else {
var buffCheckAgain 1
}
return
}
# MOON MAGE
if ($char.fight.useSeer = 1 && ($SpellTimer.SeersSense.active = 0 || $SpellTimer.SeersSense.duration < 3)) then {
gosub runScript cast seer noCast
return
}
if ($char.fight.useCol = 1 && ($SpellTimer.CageofLight.active = 0 || $SpellTimer.CageofLight.duration < 3)) then {
gosub buffCol
return
}
if ($char.fight.useShadowling = 1 && $SpellTimer.Shadowling.active = 0) then {
gosub runScript cast shadowling noCast
return
}
if ($char.fight.useShadows = 1 && ($SpellTimer.Shadows.active = 0 || $SpellTimer.Shadows.duration < 2)) then {
gosub runScript cast shadows noCast
return
}
if ($char.fight.useTksh = 1 && ($SpellTimer.TelekineticShield.active = 0 || $SpellTimer.TelekineticShield.duration < 2)) then {
gosub runScript cast tksh noCast
return
}
# NECROMANCER
if ($char.fight.usePhp = 1 && %avoidDivineOutrage != 1 && ($SpellTimer.PhilosophersPreservation.active != 1 || $SpellTimer.PhilosophersPreservation.duration < 3)) then {
gosub runScript cast php
return
}
if ($char.fight.useObf = 1 && ($SpellTimer.Obfuscation.active != 1 || $SpellTimer.Obfuscation.duration < 2)) then {
gosub runScript cast obf
return
}
if ($char.fight.useCh = 1 && %avoidDivineOutrage != 1 && ($SpellTimer.CalcifiedHide.active != 1 || $SpellTimer.CalcifiedHide.duration < 3)) then {
gosub runScript cast ch
return
}
if ($char.fight.useIvm = 1 && %avoidDivineOutrage != 1 && $SpellTimer.IvoryMask.active != 1 && "%weapons.skills(%weapons.index)" = "Targeted_Magic") then {
gosub runScript cast ivm
return
}
if ($char.fight.useQe = 1 && $SpellTimer.QuickentheEarth.active != 1) then {
gosub runScript cast qe
return
}
# PALADIN
if ($char.fight.useSr = 1 && ($SpellTimer.SentinelsResolve.active = 0 || $SpellTimer.SentinelsResolve.duration < 3)) then {
gosub runScript cast sr noCast
return
}
# RANGER
if ($char.fight.useInst = 1 && ($SpellTimer.Instinct.active != 1 || $SpellTimer.Instinct.duration < 2)) then {
gosub runScript cast inst
return
}
if ($char.fight.useStw = 1 && $SpellTimer.SeetheWind.active = 0) then {
gosub runScript cast stw
return
}
# TRADER
if ($char.fight.useLgv = 1 && ($SpellTimer.LastGiftofVithwokIV.active = 0 || $SpellTimer.LastGiftofVithwokIV.duration < 3)) then {
gosub runScript cast lgv noCast
return
}
# WARRIOR MAGE
if ($char.fight.useSuf = 1 && ($SpellTimer.SureFooting.active = 0 || $SpellTimer.SureFooting.duration < 3)) then {
gosub runScript cast suf noCast
return
}
return
###############################
### buffCol
###############################
buffCol:
if ($Time.isKatambaUp = 1) then {
put .cast col katamba
waitforre ^CAST DONE
return
}
if ($Time.isXibarUp = 1) then {
put .cast col xibar
waitforre ^CAST DONE
return
}
if ($Time.isYavashUp = 1) then {
put .cast col yavash
waitforre ^CAST DONE
return
}
return
###############################
### checkArmorSkills
###############################
checkArmorSkills:
if (!(%armorIndex > -1)) then var armorIndex 0
var tmpArmorSkill $char.fight.armor.skill.%armorIndex
if (!($char.fight.lastArmorSwapGametime > -1)) then put #tvar char.fight.lastArmorSwapGametime 1
evalmath fight.tmp.nextArmorSwapGametime ($char.fight.lastArmorSwapGametime + 300)
if ($%tmpArmorSkill(0).LearningRate >= %armor.targetLearningRate && (%armor.targetLearningRate < 34 || $gametime > %fight.tmp.nextArmorSwapGametime)) then {
put #echo >Log [fight] Swap armor %tmpArmorSkill $%tmpArmorSkill(0).LearningRate / 34
gosub checkArmorSkills.removeArmor $char.fight.armor.items.%armorIndex
math armorIndex add 1
if (contains("$char.fight.armor.skill.%armorIndex", "char.fight.armor")) then var armorIndex 0
var tmpArmorSkill $char.fight.armor.skill.%armorIndex
gosub checkArmorSkills.wearArmor $char.fight.armor.items.%armorIndex
evalmath armor.targetLearningRate ($%tmpArmorSkill.LearningRate + 5)
if (%armor.targetLearningRate > 34) then var armor.targetLearningRate 34
put #tvar char.fight.lastArmorSwapGametime $gametime
}
put #statusbar 8 Armor: %tmpArmorSkill $%tmpArmorSkill(0).LearningRate/%armor.targetLearningRate
unvar tmpArmorSkill
unvar fight.tmp.nextArmorSwapGametime
return
checkArmorSkills.removeArmor:
var armorItems $0
var tmpRemoveArmorIndex 0
checkArmorSkills.removeArmor.loop:
gosub retreat
gosub remove my %armorItems(%tmpRemoveArmorIndex)
gosub stow my %armorItems(%tmpRemoveArmorIndex)
math tmpRemoveArmorIndex add 1
if (%tmpRemoveArmorIndex > count("%armorItems", "|")) then {
unvar armorItems
unvar tmpRemoveArmorIndex
return
}
goto checkArmorSkills.removeArmor.loop
checkArmorSkills.wearArmor:
var armorItems $0
var tmpWearArmorIndex 0
checkArmorSkills.wearArmor.loop:
gosub retreat
gosub get my %armorItems(%tmpWearArmorIndex)
gosub wear my %armorItems(%tmpWearArmorIndex)
math tmpWearArmorIndex add 1
if (%tmpWearArmorIndex > count("%armorItems", "|")) then {
unvar armorItems
unvar tmpWearArmorIndex
return
}
goto checkArmorSkills.wearArmor.loop
###############################
### checkWeaponSkills
###############################
checkWeaponSkills:
if (%forceNextWeaponTactics = 1) then {
gosub checkWeaponSkills.nextWeapon
var forceNextWeaponTactics 0
}
# TM CYCLICS
if ("%weapons.skills(%weapons.index)" = "Targeted_Magic") then {
# Figure out if we're using a cyclic for TM, and if so, skip over TM
var useTmCyclic 0
if (%useUsol = 1) then var useTmCyclic 1
if (%useSls = 1 && $Time.isDay = 0) then var useTmCyclic 1
if (%useTmCyclic = 1) then gosub checkWeaponSkills.nextWeapon
}
if (%noAmmo = 1 && ("%weapons.skills(%weapons.index)" = "Crossbow" || "%weapons.skills(%weapons.index)" = "Bow" || "%weapons.skills(%weapons.index)" = "Slings")) then {
put #echo >Debug #DD6601 NO AMMO FOR %weapons.skills(%weapons.index)
gosub checkWeaponSkills.nextWeapon
var noAmmo 0
}
evalmath timeSinceLastWeaponChange ($gametime - %weapons.lastChangeAt)
#if ($%weapons.skills(%weapons.index).LearningRate >= %weapons.targetLearningRate || %timeSinceLastWeaponChange > 300) then {
if ($%weapons.skills(%weapons.index).LearningRate >= %weapons.targetLearningRate || %timeSinceLastWeaponChange > 240) then {
gosub checkWeaponSkills.nextWeapon
}
# Make sure we use shield stance for weapons we can't parry with (ex: crossbow, sling, bows)
if (matchre("%weapons.skills(%weapons.index)", "(%skillsToUseShield)")) then {
gosub stance shield
}
# Some items have three words in the short, this is a hardcoded correction for some
var handItem $righthand
if ("%handItem" = "white ironwood nightstick") then var handItem white nightstick
# Switch out whatever we have for the correct weapon
if ("%handItem" != "%weapons.items(%weapons.index)") then {
gosub stow right
gosub stow left
if ("%weapons.items(%weapons.index)" != "Empty" && "%weapons.skills(%weapons.index)" != "Targeted_Magic" && "%weapons.skills(%weapons.index)" != "Sorcery") then {
gosub get my %weapons.items(%weapons.index)
if ("$righthand" = "Empty") then gosub remove my %weapons.items(%weapons.index)
if ($char.fight.useBless = 1) then {
gosub checkStances
gosub prep bless
# For ranged weapons, bless the ammo, not the weapon
var blessTarget none
if ("%blessTarget" = "none" && "%weapons.skills(%weapons.index)" = "Crossbow") then var blessTarget $char.fight.ammo.Crossbow
if ("%blessTarget" = "none" && "%weapons.skills(%weapons.index)" = "Bow") then var blessTarget $char.fight.ammo.Bow
if ("%blessTarget" = "none" && "%weapons.skills(%weapons.index)" = "Slings") then var blessTarget $char.fight.ammo.Slings
if ("%blessTarget" = "none") then var blessTarget %weapons.items(%weapons.index)
gosub cast my %blessTarget
unvar blessTarget
}
} else {
# Bless self for brawling
if ($char.fight.useBless = 1 && ($SpellTimer.Bless.active !=1 || $SpellTimer.Bless.duration < 3)) then {
gosub prep bless
gosub charge my $char.cambrinth 5
gosub invoke my $char.cambrinth 5
gosub cast
}
}
}
if ("%weapons.items(%weapons.index)" = "bastard sword" || "%weapons.items(%weapons.index)" = "flamewood riste") then gosub checkWeaponSkills.swapWeapon
if ("%weapons.skills(%weapons.index)" = "Crossbow" && $char.fight.wornCrossbow = 1) then gosub remove my %weapons.items(%weapons.index)
put #statusbar 6 Weapon: %weapons.skills(%weapons.index) $%weapons.skills(%weapons.index).LearningRate/%weapons.targetLearningRate
return
###############################
### checkWeaponSkills.nextWeapon
###############################
checkWeaponSkills.nextWeapon:
var logMsg [fight] %weapons.skills(%weapons.index) ($%weapons.skills(%weapons.index).LearningRate/%weapons.targetLearningRate) ->
math weapons.index add 1
if (%weapons.index > %weapons.length) then {
var weapons.index 0
# Use findLowestLearningRate to always do lowest + 5
#gosub checkWeaponSkills.findLowestLearningRate
#evalmath weapons.targetLearningRate (5 + %findLowestLearningRate.result)
evalmath weapons.targetLearningRate (%weapons.targetLearningRate + 5)
if (%weapons.targetLearningRate > 34) then var weapons.targetLearningRate 34
put #echo >Debug #cc99ff [fight] findLowestLearningRate %findLowestLearningRate.result -- weapons.targetLearningRate %weapons.targetLearningRate
}
var weapons.lastChangeAt $gametime
if ($%weapons.skills(%weapons.index).LearningRate = 0) then var logMsg #FF0000 %logMsg
var logMsg %logMsg %weapons.skills(%weapons.index) ($%weapons.skills(%weapons.index).LearningRate/%weapons.targetLearningRate)
put #echo >Debug %logMsg
return
###############################
### checkWeaponSkills.findLowestLearningRate
###############################
checkWeaponSkills.findLowestLearningRate:
var findLowestLearningRate.result 9999
var index 0
checkWeaponSkills.findLowestLearningRate.loop:
if ($%weapons.skills(%index).LearningRate < %findLowestLearningRate.result) then var findLowestLearningRate.result $%weapons.skills(%index).LearningRate
math index add 1
if (%index > %weapons.length) then return
goto checkWeaponSkills.findLowestLearningRate.loop
###############################
### checkWeaponSkills.swapWeapon
###############################
checkWeaponSkills.swapWeapon:
if ("%weapons.skills(%weapons.index)" = "Large_Edged" && "%weapon_hand" != "he") then {
gosub swap my %weapons.items(%weapons.index)
goto checkWeaponSkills.swapWeapon
}
if ("%weapons.skills(%weapons.index)" = "Twohanded_Edged" && "%weapon_hand" != "The") then {
gosub swap my %weapons.items(%weapons.index)
goto checkWeaponSkills.swapWeapon
}
if ("%weapons.skills(%weapons.index)" = "Large_Blunt" && "%weapon_hand" != "hb") then {
gosub swap my %weapons.items(%weapons.index)
goto checkWeaponSkills.swapWeapon
}
if ("%weapons.skills(%weapons.index)" = "Twohanded_Blunt" && "%weapon_hand" != "Thb") then {
gosub swap my %weapons.items(%weapons.index)
goto checkWeaponSkills.swapWeapon
}
return
##
# Trains shield and parry in 5s
# Assumes, all other things being equal, that shield stance is preferable
##
###############################
### checkStances
###############################
checkStances:
#if ($health < 90 || "%weapons.skills(%weapons.index)" = "Crossbow" || "%weapons.skills(%weapons.index)" = "Slings" || "%weapons.skills(%weapons.index)" = "Bow" || "%weapons.skills(%weapons.index)" = "Twohanded_Blunt" || "$righthandnoun" = "crossbow" || "$righthandnoun" = "latchbow" || "$righthandnoun" = "lockbow" || $Parry_Ability.LearningRate > 32 || %forceShield = 1) then {
if ($health < 90 || $Parry_Ability.LearningRate > 32 || %forceShield = 1 || matchre("%weapons.skills(%weapons.index)", "(%skillsToUseShield)")) then {
var stances.index 0
} else {
if ($%stances.skills(%stances.index).LearningRate > %stances.targetLearningRate) then {
if (!($lastStanceGametime > -1)) then put #var lastStanceGametime 0
evalmath timeSinceLastStance ($gametime - $lastStanceGametime)
#delay conditions: currently in shield, shield and parry are over 32, lessthan 300s timeSinceLastStance
if (%stances.skills(%stances.index) = "shield" && %timeSinceLastStance < 300 && $Shield_Usage.LearningRate > 32 && $Parry_Ability.LearningRate > 32) then {
return
}
math stances.index add 1
if (%stances.index > %stances.length) then {
var stances.index 0
evalmath stances.targetLearningRate (5 + $%stances.skills(%stances.index).LearningRate)
if (%stances.targetLearningRate > 32) then var stances.targetLearningRate 32
}
}
}
if ("$stance" != "%stances.list(%stances.index)") then {
gosub stance %stances.list(%stances.index)
}
return
###############################
### checkDeadMob
###############################
checkDeadMob:
if (matchre ("$roomobjs", "(%critters) ((which|that) appears dead|(dead))")) then {
var mobName $1
if (1 = 0 && "$charactername" = "Qizhmur") then {
if ("%mobName" = "basilisk") then {
gosub skin basilisk for part
gosub put my fang in my satchel
}
if ("$righthandnoun" = "hide" || "$lefthandnoun" = "hide") then {
gosub put my hide in my bundle
gosub drop hide
}
gosub loot %mobName %lootType
return
}
if ("$guild" = "Necromancer" && matchre("%ritualcritters", "%mobName")) then {
gosub runScript devour %mobName
gosub performRitual %mobName
}
if (matchre("%skinnablecritters", "%mobName")) then {
#if ($char.fight.useDissect = 1 && $Skinning.LearningRate > $First_Aid.LearningRate && $First_Aid.LearningRate < 33) then {
if ($char.fight.useDissect = 1 && $First_Aid.LearningRate < 33) then {
var dissectFail 0
gosub dissect
if (%dissectFail = 1) then {
echo DISSECT FAILED!
}
}
if (%arrangeForPart = 1) then {
gosub arrange for part
}
if (%arrangeFull = 1) then {
gosub arrange full
}
if (%useSkin = 1) then {
var preSkinRightHand $righthand
gosub skin
var skinType null
if ("%preSkinRightHand" = "Empty" && "$righthand" != "Empty") then var skinType $righthandnoun
if ("%preSkinRightHand" != "Empty" && "$lefthand" != "Empty") then var skinType $lefthandnoun
if ("%skinType" != "null") then gosub makeNewBundle %skinType
}
}
gosub loot %lootType
}
return
###############################
### checkHide
###############################
checkHide:
if (%useStealth = 1 && $Stealth.LearningRate < 33) then gosub hide
return
###############################
### debil
###############################
debil:
var force 0
if ("$1" = "force" || $char.fight.forceDebil = 1) then var force 1
if (%debil.use = 1 && $mana > 80 && (%force = 1 || $Debilitation.LearningRate < 34) && (%force = 1 || !matchre("$monsterlist", "(%debilConditions)"))) then {
gosub prep %debil.spell %debil.prepAt
if (!($char.fight.debilPauseTime > -1)) then put #tvar char.fight.debilPauseTime 4
pause $char.fight.debilPauseTime
gosub cast
}
unvar force
return
###############################
### fight.observe
###############################
fight.observe:
# monstercount is here so that we don't retreat and potentially lose ammunition to a creature leaving the room
#if (%useObserve = 1 && "$predictPool.defens" = "complete") then {
# gosub runScript predict parry
# gosub predict state all
#}
if (%useObserve = 1 && $Astrology.LearningRate < 30 && $monstercount < 4) then gosub runScript observe
#if (%useObserve = 1 && $Astrology.LearningRate < 22 && $monstercount < 4) then gosub runScript predict