Advertisement
kolton

Untitled

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