Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function NTA_KillMonster(classid)
- {
- var _target;
- if(NTConfig_AttackSkill[1] < 0)
- return false;
- _target = NTC_FindUnit(NTC_UNIT_MONSTER, classid, 5);
- if(!_target)
- return false;
- if(_target.IsAttackable())
- {
- Print("ÿc4Name ÿc0" + _target.name + " ÿc4Fire resist ÿc0" + _target.GetStat(39) + " ÿc4Cold resist ÿc0" + _target.GetStat(41) + " ÿc4Lightning resist ÿc0" + _target.GetStat(43) + " ÿc4Poison resist ÿc0" + _target.GetStat(45));
- var _attackcount = 0;
- while(_attackcount < 300 && NTA_IsValidMonster(_target))
- {
- NTA_Dodge(_target, 15);
- if(NTA_Attack(_target, (_attackcount%30) == 0) < 2)
- break;
- _attackcount++;
- }
- }
- return (_target.hp <= 0 || _target.mode == 0 || _target.mode == 12);
- }
- function NTA_ClearPosition(range, pickitem, safelevel) {
- var i, orgx, orgy, monList, ignoreList, target, result,
- attackcount = 0;
- if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) {
- return false;
- }
- switch (arguments.length) {
- case 0:
- range = 20;
- case 1:
- pickitem = false;
- case 2:
- safelevel = 0;
- default:
- if (NTConfig_CheckSelfSafe < 0x01 && NTConfig_CheckMercSafe < 0x01) {
- safelevel = 0;
- }
- break;
- }
- orgx = me.x;
- orgy = me.y;
- ignoreList = [];
- MainLoop : while (attackcount < 300) {
- monList = [];
- target = NTC_FindUnit(1);
- if (target) {
- do {
- if (target.IsAttackable()) {
- if (NTConfig_Dodge && attackcount > 0 && GetDistance(me, target) < 8) {
- NTA_Dodge(target, 15);
- continue MainLoop;
- }
- if (ignoreList.indexOf(target.gid) < 0 && GetDistance(orgx, orgy, target.x, target.y) <= range && (NTC_GetSkillLevel(54) || CheckCollision(me, target, 1))) {
- if (NTA_IsValidMonster(target)) {
- monList.push(new NTA_MonsterStats(target));
- } else {
- ignoreList.push(target.gid);
- }
- }
- }
- } while (target.GetNext());
- }
- if (!monList.length) {
- break;
- }
- monList.sort(NTA_SortMonsters);
- target = NTC_FindUnit(1, monList[0].gid);
- if (target && target.IsAttackable()) {
- result = NTA_Attack(target, attackcount % 30 === 0);
- //Say("!Attacking " + target.classid + " " + target.name);
- switch (result) {
- case 1:
- monList.shift();
- ignoreList.push(target.gid);
- break;
- case 2:
- case 3:
- attackcount += 1;
- break;
- default:
- return false;
- }
- } else {
- monList.shift();
- ignoreList.push(target.gid);
- }
- }
- if (pickitem && attackcount > 0) {
- NTSI_PickItems();
- }
- switch (safelevel) {
- case 1:
- case 2:
- return NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe);
- }
- return true;
- }
- function NTA_MonsterStats(unit) {
- this.name = unit.name;
- this.x = unit.x;
- this.y = unit.y;
- this.gid = unit.gid;
- this.hp = unit.hp;
- this.classid = unit.classid;
- this.spectype = unit.spectype;
- }
- function NTA_SortMonsters(unitA, unitB) {
- if (GetDistance(me.x, me.y, unitA.x, unitA.y) < GetDistance(me.x, me.y, unitB.x, unitB.y)) {
- return -1;
- }
- return 1;
- }
- function NTA_Dodge(target, distance) {
- var i, j, coordx, coordy, monster, count,
- maxcount = 999,
- coords = [],
- goodCoords = [],
- monList = [],
- angles = [45, 90, 135, 180, 225, 270, 305, 360];
- for (i = 0; i < angles.length; 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 (CheckCollision(me.areaid, coordx, coordy, 1)) {
- coords.push([coordx, coordy]);
- }
- }
- if (coords.length === 0) { // no valid positions - don't move
- return true;
- }
- coords.sort(NTA_SortRooms);
- monster = GetUnit(1);
- if (monster) {
- do {
- if (monster.hp > 0) {
- monList.push(new NTA_MonsterStats(target));
- }
- } while (monster.GetNext());
- }
- for (i = 0; i < coords.length; i += 1) {
- count = 0;
- for (j = 0; j < monList.length; j += 1) {
- if (monList[j].hp > 0 && GetDistance(monList[j].x, monList[j].y, coords[i][0], coords[i][1]) < 10) {
- 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]) < 3 && Math.abs(me.y - goodCoords[1]) < 3) { // close enough
- return true;
- }
- NTM_MoveTo(me.areaid, goodCoords[0], goodCoords[1]);
- }
- return true;
- }
- function NTA_SortRooms(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;
- }
Add Comment
Please, Sign In to add comment