var _NTT_BeltColNeeded = new Array(4); _NTT_BeltColNeeded[0] = 0; _NTT_BeltColNeeded[1] = 0; _NTT_BeltColNeeded[2] = 0; _NTT_BeltColNeeded[3] = 0; var _NTT_BeltSize = 0; var _NTT_OldItems; var _NTT_IgnoredItems = new Array( "aqv", // Arrows quiver "cqv", // Bolts quiver "key", // Keys "tbk", // Tome of Town Portal "ibk", // Tome of Identify "tsc", // Scroll of Town Portal "isc", // Scroll of Identify "yps", // Antidote potion "vps", // Stamina potion "wms", // Thawing potion "gps", // Rancid Gas Pot "ops", // Oil Potion "gpm", // Choking Gas Pot "opm", // Exploding Pot "gpl", // Strangling Gas "opl", // Fulminating Pot "hp1","hp2","hp3","hp4","hp5", // Healing potions "mp1","mp2","mp3","mp4","mp5", // Mana potions "rvs","rvl"); // Rejuvenation potions // type : 1 = shop, 2 = ressurect, 3 = repair, 4 = potion, 5 = scrolls, 6 = gamble, 7 = ammo, 8 = healing function NTT_CheckNPC(npc, type) { var _npcclassid; if(typeof(npc) == "number") _npcclassid = npc; else _npcclassid = npc.classid; if(type == 1) { if(_npcclassid == 147 || _npcclassid == 148 || _npcclassid == 154 || _npcclassid == 177 || _npcclassid == 178 || _npcclassid == 199 || _npcclassid == 202 || _npcclassid == 252 || _npcclassid == 253 || _npcclassid == 254 || _npcclassid == 255 || _npcclassid == 257 || _npcclassid == 405 || _npcclassid == 511 || _npcclassid == 512 || _npcclassid == 513) return true; else return false; } if(type == 2) { if(_npcclassid == 150 || _npcclassid == 198 || _npcclassid == 252 || _npcclassid == 367 || _npcclassid == 515) return true; else return false; } if(type == 3) { if(_npcclassid == 154 || _npcclassid == 178 || _npcclassid == 253 || _npcclassid == 257 || _npcclassid == 511) return true; else return false; } if(type == 4) { if(_npcclassid == 148 || _npcclassid == 177 || _npcclassid == 198 || _npcclassid == 202 || _npcclassid == 255 || _npcclassid == 405 || _npcclassid == 513) return true; else return false; } if(type == 5) { if(_npcclassid == 148 || _npcclassid == 177 || _npcclassid == 255 || _npcclassid == 405 || _npcclassid == 513) return true; else return false; } if(type == 6) { if(_npcclassid == 147 || _npcclassid == 199 || _npcclassid == 254 || _npcclassid == 405 || _npcclassid == 512 || _npcclassid == 514) return true; else return false; } if(type == 7) { if(_npcclassid == 147 || _npcclassid == 154 || _npcclassid == 178 || _npcclassid == 199 || _npcclassid == 252 || _npcclassid == 253 || _npcclassid == 257 || _npcclassid == 511 || _npcclassid == 512) return true; else return false; } if(type == 8) { if(_npcclassid == 148 || _npcclassid == 178 || _npcclassid == 255 || _npcclassid == 513) return true; else return false; } return false; } // npc : NPC, stash or cube function NTT_DoInteract(npc) { var _uiflag = 0x08; if(!npc) return false; if(npc.classid == NTC_UNIT_STASH) _uiflag = 0x19; else if(npc.classid == NTC_UNIT_CUBE) _uiflag = 0x1A; if(GetUIState(_uiflag)) return true; for(var i = 0 ; i < 40 ; i++) { if((i % 10) == 0) { if(npc.classid == NTC_UNIT_CUBE) me.ClickItem(1, npc); else { if(i > 10) me.Cancel(0); NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, npc); } } NTC_Delay(200); if(GetUIState(_uiflag)) { NTC_PingDelay(500); return true; } } return false; } // type : 0 = shop, 1 = gamble function NTT_DoTrade(npc, type) { if(!npc) return false; if(GetUIState(0x0C)) return true; if(arguments.length < 2) type = 0; for(var i = 0 ; i < 20 ; i++) { if((i % 10) == 0) { if(NTT_CheckNPC(npc.classid, 3)) me.SelectNPCMenu(0x0D06); else if(type == 1 && NTT_CheckNPC(npc.classid, 6)) me.SelectNPCMenu(0x0D46); else me.SelectNPCMenu(0x0D44); } NTC_Delay(200); if(GetUIState(0x0C)) { NTC_PingDelay(1000); return true; } } return false; } function NTT_GetCorpses() { var _corpse; for(var i = 0 ; i < 4 ; i++) { _corpse = NTC_FindUnit(NTC_UNIT_PLAYER); if(_corpse) { do { if(_corpse.name == me.name && _corpse.hpmax == 0) { NTC_SwapWeapons(0); NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _corpse); NTC_PingDelay(1000); break; } } while(_corpse.GetNext()); } } } function NTT_CheckMerc() { if(NTConfig_UseMerc) { if(NTC_GetMerc()) return false; else { if(NTC_MyGold() < me.GetMercCost()) return false; return true; } } return false; } function NTT_ReviveMerc() { var _mygold; if(!NTT_CheckMerc()) return true; if(!GetUIState(0x08)) return false; _mygold = NTC_MyGold(); if(_mygold < me.GetMercCost()) return false; for(var i = 0 ; i < 8 ; i++) { if((i % 4) == 0) me.SelectNPCMenu(0x1507); NTC_Delay(500); if(_mygold > NTC_MyGold()) return true; } return false; } function NTT_ResetWeaponMerc() { var i, n; var _merc, _items; _merc = NTC_GetMerc(); if(!_merc) return false; _items = _merc.GetItems(); if(!_items) return false; for(i = 0 ; i < _items.length ; i++) { if(_items[i].itemloc == 4 && (_items[i].itemflag&0x4000000)) { SetUIState(0x24, true); for(n = 0 ; n < 80 ; n++) { if((n % 40) == 0) me.ClickMercItem(4); NTC_Delay(100); if(me.itemoncursor) { NTC_PingDelay(200); break; } } if(n >= 80) { me.Cancel(1); break; } for(n = 0 ; n < 120 ; n++) { if((n % 40) == 0) me.ClickMercItem(4); NTC_Delay(100); if(!me.itemoncursor) break; } me.Cancel(1); if(n < 120) return true; break; } } return false; } function NTT_CheckRepair(repairpercent) { var _max_dur; var _percent; var _items = me.GetItems(); if(!_items) return false; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 1 && !(_items[i].itemflag&0x400000) && !_items[i].GetStat(152)) { if(_items[i].itemtype == 42 || _items[i].itemtype == 43 || _items[i].itemtype == 44 || _items[i].itemtype == 87) _percent = Math.floor((_items[i].GetStat(70)*100) / (GetBaseStat("weapons.txt", _items[i].classid, 45)+_items[i].GetStat(254))); else { _max_dur = _items[i].GetStat(73); if(_max_dur == 0) continue; _percent = Math.floor((_items[i].GetStat(72)*100) / (_max_dur*(_items[i].GetStat(75)/100 + 1))); } if(_percent <= repairpercent) return true; } } return false; } function NTT_RepairItems(npc) { var _mygold; if(!npc) return false; if(!GetUIState(0x0C)) return false; _mygold = NTC_MyGold(); for(var i = 0 ; i < 8 ; i++) { if((i % 4) == 0) me.Repair(); NTC_Delay(500); if(_mygold > NTC_MyGold()) return true; } return false; } function NTT_CheckInventory() { var x, y; var _items; _itemlist = new Array(); _ignorestring = _NTT_IgnoredItems.join(); if(!NTC_StashGoldFull() && NTC_MyGoldCarry() > NTConfig_MinGoldToStash) return true; _invspace = new Array(4); _invspace[0] = new Array(10); _invspace[1] = new Array(10); _invspace[2] = new Array(10); _invspace[3] = new Array(10); for(y = 0 ; y < 4 ; y++) { for(x = 0 ; x < 10 ; x++) _invspace[y][x] = 0; } _items = me.GetItems(); if(!_items) return false; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) { if(NTConfig_Columns[_items[i].y][_items[i].x] > 0) _itemlist.push(_items[i].code); for(y = 0 ; y < _items[i].ysize ; y++) { for(x = 0 ; x < _items[i].xsize ; x++) _invspace[y+_items[i].y][x+_items[i].x] = 1; } } } _freecols = new Array(10); for(x = 0 ; x < 10 ; x++) _freecols[x] = 0; for(x = 0 ; x < 10 ; x++) { for(y = 0 ; y < 4 ; y++) { if(_invspace[y][x] == 1) { _freecols[x] = 1; break; } } } _numfreecols = 0; for(x = 0 ; x < 10 ; x++) { if(_freecols[x] == 0) _numfreecols++; } if(NTConfig_FreeSpace > _numfreecols) { for(x = 0 ; x < _itemlist.length ; x++) { if(_ignorestring.indexOf(_itemlist[x]) != -1) _itemlist.splice(x, 1); } if(_itemlist.length > 0) return true; } return false; } function NTT_CheckStash() { var x, y; var _items; var _StashHeight = (me.gametype == 0) ? 4 : 8; var _stashspace = new Array(_StashHeight); for(y = 0 ; y < _StashHeight ; y++) _stashspace[y] = new Array(6); for(y = 0 ; y < _StashHeight ; y++) { for(x = 0 ; x < 6 ; x++) _stashspace[y][x] = 0; } _items = me.GetItems(); if(!_items) return false; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 4) { for(y = 0 ; y < _items[i].ysize ; y++) { for(x = 0 ; x < _items[i].xsize ; x++) _stashspace[y+_items[i].y][x+_items[i].x] = 1; } } } for(y = 0 ; y < _StashHeight ; y++) { for(x = 0 ; x < 6 ; x++) { if(_stashspace[y][x] != 1) return true; } } return false; } function NTT_ManageStash(invitem) { var i, x, y; var _items; var _stashall; var StashHeight = (me.gametype == 0) ? 4 : 8; var _ignorestring = _NTT_IgnoredItems.join(); var _ignoreitem; if(!GetUIState(0x19)) return false; if(arguments.length < 1) _stashall = true; else _stashall = false; if(!NTC_StashGoldFull() && NTC_MyGoldCarry() > NTConfig_MinGoldToStash) { var _mygold = NTC_MyGoldCarry(); Gold(3, _mygold); for(i = 0 ; i < 2 ; i++) { NTC_Delay(500); if(_mygold > NTC_MyGoldCarry()) break; } } var _stashspace = new Array(StashHeight); for(y = 0 ; y < StashHeight ; y++) _stashspace[y] = new Array(6); for(y = 0 ; y < StashHeight ; y++) { for(x = 0 ; x < 6 ; x++) _stashspace[y][x] = 0; } _items = me.GetItems(); if(!_items) return false; for(i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 4) { for(y = 0 ; y < _items[i].ysize ; y++) { for(x = 0 ; x < _items[i].xsize ; x++) _stashspace[y+_items[i].y][x+_items[i].x] = 1; } } } for(i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0 && (_stashall || (_items[i].x == invitem.x && _items[i].y == invitem.y))) { if(_stashall) { _ignoreitem = (NTConfig_Columns[_items[i].y][_items[i].x] == 0); if(!_ignoreitem) { if( _ignorestring.indexOf(_items[i].code) != -1 || NTSI_CheckItem(_items[i]) <= 0 ) _ignoreitem = true; } } else _ignoreitem = false; if(!_ignoreitem) { _itemdone = false; for(y = 0 ; y < StashHeight ; y++) { if(_itemdone) break; for(x = 0 ; x < 6 ; x++) { if(_itemdone) break; if(_stashspace[y][x] == 0) { if((x+_items[i].xsize-1) < 6 && (y+_items[i].ysize-1) < StashHeight) { var _havespace = true; for(m = 0 ; m < _items[i].ysize ; m++) { for(n = 0 ; n < _items[i].xsize ; n++) { if(_stashspace[y+m][x+n] == 1) { _havespace = false; m = 4; break; } } } if(_havespace) { if(NTC_ItemToCursor(_items[i])) { for(n = 0 ; n < 80 ; n++) { if((n % 40) == 0) me.ClickItem(0, x, y, 4); NTC_Delay(100); if(!me.itemoncursor) break; } if(n < 80) { for(m = 0 ; m < _items[i].ysize ; m++) { for(n = 0 ; n < _items[i].xsize ; n++) _stashspace[y+m][x+n] = 1; } } NTC_PingDelay(200); } _itemdone = true; } } } } } } if(!_stashall) return true; } } return true; } // type : id = 0, tp = 1 function NTT_GetScroll(type) { var _items; if(arguments.length < 1) type = 0; if(type) _items = me.GetItems(529); else _items = me.GetItems(530); if(_items) { for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) return _items[i]; } } return null; } // type : id = 0, tp = 1 function NTT_GetTome(type) { var _items; if(arguments.length < 1) type = 0; if(type) _items = me.GetItems(518); else _items = me.GetItems(519); if(_items) { for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) return _items[i]; } } return null; } // type : id = 0, tp = 1 function NTT_FillTome(npc, type) { var _tome; if(arguments.length < 1) return false; if(arguments.length < 2) type = 0; _tome = NTT_GetTome(type); if(_tome) { var _items; if(_tome.GetStat(70) >= 20) return true; if(type) _items = npc.GetItems(529); else _items = npc.GetItems(530); if(_items && _items.length > 0) return NTT_ShopItem(_items[0], npc, 3); } return false; } // type : id = 0, tp = 1 function NTT_BuyScrolls(npc, type, amount) { var _items; var _counter = 0; if(arguments.length < 1) return false; if(arguments.length < 2) type = 0; if(arguments.length < 3) amount = 1; if(amount == 0) return false; if(type) _items = npc.GetItems(529); else _items = npc.GetItems(530); if(_items && _items.length > 0) { for(var i = 0 ; i < amount ; i++) { if(NTT_ShopItem(_items[0], npc, 2)) _counter++; } } return (_counter > 0); } function NTT_GetKey() { var _items; _items = me.GetItems(543); if(_items) { for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) return _items[i]; } } return null; } function NTT_FillKey(npc) { var _key; var _items; if(arguments.length < 1) return false; _key = NTT_GetKey(); if(_key) { if(_key.GetStat(70) >= 12) return true; _items = npc.GetItems(543); if(_items && _items.length > 0) return NTT_ShopItem(_items[0], npc, 3); } else { _items = npc.GetItems(543); if(_items && _items.length > 0) { NTT_ShopItem(_items[0], npc, 2); return NTT_ShopItem(_items[0], npc, 3); } } return false; } function NTT_CheckBelt() { var _needpotions = false; for(var i = 0 ; i < 4 ; i++) { _NTT_BeltColNeeded[i] = NTT_GetNeededPotionsColInt(NTConfig_BeltColType[i], i); if(_NTT_BeltColNeeded[i] > 0 && NTConfig_BeltColType[i] != "rv") _needpotions = true; } return _needpotions; } function NTT_FillBelt(npc) { if(!npc) return false; if(!GetUIState(0x0C)) return false; if(_NTT_BeltSize < 1) _NTT_BeltSize = NTC_GetBeltSize(); if(_NTT_BeltColNeeded[3] == _NTT_BeltSize || _NTT_BeltColNeeded[2] == _NTT_BeltSize || _NTT_BeltColNeeded[1] == _NTT_BeltSize || _NTT_BeltColNeeded[0] == _NTT_BeltSize) NTT_BuyPotionsSlowInt(npc); else NTT_BuyPotionsFastInt(npc); return true; } function NTT_CheckHeal() { var _merc; if(parseInt(me.hp*100/me.hpmax) < NTConfig_SkipHealLife || parseInt(me.mp*100/me.mpmax) < NTConfig_SkipHealMana) return true; _merc = NTC_GetMerc(); if(_merc) { if(parseInt(_merc.hp*100/_merc.hpmax) < NTConfig_SkipHealLife) return true; } return false; } function NTT_CheckSpace(itemX, itemY) { var i, j, x, y; var _items; _invspace = new Array(4); _invspace[0] = new Array(10); _invspace[1] = new Array(10); _invspace[2] = new Array(10); _invspace[3] = new Array(10); for(y = 0 ; y < 4 ; y++) { for(x = 0 ; x < 10 ; x++) _invspace[y][x] = 0; } _items = me.GetItems(); if(!_items) return false; for(i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) { for(y = 0 ; y < _items[i].ysize ; y++) { for(x = 0 ; x < _items[i].xsize ; x++) _invspace[y+_items[i].y][x+_items[i].x] = 1; } } } for(i = 0 ; i < 5-itemY ; i++) { invloop2: for(j = 0 ; j < 11-itemX ; j++) { for(y = 0 ; y < itemY ; y++) { for(x = 0 ; x < itemX ; x++) { if(_invspace[i+y][j+x]) continue invloop2; } } return true; } } return false; } function NTT_CleanPotions() { var _items = me.GetItems(); if(!_items) return; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0 && (_items[i].itemtype == 76 || _items[i].itemtype == 77 || _items[i].itemtype == 78)) { if(NTConfig_Columns[_items[i].y][_items[i].x] > 0) { SetUIState(0x01, true); me.ClickItem(1, _items[i]); NTC_PingDelay(500); } } } me.Cancel(1); } function NTT_ClearInventory() { var _retval = true; var _ignorestring = _NTT_IgnoredItems.join(); var _items; _items = me.GetItems(); if(!_items) return false; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) { if(NTConfig_Columns[_items[i].y][_items[i].x] > 0) { if(_ignorestring.indexOf(_items[i].code) != -1 || NTSI_CheckItem(_items[i]) != 0) continue; SetUIState(0x01, true); if(NTT_DropItem(_items[i])) NTC_PingDelay(200); else _retval = false; } } } me.Cancel(1); return _retval; } function NTT_DropItem(item) { if(!item) return false; if(NTC_ItemToCursor(item)) return NTC_ClearCursor(); return false; } function NTT_ClearBelt() { var i; var _result, _needdrop; var _items; do { _items = me.GetItems(); if(!_items) { _result = false; break; } _result = true; for(i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 2 && _items[i].x < 4) { _needdrop = false; switch(_items[i].itemtype) { case 76: if(NTConfig_BeltColType[_items[i].x] != "hp") _needdrop = true; break; case 77: if(NTConfig_BeltColType[_items[i].x] != "mp") _needdrop = true; break; case 78: if(NTConfig_BeltColType[_items[i].x] != "rv") _needdrop = true; break; default: _needdrop = true; break; } if(_needdrop) { SetUIState(0x1F, true); if(NTT_DropItem(_items[i])) NTC_PingDelay(200); _result = false; } } } } while(!_result); me.Cancel(1); return _result; } // mode : 1 = sell, 2 = buy, 3 = shift buy function NTT_ShopItem(item, npc, mode) { var _mygold = NTC_MyGold(); if(mode > 1) { if(item.GetItemCost(0, npc.classid) > _mygold) return false; } if(mode > 1) { var _havespace = false; if(item.classid == 529 || item.classid == 530) { var _book = (item.classid == 530) ? NTT_GetTome(0) : NTT_GetTome(1); if(_book && _book.GetStat(70) < 20) _havespace = true; } if(!_havespace) { if(NTT_CheckSpace(item.xsize, item.ysize)) _havespace = true; } if(_havespace) { for(var i = 0 ; i < 40 ; i++) { if((i % 20) == 0) me.ClickItem(mode > 2 ? 3 : 1, item); NTC_Delay(100); if(_mygold > NTC_MyGold()) { NTC_PingDelay(500); return true; } } } } else { if(NTC_ItemToCursor(item)) { for(var i = 0 ; i < 40 ; i++) { if((i % 20) == 0) me.ClickItem(0, 8, 6, 1); NTC_Delay(100); if(!me.itemoncursor) { NTC_PingDelay(800); return true; } } } } return false; } function NTT_IdItem(scroll, uniditem) { var i, _timer; if(arguments.length < 1 || !scroll) return false; if(arguments.length < 2 || !uniditem) return false; if(uniditem.itemflag&0x10) return true; for(i = 0 ; i < 40 ; i++) { if((i % 20) == 0) me.ClickItem(1, scroll); NTC_Delay(100); if(GetCursorType() == 6) break; } if(i >= 40) return false; NTC_PingDelay(200); for(i = 0 ; i < 40 ; i++) { if((i % 20) == 0) me.ClickItem(0, uniditem); NTC_Delay(100); if(uniditem.itemflag&0x10) { NTC_PingDelay(200); return true; } } return false; } function NTT_CheckUnids() { var _unidcount = 0; var _items = me.GetItems(); if(!_items) return _unidcount; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0 && !(_items[i].itemflag&0x10)) _unidcount++; } return _unidcount; } function NTT_GetUnidItems() { var _uniditems = new Array(); var _items = me.GetItems(); if(!_items) return _uniditems; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0 && !(_items[i].itemflag&0x10)) _uniditems.push(_items[i]); } return _uniditems; } function NTT_GambleIt(npc) { var _items, _newitem; Include("libs/common/NTItemlogger.ntl"); if(!npc) return false; if(!GetUIState(0x0C)) return false; _items = npc.GetItems(); if(!_items) return false; for(var i = 0 ; i < _items.length ; i++) { if(NTC_MyGold() < NTConfig_GambleStopGold) return false; if(NTT_IsItemInGambleArrayInt(_items[i].classid)) { if(NTT_CheckSpace(_items[i].xsize, _items[i].ysize)) { NTT_GetOldItemsInt(); if(NTT_ShopItem(_items[i], npc, 2)) _newitem = NTT_GetGambledItemInt(); else return false; if(_newitem) { while(!(_newitem.itemflag&0x10)) NTC_Delay(100); switch(NTSI_CheckItem(_newitem)) { case 1: if(NTConfig_UseXMLItemlog) NTI_WriteLog(_newitem, me, 0, 0, true, npc.name); NTC_SendLogToOOG(NTC_LOG_ITEM,"ÿc2Kept: " + NTC_ItemQualityToMGRColor[_newitem.quality] + _newitem.name.split("\n")[0]+ ";" + _newitem.itemdesc + "\n ÿc2iLvl: " + _newitem.itemlevel + "\n ÿc2Gambled: " + npc.name); case 2: break; default: if(NTConfig_UseXMLItemlog) NTI_WriteLog(_newitem, me, 0, 1, true, npc.name); if(NTConfig_LogSoldItems) if(_newitem.quality == NTConfig_LogSoldItems) // 4 = magic, 5 = set, 6 = rare, 7 = unique, 8 = crafted NTC_SendLogToOOG(NTC_LOG_ITEM,"ÿc1Sold: " + NTC_ItemQualityToMGRColor[_newitem.quality] + _newitem.name.split("\n")[0]+ ";" + _newitem.itemdesc + "\n ÿc2iLvl: " + _newitem.itemlevel + "\n ÿc2Gambled: " + npc.name); NTT_ShopItem(_newitem, npc, 1); break; } } } } } return true; } // Internal function function NTT_IsItemInGambleArrayInt(classid) { for(var i = 0 ; i < NTConfig_GambleItem.length ; i++) { if(classid == NTConfig_GambleItem[i]) return true; } return false; } function NTT_GetPotionAtNPCInt(type, npc) { var _items; if(!type) return null; if(type == "hp" || type == "mp") { _items = npc.GetItems(); if(_items) { var n; for(var i = 0 ; i < _items.length ; i++) { for(n = 5 ; n > 0 ; n--) { if(_items[i].code == (type+n)) return _items[i]; } } } } else { if(type == "rv") return null; _items = npc.GetItems(type); if(_items && _items.length > 0) return _items[0]; } return null; } function NTT_BuyPotionsFastInt(npc) { var i, n; var _insert, _potion; var _typearray = new Array(); for(i = 0 ; i < 4 ; i++) { if(_NTT_BeltColNeeded[i] > 0) { if(_typearray.length == 0) _typearray.push(NTConfig_BeltColType[i]); else { _insert = true; for(n = 0 ; n < _typearray.length ; n++) { if(_typearray[n] == NTConfig_BeltColType[i]) _insert = false; } if(_insert) _typearray.push(NTConfig_BeltColType[i]); } } } for(i = 0 ; i < _typearray.length ; i++) { if(_typearray[i] == "rv") continue; _potion = NTT_GetPotionAtNPCInt(_typearray[i], npc); if(_potion) { if(NTT_ShopItem(_potion, npc, 3)) continue; else return false; } else return false; } return true; } function NTT_BuyPotionsColInt(npc, col) { var _numpotions; var _potion; if(col < 0 || col > 3) return false; if(NTConfig_BeltColType[col] == "rv") return false; _numpotions = _NTT_BeltColNeeded[col]; if(_numpotions == 0) return false; if(_numpotions > _NTT_BeltSize) _numpotions = _NTT_BeltSize; for(var _buyloop = 0 ; _buyloop < _numpotions ; _buyloop++) { _potion = NTT_GetPotionAtNPCInt(NTConfig_BeltColType[col], npc); if(_potion) NTT_ShopItem(_potion, npc, 2); else return false; } return true; } function NTT_BuyPotionsSlowInt(npc) { var _currentcol; for(_currentcol = 0 ; _currentcol < 4 ; _currentcol++) { if(_NTT_BeltColNeeded[_currentcol] == _NTT_BeltSize) { NTT_BuyPotionsColInt(npc, _currentcol); _NTT_BeltColNeeded[_currentcol] = 0; } } for(_currentcol = 0 ; _currentcol < 4 ; _currentcol++) NTT_BuyPotionsColInt(npc, _currentcol); return true; } function NTT_GetNeededPotionsColInt(type, column) { var _restartloop = true; var _amountneeded = 0; var _items; if(!type || column > 3) return false; if(_NTT_BeltSize < 1) _NTT_BeltSize = NTC_GetBeltSize(); potionloop: do { _amountneeded = _NTT_BeltSize; _items = me.GetItems(); if(!_items) continue potionloop; for(i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 2) { if(NTT_PotInRightColInt(_items[i].x, column, _NTT_BeltSize)) { var _potcode = _items[i].code; if(_potcode.indexOf(type) != -1) _amountneeded--; else { if(_potcode.indexOf("rv") != -1) { if(_items[i].x < 4) { me.Cancel(1); return 0; } else _amountneeded--; } else { SetUIState(0x1F, true); me.ClickItem(1, _items[i]); NTC_PingDelay(500); continue potionloop; } } } } } _restartloop = false; } while(_restartloop); me.Cancel(1); return _amountneeded; } function NTT_PotInRightColInt(potx, column, beltsize) { for(var i = 0 ; i < beltsize ; i++) { if(potx-i*4 == column) return true; } return false; } function NTT_GetGambledItemInt() { var i, n; var _items; var _founditem; _items = me.GetItems(); if(!_items) return null; for(i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) { _founditem = true; for(n = 0 ; n < _NTT_OldItems.length ; n++) { if(_items[i].gid == _NTT_OldItems[n]) { _founditem = false; break; } } if(_founditem) return _items[i]; } } return null; } function NTT_GetOldItemsInt() { var _items; _NTT_OldItems = new Array(); _items = me.GetItems(); if(!_items) return false; for(var i = 0 ; i < _items.length ; i++) { if(_items[i].mode == 0 && _items[i].itemloc == 0) _NTT_OldItems.push(_items[i].gid); } return true; }