Code:
/**
* This file was modified by [Only registered and activated users can see links. Click Here To Register...]
* Check the programming section for updates and further scripts
* Last Update: 16:14 03.04.2011
*/
var _NTSI_IgnoredList = new Array(
526, // Arrows quiver
528, // Bolts quiver
518, // Tome of Town Portal
519, // Tome of Identify
514, // Antidote potion
513, // Stamina potion
517, // Thawing potion
80, // Rancid Gas Pot
81, // Oil Potion
82, // Choking Gas Pot
83, // Exploding Pot
84, // Strangling Gas
85); // Fulminating Pot
function NTSI_LoadNIPFiles(filepath, checkNips)
{
if(arguments.length < 2)
checkNips = true;
for(var i = 0; i < NTConfig_NIPFilePath.length; i++)
NTIPOpenFile(filepath + "/" + NTConfig_NIPFilePath[i]);
if(MWConfig_RunNipCheck && checkNips)
MWIPCheckNips();
}
function NTSI_PickItems(pickValuables, flag)
{
var i, _mode;
if(pickValuables && !MWConfig_PickUpMoneymakers)
return;
for(i = 0 ; i < 25 ; i++)
{
_mode = me.mode;
if((_mode >= 1 && _mode <= 3) || _mode == 5 || _mode == 6)
break;
NTC_Delay(NTC_DELAY_FRAME);
}
if(i < parseInt(NTConfig_SnagDelay/NTC_DELAY_FRAME))
NTC_PingDelay(NTConfig_SnagDelay-(i*NTC_DELAY_FRAME));
NTSI_SnagIt(pickValuables, flag);
}
function NTSI_SnagIt(pickValuables)
{
var i, j;
var _item;
var _checkeditem, _checkeditems;
var _value;
var _minindex, _mindistance;
if(arguments.length < 1)
pickValuables = false;
_item = NTC_FindUnit(NTC_UNIT_ITEM);
if(!_item)
return;
_checkeditems = new Array();
do
{
if(_item.mode == 3 || _item.mode == 5)
{
if(NTSI_IsIgnoredItemInt(_item.classid))
continue;
if(GetDistance(me, _item) <= NTConfig_SnagRange)
{
_value = NTSI_CheckItem(_item, true);
if(_item.classid == 529 && MWConfig_MinimumTpScrollCount != 0 || _item.classid == 530 && MWConfig_MinimumIdScrollCount != 0 || _item.classid == 543 && MWConfig_CarryKeys)
_value = 1;
if(pickValuables && (_value == 0 || _value == 3) && MWSI_IsValuable(_item))
_value = 4;
if(_value != 0 && _value != 3)
{
_checkeditem = new NTSI_ItemInt(_item, _value);
if(_checkeditem)
_checkeditems.push(_checkeditem);
}
}
}
} while(_item.GetNext());
while(_checkeditems.length > 0)
{
_mindistance = 100000;
for(i = 0; i < _checkeditems.length; i++)
{
if(MWConfig_PickUpPriorityItemsFirst && !_checkeditems[i].HasPriority()) // If the item at index i is a low priority item
{
for(j = 0; j < _checkeditems.length; j++) // Loop through all items in pickup queue
{
if(j == i)
continue;
if(_checkeditems[j].HasPriority())
break;
}
// If the loop was aborted due to a high priority item in the pickup queue, skip the item at index i
if(j < _checkeditems.length)
continue;
}
_value = GetDistance(me.x, me.y, _checkeditems[i].x, _checkeditems[i].y);
if(_value < _mindistance)
{
_minindex = i;
_mindistance = _value;
}
}
_checkeditem = _checkeditems.splice(_minindex, 1)[0];
_item = NTC_FindUnit(NTC_UNIT_ITEM, _checkeditem.GID);
if(_item)
{
if(!NTSI_IsLimitedItemInt(_item))
{
if(MWConfig_ShowOverheadStatus)
MWC_PrintOverheadStatus("Picking up items...");
if(NTT_CheckSpace(_item.xsize, _item.ysize) || _checkeditem.ClassID == 523 || _item.itemtype == 4 || _item.classid == 543 || _item.itemtype == 22 || _item.itemtype >= 76 && _item.itemtype <= 78)
{
MWI_WriteLoc(_item);
if(NTSI_PickUpItemInt(_item))
{
if(_item && _item.name)
{
if(_item.itemtype < 76 || _item.itemtype > 81) // All items except potions
{
Print("Picked up " + NTC_ItemQualityToD2Color[MWC_GetItemColorInt(_item)] + _item.name.split("\n")[0] + ((_checkeditem.Status == 4) ? " ÿc8[" + MWC_InsertDigitSeperator(_item.GetItemCost(1)) + "]" : ""));
NTC_SendMsgToScript("MWBotGame.ntj", "SET_PICKED_1");
if(!pickValuables && MWSI_IsCommonLogItem(_item))
NTC_SendMsgToScript("MWBotGame.ntj", "SET_COMMONITEM_" + _item.classid);
if(_item.quality < 4 && _checkeditem.Status < 2)
{
if(MWConfig_UseXMLItemlog)
MWI_WriteLog(_item, 0);
if(_item.classid <= 609 || _item.classid >= ((MWConfig_LowestRuneToLog < 0 || MWConfig_LowestRuneToLog > 32) ? 0 : MWConfig_LowestRuneToLog) + 610)
MWI_WriteManagerLog(_item, 0);
}
}
else if(MWConfig_ShowPotionPickups)
Print("Picked up " + _item.name.split("\n")[0]);
}
}
}
else
{
if(!_checkeditem.Retry && !pickValuables)
{
_checkeditem.Retry = true;
if(MWConfig_IdentAfterPickup)
MWL_IDItemsAfterPickup(true);
if(!NTT_CheckSpace(_checkeditem.xSize, _checkeditem.ySize))
{
if(!NTTMGR_VisitTown())
return;
}
_checkeditems.push(_checkeditem);
}
}
}
}
}
if(MWConfig_IdentAfterPickup)
MWL_IDItemsAfterPickup();
}
function NTSI_CheckItem(item, checkQuantity)
{
var _result;
if(arguments.length < 2)
checkQuantity = false;
switch(item.quality)
{
case 5:
case 8:
_result = NTIPCheckItem(item, checkQuantity);
break;
default:
_result = NTIPCheckItem(item, checkQuantity);
if(NTCU_CheckItem(item, _result))
_result = 2;
break;
}
if(item.itemflag&0x4000000)
_result = 1;
return _result;
}
// Internal function
function NTSI_ItemInt(item, checkedstatus)
{
this.ClassID = item.classid;
this.GID = item.gid;
this.ItemType = item.itemtype;
this.x = item.x;
this.y = item.y;
this.xSize = item.xsize;
this.ySize = item.ysize;
this.Status = checkedstatus;
this.Retry = false;
this.HasPriority = function()
{
if(this.ItemType >= 91 && this.ItemType <= 102 // Gem
|| this.ItemType >= 76 && this.ItemType <= 81 // Potions
|| this.ClassID == 543 || this.ItemType == 4 // Gold
|| this.ClassID >= 610 && this.ClassID <= 629 // Runes <= FAL
|| this.ClassID == 529 || this.ClassID == 530 // Scrolls
|| this.ClassID == 543) // Keys
return false;
return true;
}
}
function NTSI_PickUpItemInt(snagitem)
{
var _classid;
var _tome, _scrollPreCount;
var _keys, _gold;
_classid = snagitem.classid;
// Save properties that will be invalidated at pickup
_gold = snagitem.GetStat(14);
_keys = snagitem.GetStat(70);
// The successful pickup of a scroll is determined by the change of quantity
if(_classid == 529 || _classid == 530)
{
_tome = NTT_GetTome(Math.abs(snagitem.classid - 530));
if(!_tome)
return false;
_scrollPreCount = _tome.GetStat(70); // Save the quantity before pickup
}
for(var i = 0; i < 40; i++)
{
if((i % 10) == 0 && (snagitem.mode == 3 || snagitem.mode == 5))
{
if(MWConfig_UseTelekinesis && i < 20 && (_classid == 523 || snagitem.itemtype == 4 || _classid == 543 || _classid == 529 || _classid == 530 || snagitem.itemtype >= 76 && snagitem.itemtype <= 81) && NTC_GetSkillLevel(MWS_TELEKINESIS) > 0)
MWC_CastTelekinesis(snagitem);
else
{
if(GetDistance(me, snagitem) > 3)
NTM_MoveTo(snagitem.areaid, snagitem.x, snagitem.y, 3, false, 0, false);
if(NTC_ClearCursor())
NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, snagitem);
}
}
NTC_Delay(NTC_DELAY_FRAME);
if(_classid == 529 || _classid == 530) // Scrolls
{
_tome = NTT_GetTome(Math.abs(_classid - 530));
if(_tome && _tome.GetStat(70) != _scrollPreCount) // The scroll was picked up successfully if the quantity after pickup differs from the one before
return true;
}
else if(_classid == 543) // Keys
{
if(snagitem.GetStat(70) == -1) // The quantity property turns to -1 after the key was picked
{
if(_keys > 1)
Print("Picked up " + _keys + " Keys");
else
Print("Picked up Key");
return true;
}
}
else if(_classid == 523 || snagitem.itemtype == 4) // Gold
{
if(snagitem.GetStat(14) == -1) // The gold property turns to -1 after the gold was picked
{
if(MWConfig_ShowGoldPickupsPerScript)
NTC_SendMsgToScript("MWBotGame.ntj", "SET_SCRIPTGOLD_" + _gold);
if(MWConfig_ShowGoldPickups)
Print("Picked up " + MWC_InsertDigitSeperator(_gold) + " Gold");
return true;
}
if(i % 10 == 0 && NTC_CharGoldFull())
{
NTC_SendMsgToScript("MWBotGame.ntj", "STOP_STATUS_TEXT_UPDATE");
SetStatusText("ÿc8Visiting Town...");
NTTMGR_VisitTown();
SetStatusText("ÿc8Done!");
NTC_SendMsgToScript("MWBotGame.ntj", "SET_DEFAULT_STATUS");
}
return true;
}
else if(snagitem.mode != 3 && snagitem.mode != 5)
return true;
}
return false;
}
function NTSI_IsIgnoredItemInt(classid)
{
for(var i = 0 ; i < _NTSI_IgnoredList.length ; i++)
{
if(classid == _NTSI_IgnoredList[i])
return true;
}
return false;
}
function NTSI_IsLimitedItemInt(item)
{
var i;
var _items, _tome, _keys;
if(item.itemtype >= 76 && item.itemtype <= 78)
{
if(!MWT_IsPotionRequired(item.code))
return true;
}
else if(item.quality == 7 && item.classid >= 603 && item.classid <= 605)
{
_items = me.GetItems(item.classid);
if(_items.length > 0)
return true;
}
else if(item.classid == 529 || item.classid == 530) // Scrolls
{
_tome = NTT_GetTome(Math.abs(item.classid - 530));
if(!_tome || _tome.GetStat(70) == 20 || item.classid == 529 && _tome.GetStat(70) >= MWConfig_MinimumTpScrollCount || item.classid == 530 && _tome.GetStat(70) >= MWConfig_MinimumIdScrollCount)
return true;
}
else if(item.classid == 543) // Keys
{
_keys = MWTMGR_GetKeyQuantity();
if(_keys >= 12 || _keys + item.GetStat(70) > 12)
return true;
}
else if(item.classid == NTC_UNIT_CUBE)
{
_items = me.GetItems(NTC_UNIT_CUBE);
if(_items.length > 0)
return true;
}
else if(NTSI_CheckItem(item, true) == 3)
return true;
return false;
}
function MWSI_PickupItem(search)
{
var _item;
if(arguments.length < 1)
return false;
_item = NTC_FindUnit(NTC_UNIT_ITEM);
if(_item)
{
do
{
if(_item.classid == search || _item.gid == search || _item.name == search || _item.itemprefix == search || _item.itemsuffix == search)
{
if(NTT_CheckSpace(_item.xsize, _item.ysize) && NTSI_PickUpItemInt(_item))
{
MWI_WriteLoc(_item);
Print("Picked up " + NTC_ItemQualityToD2Color[MWC_GetItemColorInt(_item)] + _item.name.split("\n")[0]);
if(MWSI_IsCommonLogItem(_item))
NTC_SendMsgToScript("MWBotGame.ntj", "SET_COMMONITEM_" + _item.classid);
if(GetUIState(0x01) && me.itemoncursor)
{
NTCU_CheckCubeInventoryInt();
NTCU_MoveItemToInventoryInt(_item);
}
return true;
}
}
} while(_item.GetNext());
}
return false;
}
function MWSI_IsCommonLogItem(item)
{
if(item.classid >= 610 && item.classid <= 642) // Rune
return true;
if(item.classid >= 647 && item.classid <= 657) // Key/Organ/Essence
return true;
if(item.itemtype >= 91 && item.itemtype <= 102) // Gem
return true;
return false;
}
function MWSI_IsValuable(item)
{
if(item.quality >= 2)
{
if(item.itemtype == 12 || item.itemtype == 24 || item.itemtype == 25 && item.quality > 3 || item.itemtype == 74 && item.classid >= 622) // Amulets/Scepters/Wands/Runes >= SHAEL
return true;
if(item.itemclass >= 1)
{
switch(item.itemtype)
{
case 19: // Belts
case 32: // Knives
case 37: // Helms
case 42: // Throwing Knives
case 67: // Claws
if(item.quality < 4)
break;
case 3: // Armors
case 65: // Circlets
case 68: // Orbs
return true;
}
}
if(item.itemclass >= 2)
{
switch(item.itemtype)
{
case 2: // Shields
case 32: // Knives
case 37: // Helms
case 69: // Voodooheads
case 72: // Pelts
return true;
case 15: // Boots
case 16: // Gloves
case 42: // Throwing Knives
case 67: // Claws
if(item.quality > 3)
return true;
}
}
switch(item.classid)
{
case 196: // Tomahawk
case 210: // Truncheon
case 214: // Tyrant Club
case 215: // Reinforced Mace
case 216: // Devil Star
case 221: // Falcata
case 222: // Ataghan
case 223: // Elegant Blade
case 224: // Hydra Edge
case 226: // Conquest Sword
case 227: // Cryptic Sword
case 228: // Mythical Sword
case 240: // Flying Axe
case 259: // Walking Stick
case 324: // Gothic Plate
case 325: // Full Plate Mail
case 326: // Ancient Armor
case 498: // Sacred Target
case 499: // Sacred Rondache
case 502: // Vortex Shield
return true;
}
}
if(MWT_IsSellable(item) && item.GetItemCost(1) >= 25E3)
return true;
return false;
}