Advertisement
kolton

Untitled

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