Guest User

Untitled

a guest
Jul 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // yeah, there's some lame null pointer crash in LeaderStater2.2 when you exit the game manually..
  2. // din dickers around and doesn't go for bo..big problem - in one scenario, it happens cus din is town managing and sorc/barb are ready to go.  should make a ready notification and only bo if all chars are ready
  3. // din switchs to vigor when he moves around in cs - this is bad
  4. // FIXME: teleporting is slow... sorc gets hit, stunned, and teleporting doesn't take the first chance to cast after stunned and waits until she gets stunned again and she ends up dieing
  5. // FIXME: sorc delay after popping seal waiting on spawn. make her dodge
  6. // FIXME: dodging, i messed it up trying to improve it
  7. //sometimes sorc tp creating fails and she doesn't make tp
  8. //when sorc goes so far ahead before din kills seis, the nta killmonster diablo fails and she quits
  9. // on a rare occasion, the din thought he killed seis when he really didn't and the party continued to try to kill diablo even though seis wasn't dead.  maybe add some monster checks before diablo or smth
  10. // FIXME: large delay after din takes TP before he precasts.
  11. // still on some weird occasion the din town manages at end of run
  12. // TODO: better barb bo casting, the current one has lame delays somewhere
  13. // din precasts or smth after viz dies and doesn't take tp back to town - it's gotta be the NTM code trying to kill monsters in the way.
  14. // FIXME: sometimes din doesn't take bo tp - seems to be only when he town manages and the others are ready already
  15. // FIXME: sorc stands around when she needs to be fighting a boss or shit
  16. // FIXME: delays where the sorc just sits there after popping a seal - make her move around.
  17. // FIXME: din doesn't do pots etc when precasting - look in NTA for code to do this
  18. // FIXME: sorc doesn't do pots etc when dodging at star
  19. // FIXME: sorc doesn't wait on sealboss to die if sorcSucks = 0 (happens due to immunity skipping).
  20. // FIXME: delays when hitting seals - she stands there and dies. makes her dodge and then try to hit seal again if it still isn't popped
  21. // TODO: use NTConfig_ variables instead of just setting them in the script
  22. // TODO: NTCS_TeleportTo
  23. // TODO: NTCS_CheckAct
  24. // TODO: make din select concen before/after he takes tp
  25. // TODO: instead of looping createtp, just mod the createtp function to loop
  26. // TODO: instead of trying to use NTA_KillMonster for the sorc, make a function that clears the monsters near the boss until the boss is dead
  27. // TODO: NTCS_Town() that tries to take any close tps of members of your party or even your own if you can reach them without any collisions and they are within a small distance, but if all else fails then just make your own
  28. // TODO: NTCS_UsePortal function that tries it multiple times - another benefit to this is that you can remove the area delay
  29. // in latest taking tp's is bugged? or why else could the barb AND din not take tp for bo
  30. // din casts hammers until death even though boss is dead?
  31.  
  32. // new list:
  33. // make a var dinSucks.  if it is true, then din will go to healer then give a DinReady message after every sealboss if he has less than x/x hp/mana. sorc will wait on this message..
  34. // sorc stands still when grabbing potions with telekinesis. maybe shouldn't use telegrab
  35. // laggy ass sorc pickit that causes her to stand around tanking?
  36. // sorc goes on ahead even though sealboss isn't dead -.-
  37. // din thinks sealboss is dead when it really isn't.
  38.  
  39. //even NEWER list!
  40. // - chars wrongly thinking they killed sealboss still a problem
  41. // - pickit still hangs and causes chickens
  42. // - on a rare occasion the first time i started the bot, din/barb didn't go for bo
  43. // - dinsucks not implemented
  44. // - it's a problem when din fails to take sorc's boss tp
  45. // - sorc tries to tank monsters after popping seal. make her dodge while waiting to see if it popped correctly?
  46. // - sayMsgs must always be 1 because the sealboss down notification is message based.
  47. // - idea: sorc only tries to kill sealboss if she has above X hp/mana
  48. // - idea: change SnagIt so it only grabs potions if you are low on them
  49. // - idea for hdin attack code: if the target isn't taking damage, move
  50. // - idea: NTCS_VisitTown, and if you're a sorc, it will dodge to a close place with no monsters so it doesn't try to tp when being chewed up by a mob
  51. // - idea: sorc doesn't fight sealboss if there's more than X monsters(this is bad tho cus din could get overwhelmed)
  52. // - idea: after sorc pops seal, make her go stand by din and shoot orbs until boss dies?
  53. // - smart sorc mode: if less than x hp, don't fight boss.  if greater than x monsters OR x champions/uniques OR din has low hp then fight beside din.  if no other conditions met, fight monster normally.
  54. // - idea for tp chicken, if there is a portal made by you or someone in your party nearby, take it
  55.  
  56. var _MyDT_PreMessage = "lame";
  57. var _sealpos = 0;
  58. var safex;
  59. var safey;
  60. var prevx;
  61. var prevy;
  62. var leader = "telemarketur";
  63.  
  64. var sorcGetDiaXP = 0;
  65. var barbTakeTps = 0;
  66. var sayMsgs = 1;
  67. var barbLeaveAfterBo = 0;
  68. var onlySora = 0;
  69. var sorcSucks = 0; // TODO: instead of this var, make vars that decide if the sorc fights each seperate sealboss.
  70. var dinTouchHealerHP = 0; // if after killing a sealboss, the din has less than this percent of HP he will go touch jamella. set to 0 to disable
  71.  
  72. var _startExp;
  73.  
  74. function NTCS_Sora_TeleportTo(x, y) // doesn't care where tele lands
  75. {
  76.     var _ox = me.x, _oy = me.y;
  77.     NTC_CastSkill(54, NTC_HAND_RIGHT, x, y);
  78.    
  79.     if(NTConfig_TeleGrab == 1){
  80.         NTConfig_TeleGrab++;
  81.         NTSI_PickItems();
  82.         NTConfig_TeleGrab--;
  83.     }
  84.  
  85.     MyCS_CatchShrine();
  86.    
  87.     for(var i = 0 ; i < 20 ; i++)
  88.     {
  89.         if(me.x != _ox || me.y != _oy){
  90.             return true;
  91.         }
  92.  
  93.         Delay(NTC_DELAY_FRAME);
  94.     }
  95.     return false;
  96. }
  97.  
  98. function NTCS_WalkTo(x, y) { // kolton's updated walkto
  99.     var i, distance, nTimer,
  100.         nFail = 0,
  101.         attemptCount = 0;
  102.  
  103.     if (me.runwalk === 0) {
  104.         me.runwalk = 1;
  105.     }
  106.    
  107.     MoveLoop : while (GetDistance(me.x, me.y, x, y) > 3 && me.mode !== 17) {
  108.        
  109.         ClickMap(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, x, y);
  110.         Delay(30);
  111.         ClickMap(NTC_CLICK_LUP, NTC_SHIFT_NONE, null);
  112.        
  113.         attemptCount += 1;
  114.         nTimer = GetTickCount();
  115.        
  116.         while (me.mode !== 2 && me.mode !== 3 && me.mode !== 6) {
  117.             if (me.mode === 17) {
  118.                 break MoveLoop;
  119.             }
  120.            
  121.             if ((GetTickCount() - nTimer) > 500) {
  122.                 ++nFail;
  123.                
  124.                 if (nFail == 3) {
  125.                     return false;
  126.                 }
  127.                
  128.                 ClickMap(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, me.x + Random(-3, 3), me.y + Random(-3, 3));
  129.                 Delay(30);
  130.                 ClickMap(NTC_CLICK_LUP, NTC_SHIFT_NONE, null);
  131.                
  132.                 continue MoveLoop;
  133.             }
  134.            
  135.             Delay(20);
  136.         }
  137.        
  138.         while (me.mode !== 1 && me.mode !== 5 && me.mode !== 17) {
  139.             Delay(5);
  140.         }
  141.        
  142.         if (attemptCount >= 3) {
  143.             return false;
  144.         }
  145.     }
  146.    
  147.     return true;
  148. }
  149.  
  150. function NTCS_MoveTo(areaid, x, y, retry, clearpath, canswitch)
  151. {
  152.     //NT_LoadConfig();
  153.     //NTSI_LoadNIPFiles("NTBot/item_configs");
  154.  
  155.     var i, n;
  156.     var _teleport;
  157.     var _path = undefined; // houstin add
  158.     var _retry = 0;
  159.     var _attacked = false;
  160.  
  161.     if(x == me.x && y == me.y) { return true; }
  162.  
  163.     if(arguments.length < 4) { retry = 3; }
  164.  
  165.     if(arguments.length < 5) { clearpath = false; }
  166.  
  167.     if(arguments.length < 6) { canswitch = true; }
  168.    
  169.     // ubi21 Enigma reset start
  170.     ////////////////////////////       
  171.     if(NTConfig_ResetEnigma && NTC_GetSkillLevel(54) < 1) {
  172.         NTC_SendLogToOOG(NTC_LOG_COMMON, COLOR_1 + "Teleport Bug Found!");
  173.         Print(COLOR_1 + "Teleport Bug Found!");
  174.         NTT_ResetEnigma();     
  175.     }
  176.     // ubi21 Enigma reset end
  177.     ////////////////////////////
  178.    
  179.     if(NTC_InTown() || NTC_GetSkillLevel(54) < 1) { _teleport = false; }
  180.     else { _teleport = true; }
  181.  
  182.     if (_teleport && GetDistance(me.x, me.y, x, y) < 30) {// houstin add
  183.         return NTM_TeleportTo(x, y);
  184.     }
  185.    
  186.     _path = GetPath(areaid, me.x, me.y, x, y, _teleport);
  187.  
  188.     if(!_path) { return (NTC_InTown() && (NTCS_WalkTo(x, y) || NTTM_TownMoveXY(x, y))); }
  189.    
  190.     if(NTConfig_SwitchTele && _path.length > 2 && canswitch && _teleport){
  191.         if(NTC_SwapWeapons(1)){
  192.             if(debugMove){
  193.                 switchedtoTele = me.weaponstab == 1;
  194.                 Print(COLOR_2 + "Swapped to tele " + switchedtoTele);
  195.             }
  196.         }
  197.     }
  198.    
  199.     if ((NTTMGR_CheckCurse(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe, true)) || (me.hp <= parseInt(me.hpmax * NTConfig_TPChicken,10) / 100)) {
  200.         NTTMGR_VisitTown();
  201.     }
  202.  
  203.     for(i = 0 ; i < _path.length ; i++)
  204.     {
  205.         for(n = 0 ; n < 2 ; n++)
  206.         {
  207.             if(_teleport)
  208.             {
  209.                 if(NTM_TeleportTo(_path[i][0]+Random(-n, n), _path[i][1]+Random(-n, n))) { break; }
  210.             }
  211.             else
  212.             {
  213.                 if(NTCS_WalkTo(_path[i][0], _path[i][1])) { break; }
  214.             }
  215.         }
  216.        
  217.         if(!NTC_InTown()) { NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe); }
  218.        
  219.         if(n < 2)
  220.         {
  221.             if(clearpath)
  222.             {
  223.                 if(!NTA_ClearPosition('20', true, '2')) { return false; }
  224.                 NTP_DoPrecast(false);
  225.                 NTCS_MoveTo(me.areaid, _path[i][0], _path[i][1], 1);
  226.             }
  227.         }
  228.         else if(_retry < retry)
  229.         {
  230.             _path = GetPath(areaid, me.x, me.y, x, y, _teleport);
  231.  
  232.             if(!_path) { return false; }
  233.  
  234.             i = -1;
  235.             _retry++;
  236.             _attacked = false;
  237.         }
  238.         else if((!_attacked) && (!NTConfig_SwitchTele))
  239.         {
  240.             //NTA_ClearPosition(10, true);
  241.             //NTSI_PickItems();
  242.             _attacked = true;
  243.             _retry = 0;
  244.         }
  245.         else {
  246.             return false;
  247.         }
  248.     }
  249.    
  250.     return true;
  251. }
  252.  
  253. function NTCS_MoveToPresetUnit(areaid, unittype, classid, offsetx, offsety, clearpath)
  254. {
  255.     var i, n;
  256.     var _unit;
  257.  
  258.     if(arguments.length < 4)
  259.     {
  260.         offsetx = 0;
  261.         offsety = 0;
  262.     }
  263.  
  264.     if(arguments.length < 6)
  265.         clearpath = false;
  266.  
  267.     for(i = 0 ; i <= 15 ; i++)
  268.     {
  269.         _unit = GetPresetUnits(areaid, unittype);
  270.  
  271.         if(_unit)
  272.         {
  273.             for(n = 0 ; n < _unit.length ; n++)
  274.             {
  275.                 if(_unit[n].id == classid)
  276.                     return NTCS_MoveTo(areaid, _unit[n].roomx*5+_unit[n].x+offsetx, _unit[n].roomy*5+_unit[n].y+offsety, 3, clearpath);
  277.             }
  278.         }
  279.     }
  280.  
  281.     return false;
  282. }
  283.  
  284. function NTCS_PaladinAttackInt(target, firstorder) {
  285.     var _primaryindex;
  286.     var _attackSkill;
  287.  
  288.     if ((NTTMGR_CheckCurse(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe, true)) || (me.hp <= parseInt(me.hpmax * NTConfig_TPChicken,10) / 100)) {
  289.         if (!NTTMGR_VisitTown()) return 0;
  290.     }
  291.  
  292.     if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100) {
  293.         if (GetDistance(me, target) > _NTA_SkillRange[0] || !CheckCollision(me, target, 4)) {
  294.             var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[0], 4);
  295.  
  296.             if (_pos) NTCS_MoveTo(target.areaid, _pos[0], _pos[1], 0, false, false);
  297.         }
  298.  
  299.         if (!NTC_CastSkill(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) return 2;
  300.  
  301.         return 3;
  302.     }
  303.  
  304.     _primaryindex = (target.spectype & 0x0A) ? 1 : 3;
  305.     if (NTConfig_OnlySmiteStationary && NTConfig_AttackSkill[1] == 97 && GetBaseStat("monstats2.txt", target.classid, 56) == 1) _primaryindex = 3;
  306.  
  307.     _attackIndex = NTA_GetAttackType(target, _primaryindex, 100, 100, 100);
  308.  
  309.     if (NTConfig_AttackSkill[_attackIndex] > -1) {
  310.         if (_NTA_SkillRange[_attackIndex] < 4 && !CheckCollision(target.areaid, target.x, target.y, 1)) return 1;
  311.  
  312.         if (!NTCS_PaladinCastSkillInt(_attackIndex, target)) return 2;
  313.  
  314.         return 3;
  315.     }
  316.     return 1;
  317. }
  318.  
  319. function WillMyHammerHit(atx, aty)
  320. {
  321.     var hx = atx - me.x;
  322.     var hy = aty - me.y;
  323.     if((hx == -10 && hy == -9) ||
  324.         (hx == -9 && hy == -10) ||
  325.         (hx == -11 && hy == -7) ||
  326.         (hx == -10 && hy == -8) ||
  327.         (hx == -9 && hy == -9) ||
  328.         (hx == -8 && hy == -10) ||
  329.         (hx == -7 && hy == -11) ||
  330.         (hx == -6 && hy == -12) ||
  331.         (hx == -5 && hy == -13) ||
  332.         (hx == -12 && hy == -5) ||
  333.         (hx == -11 && hy == -6) ||
  334.         (hx == -10 && hy == -7) ||
  335.         (hx == -9 && hy == -8) ||
  336.         (hx == -8 && hy == -9) ||
  337.         (hx == -7 && hy == -10) ||
  338.         (hx == -6 && hy == -11) ||
  339.         (hx == -5 && hy == -12) ||
  340.         (hx == -12 && hy == -4) ||
  341.         (hx == -11 && hy == -5) ||
  342.         (hx == -10 && hy == -6) ||
  343.         (hx == -9 && hy == -7) ||
  344.         (hx == -7 && hy == -9) ||
  345.         (hx == -6 && hy == -10) ||
  346.         (hx == -5 && hy == -11) ||
  347.         (hx == -4 && hy == -12) ||
  348.         (hx == -3 && hy == -13) ||
  349.         (hx == -13 && hy == -2) ||
  350.         (hx == -12 && hy == -2) ||
  351.         (hx == -11 && hy == -4) ||
  352.         (hx == -10 && hy == -5) ||
  353.         (hx == -3 && hy == -12) ||
  354.         (hx == -2 && hy == -13) ||
  355.         (hx == -12 && hy == -2) ||
  356.         (hx == -11 && hy == -3) ||
  357.         (hx == -10 && hy == -4) ||
  358.         (hx == -3 && hy == -11) ||
  359.         (hx == -2 && hy == -12) ||
  360.         (hx == -1 && hy == -13) ||
  361.         (hx == 0 && hy == -14) ||
  362.         (hx == -11 && hy == 2) ||
  363.         (hx == -8 && hy == -1) ||
  364.         (hx == -7 && hy == -2) ||
  365.         (hx == -6 && hy == -3) ||
  366.         (hx == -5 && hy == -4) ||
  367.         (hx == -4 && hy == -5) ||
  368.         (hx == -3 && hy == -6) ||
  369.         (hx == -2 && hy == -7) ||
  370.         (hx == -1 && hy == -8) ||
  371.         (hx == 0 && hy == -9) ||
  372.         (hx == -12 && hy == 4) ||
  373.         (hx == -11 && hy == 3) ||
  374.         (hx == -10 && hy == 2) ||
  375.         (hx == -8 && hy == 0) ||
  376.         (hx == -7 && hy == -1) ||
  377.         (hx == -6 && hy == -2) ||
  378.         (hx == 0 && hy == -8) ||
  379.         (hx == -12 && hy == 4) ||
  380.         (hx == -11 && hy == 3) ||
  381.         (hx == -10 && hy == 2) ||
  382.         (hx == -8 && hy == 0) ||
  383.         (hx == -7 && hy == 1) ||
  384.         (hx == -6 && hy == 0) ||
  385.         (hx == -3 && hy == -3) ||
  386.         (hx == -2 && hy == -4) ||
  387.         (hx == 2 && hy == -8) ||
  388.         (hx == 3 && hy == -9) ||
  389.         (hx == -11 && hy == 4) ||
  390.         (hx == -8 && hy == 1) ||
  391.         (hx == -7 && hy == 0) ||
  392.         (hx == -6 && hy == -1) ||
  393.         (hx == 0 && hy == -7) ||
  394.         (hx == 1 && hy == -8) ||
  395.         (hx == 2 && hy == -9) ||
  396.         (hx == -11 && hy == 5) ||
  397.         (hx == -10 && hy == 4) ||
  398.         (hx == -8 && hy == 2) ||
  399.         (hx == -7 && hy == 1) ||
  400.         (hx == -6 && hy == 0) ||
  401.         (hx == -3 && hy == -3) ||
  402.         (hx == -2 && hy == -4) ||
  403.         (hx == 2 && hy == -8) ||
  404.         (hx == 3 && hy == -9) ||
  405.         (hx == -11 && hy == 5) ||
  406.         (hx == -10 && hy == 4) ||
  407.         (hx == -8 && hy == 2) ||
  408.         (hx == -7 && hy == 1) ||
  409.         (hx == -6 && hy == 0) ||
  410.         (hx == -3 && hy == -3) ||
  411.         (hx == -2 && hy == -4) ||
  412.         (hx == 2 && hy == -8) ||
  413.         (hx == 3 && hy == -9) ||
  414.         (hx == -10 && hy == 5) ||
  415.         (hx == -7 && hy == 2) ||
  416.         (hx == -6 && hy == 1) ||
  417.         (hx == -3 && hy == -2) ||
  418.         (hx == -2 && hy == -3) ||
  419.         (hx == -1 && hy == -4) ||
  420.         (hx == 0 && hy == -5) ||
  421.         (hx == 2 && hy == -7) ||
  422.         (hx == 3 && hy == -8) ||
  423.         (hx == -10 && hy == 5) ||
  424.         (hx == -7 && hy == 2) ||
  425.         (hx == -6 && hy == 1) ||
  426.         (hx == -3 && hy == -2) ||
  427.         (hx == -2 && hy == -3) ||
  428.         (hx == -1 && hy == -4) ||
  429.         (hx == 0 && hy == -5) ||
  430.         (hx == 2 && hy == -7) ||
  431.         (hx == 3 && hy == -8) ||
  432.         (hx == -10 && hy == 6) ||
  433.         (hx == -9 && hy == 5) ||
  434.         (hx == -7 && hy == 3) ||
  435.         (hx == -6 && hy == 2) ||
  436.         (hx == -3 && hy == -1) ||
  437.         (hx == 2 && hy == -2) ||
  438.         (hx == -1 && hy == -3) ||
  439.         (hx == 0 && hy == -4) ||
  440.         (hx == 1 && hy == -5) ||
  441.         (hx == 3 && hy == -7) ||
  442.         (hx == 4 && hy == -8) ||
  443.         (hx == -9 && hy == 6) ||
  444.         (hx == -6 && hy == 3) ||
  445.         (hx == -3 && hy == 0) ||
  446.         (hx == -2 && hy == -1) ||
  447.         (hx == -1 && hy == -2) ||
  448.         (hx == 0 && hy == -3) ||
  449.         (hx == 1 && hy == -4) ||
  450.         (hx == 4 && hy == -7) ||
  451.         (hx == 5 && hy == -8) ||
  452.         (hx == -9 && hy == 7) ||
  453.         (hx == -8 && hy == 6) ||
  454.         (hx == -6 && hy == 4) ||
  455.         (hx == -5 && hy == 3) ||
  456.         (hx == -3 && hy == 1) ||
  457.         (hx == -2 && hy == 0) ||
  458.         (hx == -1 && hy == -1) ||
  459.         (hx == 1 && hy == -3) ||
  460.         (hx == 2 && hy == -4) ||
  461.         (hx == 4 && hy == -6) ||
  462.         (hx == 5 && hy == -7) ||
  463.         (hx == -9 && hy == 8) ||
  464.         (hx == -8 && hy == 7) ||
  465.         (hx == -6 && hy == 5) ||
  466.         (hx == -5 && hy == 4) ||
  467.         (hx == -2 && hy == 1) ||
  468.         (hx == -1 && hy == 0) ||
  469.         (hx == 0 && hy == -1) ||
  470.         (hx == 2 && hy == -3) ||
  471.         (hx == 3 && hy == -4) ||
  472.         (hx == 5 && hy == -6) ||
  473.         (hx == 6 && hy == -7) ||
  474.         (hx == -8 && hy == 8) ||
  475.         (hx == -5 && hy == 5) ||
  476.         (hx == -4 && hy == 4) ||
  477.         (hx == -2 && hy == 2) ||
  478.         (hx == -1 && hy == 1) ||
  479.         (hx == 0 && hy == 0) ||
  480.         (hx == 2 && hy == -2) ||
  481.         (hx == 3 && hy == -3) ||
  482.         (hx == 6 && hy == -6) ||
  483.         (hx == -8 && hy == 9) ||
  484.         (hx == -7 && hy == 8) ||
  485.         (hx == -5 && hy == 6) ||
  486.         (hx == -4 && hy == 5) ||
  487.         (hx == -3 && hy == 4) ||
  488.         (hx == -1 && hy == 2) ||
  489.         (hx == 0 && hy == 1) ||
  490.         (hx == 1 && hy == 0) ||
  491.         (hx == 3 && hy == -2) ||
  492.         (hx == 4 && hy == -3) ||
  493.         (hx == 6 && hy == -5) ||
  494.         (hx == 7 && hy == -6) ||
  495.         (hx == -7 && hy == 9) ||
  496.         (hx == -6 && hy == 8) ||
  497.         (hx == -4 && hy == 6) ||
  498.         (hx == -3 && hy == 5) ||
  499.         (hx == 0 && hy == 2) ||
  500.         (hx == 1 && hy == 1) ||
  501.         (hx == 3 && hy == -1) ||
  502.         (hx == 4 && hy == -2) ||
  503.         (hx == 7 && hy == -5) ||
  504.         (hx == -6 && hy == 9) ||
  505.         (hx == -3 && hy == 6) ||
  506.         (hx == -2 && hy == 5) ||
  507.         (hx == 4 && hy == -1) ||
  508.         (hx == 5 && hy == -2) ||
  509.         (hx == 7 && hy == -4) ||
  510.         (hx == 8 && hy == -5) ||
  511.         (hx == -6 && hy == 10) ||
  512.         (hx == -5 && hy == 9) ||
  513.         (hx == -2 && hy == 6) ||
  514.         (hx == -1 && hy == 5) ||
  515.         (hx == 4 && hy == 0) ||
  516.         (hx == 5 && hy == -1) ||
  517.         (hx == 7 && hy == -3) ||
  518.         (hx == 8 && hy == -4) ||
  519.         (hx == -5 && hy == 10) ||
  520.         (hx == -4 && hy == 9) ||
  521.         (hx == -2 && hy == 7) ||
  522.         (hx == -1 && hy == 6) ||
  523.         (hx == 0 && hy == 5) ||
  524.         (hx == 4 && hy == 1) ||
  525.         (hx == 5 && hy == 0) ||
  526.         (hx == 8 && hy == -3) ||
  527.         (hx == 9 && hy == -4) ||
  528.         (hx == -4 && hy == 10) ||
  529.         (hx == -1 && hy == 7) ||
  530.         (hx == 0 && hy == 6) ||
  531.         (hx == 1 && hy == 5) ||
  532.         (hx == 2 && hy == 4) ||
  533.         (hx == 3 && hy == 3) ||
  534.         (hx == 4 && hy == 2) ||
  535.         (hx == 5 && hy == 1) ||
  536.         (hx == 6 && hy == 0) ||
  537.         (hx == 8 && hy == -2) ||
  538.         (hx == 9 && hy == -3) ||
  539.         (hx == -4 && hy == 11) ||
  540.         (hx == -3 && hy == 10) ||
  541.         (hx == -2 && hy == 9) ||
  542.         (hx == 0 && hy == 7) ||
  543.         (hx == 1 && hy == 6) ||
  544.         (hx == 2 && hy == 5) ||
  545.         (hx == 3 && hy == 4) ||
  546.         (hx == 4 && hy == 3) ||
  547.         (hx == 5 && hy == 2) ||
  548.         (hx == 6 && hy == 1) ||
  549.         (hx == 9 && hy == -2) ||
  550.         (hx == -2 && hy == 10) ||
  551.         (hx == 1 && hy == 7) ||
  552.         (hx == 2 && hy == 6) ||
  553.         (hx == 3 && hy == 5) ||
  554.         (hx == 4 && hy == 4) ||
  555.         (hx == 5 && hy == 3) ||
  556.         (hx == 6 && hy == 2) ||
  557.         (hx == 8 && hy == 0) ||
  558.         (hx == 9 && hy == -1) ||
  559.         (hx == 10 && hy == -2) ||
  560.         (hx == -2 && hy == 11) ||
  561.         (hx == -1 && hy == 10) ||
  562.         (hx == 3 && hy == 6) ||
  563.         (hx == 4 && hy == 5) ||
  564.         (hx == 5 && hy == 4) ||
  565.         (hx == 9 && hy == 0) ||
  566.         (hx == -1 && hy == 11) ||
  567.         (hx == 8 && hy == 2) ||
  568.         (hx == 9 && hy == 1) ||
  569.         (hx == 10 && hy == 0) ||
  570.         (hx == 0 && hy == 11) ||
  571.         (hx == 1 && hy == 10) ||
  572.         (hx == 2 && hy == 9) ||
  573.         (hx == 9 && hy == 2) ||
  574.         (hx == 0 && hy == 12) ||
  575.         (hx == 1 && hy == 11) ||
  576.         (hx == 2 && hy == 10) ||
  577.         (hx == 3 && hy == 9) ||
  578.         (hx == 4 && hy == 8) ||
  579.         (hx == 7 && hy == 5) ||
  580.         (hx == 8 && hy == 4) ||
  581.         (hx == 9 && hy == 3) ||
  582.         (hx == 10 && hy == 2) ||
  583.         (hx == 0 && hy == 12) ||
  584.         (hx == 1 && hy == 11) ||
  585.         (hx == 2 && hy == 10) ||
  586.         (hx == 3 && hy == 9) ||
  587.         (hx == 4 && hy == 8) ||
  588.         (hx == 7 && hy == 5) ||
  589.         (hx == 8 && hy == 4) ||
  590.         (hx == 9 && hy == 3) ||
  591.         (hx == 10 && hy == 2) ||
  592.         (hx == 2 && hy == 11) ||
  593.         (hx == 3 && hy == 10) ||
  594.         (hx == 4 && hy == 9) ||
  595.         (hx == 5 && hy == 8) ||
  596.         (hx == 6 && hy == 7) ||
  597.         (hx == 7 && hy == 6) ||
  598.         (hx == 8 && hy == 5) ||
  599.         (hx == 9 && hy == 4) ||
  600.         (hx == 4 && hy == 10) ||
  601.         (hx == 5 && hy == 9) ||
  602.         (hx == 6 && hy == 8) ||
  603.         (hx == 7 && hy == 7) ||
  604.         (hx == 8 && hy == 6) ||
  605.         (hx == 9 && hy == 5) ||
  606.         (hx == 10 && hy == 4) ||
  607.         (hx == 6 && hy == 9) ||
  608.         (hx == 7 && hy == 8) ||
  609.         (hx == 8 && hy == 7))
  610.         return true;
  611.     return false;
  612. }
  613.  
  614. function NTCS_PaladinCastSkillInt(index, target) {
  615.  
  616.     if (NTConfig_AttackSkill[index] == 112) {
  617.         if (me.x - target.x < 1 || me.x - target.x > 2 || me.y - target.y < 1 || me.y - target.y > 2) {
  618.             if (CheckCollision(target.areaid, target.x + 2, target.y + 2, 1)) NTCS_MoveTo(target.areaid, target.x + 2, target.y + 2, 0, false, false);
  619.             else if (me.x - target.x < -4 || me.x - target.x > 2 || me.y - target.y < 0 || me.y - target.y > 2) NTCS_MoveTo(target.areaid, target.x - 4, target.y, 0, false, false);
  620.             var hhx = target.x - me.x;
  621.             var hhy = target.y - me.y;
  622.             if(WillMyHammerHit(target.x, target.y))
  623.                 Print("hammer will hit them - hx = " + hhx + ", hy = " + hhy);
  624.             else
  625.                 Print("hammer won't hit them - hx = " + hhx + ", hy = " + hhy);
  626.         }
  627.     } else {
  628.         if (GetDistance(me, target) > _NTA_SkillRange[index] || !CheckCollision(me, target, 4)) {
  629.             var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[index], 4);
  630.  
  631.             if (_pos) NTCS_MoveTo(target.areaid, _pos[0], _pos[1], 0, false, false);
  632.         }
  633.     }
  634.  
  635.     if (NTConfig_AttackSkill[index + 1] > -1) NTC_PutSkill(NTConfig_AttackSkill[index + 1], NTC_HAND_RIGHT);
  636.  
  637.     return NTC_CastSkill(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  638. }
  639.  
  640. function NTCS_Din_KillMonster(classid) {
  641.     var _target;
  642.  
  643.     if (NTConfig_AttackSkill[1] < 0) {
  644.         return false;
  645.     }
  646.  
  647.     _target = NTC_FindUnit(NTC_UNIT_MONSTER, classid, 5);
  648.  
  649.     if (!_target) {
  650.         return false;
  651.     }
  652.    
  653.     if (NTConfig_PrioritizeWeakerFoes && NTConfig_PrioritizeWeakerFoesAreaDisable.indexOf(me.areaid) < 0) {
  654.         NTA_ClearPosition(20, true, 2);
  655.     }
  656.  
  657.     if (_target.IsAttackable()) {
  658.         var _attackcount = 0;
  659.  
  660.         while (_attackcount < 300 && NTA_IsValidMonster(_target)) {
  661.             if (NTCS_PaladinAttackInt(_target, (_attackcount % 30) == 0) < 2) {
  662.                 break;
  663.             }
  664.  
  665.             _attackcount++;
  666.             _sorcattack++;
  667.         }
  668.     }
  669.     if(skippedImmuneBoss){
  670.         Print(COLOR_2 + "skipping " + _target.name + " because of your skip immune settings");
  671.         return true;
  672.     }
  673.     return (_target.hp <= 0 || _target.mode == 0 || _target.mode == 12);
  674. }
  675.  
  676. function NTA_SorceressAttackInt(target, firstorder) {
  677.     var _primaryindex;
  678.     var _attackSkill;
  679.  
  680.     if ((NTTMGR_CheckCurse(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe, true)) || (me.hp <= parseInt(me.hpmax * NTConfig_TPChicken,10) / 100)) {
  681.         if (!NTTMGR_VisitTown()) { return 0; }
  682.     }
  683.  
  684.     if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && me.GetSkillStatus(NTConfig_AttackSkill[0]) != 8) {
  685.         if (GetDistance(me, target) > _NTA_SkillRange[0] || !CheckCollision(me, target, 4)) {
  686.             var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[0], 4);
  687.  
  688.             if (_pos) NTCS_MoveTo(target.areaid, _pos[0], _pos[1], 0, false, false);
  689.         }
  690.  
  691.         if (!NTC_CastSkill(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) return 2;
  692.  
  693.         return 3;
  694.     }
  695.  
  696.     var _caststatic = true;
  697.  
  698.     if (NTConfig_StaticBossesOnly) _caststatic = NTConfig_StaticBossesSelect.indexOf(target.name) > -1;
  699.  
  700.     if (_caststatic && NTConfig_CastStatic < 100 && parseInt(target.hp * 100 / target.hpmax) > NTConfig_CastStatic && NTA_GetResistance(target, NTA_DAMAGE_LIGHTNING) <= 80) {
  701.         var _staticlevel = NTC_GetSkillLevel(42);
  702.  
  703.         if (_staticlevel > 0) {
  704.             var _staticrange;
  705.             var _castx, _casty;
  706.  
  707.             _staticrange = Math.floor((5 + _staticlevel - 1) * 2 / 3);
  708.  
  709.             if (GetDistance(me, target) > _staticrange || !CheckCollision(me, target, 6)) {
  710.                 var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _staticrange, 6);
  711.  
  712.                 if (_pos) NTCS_MoveTo(target.areaid, _pos[0], _pos[1], 0, false, false);
  713.             }
  714.  
  715.             if (target.x < me.x) _castx = me.x - 1;
  716.             else if (target.x > me.x) _castx = me.x + 1;
  717.             else _castx = me.x;
  718.  
  719.             if (target.y < me.y) _casty = me.y - 1;
  720.             else if (target.y > me.y) _casty = me.y + 1;
  721.             else _casty = me.y;
  722.  
  723.             if (!CheckCollision(target.areaid, _castx, _casty, 1)) {
  724.                 _castx = me.x;
  725.                 _casty = me.y;
  726.             }
  727.  
  728.             if (!NTC_CastSkill(42, NTC_HAND_RIGHT, _castx, _casty)) return 2;
  729.  
  730.             return 3;
  731.         }
  732.     }
  733.  
  734.     _primaryindex = (target.spectype & 0x0A) ? 1 : 3;
  735.  
  736.     _attackSkill = NTA_GetAttackType(target, _primaryindex, 91, 81, 81);
  737.  
  738.     if (NTConfig_AttackSkill[_attackSkill] > -1) {
  739.         if (!NTCS_SorceressCastSkillInt(_attackSkill, target, _primaryindex)) return 2;
  740.  
  741.         return 3;
  742.     }
  743.  
  744.  
  745.     if (NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100 || (_primaryindex == 1 && NTC_GetMerc())) {
  746.         if (!NTCS_SorceressCastSkillInt(_primaryindex, target, _primaryindex)) return 2;
  747.  
  748.         return 3;
  749.     }
  750.  
  751.     return 1;
  752. }
  753.  
  754. function NTCS_SorceressCastSkillInt(index, target, primaryIndex) {
  755.     var secondarySkill = 0;
  756.     if (target.name == "Baal" && NTConfig_AttackSkill[10] > -1) {
  757.         index = 10;
  758.         if(NTConfig_AttackSkill[index] == 38) {
  759.             _NTA_SkillRange[index] = 2;
  760.         }
  761.     }
  762.        
  763.     if ((target.name == "Mephisto" || target.name == "Andariel" || target.name == "Duriel" || target.name == "Diablo") && NTConfig_AttackSkill[9] > -1) {
  764.         index = 9;
  765.         if(NTConfig_AttackSkill[index] == 38) {
  766.             _NTA_SkillRange[index] = 2;
  767.         }      
  768.     }
  769.    
  770.     //var secondarySkill = 0;
  771.     _haveCL = NTC_GetSkillLevel(53); // check to see if we even have CL
  772.     _havetele = NTC_GetSkillLevel(54);
  773.     if (DebugAttacksInGame) {
  774.         Print(COLOR_3 + " sorc attack count = " + _sorcattack);
  775.     }
  776.     if (DebugAttacksInGame && target.GetState(28) > 0) {
  777.         Print(COLOR_2 + "target convicted");
  778.         Print(COLOR_2 + "continue attack");
  779.     }
  780.     if (_sorcattack >= 20) _sorcattack = 0;
  781.     if (_havetele && NTConfig_DancingSorc) {
  782.         NTT_CheckMerc(); // revive merc
  783.         if ((NTA_CheckMyHp() || ((target.GetState(28) <= 0) && NTA_CheckMercInfinity())) || (_sorcattack % NTConfig_AttackJump) == 0) {
  784.             if (DebugAttacksInGame && target.GetState(28) <= 0) {
  785.                 Print(COLOR_11 + "target not convicted");
  786.                 Print(COLOR_11 + "let's dance");
  787.             }
  788.             NTA_Bounce(target, index);
  789.         }
  790.     }
  791.     if (me.GetSkillStatus(NTConfig_AttackSkill[index]) != 8) {
  792.         if (GetDistance(me, target) > _NTA_SkillRange[index] || !CheckCollision(me, target, 4)) {
  793.             var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[index], 4);
  794.             if (_pos) NTCS_MoveTo(target.areaid, _pos[0], _pos[1], 0, false, false);
  795.         }
  796.  
  797.         if (NTConfig_ChainLightOnLightImmunes && NTA_GetResistance(target, NTA_DAMAGE_LIGHTNING) >= 95 && _haveCL > 0) {
  798.             if (DebugAttacksInGame) {
  799.                 Print(COLOR_9 + " Target Light resist = " + NTA_GetResistance(target, NTA_DAMAGE_LIGHTNING));
  800.                 Print(COLOR_9 + "Switching to CL");
  801.             } // need to add debug to config
  802.             return (NTC_CastSkill(53, NTC_HAND_LEFT, target))
  803.         }
  804.  
  805.         return NTC_CastSkill(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  806.     }
  807.  
  808.     secondarySkill = NTA_GetAttackType(target, primaryIndex + 1, 81, 81, 81);
  809.     if (NTConfig_AttackSkill[secondarySkill] > -1) {
  810.         if (GetDistance(me, target) > _NTA_SkillRange[secondarySkill] || !CheckCollision(me, target, 4)) {
  811.             var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[secondarySkill], 4);
  812.  
  813.             if (_pos) NTCS_MoveTo(target.areaid, _pos[0], _pos[1], 0, false, false);
  814.         }
  815.  
  816.         return NTC_CastSkill(NTConfig_AttackSkill[secondarySkill], _NTA_SkillHand[secondarySkill], target);
  817.     }
  818.  
  819.     for (var i = 0; i < 25; i++) {
  820.         Delay(NTC_DELAY_FRAME);
  821.  
  822.         if (me.GetSkillStatus(NTConfig_AttackSkill[index]) != 8) break;
  823.     }
  824.  
  825.     return false;
  826. }
  827.  
  828. function NTCS_Sorc_KillMonster(classid) {
  829.     var _target;
  830.  
  831.     if (NTConfig_AttackSkill[1] < 0) {
  832.         return false;
  833.     }
  834.  
  835.     _target = NTC_FindUnit(NTC_UNIT_MONSTER, classid, 5);
  836.  
  837.     if (!_target) {
  838.         return false;
  839.     }
  840.    
  841.     if (NTConfig_PrioritizeWeakerFoes && NTConfig_PrioritizeWeakerFoesAreaDisable.indexOf(me.areaid) < 0) {
  842.         NTA_ClearPosition(20, true, 2);
  843.     }
  844.  
  845.     if (_target.IsAttackable()) {
  846.         var _attackcount = 0;
  847.  
  848.         while (_attackcount < 300 && NTA_IsValidMonster(_target)) {
  849.             if (NTA_SorceressAttackInt(_target, (_attackcount % 30) == 0) < 2) {
  850.                 break;
  851.             }
  852.  
  853.             _attackcount++;
  854.             _sorcattack++;
  855.         }
  856.     }
  857.     if(skippedImmuneBoss){
  858.         Print(COLOR_2 + "skipping " + _target.name + " because of your skip immune settings");
  859.         return true;
  860.     }
  861.     return (_target.hp <= 0 || _target.mode == 0 || _target.mode == 12);
  862. }
  863.  
  864. function NTCS_GetCloserIntS(unit){
  865.     //Print(COLOR_1 + " we are here");
  866.     if(GetDistance(me, unit) > 3)
  867.         return NTCS_MoveTo(unit.areaid, unit.x+1, unit.y);
  868.     return true;
  869. }
  870.  
  871. function NTCS_MoveCloseInt(target, maxrange)
  872. {
  873.     var _result = true;
  874.     var _dist   = GetDistance(me, target);
  875.  
  876.     if (_dist > maxrange)
  877.     {
  878.         var _destx, _desty;
  879.  
  880.         _destx = me.x + Math.round((_dist - maxrange) * (target.x - me.x) / _dist);
  881.         _desty = me.y + Math.round((_dist - maxrange) * (target.y - me.y) / _dist);
  882.  
  883.         _result = NTCS_MoveTo(target.areaid, _destx, _desty, 1);
  884.     }
  885.  
  886.     return _result;
  887. }
  888.  
  889. function NTCS_GetPortalDistance(how, dest, ownername, myportal)
  890. {
  891.     var _portal;
  892.     var _playerportal = false;
  893.  
  894.     if(how == "BluePortal")
  895.     {
  896.         if(!ownername)
  897.             ownername = me.name;
  898.  
  899.         _playerportal = true;
  900.     }
  901.  
  902.     if(arguments.length > 3 && myportal)
  903.         _portal = myportal;
  904.     else
  905.     {
  906.         _portal = NTM_FindCorrectPortalInt(_playerportal, dest, ownername);
  907.  
  908.         if(_portal < 0)
  909.             _portal = NTM_FindPortalAreaInt(dest);
  910.  
  911.         if(_portal == -1)
  912.             return false;
  913.     }
  914.  
  915.     if(!_portal)
  916.         return false;
  917.  
  918.     return GetDistance(me.x, me.y, _portal.x, _portal.y);
  919. }
  920.  
  921. function NTCS_ChangeAreaInt(how, dest, ownername, myportal)
  922. {
  923.     var _portal;
  924.     var _playerportal = false;
  925.     var _prearea;
  926.  
  927.     if(how == "BluePortal")
  928.     {
  929.         if(!ownername)
  930.             ownername = me.name;
  931.  
  932.         _playerportal = true;
  933.     }
  934.  
  935.     if(arguments.length > 3 && myportal)
  936.         _portal = myportal;
  937.     else
  938.     {
  939.         _portal = NTM_FindCorrectPortalInt(_playerportal, dest, ownername);
  940.  
  941.         if(_portal < 0)
  942.             _portal = NTM_FindPortalAreaInt(dest);
  943.  
  944.         if(_portal == -1)
  945.             return false;
  946.     }
  947.  
  948.     if(!_portal)
  949.         return false;
  950.  
  951.     _prearea = me.areaid;
  952.  
  953.     for(var i = 0 ; i < 100 ; i++)
  954.     {
  955.         if((i % 10) == 0)
  956.         {
  957.             if (me.classid === 1 && NTConfig_Telekinesis && NTC_InTown() && NTC_GetSkillLevel(43) && GetDistance(me, _portal) > 5 && GetDistance(me, _portal) < 23)
  958.             {
  959.                 if (i > 10)
  960.                     NTCS_MoveCloseInt(_portal, Math.round(GetDistance(me, _portal) / 2), false);
  961.  
  962.                 NTC_CastSkill(43, NTC_HAND_RIGHT, _portal);
  963.             }
  964.             else{
  965.                 NTCS_MoveTo(_portal.areaid, _portal.x + 1, _portal.y)
  966.                 if(NTC_GetSkillLevel(54) < 1){
  967.                     NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _portal);
  968.                 }
  969.                 else if(NTCS_GetCloserIntS(_portal)){
  970.                     NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _portal);
  971.                 }
  972.             }
  973.         }
  974.  
  975.         Delay(5);
  976.  
  977.         if(me.areaid != _prearea)
  978.         {
  979.             while(me.areaid == 0)
  980.                 Delay(1);
  981.        
  982.             if(me.areaid != _prearea)
  983.             {
  984.                 //NTC_PingDelay(NTConfig_AreaDelay);
  985.                 return true;
  986.             }
  987.        
  988.             break;
  989.         }
  990.     }
  991.  
  992.     return (me.areaid != _prearea);
  993. }
  994.  
  995. function NTCS_UsePortal(how, dest, ownername, portal)
  996. {
  997.     if(me.areaid == dest)
  998.         return true;
  999.    
  1000.     if(NTC_InTown())
  1001.         me.Cancel(1);
  1002.  
  1003.     if(NTCS_ChangeAreaInt(how, dest, ownername, portal))
  1004.     {
  1005.         return true;
  1006.     }
  1007.  
  1008.     return false;
  1009. }
  1010.  
  1011. var ax = 0;
  1012. var ay = 0;
  1013.  
  1014. function NTA_SortRooms(a, b) {
  1015.     if (GetDistance(ax, ay, a[0], a[1]) < GetDistance(ax, ay, b[0], b[1])) {
  1016.         return -1;
  1017.     }
  1018.  
  1019.     return 1;
  1020. }
  1021.    
  1022. function NTA_MonsterStats(unit) {
  1023.     this.name = unit.name;
  1024.     this.x = unit.x;
  1025.     this.y = unit.y;
  1026.     this.gid = unit.gid;
  1027.     this.classid = unit.classid;
  1028.     this.spectype = unit.spectype;
  1029. }
  1030.  
  1031. function NTA_IdleDodge(atx, aty, mindistance, maxdistance, distancestep) {
  1032.     var i, j, y, coordx, coordy, monster, count,
  1033.         maxcount = 999,
  1034.         coords = [],
  1035.         goodCoords = [],
  1036.         monList = [],
  1037.         angles = [22, 45, 67, 90, 112, 135, 157, 180, 202, 225, 247, 270, 292, 315, 337, 360];
  1038.    
  1039.     for(y = mindistance; y < maxdistance; y += distancestep) {
  1040.         for (i = 0; i < angles.length; i += 1) {
  1041.             coordx = Math.round((Math.cos(angles[i] * Math.PI / 180)) * y + atx);
  1042.             coordy = Math.round((Math.sin(angles[i] * Math.PI / 180)) * y + aty);
  1043.                    
  1044.             if (CheckCollision(me.areaid, coordx, coordy, 1)) {
  1045.                 coords.push([coordx, coordy]);
  1046.             }
  1047.         }
  1048.     }
  1049.  
  1050.     if (coords.length === 0) { // no valid positions - don't move
  1051.         return false;
  1052.     }
  1053.  
  1054.     ax = atx;
  1055.     ay = aty;
  1056.     coords.sort(NTA_SortRooms);
  1057.  
  1058.     monster = GetUnit(1);
  1059.  
  1060.     if (monster) {
  1061.         do {
  1062.             if (monster.hp > 0) {
  1063.                 monList.push(new NTA_MonsterStats(monster));
  1064.             }
  1065.         } while (monster.GetNext());
  1066.     }
  1067.     else
  1068.     {
  1069.         return false;
  1070.     }
  1071.  
  1072.     if(monList.length == 0)
  1073.         return false;
  1074.  
  1075.     for (i = 0; i < coords.length; i += 1) {
  1076.         count = 0;
  1077.                    
  1078.         for (j = 0; j < monList.length; j += 1) {
  1079.             if (GetDistance(monList[j].x, monList[j].y, coords[i][0], coords[i][1]) < 15) {
  1080.                 count += 1;
  1081.                 target = monList[j];
  1082.             }
  1083.         }
  1084.  
  1085.         if (count < maxcount) {
  1086.             goodCoords = [coords[i][0], coords[i][1]];
  1087.             maxcount = count;
  1088.                    
  1089.             if (count == 0) {
  1090.                 break;
  1091.             }
  1092.         }
  1093.     }
  1094.  
  1095.     if (goodCoords.length > 0) { // just in case goodCoords is empty (shouldn't happen)
  1096.         if (Math.abs(me.x - goodCoords[0]) < 3 && Math.abs(me.y - goodCoords[1]) < 3) {
  1097.             NTCS_WalkTo(goodCoords[0], goodCoords[1]);
  1098.             return true;
  1099.         }
  1100.  
  1101.         Print("Dodge maxcount = " + maxcount);
  1102.         NTCS_MoveTo(me.areaid, goodCoords[0], goodCoords[1]);
  1103.         return true;
  1104.     }
  1105.            
  1106.     return false;
  1107. }
  1108.  
  1109.  
  1110. function NTCS_GoToStar()
  1111. {
  1112.     if(!NTCS_MoveTo(108, 7794, 5295))
  1113.         if(!NTCS_MoveTo(108, 7794, 5295))
  1114.         {
  1115.             return false;
  1116.         }
  1117.  
  1118.     return true;
  1119. }
  1120.  
  1121. function NTC_IsPlayerInGame(name)
  1122. {
  1123.     var _player;
  1124.     var _myPartyId;
  1125.     var _area;
  1126.  
  1127.     _player = GetPlayerUnit();
  1128.  
  1129.     do
  1130.     {
  1131.         if(_player && _player.name == name)
  1132.         {
  1133.             return true;
  1134.         };
  1135.  
  1136.     }
  1137.     while(_player && _player.GetNext());
  1138.  
  1139.     return false;
  1140. }
  1141.  
  1142. var quitScript = 0;
  1143.  
  1144. function NTCS_SafeExitGame() // i wanted to do more than a normal exitgame...
  1145. {
  1146.     // TODO: cancel UI's here, or maybe there's some NT function that already does this? (because having a UI open before calling ExitGame causes a crash)
  1147.     ExitGame();
  1148.     quitScript = 1;
  1149. }
  1150.  
  1151. function NTC_IsQuesterIn(area, name)
  1152. {
  1153.     var _player;
  1154.     var _myPartyId;
  1155.     var _area;
  1156.  
  1157.     _player = GetPlayerUnit();
  1158.     if(!_player)
  1159.         return false;
  1160.     _myPartyId = _player.partyid;
  1161.  
  1162.     if(arguments.length < 1)
  1163.     {
  1164.         _area = me.areaid;
  1165.     }
  1166.    
  1167.     if(arguments.length > 0)
  1168.     {
  1169.         _area = area;
  1170.     }
  1171.  
  1172.     do
  1173.     {
  1174.         if(_player.areaid == _area && _myPartyId == _player.partyid)
  1175.         {
  1176.             if(!name)
  1177.             {
  1178.                 return true;
  1179.             }
  1180.             else if(_player.name == name)
  1181.             {
  1182.                 return true;
  1183.             }
  1184.         }
  1185.     }
  1186.     while(_player && _player.GetNext());
  1187.  
  1188.     return false;
  1189. }
  1190.  
  1191. var bossAlive = 0;
  1192. var bGotBo = 0;
  1193.  
  1194. function NTMain()
  1195. {
  1196.     Include("libs/common/NTCommon.ntl");
  1197.     NTC_IncludeLibs();
  1198.     NTC_IncludeConfig("NTBot/char_configs");
  1199.     NT_LoadConfig();
  1200.     NTSI_LoadNIPFiles("NTBot/item_configs");
  1201.     NTA_Initialize();
  1202.    
  1203.     RegisterEvent(EVENT_GAMEMSG, quitfunc);
  1204.  
  1205.     if(!NTTM_CheckAct(4))
  1206.     {
  1207.         NTC_SendMsgToScript("NTBotGame.ntj", "NTTM_CheckAct()");
  1208.         return;
  1209.     }
  1210.    
  1211.     _startExp = me.GetStat(13);
  1212.    
  1213.     NTTMGR_TownManager();
  1214.  
  1215.     TD_File("NTBot/bots/TeamD.txt", 1);
  1216.  
  1217.     if(me.classid == 1)
  1218.     {
  1219.         Print("Loading sorc function");
  1220.         TD_Sorcfunc();
  1221.     }
  1222.  
  1223.     if(me.classid == 3)
  1224.     {
  1225.         Print("Loading hammer function");
  1226.         NTTM_TownMove("portalspot");
  1227.        
  1228.         var ticksTillRepeat = 1;
  1229.  
  1230.         while(1)
  1231.         {
  1232.             if(bGotBo == 0 && --ticksTillRepeat == 0)
  1233.             {
  1234.                 Say("DinReady");
  1235.                 ticksTillRepeat = 10000;
  1236.             }
  1237.             TD_TeamCommands();
  1238.             Delay(1);
  1239.         }
  1240.     }
  1241.  
  1242.     if(me.classid == 4)
  1243.     {
  1244.         Print("Loading barb function");
  1245.         NTTM_TownMove("portalspot");
  1246.  
  1247.         while(1)
  1248.         {
  1249.             if(quitScript == 1)
  1250.                 break;
  1251.             if(!TD_TeamCommands())
  1252.                 break;
  1253.             Delay(10);
  1254.         }
  1255.     }
  1256.  
  1257.     if(me.classid == 2)
  1258.     {
  1259.         Print("Loading Necro function");
  1260.         NTTM_TownMove("portalspot");
  1261.  
  1262.         while(1)
  1263.         {
  1264.             if(quitScript == 1)
  1265.                 break;
  1266.             TD_TeamCommands();
  1267.             Delay(10);
  1268.         }
  1269.     }
  1270.  
  1271.     NTC_SendMsgToScript("NTBotGame.ntj", "SCRIPT_END");
  1272. }
  1273.  
  1274. function NTM_MakeTPFast(dest)
  1275. {
  1276.     if(NTC_InTown())
  1277.         return true;
  1278.  
  1279.     if(!NTC_CastSkill(220, NTC_HAND_RIGHT))
  1280.         return false;
  1281.    
  1282.     //NTC_PingDelay(500);
  1283.  
  1284.     _portalname = GetLocaleString(3226);
  1285.  
  1286.     for(var i = 0 ; i < 300 ; i++)
  1287.     {
  1288.         _portal = NTC_FindUnit(NTC_UNIT_OBJECT, _portalname);
  1289.  
  1290.         if(_portal)
  1291.         {
  1292.             do
  1293.             {
  1294.                 if(_portal.mode == 2 && NTC_CheckOwner(_portal))
  1295.                 {
  1296.                     return true;
  1297.                 }
  1298.             } while(_portal.GetNext());
  1299.         }
  1300.  
  1301.         Delay(5);
  1302.     }
  1303.  
  1304.     return false;
  1305.    
  1306.     return true;
  1307. }
  1308.  
  1309. function NTM_MakeTpFastSafe(dst)
  1310. {
  1311.     // rety x many times..
  1312. }
  1313.  
  1314. function NTCS_OutputStatistics()
  1315. {
  1316.     var _expGain = me.GetStat(13) - _startExp;
  1317.     if(_expGain > 0)
  1318.     {
  1319.         NTC_SendLogToOOG(NTC_LOG_COMMON, COLOR_2 + "Exp gained " + _expGain);
  1320.     }
  1321. }
  1322.  
  1323. var DinRdy = 0;
  1324.  
  1325. function TD_Sorcfunc()
  1326. {
  1327.     if(!NTTM_TownMove("waypoint"))
  1328.     {
  1329.         NTC_SendMsgToScript("NTBotGame.ntj", "NTTM_TownMove()");
  1330.         return;
  1331.     }
  1332.  
  1333.     if(!NTM_TakeWaypoint(107))
  1334.     {
  1335.         NTC_SendMsgToScript("NTBotGame.ntj", "NTM_TakeWaypoint()");
  1336.         return;
  1337.     }
  1338.    
  1339.     NTCS_WalkTo(me.x+5, me.y+5);
  1340.  
  1341.     while(!NTC_IsQuesterIn(103, "telemarkebo") || !NTC_IsQuesterIn(103, "telemarkedin"))
  1342.     {
  1343.         Delay(5);
  1344.     }
  1345.    
  1346.     while(DinRdy == 0)
  1347.         Delay(5);
  1348.        
  1349.     Delay(1000);
  1350.  
  1351.     for(var i = 0 ; i < 5 ; i++)
  1352.     {
  1353.         if(NTM_MakeTPFast())
  1354.         {
  1355.             break;
  1356.         }
  1357.     }
  1358.    
  1359.     Delay(600); // wait on tp to open
  1360.  
  1361.     TD_File("NTBot/bots/TeamD.txt", 1, ".bo");
  1362.  
  1363.     if(sayMsgs)
  1364.         Say("BO");
  1365.    
  1366.     while(!me.GetState(32))
  1367.     {
  1368.         Delay(10);
  1369.     }
  1370.  
  1371.     if(barbLeaveAfterBo == 1)
  1372.     {
  1373.         while(NTC_IsPlayerInGame("telemarkebo"))
  1374.         {
  1375.             Delay(5);
  1376.         }
  1377.     }
  1378.    
  1379.     //NTC_PingDelay(1800);
  1380.     //NTP_DoPrecast(true);
  1381.     NTC_PutSkill(40, NTC_HAND_RIGHT);
  1382.     NTC_CastSkill(40);
  1383.  
  1384.     var coordsRiver = [[107, 7798, 5880], [107, 7798, 5840], [107, 7798, 5805], [107, 7798, 5770], [107, 7798, 5730],
  1385.                 [107, 7798, 5690], [107, 7798, 5660], [107, 7798, 5610]];
  1386.    
  1387.     var coordsCs = [[108, 7798, 5570], [108, 7798, 5530], [108, 7821, 5501], [108, 7821, 5461], [108, 7821, 5421], [108, 7821, 5381],
  1388.                 [108, 7821, 5341], [108, 7821, 5320]];
  1389.    
  1390.     for(var i = 0; i < coordsRiver.length; i++)
  1391.     {
  1392.         if (!NTCS_Sora_TeleportTo(coordsRiver[i][1], coordsRiver[i][2]))
  1393.             NTCS_MoveTo(coordsRiver[i][0], coordsRiver[i][1], coordsRiver[i][2]);      
  1394.     }
  1395.        
  1396.     for(var i = 0; i < coordsCs.length; i++)
  1397.     {
  1398.         if (!NTCS_Sora_TeleportTo(coordsCs[i][1], coordsCs[i][2]))
  1399.             NTCS_MoveTo(coordsCs[i][0], coordsCs[i][1], coordsCs[i][2]);       
  1400.     }
  1401.  
  1402.     if(TD_DetectLayout(1) == 1)   //T Shape
  1403.     {
  1404.         NTCS_MoveTo(me.areaid, 7701, 5299);
  1405.         NTCS_Deploy(7687, 5288, 0, 0, 5, 5);
  1406.  
  1407.         for(var i = 0 ; i < 5 ; i++)
  1408.         {
  1409.             if(NTM_MakeTPFast())
  1410.             {
  1411.                 break;
  1412.             }
  1413.         }
  1414.     }
  1415.     else
  1416.     {
  1417.         NTCS_MoveTo(me.areaid, 7700, 5313); //L Shape
  1418.         NTCS_Deploy(7680, 5313, 5, 5, 0, 0);
  1419.  
  1420.         for(var i = 0 ; i < 5 ; i++)
  1421.         {
  1422.             if(NTM_MakeTPFast())
  1423.             {
  1424.                 break;
  1425.             }
  1426.         }
  1427.     }
  1428.  
  1429.     if(onlySora)
  1430.     {
  1431.         Delay(9000000);
  1432.     }
  1433.  
  1434.         TD_File("NTBot/bots/TeamD.txt", 1, ".s1"); //vizier
  1435.  
  1436.         if(sayMsgs)
  1437.             Say("Viz Up");
  1438.    
  1439.         if(!TD_VizierSeal())
  1440.         {
  1441.             NTC_SendMsgToScript("NTBotGame.ntj", "Seal opening");
  1442.             return;
  1443.         }
  1444.  
  1445.         if(sorcSucks == 0)
  1446.         {
  1447.             NTCS_MoveTo(me.areaid, safex, safey);
  1448.             var _Vis = NTC_FindUnit(NTC_UNIT_MONSTER, GetLocaleString(2851), 20);
  1449.  
  1450.             NTCS_Sorc_KillMonster(GetLocaleString(2851));
  1451.             NTSI_PickItems();
  1452.         }
  1453.         else
  1454.         {
  1455.             bossAlive = 1;
  1456.             NTCS_GoToStar();
  1457.  
  1458.             while(bossAlive == 1)
  1459.             {
  1460.                 if(NTA_IdleDodge(7794, 5295, 10, 30, 1))
  1461.                 {
  1462.                     Delay(1000);
  1463.                     //NTCS_GoToStar();
  1464.                 }
  1465.                 // TODO: use potions, etc
  1466.                 Delay(10);
  1467.             }
  1468.         }
  1469.  
  1470.         if(TD_DetectLayout(3) == 1)
  1471.         {
  1472.             NTCS_MoveTo(me.areaid, 7900, 5300);
  1473.             NTCS_Deploy(7920, 5291, 5, 5, 0, 0);
  1474.  
  1475.             for(var i = 0 ; i < 5 ; i++)
  1476.             {
  1477.                 if(NTM_MakeTPFast())
  1478.                 {
  1479.                     break;
  1480.                 }
  1481.             }
  1482.         }
  1483.         else
  1484.         {
  1485.             NTCS_MoveTo(me.areaid, 7900, 5300);
  1486.             NTCS_Deploy(7930, 5278, 0, 5, 5, 0);
  1487.  
  1488.             for(var i = 0 ; i < 5 ; i++)
  1489.             {
  1490.                 if(NTM_MakeTPFast())
  1491.                 {
  1492.                     break;
  1493.                 }
  1494.             }
  1495.         }
  1496.  
  1497.         TD_File("NTBot/bots/TeamD.txt", 1, ".s3"); //infector
  1498.  
  1499.         if(sayMsgs)
  1500.             Say("Fect Up");
  1501.            
  1502.         if(!TD_InfectorSeal())
  1503.         {
  1504.             NTC_SendMsgToScript("NTBotGame.ntj", "Seal opening");
  1505.             return;
  1506.         }
  1507.  
  1508.         //NTCS_MoveTo(me.areaid, safex, safey);
  1509.        
  1510.         //sorcSucks = 1; // i put this here as an easy way to make the sorc go back to star instead of trying to fight fect/seis
  1511.  
  1512.         if(sorcSucks == 0)
  1513.         {
  1514.             NTCS_MoveTo(me.areaid, 7900, 5300);
  1515.             var _fect = NTC_FindUnit(NTC_UNIT_MONSTER, GetLocaleString(2853), 20);
  1516.  
  1517.             NTCS_Sorc_KillMonster(GetLocaleString(2853));
  1518.             NTSI_PickItems();
  1519.         }
  1520.         else
  1521.         {
  1522.             bossAlive = 1;
  1523.             NTCS_GoToStar();
  1524.  
  1525.             while(bossAlive == 1)
  1526.             {
  1527.                 if(NTA_IdleDodge(7794, 5295, 10, 30, 1))
  1528.                 {
  1529.                     Delay(1000);
  1530.                     //NTCS_GoToStar();
  1531.                 }
  1532.                 Delay(10);
  1533.             }
  1534.         }
  1535.  
  1536.         if(TD_DetectLayout(2) == 1)   // S
  1537.         {
  1538.             NTCS_MoveTo(me.areaid, 7776, 5230);
  1539.             NTCS_Deploy(7776, 5220, 0, 0, 15, 15);
  1540.  
  1541.             for(var i = 0 ; i < 5 ; i++)
  1542.             {
  1543.                 if(NTM_MakeTPFast())
  1544.                 {
  1545.                     break;
  1546.                 }
  1547.             }
  1548.         }
  1549.         else
  1550.         {
  1551.             NTCS_MoveTo(me.areaid, 7779, 5200);
  1552.             NTCS_Deploy(7779, 5180, 0, 0, 10, 10);
  1553.  
  1554.             for(var i = 0 ; i < 5 ; i++)
  1555.             {
  1556.                 if(NTM_MakeTPFast())
  1557.                 {
  1558.                     break;
  1559.                 }
  1560.             }
  1561.         }
  1562.  
  1563.         TD_File("NTBot/bots/TeamD.txt", 1, ".s2"); //de seis
  1564.  
  1565.         if(sayMsgs)
  1566.             Say("Seis Up");
  1567.            
  1568.         if(!TD_DeSeisSeal())
  1569.         {
  1570.             NTC_SendMsgToScript("NTBotGame.ntj", "Seal opening");
  1571.             return;
  1572.         }
  1573.  
  1574.         if(sorcSucks == 0)
  1575.         {
  1576.             NTCS_MoveTo(me.areaid, 7776, 5230);
  1577.             var _Seis = NTC_FindUnit(NTC_UNIT_MONSTER, GetLocaleString(2852), 20);
  1578.  
  1579.             NTCS_Sorc_KillMonster(GetLocaleString(2852));
  1580.             NTSI_PickItems();
  1581.         }
  1582.         else
  1583.         {
  1584.             bossAlive = 1;
  1585.             NTCS_GoToStar();
  1586.  
  1587.             while(bossAlive == 1)
  1588.             {
  1589.                 if(NTA_IdleDodge(7794, 5295, 10, 30, 1))
  1590.                 {
  1591.                     Delay(1000);
  1592.                     //NTCS_GoToStar();
  1593.                 }
  1594.                 Delay(10);
  1595.             }
  1596.         }
  1597.  
  1598.         if(!NTCS_MoveTo(me.areaid, 7792, 5292))
  1599.         {
  1600.             NTC_SendMsgToScript("NTBotGame.ntj", "NTCS_MoveTo()");
  1601.             return;
  1602.         }
  1603.        
  1604.         NTM_MakeTPFast();
  1605.  
  1606.         TD_File("NTBot/bots/TeamD.txt", 1, ".d");
  1607.  
  1608.         if(sayMsgs)
  1609.             Say("Dia Out");
  1610.            
  1611.         NTC_FindUnit(NTC_UNIT_MONSTER, 243, 60);
  1612.        
  1613.         if(sorcGetDiaXP == 1)
  1614.         {
  1615.             if(!NTCS_Sorc_KillMonster(243))
  1616.             {
  1617.                 NTC_SendMsgToScript("NTBotGame.ntj", "NTCS_Sorc_KillMonster()");
  1618.                 return;
  1619.             }
  1620.  
  1621.             NTSI_PickItems();
  1622.         }
  1623.         else
  1624.         {
  1625.             if(!NTCS_UsePortal("BluePortal", 103, me.name))
  1626.             {
  1627.                 NTTM_CheckAct();
  1628.             }
  1629.             Delay(60000);
  1630.         }
  1631.         NTCS_OutputStatistics();
  1632. }
  1633.  
  1634. //--internal functions--
  1635. function quitfunc(msg, type)   //quit when leader leaves game
  1636. {
  1637.     //if(msg.indexOf("weaken") != -1 || msg.indexOf("timeout") != -1) { //if anyone quits
  1638.     if(msg.indexOf(leader) != -1 && msg.indexOf("telemarkebo") == -1/* && msg.indexOf("telemarkedin") == -1 */ && (msg.indexOf("weaken") != -1 || msg.indexOf("timeout") != -1))  //if leader quits
  1639.     {
  1640.         NTCS_OutputStatistics();
  1641.         Delay(2000);
  1642.         NTCS_SafeExitGame();
  1643.     }
  1644.    
  1645.     if(msg.indexOf("telemarkedin") != -1 /*&& msg.indexOf("telemarkebo") == -1 && msg.indexOf("telemarkedin") == -1 */ && (msg.indexOf("weaken") != -1 || msg.indexOf("timeout") != -1))  //if din quits
  1646.     {
  1647.         NTCS_OutputStatistics();
  1648.         Delay(2000);
  1649.         NTCS_SafeExitGame();
  1650.     }
  1651.  
  1652.     if(msg.indexOf("Viz Down") != -1 || msg.indexOf("Seis Down") != -1 || msg.indexOf("Fect Down") != -1)
  1653.     {
  1654.         bossAlive = 0;
  1655.     }
  1656.    
  1657.     if(msg.indexOf("DinReady") != -1)
  1658.     {
  1659.         DinRdy = 1;
  1660.     }
  1661. }
  1662.  
  1663. function TD_Preattack(classid, extrahammers)   //extra hammers = hammers cast after the seal boss is spawned
  1664. {
  1665.     NTC_PutSkill(NTConfig_AttackSkill[4], NTC_HAND_RIGHT);
  1666.  
  1667.     while(!NTC_FindUnit(NTC_UNIT_MONSTER, classid))
  1668.     {
  1669.         NTC_CastSkill(NTConfig_AttackSkill[3], 2);
  1670.        
  1671.         if ((NTTMGR_CheckCurse(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe, true)) || (me.hp <= parseInt(me.hpmax * NTConfig_TPChicken,10) / 100)) {
  1672.             NTTMGR_VisitTown();
  1673.         }
  1674.     }
  1675.  
  1676.     for(var i = 0 ; i < extrahammers ; i++)
  1677.     {
  1678.         var _mon = NTC_FindUnit(NTC_UNIT_MONSTER, classid);
  1679.         if(_mon.hp <= 0 || _mon.mode == 0 || _mon.mode == 12) // if they're dead we don't need to precast anymore
  1680.         {
  1681.             break;
  1682.         }
  1683.         NTC_CastSkill(NTConfig_AttackSkill[3], 2);
  1684.        
  1685.         if ((NTTMGR_CheckCurse(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe, true)) || (me.hp <= parseInt(me.hpmax * NTConfig_TPChicken,10) / 100)) {
  1686.             NTTMGR_VisitTown();
  1687.         }
  1688.     }
  1689. }
  1690.  
  1691. function TD_VizierSeal()   //vizier
  1692. {
  1693.     for(var i = 0 ; i < 30 ; i++)
  1694.     {
  1695.         NTCS_MoveToPresetUnit(me.areaid, 2, 395);
  1696.         var _seal = NTC_FindUnit(NTC_UNIT_OBJECT, 395, 5);
  1697.         NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
  1698.  
  1699.         Delay(100);
  1700.  
  1701.         if(_seal.mode <= 0)
  1702.         {
  1703.             //NTCS_MoveTo(me.areaid, safex, safey);
  1704.         }
  1705.         else
  1706.         {
  1707.             break;
  1708.         }
  1709.  
  1710.         Delay(100);
  1711.  
  1712.         if(i == 4 && _seal.mode <= 0)
  1713.         {
  1714.             return false;
  1715.         }
  1716.     }
  1717.  
  1718.     for(i = 0 ; i < 30 ; i++)
  1719.     {
  1720.         NTCS_MoveToPresetUnit(me.areaid, 2, 396);
  1721.         _seal = NTC_FindUnit(NTC_UNIT_OBJECT, 396, 5);
  1722.         NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
  1723.  
  1724.         Delay(100);
  1725.  
  1726.         if(_seal.mode <= 0)
  1727.         {
  1728.             //NTCS_MoveTo(me.areaid, safex, safey);
  1729.         }
  1730.         else
  1731.         {
  1732.             break;
  1733.         }
  1734.  
  1735.         Delay(100);
  1736.  
  1737.         if(i == 4 && _seal.mode <= 0)
  1738.         {
  1739.             return false;
  1740.         }
  1741.     }
  1742.  
  1743.     return true;
  1744. }
  1745.  
  1746. function TD_DeSeisSeal()  //de seis
  1747. {
  1748.     for(var i = 0 ; i < 30 ; i++)
  1749.     {
  1750.         NTCS_MoveToPresetUnit(me.areaid, 2, 394);
  1751.         _seal = NTC_FindUnit(NTC_UNIT_OBJECT, 394, 5);
  1752.         NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
  1753.  
  1754.         Delay(100);
  1755.  
  1756.         if(_seal.mode <= 0)
  1757.         {
  1758.             //NTCS_MoveTo(me.areaid, safex, safey);
  1759.         }
  1760.         else
  1761.         {
  1762.             break;
  1763.         }
  1764.  
  1765.         Delay(100);
  1766.  
  1767.         if(i == 4 && _seal.mode <= 0)
  1768.         {
  1769.             return false;
  1770.         }
  1771.     }
  1772.  
  1773.     return true;
  1774. }
  1775.  
  1776. function TD_InfectorSeal()   //infector
  1777. {
  1778.     for(var i = 0 ; i < 30 ; i++)
  1779.     {
  1780.         NTCS_MoveToPresetUnit(me.areaid, 2, 393);
  1781.         _seal = NTC_FindUnit(NTC_UNIT_OBJECT, 393, 5);
  1782.         NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
  1783.  
  1784.         Delay(100);
  1785.  
  1786.         if(_seal.mode <= 0)
  1787.         {
  1788.             //NTCS_MoveTo(me.areaid, safex, safey);
  1789.         }
  1790.         else
  1791.         {
  1792.             break;
  1793.         }
  1794.  
  1795.         Delay(100);
  1796.  
  1797.         if(i == 4 && _seal.mode <= 0)
  1798.         {
  1799.             return false;
  1800.         }
  1801.     }
  1802.  
  1803.     for(i = 0 ; i < 30 ; i++)
  1804.     {
  1805.         NTCS_MoveToPresetUnit(me.areaid, 2, 392);
  1806.         _seal = NTC_FindUnit(NTC_UNIT_OBJECT, 392, 5);
  1807.         NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _seal);
  1808.  
  1809.         Delay(100);
  1810.  
  1811.         if(_seal.mode <= 0)
  1812.         {
  1813.             //NTCS_MoveTo(me.areaid, safex, safey);
  1814.         }
  1815.         else
  1816.         {
  1817.             break;
  1818.         }
  1819.  
  1820.         Delay(100);
  1821.  
  1822.         if(i == 4 && _seal.mode <= 0)
  1823.         {
  1824.             return false;
  1825.         }
  1826.     }
  1827.  
  1828.     return true;
  1829. }
  1830.  
  1831. function TD_TeamCommands()
  1832. {
  1833.     var _msg = TD_File("NTBot/bots/TeamD.txt", 0);
  1834.  
  1835.     if(_msg && _msg != _MyDT_PreMessage)
  1836.     {
  1837.         _MyDT_PreMessage = _msg;
  1838.  
  1839.         switch(_msg.substring(_msg.indexOf("/") + 1))
  1840.         {
  1841.         case ".bo":
  1842.             if(me.classid == 3)   //Hammerdin
  1843.             {
  1844.                 NTCS_UsePortal("BluePortal", 107, leader);
  1845.  
  1846.                 bGotBo = 1;
  1847.  
  1848.                 while(!me.GetState(32))
  1849.                 {
  1850.                     Delay(10);
  1851.                 }
  1852.  
  1853.                 NTC_PingDelay(2000);
  1854.                 NTP_DoPrecast(true);
  1855.  
  1856.                 if(!NTCS_UsePortal("BluePortal", 103, leader)) //or make my own?
  1857.                 {
  1858.                     NTTM_CheckAct();
  1859.                 }
  1860.  
  1861.                 return true;
  1862.             }
  1863.  
  1864.             if(me.classid == 4)   //Barb
  1865.             {
  1866.                 NTCS_UsePortal("BluePortal", 107, leader);
  1867.  
  1868.                 while(!NTC_IsQuesterIn(107, "telemarkedin")) // wait on din
  1869.                 {
  1870.                     Delay(10);
  1871.                 }
  1872.                
  1873.                 NTC_CastSkill(155, NTC_HAND_RIGHT); // Battle Command
  1874.                
  1875.                 for(var _botimes = 0; _botimes < 4; _botimes++)
  1876.                 {
  1877.                     NTC_CastSkill(155, NTC_HAND_RIGHT); // Battle Command
  1878.                     NTC_CastSkill(138, NTC_HAND_RIGHT); // Shout
  1879.                     NTC_CastSkill(149, NTC_HAND_RIGHT); // Battle Orders
  1880.                 }
  1881.                
  1882.                 if(barbLeaveAfterBo == 1)
  1883.                     NTCS_SafeExitGame();
  1884.  
  1885.                 if(!NTCS_UsePortal("BluePortal", 103, leader))
  1886.                 {
  1887.                     NTTM_CheckAct();
  1888.                 }
  1889.  
  1890.                 return true;
  1891.             }
  1892.  
  1893.             if(me.classid == 2)   //Necro
  1894.             {
  1895.                 NTCS_UsePortal("BluePortal", 107, leader);
  1896.                 Delay(500);
  1897.                 NTP_DoPrecast(true);
  1898.                 Delay(4500);
  1899.  
  1900.                 if(!NTCS_UsePortal("BluePortal", 103, leader))
  1901.                 {
  1902.                     NTTM_CheckAct();
  1903.                 }
  1904.  
  1905.                 return true;
  1906.             }
  1907.  
  1908.             break;
  1909.  
  1910.         case ".s1": //vizier
  1911.             if(me.classid == 3)   //Hammerdin
  1912.             {
  1913.                 NTC_PutSkill(NTC_HAND_LEFT, 112);
  1914.                 NTC_PutSkill(NTC_HAND_RIGHT, 113);
  1915.  
  1916.                 if(!NTCS_UsePortal("BluePortal", 108, leader))
  1917.                 {
  1918.                     return true;
  1919.                 }
  1920.  
  1921.                 TD_Preattack(GetLocaleString(2851), 8);
  1922.                 NTCS_Din_KillMonster(GetLocaleString(2851));
  1923.  
  1924.                 if(sayMsgs)
  1925.                     Say("Viz Down");
  1926.                    
  1927.                 NTSI_PickItems();
  1928.                
  1929.                 if(NTCS_GetPortalDistance("BluePortal", 103, leader) >= 10 || !NTCS_UsePortal("BluePortal", 103, leader))
  1930.                 {
  1931.                     NTTM_CheckAct();
  1932.                 }
  1933.  
  1934.                 return true;
  1935.             }
  1936.  
  1937.             if(me.classid == 4 && barbTakeTps == 1)   //Barb
  1938.             {
  1939.                 if(!NTCS_UsePortal("BluePortal", 108, leader))
  1940.                 {
  1941.                     return true;
  1942.                 }
  1943.  
  1944.                 for(var i = 0 ; i < 3 ; i++)
  1945.                 {
  1946.                     NTC_CastSkill(130, NTC_HAND_RIGHT);
  1947.                 }
  1948.  
  1949.                 if(!NTCS_UsePortal("BluePortal", 103, leader))
  1950.                 {
  1951.                     return true;
  1952.                 }
  1953.  
  1954.                 NTTM_CheckAct();
  1955.  
  1956.                 if(!NTCS_UsePortal("BluePortal", 103, leader))
  1957.                 {
  1958.                     return true;
  1959.                 }
  1960.  
  1961.                 NTTM_CheckAct();
  1962.             }
  1963.  
  1964.             if(me.classid == 2)   //Necro
  1965.             {
  1966.                 if(!NTCS_UsePortal("BluePortal", 108, leader))
  1967.                 {
  1968.                     return true;
  1969.                 }
  1970.  
  1971.                 NTA_KillMonster(GetLocaleString(2851));
  1972.  
  1973.                 if(sayMsgs)
  1974.                     Say("Viz Down");
  1975.                    
  1976.                 NTTM_CheckAct();
  1977.  
  1978.                 return true;
  1979.             }
  1980.  
  1981.             break;
  1982.  
  1983.         case ".s2": //de seis
  1984.             if(me.classid == 3)   //Hammerdin
  1985.             {
  1986.                 NTC_PutSkill(NTC_HAND_LEFT, 112);
  1987.                 NTC_PutSkill(NTC_HAND_RIGHT, 113);
  1988.  
  1989.                 if(!NTCS_UsePortal("BluePortal", 108, leader))
  1990.                 {
  1991.                     return true;
  1992.                 }
  1993.  
  1994.                 TD_Preattack(GetLocaleString(2852), 8);
  1995.                 NTCS_Din_KillMonster(GetLocaleString(2852));
  1996.  
  1997.                 if(sayMsgs)
  1998.                     Say("Seis Down");
  1999.                    
  2000.                 NTSI_PickItems();
  2001.                    
  2002.                 if(NTCS_GetPortalDistance("BluePortal", 103, leader) >= 10 || !NTCS_UsePortal("BluePortal", 103, leader))
  2003.                 {
  2004.                     NTTM_CheckAct();
  2005.                 }
  2006.  
  2007.                 return true;
  2008.             }
  2009.  
  2010.             if(me.classid == 4 && barbTakeTps == 1)   //Barb
  2011.             {
  2012.                 if(!NTCS_UsePortal("BluePortal", 108, leader))
  2013.                 {
  2014.                     return true;
  2015.                 }
  2016.  
  2017.                 for(var i = 0 ; i < 3 ; i++)
  2018.                 {
  2019.                     NTC_CastSkill(130, NTC_HAND_RIGHT);
  2020.                 }
  2021.  
  2022.                 //NTP_DoPrecast(true);
  2023.                 //NTA_KillMonster(GetLocaleString(2852));
  2024.                 //NTC_Delay(500);
  2025.                 if(!NTCS_UsePortal("BluePortal", 103, leader))
  2026.                 {
  2027.                     return true;
  2028.                 }
  2029.  
  2030.                 NTTM_CheckAct();
  2031.                 return true;
  2032.             }
  2033.  
  2034.             if(me.classid == 2)   //Necro
  2035.             {
  2036.                 NTCS_UsePortal("BluePortal", 108, leader);
  2037.                 NTC_Delay(3000);
  2038.                 NTA_KillMonster(GetLocaleString(2852));
  2039.                 NTSI_PickItems();
  2040.  
  2041.                 if(!NTCS_UsePortal("BluePortal", 103, leader))
  2042.                 {
  2043.                     NTTM_CheckAct();
  2044.                 }
  2045.  
  2046.                 NTP_DoPrecast(true);
  2047.             }
  2048.  
  2049.             break;
  2050.  
  2051.         case ".s3": //infector
  2052.             if(me.classid == 3)   //Hammerdin
  2053.             {
  2054.                 NTC_PutSkill(NTC_HAND_LEFT, 112);
  2055.                 NTC_PutSkill(NTC_HAND_RIGHT, 113);
  2056.  
  2057.                 if(!NTCS_UsePortal("BluePortal", 108, leader))
  2058.                 {
  2059.                     return true;
  2060.                 }
  2061.  
  2062.                 TD_Preattack(GetLocaleString(2853), 8);
  2063.                 NTCS_Din_KillMonster(GetLocaleString(2853));
  2064.  
  2065.                 if(sayMsgs)
  2066.                     Say("Fect Down");
  2067.                    
  2068.                 NTSI_PickItems();
  2069.  
  2070.                 if(NTCS_GetPortalDistance("BluePortal", 103, leader) >= 10 || !NTCS_UsePortal("BluePortal", 103, leader))
  2071.                 {
  2072.                     NTTM_CheckAct();
  2073.                 }
  2074.  
  2075.                 return true;
  2076.                 NTP_DoPrecast(true);
  2077.             }
  2078.  
  2079.             if(me.classid == 4 && barbTakeTps == 1)   //Barb
  2080.             {
  2081.                 if(!NTCS_UsePortal("BluePortal", 108, leader))
  2082.                 {
  2083.                     return true;
  2084.                 }
  2085.  
  2086.                 for(var i = 0 ; i < 3 ; i++)
  2087.                 {
  2088.                     NTC_CastSkill(130, NTC_HAND_RIGHT);
  2089.                 }
  2090.  
  2091.                 //NTP_DoPrecast(true);
  2092.                 //NTA_KillMonster(GetLocaleString(2853));
  2093.                 //NTC_Delay(500);
  2094.                 if(!NTCS_UsePortal("BluePortal", 103, leader)) //or make my own?
  2095.                 {
  2096.                     return true;
  2097.                 }
  2098.  
  2099.                 NTTM_CheckAct();
  2100.                 return true;
  2101.             }
  2102.  
  2103.             if(me.classid == 2)   //Necro
  2104.             {
  2105.                 NTCS_UsePortal("BluePortal", 108, leader);
  2106.                 NTC_Delay(3000);
  2107.                 NTA_KillMonster(GetLocaleString(2853));
  2108.                 NTSI_PickItems();
  2109.  
  2110.                 if(!NTCS_UsePortal("BluePortal", 103, leader)) //or make my own?
  2111.                 {
  2112.                     NTTM_CheckAct();
  2113.                 }
  2114.  
  2115.                 NTP_DoPrecast(true);
  2116.             }
  2117.  
  2118.             break;
  2119.  
  2120.         case ".d":
  2121.             if(me.classid == 3)   //Hammerdin
  2122.             {
  2123.                 NTC_PutSkill(NTC_HAND_LEFT, 112);
  2124.                 NTC_PutSkill(NTC_HAND_RIGHT, 113);
  2125.                 NTCS_UsePortal("BluePortal", 108, leader);
  2126.                 NTC_FindUnit(NTC_UNIT_MONSTER, 243, 100);
  2127.  
  2128.                 if(!NTCS_Din_KillMonster(243))
  2129.                 {
  2130.                     NTC_SendMsgToScript("NTBotGame.ntj", "KillMonster()");
  2131.                     return true;
  2132.                 }
  2133.  
  2134.                 NTSI_PickItems();
  2135.                 NTCS_SafeExitGame();
  2136.             }
  2137.  
  2138.             /*if(me.classid == 4) { //Barb, Uncomment Section if you want to follow to D
  2139.                 NTCS_UsePortal("BluePortal", 108, leader);
  2140.                 NTP_DoPrecast(true);
  2141.  
  2142.                 //do something until diablo dies
  2143.  
  2144.                 var _diablo = NTC_FindUnit(NTC_UNIT_MONSTER, 243)
  2145.                 while(_diablo && _diablo.hp > 0)
  2146.                     NTC_Delay(500);
  2147.             }*/
  2148.             /*if(me.classid == 2) { //Necro Uncomment if you want to follow to D
  2149.                 NTCS_UsePortal("BluePortal", 108, leader);
  2150.                 NTP_DoPrecast(true);
  2151.  
  2152.                 //do something until diablo dies
  2153.  
  2154.                 var _diablo = NTC_FindUnit(NTC_UNIT_MONSTER, 243)
  2155.                 while(_diablo && _diablo.hp > 0)
  2156.                     NTC_Delay(500);
  2157.             }*/
  2158.             break;
  2159.         }
  2160.     }
  2161.     return true;
  2162. }
  2163.  
  2164. function TD_DetectLayout(seal)
  2165. {
  2166.     switch(seal)
  2167.     {
  2168.     case 1:
  2169.         _sealpos = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT);
  2170.  
  2171.         for(var i = 0 ; i < _sealpos.length ; i++)
  2172.         {
  2173.             if(_sealpos[i].id == 396)
  2174.             {
  2175.                 if(_sealpos[i].roomy * 5 + _sealpos[i].y == 5275)
  2176.                 {
  2177.                     return 1;
  2178.                 }
  2179.                 else
  2180.                 {
  2181.                     return 2;
  2182.                 }
  2183.  
  2184.                 break;
  2185.             }
  2186.         }
  2187.  
  2188.         break;
  2189.  
  2190.     case 2:
  2191.         _sealpos = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT);
  2192.  
  2193.         for(i = 0 ; i < _sealpos.length ; i++)
  2194.         {
  2195.             if(_sealpos[i].id == 394)
  2196.             {
  2197.                 if(_sealpos[i].roomx * 5 + _sealpos[i].x == 7773)
  2198.                 {
  2199.                     return 1;
  2200.                 }
  2201.                 else
  2202.                 {
  2203.                     return 2;
  2204.                 }
  2205.  
  2206.                 break;
  2207.             }
  2208.         }
  2209.  
  2210.         break;
  2211.  
  2212.     case 3:
  2213.         _sealpos = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT);
  2214.  
  2215.         for(i = 0 ; i < _sealpos.length ; i++)
  2216.         {
  2217.             if(_sealpos[i].id == 392)
  2218.             {
  2219.                 if(_sealpos[i].roomx * 5 + _sealpos[i].x == 7893)
  2220.                 {
  2221.                     return 1;
  2222.                 }
  2223.                 else
  2224.                 {
  2225.                     return 2;
  2226.                 }
  2227.  
  2228.                 break;
  2229.             }
  2230.         }
  2231.  
  2232.         break;
  2233.     }
  2234. }
  2235.  
  2236. function TD_File(path, mode, msg, delay)   //big thanks to all the koreans out there
  2237. {
  2238.     var _msg  = "";
  2239.     var _line = "";
  2240.     var _fileHandle;
  2241.     var _isFileCheck = false;
  2242.  
  2243.     if(arguments.length < 3)
  2244.     {
  2245.         msg   = "";
  2246.     }
  2247.  
  2248.     if (arguments.length < 4) delay = (mode > 0) ? 5 : 2;
  2249.  
  2250.     while(delay--)
  2251.     {
  2252.         if(mode == 2 && !_isFileCheck)
  2253.         {
  2254.             _fileHandle = FileOpen(path, 0);
  2255.  
  2256.             if(!_fileHandle)
  2257.             {
  2258.                 _fileHandle = FileOpen(path, 1);
  2259.             }
  2260.  
  2261.             if(_fileHandle)
  2262.             {
  2263.                 _fileHandle.Close();
  2264.             }
  2265.  
  2266.             _isFileCheck = true;
  2267.         }
  2268.  
  2269.         _fileHandle = FileOpen(path, mode);
  2270.  
  2271.         if(_fileHandle)
  2272.         {
  2273.             break;
  2274.         }
  2275.  
  2276.         if(delay)
  2277.         {
  2278.             Delay(200);
  2279.         }
  2280.     }
  2281.  
  2282.     if(_fileHandle)
  2283.     {
  2284.         if(mode == 0)
  2285.         {
  2286.             while(!_fileHandle.eof)
  2287.             {
  2288.                 _line = _fileHandle.ReadLine();
  2289.  
  2290.                 if(_line || !_fileHandle.eof)
  2291.                 {
  2292.                     _msg += _line + msg;
  2293.                 }
  2294.             }
  2295.         }
  2296.         else if(msg)
  2297.         {
  2298.             _fileHandle.WriteLine(msg);
  2299.         }
  2300.  
  2301.         _fileHandle.Close();
  2302.     }
  2303.  
  2304.     return _msg;
  2305. }
  2306.  
  2307. function NTCS_Deploy(x, y, plusx, minusx, plusy, minusy)   //you can build up to 5 positions (x-shaped), center position is x, y; rest are +/- offsets
  2308. {
  2309.     // might wanna make this call etal's TD_Deploy, it seems more advanced
  2310.     var _monster = NTC_FindUnit(NTC_UNIT_MONSTER);
  2311.     var num = [0, 0, 0, 0, 0];
  2312.     var firstnum = 100;
  2313.  
  2314.     if(!_monster)
  2315.     {
  2316.         return NTCS_MoveTo(me.areaid, x, y);
  2317.     }
  2318.  
  2319.     do
  2320.     {
  2321.         if(GetDistance(_monster.x, _monster.y, x, y) <= 15)
  2322.             if(_monster.classid != 306)
  2323.             {
  2324.                 num[0]++;
  2325.             }
  2326.  
  2327.         if(GetDistance(_monster.x, _monster.y, x + plusx, y) <= 15)
  2328.             if(_monster.classid != 306)
  2329.             {
  2330.                 num[1]++;
  2331.             }
  2332.  
  2333.         if(GetDistance(_monster.x, _monster.y, x - minusx, y) <= 15)
  2334.             if(_monster.classid != 306)
  2335.             {
  2336.                 num[2]++;
  2337.             }
  2338.  
  2339.         if(GetDistance(_monster.x, _monster.y, x, y + plusy) <= 15)
  2340.             if(_monster.classid != 306)
  2341.             {
  2342.                 num[3]++;
  2343.             }
  2344.  
  2345.         if(GetDistance(_monster.x, _monster.y, x, y - minusy) <= 15)
  2346.             if(_monster.classid != 306)
  2347.             {
  2348.                 num[4]++;
  2349.             }
  2350.     }
  2351.     while(_monster.GetNext())
  2352.  
  2353.         for(var i = 0 ; i < num.length ; i++)
  2354.         {
  2355.             //Print("ÿc1" + num[i] + " ÿc:monsters at position ÿc;" + i); //doesn't count storm casters as of v0.8
  2356.             if(num[i] < firstnum)
  2357.             {
  2358.                 firstnum = num[i];
  2359.             }
  2360.         }
  2361.  
  2362.     if(firstnum == num[0])
  2363.     {
  2364.         safex = x;
  2365.         safey = y;
  2366.         NTCS_MoveTo(me.areaid, x, y);
  2367.     }
  2368.     else if(firstnum == num[1])
  2369.     {
  2370.         safex = x + plusx;
  2371.         safey = y;
  2372.         NTCS_MoveTo(me.areaid, x + plusx, y);
  2373.     }
  2374.     else if(firstnum == num[2])
  2375.     {
  2376.         safex = x - minusx;
  2377.         safey = y;
  2378.         NTCS_MoveTo(me.areaid, x - minusx, y);
  2379.     }
  2380.     else if(firstnum == num[3])
  2381.     {
  2382.         safex = x;
  2383.         safey = y + plusy;
  2384.         NTCS_MoveTo(me.areaid, x, y + plusy);
  2385.     }
  2386.     else if(firstnum == num[4])
  2387.     {
  2388.         safex = x;
  2389.         safey = y - minusy;
  2390.         NTCS_MoveTo(me.areaid, x, y - minusy);
  2391.     }
  2392. }
Add Comment
Please, Sign In to add comment