Advertisement
kolton

Untitled

Oct 31st, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var NTA_DAMAGE_NONE = 0;
  2. var NTA_DAMAGE_PHYSICAL = 1;
  3. var NTA_DAMAGE_MAGIC = 2;
  4. var NTA_DAMAGE_FIRE = 3;
  5. var NTA_DAMAGE_LIGHTNING = 4;
  6. var NTA_DAMAGE_COLD = 5;
  7. var NTA_DAMAGE_POISON = 6;
  8.  
  9. var MODE_DEAD = (1<<29)|(1<<12);
  10. var MODE_ALIVE = (1<<29)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)|(1<<10)|(1<<11)|(1<<13)|(1<<14)|(1<<15);
  11. var TYPE_NOT_NORMAL = 0xf;
  12.  
  13. var _NTA_SkillHand = [];
  14. var _NTA_SkillDamage = [];
  15. var _NTA_SkillRange = [];
  16. var _NTA_SkillDelay = [];
  17.  
  18. var _NTA_NovaTick;
  19.  
  20. var gidList = [];
  21.  
  22. function NTA_FastPick() {
  23.     if (!NTConfig_FastPick || !gidList.length) {
  24.         return;
  25.     }
  26.    
  27.     var i, item, string, result,
  28.         gidListLength = gidList.length;
  29.    
  30.     for (i = 0; i < gidListLength; i += 1) {
  31.         if (!gidList[i]) {
  32.             continue;
  33.         }
  34.        
  35.         item = NTC_GetUnit(NTC_UNIT_ITEM, null, null, gidList[i]);
  36.        
  37.         if (item && (item.mode === 3 || item.mode === 5)) {
  38.             result = NTSI_CheckItem(item, false);
  39.            
  40.             if (result && !NTSI_IsLimitedItemInt(item) && NTT_CheckSpace(item.sizex, item.sizey)) {
  41.                 string = ("ÿc2Fast Pick ÿc8:: " + NTC_ItemQualityToD2Color[item.quality] + item.name);
  42.                
  43.                 if (NTSI_PickUpItemInt(item)) {
  44.                     print(string);
  45.                    
  46.                     if (result === 1 && item.itemType !== 4 && (item.itemType < 76 || item.itemType > 81)) {
  47.                         DDE.logItem(item);
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.     }
  53.    
  54.     gidList = [];
  55. }
  56.  
  57. function NTA_Initialize()
  58. {
  59.     /* FIX
  60.     if(NTConfig_AttackSkill[1] == -1 || NTConfig_AttackSkill[3] == -1)
  61.         NTA_DetectAttackPattern();
  62.     */
  63.  
  64.     for(var i = 0 ; i < NTConfig_AttackSkill.length ; i++)
  65.     {
  66.         if(NTConfig_AttackSkill[i] > -1)
  67.         {
  68.             _NTA_SkillHand[i] = NTC_IsLeftSkill(NTConfig_AttackSkill[i]) ? 2 : NTC_HAND_RIGHT;
  69.             _NTA_SkillDamage[i] = NTA_GetDamageType(NTConfig_AttackSkill[i]);
  70.             _NTA_SkillDelay[i] = NTC_GetCastDelay(NTConfig_AttackSkill[i]);
  71.  
  72.             switch(NTConfig_AttackSkill[i])
  73.             {
  74.             case 0: // Normal Attack
  75.             case 10: // Jab
  76.             case 14: // Power Strike
  77.             case 19: // Impale
  78.             case 24: // Charged Strike
  79.             case 73: // Poison Dagger
  80.             case 96: // Sacrifice
  81.             case 97: // Smite
  82.             case 106: // Zeal
  83.             case 111: // Vengeance
  84.             case 116: // Conversion
  85.             case 126: // Bash
  86.             case 133: // Double Swing
  87.             case 139: // Stun
  88.             case 144: // Concentrate
  89.             case 147: // Frenzy
  90.             case 152: // Berserk
  91.             case 255: // Dragon Talon
  92.             case 260: // Dragon Claw
  93.             case 270: // Dragon Tail
  94.                 _NTA_SkillRange[i] = 2;
  95.                 _NTA_SkillHand[i] = 1; // bypass shift
  96.                 break;
  97.             case 42: // Static
  98.                 _NTA_SkillRange[i] = Math.floor((5 + NTC_CheckSkill(42) - 1) * 2/3);
  99.                 _NTA_SkillHand[i] = 2;
  100.                 break;
  101.             case 49: // lightning
  102.             case 53: // chain lightning
  103.                 _NTA_SkillRange[i] = 15;
  104.                 break;
  105.             case 44: // Frost Nova
  106.             case 48: // Nova
  107.                 _NTA_SkillRange[i] = 7;
  108.                 break;
  109.             case 51: // Fire Wall
  110.                 _NTA_SkillRange[i] = 10;
  111.                 break;
  112.             case 64: // Frozen Orb
  113.                 _NTA_SkillRange[i] = 15;
  114.                 break;
  115.             case 92: // Poison Nova
  116.                 _NTA_SkillRange[i] = 12;
  117.                 break;
  118.             case 112: // Blessed Hammer
  119.                 _NTA_SkillRange[i] = 3;
  120.                 break;
  121.             case 151: // Whirlwind
  122.                 _NTA_SkillRange[i] = 8;
  123.                 break;
  124.             case 245: // Tornado
  125.                 _NTA_SkillRange[i] = 6;
  126.                 break;
  127.             default:
  128.                 _NTA_SkillRange[i] = 30;
  129.                 break;
  130.             }
  131.         }
  132.     }
  133. }
  134.  
  135. function NTA_KillBoss(classid)
  136. {
  137.     var _target;
  138.  
  139.     if(NTConfig_AttackSkill[1] < 0)
  140.         return false;
  141.  
  142.     _target = NTC_GetUnit(NTC_UNIT_MONSTER, classid);
  143.  
  144.     if(!_target)
  145.         return false;
  146.        
  147.     //print("ÿc4" + _target.name + "ÿc3 Cold Res: ÿc0" + NTA_GetResistance(_target, NTA_DAMAGE_COLD) + "ÿc9 Light Res:ÿc0 " + NTA_GetResistance(_target, NTA_DAMAGE_LIGHTNING) + " ÿc1Fire Res: ÿc0" + NTA_GetResistance(_target, NTA_DAMAGE_FIRE))
  148.    
  149.     var _attackcount = 0;
  150.  
  151.     while (_attackcount < 300 && NTA_IsValidTarget(_target)) {
  152.         if (NTA_Attack(_target, (_attackcount%30) == 0) < 2) {
  153.             break;
  154.         }
  155.  
  156.         _attackcount++;
  157.     }
  158.    
  159.     NTA_FastPick();
  160.  
  161.     return (_target.hp <= 0 || _target.mode == 0 || _target.mode == 12);
  162. }
  163.  
  164. function NTA_ClearPosition(range, spectype, sortFunc) {
  165.     if (arguments.length < 1) {
  166.         range = 25;
  167.     }
  168.    
  169.     if (arguments.length < 2) {
  170.         spectype = false;
  171.     }
  172.    
  173.     var orgx, orgy, target, result, monsterList, ignoreList, dodgeList,
  174.         gidAttack = [],
  175.         dodgeIDs = [310, 362],
  176.         attackCount = 0;
  177.        
  178.     if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) {
  179.         return false;
  180.     }
  181.    
  182.     orgx = me.x;
  183.     orgy = me.y;
  184.     ignoreList = [];
  185.    
  186.     while (attackCount < 300) {
  187.         if (attackCount % 5 === 0) { // testing
  188.             monsterList = [];
  189.             dodgeList = [];
  190.            
  191.             target = NTC_GetUnit(NTC_UNIT_MONSTER, null, MODE_ALIVE);
  192.            
  193.             if (target) {
  194.                 do {
  195.                     if (ignoreList.indexOf(target.gid) === -1 && getDistance(orgx, orgy, target.x, target.y) <= range && (!spectype || target.spectype & spectype)) {
  196.                         monsterList.push(copyUnit(target));
  197.                     }
  198.                    
  199.                     if (NTConfig_Dodge && dodgeIDs.indexOf(target.classid) > -1) {
  200.                         dodgeList.push(copyUnit(target));
  201.                     }
  202.                 } while (target.getNext());
  203.             }
  204.         }
  205.        
  206.         if (monsterList.length === 0) {
  207.             break;
  208.         }
  209.        
  210.         if (arguments.length >= 3 && typeof(sortFunc) === 'function') {
  211.             monsterList.sort(sortFunc);
  212.         } else {
  213.             monsterList.sort(NTA_SortMonsters);
  214.         }
  215.        
  216.         target = monsterList[0];
  217.        
  218.         if (NTA_IsValidTarget(target)) {
  219.             if (me.classid === 1) {
  220.                 NTA_Dodge(target, _NTA_SkillRange[1], dodgeList);
  221.             }
  222.            
  223.             result = NTA_Attack(target, attackCount % 30 === 0);
  224.            
  225.             switch (result) {
  226.             case 1:
  227.                 print("att fail");
  228.                 monsterList.shift();
  229.                 ignoreList.push(target.gid);
  230.                 break;
  231.             case 2:
  232.             case 3:
  233.                 if (!target.spectype & 0x7) {
  234.                     if(!gidAttack[target.gid]) {
  235.                         gidAttack[target.gid] = 0;
  236.                     }
  237.                    
  238.                     gidAttack[target.gid] += 1;
  239.                    
  240.                     if (gidAttack[target.gid] > 8) {
  241.                         print("Skipping " + target.name);
  242.                         monsterList.shift();
  243.                         ignoreList.push(target.gid);
  244.                     }
  245.                 }
  246.                
  247.                 attackCount += 1;
  248.                
  249.                 if (target.mode === 0 || target.mode === 12) {
  250.                     NTA_FastPick();
  251.                 }
  252.                
  253.                 break;
  254.             default:
  255.                 return false;
  256.             }
  257.         } else {
  258.             monsterList.shift();
  259.             ignoreList.push(target.gid);
  260.         }
  261.     }
  262.  
  263.     switch (me.classid) {
  264.     case NTC_CHAR_CLASS_PALADIN:
  265.         if (attackCount > 2 && NTConfig_Redemption != false) {
  266.             if (Math.round(me.hp * 100 / me.hpmax) < NTConfig_Redemption[0] || Math.round(me.mp * 100 / me.mpmax) < NTConfig_Redemption[1]) {
  267.                 NTC_PutSkill(124, NTC_HAND_RIGHT);
  268.                 NTC_PingDelay(1000);
  269.             }
  270.         }
  271.        
  272.         break;
  273.     }
  274.    
  275.     if (attackCount > 0) {
  276.         NTSI_PickItems();
  277.         NTT_CleanPotions();
  278.     }
  279.    
  280.     return true;
  281. }
  282.  
  283. function NTA_Dodge(target, distance, list) { // experimental dodge function
  284.     if (!NTConfig_Dodge) {
  285.         return true;
  286.     }
  287.    
  288.     me.overhead("Dodge " + target.name);
  289.    
  290.     var i, j, coordx, coordy, monster, count,
  291.         maxcount = 0,
  292.         coords = [],
  293.         goodCoords = [],
  294.         angles = [45, 90, 135, 180, 225, 270, 305, 360];
  295.        
  296.     // step 1 - build possible dodge positions based on angles
  297.    
  298.     for (i = 0; i < angles.length; i = i + 1) {
  299.         coordx = Math.round((Math.cos(angles[i] * Math.PI / 180)) * distance + target.x);
  300.         coordy = Math.round((Math.sin(angles[i] * Math.PI / 180)) * distance + target.y);
  301.        
  302.         if (getCollision(me.area, coordx, coordy) === 0) {
  303.             coords.push([coordx, coordy]);
  304.         }
  305.     }
  306.    
  307.     if (coords.length === 0) { // no valid positions - don't move
  308.         return true;
  309.     }
  310.    
  311.     coords.sort(NTA_SortRoomInt);
  312.    
  313.     for (i = 0; i < list.length; i += 1) {
  314.         if (list[i].hp > 0 && getDistance(me, list[i]) < 8) {
  315.             maxcount += 1;
  316.         }
  317.     }
  318.    
  319.     if (maxcount === 0) {
  320.         return true;
  321.     }
  322.    
  323.     for (i = 0; i < coords.length; i += 1) {
  324.         count = 0;
  325.        
  326.         for (j = 0; j < list.length; j += 1) {
  327.             if (list[j].hp > 0 && getDistance(list[j].x, list[j].y, coords[i][0], coords[i][1]) < 8) {
  328.                 count += 1;
  329.             }
  330.         }
  331.        
  332.         if (count < maxcount) {
  333.             goodCoords = [coords[i][0], coords[i][1]];
  334.             maxcount = count;
  335.            
  336.             if (count === 0) {
  337.                 break;
  338.             }
  339.         }
  340.     }
  341.    
  342.     if (goodCoords.length > 0) { // just in case goodCoords is empty (shouldn't happen)
  343.         if (Math.abs(me.x - goodCoords[0]) < 5 && Math.abs(me.y - goodCoords[1]) < 5) { // close enough
  344.             return true;
  345.         }
  346.        
  347.         NTM_MoveTo(goodCoords[0], goodCoords[1]);
  348.     }
  349.    
  350.     return true;
  351. }
  352.  
  353. function NTA_ClearRooms(spectype) {
  354.     var i, j, coll, room, rooms;
  355.    
  356.     room = getRoom();
  357.    
  358.     if (!room) {
  359.         return false;
  360.     }
  361.    
  362.     if (arguments.length < 1) {
  363.         spectype = false;
  364.     }
  365.    
  366.     rooms = [];
  367.    
  368.     do {
  369.         coll = room.getCollision();
  370.        
  371.         main: for (i = 0; i < coll.length; i++) {
  372.             for (j = 0; j < coll[i].length; j++) {
  373.                 if (coll[i][j] === 0) {
  374.                     rooms.push([room.x * 5 + j, room.y * 5 + i]); // sizes are reversed
  375.                     break main;
  376.                 }
  377.             }
  378.         }
  379.     } while (room.getNext());
  380.    
  381.     while (rooms.length > 0) {
  382.         rooms.sort(NTA_SortRoomInt);
  383.        
  384.         room = rooms.shift();
  385.        
  386.         NTM_MoveTo(room[0], room[1]);
  387.        
  388.         if (!NTA_ClearRoom(spectype)) {
  389.             return false;
  390.         }      
  391.     }
  392.    
  393.     return true;
  394. }
  395.  
  396. function NTA_ClearRoom(spectype, sortFunc) {
  397.     if (arguments.length < 1) {
  398.         spectype = false;
  399.     }
  400.    
  401.     var orgx, orgy, target, result, monsterList, ignoreList, dodgeList, room,
  402.         gidAttack = [],
  403.         dodgeIDs = [0, 6, 310, 362],
  404.         attackCount = 0;
  405.        
  406.     if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) {
  407.         return false;
  408.     }
  409.    
  410.     room = getRoom(me.x, me.y);
  411.     ignoreList = [];
  412.    
  413.     while (attackCount < 300) {
  414.         if (attackCount % 5 === 0) { // testing
  415.             monsterList = [];
  416.             dodgeList = [];
  417.            
  418.             target = NTC_GetUnit(NTC_UNIT_MONSTER, null, MODE_ALIVE);
  419.            
  420.             if (target) {
  421.                 do {
  422.                     if (ignoreList.indexOf(target.gid) === -1 && room.unitInRoom(target) && (!spectype || target.spectype & spectype)) {
  423.                         monsterList.push(copyUnit(target));
  424.                     }
  425.                    
  426.                     if (NTConfig_Dodge && dodgeIDs.indexOf(target.classid) > -1) {
  427.                         dodgeList.push(copyUnit(target));
  428.                     }
  429.                 } while (target.getNext());
  430.             }
  431.         }
  432.        
  433.         if (monsterList.length === 0) {
  434.             break;
  435.         }
  436.        
  437.         if (arguments.length >= 2 && typeof(sortFunc) === 'function') {
  438.             monsterList.sort(sortFunc);
  439.         } else {
  440.             monsterList.sort(NTA_SortMonsters);
  441.         }
  442.        
  443.         target = monsterList[0];
  444.        
  445.         if (NTA_IsValidTarget(target)) {
  446.             if (me.classid === 1) {
  447.                 NTA_Dodge(target, _NTA_SkillRange[1], dodgeList);
  448.             }
  449.            
  450.             result = NTA_Attack(target, attackCount % 30 === 0);
  451.            
  452.             switch (result) {
  453.             case 1:
  454.                 print("att fail");
  455.                 monsterList.shift();
  456.                 ignoreList.push(target.gid);
  457.                 break;
  458.             case 2:
  459.             case 3:
  460.                 if (!target.spectype & 0x7) {
  461.                     if(!gidAttack[target.gid]) {
  462.                         gidAttack[target.gid] = 0;
  463.                     }
  464.                    
  465.                     gidAttack[target.gid] += 1;
  466.                    
  467.                     if (gidAttack[target.gid] > 8) {
  468.                         print("Skipping " + target.name);
  469.                         monsterList.shift();
  470.                         ignoreList.push(target.gid);
  471.                     }
  472.                 }
  473.                
  474.                 attackCount += 1;
  475.                
  476.                 if (target.mode === 0 || target.mode === 12) {
  477.                     NTA_FastPick();
  478.                 }
  479.                
  480.                 break;
  481.             default:
  482.                 return false;
  483.             }
  484.         } else {
  485.             monsterList.shift();
  486.             ignoreList.push(target.gid);
  487.         }
  488.     }
  489.  
  490.     switch (me.classid) {
  491.     case NTC_CHAR_CLASS_PALADIN:
  492.         if (attackCount > 2 && NTConfig_Redemption != false) {
  493.             if (Math.round(me.hp * 100 / me.hpmax) < NTConfig_Redemption[0] || Math.round(me.mp * 100 / me.mpmax) < NTConfig_Redemption[1]) {
  494.                 NTC_PutSkill(124, NTC_HAND_RIGHT);
  495.                 NTC_PingDelay(1000);
  496.             }
  497.         }
  498.        
  499.         break;
  500.     }
  501.    
  502.     NTA_OpenChests(20);
  503.    
  504.     if (attackCount > 0) {
  505.         NTSI_PickItems();
  506.         NTT_CleanPotions();
  507.     }
  508.    
  509.     return true;
  510. }
  511.  
  512. function NTA_OpenChests(range) {
  513.     var i, unit,
  514.         ids = ["chest", "WeaponRack", "ArmorStand"];
  515.        
  516.     for (i = 0; i < ids.length; i += 1) {
  517.         unit = getUnit(2, ids[i]);
  518.        
  519.         if (unit) {
  520.             do {
  521.                 if (getDistance(me, unit) <= range && NTC_OpenChest(unit)) {
  522.                     NTSI_PickItems();
  523.                 }
  524.             } while (unit.getNext());
  525.         }
  526.     }
  527. }
  528.  
  529. function NTA_IsValidTarget(monster, simple)
  530. {
  531.     if(monster && monster.type == 0 && NT_HostileAction ==2)
  532.         return true;
  533.        
  534.     if(!monster || monster.type != NTC_UNIT_MONSTER) // added for pking
  535.         return false;
  536.  
  537.     if(monster.mode == 0 || monster.mode == 12 || monster.hp <= 0)
  538.         return false;
  539.  
  540.     if(arguments.length < 2)
  541.         simple = false;
  542.  
  543.     if(!simple)
  544.     {
  545.         if(!monster.name)
  546.             return false;
  547.  
  548.         switch(monster.name.toLowerCase())
  549.         {
  550.         case "dummy":
  551.         case "an evil force":
  552.             return false;
  553.         }
  554.  
  555.         switch(monster.classid)
  556.         {
  557.         case 271:   // Merc
  558.         case 338:
  559.         case 359:
  560.         case 561:
  561.         case 356:   // Decoy
  562.         case 357:   // Valkyrie
  563.         case 418:   // Shadow Warrior
  564.         case 419:   // Shadow Master
  565.         case 363:   // Necro Skeleton
  566.         case 364:   // Necro Mage
  567.         case 366:   // Compelling Orb
  568.         case 406:   // Izual's Spirit
  569.         case 266:   // Act1: Flavie     (Navi)      -> Between BloodMoor & ColdPlains
  570.         case 408:   // Act4: Hadriel    (Malachai)  -> Entrance of River of Flames
  571.         case 516:   // Act5: Impact point for Catapults (Invisible) -> Frigid Highlands
  572.         case 517:   // Act5: Impact point for Catapults (Invisible)
  573.         case 518:   // Act5: Impact point for Catapults (Invisible) -> Bloodyfoot Hill
  574.         case 519:   // Act5: Impact point for Catapults (Invisible)
  575.         case 522:   // Act5: Combatant Barbarian
  576.         case 523:   // Act5: Combatant Barbarian
  577.         case 543:   // Baal on stairs outside Worldstone Chamber
  578.         case 545:   // Baal taunts
  579.             return false;
  580.         }
  581.  
  582.         if(monster.classid >= 289 && monster.classid <= 292) // Necro's Golem
  583.             return false;
  584.  
  585.         if((monster.classid >= 326 && monster.classid <= 330) || (monster.classid >= 410 && monster.classid <= 417)) // Traps
  586.             return false;
  587.  
  588.         if(monster.classid >= 351 && monster.classid <= 353) // Hydra
  589.             return false;
  590.  
  591.         if(monster.classid >= 420 && monster.classid <= 432) // Druid's friend
  592.             return false;
  593.     }
  594.  
  595.     if(((monster.classid >= 110 && monster.classid <= 113) || monster.classid == 608) && monster.mode == 8)
  596.         return false;
  597.  
  598.     if(monster.classid == 68 && monster.mode == 14)
  599.         return false;
  600.  
  601.     if((monster.classid == 258 || monster.classid == 261) && monster.mode == 14)
  602.         return false;
  603.  
  604.     if(monster.getStat(172) == 2 || monster.getState(105) == 0)
  605.         return false;
  606.  
  607.     if(monster.getState(53) || monster.getState(96)) // Conversion, Revive
  608.         return false;
  609.        
  610.     if((me.classid === 3 || monster.spectype & 0x7) && monster.classid == 306 && getCollision(me.area, monster.x, monster.y) & 0x1) {
  611.         return false;
  612.     }
  613.    
  614.     return true;
  615. }
  616.  
  617. function NTA_GetDamageType(skillid)
  618. {
  619.     switch(skillid)
  620.     {
  621.     case 74: // Corpse Explosion
  622.     case 106: // Zeal
  623.     case 107: // Charge
  624.     case 151: // Whirlwind
  625.     case 245: // tornado
  626.         return NTA_DAMAGE_PHYSICAL;
  627.     case 112: // Blessed Hammer
  628.         return NTA_DAMAGE_MAGIC;
  629.     case 47: // Fire Ball
  630.     case 56: // Meteor
  631.         return NTA_DAMAGE_FIRE;
  632.     case 48: // Nova
  633.     case 49: // Lightning
  634.     case 53: // Chain Lightning
  635.         return NTA_DAMAGE_LIGHTNING;
  636.     case 59: // Blizzard
  637.     case 64: // Frozen Orb
  638.         return NTA_DAMAGE_COLD;
  639.     case 92: // Poison Nova
  640.         return NTA_DAMAGE_POISON;
  641.     }
  642.  
  643.     var _etype;
  644.  
  645.     if(skillid == 74)
  646.         return NTA_DAMAGE_PHYSICAL;
  647.     if(skillid == 101)
  648.         return NTA_DAMAGE_NONE;
  649.        
  650.     _etype = getBaseStat(3, parseInt(skillid, 10), 211);
  651.  
  652.     switch(_etype)
  653.     {
  654.     case 0: return NTA_DAMAGE_PHYSICAL;
  655.     case 1: return NTA_DAMAGE_FIRE;
  656.     case 2: return NTA_DAMAGE_LIGHTNING;
  657.     case 3: return NTA_DAMAGE_MAGIC;
  658.     case 4: return NTA_DAMAGE_COLD;
  659.     case 5: return NTA_DAMAGE_POISON;
  660.     }
  661.  
  662.     return NTA_DAMAGE_NONE;
  663. }
  664.  
  665. function NTA_GetResistance(enemy, type) {
  666.     if (enemy.type === 0) { // PK optimization
  667.         return 0;
  668.     }
  669.  
  670.     switch (type) {
  671.     case NTA_DAMAGE_PHYSICAL:
  672.         return enemy.getStat(36);
  673.     case NTA_DAMAGE_MAGIC:
  674.         return enemy.getStat(37);
  675.     case NTA_DAMAGE_FIRE:
  676.         return enemy.getStat(39);
  677.     case NTA_DAMAGE_LIGHTNING:
  678.         return enemy.getStat(41);
  679.     case NTA_DAMAGE_COLD:
  680.         return enemy.getStat(43);
  681.     case NTA_DAMAGE_POISON:
  682.         return enemy.getStat(45);
  683.     }
  684.  
  685.     return 0;
  686. }
  687.  
  688. function NTA_Attack(target, firstorder)
  689. {
  690.     me.overhead(target.name + " " + target.classid);
  691.    
  692.     switch(me.classid)
  693.     {
  694.     case NTC_CHAR_CLASS_AMAZON:
  695.         return NTA_AmazonAttackInt(target, firstorder);
  696.     case NTC_CHAR_CLASS_SORCERESS:
  697.         return NTA_SorceressAttackInt(target, firstorder);
  698.     case NTC_CHAR_CLASS_NECROMANCER:
  699.         return NTA_NecromancerAttackInt(target, firstorder);
  700.     case NTC_CHAR_CLASS_PALADIN:
  701.         return NTA_PaladinAttackInt(target, firstorder);
  702.     case NTC_CHAR_CLASS_BARBARIAN:
  703.         return NTA_BarbarianAttackInt(target, firstorder);
  704.     case NTC_CHAR_CLASS_DRUID:
  705.         return NTA_DruidAttackInt(target, firstorder);
  706.     case NTC_CHAR_CLASS_ASSASSIN:
  707.         return NTA_AssassinAttackInt(target, firstorder);
  708.     }
  709.  
  710.     return 0;
  711. }
  712.  
  713. function NTA_AmazonAttackInt(target, firstorder)
  714. {
  715.     var primaryindex;
  716.    
  717.     if(firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && !me.getState(121)) {
  718.         if(getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4))
  719.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4);
  720.  
  721.         if(!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target))
  722.             return 2;
  723.  
  724.         return 3;
  725.     }
  726.    
  727.     primaryindex = target.spectype & 0x7 ? 1 : 3;
  728.    
  729.     if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100) {
  730.         if (!NTA_AmazonCastSkillInt(primaryindex, target)) {
  731.             return 2;
  732.         }
  733.  
  734.         return 3;
  735.     }
  736.    
  737.     if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) <= 80) {
  738.         if (!NTA_AmazonCastSkillInt(5, target)) {
  739.             return 2;
  740.         }
  741.  
  742.         return 3;
  743.     }
  744.  
  745.     if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100 || (NTA_GetResistance(target, NTA_DAMAGE_PHYSICAL) < 100 && primaryindex == 1 && NTC_GetMerc())) {
  746.         if (!NTA_AmazonCastSkillInt(primaryindex, target)) {
  747.             return 2;
  748.         }
  749.  
  750.         return 3;
  751.     }
  752.    
  753.     return 1;
  754. }
  755.  
  756. function NTA_AmazonCastSkillInt(index, target) {
  757.     if (NTConfig_AttackSkill[index] === 24) {
  758.         if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  759.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  760.         }
  761.  
  762.         return Farcast(target);
  763.     }
  764.  
  765.     if (!me.getState(121)) {
  766.         if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  767.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  768.         }
  769.  
  770.         return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  771.     }
  772.    
  773.     if (NTConfig_AttackSkill[index+1] > -1) {
  774.         if (getDistance(me, target) > _NTA_SkillRange[index+1] || checkCollision(me, target, 0x4)) {
  775.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index+1], 0x4);
  776.         }
  777.  
  778.         return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target); 
  779.     }
  780.    
  781.     if (me.getState(121)) {
  782.         for (var i = 0; i < 200; i++) {
  783.             NTC_Delay(NTC_DELAY_FRAME);
  784.  
  785.             if (!me.getState(121)) {
  786.                 return true;
  787.             }
  788.         }
  789.     }
  790.  
  791.     return false;
  792. }
  793.  
  794. function Farcast (target) {
  795.     if (NTC_PutSkill(24, NTC_HAND_RIGHT)) {
  796.         var i, n, mode;
  797.        
  798.         me.castUnit(24, NTC_HAND_RIGHT, target, true);
  799.        
  800.         for(n = 0; n < 4; n = n + 1) {
  801.             NTC_Delay(NTC_DELAY_FRAME);
  802.            
  803.             mode = me.mode;
  804.            
  805.             if (mode === 7 || mode === 8 || (mode >= 10 && mode <= 16) || mode === 18) {
  806.                 NTC_Delay(NTC_DELAY_FRAME);
  807.                 break;
  808.             }
  809.         }
  810.        
  811.         if (n < 4) {
  812.             for (i = 0; i < 100; i = i + 1) {
  813.                 NTC_Delay(20);
  814.                
  815.                 if (me.mode !== mode) {
  816.                     break;
  817.                 }
  818.             }
  819.            
  820.             return true;
  821.         }
  822.     }
  823.    
  824.     return false;
  825. }
  826.  
  827. function NTA_SorceressAttackInt(target, firstorder)
  828. {
  829.     if (me.gametype > 0 && !NTC_GetMerc() && target.type === 1) {
  830.         NTTMGR_VisitTown();
  831.     }
  832.    
  833.     var _primaryindex;
  834.    
  835.     if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && !me.getState(121)) {
  836.         if (getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4)) {
  837.             if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4)) {
  838.                 return 2;
  839.             }
  840.         }
  841.        
  842.         if (!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) {
  843.             return 2;
  844.         }
  845.  
  846.         return 3;
  847.     }
  848.    
  849.     if(NTConfig_CastStatic < 100 && parseInt(target.hp*100/target.hpmax) > NTConfig_CastStatic && NTA_GetResistance(target, NTA_DAMAGE_LIGHTNING) <= 80 && (target.classid == 242 || target.classid == 544 || target.classid == 243 || target.classid == 156))
  850.     {
  851.         var _staticlevel = NTC_CheckSkill(42);
  852.  
  853.         if(_staticlevel > 0)
  854.         {
  855.             var _staticrange;
  856.             var _castx, _casty;
  857.  
  858.             _staticrange = Math.floor((5+_staticlevel-1)*2/3);
  859.  
  860.             if(getDistance(me, target) > _staticrange || checkCollision(me, target, 0x4))
  861.                 NTA_GetToOptimalPosition(target, _staticrange, 0x4);
  862.  
  863.             if(!NTC_DoCast(42, NTC_HAND_RIGHT, me.x, me.y))
  864.                 return 2;
  865.  
  866.             return 3;
  867.         }
  868.     }
  869.    
  870.     _primaryindex = (target.spectype&0x7) ? 1 : 3;
  871.    
  872.     if(!NTA_SorceressCastSkillInt(_primaryindex, target))
  873.         return 1;
  874.     else
  875.         return 3;
  876. }
  877.  
  878. function NTA_SorceressCastSkillInt(index, target)
  879. {
  880.     if(!me.getState(121))
  881.     {
  882.         if(NTA_GetResistance(target, _NTA_SkillDamage[index]) < 100)
  883.         {
  884.             if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  885.                 if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4)) {
  886.                     return false;
  887.                 }
  888.             }
  889.            
  890.             return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  891.         }
  892.         else if(NTConfig_AttackSkill[5] > -1)
  893.         {
  894.             if (getDistance(me, target) > _NTA_SkillRange[5] || checkCollision(me, target, 0x4)) {
  895.                 if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[5], 0x4)) {
  896.                     return false
  897.                 }
  898.             }
  899.                
  900.             return NTC_DoCast(NTConfig_AttackSkill[5], _NTA_SkillHand[5], target);
  901.         }
  902.     }
  903.    
  904.     if(NTConfig_AttackSkill[index+1] > -1)
  905.     {
  906.         if(NTA_GetResistance(target, _NTA_SkillDamage[index+1]) < 100)
  907.         {
  908.             if (getDistance(me, target) > _NTA_SkillRange[index+1] || checkCollision(me, target, 0x4)) {
  909.                 if (NTA_GetToOptimalPosition(target, _NTA_SkillRange[index+1], 0x4)) {
  910.                     return false;
  911.                 }
  912.             }
  913.                
  914.             return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target);
  915.         }
  916.         else if(NTConfig_AttackSkill[6] > -1)
  917.         {
  918.             if (getDistance(me, target) > _NTA_SkillRange[6] || checkCollision(me, target, 0x4)) {
  919.                 if (NTA_GetToOptimalPosition(target, _NTA_SkillRange[6], 0x4)) {
  920.                     return false;
  921.                 }
  922.             }
  923.                
  924.             return NTC_DoCast(NTConfig_AttackSkill[6], _NTA_SkillHand[6], target);
  925.         }
  926.     }
  927.  
  928.     if(me.getState(121))
  929.     {
  930.         for(var i = 0; i < 200; i++)
  931.         {
  932.             NTC_Delay(NTC_DELAY_FRAME);
  933.  
  934.             if(!me.getState(121))
  935.                 return true;
  936.         }
  937.     }
  938.  
  939.     return false;
  940. }
  941.  
  942. function NTA_NecromancerAttackInt(target, firstorder) {
  943.     var _primaryindex,
  944.         currentLife = me.hp;
  945.    
  946.     /*if (NTTMGR_CheckCurse(NTConfig_CheckSelfSafe & 0x10, NTConfig_CheckMercSafe & 0x10)) {
  947.         if (!NTTMGR_VisitTown()) {
  948.             return 0;
  949.         }
  950.     }*/
  951.    
  952.     //NTTMGR_CheckSafe(false, 0x01); //instant merc revive
  953.    
  954.     if (!me.getState(14)) { // bone armor recast
  955.         NTC_DoCast(68, NTC_HAND_RIGHT);
  956.     }
  957.    
  958.     if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && me.GetSkillStatus(NTConfig_AttackSkill[0]) !== 8) {
  959.         if (GetDistance(me, target) > _NTA_SkillRange[0] || !CheckCollision(me, target, 4)) {
  960.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4);
  961.         }
  962.  
  963.         if (!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) {
  964.             return 2;
  965.         }
  966.  
  967.         return 3;
  968.     }
  969.    
  970.     if (NTConfig_Curse[2] > 0 && NTConfig_CurseList.indexOf(target.classid) > -1 && NTA_IsCursable(target)) {
  971.         if (!target.getState(_NTA_CurseState[2])) {
  972.             if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4)) {
  973.                 NTA_GetToOptimalPosition(target, 25, 0x4);
  974.             }
  975.            
  976.             if (!NTC_DoCast(NTConfig_Curse[2], NTC_HAND_RIGHT, target)) {
  977.                 return 2;
  978.             }
  979.            
  980.             return 3;
  981.         }
  982.     } else if (NTConfig_Curse[1] > 0 && NTA_IsCursable(target) && !(target.spectype & 0x0A)) {
  983.         if (!target.getState(_NTA_CurseState[1])) {
  984.             if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4)) {
  985.                 NTA_GetToOptimalPosition(target, 25, 0x4);
  986.             }
  987.            
  988.             if (!NTC_DoCast(NTConfig_Curse[1], NTC_HAND_RIGHT, target)) {
  989.                 return 2;
  990.             }
  991.            
  992.             return 3;
  993.         }
  994.     } else if (NTConfig_Curse[0] > 0 && NTA_IsCursable(target) && target.spectype & 0x0A) {
  995.         if (!target.getState(_NTA_CurseState[0])) {
  996.             if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4)) {
  997.                 NTA_GetToOptimalPosition(target, 25, 0x4);
  998.             }
  999.            
  1000.             if (!NTC_DoCast(NTConfig_Curse[0], NTC_HAND_RIGHT, target)) {
  1001.                 return 2;
  1002.             }
  1003.            
  1004.             return 3;
  1005.         }
  1006.     }
  1007.    
  1008.     _primaryindex = (target.spectype & 0x7) ? 1 : 3;
  1009.    
  1010.     if (NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100) {
  1011.         if (NTConfig_TeleStomp) {
  1012.             NTM_GetCloserInt(target);
  1013.         }
  1014.        
  1015.         if (!NTA_NecromancerCastSkillInt(_primaryindex, target)) {
  1016.             return 2;
  1017.         }
  1018.        
  1019.         /*if (NTConfig_ActiveSummon) {
  1020.             NTA_RaiseArmy();
  1021.         }
  1022.        
  1023.         NTA_ExplodeCorpses(target);*/
  1024.        
  1025.         return 3;
  1026.     }
  1027.    
  1028.     if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) < 100) {
  1029.         if (!NTA_NecromancerCastSkillInt(5, target)) {
  1030.             return 2;
  1031.         }
  1032.        
  1033.         /*if (NTConfig_ActiveSummon) {
  1034.             NTA_RaiseArmy();
  1035.         }
  1036.        
  1037.         NTA_ExplodeCorpses(target);*/
  1038.        
  1039.         return 3;
  1040.     }
  1041.  
  1042.     if (NTConfig_TeleStomp && NTC_GetMerc() && NTA_GetResistance(target, NTA_DAMAGE_PHYSICAL) < 100) {
  1043.         NTM_GetCloserInt(target);
  1044.        
  1045.         if (target.mode === 12) {
  1046.             return 2;
  1047.         }
  1048.        
  1049.         NTC_Delay(300);
  1050.  
  1051.         /*if (NTConfig_ActiveSummon) {
  1052.             NTA_RaiseArmy();
  1053.         }
  1054.        
  1055.         NTA_ExplodeCorpses(target);*/
  1056.  
  1057.         return 3;
  1058.     }
  1059.    
  1060.     return 1;
  1061. }
  1062.  
  1063. function NTA_NecromancerCastSkillInt(index, target) {
  1064.     var i, _pos;
  1065.    
  1066.     if (NTConfig_AttackSkill[index] === 92) {
  1067.         if (!_NTA_NovaTick || GetTickCount() > _NTA_NovaTick + NTConfig_PoisonNovaDelay) {
  1068.             if (getDistance(me, target) > _NTA_SkillRange[index] || !checkCollision(me, target, 4)) {
  1069.                 NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  1070.             }
  1071.            
  1072.             _NTA_NovaTick = getTickCount();
  1073.            
  1074.             return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  1075.         }
  1076.     } else if (NTConfig_AttackSkill[index] === SUMMONER) { // summoners, fishymancers, overlords... any necro that doesn't use direct attacks
  1077.         if (getDistance(me, target) > _NTA_SkillRange[index] || !checkCollision(me, target, 0x4))   {
  1078.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  1079.         }
  1080.        
  1081.         NTC_Delay(300);
  1082.        
  1083.         return true;
  1084.     } else if (!me.getState(121)) {
  1085.         if (getDistance(me, target) > _NTA_SkillRange[index] || !checkCollision(me, target, 0x4))   {
  1086.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  1087.         }
  1088.        
  1089.         return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  1090.     }
  1091.    
  1092.     if (NTConfig_AttackSkill[index+1] > -1) {
  1093.         if (getDistance(me, target) > _NTA_SkillRange[index + 1] || !checkCollision(me, target, 0x4)) {
  1094.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index + 1], 0x4);
  1095.         }
  1096.        
  1097.         return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target);
  1098.     }
  1099.    
  1100.     for (i = 0; i < 25; i+= 1) {
  1101.         NTC_Delay(NTC_DELAY_FRAME);
  1102.  
  1103.         if (!me.getState(121) && (GetTickCount() > _NTA_NovaTick + NTConfig_PoisonNovaDelay || !_NTA_NovaTick)) {
  1104.             break;
  1105.         }
  1106.     }
  1107.    
  1108.     return false;
  1109. }
  1110.  
  1111. function NTA_RaiseArmy() {
  1112.     if (me.classid !== 2) {
  1113.         return false;
  1114.     }
  1115.    
  1116.     var corpse, corpseList, skill, maxSkeletons, maxMages, maxRevives;
  1117.    
  1118.     if (NTConfig_SkeletonArmy === 'max') {
  1119.         skill = NTC_CheckSkill(70);
  1120.         maxSkeletons = skill < 4 ? skill : (Math.floor(skill / 3) + 2);
  1121.     } else {
  1122.         maxSkeletons = NTConfig_SkeletonArmy || 0;
  1123.     }
  1124.    
  1125.     if (NTConfig_MageArmy === 'max') {
  1126.         skill = NTC_CheckSkill(80);
  1127.         maxMages = skill < 4 ? skill : (Math.floor(skill / 3) + 2);
  1128.     } else {
  1129.         maxMages = NTConfig_MageArmy || 0;
  1130.     }
  1131.    
  1132.     if (NTConfig_ReviveArmy === 'max') {
  1133.         skill = NTC_CheckSkill(95);
  1134.         maxRevives = skill;
  1135.     } else {
  1136.         maxRevives = NTConfig_ReviveArmy || 0;
  1137.     }
  1138.    
  1139.     corpse = NTC_GetUnit(1, null, MODE_DEAD);
  1140.     corpseList = [];
  1141.    
  1142.     if (corpse) {
  1143.         do {
  1144.             if (getDistance(me, corpse) <= 25 && !checkCollision(me, corpse, 0x4)) {
  1145.                 corpseList.push(copyUnit(corpse));
  1146.             }
  1147.         } while (corpse.getNext());
  1148.     }
  1149.    
  1150.     MainLoop : while (corpseList.length > 0) {
  1151.         corpse = corpseList.shift();
  1152.        
  1153.         if (NTA_IsValidCorpse(corpse)) {
  1154.             if (me.getMinionCount(4) < maxSkeletons) {
  1155.                 if (!NTC_DoCast(70, NTC_HAND_RIGHT, corpse)) {
  1156.                     return false;
  1157.                 }
  1158.                
  1159.                 NTC_Delay(200);
  1160.             } else if (me.getMinionCount(5) < maxMages) {
  1161.                 if (!NTC_DoCast(80, NTC_HAND_RIGHT, corpse)) {
  1162.                     return false;
  1163.                 }
  1164.                
  1165.                 NTC_Delay(200);
  1166.             } else if (me.getMinionCount(6) < maxRevives) {
  1167.                 if (corpse.spectype & 0x7) {
  1168.                     continue MainLoop;
  1169.                 }
  1170.                
  1171.                 if (!NTC_DoCast(95, NTC_HAND_RIGHT, corpse)) {
  1172.                     return false;
  1173.                 }
  1174.                
  1175.                 NTC_Delay(200);
  1176.             } else {
  1177.                 break MainLoop;
  1178.             }
  1179.         }
  1180.     }
  1181.    
  1182.     return true;
  1183. }
  1184.  
  1185. function NTA_GetMinionCount(type) { // 0 - skeleton, 1 - mage, 2 - revive
  1186.     var minion,
  1187.         num = 0;
  1188.        
  1189.     switch (type) {
  1190.     case 0:
  1191.         minion = NTC_GetUnit(NTC_UNIT_MONSTER, 363);
  1192.         break;
  1193.     case 1:
  1194.         minion = NTC_GetUnit(NTC_UNIT_MONSTER, 364);
  1195.         break;
  1196.     case 2:
  1197.         minion = NTC_GetUnit(NTC_UNIT_MONSTER);
  1198.         break;
  1199.     }
  1200.    
  1201.     if (minion) {
  1202.         do {
  1203.             if (NTC_CheckOwner(minion) && minion.hp > 0) {
  1204.                 if (type === 2) {
  1205.                     if (minion.getState(96)) {
  1206.                         num += 1;
  1207.                     }
  1208.                 } else {
  1209.                     num += 1;
  1210.                 }
  1211.             }
  1212.         } while (minion.getNext());
  1213.     }
  1214.    
  1215.     return num;
  1216. }
  1217.  
  1218. function NTA_IsValidCorpse(unit) {
  1219.     switch (unit.classid) { // muddys
  1220.         case 151: // An evil force
  1221.         case 156: // Andariel
  1222.         case 159: // An evil force
  1223.         case 180: // Sand Maggot Young
  1224.         case 181: // Rock Worm Young
  1225.         case 182: // Devourer Young
  1226.         case 183: // Giant Lamprey Young
  1227.         case 184: // World Killer Young
  1228.         case 190: // Sand Maggot Egg
  1229.         case 191: // Rock Worm Egg
  1230.         case 192: // Devourer Egg
  1231.         case 193: // Giant Lamprey Egg
  1232.         case 194: // World Killer Egg
  1233.         case 206: // Fould Crow Nest
  1234.         case 207: // Blood Hawk Nest
  1235.         case 208: // Black Vulture Nest
  1236.         case 209: // Cloud Stalker Nest
  1237.         case 221: // Duriel
  1238.         case 227: // Maggot
  1239.         case 228: // Mummy Generator
  1240.         case 234: // Flying Scimitar
  1241.         case 242: // Mephisto
  1242.         case 243: // Diablo
  1243.         case 250: // Summoner
  1244.         case 258: // Water Watcher Limb
  1245.         case 259: // River Stalker Limb
  1246.         case 260: // Sygain Watcher Limb       
  1247.         case 261: // Water Watcher Head
  1248.         case 262: // River Stalker Head
  1249.         case 263: // Sygain Watcher Head
  1250.         case 267: // Blood Raven
  1251.         case 269: // An evil force
  1252.         case 270: // Rogue Scout (== Merc)
  1253.         case 273: // Gargoyle Trap
  1254.         case 289: // Clay Golem
  1255.         case 290: // Blood Golem
  1256.         case 291: // Iron Golem
  1257.         case 292: // Fire Golem
  1258.         case 301: // Flesh Beast
  1259.         case 302: // Stygian Dog
  1260.         case 303: // Grotesque Wyrm
  1261.         case 318: // An Evil Force
  1262.         case 319: // An Evil Force
  1263.         case 326: // A Trap
  1264.         case 327: // A Trap
  1265.         case 328: // A Trap
  1266.         case 329: // A Trap
  1267.         case 330: // A Trap
  1268.         case 334: // Sucker Nest
  1269.         case 335: // Fleeder Nest
  1270.         case 336: // Blood Hook Nest
  1271.         case 337: // Blood Wing Nest
  1272.         case 338: // Act 2 guard (== Merc)
  1273.         case 348: // Turret
  1274.         case 349: // Turret
  1275.         case 350: // Turret
  1276.         case 351: // Hydra
  1277.         case 352: // Hydra
  1278.         case 353: // Hydra
  1279.         case 354: // A Trap
  1280.         case 356: // Dopplezon
  1281.         case 357: // Valkyrie
  1282.         case 359: // Iron Wolf (== Merc)
  1283.         case 363: // Necro Skeleton
  1284.         case 364: // Necro Skeletal Mage
  1285.         case 366: // Compelling Orb
  1286.         case 369: // A Trap
  1287.         case 371: // Lightning Spire
  1288.         case 372: // Fire Tower
  1289.         case 403: // Traped Soul
  1290.         case 404: // Traped Soul
  1291.         case 406: // Izual
  1292.         case 410: // Wake Of Destruction
  1293.         case 411: // Charged Bolt Sentry
  1294.         case 412: // Lightning Sentry
  1295.         case 413: // Blade Creeper
  1296.         case 414: // Invisible Pet
  1297.         case 415: // Inferno Sentry
  1298.         case 416: // Death Sentry
  1299.         case 417: // Shadow Warrior
  1300.         case 418: // Shadow Master
  1301.         case 419: // Druid Hawk
  1302.         case 420: // Druid Spirit Wolf
  1303.         case 421: // Druid Fenris
  1304.         case 422: // Spirit of Barbs
  1305.         case 423: // Heart Of Wolverine
  1306.         case 424: // Oak Sage
  1307.         case 425: // Druid Plague Poppy
  1308.         case 426: // Druid Cycle of Life
  1309.         case 427: // Vine Creature
  1310.         case 428: // Druid Bear
  1311.         case 429: // Eagle
  1312.         case 430: // Wolf
  1313.         case 431: // Bear
  1314.         case 432: // Barricaded Door
  1315.         case 433: // Barricaded Door
  1316.         case 434: // Prison Door
  1317.         case 435: // Barricaded Door
  1318.         case 461: // Fanatic Minion
  1319.         case 462: // Beserk Slayer
  1320.         case 463: // Consumed Fire Boar
  1321.         case 464: // Consumed Ice Boar
  1322.         case 465: // Frenzied Hell Spawn
  1323.         case 466: // Frenzied Hell Spawn
  1324.         case 467: // Insane Hell Spawn
  1325.         case 468: // Insane Ice Spawn
  1326.         case 497: // Catapult
  1327.         case 498: // Catapult
  1328.         case 499: // Catapult
  1329.         case 500: // Catapult
  1330.         case 501: // Frozen Horror 1
  1331.         case 502: // Frozen Horror 2
  1332.         case 503: // Frozen Horror 3
  1333.         case 504: // Frozen Horror 4
  1334.         case 505: // Frozen Horror 5
  1335.         case 516: // Catapult
  1336.         case 517: // Catapult
  1337.         case 518: // Catapult
  1338.         case 519: // Catapult
  1339.         case 522: // Barbarian Fighter
  1340.         case 523: // Barbarian Fighter
  1341.         case 524: // Barricade Wall Right
  1342.         case 525: // Barricade Wall Left
  1343.         case 526: // Nihlatak
  1344.         case 528: // Evil Hut
  1345.         case 535: // Barbarian Fighter
  1346.         case 536: // Barbarian Fighter
  1347.         case 537: // Ancient Statue 1
  1348.         case 538: // Ancient Statue 2
  1349.         case 539: // Ancient Statue 3
  1350.         case 540: // Ancient Barbarian 1
  1351.         case 541: // Ancient Barbarian 2
  1352.         case 542: // Ancient Barbarian 3
  1353.         case 543: // Baal Throne
  1354.         case 544: // Baal Crab
  1355.         case 545: // Baal Taunt
  1356.         case 551: // Pain Worm
  1357.         case 552: // Pain Worm
  1358.         case 553: // Pain Worm
  1359.         case 554: // Pain Worm
  1360.         case 555: // Pain Worm
  1361.         case 556: // Bunny
  1362.         case 559: // Baal Crab to Stairs
  1363.         case 560: // Hireling
  1364.         case 561: // Hireling
  1365.         case 562: // Baal Tentacle
  1366.         case 563: // Baal Tentacle
  1367.         case 564: // Baal Tentacle
  1368.         case 565: // Baal Tentacle
  1369.         case 566: // Baal Tentacle
  1370.         case 567: // Injured Barbarian
  1371.         case 568: // Injured Barbarian
  1372.         case 569: // Injured Barbarian
  1373.         case 570: // Baal Crab Clone
  1374.         case 571: // Baals Minions
  1375.         case 572: // Baals Minions     
  1376.         case 573: // Baals Minions
  1377.         case 574: // Worldstone Effect
  1378.         case 662: // Flayer Shaman
  1379.             return false;
  1380.     }
  1381.    
  1382.     if(!unit.getState(107) // Shattered
  1383.         && !unit.getState(104) // Corpse Explosion
  1384.         && !unit.getState(1) // Freeze
  1385.         && !unit.getState(118) // Already Looted/Unlootable
  1386.         && !unit.getState(99) // Redeemed
  1387.         && !unit.getState(2) // Freezed
  1388.         && !unit.getState(96) // Revived
  1389.         && (unit.hp <= 0 || unit.mode === 0 || unit.mode === 12)) { // Dead
  1390.         return true;
  1391.     }
  1392.    
  1393.     return false;
  1394. }
  1395.  
  1396. function NTA_PaladinAttackInt(target, firstorder)
  1397. {
  1398.     if (!me.getState(101)) {
  1399.         NTC_DoCast(117, NTC_HAND_RIGHT); // Holy Shield Recast
  1400.     }
  1401.    
  1402.     var _primaryindex;
  1403.  
  1404.     if(firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100)
  1405.     {
  1406.         if(getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4))
  1407.             NTA_MoveCloseInt(target, _NTA_SkillRange[0]);
  1408.            
  1409.         if(!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target))
  1410.             return 2;
  1411.  
  1412.         return 3;
  1413.     }
  1414.  
  1415.     _primaryindex = (target.spectype & 0x7) ? 1 : 3;
  1416.    
  1417.     if(NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100)
  1418.     {
  1419.         if(_NTA_SkillRange[_primaryindex] < 4 && !NTA_IsValidSpot(target.x, target.y))
  1420.             return 1;
  1421.  
  1422.         if(!NTA_PaladinCastSkillInt(_primaryindex, target))
  1423.             return 2;
  1424.  
  1425.         return 3;
  1426.     }
  1427.  
  1428.     if(NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) < 100)
  1429.     {
  1430.         if(_NTA_SkillRange[5] < 4 && !NTA_IsValidSpot(target.x, target.y))
  1431.             return 1;
  1432.  
  1433.         if(!NTA_PaladinCastSkillInt(5, target))
  1434.             return 2;
  1435.  
  1436.         return 3;
  1437.     }
  1438.  
  1439.     return 1;
  1440. }
  1441.  
  1442. function NTA_PaladinCastSkillInt(index, target) {
  1443.     if (NTConfig_AttackSkill[index] === 112) {
  1444.         if (!NTA_CheckHammerPosition(target)) {
  1445.             NTA_GetHammerPosition(target);
  1446.         }
  1447.     } else {
  1448.         if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  1449.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  1450.         }
  1451.     }
  1452.    
  1453.     if (NTConfig_AttackSkill[index+1] > -1) {
  1454.         NTC_PutSkill(NTConfig_AttackSkill[index+1], NTC_HAND_RIGHT);
  1455.     }
  1456.    
  1457.     if (target.hp <= 0 || target.mode === 0 || target.mode === 12) {
  1458.         return true;
  1459.     }
  1460.    
  1461.     return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  1462. }
  1463.  
  1464. function NTA_CheckHammerPosition(unit) {
  1465.     var i,
  1466.         offsets = [[3, 2], [3, 1], [-3, 3], [0, 3], [-3, 2], [-4, 0]];
  1467.        
  1468.     for (i = 0; i < offsets.length; i += 1) {
  1469.         if (Math.abs(unit.x + offsets[i][0] - me.x) < 1 && Math.abs(unit.y + offsets[i][1] - me.y) < 1) {
  1470.             return true;
  1471.         }
  1472.     }
  1473.    
  1474.     return false;
  1475. }
  1476.  
  1477. function NTA_GetHammerPosition(unit) {
  1478.     var i,
  1479.         positions = [],
  1480.         offsets = [[3, 2], [3, 1], [-3, 3], [0, 3], [-3, 2], [-4, 0]];
  1481.        
  1482.     for (i = 0; i < offsets.length; i += 1) {
  1483.         if (NTA_IsValidSpot(unit.x + offsets[i][0], unit.y + offsets[i][1])) {
  1484.             return NTM_MoveTo(unit.x + offsets[i][0], unit.y + offsets[i][1]);
  1485.         }
  1486.     }
  1487.    
  1488.     return false;
  1489. }
  1490.  
  1491. function NTA_BarbarianAttackInt(target, firstorder)
  1492. {
  1493.     var primaryindex;
  1494.    
  1495.     if(firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && !me.getState(121)) {
  1496.         if(getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4))
  1497.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4);
  1498.  
  1499.         if(!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target))
  1500.             return 2;
  1501.  
  1502.         return 3;
  1503.     }
  1504.    
  1505.     primaryindex = target.spectype & 0x7 ? 1 : 3;
  1506.    
  1507.     if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100) {
  1508.         if (!NTA_BarbarianCastSkillInt(primaryindex, target)) {
  1509.             return 2;
  1510.         }
  1511.  
  1512.         return 3;
  1513.     }
  1514.    
  1515.     if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) <= 80) {
  1516.         if (!NTA_BarbarianCastSkillInt(5, target)) {
  1517.             return 2;
  1518.         }
  1519.  
  1520.         return 3;
  1521.     }
  1522.  
  1523.     if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100 || (NTA_GetResistance(target, NTA_DAMAGE_PHYSICAL) < 100 && primaryindex == 1 && NTC_GetMerc())) {
  1524.         if (!NTA_BarbarianCastSkillInt(primaryindex, target)) {
  1525.             return 2;
  1526.         }
  1527.  
  1528.         return 3;
  1529.     }
  1530.    
  1531.     return 1;
  1532. }
  1533.  
  1534. function NTA_BarbarianCastSkillInt(index, target) {
  1535.     if (NTConfig_AttackSkill[index] === 24) {
  1536.         if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  1537.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  1538.         }
  1539.        
  1540.         return Farcast(target);
  1541.     }
  1542.    
  1543.     if (!me.getState(121)) {
  1544.         if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  1545.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
  1546.         }
  1547.  
  1548.         return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  1549.     }
  1550.    
  1551.     if (NTConfig_AttackSkill[index+1] > -1) {
  1552.         if (getDistance(me, target) > _NTA_SkillRange[index+1] || checkCollision(me, target, 0x4)) {
  1553.             NTA_GetToOptimalPosition(target, _NTA_SkillRange[index+1], 0x4);
  1554.         }
  1555.  
  1556.         return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target); 
  1557.     }
  1558.    
  1559.     if (me.getState(121)) {
  1560.         for (var i = 0; i < 200; i++) {
  1561.             NTC_Delay(NTC_DELAY_FRAME);
  1562.            
  1563.             if (!me.getState(121)) {
  1564.                 return true;
  1565.             }
  1566.         }
  1567.     }
  1568.  
  1569.     return false;
  1570. }
  1571.  
  1572.  
  1573. function NTA_DruidAttackInt(target, firstorder)
  1574. {
  1575.     if (!me.getState(144)) {
  1576.         NTC_DoCast(250, NTC_HAND_RIGHT); // Hurricane Recast
  1577.     }
  1578.    
  1579.     if (!me.getState(151)) {
  1580.         NTC_DoCast(235, NTC_HAND_RIGHT); // Cyclone Armor Recast
  1581.     }
  1582.    
  1583.     if (!me.getState(149)) {
  1584.         NTC_DoCast(226, NTC_HAND_RIGHT); // Oak Sage Recast
  1585.     }
  1586.    
  1587.     var _primaryindex;
  1588.    
  1589.     if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100) {
  1590.         if (getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4)) {
  1591.             if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4)) {
  1592.                 return false;
  1593.             }
  1594.         }
  1595.        
  1596.         if (!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) {
  1597.             return 2;
  1598.         }
  1599.  
  1600.         return 3;
  1601.     }
  1602.    
  1603.     _primaryindex = (target.spectype & 0x7) ? 1 : 3;
  1604.    
  1605.     if (NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100 || NTC_CheckSkill(250) && NTA_GetResistance(target, NTA_DAMAGE_COLD) < 100) { // hurricane optimization
  1606.         if (!NTA_DruidCastSkillInt(_primaryindex, target)) {
  1607.             return 2;
  1608.         }
  1609.  
  1610.         return 3;
  1611.     }
  1612.    
  1613.     if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) < 100) {
  1614.         if (!NTA_DruidCastSkillInt(5, target)) {
  1615.             return 2;
  1616.         }
  1617.        
  1618.         return 3;
  1619.     }
  1620.    
  1621.     return 1;
  1622. }    
  1623.  
  1624. function NTA_DruidCastSkillInt(index, target) {
  1625.     if (NTConfig_AttackSkill[index] === 245) {
  1626.         if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  1627.             NTA_GetTornadoPosition(target);
  1628.         }
  1629.        
  1630.         if (getDistance(me, target) <= _NTA_SkillRange[index] && !checkCollision(me, target, 0x4)) {
  1631.             return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  1632.         } else {
  1633.             return false;
  1634.         }
  1635.     } else if (!me.getState(121)) {
  1636.         if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
  1637.             if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4)) {
  1638.                 return false;
  1639.             }
  1640.         }
  1641.        
  1642.         return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  1643.     }
  1644.    
  1645.     if (NTConfig_AttackSkill[index + 1] > -1) {
  1646.         if (getDistance(me, target) > _NTA_SkillRange[index + 1] || checkCollision(me, target, 0x4)) {
  1647.             if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[index + 1], 0x4)) {
  1648.                 return false;
  1649.             }
  1650.         }
  1651.        
  1652.         return NTC_DoCast(NTConfig_AttackSkill[index + 1], _NTA_SkillHand[index + 1], target);
  1653.     }
  1654.    
  1655.     if (me.getState(121)) {
  1656.         for (var i = 0; i < 200; i += 1) {
  1657.             NTC_Delay(NTC_DELAY_FRAME);
  1658.  
  1659.             if (!me.getState(121)) {
  1660.                 return true;
  1661.             }
  1662.         }
  1663.     }
  1664.    
  1665.     return false;
  1666. }
  1667.  
  1668. function NTA_GetTornadoPosition(unit) {
  1669.     var i,
  1670.         positions = [],
  1671.         offsets = [[4,4], [4, -4], [-4, 0], [0, 4]];
  1672.        
  1673.     for (i = 0; i < offsets.length; i += 1) {
  1674.         if (NTA_IsValidSpot(unit.x + offsets[i][0], unit.y + offsets[i][1])) {
  1675.             positions.push([unit.x + offsets[i][0], unit.y + offsets[i][1]]);
  1676.         }
  1677.     }
  1678.    
  1679.     positions.sort(NTA_SortRoomInt);
  1680.    
  1681.     for (i = 0; i < positions.length; i += 1) { // lazy style!
  1682.         NTM_MoveTo(positions[i][0], positions[i][1]);
  1683.        
  1684.         if (!checkCollision(me, unit, 0x4)) {
  1685.             return true;
  1686.         }
  1687.     }
  1688.    
  1689.     return false;
  1690. }
  1691.  
  1692. function NTA_AssassinAttackInt(target, boss, maxattacks)
  1693. {
  1694.     return false;
  1695. }
  1696.  
  1697. function NTA_MoveCloseInt(target, maxrange)
  1698. {
  1699.     var _dist = parseInt(getDistance(me, target));
  1700.    
  1701.     if(_dist > maxrange)
  1702.     {
  1703.         var _destx, _desty;
  1704.  
  1705.         _destx = me.x + Math.round((_dist-maxrange)*(target.x-me.x) / _dist);
  1706.         _desty = me.y + Math.round((_dist-maxrange)*(target.y-me.y) / _dist);
  1707.        
  1708.         NTM_MoveTo(_destx, _desty);
  1709.        
  1710.         /*if(getDistance(me, target) > maxrange)
  1711.             NTM_MoveTo(target.x,target.y);*/
  1712.     }
  1713.  
  1714.     return true;
  1715. }
  1716.  
  1717. function NTA_SortRoomInt(a, b)
  1718. {
  1719.     if(getDistance(me.x, me.y, a[0], a[1]) < getDistance(me.x, me.y, b[0], b[1]))
  1720.         return -1;
  1721.  
  1722.     return 1;
  1723. }
  1724.  
  1725. function NTA_SortMonsters(unitA, unitB) {
  1726.     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];
  1727.    
  1728.     if (monID.indexOf(unitA.classid) > -1) { // priority monsters
  1729.         return -1;
  1730.     } else if (!checkCollision(me, unitA, 0x4) && getDistance(me, unitA) < getDistance(me, unitB)) { // closest visible target
  1731.         return -1;
  1732.     }
  1733.    
  1734.     return 1;
  1735. }
  1736.  
  1737. function NTA_IsValidSpot(x, y) {   
  1738.     if (getCollision(me.area, x, y) & 0x1) {
  1739.         return false;
  1740.     }
  1741.    
  1742.     return true;
  1743. }
  1744.  
  1745. function NTA_GetToOptimalPosition(target, distance, coll) {
  1746.     var n, i, j, cx, cy, t, room, map,
  1747.         coords = [],
  1748.         goodCoords = [],
  1749.         angles = [0, 45, 90, 135, 180, 225, 270, 305];
  1750.        
  1751.     t = getTickCount();
  1752.     room = getRoom(target.x, target.y);
  1753.    
  1754.     if (!room) {
  1755.         return false;
  1756.     }
  1757.    
  1758.     map = room.getCollision();
  1759.    
  1760.     // discard invalid final spots
  1761.    
  1762.     for (n = 0; n < 3; n += 1) {
  1763.         if (n > 0) {
  1764.             distance = Math.round(distance / 2);
  1765.         }
  1766.        
  1767.         for (i = 0; i < angles.length; i += 1) {
  1768.             cx = Math.round((Math.cos(angles[i] * Math.PI / 180)) * distance + target.x);
  1769.             cy = Math.round((Math.sin(angles[i] * Math.PI / 180)) * distance + target.y);
  1770.            
  1771.             if (NTA_IsValidSpot(cx, cy)) {
  1772.                 coords.push([cx, cy, angles[i]]); // push angles to be sorted
  1773.             }
  1774.         }
  1775.        
  1776.         if (coords.length > 0) {
  1777.             coords.sort(NTA_SortRoomInt); // sort angles by final spot distance
  1778.         } else { // no good final spots
  1779.             return false;
  1780.         }
  1781.        
  1782.         MainLoop: for (i = 0; i < coords.length; i += 1) { // sorted angles are coords[i][2]
  1783.             for (j = 1; j < distance; j += 1) {
  1784.                 cx = Math.round((Math.cos(coords[i][2] * Math.PI / 180)) * j + target.x);
  1785.                 cy = Math.round((Math.sin(coords[i][2] * Math.PI / 180)) * j + target.y);
  1786.                
  1787.                 //if (getCollision(me.area, cx, cy) & coll) {
  1788.                 if (getCollisionEx(room.x * 5, room.y * 5, map, cx, cy) & coll) {
  1789.                     continue MainLoop; // skip if path is blocked
  1790.                 }
  1791.             }
  1792.            
  1793.             if (NTA_IsValidSpot(cx, cy)) { // just in case
  1794.                 print(getTickCount() - t);
  1795.                 NTM_MoveTo(cx, cy, 0); // first good spot is the closest
  1796.                
  1797.                 if (!checkCollision(me, target, coll)) {
  1798.                     return true;
  1799.                 }
  1800.             }
  1801.         }
  1802.     }
  1803.    
  1804.     return false;
  1805. }
  1806.  
  1807. function getCollisionEx(roomx, roomy, map, x, y) {     
  1808.     for (var i = 0; i < map.length; i += 1) {
  1809.         for (var j = 0; j < map[i].length; j += 1) {
  1810.             if (roomx + j === x && roomy + i === y) {
  1811.                 return map[i][j];
  1812.             }
  1813.         }
  1814.     }
  1815.    
  1816.     return 1;
  1817. }
  1818.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement