-
Notifications
You must be signed in to change notification settings - Fork 5
/
encountEX.lua
340 lines (332 loc) · 12.9 KB
/
encountEX.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
local Module = ModuleBase:createModule('encountEX')
local 不消耗诱魔水 = false--消耗道具开关
local 不消耗驱魔水 = false--消耗道具开关
local ymxs = 900498--诱魔香水
local qmxs = 900497--驱魔香水
local hmxs = 900500--满怪香水
local gmxs = 900501--黄金喷雾
local EnemyTbl = {}
function Module:battleStartEventCallback(battleIndex)
for i=10, 19 do
local enemy = Battle.GetPlayIndex(battleIndex, i)
local player = Battle.GetPlayIndex(battleIndex, 0)
local playerpet = Battle.GetPlayer(battleIndex, 5)
if Char.GetData(player, CONST.CHAR_类型) == CONST.对象类型_人 then
player = player
else
player = playerpet
end
local hmxsnum = Char.ItemNum(player,hmxs)
local gmxsnum = Char.ItemNum(player,gmxs)
if enemy>=0 and hmxsnum >= 1 and gmxsnum == 0 and Char.GetData(enemy, CONST.CHAR_类型) == CONST.对象类型_怪 and Char.GetData(enemy,CONST.对象_战斗状态) ~= CONST.战斗_BOSS战 then
local enemyId = Char.GetData(enemy, CONST.CHAR_ENEMY_ID);
local enemyLv = Char.GetData(enemy,CONST.CHAR_等级);
--local enemyIndex = Data.EnemyGetDataIndex(enemyId)
local cdk = Char.GetData(player,CONST.对象_CDK);
if EnemyTbl[cdk] ~= nill then
local EnemyIdAr = {enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId}
local BaseLevelAr = {enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv}
table.insert(EnemyTbl[cdk],EnemyIdAr);
table.insert(EnemyTbl[cdk],BaseLevelAr);
return EnemyTbl[cdk];
end
elseif enemy>=0 and hmxsnum >= 1 and gmxsnum >= 1 and Char.GetData(enemy, CONST.CHAR_类型) == CONST.对象类型_怪 and Char.GetData(enemy,CONST.对象_战斗状态) ~= CONST.战斗_BOSS战 then
local enemyId = Char.GetData(enemy, CONST.CHAR_ENEMY_ID);
local enemyLv = Char.GetData(enemy,CONST.CHAR_等级);
local cdk = Char.GetData(player,CONST.对象_CDK);
local enemyLv = enemyLv+5;
if EnemyTbl[cdk] ~= nill then
local EnemyIdAr = {enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId, enemyId}
local BaseLevelAr = {enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv, enemyLv}
table.insert(EnemyTbl[cdk],EnemyIdAr);
table.insert(EnemyTbl[cdk],BaseLevelAr);
return EnemyTbl[cdk];
end
end
end
end
function Module:LoginGateEvent(player)
local cdk = Char.GetData(player,CONST.对象_CDK);
Char.SetData(player,%对象_香步数%,0);
Char.SetData(player,%对象_香上限%,0);
Char.SetLoopEvent(nil,'ymloop',player,0);
Char.SetData(player,%对象_不遇敌开关%,0);
Char.SetLoopEvent(nil,'qmloop',player,0);
NLG.UpChar(player);
if EnemyTbl[cdk] ~= nill then
for i,v in ipairs(EnemyTbl[cdk]) do
if ( cdk==v )then
table.remove(EnemyTbl[cdk],i);
EnemyTbl[cdk] = {};
end
end
end
NLG.SystemMessage(player,"自動遇敵、不遇敵、滿怪關閉了!");
return 0;
end
function Module:LogoutEvent(player)
local cdk = Char.GetData(player,CONST.对象_CDK);
Char.SetData(player,%对象_香步数%,0);
Char.SetData(player,%对象_香上限%,0);
Char.SetLoopEvent(nil,'ymloop',player,0);
Char.SetData(player,%对象_不遇敌开关%,0);
Char.SetLoopEvent(nil,'qmloop',player,0);
NLG.UpChar(player);
if EnemyTbl[cdk] ~= nill then
for i,v in ipairs(EnemyTbl[cdk]) do
if ( cdk==v )then
table.remove(EnemyTbl[cdk],i);
EnemyTbl[cdk] = {};
end
end
end
NLG.SystemMessage(player,"自動遇敵、不遇敵、滿怪關閉了!");
return 0;
end
function Module:onLoad()
self:logInfo('load')
self:regCallback('BattleStartEvent', Func.bind(self.battleStartEventCallback, self))
self:regCallback('LoginGateEvent', Func.bind(self.LoginGateEvent, self))
self:regCallback('LogoutEvent', Func.bind(self.LogoutEvent, self))
self:regCallback('LoopEvent', Func.bind(self.ymloop,self))
self:regCallback('ymloop',function(player)
local playeryd = Char.GetData(player,%对象_战斗中%) == 0
local ymxsnum = Char.ItemNum(player,ymxs)
local ymbs = Char.GetData(player,%对象_香步数%)
local hmxsnum = Char.ItemNum(player,hmxs)
local gmxsnum = Char.ItemNum(player,gmxs)
local cdk = Char.GetData(player,CONST.对象_CDK);
if playeryd then
if 不消耗诱魔水 then
Battle.Encount(player, player);
else
if ymbs > 979 then--修改诱魔水持续步数
Char.SetData(player,%对象_香步数%,ymbs-1);
NLG.UpChar(player);
if cdk == EnemyTbl[cdk][1] and EnemyTbl[cdk][2] == nill then
Battle.Encount(player, player);
elseif cdk == EnemyTbl[cdk][1] and hmxsnum > 1 and gmxsnum == 0 then --满怪香水
local PartyNum = Char.PartyNum(player);
if (PartyNum>1) then
for Slot=1,PartyNum do
local TeamPlayer = Char.GetPartyMember(player,Slot);
if Char.GetBattleIndex(player) >= 0 then
return
end
end
Char.DelItem(player,hmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
else
Char.DelItem(player,hmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
end
elseif cdk == EnemyTbl[cdk][1] and hmxsnum > 1 and gmxsnum >= 1 then --满怪香水&黄金喷雾
local PartyNum = Char.PartyNum(player);
if (PartyNum>1) then
for Slot=1,PartyNum do
local TeamPlayer = Char.GetPartyMember(player,Slot);
if Char.GetBattleIndex(player) >= 0 then
return
end
end
Char.DelItem(player,hmxs,1);
Char.DelItem(player,gmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
else
Char.DelItem(player,hmxs,1);
Char.DelItem(player,gmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
end
elseif cdk == EnemyTbl[cdk][1] and hmxsnum == 1 and gmxsnum == 0 then --满怪香水
local PartyNum = Char.PartyNum(player);
if (PartyNum>1) then
for Slot=1,PartyNum do
local TeamPlayer = Char.GetPartyMember(player,Slot);
if Char.GetBattleIndex(player) >= 0 then
return
end
end
Char.DelItem(player,hmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
else
Char.DelItem(player,hmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
end
for i,v in ipairs(EnemyTbl[cdk]) do
if ( cdk==v )then
table.remove(EnemyTbl[cdk],i);
EnemyTbl[cdk] = {};
end
end
elseif cdk == EnemyTbl[cdk][1] and hmxsnum == 1 and gmxsnum >= 1 then --满怪香水&黄金喷雾
local PartyNum = Char.PartyNum(player);
if (PartyNum>1) then
for Slot=1,PartyNum do
local TeamPlayer = Char.GetPartyMember(player,Slot);
if Char.GetBattleIndex(player) >= 0 then
return
end
end
Char.DelItem(player,hmxs,1);
Char.DelItem(player,gmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
else
Char.DelItem(player,hmxs,1);
Char.DelItem(player,gmxs,1);
Battle.PVE(player, player, nil, EnemyTbl[cdk][2], EnemyTbl[cdk][3], nil)
end
for i,v in ipairs(EnemyTbl[cdk]) do
if ( cdk==v )then
table.remove(EnemyTbl[cdk],i);
EnemyTbl[cdk] = {};
end
end
else
local PartyNum = Char.PartyNum(player);
if (PartyNum>1) then
for Slot=1,PartyNum do
local TeamPlayer = Char.GetPartyMember(player,Slot);
if Char.GetBattleIndex(player) >= 0 then
return
end
end
Battle.Encount(player, player);
else
Battle.Encount(player, player);
end
end
NLG.SystemMessage(player,'自動遇敵剩餘'..(ymbs-980)..'步')
else
if ymxsnum > 1 then
Char.SetData(player,%对象_香步数%,998);
Char.DelItem(player,ymxs,1);
Item.UpItem(player,-1);
NLG.UpChar(player);
NLG.SystemMessage(player,'消耗一個怪物餅乾,自動遇敵繼續,還有'..(ymxsnum-1)..'個怪物餅乾。');
local PartyNum = Char.PartyNum(player);
if (PartyNum>1) then
for Slot=1,PartyNum do
local TeamPlayer = Char.GetPartyMember(player,Slot);
if Char.GetBattleIndex(player) >= 0 then
return
end
end
Battle.Encount(player, player);
else
Battle.Encount(player, player);
end
elseif ymxsnum == 1 then
Char.SetData(player,%对象_香步数%,998);
Char.DelItem(player,ymxs,1);
Item.UpItem(player,-1);
NLG.UpChar(player);
NLG.SystemMessage(player,'自動遇敵最後一次生效,請及時補充怪物餅乾!');
local PartyNum = Char.PartyNum(player);
if (PartyNum>1) then
for Slot=1,PartyNum do
local TeamPlayer = Char.GetPartyMember(player,Slot);
if Char.GetBattleIndex(player) >= 0 then
return
end
end
Battle.Encount(player, player);
else
Battle.Encount(player, player);
end
else
Char.SetData(player,%对象_香步数%,0);
Char.SetData(player,%对象_香上限%,0);
Char.SetLoopEvent(nil,'ymloop',player,0);
NLG.SystemMessage(player,'怪物餅乾消耗殆盡,自動遇敵關閉!')
end
end
end
end
end)
self:regCallback('LoopEvent', Func.bind(self.qmloop,self))
self:regCallback('qmloop', function(player)
local qmxsnum = Char.ItemNum(player,qmxs)
if qmxsnum > 1 then
Char.DelItem(player,qmxs,1);
Item.UpItem(player, -1);
NLG.SystemMessage(player,'消耗一瓶大蒜油,不遇敵繼續,還有'..(qmxsnum-1)..'瓶大蒜油。');
elseif qmxsnum == 1 then
Char.DelItem(player,qmxs,1);
Item.UpItem(player,-1);
NLG.SystemMessage(player,'不遇敵最後一次生效,請及時補充大蒜油!');
else
Char.SetData(player,%对象_不遇敌开关%,0);
Char.SetLoopEvent(nil,'qmloop',player,0);
NLG.UpChar(player);
NLG.SystemMessage(player,'大蒜油消耗殆盡,不遇敵關閉!')
end
end)
self:regCallback('TalkEvent', function(player, msg)
local ymxsnum = Char.ItemNum(player,ymxs)
local qmxsnum = Char.ItemNum(player,qmxs)
local cdk = Char.GetData(player,CONST.对象_CDK);
if (msg == "/1" or msg == "、1") then
if EnemyTbl[cdk] == nill then
EnemyTbl[cdk] = {}
table.insert(EnemyTbl[cdk],cdk);
else
for i,v in ipairs(EnemyTbl[cdk]) do
if ( cdk==v )then
table.remove(EnemyTbl[cdk],i);
EnemyTbl[cdk] = {};
end
end
table.insert(EnemyTbl[cdk],cdk);
end
if Char.GetData(player,%对象_不遇敌开关%) == 1 then
NLG.SystemMessage(player,"你正在使用大蒜油,無法使用自動遇敵");
elseif Char.GetData(player,%对象_香步数%) > 0 then
Char.SetData(player,%对象_香步数%,0);
Char.SetData(player,%对象_香上限%,0);
Char.SetLoopEvent(nil,'ymloop',player,0);
NLG.UpChar(player);
NLG.SystemMessage(player,"自動遇敵關閉了!");
elseif 不消耗诱魔水 then
Char.SetData(player,%对象_香步数%,999);
Char.SetData(player,%对象_香上限%,999);
Char.SetLoopEvent(nil,'ymloop',player,10000);
NLG.UpChar(player);
NLG.SystemMessage(player,"自動遇敵開始了,每10秒嘗試一次。");
elseif not 不消耗诱魔水 and ymxsnum > 0 then
Char.SetData(player,%对象_香步数%,999);
Char.SetData(player,%对象_香上限%,999);
Char.SetLoopEvent(nil,'ymloop',player,10000);
Char.DelItem(player,ymxs,1);
Item.UpItem(player,-1);
NLG.UpChar(player);
NLG.SystemMessage(player,"自動遇敵開始了,每10秒嘗試一次。");
elseif not 不消耗诱魔水 and ymxsnum == 0 then
NLG.SystemMessage(player,'缺少怪物餅乾,自動遇敵無法開啟!');
end
elseif (msg == "/2" or msg == "、2") then
if Char.GetData(player,%对象_香步数%)>0 then
NLG.SystemMessage(player,"你正在使用步步遇敵,無法使用大蒜油!");
elseif Char.GetData(player,%对象_不遇敌开关%)==1 then
Char.SetData(player,%对象_不遇敌开关%,0);
Char.SetLoopEvent(nil,'qmloop',player,0);
NLG.UpChar(player);
NLG.SystemMessage(player,"不遇敵功能關閉!");
elseif 不消耗驱魔水 then
Char.SetData(player,%对象_不遇敌开关%,1);
NLG.UpChar(player);
NLG.SystemMessage(player,"不遇敵已經開啟!");
elseif not 不消耗驱魔水 and qmxsnum > 0 then
Char.SetData(player,%对象_不遇敌开关%,1);
Char.SetLoopEvent(nil,'qmloop',player,120000);--修改驱魔水持续时间,单位毫秒
NLG.UpChar(player);
NLG.SystemMessage(player,"不遇敵已經開啟!");
elseif not 不消耗驱魔水 and qmxsnum == 0 then
NLG.SystemMessage(player,'缺少大蒜油,不遇敵無法開啟!');
end
end
end)
end
function Module:onUnload()
self:logInfo('unload');
end
return Module;