// default.dbj gets executed upon gamejoin
var sh = null;
js_strict(true);
function main()
{
sendCopyData(null, "OOG", 0,me.classid+" classid");
while(!me.area ) {
sendCopyData(null, "OOG", 0,"pregame delay");
delay(100);
}
var NT_StartTime= getTickCount();
//print ("me.getItemNew.length "+i.length)
//var a = new Object();
//a = new NpcGetItem(me,null,null,null);
if(me.itemoncursor){ // checks to see if you have a merc weapon on cursor puts it on merc it can else stops
var item = getUnit(100);
if (item){
if (item.bodylocation ==4 && item.getFlag(0x4000000)){
var merc = me.getMerc();
if (merc){
var mercItems = merc.getItems();
var hasWep = false;
for(var i = 0 ; i < mercItems.length ; i++){
if (mercItems[i].bodylocation ==4)
hasWep= true;
}
if (!hasWep){
print("trying to reset merc weapon");
clickItem(4, 4);
delay(1000);
}
}
if(me.itemoncursor){
print("item on curor runeword wep stopping")
sendCopyData(null, "OOG", 0,"Stop Me");
var a =getScript();
do{
if(a.name == "default.dbj") {
a.stop();
break;
}
}while(a.getNext());
}
}
}
} //end item on cursor check
print("ÿc9NTBot by Bobite rev: 219");
sendCopyData(null, "OOG", 0,"In Game");
dumpInventory();
addEventListener("itemdrop", dropHandler);
addEventListener("itemaction",dropHandlerNew);
addEventListener("keyup", KeyHandler);
//addEventListener("copydata",ScriptMsg);
//addEventListener("chatcmd", GameMSG);
addEventListener("gamemsg", GameMSG);
include("common/HookedControls.dbl");
include("common/NTCommon.dbl");
include("itemlogger.dbl");
NTC_IncludeConfig();
NTC_IncludeLibs();
NT_LoadConfig();
NTSI_LoadNIPFiles();
sendCopyData(null, "OOG", 0,"Info "+NTAR_Areas[me.area]);
if(NTConfig_StartDelay > 0);
NTC_Delay(NTConfig_StartDelay);
NTA_Initialize();
NTT_GetCorpses();
NTSI_PickItems();
if(NTConfig_Script.length > 0)
{
//Script::CompileFile("yourscript.dbj")->Run();
NTC_Include("bots/NTLoader.dbl");
if(NTConfig_Script[0] !="SimonSays"){
NTT_ClearInventory();
NTT_ClearBelt();
}
load("tools/NTToolsThread.dbj");
NTC_Delay(500);
NT_Loader();
}
sendCopyData(null, "OOG", 0,"Quit:Full Run" );
NTC_Delay(500);
if(NT_MinGameTime){
if(getTickCount()-NT_StartTime < NT_MinGameTime *1000){
me.overhead ("Stalling for "+parseInt(((NT_StartTime + ( NT_MinGameTime *1000))-getTickCount())/1000)+ " Seconds");
NTTM_CheckAct()
NTTMGR_TownManager();
while (getTickCount()-NT_StartTime < NT_MinGameTime *1000){
me.overhead ("Stalling for "+parseInt(((NT_StartTime + ( NT_MinGameTime *1000))-getTickCount())/1000)+ " Seconds");
NTC_Delay(1000);
}
}
}
quit();
}
function dropHandler(id,code,x,y,mode)
{
//sendCopyData(null, "OOG", 0,"Drop: "+id);
for (var i=0 ; i < Bob_ItemList.length ; i++){
if (Bob_ItemList[i]==id) return true; //aready there
}
Bob_ItemList.push(id);//,code,x,y,mode);
return true;
}
function dropHandlerNew(id,mode,code,global)
{
//print("itemaction id:"+id +" mode: "+mode + " code: "+code +" global "+ global);
if (mode == 0 || mode == 2 || mode == 3){
// sendCopyData(null, "OOG", 0,"Drop: "+id);
for (var i=0 ; i < Bob_ItemList.length ; i++){
if (Bob_ItemList[i]==id) return true; //aready there
}
Bob_ItemList.push(id);//,code,x,y,mode);
return true;
}
return true;
}
function KeyHandler(key,arg2)
{
sendCopyData(null, "OOG", 0,"key press: "+key);
if (key==19){
if (getTickCount()-NT_LastPause>200){
NT_Pause = !NT_Pause;
NT_LastPause=getTickCount();
if (NT_Pause){
print("ÿc;Pausing Bot...(Press 'Pause' again to resume)");
me.overhead("Pausing Bot...(Press 'Pause' again to resume)");
} else{
print("ÿc2Resuming Bot...");
me.overhead("Resuming Bot...");
}
}
}
if (key == 123) { //f12
me.overhead("Reavealing " + NTAR_Areas[me.area]);
print("Reavealing " + NTAR_Areas[me.area]);
RevealArea(me.area);
}
if (key==122) { //f11
var _target = NTC_GetUnit(0);
if(_target)
{
sendCopyData(null, "OOG", 0,"ShowInventory" );
do
{
var items=_target.getItems();
if(items){
for(var i = 0 ; i < items.length ; i++)
{
sendCopyData(null, "OOG", 0,"dump "+_target.name+" " +items[i].toSource());
}
}
} while(_target.getNext());
sendCopyData(null, "OOG", 0,"ShowInventoryEnd" );
}
}
if(key ==120){//f9
print("x: "+me.x+" y: "+me.y)
var unit = getPresetUnits(me.area);
if(unit){
for (var j = 0; j < unit.length; j++)
sendCopyData(null, "OOG", 0,"preset id "+unit[j].id+" x: "+(unit[j].roomx*5+unit[j].x)+" y: "+(unit[j].roomy*5+unit[j].y)+" Dist" +getDistance(me.x,me.y,unit[j].roomx*5+unit[j].x,unit[j].roomy*5+unit[j].y));
}
}
if(key ==107){
var _OSC = "ÿc!X:ÿc< "+me.x+ " " +"ÿc!Y:ÿc< "+me.y
print(_OSC)
for (var n = 0; n < 5; n++) {
me.overhead(_OSC);
}
}
if(typeof(scriptKeyHandler) == 'function')
scriptKeyHandler(key)
//sendCopyData(null, me.windowtitle, 0,"Woohooo" );
//var a =getScript();
//do{
// print("script name:"+a.name+" running :"+a.running);
//}while(a.getNext);
return true;
}
function GameMSG(str1,str2)
{
sendCopyData(null, "OOG", 0,str1+":"+str2 );
print(str1);
return true;
}
function ScriptMsg(mode,mes){
print("Default recived:"+mes);
}
function keepAlive(){
}
function rnd(min,max){ //keeping up with d2bs 1.5
if(typeof(rand) == 'function')
return rand(min,max);
else
return Math.floor(Math.random()*(max-min)+1)+min;
}
function RevealArea(area)
{
if(area in revealedAreas)
return;
revealedAreas.push(area);
var room = getRoom(area);
var roomsRevealed = [];
do {
if(room == undefined || room.area != area)
return; // exit when we've finished with the rooms for this area
if([room.x, room.y] in roomsRevealed)
{
roomsRevealed.push([room.x, room.y]);
room.getNext();
}
else
room.reveal(true);
} while(room.getNext());
}
function dumpInventory()
{
var items=me.getItems();
if(items){
sendCopyData(null, "OOG", 0,"dump_Start "+me.name +"@" +me.account);
for(var i = 0 ; i < items.length ; i++)
{
sendCopyData(null, "OOG", 0,"dump " +items[i].toSource());
}
sendCopyData(null, "OOG", 0,"dump_End "+me.name +"@" +me.account);
}
}