Advertisement
kolton

Untitled

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