Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var NTA_DAMAGE_NONE = 0;
- var NTA_DAMAGE_PHYSICAL = 1;
- var NTA_DAMAGE_MAGIC = 2;
- var NTA_DAMAGE_FIRE = 3;
- var NTA_DAMAGE_LIGHTNING = 4;
- var NTA_DAMAGE_COLD = 5;
- var NTA_DAMAGE_POISON = 6;
- var MODE_DEAD = (1<<29)|(1<<12);
- 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);
- var TYPE_NOT_NORMAL = 0xf;
- var _NTA_SkillHand = [];
- var _NTA_SkillDamage = [];
- var _NTA_SkillRange = [];
- var _NTA_SkillDelay = [];
- var _NTA_NovaTick;
- var gidList = [];
- function NTA_FastPick() {
- if (!NTConfig_FastPick || !gidList.length) {
- return;
- }
- var i, item, string, result,
- gidListLength = gidList.length;
- for (i = 0; i < gidListLength; i += 1) {
- if (!gidList[i]) {
- continue;
- }
- item = NTC_GetUnit(NTC_UNIT_ITEM, null, null, gidList[i]);
- if (item && (item.mode === 3 || item.mode === 5)) {
- result = NTSI_CheckItem(item, false);
- if (result && !NTSI_IsLimitedItemInt(item) && NTT_CheckSpace(item.sizex, item.sizey)) {
- string = ("ÿc2Fast Pick ÿc8:: " + NTC_ItemQualityToD2Color[item.quality] + item.name);
- if (NTSI_PickUpItemInt(item)) {
- print(string);
- if (result === 1 && item.itemType !== 4 && (item.itemType < 76 || item.itemType > 81)) {
- DDE.logItem(item);
- }
- }
- }
- }
- }
- gidList = [];
- }
- function NTA_Initialize()
- {
- /* FIX
- if(NTConfig_AttackSkill[1] == -1 || NTConfig_AttackSkill[3] == -1)
- NTA_DetectAttackPattern();
- */
- for(var i = 0 ; i < NTConfig_AttackSkill.length ; i++)
- {
- if(NTConfig_AttackSkill[i] > -1)
- {
- _NTA_SkillHand[i] = NTC_IsLeftSkill(NTConfig_AttackSkill[i]) ? 2 : NTC_HAND_RIGHT;
- _NTA_SkillDamage[i] = NTA_GetDamageType(NTConfig_AttackSkill[i]);
- _NTA_SkillDelay[i] = NTC_GetCastDelay(NTConfig_AttackSkill[i]);
- switch(NTConfig_AttackSkill[i])
- {
- case 0: // Normal Attack
- case 10: // Jab
- case 14: // Power Strike
- case 19: // Impale
- case 24: // Charged Strike
- case 73: // Poison Dagger
- case 96: // Sacrifice
- case 97: // Smite
- case 106: // Zeal
- case 111: // Vengeance
- case 116: // Conversion
- case 126: // Bash
- case 133: // Double Swing
- case 139: // Stun
- case 144: // Concentrate
- case 147: // Frenzy
- case 152: // Berserk
- case 255: // Dragon Talon
- case 260: // Dragon Claw
- case 270: // Dragon Tail
- _NTA_SkillRange[i] = 2;
- _NTA_SkillHand[i] = 1; // bypass shift
- break;
- case 42: // Static
- _NTA_SkillRange[i] = Math.floor((5 + NTC_CheckSkill(42) - 1) * 2/3);
- _NTA_SkillHand[i] = 2;
- break;
- case 49: // lightning
- case 53: // chain lightning
- _NTA_SkillRange[i] = 15;
- break;
- case 44: // Frost Nova
- case 48: // Nova
- _NTA_SkillRange[i] = 7;
- break;
- case 51: // Fire Wall
- _NTA_SkillRange[i] = 10;
- break;
- case 64: // Frozen Orb
- _NTA_SkillRange[i] = 15;
- break;
- case 92: // Poison Nova
- _NTA_SkillRange[i] = 12;
- break;
- case 112: // Blessed Hammer
- _NTA_SkillRange[i] = 3;
- break;
- case 151: // Whirlwind
- _NTA_SkillRange[i] = 8;
- break;
- case 245: // Tornado
- _NTA_SkillRange[i] = 6;
- break;
- default:
- _NTA_SkillRange[i] = 30;
- break;
- }
- }
- }
- }
- function NTA_KillBoss(classid)
- {
- var _target;
- if(NTConfig_AttackSkill[1] < 0)
- return false;
- _target = NTC_GetUnit(NTC_UNIT_MONSTER, classid);
- if(!_target)
- return false;
- //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))
- var _attackcount = 0;
- while (_attackcount < 300 && NTA_IsValidTarget(_target)) {
- if (NTA_Attack(_target, (_attackcount%30) == 0) < 2) {
- break;
- }
- _attackcount++;
- }
- NTA_FastPick();
- return (_target.hp <= 0 || _target.mode == 0 || _target.mode == 12);
- }
- function NTA_ClearPosition(range, spectype, sortFunc) {
- if (arguments.length < 1) {
- range = 25;
- }
- if (arguments.length < 2) {
- spectype = false;
- }
- var orgx, orgy, target, result, monsterList, ignoreList, dodgeList,
- gidAttack = [],
- dodgeIDs = [310, 362],
- attackCount = 0;
- if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) {
- return false;
- }
- orgx = me.x;
- orgy = me.y;
- ignoreList = [];
- while (attackCount < 300) {
- if (attackCount % 5 === 0) { // testing
- monsterList = [];
- dodgeList = [];
- target = NTC_GetUnit(NTC_UNIT_MONSTER, null, MODE_ALIVE);
- if (target) {
- do {
- if (ignoreList.indexOf(target.gid) === -1 && getDistance(orgx, orgy, target.x, target.y) <= range && (!spectype || target.spectype & spectype)) {
- monsterList.push(copyUnit(target));
- }
- if (NTConfig_Dodge && dodgeIDs.indexOf(target.classid) > -1) {
- dodgeList.push(copyUnit(target));
- }
- } while (target.getNext());
- }
- }
- if (monsterList.length === 0) {
- break;
- }
- if (arguments.length >= 3 && typeof(sortFunc) === 'function') {
- monsterList.sort(sortFunc);
- } else {
- monsterList.sort(NTA_SortMonsters);
- }
- target = monsterList[0];
- if (NTA_IsValidTarget(target)) {
- if (me.classid === 1) {
- NTA_Dodge(target, _NTA_SkillRange[1], dodgeList);
- }
- result = NTA_Attack(target, attackCount % 30 === 0);
- switch (result) {
- case 1:
- print("att fail");
- monsterList.shift();
- ignoreList.push(target.gid);
- break;
- case 2:
- case 3:
- if (!target.spectype & 0x7) {
- if(!gidAttack[target.gid]) {
- gidAttack[target.gid] = 0;
- }
- gidAttack[target.gid] += 1;
- if (gidAttack[target.gid] > 8) {
- print("Skipping " + target.name);
- monsterList.shift();
- ignoreList.push(target.gid);
- }
- }
- attackCount += 1;
- if (target.mode === 0 || target.mode === 12) {
- NTA_FastPick();
- }
- break;
- default:
- return false;
- }
- } else {
- monsterList.shift();
- ignoreList.push(target.gid);
- }
- }
- switch (me.classid) {
- case NTC_CHAR_CLASS_PALADIN:
- if (attackCount > 2 && NTConfig_Redemption != false) {
- if (Math.round(me.hp * 100 / me.hpmax) < NTConfig_Redemption[0] || Math.round(me.mp * 100 / me.mpmax) < NTConfig_Redemption[1]) {
- NTC_PutSkill(124, NTC_HAND_RIGHT);
- NTC_PingDelay(1000);
- }
- }
- break;
- }
- if (attackCount > 0) {
- NTSI_PickItems();
- NTT_CleanPotions();
- }
- return true;
- }
- function NTA_Dodge(target, distance, list) { // experimental dodge function
- if (!NTConfig_Dodge) {
- return true;
- }
- me.overhead("Dodge " + target.name);
- var i, j, coordx, coordy, monster, count,
- maxcount = 0,
- coords = [],
- goodCoords = [],
- angles = [45, 90, 135, 180, 225, 270, 305, 360];
- // step 1 - build possible dodge positions based on angles
- for (i = 0; i < angles.length; i = i + 1) {
- coordx = Math.round((Math.cos(angles[i] * Math.PI / 180)) * distance + target.x);
- coordy = Math.round((Math.sin(angles[i] * Math.PI / 180)) * distance + target.y);
- if (getCollision(me.area, coordx, coordy) === 0) {
- coords.push([coordx, coordy]);
- }
- }
- if (coords.length === 0) { // no valid positions - don't move
- return true;
- }
- coords.sort(NTA_SortRoomInt);
- for (i = 0; i < list.length; i += 1) {
- if (list[i].hp > 0 && getDistance(me, list[i]) < 8) {
- maxcount += 1;
- }
- }
- if (maxcount === 0) {
- return true;
- }
- for (i = 0; i < coords.length; i += 1) {
- count = 0;
- for (j = 0; j < list.length; j += 1) {
- if (list[j].hp > 0 && getDistance(list[j].x, list[j].y, coords[i][0], coords[i][1]) < 8) {
- count += 1;
- }
- }
- if (count < maxcount) {
- goodCoords = [coords[i][0], coords[i][1]];
- maxcount = count;
- if (count === 0) {
- break;
- }
- }
- }
- if (goodCoords.length > 0) { // just in case goodCoords is empty (shouldn't happen)
- if (Math.abs(me.x - goodCoords[0]) < 5 && Math.abs(me.y - goodCoords[1]) < 5) { // close enough
- return true;
- }
- NTM_MoveTo(goodCoords[0], goodCoords[1]);
- }
- return true;
- }
- function NTA_ClearRooms(spectype) {
- var i, j, coll, room, rooms;
- room = getRoom();
- if (!room) {
- return false;
- }
- if (arguments.length < 1) {
- spectype = false;
- }
- rooms = [];
- do {
- coll = room.getCollision();
- main: for (i = 0; i < coll.length; i++) {
- for (j = 0; j < coll[i].length; j++) {
- if (coll[i][j] === 0) {
- rooms.push([room.x * 5 + j, room.y * 5 + i]); // sizes are reversed
- break main;
- }
- }
- }
- } while (room.getNext());
- while (rooms.length > 0) {
- rooms.sort(NTA_SortRoomInt);
- room = rooms.shift();
- NTM_MoveTo(room[0], room[1]);
- if (!NTA_ClearRoom(spectype)) {
- return false;
- }
- }
- return true;
- }
- function NTA_ClearRoom(spectype, sortFunc) {
- if (arguments.length < 1) {
- spectype = false;
- }
- var orgx, orgy, target, result, monsterList, ignoreList, dodgeList, room,
- gidAttack = [],
- dodgeIDs = [0, 6, 310, 362],
- attackCount = 0;
- if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) {
- return false;
- }
- room = getRoom(me.x, me.y);
- ignoreList = [];
- while (attackCount < 300) {
- if (attackCount % 5 === 0) { // testing
- monsterList = [];
- dodgeList = [];
- target = NTC_GetUnit(NTC_UNIT_MONSTER, null, MODE_ALIVE);
- if (target) {
- do {
- if (ignoreList.indexOf(target.gid) === -1 && room.unitInRoom(target) && (!spectype || target.spectype & spectype)) {
- monsterList.push(copyUnit(target));
- }
- if (NTConfig_Dodge && dodgeIDs.indexOf(target.classid) > -1) {
- dodgeList.push(copyUnit(target));
- }
- } while (target.getNext());
- }
- }
- if (monsterList.length === 0) {
- break;
- }
- if (arguments.length >= 2 && typeof(sortFunc) === 'function') {
- monsterList.sort(sortFunc);
- } else {
- monsterList.sort(NTA_SortMonsters);
- }
- target = monsterList[0];
- if (NTA_IsValidTarget(target)) {
- if (me.classid === 1) {
- NTA_Dodge(target, _NTA_SkillRange[1], dodgeList);
- }
- result = NTA_Attack(target, attackCount % 30 === 0);
- switch (result) {
- case 1:
- print("att fail");
- monsterList.shift();
- ignoreList.push(target.gid);
- break;
- case 2:
- case 3:
- if (!target.spectype & 0x7) {
- if(!gidAttack[target.gid]) {
- gidAttack[target.gid] = 0;
- }
- gidAttack[target.gid] += 1;
- if (gidAttack[target.gid] > 8) {
- print("Skipping " + target.name);
- monsterList.shift();
- ignoreList.push(target.gid);
- }
- }
- attackCount += 1;
- if (target.mode === 0 || target.mode === 12) {
- NTA_FastPick();
- }
- break;
- default:
- return false;
- }
- } else {
- monsterList.shift();
- ignoreList.push(target.gid);
- }
- }
- switch (me.classid) {
- case NTC_CHAR_CLASS_PALADIN:
- if (attackCount > 2 && NTConfig_Redemption != false) {
- if (Math.round(me.hp * 100 / me.hpmax) < NTConfig_Redemption[0] || Math.round(me.mp * 100 / me.mpmax) < NTConfig_Redemption[1]) {
- NTC_PutSkill(124, NTC_HAND_RIGHT);
- NTC_PingDelay(1000);
- }
- }
- break;
- }
- NTA_OpenChests(20);
- if (attackCount > 0) {
- NTSI_PickItems();
- NTT_CleanPotions();
- }
- return true;
- }
- function NTA_OpenChests(range) {
- var i, unit,
- ids = ["chest", "WeaponRack", "ArmorStand"];
- for (i = 0; i < ids.length; i += 1) {
- unit = getUnit(2, ids[i]);
- if (unit) {
- do {
- if (getDistance(me, unit) <= range && NTC_OpenChest(unit)) {
- NTSI_PickItems();
- }
- } while (unit.getNext());
- }
- }
- }
- function NTA_IsValidTarget(monster, simple)
- {
- if(monster && monster.type == 0 && NT_HostileAction ==2)
- return true;
- if(!monster || monster.type != NTC_UNIT_MONSTER) // added for pking
- return false;
- if(monster.mode == 0 || monster.mode == 12 || monster.hp <= 0)
- return false;
- if(arguments.length < 2)
- simple = false;
- if(!simple)
- {
- if(!monster.name)
- return false;
- switch(monster.name.toLowerCase())
- {
- case "dummy":
- case "an evil force":
- return false;
- }
- switch(monster.classid)
- {
- case 271: // Merc
- case 338:
- case 359:
- case 561:
- case 356: // Decoy
- case 357: // Valkyrie
- case 418: // Shadow Warrior
- case 419: // Shadow Master
- case 363: // Necro Skeleton
- case 364: // Necro Mage
- case 366: // Compelling Orb
- case 406: // Izual's Spirit
- case 266: // Act1: Flavie (Navi) -> Between BloodMoor & ColdPlains
- case 408: // Act4: Hadriel (Malachai) -> Entrance of River of Flames
- case 516: // Act5: Impact point for Catapults (Invisible) -> Frigid Highlands
- case 517: // Act5: Impact point for Catapults (Invisible)
- case 518: // Act5: Impact point for Catapults (Invisible) -> Bloodyfoot Hill
- case 519: // Act5: Impact point for Catapults (Invisible)
- case 522: // Act5: Combatant Barbarian
- case 523: // Act5: Combatant Barbarian
- case 543: // Baal on stairs outside Worldstone Chamber
- case 545: // Baal taunts
- return false;
- }
- if(monster.classid >= 289 && monster.classid <= 292) // Necro's Golem
- return false;
- if((monster.classid >= 326 && monster.classid <= 330) || (monster.classid >= 410 && monster.classid <= 417)) // Traps
- return false;
- if(monster.classid >= 351 && monster.classid <= 353) // Hydra
- return false;
- if(monster.classid >= 420 && monster.classid <= 432) // Druid's friend
- return false;
- }
- if(((monster.classid >= 110 && monster.classid <= 113) || monster.classid == 608) && monster.mode == 8)
- return false;
- if(monster.classid == 68 && monster.mode == 14)
- return false;
- if((monster.classid == 258 || monster.classid == 261) && monster.mode == 14)
- return false;
- if(monster.getStat(172) == 2 || monster.getState(105) == 0)
- return false;
- if(monster.getState(53) || monster.getState(96)) // Conversion, Revive
- return false;
- if((me.classid === 3 || monster.spectype & 0x7) && monster.classid == 306 && getCollision(me.area, monster.x, monster.y) & 0x1) {
- return false;
- }
- return true;
- }
- function NTA_GetDamageType(skillid)
- {
- switch(skillid)
- {
- case 74: // Corpse Explosion
- case 106: // Zeal
- case 107: // Charge
- case 151: // Whirlwind
- case 245: // tornado
- return NTA_DAMAGE_PHYSICAL;
- case 112: // Blessed Hammer
- return NTA_DAMAGE_MAGIC;
- case 47: // Fire Ball
- case 56: // Meteor
- return NTA_DAMAGE_FIRE;
- case 48: // Nova
- case 49: // Lightning
- case 53: // Chain Lightning
- return NTA_DAMAGE_LIGHTNING;
- case 59: // Blizzard
- case 64: // Frozen Orb
- return NTA_DAMAGE_COLD;
- case 92: // Poison Nova
- return NTA_DAMAGE_POISON;
- }
- var _etype;
- if(skillid == 74)
- return NTA_DAMAGE_PHYSICAL;
- if(skillid == 101)
- return NTA_DAMAGE_NONE;
- _etype = getBaseStat(3, parseInt(skillid, 10), 211);
- switch(_etype)
- {
- case 0: return NTA_DAMAGE_PHYSICAL;
- case 1: return NTA_DAMAGE_FIRE;
- case 2: return NTA_DAMAGE_LIGHTNING;
- case 3: return NTA_DAMAGE_MAGIC;
- case 4: return NTA_DAMAGE_COLD;
- case 5: return NTA_DAMAGE_POISON;
- }
- return NTA_DAMAGE_NONE;
- }
- function NTA_GetResistance(enemy, type) {
- if (enemy.type === 0) { // PK optimization
- return 0;
- }
- switch (type) {
- case NTA_DAMAGE_PHYSICAL:
- return enemy.getStat(36);
- case NTA_DAMAGE_MAGIC:
- return enemy.getStat(37);
- case NTA_DAMAGE_FIRE:
- return enemy.getStat(39);
- case NTA_DAMAGE_LIGHTNING:
- return enemy.getStat(41);
- case NTA_DAMAGE_COLD:
- return enemy.getStat(43);
- case NTA_DAMAGE_POISON:
- return enemy.getStat(45);
- }
- return 0;
- }
- function NTA_Attack(target, firstorder)
- {
- me.overhead(target.name + " " + target.classid);
- switch(me.classid)
- {
- case NTC_CHAR_CLASS_AMAZON:
- return NTA_AmazonAttackInt(target, firstorder);
- case NTC_CHAR_CLASS_SORCERESS:
- return NTA_SorceressAttackInt(target, firstorder);
- case NTC_CHAR_CLASS_NECROMANCER:
- return NTA_NecromancerAttackInt(target, firstorder);
- case NTC_CHAR_CLASS_PALADIN:
- return NTA_PaladinAttackInt(target, firstorder);
- case NTC_CHAR_CLASS_BARBARIAN:
- return NTA_BarbarianAttackInt(target, firstorder);
- case NTC_CHAR_CLASS_DRUID:
- return NTA_DruidAttackInt(target, firstorder);
- case NTC_CHAR_CLASS_ASSASSIN:
- return NTA_AssassinAttackInt(target, firstorder);
- }
- return 0;
- }
- function NTA_AmazonAttackInt(target, firstorder)
- {
- var primaryindex;
- if(firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && !me.getState(121)) {
- if(getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4))
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4);
- if(!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target))
- return 2;
- return 3;
- }
- primaryindex = target.spectype & 0x7 ? 1 : 3;
- if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100) {
- if (!NTA_AmazonCastSkillInt(primaryindex, target)) {
- return 2;
- }
- return 3;
- }
- if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) <= 80) {
- if (!NTA_AmazonCastSkillInt(5, target)) {
- return 2;
- }
- return 3;
- }
- if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100 || (NTA_GetResistance(target, NTA_DAMAGE_PHYSICAL) < 100 && primaryindex == 1 && NTC_GetMerc())) {
- if (!NTA_AmazonCastSkillInt(primaryindex, target)) {
- return 2;
- }
- return 3;
- }
- return 1;
- }
- function NTA_AmazonCastSkillInt(index, target) {
- if (NTConfig_AttackSkill[index] === 24) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- return Farcast(target);
- }
- if (!me.getState(121)) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- }
- if (NTConfig_AttackSkill[index+1] > -1) {
- if (getDistance(me, target) > _NTA_SkillRange[index+1] || checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index+1], 0x4);
- }
- return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target);
- }
- if (me.getState(121)) {
- for (var i = 0; i < 200; i++) {
- NTC_Delay(NTC_DELAY_FRAME);
- if (!me.getState(121)) {
- return true;
- }
- }
- }
- return false;
- }
- function Farcast (target) {
- if (NTC_PutSkill(24, NTC_HAND_RIGHT)) {
- var i, n, mode;
- me.castUnit(24, NTC_HAND_RIGHT, target, true);
- for(n = 0; n < 4; n = n + 1) {
- NTC_Delay(NTC_DELAY_FRAME);
- mode = me.mode;
- if (mode === 7 || mode === 8 || (mode >= 10 && mode <= 16) || mode === 18) {
- NTC_Delay(NTC_DELAY_FRAME);
- break;
- }
- }
- if (n < 4) {
- for (i = 0; i < 100; i = i + 1) {
- NTC_Delay(20);
- if (me.mode !== mode) {
- break;
- }
- }
- return true;
- }
- }
- return false;
- }
- function NTA_SorceressAttackInt(target, firstorder)
- {
- if (me.gametype > 0 && !NTC_GetMerc() && target.type === 1) {
- NTTMGR_VisitTown();
- }
- var _primaryindex;
- if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && !me.getState(121)) {
- if (getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4)) {
- if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4)) {
- return 2;
- }
- }
- if (!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) {
- return 2;
- }
- return 3;
- }
- 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))
- {
- var _staticlevel = NTC_CheckSkill(42);
- if(_staticlevel > 0)
- {
- var _staticrange;
- var _castx, _casty;
- _staticrange = Math.floor((5+_staticlevel-1)*2/3);
- if(getDistance(me, target) > _staticrange || checkCollision(me, target, 0x4))
- NTA_GetToOptimalPosition(target, _staticrange, 0x4);
- if(!NTC_DoCast(42, NTC_HAND_RIGHT, me.x, me.y))
- return 2;
- return 3;
- }
- }
- _primaryindex = (target.spectype&0x7) ? 1 : 3;
- if(!NTA_SorceressCastSkillInt(_primaryindex, target))
- return 1;
- else
- return 3;
- }
- function NTA_SorceressCastSkillInt(index, target)
- {
- if(!me.getState(121))
- {
- if(NTA_GetResistance(target, _NTA_SkillDamage[index]) < 100)
- {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4)) {
- return false;
- }
- }
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- }
- else if(NTConfig_AttackSkill[5] > -1)
- {
- if (getDistance(me, target) > _NTA_SkillRange[5] || checkCollision(me, target, 0x4)) {
- if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[5], 0x4)) {
- return false
- }
- }
- return NTC_DoCast(NTConfig_AttackSkill[5], _NTA_SkillHand[5], target);
- }
- }
- if(NTConfig_AttackSkill[index+1] > -1)
- {
- if(NTA_GetResistance(target, _NTA_SkillDamage[index+1]) < 100)
- {
- if (getDistance(me, target) > _NTA_SkillRange[index+1] || checkCollision(me, target, 0x4)) {
- if (NTA_GetToOptimalPosition(target, _NTA_SkillRange[index+1], 0x4)) {
- return false;
- }
- }
- return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target);
- }
- else if(NTConfig_AttackSkill[6] > -1)
- {
- if (getDistance(me, target) > _NTA_SkillRange[6] || checkCollision(me, target, 0x4)) {
- if (NTA_GetToOptimalPosition(target, _NTA_SkillRange[6], 0x4)) {
- return false;
- }
- }
- return NTC_DoCast(NTConfig_AttackSkill[6], _NTA_SkillHand[6], target);
- }
- }
- if(me.getState(121))
- {
- for(var i = 0; i < 200; i++)
- {
- NTC_Delay(NTC_DELAY_FRAME);
- if(!me.getState(121))
- return true;
- }
- }
- return false;
- }
- function NTA_NecromancerAttackInt(target, firstorder) {
- var _primaryindex,
- currentLife = me.hp;
- /*if (NTTMGR_CheckCurse(NTConfig_CheckSelfSafe & 0x10, NTConfig_CheckMercSafe & 0x10)) {
- if (!NTTMGR_VisitTown()) {
- return 0;
- }
- }*/
- //NTTMGR_CheckSafe(false, 0x01); //instant merc revive
- if (!me.getState(14)) { // bone armor recast
- NTC_DoCast(68, NTC_HAND_RIGHT);
- }
- if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && me.GetSkillStatus(NTConfig_AttackSkill[0]) !== 8) {
- if (GetDistance(me, target) > _NTA_SkillRange[0] || !CheckCollision(me, target, 4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4);
- }
- if (!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) {
- return 2;
- }
- return 3;
- }
- if (NTConfig_Curse[2] > 0 && NTConfig_CurseList.indexOf(target.classid) > -1 && NTA_IsCursable(target)) {
- if (!target.getState(_NTA_CurseState[2])) {
- if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4)) {
- NTA_GetToOptimalPosition(target, 25, 0x4);
- }
- if (!NTC_DoCast(NTConfig_Curse[2], NTC_HAND_RIGHT, target)) {
- return 2;
- }
- return 3;
- }
- } else if (NTConfig_Curse[1] > 0 && NTA_IsCursable(target) && !(target.spectype & 0x0A)) {
- if (!target.getState(_NTA_CurseState[1])) {
- if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4)) {
- NTA_GetToOptimalPosition(target, 25, 0x4);
- }
- if (!NTC_DoCast(NTConfig_Curse[1], NTC_HAND_RIGHT, target)) {
- return 2;
- }
- return 3;
- }
- } else if (NTConfig_Curse[0] > 0 && NTA_IsCursable(target) && target.spectype & 0x0A) {
- if (!target.getState(_NTA_CurseState[0])) {
- if (GetDistance(me, target) > 25 || !CheckCollision(me, target, 4)) {
- NTA_GetToOptimalPosition(target, 25, 0x4);
- }
- if (!NTC_DoCast(NTConfig_Curse[0], NTC_HAND_RIGHT, target)) {
- return 2;
- }
- return 3;
- }
- }
- _primaryindex = (target.spectype & 0x7) ? 1 : 3;
- if (NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100) {
- if (NTConfig_TeleStomp) {
- NTM_GetCloserInt(target);
- }
- if (!NTA_NecromancerCastSkillInt(_primaryindex, target)) {
- return 2;
- }
- /*if (NTConfig_ActiveSummon) {
- NTA_RaiseArmy();
- }
- NTA_ExplodeCorpses(target);*/
- return 3;
- }
- if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) < 100) {
- if (!NTA_NecromancerCastSkillInt(5, target)) {
- return 2;
- }
- /*if (NTConfig_ActiveSummon) {
- NTA_RaiseArmy();
- }
- NTA_ExplodeCorpses(target);*/
- return 3;
- }
- if (NTConfig_TeleStomp && NTC_GetMerc() && NTA_GetResistance(target, NTA_DAMAGE_PHYSICAL) < 100) {
- NTM_GetCloserInt(target);
- if (target.mode === 12) {
- return 2;
- }
- NTC_Delay(300);
- /*if (NTConfig_ActiveSummon) {
- NTA_RaiseArmy();
- }
- NTA_ExplodeCorpses(target);*/
- return 3;
- }
- return 1;
- }
- function NTA_NecromancerCastSkillInt(index, target) {
- var i, _pos;
- if (NTConfig_AttackSkill[index] === 92) {
- if (!_NTA_NovaTick || GetTickCount() > _NTA_NovaTick + NTConfig_PoisonNovaDelay) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || !checkCollision(me, target, 4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- _NTA_NovaTick = getTickCount();
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- }
- } else if (NTConfig_AttackSkill[index] === SUMMONER) { // summoners, fishymancers, overlords... any necro that doesn't use direct attacks
- if (getDistance(me, target) > _NTA_SkillRange[index] || !checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- NTC_Delay(300);
- return true;
- } else if (!me.getState(121)) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || !checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- }
- if (NTConfig_AttackSkill[index+1] > -1) {
- if (getDistance(me, target) > _NTA_SkillRange[index + 1] || !checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index + 1], 0x4);
- }
- return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target);
- }
- for (i = 0; i < 25; i+= 1) {
- NTC_Delay(NTC_DELAY_FRAME);
- if (!me.getState(121) && (GetTickCount() > _NTA_NovaTick + NTConfig_PoisonNovaDelay || !_NTA_NovaTick)) {
- break;
- }
- }
- return false;
- }
- function NTA_RaiseArmy() {
- if (me.classid !== 2) {
- return false;
- }
- var corpse, corpseList, skill, maxSkeletons, maxMages, maxRevives;
- if (NTConfig_SkeletonArmy === 'max') {
- skill = NTC_CheckSkill(70);
- maxSkeletons = skill < 4 ? skill : (Math.floor(skill / 3) + 2);
- } else {
- maxSkeletons = NTConfig_SkeletonArmy || 0;
- }
- if (NTConfig_MageArmy === 'max') {
- skill = NTC_CheckSkill(80);
- maxMages = skill < 4 ? skill : (Math.floor(skill / 3) + 2);
- } else {
- maxMages = NTConfig_MageArmy || 0;
- }
- if (NTConfig_ReviveArmy === 'max') {
- skill = NTC_CheckSkill(95);
- maxRevives = skill;
- } else {
- maxRevives = NTConfig_ReviveArmy || 0;
- }
- corpse = NTC_GetUnit(1, null, MODE_DEAD);
- corpseList = [];
- if (corpse) {
- do {
- if (getDistance(me, corpse) <= 25 && !checkCollision(me, corpse, 0x4)) {
- corpseList.push(copyUnit(corpse));
- }
- } while (corpse.getNext());
- }
- MainLoop : while (corpseList.length > 0) {
- corpse = corpseList.shift();
- if (NTA_IsValidCorpse(corpse)) {
- if (me.getMinionCount(4) < maxSkeletons) {
- if (!NTC_DoCast(70, NTC_HAND_RIGHT, corpse)) {
- return false;
- }
- NTC_Delay(200);
- } else if (me.getMinionCount(5) < maxMages) {
- if (!NTC_DoCast(80, NTC_HAND_RIGHT, corpse)) {
- return false;
- }
- NTC_Delay(200);
- } else if (me.getMinionCount(6) < maxRevives) {
- if (corpse.spectype & 0x7) {
- continue MainLoop;
- }
- if (!NTC_DoCast(95, NTC_HAND_RIGHT, corpse)) {
- return false;
- }
- NTC_Delay(200);
- } else {
- break MainLoop;
- }
- }
- }
- return true;
- }
- function NTA_GetMinionCount(type) { // 0 - skeleton, 1 - mage, 2 - revive
- var minion,
- num = 0;
- switch (type) {
- case 0:
- minion = NTC_GetUnit(NTC_UNIT_MONSTER, 363);
- break;
- case 1:
- minion = NTC_GetUnit(NTC_UNIT_MONSTER, 364);
- break;
- case 2:
- minion = NTC_GetUnit(NTC_UNIT_MONSTER);
- break;
- }
- if (minion) {
- do {
- if (NTC_CheckOwner(minion) && minion.hp > 0) {
- if (type === 2) {
- if (minion.getState(96)) {
- num += 1;
- }
- } else {
- num += 1;
- }
- }
- } while (minion.getNext());
- }
- return num;
- }
- function NTA_IsValidCorpse(unit) {
- switch (unit.classid) { // muddys
- case 151: // An evil force
- case 156: // Andariel
- case 159: // An evil force
- case 180: // Sand Maggot Young
- case 181: // Rock Worm Young
- case 182: // Devourer Young
- case 183: // Giant Lamprey Young
- case 184: // World Killer Young
- case 190: // Sand Maggot Egg
- case 191: // Rock Worm Egg
- case 192: // Devourer Egg
- case 193: // Giant Lamprey Egg
- case 194: // World Killer Egg
- case 206: // Fould Crow Nest
- case 207: // Blood Hawk Nest
- case 208: // Black Vulture Nest
- case 209: // Cloud Stalker Nest
- case 221: // Duriel
- case 227: // Maggot
- case 228: // Mummy Generator
- case 234: // Flying Scimitar
- case 242: // Mephisto
- case 243: // Diablo
- case 250: // Summoner
- case 258: // Water Watcher Limb
- case 259: // River Stalker Limb
- case 260: // Sygain Watcher Limb
- case 261: // Water Watcher Head
- case 262: // River Stalker Head
- case 263: // Sygain Watcher Head
- case 267: // Blood Raven
- case 269: // An evil force
- case 270: // Rogue Scout (== Merc)
- case 273: // Gargoyle Trap
- case 289: // Clay Golem
- case 290: // Blood Golem
- case 291: // Iron Golem
- case 292: // Fire Golem
- case 301: // Flesh Beast
- case 302: // Stygian Dog
- case 303: // Grotesque Wyrm
- case 318: // An Evil Force
- case 319: // An Evil Force
- case 326: // A Trap
- case 327: // A Trap
- case 328: // A Trap
- case 329: // A Trap
- case 330: // A Trap
- case 334: // Sucker Nest
- case 335: // Fleeder Nest
- case 336: // Blood Hook Nest
- case 337: // Blood Wing Nest
- case 338: // Act 2 guard (== Merc)
- case 348: // Turret
- case 349: // Turret
- case 350: // Turret
- case 351: // Hydra
- case 352: // Hydra
- case 353: // Hydra
- case 354: // A Trap
- case 356: // Dopplezon
- case 357: // Valkyrie
- case 359: // Iron Wolf (== Merc)
- case 363: // Necro Skeleton
- case 364: // Necro Skeletal Mage
- case 366: // Compelling Orb
- case 369: // A Trap
- case 371: // Lightning Spire
- case 372: // Fire Tower
- case 403: // Traped Soul
- case 404: // Traped Soul
- case 406: // Izual
- case 410: // Wake Of Destruction
- case 411: // Charged Bolt Sentry
- case 412: // Lightning Sentry
- case 413: // Blade Creeper
- case 414: // Invisible Pet
- case 415: // Inferno Sentry
- case 416: // Death Sentry
- case 417: // Shadow Warrior
- case 418: // Shadow Master
- case 419: // Druid Hawk
- case 420: // Druid Spirit Wolf
- case 421: // Druid Fenris
- case 422: // Spirit of Barbs
- case 423: // Heart Of Wolverine
- case 424: // Oak Sage
- case 425: // Druid Plague Poppy
- case 426: // Druid Cycle of Life
- case 427: // Vine Creature
- case 428: // Druid Bear
- case 429: // Eagle
- case 430: // Wolf
- case 431: // Bear
- case 432: // Barricaded Door
- case 433: // Barricaded Door
- case 434: // Prison Door
- case 435: // Barricaded Door
- case 461: // Fanatic Minion
- case 462: // Beserk Slayer
- case 463: // Consumed Fire Boar
- case 464: // Consumed Ice Boar
- case 465: // Frenzied Hell Spawn
- case 466: // Frenzied Hell Spawn
- case 467: // Insane Hell Spawn
- case 468: // Insane Ice Spawn
- case 497: // Catapult
- case 498: // Catapult
- case 499: // Catapult
- case 500: // Catapult
- case 501: // Frozen Horror 1
- case 502: // Frozen Horror 2
- case 503: // Frozen Horror 3
- case 504: // Frozen Horror 4
- case 505: // Frozen Horror 5
- case 516: // Catapult
- case 517: // Catapult
- case 518: // Catapult
- case 519: // Catapult
- case 522: // Barbarian Fighter
- case 523: // Barbarian Fighter
- case 524: // Barricade Wall Right
- case 525: // Barricade Wall Left
- case 526: // Nihlatak
- case 528: // Evil Hut
- case 535: // Barbarian Fighter
- case 536: // Barbarian Fighter
- case 537: // Ancient Statue 1
- case 538: // Ancient Statue 2
- case 539: // Ancient Statue 3
- case 540: // Ancient Barbarian 1
- case 541: // Ancient Barbarian 2
- case 542: // Ancient Barbarian 3
- case 543: // Baal Throne
- case 544: // Baal Crab
- case 545: // Baal Taunt
- case 551: // Pain Worm
- case 552: // Pain Worm
- case 553: // Pain Worm
- case 554: // Pain Worm
- case 555: // Pain Worm
- case 556: // Bunny
- case 559: // Baal Crab to Stairs
- case 560: // Hireling
- case 561: // Hireling
- case 562: // Baal Tentacle
- case 563: // Baal Tentacle
- case 564: // Baal Tentacle
- case 565: // Baal Tentacle
- case 566: // Baal Tentacle
- case 567: // Injured Barbarian
- case 568: // Injured Barbarian
- case 569: // Injured Barbarian
- case 570: // Baal Crab Clone
- case 571: // Baals Minions
- case 572: // Baals Minions
- case 573: // Baals Minions
- case 574: // Worldstone Effect
- case 662: // Flayer Shaman
- return false;
- }
- if(!unit.getState(107) // Shattered
- && !unit.getState(104) // Corpse Explosion
- && !unit.getState(1) // Freeze
- && !unit.getState(118) // Already Looted/Unlootable
- && !unit.getState(99) // Redeemed
- && !unit.getState(2) // Freezed
- && !unit.getState(96) // Revived
- && (unit.hp <= 0 || unit.mode === 0 || unit.mode === 12)) { // Dead
- return true;
- }
- return false;
- }
- function NTA_PaladinAttackInt(target, firstorder)
- {
- if (!me.getState(101)) {
- NTC_DoCast(117, NTC_HAND_RIGHT); // Holy Shield Recast
- }
- var _primaryindex;
- if(firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100)
- {
- if(getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4))
- NTA_MoveCloseInt(target, _NTA_SkillRange[0]);
- if(!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target))
- return 2;
- return 3;
- }
- _primaryindex = (target.spectype & 0x7) ? 1 : 3;
- if(NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100)
- {
- if(_NTA_SkillRange[_primaryindex] < 4 && !NTA_IsValidSpot(target.x, target.y))
- return 1;
- if(!NTA_PaladinCastSkillInt(_primaryindex, target))
- return 2;
- return 3;
- }
- if(NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) < 100)
- {
- if(_NTA_SkillRange[5] < 4 && !NTA_IsValidSpot(target.x, target.y))
- return 1;
- if(!NTA_PaladinCastSkillInt(5, target))
- return 2;
- return 3;
- }
- return 1;
- }
- function NTA_PaladinCastSkillInt(index, target) {
- if (NTConfig_AttackSkill[index] === 112) {
- if (!NTA_CheckHammerPosition(target)) {
- NTA_GetHammerPosition(target);
- }
- } else {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- }
- if (NTConfig_AttackSkill[index+1] > -1) {
- NTC_PutSkill(NTConfig_AttackSkill[index+1], NTC_HAND_RIGHT);
- }
- if (target.hp <= 0 || target.mode === 0 || target.mode === 12) {
- return true;
- }
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- }
- function NTA_CheckHammerPosition(unit) {
- var i,
- offsets = [[3, 2], [3, 1], [-3, 3], [0, 3], [-3, 2], [-4, 0]];
- for (i = 0; i < offsets.length; i += 1) {
- if (Math.abs(unit.x + offsets[i][0] - me.x) < 1 && Math.abs(unit.y + offsets[i][1] - me.y) < 1) {
- return true;
- }
- }
- return false;
- }
- function NTA_GetHammerPosition(unit) {
- var i,
- positions = [],
- offsets = [[3, 2], [3, 1], [-3, 3], [0, 3], [-3, 2], [-4, 0]];
- for (i = 0; i < offsets.length; i += 1) {
- if (NTA_IsValidSpot(unit.x + offsets[i][0], unit.y + offsets[i][1])) {
- return NTM_MoveTo(unit.x + offsets[i][0], unit.y + offsets[i][1]);
- }
- }
- return false;
- }
- function NTA_BarbarianAttackInt(target, firstorder)
- {
- var primaryindex;
- if(firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100 && !me.getState(121)) {
- if(getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4))
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4);
- if(!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target))
- return 2;
- return 3;
- }
- primaryindex = target.spectype & 0x7 ? 1 : 3;
- if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100) {
- if (!NTA_BarbarianCastSkillInt(primaryindex, target)) {
- return 2;
- }
- return 3;
- }
- if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) <= 80) {
- if (!NTA_BarbarianCastSkillInt(5, target)) {
- return 2;
- }
- return 3;
- }
- if (NTA_GetResistance(target, _NTA_SkillDamage[primaryindex]) < 100 || (NTA_GetResistance(target, NTA_DAMAGE_PHYSICAL) < 100 && primaryindex == 1 && NTC_GetMerc())) {
- if (!NTA_BarbarianCastSkillInt(primaryindex, target)) {
- return 2;
- }
- return 3;
- }
- return 1;
- }
- function NTA_BarbarianCastSkillInt(index, target) {
- if (NTConfig_AttackSkill[index] === 24) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- return Farcast(target);
- }
- if (!me.getState(121)) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4);
- }
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- }
- if (NTConfig_AttackSkill[index+1] > -1) {
- if (getDistance(me, target) > _NTA_SkillRange[index+1] || checkCollision(me, target, 0x4)) {
- NTA_GetToOptimalPosition(target, _NTA_SkillRange[index+1], 0x4);
- }
- return NTC_DoCast(NTConfig_AttackSkill[index+1], _NTA_SkillHand[index+1], target);
- }
- if (me.getState(121)) {
- for (var i = 0; i < 200; i++) {
- NTC_Delay(NTC_DELAY_FRAME);
- if (!me.getState(121)) {
- return true;
- }
- }
- }
- return false;
- }
- function NTA_DruidAttackInt(target, firstorder)
- {
- if (!me.getState(144)) {
- NTC_DoCast(250, NTC_HAND_RIGHT); // Hurricane Recast
- }
- if (!me.getState(151)) {
- NTC_DoCast(235, NTC_HAND_RIGHT); // Cyclone Armor Recast
- }
- if (!me.getState(149)) {
- NTC_DoCast(226, NTC_HAND_RIGHT); // Oak Sage Recast
- }
- var _primaryindex;
- if (firstorder && NTConfig_AttackSkill[0] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[0]) < 100) {
- if (getDistance(me, target) > _NTA_SkillRange[0] || checkCollision(me, target, 0x4)) {
- if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[0], 0x4)) {
- return false;
- }
- }
- if (!NTC_DoCast(NTConfig_AttackSkill[0], _NTA_SkillHand[0], target)) {
- return 2;
- }
- return 3;
- }
- _primaryindex = (target.spectype & 0x7) ? 1 : 3;
- if (NTA_GetResistance(target, _NTA_SkillDamage[_primaryindex]) < 100 || NTC_CheckSkill(250) && NTA_GetResistance(target, NTA_DAMAGE_COLD) < 100) { // hurricane optimization
- if (!NTA_DruidCastSkillInt(_primaryindex, target)) {
- return 2;
- }
- return 3;
- }
- if (NTConfig_AttackSkill[5] > -1 && NTA_GetResistance(target, _NTA_SkillDamage[5]) < 100) {
- if (!NTA_DruidCastSkillInt(5, target)) {
- return 2;
- }
- return 3;
- }
- return 1;
- }
- function NTA_DruidCastSkillInt(index, target) {
- if (NTConfig_AttackSkill[index] === 245) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- NTA_GetTornadoPosition(target);
- }
- if (getDistance(me, target) <= _NTA_SkillRange[index] && !checkCollision(me, target, 0x4)) {
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- } else {
- return false;
- }
- } else if (!me.getState(121)) {
- if (getDistance(me, target) > _NTA_SkillRange[index] || checkCollision(me, target, 0x4)) {
- if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[index], 0x4)) {
- return false;
- }
- }
- return NTC_DoCast(NTConfig_AttackSkill[index], _NTA_SkillHand[index], target);
- }
- if (NTConfig_AttackSkill[index + 1] > -1) {
- if (getDistance(me, target) > _NTA_SkillRange[index + 1] || checkCollision(me, target, 0x4)) {
- if (!NTA_GetToOptimalPosition(target, _NTA_SkillRange[index + 1], 0x4)) {
- return false;
- }
- }
- return NTC_DoCast(NTConfig_AttackSkill[index + 1], _NTA_SkillHand[index + 1], target);
- }
- if (me.getState(121)) {
- for (var i = 0; i < 200; i += 1) {
- NTC_Delay(NTC_DELAY_FRAME);
- if (!me.getState(121)) {
- return true;
- }
- }
- }
- return false;
- }
- function NTA_GetTornadoPosition(unit) {
- var i,
- positions = [],
- offsets = [[4,4], [4, -4], [-4, 0], [0, 4]];
- for (i = 0; i < offsets.length; i += 1) {
- if (NTA_IsValidSpot(unit.x + offsets[i][0], unit.y + offsets[i][1])) {
- positions.push([unit.x + offsets[i][0], unit.y + offsets[i][1]]);
- }
- }
- positions.sort(NTA_SortRoomInt);
- for (i = 0; i < positions.length; i += 1) { // lazy style!
- NTM_MoveTo(positions[i][0], positions[i][1]);
- if (!checkCollision(me, unit, 0x4)) {
- return true;
- }
- }
- return false;
- }
- function NTA_AssassinAttackInt(target, boss, maxattacks)
- {
- return false;
- }
- function NTA_MoveCloseInt(target, maxrange)
- {
- var _dist = parseInt(getDistance(me, target));
- if(_dist > maxrange)
- {
- var _destx, _desty;
- _destx = me.x + Math.round((_dist-maxrange)*(target.x-me.x) / _dist);
- _desty = me.y + Math.round((_dist-maxrange)*(target.y-me.y) / _dist);
- NTM_MoveTo(_destx, _desty);
- /*if(getDistance(me, target) > maxrange)
- NTM_MoveTo(target.x,target.y);*/
- }
- return true;
- }
- function NTA_SortRoomInt(a, b)
- {
- if(getDistance(me.x, me.y, a[0], a[1]) < getDistance(me.x, me.y, b[0], b[1]))
- return -1;
- return 1;
- }
- function NTA_SortMonsters(unitA, unitB) {
- 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];
- if (monID.indexOf(unitA.classid) > -1) { // priority monsters
- return -1;
- } else if (!checkCollision(me, unitA, 0x4) && getDistance(me, unitA) < getDistance(me, unitB)) { // closest visible target
- return -1;
- }
- return 1;
- }
- function NTA_IsValidSpot(x, y) {
- if (getCollision(me.area, x, y) & 0x1) {
- return false;
- }
- return true;
- }
- function NTA_GetToOptimalPosition(target, distance, coll) {
- var n, i, j, cx, cy, t, room, map,
- coords = [],
- goodCoords = [],
- angles = [0, 45, 90, 135, 180, 225, 270, 305];
- t = getTickCount();
- room = getRoom(target.x, target.y);
- if (!room) {
- return false;
- }
- map = room.getCollision();
- // discard invalid final spots
- for (n = 0; n < 3; n += 1) {
- if (n > 0) {
- distance = Math.round(distance / 2);
- }
- for (i = 0; i < angles.length; i += 1) {
- cx = Math.round((Math.cos(angles[i] * Math.PI / 180)) * distance + target.x);
- cy = Math.round((Math.sin(angles[i] * Math.PI / 180)) * distance + target.y);
- if (NTA_IsValidSpot(cx, cy)) {
- coords.push([cx, cy, angles[i]]); // push angles to be sorted
- }
- }
- if (coords.length > 0) {
- coords.sort(NTA_SortRoomInt); // sort angles by final spot distance
- } else { // no good final spots
- return false;
- }
- MainLoop: for (i = 0; i < coords.length; i += 1) { // sorted angles are coords[i][2]
- for (j = 1; j < distance; j += 1) {
- cx = Math.round((Math.cos(coords[i][2] * Math.PI / 180)) * j + target.x);
- cy = Math.round((Math.sin(coords[i][2] * Math.PI / 180)) * j + target.y);
- //if (getCollision(me.area, cx, cy) & coll) {
- if (getCollisionEx(room.x * 5, room.y * 5, map, cx, cy) & coll) {
- continue MainLoop; // skip if path is blocked
- }
- }
- if (NTA_IsValidSpot(cx, cy)) { // just in case
- print(getTickCount() - t);
- NTM_MoveTo(cx, cy, 0); // first good spot is the closest
- if (!checkCollision(me, target, coll)) {
- return true;
- }
- }
- }
- }
- return false;
- }
- function getCollisionEx(roomx, roomy, map, x, y) {
- for (var i = 0; i < map.length; i += 1) {
- for (var j = 0; j < map[i].length; j += 1) {
- if (roomx + j === x && roomy + i === y) {
- return map[i][j];
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement