-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstudy.mod
More file actions
355 lines (326 loc) · 7.74 KB
/
study.mod
File metadata and controls
355 lines (326 loc) · 7.74 KB
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
skilllistre=rex.new("^(?<skill>[^<]+?)(<(?<levelmax>.*)){0,1}(\\((?<study>[[:alpha:]]+){0,1}?(-{0,1}(?<npc>[[:alpha:]]+\\s+[[:alpha:]]+)){0,1}(-{0,1}(?<npcname>[^a-zA-Z1-9 ]+)){0,1}(-{0,1}(?<loc>\\d+)){0,1}\\)){0,1}$")
study={}
study["skill"]=nil
study["ok"]=nil
study["fail"]=nil
checkstudy=function(checkok,checkfail,levelmax)
if needstudy() then
do_study(checkok,checkfail,levelmax)
return true
else
return false
end
end
needstudy=function()
potmax=GetVariable("potmax")
if potmax==nil then
potmax=0
else
potmax=tonumber(potmax)
end
if (potmax>0) and getnum(me.hp.pot)>potmax then
return true
else
return false
end
end
study.levelmax=0
do_study=function(study_ok,study_fail,levelmax)
study["ok"]=study_ok
study["fail"]=study_fail
study.levelmax=getnum(tonumber(levelmax))
if study.skill==nil then
study_end_fail()
return
end
lastpot=0
lastpotcount=0
local levelmax=getnum(study.skill.levelmax)
if study[study.skill.study]~=nil and ((levelmax==0)or(queryskilllv(study.skill.skill)<levelmax))then
study[study.skill.study]()
else
study["end"]("fail")
end
end
study_end_fail=function()
study["end"]("fail")
end
study_end_ok=function()
study["end"]("ok")
end
study["arrive"]=function()
end
study["end2"]=function(s)
setupskill(study.levelmax)
study.levelmax=0
cha()
if ((s~="")and(s~=nil)) then
infoend(study[s])
end
study["ok"]=nil
study["fail"]=nil
end
study["end"]=function(s)
infoend(study["end2"],s)
end
study["xue"]=function()
go(study.skill.loc,study["xuecmd"],study_end_fail)
end
study["xuecmd"]=function()
if (me.hp.pot==0)or((me.hp.neili==0)and(me.hp.neilimax~=0))or(lastpotcount>7) then
study["end"]("ok")
else
if me.hp.pot==lastpot then
lastpotcount=lastpotcount+1
else
lastpot=me.hp.pot
lastpotcount=1
end
if getnum(me.hp.pot)<100 then
pots=me.hp.pot
else
pots=100
end
catch("study","xue "..study.skill.npc.." about "..study.skill.skill.." "..tostring(pots))
eatdrink()
hp()
delay(1,study["xuecmd"])
end
end
study["ask"]=function()
go(study.skill.loc,study["askcmd"],study_end_fail)
end
study["askcmd"]=function()
if (me.hp.pot<100)or((me.hp.neili==0)and(me.hp.neilimax~=0))or(lastpotcount>7) then
study["end"]("ok")
else
if me.hp.pot==lastpot then
lastpotcount=lastpotcount+1
else
lastpot=me.hp.pot
lastpotcount=1
end
catch("study","ask "..study.skill.npc.." about "..study.skill.skill)
eatdrink()
hp()
delay(1,study_end_ok)
end
end
study["jingxiu"]=function()
if me.fam=="武当派" or me.fam=="全真教" then
go(familys[me.fam].dazuoloc,study["jingxiucmd"],study_end_fail)
else
busytest(study_end_fail)
end
end
study["jingxiucmd"]=function()
if (me.hp.pot<10)or((me.hp.neili==0)and(me.hp.neilimax~=0))or(lastpotcount>3) then
study["end"]("ok")
else
if me.hp.pot==lastpot then
lastpotcount=lastpotcount+1
else
lastpot=me.hp.pot
lastpotcount=1
end
if getnum(me.hp.pot)<100 then
pots=me.hp.pot
else
pots=100
end
eatdrink()
run("i")
catch("study","jingxiu "..tostring(pots))
busytest(study["jingxiutest"],4)
end
end
study["jingxiutest"]=function()
hp()
if checkitems(inv,study["jingxiu"],study_end_fail) then
return
else
busytest(study["jingxiucmd"])
end
end
study["closed"]=function()
go(2489,study["closedcmd"],study_end_fail)
end
study["closedcmd"]=function()
if (me.hp.pot==0)or((me.hp.neili==0)and(me.hp.neilimax~=0))or(lastpotcount>3) then
study["end"]("ok")
else
if me.hp.pot==lastpot then
lastpotcount=lastpotcount+1
else
lastpot=me.hp.pot
lastpotcount=1
end
catch("study","closed")
eatdrink()
hp()
busytest(study_end_ok,30)
end
end
study["yanjiu"]=function()
settags()
go(yanjiuloc,study.yanjiucmd,study.yanjiufail)
end
study["yanjiucmd"]=function()
if (me.hp.pot==0)or((me.hp.neili==0)and(me.hp.neilimax~=0))or(lastpotcount>7) then
study["end"]("ok")
else
if me.hp.pot==lastpot then
lastpotcount=lastpotcount+1
else
lastpot=me.hp.pot
lastpotcount=1
end
if getnum(me.hp.pot)<100 then
pots=me.hp.pot
else
pots=100
end
catch("study","yanjiu "..study.skill.skill.." "..tostring(pots))
eatdrink()
hp()
delay(1,study["yanjiucmd"])
end
end
study["yanjiufail"]=function()
go(-2,study.yanjiucmd,study_end_fail)
end
study["lian"]=function()
go(-2,study.liancmd,study_end_fail)
end
study["liancmd"]=function()
if (me.hp.pot<11)or((me.hp.neili==0)and(me.hp.neilimax~=0))or(lastpotcount>7) then
study["end"]("ok")
else
if me.hp.pot==lastpot then
lastpotcount=lastpotcount+1
else
lastpot=me.hp.pot
lastpotcount=1
end
if getnum(me.hp.pot)<50 then
pots=me.hp.pot
else
pots=50
end
eatdrink()
catch("study","lian "..study.skill.skill.." "..tostring(pots))
run("yun recover;yun regenerate; i")
delay(1,study["liantest"])
end
end
study["liantest"]=function()
hp()
if checkitems(inv,study["lian"],study_end_fail) then
elseif checkrest(study["lian"],study_end_fail) then
else
busytest(study["liancmd"])
end
end
getdefalutstudy=function()
if study.skill.npc~=false or study.skill.npcname~=false then
return "xue"
else
if getnum(tonumber(GetVariable("expmax")))<800000 then
return "xue"
else
return "yanjiu"
end
end
end
getskillloc=function()
if study.skill.study=="xue" then
return study.skill.loc
end
end
getskill=function(str)
s,e,t=skilllistre:match(str)
return t
end
splitre=rex.new("([^;,|]+)")
setupskill=function(levelmax)
if levelmax==nil then
levelmax=study.levelmax
end
skilllist=GetVariable("skilllist")
if skilllist==nil then skilllist="" end
study["skill"]={}
_skilllist={}
local i=0
n=splitre:gmatch(skilllist,function (m, t)
study["skill"]=getskill(m)
if study["skill"]~=nil then
if study.skill.levelmax==false then
study.skill.levelmax=levelmax
else
study.skill.levelmax=getnum(tonumber(study.skill.levelmax))
end
if study.skill.skill=="jingxiu" then
study.skill.loc=0
study.skill.npc=""
study.skill.study="jingxiu"
study.skill.skill="taoism"
elseif study.skill.skill=="closed" then
study.skill.loc=0
study.skill.npc=""
study.skill.study="closed"
else
if study.skill.study==false then study.skill.study=getdefalutstudy() end
if study.skill.npc~=false then
if npcs[study.skill.npc]==nil then
study.skill.npc=false
end
end
if study.skill.loc==false then study.skill.loc=0 end
if study.skill.npc==false then
if npcs[study.skill.npcname]~=nil then
study.skill.npc=npcs[study.skill.npcname].id
end
end
if study.skill.npc==false then
if me.fam~=nil then
if me.score.teacher~="none" and me.score.teacher~=nil then
if npcs[me.score.teacher]~=nil then
study.skill.npc=npcs[me.score.teacher].id
end
end
end
end
if study.skill.npc==false then
study.skill.npc=""
else
study.skill.loc=npcs[study.skill.npc]["loc"]
end
end
end
if (study.skill.levelmax==0)or(queryskilllv(study.skill.skill)<study.skill.levelmax) then
i=i+1
_skilllist[i]=study.skill
end
end)
if i==0 then
study.skill=nil
_skilllist=nil
else
study.skill=_skilllist[math.random(1,i)]
end
end
study_fail=function(n,l,w)
lastpotcount=8
end
study_needweapon=function(n,l,w)
weapon(3)
end
study_gold=function(n,l,w)
if studygodnpc[w[2]]~=nil then
run("give 1 gold to "..studygodnpc[w[2]])
end
end
studygodnpc={}
studygodnpc["朱熹"]="zhu xi"
studygodnpc["厨娘"]="chu niang"
studygodnpc["戚长发"]="qi changfa"