empty inventory before going to worldstone chamber

08/21/2010 23:58 stairbuilder#1
I just copy pasted this from my post on GV because I am lazy, lol

icu requested this a day or 2 ago and the easy fix was NTTMGR_VisitTown();

I decided to play around with it a bit and came up with this and decided I would post it here so the pub runners around here would have it before the next etalBot update and also to help drum up some more channel runners for op gotv
before I forget thanks to icu for helping me test this

this also will help the bug of missed items after killing baal, going to town and then going back to worldstone for items


first you need to add these lines to your character configs in with the other baal configs
Code:
				NTConfig_TownBeforeBaal = true;//check inventory and go to town if any items before going to worldstone to kill baal.  must have NTConfig_FreeSpace configured correctly			
			NTConfig_FreeSpaceBeforeBaal = 6;//# of free columns you want if less than that it bot will town
next open up your scripts/libs/common/NTTown.ntl and at the bottom add this
Code:
function NTT_CheckInventoryBeforeBaal()
{
	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;
			}
		}
	}

	_freecolss = new Array(10);

	for(x = 0 ; x < 10 ; x++)
		_freecolss[x] = 0; 

	for(x = 0 ; x < 10 ; x++)
	{
		for(y = 0 ; y < 4 ; y++)
		{
			if(_invspace[y][x] == 1)
			{
				_freecolss[x] = 1;
				break;
			}
		}
	}

	_numfreecolss = 0;

	for(x = 0 ; x < 10 ; x++)
	{ 
		if(_freecolss[x] == 0)
			_numfreecolss++;
	}

	if(NTConfig_FreeSpaceBeforeBaal > _numfreecolss)
	{
		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;
}
could have modded the checkinventory function here but I seem to have an affinity for screwing things up when I modd existing functions, lol

now going into your bots/NTBaal.ntj and add the red part
Code:
	
	if(NTConfig_KillBaal)
	{
		var _portal;

		if(NTConfig_PublicMode)
			Say(Baal_KillBaalMessage);

		[COLOR="red"][B]if(NTConfig_TownBeforeBaal && NTT_CheckInventoryBeforeBaal())
			NTTMGR_VisitTown(); 
[/B][/COLOR]
		if(!NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe))
		{
			NTC_SendMsgToScript("NTBotGame.ntj", "NTTMGR_CheckSafe()");
			return;
		}

		NTM_MoveTo(me.areaid, 15092, 5010);
configure the NTConfig_FreeSpaceBeforeBaal = ; to how many free columns you want to have before going to baal. If it is less than that the bot will town before

you can use this for chaos script by adding the line in before killing diablo also

I only lightly tested this, but seems to work perfect
enjoy!!!
08/22/2010 19:24 Muddy Waters#2
I actually think it wasn't even necessary writing a function for this, cause there are standard D2NT that do pretty much the same, but anyway. :)

If I were you, I'd do something about those nasty undeclared variables in there. :p

Regards
Muddy
08/22/2010 20:28 stairbuilder#3
Quote:
Originally Posted by Muddy_Waters View Post
I actually think it wasn't even necessary writing a function for this, cause there are standard D2NT that do pretty much the same, but anyway. :)

If I were you, I'd do something about those nasty undeclared variables in there. :p

Regards
Muddy
actually covered that
Quote:
Originally Posted by stairbuilder View Post
could have modded the checkinventory function here but I seem to have an affinity for screwing things up when I modd existing functions, lol
always remember that I am an old carpenter that until about 2 years ago could barely check his e-mail, lmao
there are huge benefits growing up in the age most of you did. The only thing I was exposed to in school was dos.

I'm just happy when things work as expected, more or less, and as I continue to learn I revisit my work and put a better polish on them:D

thanks for the input always appreciated:handsdown:

*edtit
btw this is just a renamed version of the check inventory function with a couple changes made to it
not really sure where you are seeing undeclared variables either
bottom line is as I said it works and was just trying to give something here on pvp's because I look at the work people do around here quite a bit.