[Release] Muddy's D2NT

07/17/2011 21:58 Thomas Gürtler#2536
hey leute mal ne frage-->

spiel schon lange zeit mit d2nt bluebird, aber der is in manchen gebieten überarbeitungswürdig sag ich mal so.

deshalb wollte ich mal muddys ausprobieren wegen der guten rezessionen, aber jedes mal wenn der einen magic ring aufnimmt oder gambled, dann kommt ein shutdown des systems.

HALT
Location: line#2245
Expression: Unrecoverable internal error6fb422e5

kann mir wer sagen was das is ?

und wie bekomm ich die blöden ansagen weg, was er grade macht xD

danke schon mal fürs helfen
07/17/2011 22:06 AmonRa#2537
Quote:
Originally Posted by Thomas Gürtler View Post
hey leute mal ne frage-->

spiel schon lange zeit mit d2nt bluebird, aber der is in manchen gebieten überarbeitungswürdig sag ich mal so.

deshalb wollte ich mal muddys ausprobieren wegen der guten rezessionen, aber jedes mal wenn der einen magic ring aufnimmt oder gambled, dann kommt ein shutdown des systems.

HALT
Location: line#2245
Expression: Unrecoverable internal error6fb422e5

kann mir wer sagen was das is ?

und wie bekomm ich die blöden ansagen weg, was er grade macht xD

danke schon mal fürs helfen
Na haben wir d2 nicht auf Englisch ?

und zum status:MWConfig_ShowOverheadStatus = false; in der MWConfig_GlobalSettings.ntl


mfg AmonRa
07/17/2011 22:13 Thomas Gürtler#2538
könnte sein xD muss ich dann alle versionen meiner d2 ordner in eglish ausführen?

hab 3 mal diablo am rennen. und will wenn ich manuell bzw. mit bluebird spiele ned immer umschreiben müssen, aber da gibts wohl keine alternative lösung dafür oder?

danke schon mal

mfg ToM
07/17/2011 22:19 AmonRa#2539
Quote:
Originally Posted by Thomas Gürtler View Post
könnte sein xD muss ich dann alle versionen meiner d2 ordner in eglish ausführen?

hab 3 mal diablo am rennen. und will wenn ich manuell bzw. mit bluebird spiele ned immer umschreiben müssen, aber da gibts wohl keine alternative lösung dafür oder?

danke schon mal

mfg ToM
[Only registered and activated users can see links. Click Here To Register...]
Da unter Guides/Tutorials findest du drei Anleitungen.
07/18/2011 00:13 fred9x9#2540
Quote:
Originally Posted by DeathFromHeaven View Post
Code:
// This is the minimum time in seconds for your char to remain in a single game. Your char will not exit the game before this time elapsed.
	me.mingametime = 270;
diese falls du nicht willst dass er im Game stehen bleibt, und diese, falls er dir in der Lobby zu lange wartet:

Code:
var GameMinLength				= 180000;		// time in milliseconds, minimum game length, 180 seconds default (1 game/3 minutes)
erstere befindet sich in der Charconfig und zweitere in der NTBot.ntj
Ja danke DeathFromHeaven, aber das hilft ja nix, da in Classic das Game bei Dia automatisch nach ~90 sec.beendet wir. Und wenn dann die mingametime nicht vor Ablauf erreicht wird, crashed es. Und die Mingamtime braucht man, damit nicht mehr als 20 game p.h. erstellt werden.
07/18/2011 08:31 DeathFromHeaven#2541
Quote:
Originally Posted by modw89 View Post
kann mir wer sagen welchen delay ich runterschrauben muss wenn der bot das game vorzeitig verlässt?[z.b. bei skip wenn puppets im tron sind]
hatte mich auch eigentlich auf ihn bezogen, da gehe ich von aus, dass er nicht classic spielt :P
07/18/2011 12:48 Muddy Waters#2542
Quote:
Originally Posted by fred9x9 View Post
Genau so ist es Muddy.
Meist nicht nur ein Restart, sondern ein Hänger beim Ausloggen,
bis der Server dich rausschmeißt.
Aber man weiß ja, ich kann deinen Vorschlag leider nicht umsetzen. :p
Zumal der Timer noch an der "richtigen" Stelle, mit den richtigen Informationen sitzen müsste, damit Lod Player nicht davon betroffen werden.
LG
Fred
So furchtbar groß ist der Aufwand nicht, zwei neue Variablen, einen case im Script Message Handler und eine if-Anweisung innerhalb der Endlosschleife.
Kannst mir ja mal deine derzeitige MWBotgGame.ntj zukommen lassen, dann passe ich es dir schnell an. ;)

Quote:
Originally Posted by mirkoregge View Post
Hallo,
ich habe immer noch das Problem wie in diesem [Only registered and activated users can see links. Click Here To Register...] beschrieben. Sobald der Bot Chicken, Waypointbug oder Joinbug hat, hängt sich die Game.exe auf. Der Fehler tritt auch auf, wenn man das Game manuell beendet (Ende-Taste). Es ist ein kurer Fehlerton seitens Windows 7 zu hören. Das Bild friert ein und nix passiert mehr. Im Manager erfolgt zwar ein Neustart, aber auch der bleibt in einer Endlosschleife. Hatte die letzte Version hier gedownloaded. Hoffe mir kann jemand helfen. Danke. Bis Freitag ;)
Um das zu beheben, müsste ich erstmal wissen, wodurch es genau ausgelöst wird. Da ich absolut keinen Anhaltspunkt habe, lässt sich das leider schwer umsetzen... :(

LG
Muddy
07/18/2011 13:50 fred9x9#2543
Quote:
Originally Posted by Muddy_Waters View Post
So furchtbar groß ist der Aufwand nicht, zwei neue Variablen, einen case im Script Message Handler und eine if-Anweisung innerhalb der Endlosschleife.
Kannst mir ja mal deine derzeitige MWBotgGame.ntj zukommen lassen, dann passe ich es dir schnell an. ;)


Um das zu beheben, müsste ich erstmal wissen, wodurch es genau ausgelöst wird. Da ich absolut keinen Anhaltspunkt habe, lässt sich das leider schwer umsetzen... :(

LG
Muddy
Im Voraus schon mal ein kleines DANKE.
Solte eigentlich die von dir zuletzt veröffentlichte sein.
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: 02/26/2011
*/
// Global constants
const _MWBG_CHAT_COMMAND_TRIGGER = '.';

// Global variables
var _MWBG_ExperienceThresholds = new Array(
500, 1500, 3750, 7875, 14175, 22680, 32886, 44396,																		// Level 2 - 9
57715, 72144, 90180, 112725, 140906, 176132, 220165, 275207, 344008, 430010,											// Level 10 - 19
537513, 671891, 839864, 1049830, 1312287, 1640359, 2050449, 2563061, 3203826, 3902260,									// Level 20 - 29
4663553, 5493363, 6397855, 7383752, 8458379, 9629723, 10906488, 12298162, 13815086, 15468534,							// Level 30 - 39
17270791, 19235252, 21376515, 23710491, 26254525, 29027522, 32050088, 35344686, 38935798, 42850109,						// Level 40 - 49
47116709, 51767302, 56836449, 62361819, 68384473, 74949165, 82104680, 89904191, 98405658, 107672256,					// Level 50 - 59
117772849, 128782495, 140783010, 153863570, 168121381, 183662396, 200602101, 219066380, 239192444, 261129853,			// Level 60 - 69
285041630, 311105466, 339515048, 370481492, 404234916, 441026148, 481128591, 524840254, 572485967, 624419793,			// Level 70 - 79
681027665, 742730244, 809986056, 883294891, 963201521, 1050299747, 1145236814, 1248718217, 1361512946, 1484459201,		// Level 80 - 89
1618470619, 1764543065, 1923762030, 2097310703, 2286478756, 2492671933, 2717422497, 2962400612, 3229426756, 3520485254);// Level 90 - 99

var _MWBG_CurScriptIndex = 0;
var _MWBG_CurScriptEndTick = GetTickCount();
var _MWBG_CurScriptStartTick = GetTickCount();

var _MWBG_LastScript = false;
var _MWBG_UserExit = false;

var _MWBG_Statistics;
var _MWBG_WorldEventData;

var _MWBG_ShowStatusText = true;
var _MWBG_ShowCurrentPing = false;

var _MWBG_PositionsPrinted = new Array();

function MW_GameStatistics()
{
	this.Potions = new Array();
	this.Potions.Hp = 0;
	this.Potions.Mp = 0;
	this.Potions.Rv = 0;
	
	this.Init = new Array();
	this.Init.Ticks = GetTickCount();
	this.Init.Exp = me.GetStat(13);
	this.Init.CharLevel = me.GetStat(12);
	this.Init.Gold = me.GetStat(14) + me.GetStat(15);
	
	this.CommonLog = new Array();
	this.CorpsesLooted = 0;
	this.ChestsOpened = 0;
	this.ShrinesUsed = 0;
	this.ItemsPicked = 0;
	this.ScriptGold = 0;
	this.Errors = 0;
}

function MW_WorldEventData()
{
	this.SojSoldString = GetLocaleString(11004).replace("%d ", "");
	this.DiabloWalkString = GetLocaleString(11005);
	
	this.Count = new Array();
	this.Count.Message = 0;
	this.Count.Recent = 0;
	this.Count.Last = 0;
	this.Count.Init = 0;
	
	this.Loop = new Array();
	this.Loop.Runtime = 0;
	this.Loop.Mode = 0;
	this.Loop.Running = false;
	
	this.InitTicks = 0;
}

function NTMain()
{
	SetStatusText("ÿc8Initializing...");
	
	Include("libs/common/NTCommon.ntl");
		
	NTC_IncludeLibs();
	NTC_IncludeConfig("NTBot/char_configs");
	
	NT_LoadConfig();
	NTSI_LoadNIPFiles("NTBot/item_configs");
	
	var _script, _loops;
	
	_MWBG_Statistics = new MW_GameStatistics();
	_MWBG_WorldEventData = new MW_WorldEventData();	
		
	NTC_Delay(NTConfig_StartDelay);
	
	if(!_MWBG_Statistics || !_MWBG_WorldEventData)
		ExitGame();
		
	if(MWConfig_UseXMLItemlog)
	{
		if(MWI_WriteTempLogToXML())
			MWI_ClearTempLog();
	}
	
	MWI_ClearLoc();
	
	SetUIState(0x0A, true);
	
	NTT_GetCorpses();

	if(MWConfig_ExitGameOnMissingPassword && !me.gamepassword)
	{
		SetStatusText("ÿc1Exiting game...");
		ExitGame();
	}

	if(MWConfig_Script.length > 0)
	{
		NTCU_InitCubing();
			
		Load("NTBot/tools/NTToolsThread.ntj");

		RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);
		RegisterEvent(EVENT_KEYDOWN, NT_KeyEvents);
		RegisterEvent(EVENT_SCRIPTMSG, NT_ScriptMsgEvents);

		MW_ResetTicks();

		Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);

		_loops = 0;
		
		while(!_MWBG_LastScript && me.ingame)
		{
			MW_SetStatusText();
			
			if(GetTickCount() >= _MWBG_CurScriptEndTick && MWConfig_Script[_MWBG_CurScriptIndex][1] != 0 && !isNaN(MWConfig_Script[_MWBG_CurScriptIndex][1]) && !NTC_InTown() && !_MWBG_WorldEventData.Loop.Running)
			{
				_script = NTC_FindScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
				
				if(_script && _script.running)
				{
					Print("ÿc;" + MWConfig_Script[_MWBG_CurScriptIndex][0] + "ÿc8 is skipped due to exceeding the maximum runtime of ÿc;" + MWConfig_Script[_MWBG_CurScriptIndex][1] + "ÿc8 minutes!");
					
					NT_ScriptMsgEvents("SCRIPT_END");
				}
			}
			
			NTC_Delay(500);
			
			if(!_MWBG_LastScript && _MWBG_Statistics.Errors > MWConfig_GameErrorLimit)
			{
				
				NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);

				_MWBG_LastScript = true;
			}
			
			if(_loops++ % 40 == 0)
				MW_UpdateCommonLog();
		}
	}
	
	UnregisterEvent(EVENT_GAMEMSG);
	UnregisterEvent(EVENT_KEYDOWN);
	UnregisterEvent(EVENT_SCRIPTMSG);
	
	MW_UpdateCommonLog();
	
	MW_CheckMinGametime();
	
	SetStatusText("ÿc1Exiting game...");

	if(me.ingame)
		MW_PrintOutputString(_MWBG_UserExit);
	
	me.revealautomap = false;
	me.showmissileonautomap = false;
	me.showenemyonautomap = false;

	if(!NTC_InTown() && !_MWBG_UserExit)
		NTSI_PickItems(true);

	ExitGame();
}

