-
Notifications
You must be signed in to change notification settings - Fork 0
/
scribe.mac
322 lines (267 loc) · 12.7 KB
/
scribe.mac
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
| scribe.mac - Sym 9.4.2012
| Updated 11.18.2012
| Buys all available spells and tomes for specified level range (default is level 1 to current level) if a merchant window is open
| It will not buy lower rank spells than you already have. If you have a rk. ii spell it will not buy a rk. i of the same name, but would buy a rk. iii if it was available.
| when finished buying, or if no window open it scribes every available spell/tome found in inventory (regardless of level range given)
|
| It will now loop and keep buying/scribing if you run out of inventory space before you run out of spells to buy.
|
|
| Usage: /mac scribe minlevel maxlevel
|
| /mac scribe 10 20
| ^^ This will buy all spells/tomes from levels 10 to 20 from the current merchant
|
| /mac scribe
| ^^ This will buy all spells/tomes from level 1 to your current level from the current merchant
|
| /mac scribe 30
| ^^ This will buy all spells/tomes from level 30 to your current level from the current merchant
|
#event FullInventory "#*#Your inventory appears full!#*#"
#event NotGold "#*#you do not have at least a gold membership#*#"
#event WrongDiety "#*#You do not worship#*#"
Sub Main
/declare HasVoA int outer 1
/declare InvScribeSlot int outer 1
/declare MyDeity string outer ${Me.Deity}
/declare MaxInvSlots int outer 10
/declare MinLevel int outer 1
/declare MaxLevel int outer ${Me.Level}
/declare DoLoop int outer 0
/declare mName string outer
/if (${Param0}) /varset MinLevel ${Param0}
/if (${Param1}) /varset MaxLevel ${Param1}
:Start
/varset DoLoop 0
/if (${Merchant.Open}) {
/varset mName ${Merchant.Name}
/echo Buying all ${Me.Class} spells/tomes for levels ${MinLevel} to ${MaxLevel}
/if (!${Select[${Me.Class.ShortName},CLR,DRU,SHM,ENC,WIZ,MAG,NEC]}) /call BuyTomes
/if (!${Select[${Me.Class.ShortName},WAR,BER,MNK,ROG]}) /call BuySpells
/delay 2s
}
/if (${Merchant.Open}) {
/notify MerchantWnd MW_Done_Button leftmouseup
/delay 1s !${Merchant.Open}
}
/if (!${Select[${Me.Class.ShortName},CLR,DRU,SHM,ENC,WIZ,MAG,NEC]}) /call ScribeTomes
/if (!${Select[${Me.Class.ShortName},WAR,BER,MNK,ROG]}) /call ScribeSpells
/if (${DoLoop}) {
/target ${mName}
/delay 2s ${Target.ID}
/click right target
/delay 1s
/goto :Start
}
/return
Sub BuySpells
/if (!${Merchant.Open}) /return
/delay 2s
/if (!${Merchant.Items}) /return
/declare a int local
/declare b int local
/declare c int local
/declare SpellName string local
/for a 1 to ${Merchant.Items}
/if (!${Me.FreeInventory}) /return
/if (!${Merchant.Open}) /return
/varset c 0
/varset SpellName ${Merchant.Item[${a}].Spell.Name}
/if (${SpellName.Find[ Rk. II ]}) /varset SpellName ${Merchant.Item[${a}].Spell.Name.Replace[ Rk. II ,]}
/if (${SpellName.Find[ Rk. III ]}) /varset SpellName ${Merchant.Item[${a}].Spell.Name.Replace[ Rk. III ,]}
/if (${Merchant.Item[${a}].Type.Equal[Scroll]} && ${Merchant.Item[${a}].Spell.Level} >= ${MinLevel} && ${Merchant.Item[${a}].Spell.Level} <= ${MaxLevel} && ${Math.Calc[${Merchant.Item[${a}].BuyPrice}\1000]} < ${Me.Platinum} && !${Me.Book[${Merchant.Item[${a}].Spell.Name}]} && !${FindItemCount[${Merchant.Item[${a}]}]}) {
/if (${Me.CombatAbility[${SpellName}]}) {
/e :: I already know ${SpellName}
/next a
}
/if (${FindItemCount[${Merchant.Item[${a}]}]}) {
/e :: I already have ${Merchant.Item[${a}]} in inventory
/next a
}
/if (${Me.CombatAbility[${SpellName} Rk. II]} || ${FindItemCount[${Merchant.Item[${a}]} Rk. II]}) {
/e :: Skipping lower rank of ${SpellName}
/next a
}
/if (${Me.CombatAbility[${SpellName} Rk. III]} || ${FindItemCount[${Merchant.Item[${a}]} Rk. III]}) {
/e :: Skipping lower rank of ${SpellName}
/next a
}
/if (${Merchant.Item[${a}].Deities} && ${MyDeity.NotEqual[${Merchant.Item[${a}].Deity[1]}]}) {
/e Unable to use ${SpellName} because of deity
/next a
}
/if (${Me.Book[${SpellName} Rk. II]} || ${FindItemCount[${SpellName} Rk. II]}) {
/e Skipping lower rank of ${SpellName}
/next a
}
/if (${Me.Book[${SpellName} Rk. III]} || ${FindItemCount[${SpellName} Rk. III]}) {
/e Skipping lower rank of ${SpellName}
/next a
}
| this loop is needed because the merchant item number doesn't match up to the interface line number
/for b 1 to ${Window[MerchantWnd].Child[MW_ItemList].Items}
/if (${Window[MerchantWnd].Child[MW_ItemList].List[${b},2].Equal[${Merchant.Item[${a}]}]}) /varset c ${b}
/next b
| merchant line number matches what we are looking to buy, buy 1 copy of it
/if (${c}) {
/echo Buying ${Window[MerchantWnd].Child[MW_ItemList].List[${c},2]}
/notify MerchantWnd MW_ItemList listselect ${c}
/nomodkey /ctrlkey /notify MerchantWnd MW_Buy_Button leftmouseup
/delay 1s
/doevents
}
}
/next a
/return
Sub ScribeSpells
/declare Bag int local
/declare Slot int local
/if (${Cursor.ID}) /autoinv
/for Bag 1 to ${MaxInvSlots}
/if (${InvSlot[pack${Bag}].Item.Container}) {
/if (!${Window[Pack${Bag}].Open}) /itemnotify pack${Bag} rightmouseup
/delay 1s ${Window[Pack${Bag}].Open}
/for Slot 1 to ${InvSlot[pack${Bag}].Item.Container}
/if (${InvSlot[pack${Bag}].Item.Item[${Slot}].Type.Equal[Scroll]} && ${InvSlot[pack${Bag}].Item.Item[${Slot}].Spell.Level} <= ${Me.Level} && !${Me.Book[${InvSlot[pack${Bag}].Item.Item[${Slot}].Spell.Name}]}) {
/nomodkey /ctrlkey /itemnotify in pack${Bag} ${Slot} leftmouseup
/delay 1s ${Cursor.ID}
/if (${Cursor.ID}) /call doScribe
}
/next Slot
/if (${Window[Pack${Bag}].Open}) /itemnotify pack${Bag} rightmouseup
} else {
/if (${InvSlot[pack${Bag}].Item.Type.Equal[Scroll]} && ${InvSlot[pack${Bag}].Item.Spell.Level} <= ${Me.Level} && !${Me.Book[${InvSlot[pack${Bag}].Item.Spell.Name}]}) {
/nomodkey /ctrlkey /itemnotify ${InvSlot[pack${Bag}]} leftmouseup
/delay 1s ${Cursor.ID}
/if (${Cursor.ID}) /call doScribe
}
}
/next Bag
/if (${Window[SpellBookWnd].Open}) /squelch /windowstate SpellBookWnd close
/return
Sub doScribe
/declare a int local 1
/declare BookPage int local
/declare BookSlot int local
/declare tOut timer
| find first available open spellbook slot, minus 1 in case last scribe was an overwrite
/varcalc a ${a} - 1
:NeedSlot
/varcalc a ${a} + 1
/if (${Me.Book[${a}].ID}) /goto :NeedSlot
/varset BookPage ${Math.Calc[${a} / 8].Int}
| no ceil() function, fake it
/if (${Math.Calc[${a} / 8]} > ${Math.Calc[${a} / 8].Int}) /varcalc BookPage ${BookPage} + 1
/varset BookSlot ${Math.Calc[${a} % 8].Int}
/if (${Math.Calc[${BookPage} % 2]} == 0) {
/if (${BookSlot} == 0) {
/varset BookSlot 16
} else {
/varcalc BookSlot ${BookSlot} + 8
}
} else {
/if (${BookSlot} == 0) /varset BookSlot 8
}
/varset tOut 5s
/echo Scribing ${Cursor.Spell.Name} to page ${BookPage}
/book ${BookPage}
/delay 2
/varcalc BookSlot ${BookSlot} - 1
/notify SpellBookWnd SBW_Spell${BookSlot} leftmouseup
:WaitFinished
/if (${Window[ConfirmationDialogBox].Open} && ${Window[ConfirmationDialogBox].Child[CD_TextOutput].Text.Find[${Cursor.Spell.Name} will replace]}) /notify ConfirmationDialogBox Yes_Button leftmouseup
/if (!${tOut}) /autoinv
/delay 2
/doevents
/if (${Cursor.ID}) /goto :WaitFinished
/return
Sub BuyTomes
/if (!${Merchant.Open}) /return
/delay 2s
/if (!${Merchant.Items}) /return
/declare a int local
/declare b int local
/declare c int local
/declare SpellName string local
/for a 1 to ${Merchant.Items}
/if (!${Me.FreeInventory}) /return
/varset c 0
/varset SpellName ${Merchant.Item[${a}].Spell.Name}
/if (${SpellName.Find[ Rk. II ]}) /varset SpellName ${Merchant.Item[${a}].Spell.Name.Replace[ Rk. II ,]}
/if (${SpellName.Find[ Rk. III ]}) /varset SpellName ${Merchant.Item[${a}].Spell.Name.Replace[ Rk. III ,]}
|/e Item ${a} is ${Merchant.Item[${a}].Spell.Name}
/if (${Merchant.Item[${a}].Type.Equal[Scroll]} && ${Merchant.Item[${a}].Spell.Level} >= ${MinLevel} && ${Merchant.Item[${a}].Spell.Level} <= ${MaxLevel} && ${Math.Calc[${Merchant.Item[${a}].BuyPrice}\1000]} < ${Me.Platinum}) {
/if (${Me.CombatAbility[${SpellName}]}) {
/e :: I already know ${SpellName}
/next a
}
/if (${FindItemCount[${Merchant.Item[${a}]}]}) {
/e :: I already have ${Merchant.Item[${a}]} in inventory
/next a
}
/if (${Me.CombatAbility[${SpellName} Rk. II]} || ${FindItemCount[${Merchant.Item[${a}]} Rk. II]}) {
/e :: Skipping lower rank of ${SpellName}
/next a
}
/if (${Me.CombatAbility[${SpellName} Rk. III]} || ${FindItemCount[${Merchant.Item[${a}]} Rk. III]}) {
/e :: Skipping lower rank of ${SpellName}
/next a
}
| this loop is needed because the merchant item number doesn't match up to the interface line number
/for b 1 to ${Window[MerchantWnd].Child[MW_ItemList].Items}
/if (${Window[MerchantWnd].Child[MW_ItemList].List[${b},2].Equal[${Merchant.Item[${a}]}]}) /varset c ${b}
/next b
| merchant line number matches what we are looking to buy, buy 1 copy of it
/if (${c}) {
/echo Buying ${Window[MerchantWnd].Child[MW_ItemList].List[${c},2]}
/notify MerchantWnd MW_ItemList listselect ${c}
/nomodkey /ctrlkey /notify MerchantWnd MW_Buy_Button leftmouseup
/delay 1s
/doevents
}
}
/next a
/return
Sub ScribeTomes
/declare Bag int local
/declare Slot int local
/if (${Cursor.ID}) /autoinv
/if (!${HasVoA} && ${InvSlot[pack${InvScribeSlot}].Item.Type.Equal[Scroll]} && ${InvSlot[pack${InvScribeSlot}].Item.Spell.Level} <= ${Me.Level} && !${Me.Book[${InvSlot[pack${InvScribeSlot}].Item.Spell.Name}]}) /nomodkey /ctrlkey /itemnotify ${InvSlot[pack${InvScribeSlot}]} rightmouseup
/for Bag 1 to ${MaxInvSlots}
/if (${InvSlot[pack${Bag}].Item.Container}) {
/if (!${Window[Pack${Bag}].Open}) /itemnotify pack${Bag} rightmouseup
/delay 1s ${Window[Pack${Bag}].Open}
/for Slot 1 to ${InvSlot[pack${Bag}].Item.Container}
/if (${InvSlot[pack${Bag}].Item.Item[${Slot}].Name.Find[Tome]} && ${InvSlot[pack${Bag}].Item.Item[${Slot}].Type.Equal[Scroll]} && ${InvSlot[pack${Bag}].Item.Item[${Slot}].Spell.Level} <= ${Me.Level} && !${Me.Book[${InvSlot[pack${Bag}].Item.Item[${Slot}].Spell.Name}]}) {
/if (${HasVoA}) {
/nomodkey /ctrlkey /itemnotify in pack${Bag} ${Slot} rightmouseup
/delay 1s !${InvSlot[pack${Bag}].Item.Item[${Slot}].ID}
} else {
/nomodkey /ctrlkey /itemnotify in pack${Bag} ${Slot} leftmouseup
/delay 1s ${Cursor.ID}
/nomodkey /ctrlkey /itemnotify ${InvSlot[pack${InvScribeSlot}]} leftmouseup
/delay 1s !${Cursor.ID}
/nomodkey /ctrlkey /itemnotify ${InvSlot[pack${InvScribeSlot}]} rightmouseup
/delay 1s !${InvSlot[pack${InvScribeSlot}].ID}
}
}
/next Slot
}
/if (${Window[Pack${Bag}].Open}) /itemnotify pack${Bag} rightmouseup
/next Bag
/if (${Cursor.ID}) /autoinv
/return
sub Event_NotGold
/autoinv
/return
sub Event_WrongDiety
/autoinv
/return
sub Event_FullInventory
/if (${Merchant.Open}) {
/notify MerchantWnd MW_Done_Button leftmouseup
/delay 1s !${Merchant.Open}
}
/varset DoLoop 1
/return