Advertisement
kolton

NTDiablo

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