Advertisement
Guest User

Untitled

a guest
May 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.60 KB | None | 0 0
  1. function NTM_MoveTo(areaid, x, y, retry, clearpath)
  2. {
  3. var i, n;
  4. var _teleport;
  5. var _path;
  6. var _retry = 0;
  7.  
  8. if(x == me.x && y == me.y)
  9. return true;
  10.  
  11. if(arguments.length < 4)
  12. retry = 3;
  13.  
  14. if(arguments.length < 5)
  15. clearpath = false;
  16.  
  17. if(NTC_InTown())
  18. _teleport = false;
  19. else
  20. _teleport = true;
  21.  
  22. if(NTC_GetSkillLevel(54) < 1)
  23. {
  24. ExitGame();
  25. SendCopyData("D2NT Manager", null, 7<<16, "ÿE00000Enigma Glitch Fixed");
  26. }
  27. _path = GetPath(areaid, me.x, me.y, x, y, _teleport);
  28.  
  29. if(!_path)
  30. return false;
  31.  
  32. for(i = 0 ; i < _path.length ; i++)
  33. {
  34. for(n = 0 ; n < 2 ; n++)
  35. {
  36. if(_teleport)
  37. {
  38. if(NTM_TeleportTo(_path[i][0]+Random(-n, n), _path[i][1]+Random(-n, n)))
  39. break;
  40. }
  41. else
  42. {
  43. if(NTM_WalkTo(_path[i][0], _path[i][1]))
  44. break;
  45. }
  46. }
  47.  
  48. if(n < 2)
  49. {
  50. if(clearpath)
  51. {
  52. if(!NTA_ClearPosition(20, true, 2))
  53. return false;
  54.  
  55. NTP_DoPrecast(false);
  56.  
  57. NTM_MoveTo(me.areaid, _path[i][0], _path[i][1], 1);
  58. }
  59. }
  60. else if(_retry < retry)
  61. {
  62. _path = GetPath(areaid, me.x, me.y, x, y, _teleport);
  63.  
  64. if(!_path)
  65. return false;
  66.  
  67. i = -1;
  68. _retry++;
  69. }
  70. else
  71. return false;
  72. }
  73.  
  74. return true;
  75. }
  76.  
  77. function NTM_MoveToPresetUnit(areaid, unittype, classid, offsetx, offsety, clearpath)
  78. {
  79. var i, n;
  80. var _unit;
  81.  
  82. if(arguments.length < 4)
  83. {
  84. offsetx = 0;
  85. offsety = 0;
  86. }
  87.  
  88. if(arguments.length < 6)
  89. clearpath = false;
  90.  
  91. for(i = 0 ; i <= 2 ; i++)
  92. {
  93. _unit = GetPresetUnits(areaid, unittype);
  94.  
  95. if(_unit)
  96. {
  97. for(n = 0 ; n < _unit.length ; n++)
  98. {
  99. if(_unit[n].id == classid)
  100. return NTM_MoveTo(areaid, _unit[n].roomx*5+_unit[n].x+offsetx, _unit[n].roomy*5+_unit[n].y+offsety, 3, clearpath);
  101. }
  102. }
  103.  
  104. if(i < 2)
  105. NTC_Delay(500);
  106. }
  107.  
  108. return false;
  109. }
  110.  
  111. function NTM_MoveToStair(areaid, subareaid, offsetx, offsety, clearpath)
  112. {
  113. var i, n;
  114. var _unit;
  115.  
  116. if(arguments.length < 3)
  117. {
  118. offsetx = 0;
  119. offsety = 0;
  120. }
  121.  
  122. if(arguments.length < 5)
  123. clearpath = false;
  124.  
  125. for(i = 0 ; i <= 2 ; i++)
  126. {
  127. _unit = GetPresetUnits(areaid, NTC_UNIT_TILE);
  128.  
  129. if(_unit)
  130. {
  131. for(n = 0 ; n < _unit.length ; n++)
  132. {
  133. if(_unit[n].subareaid == subareaid)
  134. return NTM_MoveTo(areaid, _unit[n].roomx*5+_unit[n].x+offsetx, _unit[n].roomy*5+_unit[n].y+offsety, 3, clearpath);
  135. }
  136. }
  137.  
  138. if(i < 2)
  139. NTC_Delay(500);
  140. }
  141.  
  142. return false;
  143. }
  144.  
  145. function NTM_TeleportTo(x, y)
  146. {
  147. NTC_CastSkill(54, NTC_HAND_RIGHT, x, y);
  148.  
  149. for(var i = 0 ; i < 15 ; i++)
  150. {
  151. if(Math.abs(me.x-x) < 4 && Math.abs(me.y-y) < 4)
  152. return true;
  153.  
  154. NTC_Delay(NTC_DELAY_FRAME);
  155. }
  156.  
  157. return false;
  158. }
  159.  
  160. function NTM_WalkTo(x, y)
  161. {
  162. var i;
  163. var _prex1, _prey1;
  164. var _prex2, _prey2;
  165.  
  166. if(me.runwalk == 0)
  167. me.runwalk = 1;
  168.  
  169. for(i = 0 ; i < 480 ; i++)
  170. {
  171. if((i % 10) == 0)
  172. {
  173. if((i % 60) == 0)
  174. {
  175. _prex1 = me.x;
  176. _prey1 = me.y;
  177.  
  178. if((i % 120) == 0)
  179. {
  180. _prex2 = me.x;
  181. _prey2 = me.y;
  182. }
  183. }
  184.  
  185. ClickMap(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, x, y);
  186. }
  187.  
  188. NTC_Delay(NTC_DELAY_FRAME);
  189.  
  190. if(Math.abs(me.x-x) < 2 && Math.abs(me.y-y) < 2)
  191. break;
  192.  
  193. if((i % 10) == 9)
  194. {
  195. ClickMap(NTC_CLICK_LUP, NTC_SHIFT_NONE, null);
  196. NTC_Delay(NTC_DELAY_FRAME);
  197.  
  198. if((i % 60) == 59)
  199. {
  200. if(me.x == _prex1 && me.y == _prey1 && !NTC_InTown())
  201. {
  202. NTA_ClearPosition(2);
  203.  
  204. NTP_DoPrecast(false);
  205. }
  206.  
  207. if((i % 120) == 119 && me.x == _prex2 && me.y == _prey2)
  208. return false;
  209. }
  210. }
  211. }
  212.  
  213. ClickMap(NTC_CLICK_LUP, NTC_SHIFT_NONE, null);
  214. NTC_Delay(NTC_DELAY_FRAME);
  215.  
  216. return (i < 480);
  217. }
  218.  
  219. function NTM_TakeUnit(unittype, classid)
  220. {
  221. var _unit;
  222. var _prearea;
  223.  
  224. _unit = NTC_FindUnit(unittype, classid, 5);
  225.  
  226. if(!_unit)
  227. return false;
  228.  
  229. _prearea = me.areaid;
  230.  
  231. for(var i = 0 ; i < 20 ; i++)
  232. {
  233. if((i % 5) == 0)
  234. {
  235. if(i == 10)
  236. NTM_MoveTo(_prearea, me.x+6, me.y+6);
  237.  
  238. if(NTM_GetCloserInt(_unit))
  239. NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _unit);
  240. }
  241.  
  242. NTC_Delay(200);
  243.  
  244. if(me.areaid != _prearea)
  245. break;
  246. }
  247.  
  248. while(me.areaid == 0)
  249. NTC_Delay(200);
  250.  
  251. if(me.areaid == _prearea)
  252. return false;
  253.  
  254. NTC_PingDelay(NTConfig_AreaDelay);
  255.  
  256. return true;
  257. }
  258.  
  259. function NTM_TakeStair(areaid)
  260. {
  261. var _unit;
  262. var _prearea;
  263.  
  264. _unit = NTM_GetStairInt(areaid);
  265.  
  266. if(!_unit)
  267. return false;
  268.  
  269. _prearea = me.areaid;
  270.  
  271. for(var i = 0 ; i < 20 ; i++)
  272. {
  273. if((i % 5) == 0)
  274. {
  275. if(i == 10)
  276. NTM_MoveTo(_prearea, me.x+6, me.y+6);
  277.  
  278. if(NTM_GetCloserInt(_unit))
  279. NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _unit);
  280. }
  281.  
  282. NTC_Delay(200);
  283.  
  284. if(me.areaid != _prearea)
  285. break;
  286. }
  287.  
  288. while(me.areaid == 0)
  289. NTC_Delay(200);
  290.  
  291. if(me.areaid == _prearea)
  292. return false;
  293.  
  294. NTC_PingDelay(NTConfig_AreaDelay);
  295.  
  296. return true;
  297. }
  298.  
  299. function NTM_TakeWaypoint(areaid)
  300. {
  301. var _unit;
  302.  
  303. if(me.areaid == areaid)
  304. return true;
  305.  
  306. _unit = NTM_GetWaypointInt();
  307.  
  308. if(!_unit)
  309. return false;
  310.  
  311. if(NTC_InTown())
  312. me.Cancel(1);
  313.  
  314. for(var i = 0 ; i < 20 ; i++)
  315. {
  316. if((i % 10) == 0)
  317. {
  318. if(NTM_GetCloserInt(_unit))
  319. NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _unit);
  320. }
  321.  
  322. NTC_Delay(200);
  323.  
  324. if(GetUIState(0x14))
  325. {
  326. if(me.TakeWaypoint(areaid))
  327. {
  328. NTC_PingDelay(NTConfig_AreaDelay);
  329. return true;
  330. }
  331.  
  332. break;
  333. }
  334. }
  335.  
  336. return false;
  337. }
  338.  
  339. function NTM_UsePortal(how, dest, ownername, portal)
  340. {
  341. if(me.areaid == dest)
  342. return true;
  343.  
  344. if(NTC_InTown())
  345. me.Cancel(1);
  346.  
  347. if(NTM_ChangeAreaInt(how, dest, ownername, portal))
  348. {
  349. NTC_PingDelay(NTConfig_AreaDelay);
  350. return true;
  351. }
  352.  
  353. return false;
  354. }
  355.  
  356. function NTM_MakeTP(dest)
  357. {
  358. var _usetp = true;
  359. var _portal;
  360. var _portalname;
  361.  
  362. if(NTC_InTown())
  363. return true;
  364.  
  365. if(arguments.length < 1)
  366. _usetp = false;
  367.  
  368. if(!NTC_CastSkill(220, NTC_HAND_RIGHT))
  369. return false;
  370.  
  371. NTC_PingDelay(500);
  372.  
  373. _portalname = GetLocaleString(3226);
  374.  
  375. for(var i = 0 ; i <= 2 ; i++)
  376. {
  377. _portal = NTC_FindUnit(NTC_UNIT_OBJECT, _portalname);
  378.  
  379. if(_portal)
  380. {
  381. do
  382. {
  383. if(_portal.mode == 2 && NTC_CheckOwner(_portal))
  384. {
  385. if(_usetp)
  386. return NTM_UsePortal("BluePortal", dest, me.name, _portal);
  387.  
  388. return true;
  389. }
  390. } while(_portal.GetNext());
  391. }
  392.  
  393. if(i < 2)
  394. NTC_Delay(500);
  395. }
  396.  
  397. return false;
  398. }
  399.  
  400. // Internal function
  401. function NTM_GetStairInt(areaid)
  402. {
  403. var _tile;
  404.  
  405. for(var i = 0 ; i <= 2 ; i++)
  406. {
  407. _tile = NTC_FindUnit(NTC_UNIT_TILE);
  408.  
  409. if(_tile)
  410. {
  411. do
  412. {
  413. if(!areaid || _tile.subareaid == areaid)
  414. return _tile;
  415. } while(_tile.GetNext());
  416. }
  417.  
  418. if(i < 2)
  419. NTC_Delay(500);
  420. }
  421.  
  422. return null;
  423. }
  424.  
  425. function NTM_GetWaypointInt()
  426. {
  427. var _waypoint;
  428. var _classid;
  429.  
  430. for(var i = 0 ; i <= 2 ; i++)
  431. {
  432. _waypoint = NTC_FindUnit(NTC_UNIT_OBJECT);
  433.  
  434. if(_waypoint)
  435. {
  436. do
  437. {
  438. _classid = _waypoint.classid;
  439.  
  440. if(_classid == 119 || _classid == 145 || _classid == 156 || _classid == 157
  441. || _classid == 237 || _classid == 238 || _classid == 288 || _classid == 323
  442. || _classid == 324 || _classid == 398 || _classid == 402 || _classid == 429
  443. || _classid == 494 || _classid == 496 || _classid == 511 || _classid == 539)
  444. return _waypoint;
  445. } while(_waypoint.GetNext());
  446. }
  447.  
  448. if(i < 2)
  449. NTC_Delay(500);
  450. }
  451.  
  452. return null;
  453. }
  454.  
  455. function NTM_ChangeAreaInt(how, dest, ownername, myportal)
  456. {
  457. var _portal;
  458. var _playerportal = false;
  459. var _prearea;
  460.  
  461. if(how == "BluePortal")
  462. {
  463. if(!ownername)
  464. ownername = me.name;
  465.  
  466. _playerportal = true;
  467. }
  468.  
  469. if(arguments.length > 3 && myportal)
  470. _portal = myportal;
  471. else
  472. {
  473. _portal = NTM_FindCorrectPortalInt(_playerportal, ownername);
  474.  
  475. if(_portal < 0)
  476. _portal = NTM_FindPortalAreaInt(dest);
  477.  
  478. if(_portal == -1)
  479. return false;
  480. }
  481.  
  482. if(!_portal)
  483. return false;
  484.  
  485. _prearea = me.areaid;
  486.  
  487. for(var i = 0 ; i < 20 ; i++)
  488. {
  489. if((i % 5) == 0)
  490. {
  491. if(i == 10)
  492. NTM_MoveTo(_prearea, me.x+6, me.y+6);
  493.  
  494. if(NTM_GetCloserInt(_portal))
  495. NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _portal);
  496. }
  497.  
  498. NTC_Delay(200);
  499.  
  500. if(me.areaid != _prearea)
  501. break;
  502. }
  503.  
  504. while(me.areaid == 0)
  505. NTC_Delay(200);
  506.  
  507. return (me.areaid == dest);
  508. }
  509.  
  510. function NTM_FindCorrectPortalInt(blueportal, ownername)
  511. {
  512. var _portal;
  513. var _portalname;
  514.  
  515. _portalname = GetLocaleString(3226);
  516.  
  517. if(blueportal)
  518. {
  519. for(var i = 0 ; i <= 2 ; i++)
  520. {
  521. _portal = NTC_FindUnit(NTC_UNIT_OBJECT, _portalname);
  522.  
  523. if(_portal)
  524. {
  525. do
  526. {
  527. if(_portal.mode == 2 && NTC_CheckOwner(_portal, ownername) && GetDistance(me, _portal) <= 30)
  528. return _portal;
  529. } while(_portal.GetNext());
  530. }
  531.  
  532. if(i < 2)
  533. NTC_Delay(500);
  534. }
  535.  
  536. return -2;
  537. }
  538. else
  539. {
  540. for(var i = 0 ; i <= 2 ; i++)
  541. {
  542. _portal = NTC_FindUnit(NTC_UNIT_OBJECT, _portalname);
  543.  
  544. if(_portal)
  545. {
  546. do
  547. {
  548. if(_portal.mode == 2 && !_portal.GetParent())
  549. return _portal;
  550. } while(_portal.GetNext());
  551. }
  552.  
  553. if(i < 2)
  554. NTC_Delay(500);
  555. }
  556. }
  557.  
  558. return -3;
  559. }
  560.  
  561. function NTM_FindPortalAreaInt(dest)
  562. {
  563. var _portal;
  564. var _portalname;
  565.  
  566. _portalname = GetLocaleString(3226);
  567.  
  568. for(var i = 0 ; i <= 2 ; i++)
  569. {
  570. _portal = NTC_FindUnit(NTC_UNIT_OBJECT, _portalname);
  571.  
  572. if(_portal)
  573. {
  574. do
  575. {
  576. if(_portal.mode == 2 && _portal.subareaid == dest)
  577. {
  578. if(_portal.GetParent())
  579. {
  580. if(NTC_CheckOwner(_portal) || NTC_InMyParty(_portal.GetParent()))
  581. return _portal;
  582. }
  583. else
  584. return _portal;
  585. }
  586. } while(_portal.GetNext());
  587. }
  588.  
  589. if(i < 2)
  590. NTC_Delay(500);
  591. }
  592.  
  593. return -1;
  594. }
  595.  
  596. function NTM_GetCloserInt(unit)
  597. {
  598. if(GetDistance(me, unit) > 2)
  599. return NTM_MoveTo(unit.areaid, unit.x, unit.y);
  600.  
  601. return true;
  602. }
  603.  
  604. // vector class
  605. function vector()
  606. {
  607. if(arguments.length == 2)
  608. {
  609. this.x = arguments[0];
  610. this.y = arguments[1];
  611. }
  612. else if(arguments.length == 1)
  613. {
  614. this.x = arguments[0].x;
  615. this.y = arguments[0].y;
  616. }
  617. else
  618. {
  619. this.x = 0;
  620. this.y = 0;
  621. }
  622.  
  623. this.rotate = vector_rotate;
  624. this.normalize = vector_normalize;
  625. this.length = vector_length;
  626. this.setlength = vector_setlength;
  627. this.toString = vector_toString;
  628. this.set = vector_set;
  629. this.angle = vector_angle;
  630. }
  631.  
  632. function vector_rotate(degree)
  633. {
  634. if(!degree)
  635. return true;
  636.  
  637. l = this.length();
  638. if(!l)
  639. return false;
  640.  
  641. this.normalize();
  642.  
  643. rad = degree * (Math.PI/180);
  644.  
  645. nx = this.x * Math.cos(rad) - this.y * Math.sin(rad);
  646. ny = this.x * Math.sin(rad) + this.y * Math.cos(rad);
  647.  
  648. this.x = nx;
  649. this.y = ny;
  650.  
  651. this.normalize();
  652. if(l != 1)
  653. this.setlength(l);
  654.  
  655. return true;
  656. }
  657.  
  658. function vector_angle(v)
  659. {
  660. rad_degree = 180 / Math.PI;
  661.  
  662. return Math.acos((this.x*v.x) + (this.y*v.y)) * rad_degree;
  663. }
  664.  
  665. function vector_length()
  666. {
  667. return Math.sqrt((this.x*this.x) + (this.y*this.y));
  668. }
  669.  
  670. function vector_setlength(length)
  671. {
  672. this.normalize();
  673. this.x *= length;
  674. this.y *= length;
  675. }
  676.  
  677. function vector_normalize()
  678. {
  679. l = this.length();
  680. if(!l)
  681. return false;
  682.  
  683. this.x /= l;
  684. this.y /= l;
  685.  
  686. return true;
  687. }
  688.  
  689. function vector_toString()
  690. {
  691. str = "(";
  692. str += Math.round(this.x*1000)/1000;
  693. str += " , ";
  694. str += Math.round(this.y*1000)/1000;
  695. str += ") : ";
  696. str += Math.round(this.length()*1000)/1000;
  697.  
  698. return str;
  699. }
  700.  
  701. function vector_set(tx, ty)
  702. {
  703. if(arguments.length == 1)
  704. {
  705. this.x = tx.x;
  706. this.y = tx.y;
  707. }
  708. else if(arguments.length == 2)
  709. {
  710. this.x = tx;
  711. this.y = ty;
  712. }
  713. }
  714.  
  715. // coord class
  716. function coord()
  717. {
  718. this.data = null;
  719.  
  720. if(arguments.length == 3)
  721. {
  722. this.x = arguments[0];
  723. this.y = arguments[1];
  724. this.data = arguments[2];
  725. }
  726. else if(arguments.length == 2)
  727. {
  728. this.x = arguments[0];
  729. this.y = arguments[1];
  730. }
  731. else if(arguments.length == 1)
  732. {
  733. this.x = arguments[0].x;
  734. this.y = arguments[0].y;
  735. }
  736. else
  737. {
  738. this.x = 0;
  739. this.y = 0;
  740. }
  741.  
  742. this.dist = coord_dist;
  743. this.dist2 = coord_dist2;
  744. this.dir = coord_dir;
  745. this.move = coord_move;
  746. this.set = coord_set;
  747. this.toString = coord_toString;
  748. }
  749.  
  750. function coord_set(tx, ty, d)
  751. {
  752. if(arguments.length == 1)
  753. {
  754. this.x = tx.x;
  755. this.y = tx.y;
  756.  
  757. if(tx.data)
  758. this.data = tx.data;
  759. else
  760. this.data = null;
  761. }
  762. else if(arguments.length == 2)
  763. {
  764. this.x = tx;
  765. this.y = ty;
  766. this.data = null;
  767. }
  768. else if(arguments.length == 3)
  769. {
  770. this.x = tx;
  771. this.y = ty;
  772. this.data = d;
  773. }
  774. }
  775.  
  776. function coord_dist(tx, ty)
  777. {
  778. if(arguments.length == 1)
  779. {
  780. vx = this.x - tx.x;
  781. vy = this.y - tx.y;
  782.  
  783. return Math.round(Math.sqrt((vx*vx) + (vy*vy)));
  784. }
  785. else if(arguments.length == 2)
  786. {
  787. vx = this.x - tx;
  788. vy = this.y - ty;
  789.  
  790. return Math.round(Math.sqrt((vx*vx) + (vy*vy)));
  791. }
  792. }
  793.  
  794. function coord_dist2(tx, ty)
  795. {
  796. if(arguments.length == 1)
  797. {
  798. vx = this.x - tx.x;
  799. vy = this.y - tx.y;
  800.  
  801. return Math.floor((vx*vx) + (vy*vy));
  802. }
  803. else if(arguments.length == 2)
  804. {
  805. vx = this.x - tx;
  806. vy = this.y - ty;
  807.  
  808. return Math.floor((vx*vx) + (vy*vy));
  809. }
  810. }
  811.  
  812. function coord_dir(tx, ty)
  813. {
  814. if(arguments.length == 1)
  815. {
  816. v = new vector(tx.x-this.x, tx.y-this.y);
  817. v.normalize();
  818.  
  819. return v;
  820. }
  821. else if(arguments.length == 2)
  822. {
  823. v = new vector(tx-this.x, ty-this.y);
  824. v.normalize();
  825.  
  826. return v;
  827. }
  828. }
  829.  
  830. function coord_move(vec, d)
  831. {
  832. if(d)
  833. {
  834. this.x += Math.round(vec.x*d);
  835. this.y += Math.round(vec.y*d);
  836.  
  837. return true;
  838. }
  839. else if(vec.length())
  840. {
  841. this.x += Math.round(vec.x);
  842. this.y += Math.round(vec.y);
  843.  
  844. return true;
  845. }
  846.  
  847. return false;
  848. }
  849.  
  850. function coord_toString()
  851. {
  852. return "( " + this.x + " , " + this.y + " ) " + this.data;
  853. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement