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. ;)
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);
}
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. :)