function NT_GameMsgEvents(msg, type)
{
	var _message, _messenger, _output, _date;
	var i;	
	
	if(type == 0)
	{
		_message = msg.split("ÿc0: ")[1]; // Extract the message
	 
		if(_message.substr(0, _MWBG_CHAT_COMMAND_TRIGGER.length) != _MWBG_CHAT_COMMAND_TRIGGER)
			return;
			
		_message = _message.substr(_MWBG_CHAT_COMMAND_TRIGGER.length, _message.length); // Remove the trigger
		
		_messenger = msg.split("ÿc0: ")[0].replace("ÿc4", ""); // Extract the name of the char that wrote the message
		
		if(_messenger == me.charname && _message.toLowerCase().indexOf("run") == 0)
		{
			for(i = 0; i < MWConfig_Script.length; i++)
			{
				if(MWConfig_Script[i][0].toLowerCase().indexOf(_message.toLowerCase().split(" ")[1]) > -1)
					break;
			}

			if(i < MWConfig_Script.length)
			{
				Print("ÿc8Switching to ÿc;" + MWConfig_Script[i][0] + "ÿc8...");
				
				NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
				
				NTC_Delay(250);
				
				_MWBG_CurScriptIndex = i - 1;
				
				NT_ScriptMsgEvents("SCRIPT_END");
			}
			else
				Print("ÿc1There is no script activated matching the term '" + _message + "'!");
				
			return;
		}
		
		NTC_SendMsgToScript("MWRush.ntj", _messenger + " " + _message.toUpperCase());
	}
	
	if(type == 4)
	{
		if(MWConfig_CheckSojSales && msg.indexOf(_MWBG_WorldEventData.SojSoldString) > -1)
		{
			me.maxgametime = 0;
			
			NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
			NTC_Delay(200);
			
			_MWBG_WorldEventData.Count.Last = _MWBG_WorldEventData.Count.Recent;
			_MWBG_WorldEventData.Count.Recent = parseInt(msg.split(" ")[0]);
			_MWBG_WorldEventData.Count.Message++;
			
			if(_MWBG_WorldEventData.Count.Init == 0)
			{
				_MWBG_WorldEventData.Count.Init = _MWBG_WorldEventData.Count.Recent;
				_MWBG_WorldEventData.InitTicks = GetTickCount();
			}
		
			if(!_MWBG_WorldEventData.Loop.Running)
			{
				_MWBG_WorldEventData.Loop.Runtime = _MWBG_WorldEventData.Count.Message*10*60E3;
				_MWBG_WorldEventData.Loop.Mode = 1;
			}
			else if(_MWBG_WorldEventData.Loop.Mode == 1)
				_MWBG_WorldEventData.Loop.Runtime = _MWBG_WorldEventData.Count.Message*5*60E3;
				
			_output = "ÿc4" + msg;
			_output += ";ÿc0Game:ÿc8 " + me.gamename  + "//" + me.gamepassword;
			_output += "\nÿc0Server IP:ÿc8 " + me.gameserverip.split(".")[3];
			_output += "\nÿc0Message Count:ÿc8 " + _MWBG_WorldEventData.Count.Message; 
			_output += "\nÿc0Sojs Total:ÿc8 " + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Init) + " [+" + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Last) + "]";
			
			_date = new Date(_MWBG_WorldEventData.InitTicks);
			
			if(_date)
			{
				_output += "\nÿc0First Message:ÿc8 " + _date.toLocaleFormat("%H:%M:%S");
				_output +=  " [-" + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_Statistics.Init.Ticks) + "]";
			}
			
			_output += "\nÿc0Waitingÿc8 " + (_MWBG_WorldEventData.Loop.Runtime / 60E3) + " ÿc0minutes";
			
			NTC_SendLogToOOG(NTC_LOG_COMMON, _output);
			
			if(!_MWBG_WorldEventData.Loop.Running)
			{
				MW_AntiIdle();
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
			}
		}
		else if(NTConfig_CheckCloneDiablo && msg.indexOf(_MWBG_WorldEventData.DiabloWalkString) > -1)
		{
			me.maxgametime = 0;
			
			_output = "ÿc4" + msg;
			_output += ";ÿc0Game:ÿc8 " + me.gamename  + "//" + me.gamepassword;
			_output += "\nÿc0Server IP:ÿc8 " + me.gameserverip.split(".")[3];
			_output += "\nÿc0Message Count:ÿc8 " + _MWBG_WorldEventData.Count.Message; 
			_output += "\nÿc0Sojs Total:ÿc8 " + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Init) + " [+" + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Last) + "]";
			
			_date = new Date(_MWBG_WorldEventData.InitTicks);
			
			if(_date)
			{
				_output += "\nÿc0First Message:ÿc8 " + _date.toLocaleFormat("%H:%M:%S");
				_output +=  " [-" + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_Statistics.Init.Ticks) + "]";
			}
			
			NTC_SendLogToOOG(NTC_LOG_COMMON, _output);

			NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
			NTC_Delay(200);

			_MWBG_WorldEventData.Loop.Runtime = 0;
			_MWBG_WorldEventData.Loop.Mode = 0;
			
			if(!_MWBG_WorldEventData.Loop.Running)
				MW_AntiIdle();
		}
	}
}

function NT_KeyEvents(keycode)
{
	//Print("Keycode: " + keycode);
	var _script = NTC_FindScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
	
	switch(keycode)
	{
		case 19: // Pause (PAUSE)
			if(_script)
			{
				if(_script.running)
				{
					_MWBG_ShowStatusText = false;
					_script.Stop();
					
					me.maxgametime = 0;
					
					NTC_Delay(250);
					
					ClickMap(NTC_CLICK_LUP, NTC_SHIFT_NONE, null);
					
					SetStatusText("ÿc1Stopped ÿc4" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
					
					NTC_Delay(500);
				}
				else
				{
					if(_MWBG_WorldEventData.Loop.Running)
					{
						_MWBG_WorldEventData.Loop.Running = false;
						NTC_Delay(500);
					}
					
					MW_ResetTicks();
					
					Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
				}
				
				NT_ScriptMsgEvents("SET_DEFAULT_STATUS");
			}
			break;
		case 33: // Skip (PGUP)
			_MWBG_ShowStatusText = false;
			SetStatusText("ÿc1Skipping current script...");
			_MWBG_WorldEventData.Loop.Running = false
			if(!_script)
				break;
			if(_script.running)
				_script.Stop();
			
			NTC_PingDelay(250);
			NT_ScriptMsgEvents("SCRIPT_END");
			break;
		case 34: // Repeat (PGDN)
			_MWBG_ShowStatusText = false;
			SetStatusText("ÿc1Repeating previous script...");
			_MWBG_WorldEventData.Loop.Running = false
			if(!_script)
				break;
			if(_script.running)
				_script.Stop();
			
			NTC_PingDelay(250);
			NT_ScriptMsgEvents("SCRIPT_REPEAT");
			break;
		case 35: // Clear current XML logfile (END)
			_MWBG_ShowCurrentPing = !_MWBG_ShowCurrentPing;
			break;
		case 36: // Show coordinates (POS1/HOME)
			MW_PrintPosition();
			break;
		case 46: // Exit (DEL)
			if(_MWBG_LastScript)
				return;
			
			SetStatusText("ÿc1Exiting game...");

			_MWBG_WorldEventData.Loop.Running = false
			_MWBG_ShowStatusText = false;
			
			_MWBG_UserExit = true;
			_MWBG_LastScript = true;
			
			if(NTConfig_PublicMode)
				Say("Next game!");
				
			break;
		case 45: // Log stashed items (INS)
			_MWBG_ShowStatusText = false;
			SetStatusText("ÿc8Logging current stash to " + ((MWConfig_LogStashToTxt) ? "TXT" : "XML") + "...");
			if(MWI_LogStashedItems())
				SetStatusText("ÿc8Done!");
			else
				SetStatusText("ÿc1Logging failed!");
			NT_ScriptMsgEvents("SET_DEFAULT_STATUS");
			break;
		default:
			MWUC_HandleUserCommand(keycode, _MWBG_Statistics, _MWBG_CurScriptIndex);
			break;
	}
}

function MW_PrintPosition()
{
	var _color;
	
	_MWBG_PositionsPrinted.push([me.x, me.y, me.areaid]);
	
	if(_MWBG_PositionsPrinted.length > 2)
		_MWBG_PositionsPrinted.splice(0, 1);
		
	_color = MWC_GetRandomColor();
		
	Print(_color + "Current Position: ÿc0(ÿc2" + _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][0] + "ÿc0|ÿc1" + _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][1] + "ÿc0) [ÿc7" + _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][2] + "ÿc0]");
	
	if(_MWBG_PositionsPrinted.length > 1)
		Print(_color + "Last Position: ÿc0(ÿc2" + _MWBG_PositionsPrinted[0][0] + "ÿc0|ÿc1" + _MWBG_PositionsPrinted[0][1] + "ÿc0) [ÿc7" + _MWBG_PositionsPrinted[0][2] + "ÿc0] (ÿc7Distance: " + GetDistance(_MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][0], _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][1], _MWBG_PositionsPrinted[0][0], _MWBG_PositionsPrinted[0][1]).toFixed(2) + "ÿc0)");	
}

function NT_ScriptMsgEvents(msg)
{
	var _area, _msg, _fhandle, _buffer, _script;
	
	if(!msg)
		return;
	
	if(msg.split("_")[0] == "SET" && msg.indexOf("SET_DEFAULT_STATUS") == -1)
	{
		MW_EvaluateInputData(msg);
		
		return;
	}
	
	switch(msg)
	{
		case "SCRIPT_END":
			_MWBG_ShowStatusText = false;
			NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
			
			if(++_MWBG_CurScriptIndex < MWConfig_Script.length)
			{
				if(MWConfig_ShowGoldPickupsPerScript)
				{
					if(_MWBG_Statistics.ScriptGold > 0)
						Print("ÿc8Picked up ÿc;" + MWC_InsertDigitSeperator(_MWBG_Statistics.ScriptGold) + "ÿc8 gold running ÿc;" + MWConfig_Script[_MWBG_CurScriptIndex - 1][0]);
					
					_MWBG_Statistics.ScriptGold = 0;
				}

				MW_ResetTicks();
				
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
				_MWBG_ShowStatusText = true;
			}
			else
				_MWBG_LastScript = true;
			break;
		case "SCRIPT_REPEAT":
			_MWBG_ShowStatusText = false;
			if(_MWBG_CurScriptIndex - 1 >= 0)
			{
				_MWBG_CurScriptIndex--;

				MW_ResetTicks();
				
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
			}
			else
			{
				SetStatusText("ÿc1Cannot repeat - Invalid Index!");
				NTC_PingDelay(250);

				MW_ResetTicks();
				
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
			}
			_MWBG_ShowStatusText = true;
			break;
		case "SET_DEFAULT_STATUS":
			NTC_Delay(2500);
			_MWBG_ShowStatusText = true;
			break;
		case "STOP_STATUS_TEXT_UPDATE":
			_MWBG_ShowStatusText = false;
			break;
		case "RESET_TICKS":
			MW_ResetTicks();
			break;
		case "EXIT_GAME":
			SetStatusText("ÿc1Exiting game...");

			_MWBG_WorldEventData.Loop.Running = false
			_MWBG_ShowStatusText = false;
			
			_MWBG_UserExit = true;
			_MWBG_LastScript = true;
			break;
		default:
			_msg = new Array();
			
			_msg.push(msg);
			_msg.push("");
			
			_fhandle = FileOpen("Logs/Temporary Data/"+ me.charname + ".errdata", 2);
			
			if(_fhandle)
			{
				while(!_fhandle.eof)
				{
					_buffer = _fhandle.ReadLine();
					
					if(_buffer != "" && _buffer.indexOf("//") == -1)
					{
						if(_msg[1] != "")
							_msg[1] += "\n";
						
						_msg[1] += _buffer;
					}
				}
				
				_fhandle.Close();
				
				_fhandle = FileOpen("Logs/Temporary Data/"+ me.charname + ".errdata", 1);
				
				if(_fhandle)
				{
					_fhandle.WriteLine("// This file holds aditional error information");
					_fhandle.Close();
				}
			}
			
			if(_msg[1] == "")
				_msg[1] = "ÿBE0000No additional error description available!";
			else
				_msg[1] = _msg[1].replace("%script", MWConfig_Script[_MWBG_CurScriptIndex][0]);

			Print("ÿc1" + MWConfig_Script[_MWBG_CurScriptIndex][0] + " failed: " + _msg[0]);

			_area = MWC_FindArea();

			if(_area)
				NTC_SendLogToOOG(NTC_LOG_COMMON, "ÿBE0000" + MWConfig_Script[_MWBG_CurScriptIndex][0] + " : " + _msg[0] + " failed (" + _area.name + ");" + _msg[1]);
			else
				NTC_SendLogToOOG(NTC_LOG_COMMON, "ÿBE0000" + MWConfig_Script[_MWBG_CurScriptIndex][0] + " : " + _msg[0] + " failed (unknown area);" + _msg[1]);

			_MWBG_Statistics.Errors++;
			NT_ScriptMsgEvents("SCRIPT_END");
			break;
	}
}

function MW_ResetTicks()
{
	_MWBG_CurScriptStartTick = GetTickCount();
	
	if(MWConfig_Script[_MWBG_CurScriptIndex].length == 2 && !isNaN(MWConfig_Script[_MWBG_CurScriptIndex][1]))
		_MWBG_CurScriptEndTick = _MWBG_CurScriptStartTick + 6E4 * MWConfig_Script[_MWBG_CurScriptIndex][1];
}

function MW_AntiIdle()
{
	var _endtime, _starttick, _loops, _timeString, _time;
	
	_loops = 0;
	_MWBG_WorldEventData.Loop.Running = true;	
	_MWBG_ShowStatusText = false;
	_starttick = GetTickCount();
	
	if(_MWBG_WorldEventData.Loop.Mode == 0)
		_MWBG_WorldEventData.Loop.Runtime = MWConfig_WorldEventWaitTime;
		
	if(GetUIState(0x01) || GetUIState(0x0C))
		me.Cancel(1);
		
	while((_MWBG_WorldEventData.Loop.Runtime == 0 || _MWBG_WorldEventData.Loop.Runtime + _starttick > GetTickCount()) && _MWBG_WorldEventData.Loop.Running && me.ingame)
	{
		if(_loops % 2 == 0)
		{
			if(MWConfig_WorldEventAccount)
			{
				if(_MWBG_WorldEventData.Loop.Mode == 0)
					Say("/w *" + MWConfig_WorldEventAccount + " World Event in " + me.gamename + "//" + me.gamepassword + "!");
				else
					Say("/w *" + MWConfig_WorldEventAccount + " Soj Count in " + me.gamename + "//" + me.gamepassword + " (" + _MWBG_SojCount + ((_MWBG_SojCount - _MWBG_InitialSojCount) ? " [+" + (_MWBG_SojCount - _MWBG_InitialSojCount)+ "]" : "") + " sold)!");
			}
		}
		
		SetStatusText("ÿc8Switching to Act " + (1 +_loops % 5) + "...");
		NTTM_CheckAct(1 + _loops % 5);
				
		SetStatusText("ÿc8Moving to Portal Spot...");
		NTTM_TownMove("portalspot");
		
		_endtime = GetTickCount() + 300E3; // Wait 300 seconds in each act
		while(_endtime > GetTickCount() && (_MWBG_WorldEventData.Loop.Runtime == 0 || _MWBG_WorldEventData.Loop.Runtime + _starttick > GetTickCount()) && _MWBG_WorldEventData.Loop.Running && me.ingame)
		{
			if(_MWBG_WorldEventData.Loop.Mode == 0)
			{
				_timeString = "ÿc8Diablo Walks the Earth! [";
				_time = GetTickCount() - _starttick;
			}
			else
			{
				_timeString = "ÿc8Awaiting Soj Sale... [";
				_time = _MWBG_WorldEventData.Loop.Runtime + _starttick - GetTickCount();
			}
			
			_timeString += MWC_ConvertTicksToTimeString(_time) + "]";

			SetStatusText(_timeString);
			
			NTC_Delay(250);
		}
		
		_loops++;
	}
	
	_MWBG_WorldEventData.Loop.Running = false;
	
	if(_MWBG_WorldEventData.Loop.Mode != 0)
		NTC_SendLogToOOG(NTC_LOG_COMMON, "ÿc4Proceeding...;ÿc0Total Sojs sold:ÿc8 " + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Init) + "\nÿc0Waitedÿc8 " + (parseInt((GetTickCount() - _starttick) / 6E4) % 60) + ":" + (parseInt((GetTickCount() - _starttick) / 1E3) % 60) + "");
	
	MW_ResetTicks();
	_MWBG_ShowStatusText = true;
	
}

function MW_EvaluateInputData(msg)
{
	switch(msg.split("_")[1])
	{
		case "SHRINEACTIVATED":
			_MWBG_Statistics.ShrinesUsed++;
			break;
		case "CHESTOPENEND":
			_MWBG_Statistics.ChestsOpened++;
			break;
		case "LOOTED":
			_MWBG_Statistics.CorpsesLooted++;
			break;
		case "PICKED":
			_MWBG_Statistics.ItemsPicked++;
			break;
		case "SCRIPTGOLD":
			_MWBG_Statistics.ScriptGold += parseInt(msg.split("_")[2]);
			break;
		case "HPDRANK":
			_MWBG_Statistics.Potions.Hp++;
			break;
		case "MPDRANK":
			_MWBG_Statistics.Potions.Mp++;
			break;
		case "RVDRANK":
			_MWBG_Statistics.Potions.Rv++;
			break;
		case "COMMONITEM":
			_MWBG_Statistics.CommonLog.push(parseInt(msg.split("_")[2]));
			break;
	}
}

function MW_PrintOutputString(byUser)
{
	var _output, _room, _gold, _expString, _tempString, _dateDiff;
	
	if(arguments.length < 1)
		byUser = false;

	_room = MWI_GetStashRoom();

	if(byUser)
	{
		_output = MW_GetInterpolationColor(_room[0] / _room[1]) + "Game" + ((me.gamename.slice(me.gamename.lastIndexOf('-') + 1)) ? " (" + me.gamename.slice(me.gamename.lastIndexOf('-') + 1) + ") " : " ") + "was finished by User!;";
	}
	else
	{
		if(_MWBG_Statistics.Errors > 1)
			_output = "ÿF66F21Game" + ((me.gamename.slice(me.gamename.lastIndexOf('-') + 1)) ? " ("+ me.gamename.slice(me.gamename.lastIndexOf('-') + 1) + ") " : " ") + "was finished!;";
		else
			_output = MW_GetInterpolationColor(_room[0] / _room[1]) + "Game" + ((me.gamename.slice(me.gamename.lastIndexOf('-') + 1)) ? " ("+ me.gamename.slice(me.gamename.lastIndexOf('-') + 1) + ") " : " ") + "was finished successfully!;";
	}
	// Level up info	
	if(_MWBG_Statistics.Init.CharLevel != me.GetStat(12))
		_output += "ÿ00FF40!!! Level up (" + me.GetStat(12) + ") !!!\n";
	
	// Gametime info
	_output += "ÿc0Duration:ÿc8 " + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_Statistics.Init.Ticks);
			
	// Add the relation between maximum and actual gametime
	if(me.maxgametime > 0)
		_output += " [" + ((GetTickCount() - _MWBG_Statistics.Init.Ticks) / 10 / me.maxgametime).toFixed(1) + "%]";
	
	// Exp info
	if(_MWBG_Statistics.Init.CharLevel == me.GetStat(12) && me.GetStat(13) - _MWBG_Statistics.Init.Exp > 0)
	{
		_output += "\nÿc0Experience:ÿc8 " + MWC_InsertDigitSeperator(me.GetStat(13) - _MWBG_Statistics.Init.Exp);

		if(MW_GetRequiredExp(me.GetStat(12) + 1) - MW_GetRequiredExp(me.GetStat(12)) > 0)
			_output += " [" + ((me.GetStat(13) - _MWBG_Statistics.Init.Exp) / (MW_GetRequiredExp(me.GetStat(12) + 1) - MW_GetRequiredExp(me.GetStat(12))) * 100).toFixed(4) + "%]";
	}
		
	// Potion Info
	if(_MWBG_Statistics.Potions.Hp > 0 || _MWBG_Statistics.Potions.Mp > 0  || _MWBG_Statistics.Potions.Rv > 0)
		_output += "\nÿc0Potions:ÿBE0000 (" + _MWBG_Statistics.Potions.Hp + ")ÿc3 (" + _MWBG_Statistics.Potions.Mp + ")ÿ9F008C (" + _MWBG_Statistics.Potions.Rv + ")";

	// Gold pickup
	_gold = NTC_MyGold() - _MWBG_Statistics.Init.Gold;
	
	if(_gold != 0)
		_output += "\nÿc0Gold:ÿc8 " + MWC_InsertDigitSeperator(_gold);
	
	// Picked items
	if(_MWBG_Statistics.ItemsPicked > 0)
		_output += "\nÿc0Items:ÿc8 " + _MWBG_Statistics.ItemsPicked;
	
	// Looted corpses
	if(_MWBG_Statistics.CorpsesLooted > 0)
		_output += "\nÿc0Looted:ÿc8 " + _MWBG_Statistics.CorpsesLooted;
	
	// Chest info
	if(_MWBG_Statistics.ChestsOpened > 0)
		_output += "\nÿc0Chests:ÿc8 " + _MWBG_Statistics.ChestsOpened;
	
	// Shrine info
	if(_MWBG_Statistics.ShrinesUsed > 0)
		_output += "\nÿc0Shrines:ÿc8 " + _MWBG_Statistics.ShrinesUsed;
	
	// Stash info
	_output += "\nÿc0Stash: " + MW_GetInterpolationColor(_room[0] / _room[1]) + _room[0] + "/" + _room[1];
	
	// Inventory info
	_room = MWI_GetStashRoom(false, true);
	_output += "\nÿc0Inventory: " + MW_GetInterpolationColor(_room[0] / _room[1]) + _room[0] + "/" + _room[1];
	// _output += "\nÿc0Color Check: " + MW_GetInterpolationColor(0.0) + "0% " + MW_GetInterpolationColor(0.25) + "25% " + MW_GetInterpolationColor(0.5) + "50% " + MW_GetInterpolationColor(0.75) + "75% " + MW_GetInterpolationColor(1.0) + "100% "; 
	
	// Error info
	if(_MWBG_Statistics.Errors > 0)
		_output +=	"\nÿBE0000Errors: " + _MWBG_Statistics.Errors;
		
	NTC_SendLogToOOG(NTC_LOG_COMMON, _output);
}

function MW_GetRequiredExp(level)
{
	// Returns the experience which is required for the level specified

	if(!level || level < 2 || level > 99)
		return -1;
	
	return _MWBG_ExperienceThresholds[level - 2];
}

function MW_GetScriptRuntimeMinutes(addZeros)
{
	return parseInt((GetTickCount() - _MWBG_CurScriptStartTick) / 6E4) % 60;
}

function MW_GetScriptRuntimeSeconds(addZeros)
{
	return parseInt((GetTickCount() - _MWBG_CurScriptStartTick) / 1E3) % 60;
}

function MW_SetStatusText()
{
	var _seconds, _minutes, _script, _timeString, _textString, _color;
	
	if(!_MWBG_ShowStatusText)
		return;
	
	_script = NTC_FindScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
	_seconds = MW_GetScriptRuntimeSeconds();
	_minutes = MW_GetScriptRuntimeMinutes();
	_timeString = "";
		
	if(_script && _script.running)
	{
		_textString = "ÿc2Running ÿc4" + MWConfig_Script[_MWBG_CurScriptIndex][0];
		
		if(_minutes == 0 && _seconds <= 5)	
		{
			if(_seconds % 2 == 1)
				_color = "ÿc8";
			else
				_color = "ÿc4";

			if(isNaN(MWConfig_Script[_MWBG_CurScriptIndex][1]) || MWConfig_Script[_MWBG_CurScriptIndex][1] <= 0)
				_timeString = _color + " [+Inf]";
			else
			{
				_timeString = _color + " [";
				
				if(MWConfig_Script[_MWBG_CurScriptIndex][1] < 10)
					_timeString += "0";
				
				_timeString += MWConfig_Script[_MWBG_CurScriptIndex][1] + ":00]";
			}
		}
		else
		{
			if(MWConfig_Script[_MWBG_CurScriptIndex][1] != 0)
			{
				if(_minutes >= MWConfig_Script[_MWBG_CurScriptIndex][1] || _minutes >= MWConfig_Script[_MWBG_CurScriptIndex][1] - 1 && _seconds >= 50)
					_timeString = "ÿc1";
				else if(_minutes >= MWConfig_Script[_MWBG_CurScriptIndex][1] - 1)
					_timeString = "ÿc8";
			}
			
			_timeString += " [" + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_CurScriptStartTick) + "]"
			
			if(_MWBG_ShowCurrentPing)
				_timeString = " (" +  me.ping + ")" + _timeString;
		}
	}
	else
	{
		_textString = "ÿc1Stopped ÿc4" + MWConfig_Script[_MWBG_CurScriptIndex][0];
		
		if(_MWBG_ShowCurrentPing)
			_timeString = " (" +  me.ping + ")";
	}
		
	MWC_SetStatusText(_textString, _timeString);
}

function MW_GetInterpolationColor(percentage)
{
	var _colors, _colorIndex, _deltaColor, _colorPercentage, _component, _colorHexString;
	
	if(arguments.length < 1 || percentage < 0.0 || percentage > 1.0)
		return "ÿFFFFFF";
	
	// Define RGB colors - Note: red values between 191 and 208 are invalid as they would lead to a 'C' at the very beginning of the HEX string which would cause the HEX color to be misinterpreted as a D2 color code (ÿc)
	_colors = new Array(3);
	_colors[0] = [0, 255, 50];
	_colors[1] = [0, 120, 255];
	_colors[2] = [190, 0, 0];
	
	_colorHexString = "";
	
	// Transform the given percentage in order to match the color scale
	if(percentage < 0.5)
	{
		_colorIndex = 0;
		_colorPercentage = percentage / 0.4999;
	}
	else
	{
		_colorIndex = 1;
		_colorPercentage = (percentage - 0.5) / 0.5;
	}
	
	// Calculate the actual difference of each red, green and blue
	_deltaColor = new Array(3);
	_deltaColor[0] = _colors[_colorIndex + 1][0] - _colors[_colorIndex][0];
	_deltaColor[1] = _colors[_colorIndex + 1][1] - _colors[_colorIndex][1];
	_deltaColor[2] = _colors[_colorIndex + 1][2] - _colors[_colorIndex][2];

	for(var i = 0; i < _colors.length; i++)
	{
		// Calculate the color component
		_component = parseInt(_colors[_colorIndex][i] + _colorPercentage * _deltaColor[i]);
		
		if(_component >= 0 && _component < 256 && !(_component > 191 && _component < 208 && i == 0))
			_colorHexString += ((_component.toString(16).length == 1) ? "0" : "") + _component.toString(16);
		else
			return "ÿFFFFFF";
	}

	return "ÿ" + _colorHexString;
}

function MW_UpdateCommonLog(charlog)
{
	var _filepath, _fhandle, _newfile, _buffer, _lines, _itemData, _data, _date, _addedString;
	
	if(_MWBG_Statistics.CommonLog.length < 1)
		return true;
		
	if(arguments.length < 1)
		charlog = false;
		
	_lines = new Array();
	
	if(charlog)
		_filepath = "Logs/" + me.charname + "/MyCommonLog.txt";
	else
		_filepath = "Logs/CommonLog.txt";
	
	_fhandle = FileOpen(_filepath, 2);
	
	if(_fhandle)
	{
		while(!_fhandle.eof)
		{
			_buffer = _fhandle.ReadLine();
			
			if(_buffer != "" && _buffer.indexOf("//") == -1 || _buffer.indexOf("File") > -1)
				_lines.push(_buffer);
		}
		
		_fhandle.Close();
	}
	else if(!charlog)
		return false;
		
	if(_lines.length < 1 || _lines[0].indexOf("INVALID_DATE") > -1)
		_newfile = true;
	else 
		_newfile = false;
	
	_itemData = new Array([610], [611], [612], [613], [614], [615], [616], [617], [618], [619], [620], [621], [622], [623], [624], [625], [626], [627], [628], [629], [630], [631], [632], [633], [634], [635], [636], [637], [638], [639], [640], [641], [642], // Runes 
						  [557], [558], [559], [560], [561], [562], [563], [564], [565], [566], [567], [568], [569], [570], [571], [572], [573], [574], [575], [576], [577], [578], [579], [580], [581], [582], [583], [584], [585], [586], [597], [598], [599], [600], [601], // Gems
						  [647], [648], [649], // Keys
						  [650], [651], [652], // Organs
						  [654], [655], [656], [657]); // Essences
						  
	for(var i = 0; i < _itemData.length; i++)
		_itemData[i].push(_NTIPIDToName[_itemData[i][0]], 0); // Add the item's name and an integer to save the quantity of this item type
		
	for(var i = 1; i < _lines.length; i++)
	{
		_data = _lines[i].split(": ");

		for(var j = 0; j < _itemData.length; j++)
		{
			if(_data[0] == _itemData[j][1])
			{
				if(_data.length == 2)
					_itemData[j][2] = parseInt(_data[1].replace(",", ""));
				
				break;
			}
		}
	}
	
	for(var i = 0; i < _MWBG_Statistics.CommonLog.length; i++)
	{
		for(var j = 0; j < _itemData.length; j++)
		{
			if(_MWBG_Statistics.CommonLog[i] == _itemData[j][0])
			{
				_itemData[j][2]++;
				break;
			}
		}
	}
	
	_fhandle = FileOpen(_filepath, 1);
	
	if(_fhandle)
	{
		_date = new Date();
		_addedString = "";
		
		for(var i = 0; i < _MWBG_Statistics.CommonLog.length; i++)
		{
			_addedString += _NTIPIDToName[_MWBG_Statistics.CommonLog[i]];
			
			if(i + 1 < _MWBG_Statistics.CommonLog.length)
				_addedString += ", ";
		}
		
		if(_date)
		{
			if(_newfile)
				_fhandle.WriteLine("// File Created: " + _date.toLocaleFormat("%a %m/%d/%y %H:%M:%S") + " <> Last Update: " + _date.toLocaleFormat("%a %m/%d/%y %H:%M:%S") + " by " + me.charname + " (" + _addedString + ")");
			else
				_fhandle.WriteLine(_lines[0].split(" <>")[0] + " <> Last Update: " + _date.toLocaleFormat("%a %m/%d/%y %H:%M:%S") + " (" + me.charname + ": " + _addedString + ")");
		}
		else
		{
			if(_newfile)
				_fhandle.WriteLine("// File Created: INVALID_DATE <> Last Update: INVALID_DATE" + " (" + me.charname + ": " + _addedString + ")");
			else
				_fhandle.WriteLine(_lines[0].split(" <>")[0] + " <> Last Update: INVALID_DATE" + " (" + me.charname + ": " + _addedString + ")");
		}
		
		_fhandle.WriteLine("// ###### Runes ######");
		for(var i = 0; i < _itemData.length; i++)
		{
			_fhandle.WriteLine(_itemData[i][1] + ": " + MWC_InsertDigitSeperator(_itemData[i][2]));
		
			if(_itemData[i][0] == 642)
				_fhandle.WriteLine("\n// ###### Gems ######");
			else if(_itemData[i][0] == 601)
				_fhandle.WriteLine("\n// ###### Keys ######");
			else if(_itemData[i][0] == 649)
				_fhandle.WriteLine("\n// ###### Organs ######");
			else if(_itemData[i][0] == 652)
				_fhandle.WriteLine("\n// ###### Essences ######");
			else if(_itemData[i][0] == 561 || _itemData[i][0] == 566 || _itemData[i][0] == 571 || _itemData[i][0] == 576 || _itemData[i][0] == 581 || _itemData[i][0] == 586)
				_fhandle.WriteLine("");
		}
				
		_fhandle.Close();
	}
	else if(!charlog)
		return false;
		
	if(!charlog)
		return MW_UpdateCommonLog(true);
	
	_MWBG_Statistics.CommonLog = new Array();
	
	return true;
}

function MW_CheckMinGametime()
{
	var _deltaTime; 
		
	do
	{
		if(_deltaTime)
		{
			if(!NTC_InTown())
				NTTM_CheckAct();
			
			MWC_SetStatusText("ÿc8Awaiting minimum gametime... [" + MWC_ConvertTicksToTimeString(_deltaTime) + "]");
			
			NTC_Delay(500);
		}
			
		_deltaTime = me.mingametime * 1E3 - GetTickCount() + _MWBG_Statistics.Init.Ticks;
	
	} while(_deltaTime > 0 && !_MWBG_UserExit);
}
Der von Mirkoregge beschriebene "Abgang" deckt sich mit dem meines Fehlers. Vlt. hilft das dort weiter.
Achja solltest du die neue Routine nicht allgemein einbinden? Das Prob. haben ja alle User, die in Classic nur CS runs machen.

