Advertisement
Guest User

usePortal

a guest
Mar 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. usePortal: function (targetArea, owner, unit) {
  2. /*
  3. Pather.usePortal(targetArea, owner, unit);
  4. targetArea - id of the area the portal leads to
  5. owner - name of the portal's owner
  6. unit - use existing portal unit
  7. */
  8. if (this.debugPather) { print("ÿc2Pather: ÿc0usePortal: function (targetArea, owner, unit) " + (targetArea + " " + owner + " " + unit)) } ;
  9.  
  10. Attack.stopLevel = false;
  11. this.stopCourse = false;
  12.  
  13. if (me.inTown && (targetArea || owner || unit)){
  14. Town.move("portalspot");
  15. me.cancel();
  16. }
  17.  
  18. var i, tick, portal, useTK,
  19. preArea = me.area;
  20.  
  21. if (unit) {
  22. portal = copyUnit(unit);
  23.  
  24. if (!portal) {
  25. return false;
  26. }
  27. }
  28.  
  29. for (i = 0; i < 5; i += 1) {
  30. if (!unit) {
  31. portal = this.getPortal(targetArea, owner);
  32. }
  33.  
  34. if (portal) {
  35. useTK = me.classid === 1 && me.getSkill(43, 1) && me.inTown && portal.getParent();
  36.  
  37. if (useTK) {
  38. if (getDistance(me, portal) > 12) {
  39. Attack.getIntoPosition(portal, 12, 0x4);
  40. }
  41.  
  42. Skill.cast(43, 0, portal);
  43. } else {
  44. if (getDistance(me, portal) > 2) {
  45. this.moveToUnit(portal);
  46. }
  47.  
  48. portal.interact();
  49. //sendPacket(1, 0x13, 4, 2, 4, portal.gid);
  50. }
  51.  
  52. if (portal.mode !== 2 && portal.classid === 298) { // Arcane Sanctuary, maybe some other portals
  53. portal.interact();
  54.  
  55. tick = getTickCount();
  56.  
  57. while (getTickCount() - tick < 2000) {
  58. if (portal.mode === 2) {
  59. break;
  60. }
  61.  
  62. delay(10);
  63. }
  64. }
  65.  
  66. tick = getTickCount();
  67.  
  68. while (getTickCount() - tick < 1000) {
  69. while (!me.area) {
  70. delay(100);
  71. }
  72.  
  73. if (me.area !== preArea) {
  74. delay(200);
  75. if(!me.inTown){
  76. this.checkForWP();
  77. }
  78. return true;
  79. }
  80.  
  81. delay(10);
  82. }
  83.  
  84. if (i > 1) {
  85. Packet.flash(me.gid);
  86.  
  87. useTK = false;
  88. }
  89.  
  90. //this.moveTo(me.x + rand(-1, 1) * 3, me.y + rand(-1, 1) * 3); // In case of client/server desync
  91. }
  92.  
  93. delay(100);
  94. }
  95.  
  96. return false;
  97. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement