Don't like ads? PRO users don't see any ads ;-)
Guest

NTAttackNecromancer.ntl

By: a guest on Jun 25th, 2012  |  syntax: JavaScript  |  size: 9.43 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function NTA_DetectAttackPattern() {
  2.         return NTA_NecromancerAttackPatternInt();
  3. }
  4.  
  5. function NTA_Attack(target, firstorder) {
  6.         return NTA_NecromancerAttackInt(target, firstorder);
  7. }
  8.  
  9. function NTA_NecromancerAttackPatternInt() {
  10.         return false;
  11. }
  12.  
  13. function NTA_NecromancerAttackInt(target, firstorder) {
  14.         var _primaryindex;
  15.  
  16.         if ((NTTMGR_CheckCurse(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe, true)) || (me.hp <= parseInt(me.hpmax * NTConfig_TPChicken,10) / 100)) {
  17.                 if (!NTTMGR_VisitTown()) {
  18.                         return 0;
  19.                 }
  20.         }
  21.  
  22.         if (NTT_CheckMerc()) { // merc revive
  23.                 NTTMGR_VisitTown();
  24.         }
  25.        
  26.         if (!me.GetState(14)) { //check and recast bone armor
  27.                 NTC_CastSkill(68, NTC_HAND_RIGHT);
  28.         }
  29.  
  30.         if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && me.GetSkillStatus(NTConfig_AttackSkill[0]) != 8) {
  31.                 if (GetDistance(me, target) > _NTA_SkillRange[0] || !CheckCollision(me, target, 4))     {
  32.                         var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[0], 4);
  33.  
  34.                         if (_pos) {
  35.                                 NTM_MoveTo(target.areaid, _pos[0], _pos[1], 0);
  36.                         }
  37.                 }
  38.  
  39.                 if (!NTC_CastSkill(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) {
  40.                         return 2;
  41.                 }
  42.  
  43.                 return 3;
  44.         }
  45.        
  46.         if (NTConfig_Curse[0] > 0 && target.spectype & 0x0A && !target.GetState(_NTA_CurseState[0]) && NTA_IsCursable(target))
  47.         {
  48.                 if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4)) {
  49.                         var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, 25, 4);
  50.  
  51.                         if (_pos) {
  52.                                 NTM_MoveTo(target.areaid, _pos[0], _pos[1], 0);
  53.                         }
  54.                 }
  55.  
  56.                 if (!NTC_CastSkill(NTConfig_Curse[0], NTC_HAND_RIGHT, target)) {
  57.                         return 2;
  58.                 }
  59.  
  60.                 return 3;
  61.         }
  62.         else if (NTConfig_Curse[1] > 0 && !(target.spectype&0x0A) && !target.GetState(_NTA_CurseState[1]) && NTA_IsCursable(target)) {
  63.                 if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4))     {
  64.                         var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, 25, 4);
  65.  
  66.                         if (_pos) {
  67.                                 NTM_MoveTo(target.areaid, _pos[0], _pos[1], 0);
  68.                         }
  69.                 }
  70.  
  71.                 if (!NTC_CastSkill(NTConfig_Curse[1], NTC_HAND_RIGHT, target)) {
  72.                         return 2;
  73.                 }
  74.  
  75.                 return 3;
  76.         }
  77.  
  78.         _primaryindex = (target.spectype & 0x0A) ? 1 : 3;
  79.        
  80.         if (NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100) {
  81.                 if (NTConfig_TeleStomp && _primaryindex === 1) {
  82.                         NTM_GetCloserInt(target);
  83.                 }
  84.        
  85.                 if (!NTA_NecromancerCastSkillInt(_primaryindex, target)) {
  86.                         return 2;
  87.                 }
  88.  
  89.                 if (NTConfig_ActiveSummon) {
  90.                         if (NTA_SkeletonArmy(NTConfig_SkeletonArmy)) {
  91.                                 if (NTA_MageArmy(NTConfig_MageArmy)) {
  92.                                         if (NTA_ReviveArmy(NTConfig_ReviveArmy)) {
  93.                                                 NTA_ExplodeCorpses(target);
  94.                                         }
  95.                                 }
  96.                         }
  97.                 } else {
  98.                         NTA_ExplodeCorpses(target);
  99.                 }
  100.                
  101.                 return 3;
  102.         }
  103.        
  104.         if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) < 100) {
  105.                 if (!NTA_NecromancerCastSkillInt(5, target)) {
  106.                         return 2;
  107.                 }
  108.                
  109.                 if (NTConfig_ActiveSummon) {
  110.                         if (NTA_SkeletonArmy(NTConfig_SkeletonArmy)) {
  111.                                 if (NTA_MageArmy(NTConfig_MageArmy)) {
  112.                                         if (NTA_ReviveArmy(NTConfig_ReviveArmy)) {
  113.                                                 NTA_ExplodeCorpses(target);
  114.                                         }
  115.                                 }
  116.                         }
  117.                 } else {
  118.                         NTA_ExplodeCorpses(target);
  119.                 }
  120.                
  121.                 return 3;
  122.         }
  123.  
  124.         if (NTConfig_TeleStomp && NTC_GetMerc() && NTA_GetResistance(target, NTA_DAMAGE_PHYSICAL) < 100) {
  125.                 NTM_GetCloserInt(target);
  126.                
  127.                 if (target.mode === 12) {
  128.                         return 2;
  129.                 }
  130.                
  131.                 NTC_Delay(300);
  132.  
  133.                 if (NTConfig_ActiveSummon) {
  134.                         if (NTA_SkeletonArmy(NTConfig_SkeletonArmy)) {
  135.                                 if (NTA_MageArmy(NTConfig_MageArmy)) {
  136.                                         if (NTA_ReviveArmy(NTConfig_ReviveArmy)) {
  137.                                                 NTA_ExplodeCorpses(target);
  138.                                         }
  139.                                 }
  140.                         }
  141.                 } else {
  142.                         NTA_ExplodeCorpses(target);
  143.                 }
  144.  
  145.                 return 3;
  146.         }
  147.        
  148.         return 1;
  149. }
  150.  
  151. function NTA_NecromancerCastSkillInt(index, target) {
  152.         if (NTConfig_AttackSkill[index] === 92) {
  153.                 if (!_NTA_NovaTick || GetTickCount() > _NTA_NovaTick + NTConfig_PoisonNovaDelay) {
  154.                         if (GetDistance(me, target) > _NTA_SkillRange[index] || !CheckCollision(me, target, 4)) {
  155.                                 var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[index], 4);
  156.  
  157.                                 if (_pos) {
  158.                                         NTM_MoveTo(target.areaid, _pos[0], _pos[1], 0);
  159.                                 }
  160.                         }
  161.                        
  162.                         _NTA_NovaTick = GetTickCount();
  163.                        
  164.                         return NTC_CastSkill(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  165.                 }
  166.         } else if (me.GetSkillStatus(NTConfig_AttackSkill[index]) != 8) {
  167.                 if (GetDistance(me, target) > _NTA_SkillRange[index] || !CheckCollision(me, target, 4)) {
  168.                         var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[index], 4);
  169.  
  170.                         if (_pos) {
  171.                                 NTM_MoveTo(target.areaid, _pos[0], _pos[1], 0);
  172.                         }
  173.                 }
  174.  
  175.                 return NTC_CastSkill(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
  176.         }
  177.  
  178.         if (NTConfig_AttackSkill[index+1] > -1) {
  179.                 if (GetDistance(me, target) > _NTA_SkillRange[index+1] || !CheckCollision(me, target, 4)) {
  180.                         var _pos = me.GetOptimalAttackPos(target.areaid, target.x, target.y, _NTA_SkillRange[index+1], 4);
  181.  
  182.                         if (_pos) {
  183.                                 NTM_MoveTo(target.areaid, _pos[0], _pos[1], 0);
  184.                         }
  185.                 }
  186.  
  187.                 return NTC_CastSkill(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target);
  188.         }
  189.  
  190.         for (var i = 0; i < 25; i+= 1) {
  191.                 NTC_Delay(NTC_DELAY_FRAME);
  192.  
  193.                 if (me.GetSkillStatus(NTConfig_AttackSkill[index]) != 8 && (GetTickCount() > _NTA_NovaTick + NTConfig_PoisonNovaDelay || !_NTA_NovaTick)) {
  194.                         break;
  195.                 }
  196.         }
  197.  
  198.         return false;
  199. }
  200.  
  201. function NTA_IsCursable(target) {
  202.         if (target.name.indexOf(GetLocaleString(11086)) != -1) { // Possessed
  203.                 return false;
  204.         }
  205.  
  206.         switch (target.classid) {
  207.     case 206: // Foul Crow Nest
  208.     case 258: // Water Watcher
  209.     case 261: // Water Watcher
  210.     case 266: // Flavie
  211.                 return false;
  212.         }
  213.        
  214.         return true;
  215. }
  216.  
  217. function NTA_SkeletonArmy(num)
  218. {
  219.         if (num <= 0) {
  220.                 return true;
  221.         }
  222.        
  223.         if (NTA_GetMinionCount(0) >= num) {
  224.                 return true;
  225.         }
  226.        
  227.         for (var i = 0; i < 5; i += 1) {
  228.                 var corpse = NTC_FindUnit(NTC_UNIT_MONSTER);
  229.                
  230.                 if (corpse) {
  231.                         do {
  232.                                 if (NTA_IsValidCorpse(corpse)) {
  233.                                         if (NTA_GetMinionCount(0) >= num) {
  234.                                                 return true;
  235.                                         }
  236.                                        
  237.                                         //Print("Skeleton Raising " + corpse.classid + " " + corpse.name);
  238.                                        
  239.                                         NTC_CastSkill(70, NTC_HAND_RIGHT, corpse);
  240.                                 }
  241.                         } while (corpse.GetNext());
  242.                 } else {
  243.                         break;
  244.                 }
  245.         }
  246.        
  247.         return false;
  248. }
  249.  
  250. function NTA_MageArmy(num) {
  251.         if (num <= 0) {
  252.                 return true;
  253.         }
  254.        
  255.         if (NTA_GetMinionCount(1) >= num) {
  256.                 return true;
  257.         }
  258.        
  259.         for (var i = 0; i < 5; i += 1) {
  260.                 var corpse = NTC_FindUnit(NTC_UNIT_MONSTER);
  261.                
  262.                 if (corpse) {
  263.                         do {
  264.                                 if (NTA_IsValidCorpse(corpse)) {
  265.                                         if (NTA_GetMinionCount(1) >= num) {
  266.                                                 return true;
  267.                                         }      
  268.                                        
  269.                                         //Print("Mage Raising " + corpse.classid + " " + corpse.name);
  270.                                        
  271.                                         NTC_CastSkill(80, NTC_HAND_RIGHT, corpse);
  272.                                 }
  273.                         } while (corpse.GetNext());
  274.                 } else {
  275.                         break;
  276.                 }
  277.         }
  278.        
  279.         return false;
  280. }
  281.  
  282. function NTA_ReviveArmy(num) {
  283.         if (num <= 0) {
  284.                 return true;
  285.         }
  286.        
  287.         if (NTA_GetMinionCount(2) >= num) {
  288.                 return true;
  289.         }
  290.        
  291.         for (var i = 0; i < 5; i += 1) {
  292.                 var corpse = NTC_FindUnit(NTC_UNIT_MONSTER);
  293.                
  294.                 if (corpse) {
  295.                         do {
  296.                                 if(NTA_IsValidCorpse(corpse, true)) {
  297.                                         if (NTA_GetMinionCount(2) >= num) {
  298.                                                 return true;
  299.                                         }
  300.                                        
  301.                                         //Print("Reviving " + corpse.classid + " " + corpse.name);
  302.                                        
  303.                                         NTC_CastSkill(95, NTC_HAND_RIGHT, corpse);
  304.                                 }
  305.                         } while (corpse.GetNext());
  306.                 } else {
  307.                         break;
  308.                 }
  309.         }
  310.        
  311.         return false;
  312. }
  313.  
  314. function NTA_ExplodeCorpses(target) {
  315.         if (NTConfig_ExplodeCorpses === 0 || target.hp === 0 || target.mode === 0 || target.mode === 12) {
  316.                 return false;
  317.         }
  318.        
  319.         var exploded = 0,
  320.                 corpse = NTC_FindUnit(NTC_UNIT_MONSTER);
  321.                
  322.         if (corpse) {
  323.                 do {
  324.                         if (GetDistance(corpse, target) <= 10 && NTA_IsValidCorpse(corpse))     {
  325.                                 //Print("Exploding " + corpse.classid + " " + corpse.name);
  326.                                
  327.                                 if (NTC_CastSkill(NTConfig_ExplodeCorpses, NTC_HAND_RIGHT, corpse)) {
  328.                                         exploded++;
  329.                                 }
  330.                                
  331.                                 if (exploded >= 2) {
  332.                                         return false;
  333.                                 }
  334.                         }
  335.                 } while (corpse.GetNext());
  336.         }
  337.        
  338.         return true;
  339. }
  340.  
  341. function NTA_IsValidCorpse(unit, revive) {
  342.         if (arguments.length < 2) {
  343.                 revive = false;
  344.         }
  345.        
  346.         var badList = [462, 571];
  347.        
  348.         if (revive && unit.spectype & 0x0A || badList.indexOf(unit.classid) !== -1) {
  349.                 return false;
  350.         }
  351.        
  352.         if ((unit.hp === 0 || unit.mode === 0 || unit.mode === 12) && GetDistance(me, unit) <= 25 && CheckCollision(me, unit, 4) &&
  353.                 !unit.GetState(1) && // freeze
  354.                 !unit.GetState(96) && // revive
  355.                 !unit.GetState(99) && // redeemed
  356.                 !unit.GetState(104) && // nodraw
  357.                 !unit.GetState(107) && // shatter
  358.                 !unit.GetState(118) && // noselect
  359.                 GetBaseStat("monstats2.txt", unit.classid, revive ? 97 : 95)) { // non selectable and non revivable monsters
  360.                         if (GetBaseStat("monstats2.txt", unit.classid, revive ? 4 : 95) === 3) { return false; }        //      too big
  361.                         return true;
  362.         }
  363.        
  364.         return false;
  365. }
  366.  
  367. function NTA_GetMinionCount(type) { // 0 - skeleton, 1 - mage, 2 - revive
  368.         var minion,
  369.                 num = 0;
  370.                
  371.         switch (type) {
  372.                 case 0:
  373.                         minion = NTC_FindUnit(NTC_UNIT_MONSTER, 363);
  374.                         break;
  375.                 case 1:
  376.                         minion = NTC_FindUnit(NTC_UNIT_MONSTER, 364);
  377.                         break;
  378.                 case 2:
  379.                         minion = NTC_FindUnit(NTC_UNIT_MONSTER);
  380.                         break;
  381.         }
  382.        
  383.         if (minion) {
  384.                 do {
  385.                         if (NTC_CheckOwner(minion) && minion.hp > 0) {
  386.                                 if (type === 2) {
  387.                                         if (minion.GetState(96)) {
  388.                                                 num += 1;
  389.                                         }
  390.                                 } else {
  391.                                         num += 1;
  392.                                 }
  393.                         }
  394.                 } while (minion.GetNext());
  395.         }
  396.        
  397.         return num;
  398. }