LG
07/18/2011 14:28 Muddy Waters#2544
Ich weiss aber gerade nicht genau, inwieweit ich das bei mir von der aktuellen Version abgeändert habe, insofern ändere ich es besser direkt. Abgesehen davon, ist es eine Arbeit von unter 5 Minuten. ;)

So, versuch es mal so:
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: 14:27 18.07.2011
*/
// Global constants
const _MWBG_CHAT_COMMAND_TRIGGER = '.';
const _MWBG_SEC_AFTER_DIA_KILL = 100;

// Global variables
var _MWBG_ExperienceThresholds = new Array(
500, 1500, 3750, 7875, 14175, 22680, 32886, 44396,																		// Level 2 - 9
57715, 72144, 90180, 112725, 140906, 176132, 220165, 275207, 344008, 430010,											// Level 10 - 19
537513, 671891, 839864, 1049830, 1312287, 1640359, 2050449, 2563061, 3203826, 3902260,									// Level 20 - 29
4663553, 5493363, 6397855, 7383752, 8458379, 9629723, 10906488, 12298162, 13815086, 15468534,							// Level 30 - 39
17270791, 19235252, 21376515, 23710491, 26254525, 29027522, 32050088, 35344686, 38935798, 42850109,						// Level 40 - 49
47116709, 51767302, 56836449, 62361819, 68384473, 74949165, 82104680, 89904191, 98405658, 107672256,					// Level 50 - 59
117772849, 128782495, 140783010, 153863570, 168121381, 183662396, 200602101, 219066380, 239192444, 261129853,			// Level 60 - 69
285041630, 311105466, 339515048, 370481492, 404234916, 441026148, 481128591, 524840254, 572485967, 624419793,			// Level 70 - 79
681027665, 742730244, 809986056, 883294891, 963201521, 1050299747, 1145236814, 1248718217, 1361512946, 1484459201,		// Level 80 - 89
1618470619, 1764543065, 1923762030, 2097310703, 2286478756, 2492671933, 2717422497, 2962400612, 3229426756, 3520485254);// Level 90 - 99

var _MWBG_CurScriptIndex = 0;
var _MWBG_CurScriptEndTick = GetTickCount();
var _MWBG_CurScriptStartTick = GetTickCount();
var _MWBG_DiaKillTicks = 0;

var _MWBG_LastScript = false;
var _MWBG_UserExit = false;

var _MWBG_Statistics;
var _MWBG_WorldEventData;

var _MWBG_ShowStatusText = true;
var _MWBG_ShowCurrentPing = false;

var _MWBG_PositionsPrinted = new Array();

function MW_GameStatistics()
{
	this.Potions = new Array();
	this.Potions.Hp = 0;
	this.Potions.Mp = 0;
	this.Potions.Rv = 0;
	
	this.Init = new Array();
	this.Init.Ticks = GetTickCount();
	this.Init.Exp = me.GetStat(13);
	this.Init.CharLevel = me.GetStat(12);
	this.Init.Gold = me.GetStat(14) + me.GetStat(15);
	
	this.CommonLog = new Array();
	this.CorpsesLooted = 0;
	this.ChestsOpened = 0;
	this.ShrinesUsed = 0;
	this.ItemsPicked = 0;
	this.ScriptGold = 0;
	this.Errors = 0;
}

function MW_WorldEventData()
{
	this.SojSoldString = GetLocaleString(11004).replace("%d ", "");
	this.DiabloWalkString = GetLocaleString(11005);
	
	this.Count = new Array();
	this.Count.Message = 0;
	this.Count.Recent = 0;
	this.Count.Last = 0;
	this.Count.Init = 0;
	
	this.Loop = new Array();
	this.Loop.Runtime = 0;
	this.Loop.Mode = 0;
	this.Loop.Running = false;
	
	this.InitTicks = 0;
}

function NTMain()
{
	SetStatusText("ÿc8Initializing...");
	
	Include("libs/common/NTCommon.ntl");
		
	NTC_IncludeLibs();
	NTC_IncludeConfig("NTBot/char_configs");
	
	NT_LoadConfig();
	NTSI_LoadNIPFiles("NTBot/item_configs");
	
	var _script, _loops;
	
	_MWBG_Statistics = new MW_GameStatistics();
	_MWBG_WorldEventData = new MW_WorldEventData();	
		
	NTC_Delay(NTConfig_StartDelay);
	
	if(!_MWBG_Statistics || !_MWBG_WorldEventData)
		ExitGame();
		
	if(MWConfig_UseXMLItemlog)
	{
		if(MWI_WriteTempLogToXML())
			MWI_ClearTempLog();
	}
	
	MWI_ClearLoc();
	
	SetUIState(0x0A, true);
	
	NTT_GetCorpses();

	if(MWConfig_ExitGameOnMissingPassword && !me.gamepassword)
	{
		SetStatusText("ÿc1Exiting game...");
		ExitGame();
	}

	if(MWConfig_Script.length > 0)
	{
		NTCU_InitCubing();
			
		Load("NTBot/tools/NTToolsThread.ntj");

		RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);
		RegisterEvent(EVENT_KEYDOWN, NT_KeyEvents);
		RegisterEvent(EVENT_SCRIPTMSG, NT_ScriptMsgEvents);

		MW_ResetTicks();

		Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);

		_loops = 0;
		
		while(!_MWBG_LastScript && me.ingame)
		{
			MW_SetStatusText();
			
			if(GetTickCount() >= _MWBG_CurScriptEndTick && MWConfig_Script[_MWBG_CurScriptIndex][1] != 0 && !isNaN(MWConfig_Script[_MWBG_CurScriptIndex][1]) && !NTC_InTown() && !_MWBG_WorldEventData.Loop.Running)
			{
				_script = NTC_FindScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
				
				if(_script && _script.running)
				{
					Print("ÿc;" + MWConfig_Script[_MWBG_CurScriptIndex][0] + "ÿc8 is skipped due to exceeding the maximum runtime of ÿc;" + MWConfig_Script[_MWBG_CurScriptIndex][1] + "ÿc8 minutes!");
					
					NT_ScriptMsgEvents("SCRIPT_END");
				}
			}
			
			NTC_Delay(500);
			
			if(!_MWBG_LastScript && _MWBG_Statistics.Errors > MWConfig_GameErrorLimit || _MWBG_DiaKillTicks > 0 && _MWBG_DiaKillTicks + _MWBG_SEC_AFTER_DIA_KILL * 1000 < GetTickCount())
			{
				NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);

				_MWBG_LastScript = true;
			}
			
			if(_loops++ % 40 == 0)
				MW_UpdateCommonLog();
		}
	}
	
	UnregisterEvent(EVENT_GAMEMSG);
	UnregisterEvent(EVENT_KEYDOWN);
	UnregisterEvent(EVENT_SCRIPTMSG);
	
	MW_UpdateCommonLog();
	
	MW_CheckMinGametime();
	
	SetStatusText("ÿc1Exiting game...");

	if(me.ingame)
		MW_PrintOutputString(_MWBG_UserExit);
	
	me.revealautomap = false;
	me.showmissileonautomap = false;
	me.showenemyonautomap = false;

	if(!NTC_InTown() && !_MWBG_UserExit)
		NTSI_PickItems(true);

	ExitGame();
}

function NT_GameMsgEvents(msg, type)
{
	var _message, _messenger, _output, _date;
	var i;	
	
	if(type == 0)
	{
		_message = msg.split("ÿc0: ")[1]; // Extract the message
	 
		if(_message.substr(0, _MWBG_CHAT_COMMAND_TRIGGER.length) != _MWBG_CHAT_COMMAND_TRIGGER)
			return;
			
		_message = _message.substr(_MWBG_CHAT_COMMAND_TRIGGER.length, _message.length); // Remove the trigger
		
		_messenger = msg.split("ÿc0: ")[0].replace("ÿc4", ""); // Extract the name of the char that wrote the message
		
		if(_messenger == me.charname && _message.toLowerCase().indexOf("run") == 0)
		{
			for(i = 0; i < MWConfig_Script.length; i++)
			{
				if(MWConfig_Script[i][0].toLowerCase().indexOf(_message.toLowerCase().split(" ")[1]) > -1)
					break;
			}

			if(i < MWConfig_Script.length)
			{
				Print("ÿc8Switching to ÿc;" + MWConfig_Script[i][0] + "ÿc8...");
				
				NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
				
				NTC_Delay(250);
				
				_MWBG_CurScriptIndex = i - 1;
				
				NT_ScriptMsgEvents("SCRIPT_END");
			}
			else
				Print("ÿc1There is no script activated matching the term '" + _message + "'!");
				
			return;
		}
		
		NTC_SendMsgToScript("MWRush.ntj", _messenger + " " + _message.toUpperCase());
	}
	
	if(type == 4)
	{
		if(MWConfig_CheckSojSales && msg.indexOf(_MWBG_WorldEventData.SojSoldString) > -1)
		{
			me.maxgametime = 0;
			
			NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
			NTC_Delay(200);
			
			_MWBG_WorldEventData.Count.Last = _MWBG_WorldEventData.Count.Recent;
			_MWBG_WorldEventData.Count.Recent = parseInt(msg.split(" ")[0]);
			_MWBG_WorldEventData.Count.Message++;
			
			if(_MWBG_WorldEventData.Count.Init == 0)
			{
				_MWBG_WorldEventData.Count.Init = _MWBG_WorldEventData.Count.Recent;
				_MWBG_WorldEventData.InitTicks = GetTickCount();
			}
		
			if(!_MWBG_WorldEventData.Loop.Running)
			{
				_MWBG_WorldEventData.Loop.Runtime = _MWBG_WorldEventData.Count.Message*10*60E3;
				_MWBG_WorldEventData.Loop.Mode = 1;
			}
			else if(_MWBG_WorldEventData.Loop.Mode == 1)
				_MWBG_WorldEventData.Loop.Runtime = _MWBG_WorldEventData.Count.Message*5*60E3;
				
			_output = "ÿc4" + msg;
			_output += ";ÿc0Game:ÿc8 " + me.gamename  + "//" + me.gamepassword;
			_output += "\nÿc0Server IP:ÿc8 " + me.gameserverip.split(".")[3];
			_output += "\nÿc0Message Count:ÿc8 " + _MWBG_WorldEventData.Count.Message; 
			_output += "\nÿc0Sojs Total:ÿc8 " + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Init) + " [+" + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Last) + "]";
			
			_date = new Date(_MWBG_WorldEventData.InitTicks);
			
			if(_date)
			{
				_output += "\nÿc0First Message:ÿc8 " + _date.toLocaleFormat("%H:%M:%S");
				_output +=  " [-" + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_Statistics.Init.Ticks) + "]";
			}
			
			_output += "\nÿc0Waitingÿc8 " + (_MWBG_WorldEventData.Loop.Runtime / 60E3) + " ÿc0minutes";
			
			NTC_SendLogToOOG(NTC_LOG_COMMON, _output);
			
			if(!_MWBG_WorldEventData.Loop.Running)
			{
				MW_AntiIdle();
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
			}
		}
		else if(NTConfig_CheckCloneDiablo && msg.indexOf(_MWBG_WorldEventData.DiabloWalkString) > -1)
		{
			me.maxgametime = 0;
			
			_output = "ÿc4" + msg;
			_output += ";ÿc0Game:ÿc8 " + me.gamename  + "//" + me.gamepassword;
			_output += "\nÿc0Server IP:ÿc8 " + me.gameserverip.split(".")[3];
			_output += "\nÿc0Message Count:ÿc8 " + _MWBG_WorldEventData.Count.Message; 
			_output += "\nÿc0Sojs Total:ÿc8 " + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Init) + " [+" + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Last) + "]";
			
			_date = new Date(_MWBG_WorldEventData.InitTicks);
			
			if(_date)
			{
				_output += "\nÿc0First Message:ÿc8 " + _date.toLocaleFormat("%H:%M:%S");
				_output +=  " [-" + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_Statistics.Init.Ticks) + "]";
			}
			
			NTC_SendLogToOOG(NTC_LOG_COMMON, _output);

			NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
			NTC_Delay(200);

			_MWBG_WorldEventData.Loop.Runtime = 0;
			_MWBG_WorldEventData.Loop.Mode = 0;
			
			if(!_MWBG_WorldEventData.Loop.Running)
				MW_AntiIdle();
		}
	}
}

function NT_KeyEvents(keycode)
{
	//Print("Keycode: " + keycode);
	var _script = NTC_FindScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
	
	switch(keycode)
	{
		case 19: // Pause (PAUSE)
			if(_script)
			{
				if(_script.running)
				{
					_MWBG_ShowStatusText = false;
					_script.Stop();
					
					me.maxgametime = 0;
					
					NTC_Delay(250);
					
					ClickMap(NTC_CLICK_LUP, NTC_SHIFT_NONE, null);
					
					SetStatusText("ÿc1Stopped ÿc4" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
					
					NTC_Delay(500);
				}
				else
				{
					if(_MWBG_WorldEventData.Loop.Running)
					{
						_MWBG_WorldEventData.Loop.Running = false;
						NTC_Delay(500);
					}
					
					MW_ResetTicks();
					
					Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
				}
				
				NT_ScriptMsgEvents("SET_DEFAULT_STATUS");
			}
			break;
		case 33: // Skip (PGUP)
			_MWBG_ShowStatusText = false;
			SetStatusText("ÿc1Skipping current script...");
			_MWBG_WorldEventData.Loop.Running = false
			if(!_script)
				break;
			if(_script.running)
				_script.Stop();
			
			NTC_PingDelay(250);
			NT_ScriptMsgEvents("SCRIPT_END");
			break;
		case 34: // Repeat (PGDN)
			_MWBG_ShowStatusText = false;
			SetStatusText("ÿc1Repeating previous script...");
			_MWBG_WorldEventData.Loop.Running = false
			if(!_script)
				break;
			if(_script.running)
				_script.Stop();
			
			NTC_PingDelay(250);
			NT_ScriptMsgEvents("SCRIPT_REPEAT");
			break;
		case 35: // Clear current XML logfile (END)
			_MWBG_ShowCurrentPing = !_MWBG_ShowCurrentPing;
			break;
		case 36: // Show coordinates (POS1/HOME)
			MW_PrintPosition();
			break;
		case 46: // Exit (DEL)
			if(_MWBG_LastScript)
				return;
			
			SetStatusText("ÿc1Exiting game...");

			_MWBG_WorldEventData.Loop.Running = false
			_MWBG_ShowStatusText = false;
			
			_MWBG_UserExit = true;
			_MWBG_LastScript = true;
			
			if(NTConfig_PublicMode)
				Say("Next game!");
				
			break;
		case 45: // Log stashed items (INS)
			_MWBG_ShowStatusText = false;
			SetStatusText("ÿc8Logging current stash to " + ((MWConfig_LogStashToTxt) ? "TXT" : "XML") + "...");
			if(MWI_LogStashedItems())
				SetStatusText("ÿc8Done!");
			else
				SetStatusText("ÿc1Logging failed!");
			NT_ScriptMsgEvents("SET_DEFAULT_STATUS");
			break;
		default:
			MWUC_HandleUserCommand(keycode, _MWBG_Statistics, _MWBG_CurScriptIndex);
			break;
	}
}

function MW_PrintPosition()
{
	var _color;
	
	_MWBG_PositionsPrinted.push([me.x, me.y, me.areaid]);
	
	if(_MWBG_PositionsPrinted.length > 2)
		_MWBG_PositionsPrinted.splice(0, 1);
		
	_color = MWC_GetRandomColor();
		
	Print(_color + "Current Position: ÿc0(ÿc2" + _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][0] + "ÿc0|ÿc1" + _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][1] + "ÿc0) [ÿc7" + _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][2] + "ÿc0]");
	
	if(_MWBG_PositionsPrinted.length > 1)
		Print(_color + "Last Position: ÿc0(ÿc2" + _MWBG_PositionsPrinted[0][0] + "ÿc0|ÿc1" + _MWBG_PositionsPrinted[0][1] + "ÿc0) [ÿc7" + _MWBG_PositionsPrinted[0][2] + "ÿc0] (ÿc7Distance: " + GetDistance(_MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][0], _MWBG_PositionsPrinted[_MWBG_PositionsPrinted.length - 1][1], _MWBG_PositionsPrinted[0][0], _MWBG_PositionsPrinted[0][1]).toFixed(2) + "ÿc0)");	
}

function NT_ScriptMsgEvents(msg)
{
	var _area, _msg, _fhandle, _buffer, _script;
	
	if(!msg)
		return;
	
	if(msg.split("_")[0] == "SET" && msg.indexOf("SET_DEFAULT_STATUS") == -1)
	{
		MW_EvaluateInputData(msg);
		
		return;
	}
	
	switch(msg)
	{
		case "SCRIPT_END":
			_MWBG_ShowStatusText = false;
			NTC_StopScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
			
			if(++_MWBG_CurScriptIndex < MWConfig_Script.length)
			{
				if(MWConfig_ShowGoldPickupsPerScript)
				{
					if(_MWBG_Statistics.ScriptGold > 0)
						Print("ÿc8Picked up ÿc;" + MWC_InsertDigitSeperator(_MWBG_Statistics.ScriptGold) + "ÿc8 gold running ÿc;" + MWConfig_Script[_MWBG_CurScriptIndex - 1][0]);
					
					_MWBG_Statistics.ScriptGold = 0;
				}

				MW_ResetTicks();
				
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
				_MWBG_ShowStatusText = true;
			}
			else
				_MWBG_LastScript = true;
			break;
		case "SCRIPT_REPEAT":
			_MWBG_ShowStatusText = false;
			if(_MWBG_CurScriptIndex - 1 >= 0)
			{
				_MWBG_CurScriptIndex--;

				MW_ResetTicks();
				
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
			}
			else
			{
				SetStatusText("ÿc1Cannot repeat - Invalid Index!");
				NTC_PingDelay(250);

				MW_ResetTicks();
				
				Load("NTBot/bots/" + MWConfig_Script[_MWBG_CurScriptIndex][0]);
			}
			_MWBG_ShowStatusText = true;
			break;
		case "SET_DEFAULT_STATUS":
			NTC_Delay(2500);
			_MWBG_ShowStatusText = true;
			break;
		case "STOP_STATUS_TEXT_UPDATE":
			_MWBG_ShowStatusText = false;
			break;
		case "RESET_TICKS":
			MW_ResetTicks();
			break;
		case "EXIT_GAME":
			SetStatusText("ÿc1Exiting game...");

			_MWBG_WorldEventData.Loop.Running = false
			_MWBG_ShowStatusText = false;
			
			_MWBG_UserExit = true;
			_MWBG_LastScript = true;
			break;
		case "DIA_KILL":
			if(me.gametype == 0)
			{
				_MWBG_DiaKillTicks = GetTickCount();
				Print("ÿc<Exiting game in ÿc1" + _MWBG_SEC_AFTER_DIA_KILL + "ÿc< seconds...");
			}
			break;
		default:
			_msg = new Array();
			
			_msg.push(msg);
			_msg.push("");
			
			_fhandle = FileOpen("Logs/Temporary Data/"+ me.charname + ".errdata", 2);
			
			if(_fhandle)
			{
				while(!_fhandle.eof)
				{
					_buffer = _fhandle.ReadLine();
					
					if(_buffer != "" && _buffer.indexOf("//") == -1)
					{
						if(_msg[1] != "")
							_msg[1] += "\n";
						
						_msg[1] += _buffer;
					}
				}
				
				_fhandle.Close();
				
				_fhandle = FileOpen("Logs/Temporary Data/"+ me.charname + ".errdata", 1);
				
				if(_fhandle)
				{
					_fhandle.WriteLine("// This file holds aditional error information");
					_fhandle.Close();
				}
			}
			
			if(_msg[1] == "")
				_msg[1] = "ÿBE0000No additional error description available!";
			else
				_msg[1] = _msg[1].replace("%script", MWConfig_Script[_MWBG_CurScriptIndex][0]);

			Print("ÿc1" + MWConfig_Script[_MWBG_CurScriptIndex][0] + " failed: " + _msg[0]);

			_area = MWC_FindArea();

			if(_area)
				NTC_SendLogToOOG(NTC_LOG_COMMON, "ÿBE0000" + MWConfig_Script[_MWBG_CurScriptIndex][0] + " : " + _msg[0] + " failed (" + _area.name + ");" + _msg[1]);
			else
				NTC_SendLogToOOG(NTC_LOG_COMMON, "ÿBE0000" + MWConfig_Script[_MWBG_CurScriptIndex][0] + " : " + _msg[0] + " failed (unknown area);" + _msg[1]);

			_MWBG_Statistics.Errors++;
			NT_ScriptMsgEvents("SCRIPT_END");
			break;
	}
}

function MW_ResetTicks()
{
	_MWBG_CurScriptStartTick = GetTickCount();
	
	if(MWConfig_Script[_MWBG_CurScriptIndex].length == 2 && !isNaN(MWConfig_Script[_MWBG_CurScriptIndex][1]))
		_MWBG_CurScriptEndTick = _MWBG_CurScriptStartTick + 6E4 * MWConfig_Script[_MWBG_CurScriptIndex][1];
}

