SHOW:
|
|
- or go back to the newest paste.
1 | // Chaos Sanctuary Script Modified by SavSin @ Clan ChX v1.0.1 | |
2 | // | |
3 | // Modifications: | |
4 | // Full support with modified *Passive Leech Script* | |
5 | // Added Custom Leech Commands. | |
6 | // Fixed Final Seal pop. | |
7 | // Added New Vars | |
8 | // Allows reverse Chaos (Infect, Desis, Vizor) | |
9 | // Added Giving waypoint at begining of round. | |
10 | // | |
11 | // | |
12 | // New Vars | |
13 | // NTConfig_CS_LeechSupTP - Text to bring leecher into the portal. | |
14 | // NTConfig_CS_LeechTown - Text to send leecher back to town. | |
15 | // NTConfig_CS_DiabloTP - Text to tell the leecher diablo's ready (hides leecher). | |
16 | // NTConfig_CS_DiabloDead - Tells leecher diablo is dead and will go to star to loot. | |
17 | // NTConfig_CS_DiabloText - Text Displayed to all for announcing Diablo is ready. (Must be different than NTConfig_CS_DiabloTP) | |
18 | // NTConfig_CS_GiveWaypoint - Gives the WP at the start of the run then Precasts and starts run. | |
19 | ||
20 | // How to use Passive Leech Support | |
21 | // NTConfig_LeechSupport must be set to TRUE | |
22 | // Configure the above new vars to your liking. | |
23 | // The bot will automatically make the TP's and send the commands as you have configed. | |
24 | ||
25 | ||
26 | function NTMain() { | |
27 | Include("libs/common/NTCommon.ntl"); | |
28 | NTC_IncludeLibs(); | |
29 | NTC_IncludeConfig("NTBot/char_configs"); | |
30 | NT_LoadConfig(); | |
31 | NTSI_LoadNIPFiles("NTBot/item_configs"); | |
32 | NTA_Initialize(); | |
33 | ||
34 | if(!NTTM_CheckAct()){ | |
35 | NTC_SendMsgToScript("NTBotGame.ntj", "NTTM_CheckAct()"); | |
36 | return; | |
37 | } | |
38 | NTTMGR_TownManager(); | |
39 | if(!NTTM_TownMove("waypoint")){ | |
40 | NTC_SendMsgToScript("NTBotGame.ntj", "NTTM_TownMove()"); | |
41 | return; | |
42 | } | |
43 | if(!NTM_TakeWaypoint(107)){ | |
44 | NTC_SendMsgToScript("NTBotGame.ntj", "NTM_TakeWaypoint()"); | |
45 | return; | |
46 | } | |
47 | ||
48 | if(NTConfig_CS_GiveWaypoint) | |
49 | { | |
50 | PubTP(); | |
51 | PubSay("Waypoint Up"); | |
52 | } | |
53 | ||
54 | NTP_DoPrecast(true); | |
55 | ||
56 | if (!NTM_MoveTo(108, 7790, 5544)) { | |
57 | NTC_SendMsgToScript("NTBotGame.ntj", "NTM_MoveTo()"); | |
58 | return; | |
59 | } | |
60 | ||
61 | - | if (!NT_OpenSealsInt()) { |
61 | + | |
62 | - | NTC_SendMsgToScript("NTBotGame.ntj", "NT_OpenSealsInt()"); |
62 | + | |
63 | } | |
64 | ||
65 | if (!NTConfig_FastChaos) { | |
66 | if (NTConfig_Entrance) { | |
67 | NTCS_ClearPosition(30, EntranceSort); | |
68 | NTM_MoveTo(108, 7790, 5544); | |
69 | PubTP(); | |
70 | PubSay(NTConfig_CS_EntranceTP); | |
71 | BO_Party(); | |
72 | NTCS_ClearPosition(30, EntranceSort); | |
73 | var FrontToStarX = [7792,7794,7791,7777,7813,7769,7782,7802,7819,7768,7770,7791,7819, 7804]; | |
74 | var FrontToStarY = [5564,5529,5495,5486,5486,5445,5421,5421,5446,5390,5355,5355,5376, 5340]; | |
75 | for (var i = 0; i < FrontToStarX.length; i += 1) { | |
76 | NTM_MoveTo(108, FrontToStarX[i], FrontToStarY[i]); | |
77 | NTCS_ClearPosition(35, EntranceSort); | |
78 | } | |
79 | } | |
80 | for (i = 0; i < 2; i += 1) { | |
81 | NTM_MoveTo(108, 7784, 5310); | |
82 | NTCS_ClearPosition(30, SealSort); | |
83 | NTC_PingDelay(i < 1 ? 1000 : 10); | |
84 | } | |
85 | PubTP(); | |
86 | PubSay(NTConfig_CS_StarTP); | |
87 | BO_Party(); | |
88 | NTCS_ClearPosition(30, SealSort); | |
89 | } else { | |
90 | NTM_MoveTo(108, 7784, 5310); | |
91 | NTCS_ClearPosition(20, DistanceSort); | |
92 | PubTP(); | |
93 | } | |
94 | ||
95 | if(NTConfig_CS_ReverseCS) | |
96 | { | |
97 | if(!NT_OpenSealsIntReverse()) | |
98 | { | |
99 | NTC_SendMsgToScript("NTBotGame.ntj", "NT_OpenSealsIntReverse()"); | |
100 | return; | |
101 | } | |
102 | } | |
103 | else | |
104 | { | |
105 | if (!NT_OpenSealsInt()) | |
106 | { | |
107 | NTC_SendMsgToScript("NTBotGame.ntj", "NT_OpenSealsInt()"); | |
108 | return; | |
109 | } | |
110 | } | |
111 | ||
112 | PubSay(NTConfig_CS_DiabloText); | |
113 | ||
114 | if (NTConfig_LeechSupport) | |
115 | { | |
116 | NTM_MoveTo(108, 7760, 5267); | |
117 | PubTP(); | |
118 | PubSay(NTConfig_CS_DiabloTP); | |
119 | } | |
120 | ||
121 | NTM_MoveTo(108, 7792, 5291); | |
122 | for (i = 0; i < 200; i += 1) { | |
123 | if (GetUnit(NTC_UNIT_MONSTER, 243)) { | |
124 | break; | |
125 | } | |
126 | NTC_Delay(500); | |
127 | } | |
128 | if (!NTA_KillMonster(243)) { | |
129 | NTC_SendMsgToScript("NTBotGame.ntj", "NTA_KillMonster()"); | |
130 | return; | |
131 | } | |
132 | ||
133 | NTSI_PickItems(); | |
134 | ||
135 | if (NTConfig_LeechSupport) | |
136 | { | |
137 | PubSay(NTConfig_CS_DiabloDead); | |
138 | } | |
139 | ||
140 | if (NTConfig_CS_NextGame != "") PubSay(NTConfig_CS_NextGame + NTC_GetNextGame()); | |
141 | NTC_SendMsgToScript("NTBotGame.ntj", "SCRIPT_END"); | |
142 | } | |
143 | ||
144 | function NT_OpenSealsInt() { | |
145 | var _unit; | |
146 | var _result; | |
147 | ||
148 | _unit = GetPresetUnits(108, NTC_UNIT_OBJECT, 396); | |
149 | ||
150 | if (!_unit) { | |
151 | return false; | |
152 | } | |
153 | if (_unit[0].roomy * 5 + _unit[0].y == 5275) { | |
154 | _result = NT_OpenVizierSealInt(1); | |
155 | } else { | |
156 | _result = NT_OpenVizierSealInt(2); | |
157 | } | |
158 | if (!NTConfig_FastChaos) { | |
159 | NTP_DoPrecast(true); | |
160 | } | |
161 | _unit = GetPresetUnits(108, NTC_UNIT_OBJECT, 394); | |
162 | if (_unit[0].roomx * 5 + _unit[0].x == 7773) { | |
163 | _result = NT_OpenDeSeisSealInt(1); | |
164 | } else { | |
165 | _result = NT_OpenDeSeisSealInt(2); | |
166 | } | |
167 | if (!_result) { | |
168 | return false; | |
169 | } | |
170 | if (!NTConfig_FastChaos) { | |
171 | PubTP(); | |
172 | - | if (!NT_OpenSealInt(395) || !NT_OpenSealInt(396)) { |
172 | + | |
173 | NTCS_ClearPosition(40, SealSortB); | |
174 | } | |
175 | _unit = GetPresetUnits(108, NTC_UNIT_OBJECT, 392); | |
176 | if (!_unit) { | |
177 | return false; | |
178 | } | |
179 | if (_unit[0].roomx * 5 + _unit[0].x == 7893) { | |
180 | _result = NT_OpenVenomSealInt(1); | |
181 | } else { | |
182 | _result = NT_OpenVenomSealInt(2); | |
183 | } | |
184 | NTP_DoPrecast(true); | |
185 | return _result; | |
186 | } | |
187 | ||
188 | function NT_OpenSealsIntReverse() { | |
189 | var _unit; | |
190 | var _result; | |
191 | ||
192 | _unit = GetPresetUnits(108, NTC_UNIT_OBJECT, 392); | |
193 | if (!_unit) { | |
194 | return false; | |
195 | } | |
196 | if (_unit[0].roomx * 5 + _unit[0].x == 7893) { | |
197 | _result = NT_OpenVenomSealInt(1); | |
198 | } else { | |
199 | _result = NT_OpenVenomSealInt(2); | |
200 | } | |
201 | NTP_DoPrecast(true); | |
202 | ||
203 | _unit = GetPresetUnits(108, NTC_UNIT_OBJECT, 394); | |
204 | if (_unit[0].roomx * 5 + _unit[0].x == 7773) { | |
205 | _result = NT_OpenDeSeisSealInt(1); | |
206 | } else { | |
207 | _result = NT_OpenDeSeisSealInt(2); | |
208 | } | |
209 | if (!_result) { | |
210 | return false; | |
211 | } | |
212 | ||
213 | _unit = GetPresetUnits(108, NTC_UNIT_OBJECT, 396); | |
214 | if (!_unit) { | |
215 | return false; | |
216 | } | |
217 | if (_unit[0].roomy * 5 + _unit[0].y == 5275) { | |
218 | _result = NT_OpenVizierSealInt(1); | |
219 | } else { | |
220 | _result = NT_OpenVizierSealInt(2); | |
221 | } | |
222 | if (!NTConfig_FastChaos) { | |
223 | NTP_DoPrecast(true); | |
224 | } | |
225 | ||
226 | return _result; | |
227 | } | |
228 | ||
229 | function NT_OpenVizierSealInt(type) { | |
230 | var i; | |
231 | ||
232 | if (!NTConfig_FastChaos) { | |
233 | if (type === 1) { | |
234 | var vx = [7767,7756,7744,7747,7750,7741,7729,7720,7720,7721,7719,7712,7700,7687,7676, 7666]; | |
235 | var vy = [5292,5284,5275,5290,5303,5310,5314,5312,5301,5288,5273,5292,5294,5294,5292, 5307]; | |
236 | } | |
237 | else | |
238 | { | |
239 | var vx = [7768,7755,7741,7733,7723,7714,7707,7680,7666, 7655]; | |
240 | var vy = [5289,5295,5282,5291,5300,5282,5315,5310,5311, 5282]; | |
241 | } | |
242 | for (i = 0; i < vx.length; i += 1) { | |
243 | NTM_MoveTo(108, vx[i], vy[i]); | |
244 | NTCS_ClearPosition(30, SealSort); | |
245 | } | |
246 | } | |
247 | if (NTConfig_LeechSupport) | |
248 | { | |
249 | if (type === 1) | |
250 | { | |
251 | NTM_MoveTo(108, 7672, 5283); | |
252 | NTCS_ClearPosition(25, DistanceSort); | |
253 | NTM_MoveTo(108, 7649, 5269); | |
254 | NTCS_ClearPosition(25, DistanceSort); | |
255 | } | |
256 | else | |
257 | { | |
258 | NTM_MoveTo(108, 7654, 5295); | |
259 | NTCS_ClearPosition(25, DistanceSort); | |
260 | NTM_MoveTo(108, 7647, 5274); | |
261 | NTCS_ClearPosition(25, DistanceSort); | |
262 | } | |
263 | PubTP(); | |
264 | PubSay(NTConfig_CS_LeechSupTP); | |
265 | } | |
266 | if (!NT_OpenSealInt(396)) | |
267 | { | |
268 | return false; | |
269 | } | |
270 | if (type == 1) { | |
271 | NTM_MoveTo(108, 7691, 5292); | |
272 | } else { | |
273 | NTM_MoveTo(108, 7695, 5316); | |
274 | } | |
275 | ||
276 | NTCS_Preattack(GetLocaleString(2851)); | |
277 | ||
278 | if(!NTConfig_EvenFasterChaos) | |
279 | { | |
280 | NTCS_ClearPosition(40, DistanceSort, NTConfig_FastChaos && !NTConfig_LeechSupport ? 0x10 : null, NTConfig_FastChaos && !NTConfig_LeechSupport ? 306 : null); | |
281 | } | |
282 | ||
283 | NTA_KillMonster(GetLocaleString(2851)); // Grand Vizier of Chaos | |
284 | ||
285 | if(!NTConfig_EvenFasterChaos) | |
286 | { | |
287 | NTCS_ClearPosition(40, DistanceSort, NTConfig_FastChaos && !NTConfig_LeechSupport ? 0x10 : null, NTConfig_FastChaos && !NTConfig_LeechSupport ? 306 : null); | |
288 | } | |
289 | ||
290 | if(!NT_OpenSealInt(395)) | |
291 | return false; | |
292 | ||
293 | if(NTConfig_LeechSupport) | |
294 | { | |
295 | PubSay(NTConfig_CS_LeechTown); | |
296 | } | |
297 | else | |
298 | { | |
299 | PubSay("Vizier dead."); | |
300 | } | |
301 | ||
302 | if(NTConfig_IdInField){ | |
303 | NT_FieldID(); | |
304 | } return true; | |
305 | } | |
306 | ||
307 | function NT_OpenDeSeisSealInt(type) { | |
308 | var i, n; | |
309 | ||
310 | if (!NTConfig_FastChaos) { | |
311 | if (type === 1) { | |
312 | var sx = [7791,7783,7800,7809,7785,7773,7773,7776,7794,7811,7817,7815,7798]; // Shape of "2" | |
313 | var sy = [5265,5256,5247,5232,5230,5222,5212,5194,5194,5193,5177,5157,5155]; | |
314 | } else { | |
315 | var sx = [7786,7801,7786,7787,7810,7811,7810,7790,7774,7773,7794]; // shape of an "S" or "5" | |
316 | var sy = [5263,5249,5245,5227,5233,5215,5198,5194,5181,5156,5154]; | |
317 | } | |
318 | for (var i = 0; i < sx.length; i += 1) { | |
319 | NTM_MoveTo(108, sx[i], sy[i]); | |
320 | NTCS_ClearPosition(30, type === 1 ? SealSort : SealSortB); | |
321 | } | |
322 | } | |
323 | if (NTConfig_LeechSupport) { | |
324 | if (type === 1) { | |
325 | NTM_MoveTo(108, 7794, 5155); | |
326 | NTCS_ClearPosition(25, DistanceSort); | |
327 | NTM_MoveTo(108, 7777, 5155); | |
328 | NTCS_ClearPosition(25, DistanceSort); | |
329 | } else { | |
330 | NTM_MoveTo(108, 7785, 5154); | |
331 | NTCS_ClearPosition(25, DistanceSort); | |
332 | NTM_MoveTo(108, 7811, 5155); | |
333 | NTCS_ClearPosition(25, DistanceSort); | |
334 | } | |
335 | PubTP(); | |
336 | PubSay(NTConfig_CS_LeechSupTP); | |
337 | } | |
338 | if (!NT_OpenSealInt(394)) { | |
339 | return false; | |
340 | } | |
341 | if (type == 1) { | |
342 | NTM_MoveTo(108, 7797, 5201); | |
343 | for (i = 0; i < 3; i += 1) { | |
344 | NTM_TeleportTo(7794, 5227); | |
345 | } | |
346 | } else { | |
347 | NTM_MoveTo(108, 7798, 5186); | |
348 | } | |
349 | ||
350 | NTCS_Preattack(GetLocaleString(2852)); | |
351 | if(!NTConfig_EvenFasterChaos){ | |
352 | NTCS_ClearPosition(40, DistanceSort, NTConfig_FastChaos && !NTConfig_LeechSupport ? 0x10 : null, NTConfig_FastChaos && !NTConfig_LeechSupport ? 310 : null); | |
353 | } | |
354 | NTA_KillMonster(GetLocaleString(2852)); // Lord De Seis | |
355 | if(!NTConfig_EvenFasterChaos){ | |
356 | NTCS_ClearPosition(40, DistanceSort, NTConfig_FastChaos && !NTConfig_LeechSupport ? 0x10 : null, NTConfig_FastChaos && !NTConfig_LeechSupport ? 310 : null); | |
357 | } | |
358 | ||
359 | if(NTConfig_LeechSupport) | |
360 | { | |
361 | PubSay(NTConfig_CS_LeechTown); | |
362 | } | |
363 | else | |
364 | { | |
365 | PubSay("De Seis dead."); | |
366 | } | |
367 | ||
368 | if(NTConfig_IdInField){ | |
369 | NT_FieldID(); | |
370 | } return NTM_MoveTo(108, 7800, 5255); | |
371 | } | |
372 | ||
373 | function NT_OpenVenomSealInt(type) { | |
374 | if (!NTConfig_FastChaos) { | |
375 | if (type === 1) { | |
376 | var IX = [7825,7827,7834,7845,7855,7852,7875,7896,7917]; // shape of a "t" | |
377 | var IY = [5293,5276,5291,5315,5301,5278,5293,5295,5291]; | |
378 | } else { | |
379 | var IX = [7822,7826,7832,7850,7868,7877,7891,7907,7927,7932]; // looks like a hook | |
380 | var IY = [5297,5278,5307,5278,5297,5276,5276,5276,5279,5298]; | |
381 | } | |
382 | for (var i = 0; i < IX.length; i += 1) { | |
383 | NTM_MoveTo(108, IX[i], IY[i]); | |
384 | NTCS_ClearPosition(30, type === 1 ? SealSort : SealSortB); | |
385 | } | |
386 | } | |
387 | if(NTConfig_LeechSupport) { | |
388 | if (type === 1) { | |
389 | NTM_MoveTo(108, 7898, 5296); | |
390 | NTCS_ClearPosition(25, DistanceSort); | |
391 | NTM_MoveTo(108, 7892, 5321); | |
392 | NTCS_ClearPosition(25, DistanceSort); | |
393 | } else { | |
394 | NTM_MoveTo(108, 7933, 5302); | |
395 | NTCS_ClearPosition(25, DistanceSort); | |
396 | NTM_MoveTo(108, 7909, 5313); | |
397 | NTCS_ClearPosition(25, DistanceSort); | |
398 | } | |
399 | PubTP(); | |
400 | PubSay(NTConfig_CS_LeechSupTP); | |
401 | } | |
402 | if (!NT_OpenSealInt(392)) | |
403 | { | |
404 | return false; | |
405 | } | |
406 | if (type === 1) | |
407 | { | |
408 | type = 1; // temp | |
409 | } else | |
410 | { | |
411 | NTM_MoveTo(108, 7933, 5299); | |
412 | } | |
413 | ||
414 | NTCS_Preattack(GetLocaleString(2853)); | |
415 | if(!NTConfig_EvenFasterChaos){ | |
416 | NTCS_ClearPosition(40, DistanceSort, NTConfig_FastChaos && !NTConfig_LeechSupport ? 0x10 : null, NTConfig_FastChaos && !NTConfig_LeechSupport ? 362 : null); | |
417 | } | |
418 | NTA_KillMonster(GetLocaleString(2853)); // Infector of Souls | |
419 | if(!NTConfig_EvenFasterChaos){ | |
420 | NTCS_ClearPosition(40, DistanceSort, NTConfig_FastChaos && !NTConfig_LeechSupport ? 0x10 : null, NTConfig_FastChaos && !NTConfig_LeechSupport ? 362 : null); | |
421 | } | |
422 | ||
423 | if(NTConfig_LeechSupport) | |
424 | { | |
425 | PubSay(NTConfig_CS_LeechTown); | |
426 | } | |
427 | else | |
428 | { | |
429 | PubSay("Infector Dead!"); | |
430 | } | |
431 | ||
432 | if(!NT_OpenSealInt(393)) | |
433 | return false; | |
434 | ||
435 | if(NTConfig_IdInField){ | |
436 | NT_FieldID(); | |
437 | } | |
438 | if (NTC_PutSkill(124, NTC_HAND_RIGHT)) { | |
439 | NTC_PingDelay(1000); | |
440 | } return true; | |
441 | } | |
442 | ||
443 | function NT_OpenSealInt(classid) { | |
444 | var warn; | |
445 | switch (classid) { | |
446 | case 396: | |
447 | case 394: | |
448 | case 392: | |
449 | warn = true; | |
450 | break; | |
451 | default: | |
452 | warn = false; | |
453 | break; | |
454 | } | |
455 | var i, seal; | |
456 | for (i = 0; i < 5; i += 1) { | |
457 | NTM_MoveToPresetUnit(108, 2, classid, classid === 394 ? 5 : 2, classid === 394 ? 5 : 0); | |
458 | seal = NTC_FindUnit(NTC_UNIT_OBJECT, classid); | |
459 | if (!seal) { | |
460 | return false; | |
461 | } | |
462 | if (seal.mode) { // for pubbies | |
463 | if (warn) { | |
464 | PubSay(NTConfig_CS_SealBasher); | |
465 | } | |
466 | return true; | |
467 | } | |
468 | warn = false; | |
469 | NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, seal); | |
470 | NTC_Delay(classid === 394 ? 1000 : 500); | |
471 | ||
472 | if (!seal.mode) { | |
473 | if (classid === 394 && CheckCollision(seal.x + 15, seal.y)) { // de seis optimization | |
474 | NTM_MoveTo(108, seal.x + 15, seal.y); | |
475 | } else { | |
476 | NTM_MoveTo(108, seal.x - 5, seal.y - 5); | |
477 | } | |
478 | NTC_Delay(500); | |
479 | } else { | |
480 | return true; | |
481 | } | |
482 | } return false; | |
483 | } | |
484 | ||
485 | function BO_Party() { | |
486 | if (NTConfig_PublicMode) { | |
487 | NTC_Delay(1000); | |
488 | } | |
489 | NTP_DoPrecast(true); | |
490 | } | |
491 | ||
492 | function NTC_GetNextGame() { // move this to ntc | |
493 | function Pad(num) { | |
494 | if (num < 10) { | |
495 | num = 0 + "" + num; | |
496 | } | |
497 | return num; | |
498 | } | |
499 | var i, result, number, | |
500 | game = me.gamename; | |
501 | for (i = game.length - 1; i > -1; i -= 1) { | |
502 | if (isNaN(game[i])) { | |
503 | break; | |
504 | } | |
505 | } | |
506 | result = game.substring(0, i + 1); | |
507 | number = parseInt(game.substring(i + 1), 10) === 99 ? 0 : (parseInt(game.substring(i + 1), 10) + 1); // 99 correction | |
508 | result += Pad(number); | |
509 | return result; | |
510 | } | |
511 | ||
512 | function NTA_MonsterStats(unit) { | |
513 | this.name = unit.name; | |
514 | this.x = unit.x; | |
515 | this.y = unit.y; | |
516 | this.gid = unit.gid; | |
517 | this.classid = unit.classid; | |
518 | this.spectype = unit.spectype; | |
519 | } | |
520 | ||
521 | function DistanceSort(unitA, unitB) { | |
522 | if (GetDistance(me.x, me.y, unitA.x, unitA.y) < GetDistance(me.x, me.y, unitB.x, unitB.y)) { | |
523 | return -1; | |
524 | } | |
525 | return 1; | |
526 | } | |
527 | ||
528 | function EntranceSort(unitA, unitB) { | |
529 | if (GetDistance(unitA.x, unitA.y, 7790, 5544) < GetDistance(unitB.x, unitB.y, 7790, 5544)) { | |
530 | return -1; | |
531 | } | |
532 | return 1; | |
533 | } | |
534 | ||
535 | function SealSort(unitA, unitB) { | |
536 | if (GetDistance(unitA.x, unitA.y, 7784, 5310) < GetDistance(unitB.x, unitB.y, 7784, 5310)) { | |
537 | return -1; | |
538 | } | |
539 | return 1; | |
540 | } | |
541 | ||
542 | function SealSortB(unitA, unitB) { | |
543 | if (GetDistance(unitA.x, unitA.y, 7800, 5255) < GetDistance(unitB.x, unitB.y, 7800, 5255)) { | |
544 | return -1; | |
545 | } | |
546 | return 1; | |
547 | } | |
548 | ||
549 | function NTCS_Preattack(name) { | |
550 | var i, n, target, pos, positions; | |
551 | ||
552 | target = NTC_FindUnit(1, name, 10); | |
553 | ||
554 | switch (me.classid) { | |
555 | case 0: | |
556 | break; | |
557 | case 1: | |
558 | break; | |
559 | case 2: | |
560 | break; | |
561 | case 3: | |
562 | if (!target) { | |
563 | return; | |
564 | } | |
565 | positions = [[6, 11], [0, 8], [8, -1], [-9, 2], [0, -11], [8, -8]]; | |
566 | for (i = 0; i < positions.length; i += 1) { | |
567 | if (CheckCollision(me.areaid, target.x + positions[i][0], target.y + positions[i][1], 1)) { // check if we can move there | |
568 | NTM_MoveTo(108, target.x + positions[i][0], target.y + positions[i][1]); | |
569 | NTC_PutSkill(NTConfig_AttackSkill[2], NTC_HAND_RIGHT); | |
570 | for (n = 0; n < 8; n += 1) { | |
571 | NTC_CastSkill(NTConfig_AttackSkill[1], 2); | |
572 | } | |
573 | break; | |
574 | } | |
575 | } | |
576 | break; | |
577 | case 4: | |
578 | if (!target || NTConfig_AttackSkill[0] < 0) { | |
579 | return; | |
580 | } | |
581 | pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, 20, 4); | |
582 | if (pos) { | |
583 | NTM_MoveTo(108, pos[0], pos[1]); | |
584 | } | |
585 | for (i = 0; i < 2; i += 1) { | |
586 | NTC_CastSkill(130, NTC_HAND_RIGHT); | |
587 | NTC_Delay(150); | |
588 | } | |
589 | break; | |
590 | case 5: | |
591 | break; | |
592 | case 6: | |
593 | break; | |
594 | } | |
595 | } | |
596 | ||
597 | function PubTP() { | |
598 | if (NTConfig_PublicMode) { | |
599 | NTM_MakeTP(); | |
600 | } | |
601 | } | |
602 | ||
603 | function PubSay(string) { | |
604 | if (NTConfig_PublicMode) { | |
605 | Say(string); | |
606 | } | |
607 | } | |
608 | ||
609 | function OpenStashes(range) { | |
610 | var i, unit, | |
611 | objects = [GetLocaleString(3274)], | |
612 | orgx = me.x, | |
613 | orgy = me.y; | |
614 | ||
615 | for (i = 0; i < objects.length; i += 1) { | |
616 | unit = NTC_FindUnit(NTC_UNIT_OBJECT, objects[i]); | |
617 | if (unit) { | |
618 | do { | |
619 | if (GetDistance(orgx, orgy, unit.x, unit.y) <= range) { | |
620 | if (NTC_OpenChest(unit)) { | |
621 | NTSI_PickItems(); | |
622 | } | |
623 | } | |
624 | } while (unit.GetNext()); | |
625 | } | |
626 | } | |
627 | } | |
628 | ||
629 | function NTT_CheckPotionSafe() { | |
630 | var i, items, hpCheck, mpCheck; | |
631 | items = me.GetItems(); | |
632 | if (NTConfig_BeltColType.indexOf("hp") > -1) { | |
633 | for (i = 0; i < items.length; i += 1) { | |
634 | if (!hpCheck && items[i].mode === 2 && items[i].code.indexOf("hp") > -1) { | |
635 | hpCheck = true; | |
636 | } | |
637 | } | |
638 | } else { | |
639 | hpCheck = true; | |
640 | } | |
641 | if (NTConfig_BeltColType.indexOf("mp") > -1) { | |
642 | for (i = 0; i < items.length; i += 1) { | |
643 | if (!mpCheck && items[i].mode === 2 && items[i].code.indexOf("mp") > -1) { | |
644 | mpCheck = true; | |
645 | } | |
646 | } | |
647 | } else { | |
648 | mpCheck = true; | |
649 | } | |
650 | return !(hpCheck && mpCheck); | |
651 | } | |
652 | ||
653 | function NTA_Dodge(target, distance) { | |
654 | var i, j, coordx, coordy, monster, count, | |
655 | maxcount = 999, | |
656 | coords = [], | |
657 | goodCoords = [], | |
658 | monList = [], | |
659 | angles = [45, 90, 135, 180, 225, 270, 305, 360]; | |
660 | for (i = 0; i < angles.length; i += 1) { | |
661 | coordx = Math.round((Math.cos(angles[i] * Math.PI / 180)) * distance + target.x); | |
662 | coordy = Math.round((Math.sin(angles[i] * Math.PI / 180)) * distance + target.y); | |
663 | if (CheckCollision(me.areaid, coordx, coordy, 1)) { | |
664 | coords.push([coordx, coordy]); | |
665 | } | |
666 | } | |
667 | if (coords.length === 0) { // no valid positions - don't move | |
668 | return true; | |
669 | } | |
670 | coords.sort(NTA_SortRooms); | |
671 | monster = GetUnit(1); | |
672 | if (monster) { | |
673 | do { | |
674 | if (monster.hp > 0) { | |
675 | monList.push(new NTA_MonsterStats(target)); | |
676 | } | |
677 | } while (monster.GetNext()); | |
678 | } | |
679 | for (i = 0; i < coords.length; i += 1) { | |
680 | count = 0; | |
681 | for (j = 0; j < monList.length; j += 1) { | |
682 | if (monList[j].hp > 0 && GetDistance(monList[j].x, monList[j].y, coords[i][0], coords[i][1]) < 10) { | |
683 | count += 1; | |
684 | } | |
685 | } | |
686 | if (count < maxcount) { | |
687 | goodCoords = [coords[i][0], coords[i][1]]; | |
688 | maxcount = count; | |
689 | if (count === 0) { | |
690 | break; | |
691 | } | |
692 | } | |
693 | } | |
694 | if (goodCoords.length > 0) { // just in case goodCoords is empty (shouldn't happen) | |
695 | if (Math.abs(me.x - goodCoords[0]) < 3 && Math.abs(me.y - goodCoords[1]) < 3) { // close enough | |
696 | return true; | |
697 | } | |
698 | Say("!Dodge " + target.name); | |
699 | NTM_MoveTo(me.areaid, goodCoords[0], goodCoords[1]); | |
700 | } | |
701 | return true; | |
702 | } | |
703 | ||
704 | function NTCS_ClearPosition(range, sortFunc, spectype, classid) { | |
705 | var i, orgx, orgy, monList, ignoreList, target, result, | |
706 | gidAttack = [], | |
707 | dodgeIDs = [310, 362], | |
708 | attackcount = 0; | |
709 | if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) { | |
710 | return false; | |
711 | } | |
712 | switch (arguments.length) { | |
713 | case 0: | |
714 | range = 20; | |
715 | case 1: | |
716 | sortFunc = DistanceSort; | |
717 | case 2: | |
718 | spectype = false; | |
719 | case 3: | |
720 | classid = false; | |
721 | break; | |
722 | } | |
723 | orgx = me.x; | |
724 | orgy = me.y; | |
725 | ignoreList = []; | |
726 | MainLoop : while (attackcount < 300) { | |
727 | monList = []; | |
728 | target = NTC_FindUnit(NTC_UNIT_MONSTER); | |
729 | if (target) { | |
730 | do { | |
731 | if (target.IsAttackable()) { | |
732 | if ((me.classid === 1 || me.classid === 2 || me.classid === 6) && NTConfig_Dodge && GetDistance(me, target) < 7 && dodgeIDs.indexOf(target.classid) > -1) { | |
733 | NTA_Dodge(target, 15); | |
734 | continue MainLoop; | |
735 | } | |
736 | if (ignoreList.indexOf(target.gid) < 0 && GetDistance(orgx, orgy, target.x, target.y) <= range) { | |
737 | if (NTA_IsValidMonster(target)) { | |
738 | monList.push(new NTA_MonsterStats(target)); | |
739 | } else { | |
740 | ignoreList.push(target.gid); | |
741 | } | |
742 | } | |
743 | } | |
744 | } while (target.GetNext()); | |
745 | } | |
746 | if (monList.length === 0) { | |
747 | break; | |
748 | } | |
749 | monList.sort(sortFunc); | |
750 | target = NTC_FindUnit(NTC_UNIT_MONSTER, monList[0].gid); | |
751 | if (target && target.IsAttackable()) { | |
752 | result = NTA_Attack(target, attackcount % 30 === 0); | |
753 | switch (result) { | |
754 | case 1: | |
755 | monList.shift(); | |
756 | ignoreList.push(target.gid); | |
757 | break; | |
758 | case 2: | |
759 | case 3: | |
760 | if(!gidAttack[target.gid]) { | |
761 | gidAttack[target.gid] = 0; | |
762 | } | |
763 | gidAttack[target.gid] += 1; | |
764 | if (gidAttack[target.gid] > NTConfig_LowMaxAttacks) { | |
765 | monList.shift(); | |
766 | ignoreList.push(target.gid); | |
767 | } | |
768 | attackcount += 1; | |
769 | if (target.mode === 0 || target.mode === 12) { | |
770 | NTSI_FastPick(); | |
771 | } | |
772 | break; | |
773 | default: | |
774 | return false; | |
775 | } | |
776 | } else { | |
777 | monList.shift(); | |
778 | ignoreList.push(target.gid); | |
779 | } | |
780 | } | |
781 | switch (me.classid) { | |
782 | case NTC_CHAR_CLASS_PALADIN: | |
783 | if (attackcount > 2 && (parseInt(me.hp * 100/ me.hpmax) < NTConfig_UseRedemptionHP || parseInt(me.mp * 100 / me.mpmax) < NTConfig_UseRedemptionMP)) { | |
784 | if (NTC_PutSkill(124, NTC_HAND_RIGHT)) { | |
785 | NTC_PingDelay(1000); | |
786 | } | |
787 | } | |
788 | break; | |
789 | case NTC_CHAR_CLASS_NECROMANCER: | |
790 | if (typeof(NTA_SkeletonArmy) === 'function') { // old summon code | |
791 | NTA_SkeletonArmy(NTConfig_SkeletonArmy); | |
792 | NTA_MageArmy(NTConfig_MageArmy); | |
793 | NTA_ReviveArmy(NTConfig_ReviveArmy); | |
794 | } else { | |
795 | NTA_RaiseArmy(); // new summon code | |
796 | } | |
797 | break; | |
798 | case NTC_CHAR_CLASS_SORCERESS: | |
799 | if (me.GetState(30) === 0) { | |
800 | NTC_CastSkill(58, NTC_HAND_RIGHT); | |
801 | } | |
802 | break; | |
803 | case NTC_CHAR_CLASS_BARBARIAN: | |
804 | if (attackcount > 0) { | |
805 | if (typeof(MWL_FindItem) === 'function') { // in case of using muddy's item find (like myself) | |
806 | MWL_FindItem(20); | |
807 | } else if (NTConfig_UseFindItem && !NTA_CheckForCloseMonsters(10)) { | |
808 | NTA_FindItem(NTConfig_FindItemRange); | |
809 | } | |
810 | } | |
811 | break; | |
812 | } | |
813 | if (attackcount > 0) { | |
814 | NTSI_PickItems(); | |
815 | } | |
816 | if (NTConfig_OpenChest) { | |
817 | OpenStashes(range); | |
818 | } | |
819 | if (NTT_CheckMerc()) { | |
820 | NTTMGR_VisitTown(); | |
821 | } | |
822 | if (NTT_CheckPotionSafe()) { | |
823 | NTTMGR_VisitTown(); | |
824 | } | |
825 | if (NTConfig_IdInField) { | |
826 | if (!NTT_CheckSpace(NTConfig_FreeSpaceXY[0], NTConfig_FreeSpaceXY[1])) { | |
827 | NT_FieldID(); | |
828 | } | |
829 | } return true; | |
830 | } | |
831 | ||
832 | function NTA_SortRooms(a, b) { | |
833 | if (GetDistance(me.x, me.y, a[0], a[1]) < GetDistance(me.x, me.y, b[0], b[1])) { | |
834 | return -1; | |
835 | } | |
836 | return 1; | |
837 | } |