kolton

Untitled

Jan 2nd, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. function NTA_KillMonster(classid)
  2. {
  3. var _target;
  4.  
  5. if(NTConfig_AttackSkill[1] < 0)
  6. return false;
  7.  
  8. _target = NTC_FindUnit(NTC_UNIT_MONSTER, classid, 5);
  9.  
  10. if(!_target)
  11. return false;
  12.  
  13. if(_target.IsAttackable())
  14. {
  15. 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));
  16.  
  17. var _attackcount = 0;
  18.  
  19. while(_attackcount < 300 && NTA_IsValidMonster(_target))
  20. {
  21. NTA_Dodge(_target, 15);
  22.  
  23. if(NTA_Attack(_target, (_attackcount%30) == 0) < 2)
  24. break;
  25.  
  26. _attackcount++;
  27. }
  28. }
  29.  
  30. return (_target.hp <= 0 || _target.mode == 0 || _target.mode == 12);
  31. }
  32.  
  33. function NTA_ClearPosition(range, pickitem, safelevel) {
  34. var i, orgx, orgy, monList, ignoreList, target, result,
  35. attackcount = 0;
  36.  
  37. if (NTConfig_AttackSkill[1] < 0 || NTConfig_AttackSkill[3] < 0) {
  38. return false;
  39. }
  40.  
  41. switch (arguments.length) {
  42. case 0:
  43. range = 20;
  44. case 1:
  45. pickitem = false;
  46. case 2:
  47. safelevel = 0;
  48. default:
  49. if (NTConfig_CheckSelfSafe < 0x01 && NTConfig_CheckMercSafe < 0x01) {
  50. safelevel = 0;
  51. }
  52.  
  53. break;
  54. }
  55.  
  56. orgx = me.x;
  57. orgy = me.y;
  58. ignoreList = [];
  59.  
  60. MainLoop : while (attackcount < 300) {
  61. monList = [];
  62. target = NTC_FindUnit(1);
  63.  
  64. if (target) {
  65. do {
  66. if (target.IsAttackable()) {
  67. if (NTConfig_Dodge && attackcount > 0 && GetDistance(me, target) < 8) {
  68. NTA_Dodge(target, 15);
  69. continue MainLoop;
  70. }
  71.  
  72. if (ignoreList.indexOf(target.gid) < 0 && GetDistance(orgx, orgy, target.x, target.y) <= range && (NTC_GetSkillLevel(54) || CheckCollision(me, target, 1))) {
  73. if (NTA_IsValidMonster(target)) {
  74. monList.push(new NTA_MonsterStats(target));
  75. } else {
  76. ignoreList.push(target.gid);
  77. }
  78. }
  79. }
  80. } while (target.GetNext());
  81. }
  82.  
  83. if (!monList.length) {
  84. break;
  85. }
  86.  
  87. monList.sort(NTA_SortMonsters);
  88.  
  89. target = NTC_FindUnit(1, monList[0].gid);
  90.  
  91. if (target && target.IsAttackable()) {
  92. result = NTA_Attack(target, attackcount % 30 === 0);
  93. //Say("!Attacking " + target.classid + " " + target.name);
  94.  
  95. switch (result) {
  96. case 1:
  97. monList.shift();
  98. ignoreList.push(target.gid);
  99. break;
  100. case 2:
  101. case 3:
  102. attackcount += 1;
  103. break;
  104. default:
  105. return false;
  106. }
  107. } else {
  108. monList.shift();
  109. ignoreList.push(target.gid);
  110. }
  111. }
  112.  
  113. if (pickitem && attackcount > 0) {
  114. NTSI_PickItems();
  115. }
  116.  
  117. switch (safelevel) {
  118. case 1:
  119. case 2:
  120. return NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe);
  121. }
  122.  
  123. return true;
  124. }
  125.  
  126. function NTA_MonsterStats(unit) {
  127. this.name = unit.name;
  128. this.x = unit.x;
  129. this.y = unit.y;
  130. this.gid = unit.gid;
  131. this.hp = unit.hp;
  132. this.classid = unit.classid;
  133. this.spectype = unit.spectype;
  134. }
  135.  
  136. function NTA_SortMonsters(unitA, unitB) {
  137. if (GetDistance(me.x, me.y, unitA.x, unitA.y) < GetDistance(me.x, me.y, unitB.x, unitB.y)) {
  138. return -1;
  139. }
  140.  
  141. return 1;
  142. }
  143.  
  144. function NTA_Dodge(target, distance) {
  145. var i, j, coordx, coordy, monster, count,
  146. maxcount = 999,
  147. coords = [],
  148. goodCoords = [],
  149. monList = [],
  150. angles = [45, 90, 135, 180, 225, 270, 305, 360];
  151.  
  152. for (i = 0; i < angles.length; i += 1) {
  153. coordx = Math.round((Math.cos(angles[i] * Math.PI / 180)) * distance + target.x);
  154. coordy = Math.round((Math.sin(angles[i] * Math.PI / 180)) * distance + target.y);
  155.  
  156. if (CheckCollision(me.areaid, coordx, coordy, 1)) {
  157. coords.push([coordx, coordy]);
  158. }
  159. }
  160.  
  161. if (coords.length === 0) { // no valid positions - don't move
  162. return true;
  163. }
  164.  
  165. coords.sort(NTA_SortRooms);
  166.  
  167. monster = GetUnit(1);
  168.  
  169. if (monster) {
  170. do {
  171. if (monster.hp > 0) {
  172. monList.push(new NTA_MonsterStats(target));
  173. }
  174. } while (monster.GetNext());
  175. }
  176.  
  177. for (i = 0; i < coords.length; i += 1) {
  178. count = 0;
  179.  
  180. for (j = 0; j < monList.length; j += 1) {
  181. if (monList[j].hp > 0 && GetDistance(monList[j].x, monList[j].y, coords[i][0], coords[i][1]) < 10) {
  182. count += 1;
  183. }
  184. }
  185.  
  186. if (count < maxcount) {
  187. goodCoords = [coords[i][0], coords[i][1]];
  188. maxcount = count;
  189.  
  190. if (count === 0) {
  191. break;
  192. }
  193. }
  194. }
  195.  
  196. if (goodCoords.length > 0) { // just in case goodCoords is empty (shouldn't happen)
  197. if (Math.abs(me.x - goodCoords[0]) < 3 && Math.abs(me.y - goodCoords[1]) < 3) { // close enough
  198. return true;
  199. }
  200.  
  201. NTM_MoveTo(me.areaid, goodCoords[0], goodCoords[1]);
  202. }
  203.  
  204. return true;
  205. }
  206.  
  207. function NTA_SortRooms(a, b) {
  208. if (GetDistance(me.x, me.y, a[0], a[1]) < GetDistance(me.x, me.y, b[0], b[1])) {
  209. return -1;
  210. }
  211.  
  212. return 1;
  213. }
Add Comment
Please, Sign In to add comment