Advertisement
DraculaxAOE

NTSnagIt.ntl

Nov 5th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.76 KB | None | 0 0
  1. var debugSnagit = false;
  2. var _location;
  3. var _NTSI_IgnoredList = new Array(
  4. 88, //Wirt's Leg
  5. 526, // Arrows quiver
  6. 528, // Bolts quiver
  7. //543, // Keys
  8. 518, // Tome of Town Portal
  9. 519, // Tome of Identify
  10. //529, // Scroll of Town Portal
  11. //530, // Scroll of Identify
  12. 514, // Antidote potion
  13. 513, // Stamina potion
  14. 517, // Thawing potion
  15. 80, // Rancid Gas Pot
  16. 81, // Oil Potion
  17. 82, // Choking Gas Pot
  18. 83, // Exploding Pot
  19. 84, // Strangling Gas
  20. 85); // Fulminating Pot
  21.  
  22.  
  23. var _NTSI_BeltSize;
  24.  
  25. _IgnoredItems = new Array();
  26.  
  27. var isBusyPickIt = false;
  28.  
  29. var ignoredGidz = [];
  30.  
  31. //function NTSI_ClearIgnoredItems() { _IgnoredList = new Array(); }
  32.  
  33. function NTSI_ClearIgnoredItems() {
  34. _IgnoredItems = [];
  35. }
  36.  
  37. function NTSI_LoadNIPFiles(filepath) {
  38. for(var i = 0 ; i < NTConfig_NIPFilePath.length ; i++) {
  39. if (!NTIPOpenFile(filepath + "/" + NTConfig_NIPFilePath[i])) {
  40. return false;
  41. }
  42. }
  43.  
  44. _NTSI_BeltSize = NTC_GetBeltSize();
  45. return true;
  46. }
  47.  
  48. function NTSI_PickItems() {
  49. //Check for Busy State
  50. if(isBusyPickIt){
  51. // Print(COLOR_1 + "BUSY PICK IT!");
  52. return;
  53. }
  54. else{
  55. // Print(COLOR_2 + "PICK IT NOW!");
  56. isBusyPickIt = true;
  57. }
  58.  
  59. var i, _mode;
  60.  
  61. for(i = 0 ; i < 25 ; i++) {
  62. _mode = me.mode;
  63.  
  64. if((_mode >= 1 && _mode <= 3) || _mode == 5 || _mode == 6) { break; }
  65.  
  66. NTC_Delay(NTC_DELAY_FRAME);
  67. }
  68.  
  69. if(i < parseInt(NTConfig_SnagDelay / NTC_DELAY_FRAME)) {
  70. NTC_PingDelay(NTConfig_SnagDelay - (i*NTC_DELAY_FRAME));
  71. }
  72.  
  73. Include("libs/common/NTItemlogger.ntl");
  74. NTSI_SnagIt();
  75.  
  76. isBusyPickIt = false;
  77. }
  78.  
  79. function NTSI_SnagIt() {
  80. var i;
  81. var _item;
  82. var _checkeditem, _checkeditems;
  83. var _value;
  84. var resultArray = new Array();
  85. var _minindex, _mindistance;
  86. var _location;
  87. var _area = GetArea();
  88.  
  89. _item = NTC_FindUnit(NTC_UNIT_ITEM);
  90.  
  91. if(!_item){
  92. return;
  93. }
  94.  
  95. var _mename = me.name;
  96. var _isEthereal = ((_item.itemflag & 0x400000) == 0x400000);
  97. _checkeditems = new Array();
  98.  
  99. do {
  100.  
  101. if(_item.mode == 3 || _item.mode == 5) {
  102.  
  103. if (ignoredGidz.indexOf(_item.gid) < 0){
  104.  
  105. if(NTSI_IsIgnoredItemInt(_item.classid)) { continue; }
  106.  
  107. var _skipitem=false;
  108.  
  109. for (jj = 0; jj < _IgnoredItems.length; jj+=1) {
  110.  
  111. if (_IgnoredItems[jj] == _item.gid) { _skipitem = true; }
  112. }
  113.  
  114. if (_skipitem) { continue; }
  115.  
  116. //Checks if the item is in range.
  117. if (GetDistance(me, _item) <= NTConfig_SnagRange) {
  118.  
  119. resultArray = NTSI_CheckItem(_item, false);
  120. _value = resultArray[0];
  121.  
  122. //If Item passes check value, we pick it up.
  123. if(_value) { _checkeditems.push(new NTSI_ItemInt(_item, _value, resultArray)); }
  124.  
  125. //Ignored Items Logging
  126. else {
  127. ignoredGidz.push(_item.gid);
  128. // Print(COLOR_8 + ignoredGidz.length + " items on skip list."); // DEBUG
  129.  
  130. if (NTConfig_LogIgnoredItems) {
  131. if ((_item.quality == 2 && _item.classid > 609) || (_item.quality >= NTConfig_LogItemQuality && (_item.classid != 515 && _item.classid != 523 && _item.classid != 516 && _item.classid != 587 && _item.classid != 588 && _item.classid != 589 && _item.classid != 590 && _item.classid != 591 && _item.classid != 592 && _item.classid != 593 && _item.classid != 594 && _item.classid != 595 && _item.classid != 596))) {
  132. if(NTConfig_UseXMLItemlog) {
  133. if(NTConfig_IndependantLog) {
  134. NTI_WriteILog(_item, me, _isEthereal, 14);
  135. } else {
  136. NTI_WriteLog(_item, me, _isEthereal, 14);
  137. }
  138. }
  139. Print(COLOR_5 + "Ignored: " + NTC_ItemQualityToD2Color[_item.quality] + _item.name);
  140. NTC_LogLocation(_area.name);
  141. _IgnoredItems.push(_item.gid);
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. } while(_item.GetNext());
  149.  
  150. while(_checkeditems.length > 0)
  151. {
  152. _mindistance = 100000;
  153.  
  154. for(i = 0 ; i < _checkeditems.length ; i++)
  155. {
  156. _value = GetDistance(me.x, me.y, _checkeditems[i].x, _checkeditems[i].y);
  157.  
  158. if(_value < _mindistance)
  159. {
  160. _minindex = i;
  161. _mindistance = _value;
  162. }
  163. }
  164.  
  165. _checkeditem = _checkeditems.splice(_minindex, 1)[0];
  166.  
  167. _item = NTC_FindUnit(NTC_UNIT_ITEM, _checkeditem.GID);
  168.  
  169. if(_item) {
  170. if(!NTSI_IsLimitedItemInt(_item)) {
  171. if(NTT_CheckSpace(_item.xsize, _item.ysize) || _item.itemtype === 9 || _item.itemtype >= 76 && _item.itemtype <= 78) { // potion pick on full inventory fix
  172. if(NTSI_PickUpItemInt(_item)) {
  173. switch(_checkeditem.ClassID) {
  174.  
  175. case 515: // Rejuvenation Potion
  176. case 516: // Full Rejuvenation Potion
  177.  
  178. Print("Picked up "+ NTC_ItemQualityToD2Color[9] + GetLocaleString(2209+_checkeditem.ClassID-515));
  179. break;
  180.  
  181. case 523: //Gold
  182.  
  183. Print("Picked up "+ NTC_ItemQualityToD2Color[7] + GetLocaleString(2215));
  184. break;
  185.  
  186. case 587: // Minor Healing Potion
  187. case 588: // Light Healing Potion
  188. case 589: // Healing Potion
  189. case 590: // Greater Healing Potion
  190. case 591: // Super Healing Potion
  191.  
  192. Print("Picked up "+ NTC_ItemQualityToD2Color[10] + GetLocaleString(2266+_checkeditem.ClassID-587));
  193. break;
  194.  
  195. case 592: // Minor Mana Potion
  196. case 593: // Light Mana Potion
  197. case 594: // Mana Potion
  198. case 595: // Greater Mana Potion
  199. case 596: // Super Mana Potion
  200.  
  201. Print("Picked up "+ NTC_ItemQualityToD2Color[4] + GetLocaleString(2271+_checkeditem.ClassID-592));
  202. break;
  203.  
  204. default:
  205. //Print("Picked up " + NTC_ItemQualityToD2Color[_item.quality] + _item.name.split("\n")[0]);
  206. if(_item.itemtype == 74 || (_item.classid >= 654 && _item.classid <= 657) || (_item.classid >= 647 && _item.classid <= 652)) {
  207. Print("Picked up " + NTC_ItemQualityToD2Color[8] + _item.name.split("\n")[0]);
  208. }
  209. else if((_item.classid >= 544 && _item.classid <= 555) || _item.classid == 524 || _item.classid == 525){
  210. Print(COLOR_4 + "Picked Quest Item " + COLOR_17 + _item.name.split("\n")[0]);
  211. }
  212. else {
  213. Print("Picked up " + NTC_ItemQualityToD2Color[_item.quality] + _item.name.split("\n")[0]);
  214. }
  215.  
  216. NTC_LogLocation(_area.name);
  217. //if(_item.quality < 4 && _checkeditem.Status < 2 && _item.itemtype != 4 && (_item.itemtype < 76 || _item.itemtype > 81))
  218. if(_checkeditem.Status > -1 && _checkeditem.Status < 2 && _item.itemtype != 4 && (_item.itemtype < 76 || _item.itemtype > 81)) // first half of repeating item log fix
  219. {
  220. NTC_LogLocation(_area.name);
  221. if(NTConfig_UseXMLItemlog) {
  222. if(NTConfig_IndependantLog) {
  223. NTI_WriteILog(_item, me, _isEthereal, 12);// need to check the arguements eventually for this
  224. } else {
  225. NTI_WriteLog(_item, me, _isEthereal, 12);
  226. }
  227. }
  228. resultArray = NTSI_CheckItem(_item, true);
  229. if(_item.itemtype == 74 || (_item.classid >= 654 && _item.classid <= 657) || (_item.classid >= 647 && _item.classid <= 652))
  230. NTC_SendLogToOOG(NTC_LOG_ITEM, COLOR_2 + " Kept: " + NTC_ItemQualityToMGRColor[8] + _item.name.split("\n")[0]+ ";" + _item.itemdesc + "\n" + COLOR_2 + "iLvl: " + _item.itemlevel + "\n" + COLOR_2 + "Area: " +_area.name+ "\n" + COLOR_2 +resultArray[1]+", "+resultArray[2]);
  231. else
  232. NTC_SendLogToOOG(NTC_LOG_ITEM, COLOR_2 + " Kept: " + NTC_ItemQualityToMGRColor[_item.quality] + _item.name.split("\n")[0]+ ";" + _item.itemdesc + "\n" + COLOR_2 + "iLvl: " + _item.itemlevel + "\n" + COLOR_2 + "Area: " +_area.name+ "\n" + COLOR_2 +resultArray[1]+", "+resultArray[2]);
  233.  
  234. //_location = NTC_GetScript(true);//jinay edits for item log
  235. //NTC_SendLogToOOG(NTC_LOG_ITEM, COLOR_2 + "(" + _location + ") Field Kept " + NTC_ItemQualityToMGRColor[_item.quality] + _item.name.split("\n")[0] + ";" + _item.itemdesc + "\n" + COLOR_2 + "Itemlevel: " + _item.itemlevel);
  236. }
  237. break;
  238. }
  239. }
  240. }
  241.  
  242. else {
  243. if(!_checkeditem.Retry) {
  244. _checkeditem.Retry = true;
  245. NTT_ClearInventory();
  246. if(NTConfig_IdInField && NTSI_FieldItemsToId()){ // id in field add
  247. NT_FieldID();
  248. }
  249. else if(!NTTMGR_VisitTown()){
  250. return;
  251. }
  252. _checkeditems.push(_checkeditem);
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259.  
  260. // Internal function
  261. function NTSI_ItemInt(item, checkedstatus) {
  262. this.ClassID = item.classid;
  263. this.GID = item.gid;
  264. this.x = item.x;
  265. this.y = item.y;
  266. this.Status = checkedstatus;
  267. this.Retry = false;
  268. }
  269.  
  270. function NTSI_PickUpItemInt(snagitem) {
  271. var i;
  272. var _classid;
  273. var _result;
  274. var _itemType = snagitem.itemtype;
  275. var _isTelekinesis = me.classid === 1 && NTConfig_Telekinesis && NTC_GetSkillLevel(43) && (_itemType == 4 || (_itemType > 75 && _itemType < 82));
  276.  
  277. _classid = snagitem.classid;
  278.  
  279. for(i = 0 ; i < 40 ; i++) {
  280. if((i % 10) == 0 && (snagitem.mode == 3 || snagitem.mode == 5)) {
  281. _result = false;
  282. if(_isTelekinesis) {
  283. if(GetDistance(me, snagitem) > 5 && GetDistance(me, snagitem) < 20 && CheckCollision(me, snagitem, 5))
  284. _result = true;
  285. }
  286. if(NTC_ClearCursor()) {
  287. if (_result) {
  288. NTC_CastSkill(43, NTC_HAND_RIGHT, snagitem);
  289. }
  290. else if(GetDistance(me.x, me.y, snagitem.x, snagitem.y) <= 3) {
  291. NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, snagitem);
  292. }
  293. else if(NTM_MoveTo(snagitem.areaid, snagitem.x, snagitem.y, 3, false, false)) {
  294. NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, snagitem);
  295. }
  296. }
  297. }
  298. NTC_Delay(NTC_DELAY_FRAME);
  299.  
  300. if(_classid == 523) {
  301. Print("Picked up " + NTC_ItemQualityToD2Color[7] + GetLocaleString(2215));
  302. return false;
  303. }
  304. if(_classid == 543) {
  305. Print("Picked up " + NTC_ItemQualityToD2Color[7] +GetLocaleString(2221));
  306. return false;
  307. }
  308. if(_classid == 529) {
  309. Print("Picked up " + GetLocaleString(2200));
  310. return false;
  311. }
  312. if(_classid == 530) {
  313. Print("Picked up " + GetLocaleString(2202));
  314. return false;
  315.  
  316. } else if(snagitem.mode != 3 && snagitem.mode != 5) {
  317. var _parent;
  318.  
  319. NTC_PingDelay(100);
  320.  
  321. _parent = snagitem.GetParent();
  322.  
  323. return (_parent && _parent.gid == me.gid);
  324. }
  325. }
  326.  
  327. return false;
  328. }
  329.  
  330. function NTSI_CheckItem(item, checkonly)
  331. {
  332. if(arguments.length < 2)
  333. checkonly = true;
  334.  
  335. var _resultArray = new Array();
  336.  
  337. switch(item.quality)
  338. {
  339. case 5:
  340. case 8:
  341. _resultArray = NTIPCheckItem(item);
  342. break;
  343. default:
  344. _resultArray = NTIPCheckItem(item);
  345.  
  346. if(NTCU_CheckItem(item, _resultArray[0]) || NTRW_CheckItem(item, checkonly))
  347. _resultArray[0] = 2;
  348. break;
  349. }
  350.  
  351. return _resultArray;
  352. }
  353.  
  354. function NTSI_IsIgnoredItemInt(classid)
  355. {
  356. for(var i = 0 ; i < _NTSI_IgnoredList.length ; i++)
  357. {
  358. if(classid == _NTSI_IgnoredList[i])
  359. return true;
  360. }
  361.  
  362. return false;
  363. }
  364.  
  365. function NTSI_IsLimitedItemInt(item) // Note that returning true means don't pick. Returning false means pick the item
  366. {
  367. _NTSI_CarryKeys = NTT_GetKey();
  368. var i;
  369. var _items;
  370. if(item.classid == 523){ // add to not pick gold if carry gold is full
  371. return (NTC_StashGoldFull() && NTC_CharGoldFull()); // checks both stash ad inv gold
  372. }
  373. else if (item.classid == 529){ // tp scrolls
  374. var _tome = NTT_GetTome(1);
  375. if(!_tome) {
  376. return true;
  377. }
  378. return !(_tome.GetStat(70) < 20);
  379. }
  380. else if (item.classid == 530){ // id scrolls
  381. var _tome = NTT_GetTome(0);
  382. if(!_tome) {
  383. return true;
  384. }
  385. return !(_tome.GetStat(70) < 20);
  386. }
  387. else if (item.classid == 543) { // key note hard coded to only grab if amount is less than 8 else because keys drop in stacks you can end with a ton of keys
  388. if(!_NTSI_CarryKeys) {
  389. return true;
  390. }
  391. return !(NTTMGR_CheckKeys() < 8);
  392. }
  393. //If item is a potion
  394. else if(item.itemtype >= 76 && item.itemtype <= 78)
  395. {
  396. var _code, _type;
  397. var _potnum = 0;
  398.  
  399. _code = item.code;
  400. _type = item.itemtype;
  401.  
  402. for(i = 0 ; i < 4 ; i++)
  403. {
  404. if(_code.indexOf(NTConfig_BeltColType[i]) != -1)
  405. //sets _potnum to the size of the belt
  406. _potnum += _NTSI_BeltSize;
  407. }
  408.  
  409. _items = me.GetItems();
  410.  
  411. if(_items)
  412. {
  413. //goes through all items
  414. for(i = 0 ; i < _items.length ; i++) {
  415. //if it is a potion decrease number of potions previously the size of the belt
  416. if(_items[i].mode == 2 && _items[i].itemtype == _type)
  417. _potnum--;
  418. }
  419.  
  420. //If your belt is full
  421. if(_potnum < 1) {
  422. //Rejuv Swapping
  423. //if you find a Rejuv Potion
  424. if(_type == 78 && _code == "rvl") {
  425. for(i = 0 ; i < _items.length ; i++) {
  426. //Look for a small rejuv
  427. if(_items[i].mode == 2 && _items[i].code == "rvs") {
  428. //if found drink the small rejuv
  429. SetUIState(0x1F, true);
  430. if (NTConfig_DropExtraRejuvs)
  431. NTT_DropItem(_items[i]);
  432. else
  433. me.ClickItem (1, _items[i]);
  434. me.Cancel(1);
  435. return false; //return not full now after drinking a juv
  436. //It will now pick up Rejuv on the ground
  437. }
  438. }
  439. if (!NTConfig_DropExtraRejuvs) {
  440. for(i = 0 ; i < _items.length ; i++) {
  441. //Look for a full rejuv
  442. if (_items[i].mode == 2 && _items[i].code == "rvl" && _code == "rvl") {
  443. //If found drink the full rejuv
  444. SetUIState(0x1F, true);
  445. me.ClickItem (1, _items[i]);
  446. me.Cancel(1);
  447. return false; //return not full now after drinking a juv
  448. //It will now pick up Rejuv on the ground
  449. }
  450. }
  451. }
  452. }
  453. return true;
  454. }
  455. }
  456. }
  457. else if(item.quality == 7 && item.classid >= 603 && item.classid <= 605)
  458. {
  459. _items = me.GetItems(item.classid);
  460.  
  461. if(_items)
  462. {
  463. for(i = 0 ; i < _items.length ; i++)
  464. {
  465. if(_items[i].quality == 7)
  466. return true;
  467. }
  468. }
  469. }
  470.  
  471. return false;
  472. }
  473.  
  474. function NTSI_FieldItemsToId(){
  475. items = me.GetItems();
  476. if(!items || items.length < 1){
  477. return false;
  478. }
  479. for(var i = 0; i < items.length; i++){
  480. if(items[i].mode == 0 && items[i].itemloc == 0){
  481. var _value = NTSI_CheckItem(items[i])[0];
  482. if(_value == -1){
  483. return true;
  484. }
  485. }
  486. }
  487. return false;
  488. }
  489.  
  490. function NTSI_FastPick() {
  491. if (!NTConfig_FastPickit) {
  492. return;
  493. }
  494.  
  495. //Print(ignoredGids.length + " items on skip list.") // DEBUG
  496.  
  497. var area, item, string, result;
  498. var resultArray = new Array();
  499.  
  500. item = NTC_FindUnit(NTC_UNIT_ITEM);
  501.  
  502. if (item) {
  503. do {
  504. if (ignoredClassids.indexOf(item.classid) < 0 && ignoredGids.indexOf(item.gid) < 0) {
  505. resultArray = NTSI_CheckItem(item, false);
  506. result = resultArray[0];
  507.  
  508. if (result) {
  509. if (GetDistance(me, item) <= NTConfig_SnagRange && !NTSI_IsLimitedItemInt(item) && NTT_CheckSpace(item.xsize, item.ysize)) {
  510. if(item.classid == 515 || item.classid == 516) {
  511. string = (COLOR_2 + "Fast Pick" + COLOR_8 + ":: " + NTC_ItemQualityToD2Color[9] + item.name);
  512. }
  513. else if(item.itemtype == 74 || (item.classid >= 654 && item.classid <= 657) || (item.classid >= 647 && item.classid <= 652)) {
  514. string = (COLOR_2 + "Fast Pick" + COLOR_8 + ":: " + NTC_ItemQualityToD2Color[8] + item.name);
  515. }
  516. else {
  517. string = (COLOR_2 + "Fast Pick" + COLOR_8 + ":: " + NTC_ItemQualityToD2Color[item.quality] + item.name);
  518. }
  519.  
  520. if (NTSI_PickUpItemInt(item)) {
  521. Print(string);
  522.  
  523. area = GetArea();
  524.  
  525. NTC_LogLocation(area.name);
  526.  
  527. if (result === 1 && item.itemtype !== 4 && (item.itemtype < 76 || item.itemtype > 81)) {
  528. if (item.itemtype == 74 || (item.classid >= 654 && item.classid <= 657) || (item.classid >= 647 && item.classid <= 652)) {
  529. NTC_SendLogToOOG(NTC_LOG_ITEM,COLOR_2 + "Fast Pick Kept: " + NTC_ItemQualityToMGRColor[8] + item.name.split("\n")[0]+ ";" + item.itemdesc + COLOR_2 + "\n iLvl: " + item.itemlevel + COLOR_2 + "\n Area: " + area.name+ "\n" + COLOR_2 +resultArray[1]+", "+resultArray[2]);
  530. } else {
  531. NTC_SendLogToOOG(NTC_LOG_ITEM,COLOR_2 + "Fast Pick Kept: " + NTC_ItemQualityToMGRColor[item.quality] + item.name.split("\n")[0]+ ";" + item.itemdesc + COLOR_2 + "\n iLvl: " + item.itemlevel + COLOR_2 + "\n Area: " + area.name+ "\n" + COLOR_2 +resultArray[1]+", "+resultArray[2]);
  532. }
  533. }
  534. }
  535. }
  536. } else {
  537. ignoredGids.push(item.gid);
  538. }
  539. }
  540. } while (item.GetNext());
  541. }
  542. }
  543.  
  544. var ignoredClassids = [
  545. 80, // Rancid Gas Pot
  546. 81, // Oil Potion
  547. 82, // Choking Gas Pot
  548. 83, // Exploding Pot
  549. 84, // Strangling Gas
  550. 85, // Fulminating Pot
  551. 513, // Stamina potion
  552. 514, // Antidote potion
  553. 517, // Thawing potion
  554. 518, // Tome of Town Portal
  555. 519, // Tome of Identify
  556. 523, // Gold
  557. 526, // Arrows quiver
  558. 528, // Bolts quiver
  559. 543, // Keys
  560. 529, // Scroll of Town Portal
  561. 530, // Scroll of Identify
  562. 587, // minor healing
  563. 588, // light healing
  564. 589, // healing
  565. 590, // greater healing
  566. 591, // super healing
  567. 592, // minor mana
  568. 593, // light mana
  569. 594, // mana
  570. 595, // greater mana
  571. 596, // super mana
  572. 529, // tp scroll
  573. 530 // id scroll
  574. ];
  575.  
  576. var ignoredGids = [];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement