-
Notifications
You must be signed in to change notification settings - Fork 0
/
magic.cmd
278 lines (228 loc) · 9.6 KB
/
magic.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
include libmaster.cmd
action var lastSpellBackfired 1 when ^Your spell.*backfire
action (expMods) var debuffSkills %debuffSkills|$2 when ^--(\d+)\(\d+%\) (.*?) \(\d+ effective ranks\)
###############################
### INIT
###############################
#if (!($char.magic.train.charge.Augmentation > 0)) then gosub doneNoVars
#if (!($char.magic.train.charge.Utility > 0)) then gosub doneNoVars
#if (!($char.magic.train.charge.Warding > 0)) then gosub doneNoVars
#if ("$charactername" = "Qizhmur") then put #tvar char.magic.train.charge.Utility 1
var noLoop 0
if_1 then {
if ("%1" = "noLoop") then {
var noLoop 1
}
}
var lastSpellBackfired 0
var magic.skills Augmentation|Warding|Utility
# TODO: Expand this to not be specific to Utility and Rite of Contrition
if ($char.magic.train.cyclic.Utility = 1) then {
#var magic.skills Augmentation|Warding
}
if ($char.magic.train.revSorcery = 1) then {
#var magic.skills Warding
}
eval magic.length count("%magic.skills", "|")
if (!($magic.index > -1)) then put #tvar magic.index 0
if ($SpellTimer.Regenerate.active != 1 && $SpellTimer.RiteofContrition.active != 1) then gosub release cyclic
if ($SpellTimer.RiteofContrition.active = 1 || $SpellTimer.RiteofGrace.active = 1) then gosub release cyclic
###############################
### MAIN
###############################
loop:
if ($SpellTimer.RiteofGrace.active = 1) then gosub release cyclic
if ($char.magic.train.useAlmanac = 1) then {
gosub almanac.onTimer
}
if ($char.magic.train.usePray = 1) then gosub pray.onTimer $char.magic.train.prayTarget
if ("$guild" = "Empath" && $Empathy.LearningRate < 30) then gosub percHealth.onTimer
if ($Attunement.LearningRate < 33) then gosub perc.onTimer
if ($Appraisal.LearningRate < 33) then gosub appraise.onTimer
if ($lib.magicInert = 1) then {
if (%messageInert != 1) then {
put #echo >Log [magic] Inert! Waiting for it to recover
var messageInert 1
}
pause 5
goto loop
} else {
var messageInert 0
}
if ($Arcana.LearningRate < 33 && $concentration = 100) then {
if ($SpellTimer.EyesoftheBlind.active = 1) then gosub release eotb
if ($SpellTimer.RefractiveField.active = 1) then gosub release rf
if ($hidden = 1) then gosub shiver
gosub gaze my sanowret crystal
}
if ($char.magic.train.usePom = 1 && ($SpellTimer.PersistenceofMana.active != 1 || $SpellTimer.PersistenceofMana.duration < 3)) then gosub runScript cast pom
if ("$guild" = "Moon Mage") then {
if ($Astrology.LearningRate < 31) then gosub observe.onTimer
if ($Astrology.LearningRate < 25) then gosub runScript predict
}
if ("$guild" = "Moon Mage" && $char.magic.train.useShadowling = 1) then {
if ($SpellTimer.Shadowling.active = 0 || $SpellTimer.Shadowling.duration < 5) then {
gosub release shadowling
gosub runScript cast shadowling
}
}
if ("$guild" = "Moon Mage" && $char.magic.train.useServant = 1) then {
if ($SpellTimer.ShadowServant.active = 0 || $SpellTimer.ShadowServant.duration < 5) then {
gosub release servant
}
}
if ($char.magic.train.revSorcery = 1) then {
if ($SpellTimer.Revelation.active != 1) then {
var shouldCastRev 1
if ($Sorcery.LearningRate > 33 && $Augmentation.LearningRate > 33 && $Utility.LearningRate > 33) then var shouldCastRev 0
if ($mana < 80) then var shouldCastRev 0
if (%shouldCastRev = 1) then {
var debuffSkills null
action (expMods) on
put exp mods
pause 2
action (expMods) off
#if (!contains("%debuffSkills", "Sorcery")) then {
gosub release cyclic
#gosub runScript cast rev
gosub invoke tattoo
gosub waitForPrep
gosub cast
#}
}
} else {
var shouldReleaseRev 0
if ($mana < 60) then var shouldReleaseRev 1
if ($Sorcery.LearningRate > 33 && $Augmentation.LearningRate > 33 && $Utility.LearningRate > 33) then var shouldReleaseRev 1
if (!($char.cast.cyclic.lastCastGametime.rev > -1)) then put #tvar char.cast.cyclic.lastCastGametime.rev 1
evalmath nextCastRevGametime (300 + $char.cast.cyclic.lastCastGametime.rev)
if (%nextCastRevGametime < $gametime) then var shouldReleaseRev 1
if (%shouldReleaseRev = 1) then gosub release rev
}
}
if ($char.magic.train.cyclic.Utility = 1) then {
var shouldCastRoc 1
if ($SpellTimer.RiteofContrition.active = 1) then var shouldCastRoc 0
if ($mana < 90) then var shouldCastRoc 0
if ($Utility.LearningRate > 20) then var shouldCastRoc 0
if (%shouldCastRoc = 1) then {
if ($char.magic.train.cyclic.useSymbiosis = 1) then gosub prep symbiosis
gosub prep $char.magic.train.cyclic.spell.Utility $char.magic.train.cyclic.prep.Utility
gosub waitForPrep $char.magic.train.minPrepTime.Utility
gosub cast
}
if ($SpellTimer.RiteofContrition.active = 1) then {
var shouldReleaseRoc 0
evalmath nextCastCyclicGametime (300 + $char.cast.cyclic.lastCastGametime.roc)
if (%nextCastCyclicGametime < $gametime) then var shouldReleaseRoc 1
if ($mana < 70) then var shouldReleaseRoc 1
if ($Utility.LearningRate > 29) then var shouldReleaseRoc 1
if (%shouldReleaseRoc = 1) then gosub release roc
}
}
gosub findMinLearnRate
var skill %magic.skills($magic.index)
if ($%skill.LearningRate < 34) then {
if ($preparedspell != None) then gosub release spell
var lastSpellBackfired 0
if ($char.magic.train.useSymbiosis = 1) then gosub prep symbiosis
gosub prep $char.magic.train.spell.%skill $char.magic.train.prep.%skill
if ($char.wornCambrinth != 1) then {
gosub remove my $char.cambrinth
if ("$righthand" = "Empty") then {
gosub get my $char.cambrinth
}
}
gosub charge my $char.cambrinth $char.magic.train.charge.%skill
if ($char.magic.train.useInvokeSpell = 1) then {
gosub invoke my $char.cambrinth $char.magic.train.charge.%skill spell
} else {
gosub invoke my $char.cambrinth $char.magic.train.charge.%skill
}
if ($char.magic.train.harness.%skill > 0) then gosub harness $char.magic.train.harness.%skill
if ($char.wornCambrinth <> 1) then {
gosub wear my $char.cambrinth
if ("$righthand" <> "Empty") then {
gosub get my $char.cambrinth
}
}
gosub waitForPrep $char.magic.train.minPrepTime.%skill
gosub waitForConcentration $char.magic.train.minimumConcentration
if ($SpellTimer.Shear.active = 1 || $SpellTimer.Shear.duration > 0) then gosub release shear
if ("$char.magic.train.spell.%skill" = "col") then {
gosub checkMoons
if ($moon = null) then {
put #echo >log #FF0000 [magic] NO MOON AVAILABLE for Cage of Light!
goto done
}
gosub cast $moon
} else {
gosub cast
}
if ("%lastSpellBackfired" = "1") then {
put #echo >Log lastSpellBackfired = 1, reducing %skill
if ($lib.symbiosis = 1) then {
gosub release symbiosis
}
evalmath tmp ($char.magic.train.charge.%skill - 1)
put #tvar char.magic.train.charge.%skill %tmp
put #tvar char.magic.train.lastBackfireGametime.%skill $gametime
}
if ($SpellTimer.Shear.active = 1 || $SpellTimer.Shear.duration > 0) then gosub release shear
}
gosub waitForMana 80
pause .5
if (%noLoop = 1 && $Warding.LearningRate > 32 && $Utility.LearningRate > 32 && $Augmentation.LearningRate > 32) then goto done
if (%lastSpellBackfired = 1) then gosub magic.waitForBacklash
goto loop
findMinLearnRate:
put #tvar magic.index 0
var minLearnRateIndex 0
findMinLearnRateLoop:
if ($%magic.skills($magic.index).LearningRate < $%magic.skills(%minLearnRateIndex).LearningRate) then {
var minLearnRateIndex $magic.index
}
evalmath tmp ($magic.index + 1)
put #tvar magic.index %tmp
if ($magic.index > %magic.length) then {
put #tvar magic.index %minLearnRateIndex
return
}
goto findMinLearnRateLoop
magic.waitForBacklash:
magic.waitForBacklashLoop:
gosub checkForBacklashDebuff
if ($lib.backlashDebuff = 1) then {
put #echo >Log [magic] Still waiting for backlash to wear off...
if (%magic.sleepingForBacklash != 1) then {
put awake
pause .5
put sleep
pause .5
put sleep
var magic.sleepingForBacklash 1
}
pause 60
goto magic.waitForBacklashLoop
}
if (%magic.sleepingForBacklash != 0) then {
put awake
pause .5
var magic.sleepingForBacklash 0
}
return
doneNoVars:
echo CHARACTER GLOBALS AREN'T SET!
exit
done:
if ("$righthandnoun" = "$char.cambrinth") then {
if ($char.wornCambrinth <> 1) then {
gosub wear my $char.cambrinth
if ("$righthand" <> "Empty") then {
gosub stow my $char.cambrinth
}
}
}
pause .2
put #parse MAGIC DONE
exit