function MW_AntiIdle()
{
	var _endtime, _starttick, _loops, _timeString, _time;
	
	_loops = 0;
	_MWBG_WorldEventData.Loop.Running = true;	
	_MWBG_ShowStatusText = false;
	_starttick = GetTickCount();
	
	if(_MWBG_WorldEventData.Loop.Mode == 0)
		_MWBG_WorldEventData.Loop.Runtime = MWConfig_WorldEventWaitTime;
		
	if(GetUIState(0x01) || GetUIState(0x0C))
		me.Cancel(1);
		
	while((_MWBG_WorldEventData.Loop.Runtime == 0 || _MWBG_WorldEventData.Loop.Runtime + _starttick > GetTickCount()) && _MWBG_WorldEventData.Loop.Running && me.ingame)
	{
		if(_loops % 2 == 0)
		{
			if(MWConfig_WorldEventAccount)
			{
				if(_MWBG_WorldEventData.Loop.Mode == 0)
					Say("/w *" + MWConfig_WorldEventAccount + " World Event in " + me.gamename + "//" + me.gamepassword + "!");
				else
					Say("/w *" + MWConfig_WorldEventAccount + " Soj Count in " + me.gamename + "//" + me.gamepassword + " (" + _MWBG_SojCount + ((_MWBG_SojCount - _MWBG_InitialSojCount) ? " [+" + (_MWBG_SojCount - _MWBG_InitialSojCount)+ "]" : "") + " sold)!");
			}
		}
		
		SetStatusText("ÿc8Switching to Act " + (1 +_loops % 5) + "...");
		NTTM_CheckAct(1 + _loops % 5);
				
		SetStatusText("ÿc8Moving to Portal Spot...");
		NTTM_TownMove("portalspot");
		
		_endtime = GetTickCount() + 300E3; // Wait 300 seconds in each act
		while(_endtime > GetTickCount() && (_MWBG_WorldEventData.Loop.Runtime == 0 || _MWBG_WorldEventData.Loop.Runtime + _starttick > GetTickCount()) && _MWBG_WorldEventData.Loop.Running && me.ingame)
		{
			if(_MWBG_WorldEventData.Loop.Mode == 0)
			{
				_timeString = "ÿc8Diablo Walks the Earth! [";
				_time = GetTickCount() - _starttick;
			}
			else
			{
				_timeString = "ÿc8Awaiting Soj Sale... [";
				_time = _MWBG_WorldEventData.Loop.Runtime + _starttick - GetTickCount();
			}
			
			_timeString += MWC_ConvertTicksToTimeString(_time) + "]";

			SetStatusText(_timeString);
			
			NTC_Delay(250);
		}
		
		_loops++;
	}
	
	_MWBG_WorldEventData.Loop.Running = false;
	
	if(_MWBG_WorldEventData.Loop.Mode != 0)
		NTC_SendLogToOOG(NTC_LOG_COMMON, "ÿc4Proceeding...;ÿc0Total Sojs sold:ÿc8 " + (_MWBG_WorldEventData.Count.Recent - _MWBG_WorldEventData.Count.Init) + "\nÿc0Waitedÿc8 " + (parseInt((GetTickCount() - _starttick) / 6E4) % 60) + ":" + (parseInt((GetTickCount() - _starttick) / 1E3) % 60) + "");
	
	MW_ResetTicks();
	_MWBG_ShowStatusText = true;
	
}

function MW_EvaluateInputData(msg)
{
	switch(msg.split("_")[1])
	{
		case "SHRINEACTIVATED":
			_MWBG_Statistics.ShrinesUsed++;
			break;
		case "CHESTOPENEND":
			_MWBG_Statistics.ChestsOpened++;
			break;
		case "LOOTED":
			_MWBG_Statistics.CorpsesLooted++;
			break;
		case "PICKED":
			_MWBG_Statistics.ItemsPicked++;
			break;
		case "SCRIPTGOLD":
			_MWBG_Statistics.ScriptGold += parseInt(msg.split("_")[2]);
			break;
		case "HPDRANK":
			_MWBG_Statistics.Potions.Hp++;
			break;
		case "MPDRANK":
			_MWBG_Statistics.Potions.Mp++;
			break;
		case "RVDRANK":
			_MWBG_Statistics.Potions.Rv++;
			break;
		case "COMMONITEM":
			_MWBG_Statistics.CommonLog.push(parseInt(msg.split("_")[2]));
			break;
	}
}

function MW_PrintOutputString(byUser)
{
	var _output, _room, _gold, _expString, _tempString, _dateDiff;
	
	if(arguments.length < 1)
		byUser = false;

	_room = MWI_GetStashRoom();

	if(byUser)
	{
		_output = MW_GetInterpolationColor(_room[0] / _room[1]) + "Game" + ((me.gamename.slice(me.gamename.lastIndexOf('-') + 1)) ? " (" + me.gamename.slice(me.gamename.lastIndexOf('-') + 1) + ") " : " ") + "was finished by User!;";
	}
	else
	{
		if(_MWBG_Statistics.Errors > 1)
			_output = "ÿF66F21Game" + ((me.gamename.slice(me.gamename.lastIndexOf('-') + 1)) ? " ("+ me.gamename.slice(me.gamename.lastIndexOf('-') + 1) + ") " : " ") + "was finished!;";
		else
			_output = MW_GetInterpolationColor(_room[0] / _room[1]) + "Game" + ((me.gamename.slice(me.gamename.lastIndexOf('-') + 1)) ? " ("+ me.gamename.slice(me.gamename.lastIndexOf('-') + 1) + ") " : " ") + "was finished successfully!;";
	}
	// Level up info	
	if(_MWBG_Statistics.Init.CharLevel != me.GetStat(12))
		_output += "ÿ00FF40!!! Level up (" + me.GetStat(12) + ") !!!\n";
	
	// Gametime info
	_output += "ÿc0Duration:ÿc8 " + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_Statistics.Init.Ticks);
			
	// Add the relation between maximum and actual gametime
	if(me.maxgametime > 0)
		_output += " [" + ((GetTickCount() - _MWBG_Statistics.Init.Ticks) / 10 / me.maxgametime).toFixed(1) + "%]";
	
	// Exp info
	if(_MWBG_Statistics.Init.CharLevel == me.GetStat(12) && me.GetStat(13) - _MWBG_Statistics.Init.Exp > 0)
	{
		_output += "\nÿc0Experience:ÿc8 " + MWC_InsertDigitSeperator(me.GetStat(13) - _MWBG_Statistics.Init.Exp);

		if(MW_GetRequiredExp(me.GetStat(12) + 1) - MW_GetRequiredExp(me.GetStat(12)) > 0)
			_output += " [" + ((me.GetStat(13) - _MWBG_Statistics.Init.Exp) / (MW_GetRequiredExp(me.GetStat(12) + 1) - MW_GetRequiredExp(me.GetStat(12))) * 100).toFixed(4) + "%]";
	}
		
	// Potion Info
	if(_MWBG_Statistics.Potions.Hp > 0 || _MWBG_Statistics.Potions.Mp > 0  || _MWBG_Statistics.Potions.Rv > 0)
		_output += "\nÿc0Potions:ÿBE0000 (" + _MWBG_Statistics.Potions.Hp + ")ÿc3 (" + _MWBG_Statistics.Potions.Mp + ")ÿ9F008C (" + _MWBG_Statistics.Potions.Rv + ")";

	// Gold pickup
	_gold = NTC_MyGold() - _MWBG_Statistics.Init.Gold;
	
	if(_gold != 0)
		_output += "\nÿc0Gold:ÿc8 " + MWC_InsertDigitSeperator(_gold);
	
	// Picked items
	if(_MWBG_Statistics.ItemsPicked > 0)
		_output += "\nÿc0Items:ÿc8 " + _MWBG_Statistics.ItemsPicked;
	
	// Looted corpses
	if(_MWBG_Statistics.CorpsesLooted > 0)
		_output += "\nÿc0Looted:ÿc8 " + _MWBG_Statistics.CorpsesLooted;
	
	// Chest info
	if(_MWBG_Statistics.ChestsOpened > 0)
		_output += "\nÿc0Chests:ÿc8 " + _MWBG_Statistics.ChestsOpened;
	
	// Shrine info
	if(_MWBG_Statistics.ShrinesUsed > 0)
		_output += "\nÿc0Shrines:ÿc8 " + _MWBG_Statistics.ShrinesUsed;
	
	// Stash info
	_output += "\nÿc0Stash: " + MW_GetInterpolationColor(_room[0] / _room[1]) + _room[0] + "/" + _room[1];
	
	// Inventory info
	_room = MWI_GetStashRoom(false, true);
	_output += "\nÿc0Inventory: " + MW_GetInterpolationColor(_room[0] / _room[1]) + _room[0] + "/" + _room[1];
	// _output += "\nÿc0Color Check: " + MW_GetInterpolationColor(0.0) + "0% " + MW_GetInterpolationColor(0.25) + "25% " + MW_GetInterpolationColor(0.5) + "50% " + MW_GetInterpolationColor(0.75) + "75% " + MW_GetInterpolationColor(1.0) + "100% "; 
	
	// Error info
	if(_MWBG_Statistics.Errors > 0)
		_output +=	"\nÿBE0000Errors: " + _MWBG_Statistics.Errors;
		
	NTC_SendLogToOOG(NTC_LOG_COMMON, _output);
}

function MW_GetRequiredExp(level)
{
	// Returns the experience which is required for the level specified

	if(!level || level < 2 || level > 99)
		return -1;
	
	return _MWBG_ExperienceThresholds[level - 2];
}

function MW_GetScriptRuntimeMinutes(addZeros)
{
	return parseInt((GetTickCount() - _MWBG_CurScriptStartTick) / 6E4) % 60;
}

function MW_GetScriptRuntimeSeconds(addZeros)
{
	return parseInt((GetTickCount() - _MWBG_CurScriptStartTick) / 1E3) % 60;
}

function MW_SetStatusText()
{
	var _seconds, _minutes, _script, _timeString, _textString, _color;
	
	if(!_MWBG_ShowStatusText)
		return;
	
	_script = NTC_FindScript(MWConfig_Script[_MWBG_CurScriptIndex][0]);
	_seconds = MW_GetScriptRuntimeSeconds();
	_minutes = MW_GetScriptRuntimeMinutes();
	_timeString = "";
		
	if(_script && _script.running)
	{
		_textString = "ÿc2Running ÿc4" + MWConfig_Script[_MWBG_CurScriptIndex][0];
		
		if(_minutes == 0 && _seconds <= 5)	
		{
			if(_seconds % 2 == 1)
				_color = "ÿc8";
			else
				_color = "ÿc4";

			if(isNaN(MWConfig_Script[_MWBG_CurScriptIndex][1]) || MWConfig_Script[_MWBG_CurScriptIndex][1] <= 0)
				_timeString = _color + " [+Inf]";
			else
			{
				_timeString = _color + " [";
				
				if(MWConfig_Script[_MWBG_CurScriptIndex][1] < 10)
					_timeString += "0";
				
				_timeString += MWConfig_Script[_MWBG_CurScriptIndex][1] + ":00]";
			}
		}
		else
		{
			if(MWConfig_Script[_MWBG_CurScriptIndex][1] != 0)
			{
				if(_minutes >= MWConfig_Script[_MWBG_CurScriptIndex][1] || _minutes >= MWConfig_Script[_MWBG_CurScriptIndex][1] - 1 && _seconds >= 50)
					_timeString = "ÿc1";
				else if(_minutes >= MWConfig_Script[_MWBG_CurScriptIndex][1] - 1)
					_timeString = "ÿc8";
			}
			
			_timeString += " [" + MWC_ConvertTicksToTimeString(GetTickCount() - _MWBG_CurScriptStartTick) + "]"
			
			if(_MWBG_ShowCurrentPing)
				_timeString = " (" +  me.ping + ")" + _timeString;
		}
	}
	else
	{
		_textString = "ÿc1Stopped ÿc4" + MWConfig_Script[_MWBG_CurScriptIndex][0];
		
		if(_MWBG_ShowCurrentPing)
			_timeString = " (" +  me.ping + ")";
	}
		
	MWC_SetStatusText(_textString, _timeString);
}

function MW_GetInterpolationColor(percentage)
{
	var _colors, _colorIndex, _deltaColor, _colorPercentage, _component, _colorHexString;
	
	if(arguments.length < 1 || percentage < 0.0 || percentage > 1.0)
		return "ÿFFFFFF";
	
	// Define RGB colors - Note: red values between 191 and 208 are invalid as they would lead to a 'C' at the very beginning of the HEX string which would cause the HEX color to be misinterpreted as a D2 color code (ÿc)
	_colors = new Array(3);
	_colors[0] = [0, 255, 50];
	_colors[1] = [0, 120, 255];
	_colors[2] = [190, 0, 0];
	
	_colorHexString = "";
	
	// Transform the given percentage in order to match the color scale
	if(percentage < 0.5)
	{
		_colorIndex = 0;
		_colorPercentage = percentage / 0.4999;
	}
	else
	{
		_colorIndex = 1;
		_colorPercentage = (percentage - 0.5) / 0.5;
	}
	
	// Calculate the actual difference of each red, green and blue
	_deltaColor = new Array(3);
	_deltaColor[0] = _colors[_colorIndex + 1][0] - _colors[_colorIndex][0];
	_deltaColor[1] = _colors[_colorIndex + 1][1] - _colors[_colorIndex][1];
	_deltaColor[2] = _colors[_colorIndex + 1][2] - _colors[_colorIndex][2];

	for(var i = 0; i < _colors.length; i++)
	{
		// Calculate the color component
		_component = parseInt(_colors[_colorIndex][i] + _colorPercentage * _deltaColor[i]);
		
		if(_component >= 0 && _component < 256 && !(_component > 191 && _component < 208 && i == 0))
			_colorHexString += ((_component.toString(16).length == 1) ? "0" : "") + _component.toString(16);
		else
			return "ÿFFFFFF";
	}

	return "ÿ" + _colorHexString;
}

function MW_UpdateCommonLog(charlog)
{
	var _filepath, _fhandle, _newfile, _buffer, _lines, _itemData, _data, _date, _addedString;
	
	if(_MWBG_Statistics.CommonLog.length < 1)
		return true;
		
	if(arguments.length < 1)
		charlog = false;
		
	_lines = new Array();
	
	if(charlog)
		_filepath = "Logs/" + me.charname + "/MyCommonLog.txt";
	else
		_filepath = "Logs/CommonLog.txt";
	
	_fhandle = FileOpen(_filepath, 2);
	
	if(_fhandle)
	{
		while(!_fhandle.eof)
		{
			_buffer = _fhandle.ReadLine();
			
			if(_buffer != "" && _buffer.indexOf("//") == -1 || _buffer.indexOf("File") > -1)
				_lines.push(_buffer);
		}
		
		_fhandle.Close();
	}
	else if(!charlog)
		return false;
		
	if(_lines.length < 1 || _lines[0].indexOf("INVALID_DATE") > -1)
		_newfile = true;
	else 
		_newfile = false;
	
	_itemData = new Array([610], [611], [612], [613], [614], [615], [616], [617], [618], [619], [620], [621], [622], [623], [624], [625], [626], [627], [628], [629], [630], [631], [632], [633], [634], [635], [636], [637], [638], [639], [640], [641], [642], // Runes 
						  [557], [558], [559], [560], [561], [562], [563], [564], [565], [566], [567], [568], [569], [570], [571], [572], [573], [574], [575], [576], [577], [578], [579], [580], [581], [582], [583], [584], [585], [586], [597], [598], [599], [600], [601], // Gems
						  [647], [648], [649], // Keys
						  [650], [651], [652], // Organs
						  [654], [655], [656], [657]); // Essences
						  
	for(var i = 0; i < _itemData.length; i++)
		_itemData[i].push(_NTIPIDToName[_itemData[i][0]], 0); // Add the item's name and an integer to save the quantity of this item type
		
	for(var i = 1; i < _lines.length; i++)
	{
		_data = _lines[i].split(": ");

		for(var j = 0; j < _itemData.length; j++)
		{
			if(_data[0] == _itemData[j][1])
			{
				if(_data.length == 2)
					_itemData[j][2] = parseInt(_data[1].replace(",", ""));
				
				break;
			}
		}
	}
	
	for(var i = 0; i < _MWBG_Statistics.CommonLog.length; i++)
	{
		for(var j = 0; j < _itemData.length; j++)
		{
			if(_MWBG_Statistics.CommonLog[i] == _itemData[j][0])
			{
				_itemData[j][2]++;
				break;
			}
		}
	}
	
	_fhandle = FileOpen(_filepath, 1);
	
	if(_fhandle)
	{
		_date = new Date();
		_addedString = "";
		
		for(var i = 0; i < _MWBG_Statistics.CommonLog.length; i++)
		{
			_addedString += _NTIPIDToName[_MWBG_Statistics.CommonLog[i]];
			
			if(i + 1 < _MWBG_Statistics.CommonLog.length)
				_addedString += ", ";
		}
		
		if(_date)
		{
			if(_newfile)
				_fhandle.WriteLine("// File Created: " + _date.toLocaleFormat("%a %m/%d/%y %H:%M:%S") + " <> Last Update: " + _date.toLocaleFormat("%a %m/%d/%y %H:%M:%S") + " by " + me.charname + " (" + _addedString + ")");
			else
				_fhandle.WriteLine(_lines[0].split(" <>")[0] + " <> Last Update: " + _date.toLocaleFormat("%a %m/%d/%y %H:%M:%S") + " (" + me.charname + ": " + _addedString + ")");
		}
		else
		{
			if(_newfile)
				_fhandle.WriteLine("// File Created: INVALID_DATE <> Last Update: INVALID_DATE" + " (" + me.charname + ": " + _addedString + ")");
			else
				_fhandle.WriteLine(_lines[0].split(" <>")[0] + " <> Last Update: INVALID_DATE" + " (" + me.charname + ": " + _addedString + ")");
		}
		
		_fhandle.WriteLine("// ###### Runes ######");
		for(var i = 0; i < _itemData.length; i++)
		{
			_fhandle.WriteLine(_itemData[i][1] + ": " + MWC_InsertDigitSeperator(_itemData[i][2]));
		
			if(_itemData[i][0] == 642)
				_fhandle.WriteLine("\n// ###### Gems ######");
			else if(_itemData[i][0] == 601)
				_fhandle.WriteLine("\n// ###### Keys ######");
			else if(_itemData[i][0] == 649)
				_fhandle.WriteLine("\n// ###### Organs ######");
			else if(_itemData[i][0] == 652)
				_fhandle.WriteLine("\n// ###### Essences ######");
			else if(_itemData[i][0] == 561 || _itemData[i][0] == 566 || _itemData[i][0] == 571 || _itemData[i][0] == 576 || _itemData[i][0] == 581 || _itemData[i][0] == 586)
				_fhandle.WriteLine("");
		}
				
		_fhandle.Close();
	}
	else if(!charlog)
		return false;
		
	if(!charlog)
		return MW_UpdateCommonLog(true);
	
	_MWBG_Statistics.CommonLog = new Array();
	
	return true;
}

function MW_CheckMinGametime()
{
	var _deltaTime; 
		
	do
	{
		if(_deltaTime)
		{
			if(!NTC_InTown())
				NTTM_CheckAct();
			
			MWC_SetStatusText("ÿc8Awaiting minimum gametime... [" + MWC_ConvertTicksToTimeString(_deltaTime) + "]");
			
			NTC_Delay(500);
		}
			
		_deltaTime = me.mingametime * 1E3 - GetTickCount() + _MWBG_Statistics.Init.Ticks;
	
	} while(_deltaTime > 0 && !_MWBG_UserExit);
}
Du müsstest in deinem Diablo Script noch folgendes einfügen:
Code:
NTC_SendMsgToScript("MWBotGame.ntj", "DIA_KILLED");
Ausserdem die Konstante für die Wartezeit auf einen sinnvollen Wert setzen.
Bedenke, dass es eine Abtastrate von gut 500ms gibt, du solltest also definitiv ein paar Sekunden Luft einplanen.
Probier es mal aus. :)

LG
Muddy
07/18/2011 14:58 TheCrazy11#2545
Quote:
Originally Posted by Muddy_Waters View Post
Du müsstest in deinem Diablo Script noch folgendes einfügen:
Code:
NTC_SendMsgToScript("MWBotGame.ntj", "DIA_KILLED");
Mit den Übergabewerten ein bisschen aufpassen, Muddy! :D
Code:
NTC_SendMsgToScript("MWBotGame.ntj", "[COLOR="Red"]DIA_KILL[/COLOR]");
PS: Habe gerade Gott zurechtgewiesen, wo bleibt mein Keks? ;)
07/18/2011 15:12 Muddy Waters#2546
Das kommt davon, wenn man schon mit dem Schreiben des Beitrags beginnt, während man noch an dem Script rumwerkelt. :D

Aber wenn du wüsstest, wie schleppend ich mit meinem Einstiegsprojekt, einem Maphack auf D2BS Basis, voran komme, würdest du die Aussage mit dem Gott nochmal überdenken. :o
Gut, das mag zum Teil auch daran liegen, dass ich meine verfügbare Zeit derzeit eher mit dem Daddeln einer D2 Mod im SP verschwende, aber es macht eben einfach irgendwie Spaß. :)

@fred
Wie du es machst ist eigentlich egal, hauptsache konsistent. ;)

LG
Muddy
07/18/2011 15:34 lanara#2547
Quote:
Originally Posted by Muddy_Waters View Post
Aber wenn du wüsstest, wie schleppend ich mit meinem Einstiegsprojekt, einem Maphack auf D2BS Basis, voran komme, würdest du die Aussage mit dem Gott nochmal überdenken. :o
Was haste denn schon wieder vor? :P

Quote:
Originally Posted by Muddy_Waters View Post
Gut, das mag zum Teil auch daran liegen, dass ich meine verfügbare Zeit derzeit eher mit dem Daddeln einer D2 Mod im SP verschwende, aber es macht eben einfach irgendwie Spaß. :)
Du auch, welchen spielste denn? :o Hänge im Moment (mal wieder) an MedianXL. :|
07/18/2011 15:45 fred9x9#2548
Quote:
Originally Posted by TheCrazy11 View Post
Mit den Übergabewerten ein bisschen aufpassen, Muddy! :D
Code:
NTC_SendMsgToScript("MWBotGame.ntj", "[COLOR="Red"]DIA_KILL[/COLOR]");
PS: Habe gerade Gott zurechtgewiesen, wo bleibt mein Keks? ;)
Dorthin?
Code:
NTP_DoPrecast(true);
	
	if(me.classid == NTC_CHAR_CLASS_PALADIN && !MWC_CheckForExpShrineUsers())
		NTC_PutSkill(109, NTC_HAND_RIGHT);
				
	if(!NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe))
	{
		NTC_SendMsgToScript("MWBotGame.ntj", "NTTMGR_CheckSafe()");
		return;
	}

	NTC_FindUnit(NTC_UNIT_MONSTER, 243, 100);

	if(!NTA_KillMonster(243))
	{
		NTC_SendMsgToScript("MWBotGame.ntj", "NTA_KillMonster()");
		return;
	}

	NTSI_PickItems();

  ??        NTC_SendMsgToScript("MWBotGame.ntj", "DIA_KILL"); ??

	if(NTConfig_PublicMode)
		Say(""); //ff Say("Next game");
07/18/2011 15:48 Muddy Waters#2549
Ja genau. Und bitte entferne auch direkt die nachfolgende if-Anweisung mit dem Say() Aufruf mit dem leeren String als Parameter, das Gebilde sieht einfach fürchterlich aus. ;)

LG
Muddy
07/18/2011 16:52 RealAkitos#2550
Vorschlag: Der Bot sollte kein chicken machen wenn das clone diablo event läuft... Ich hab gestern nen Anni deswegen verkackt :( Dia war auf 1% gibt mir ne kelle ich droppe unter chickenlife und der bot leaved instant das game... game closed... ^^ Bitte unbedingt ändern!!! Danke
Auch wenn man im Pause Modus ist sollte kein chicken gemacht werden oder man sollte es zumindest einstellen können ob er es auf Pause machen soll. Aber beim clone diablo event sollte er auf keinenfall chicken machen!