[D2NT] Public Botten for Dummies

07/12/2011 21:39 maxor11#2056
Werde dann mal nen bischen dran rumspielen, da mir das sonst zu lange ist ;)

aber danke jetzt weiß ich wo ich das einstellen und fixen kann
07/16/2011 20:03 lanara#2057
Ich habe mal eine überarbeitete NTBotLeech, die deutlich besser funktionieren sollte als die normale. Zum einen wird der Bot damit nichtmehr "/f l" spammen, sondern die Friendlist lediglich einmal abfragen wenn er in den Chat kommt. Sollte zu dem Zeitpunkt noch kein Spiel offen sein, wartet er bis der Leader ein Spiel erstellt und joined anhand der grünen Friendmessage. Damit sollte man um einiges schneller joinen als bisher und auch das nervige Friendlist gespamme hat ein Ende. Wichtig ist nur, dass LeaderAccountName und LeaderName richtig eingetragen sind, Groß-/Kleinschreibung spielt übrigens keine Rolle. Über Feedback würde ich mich freuen.

Code:
//###################################################################
//###########################Einstellungen###########################
//###################################################################
	
var LeaderAccountName          = "LeaderAccountName";
var LeaderName                 = "LeaderName";
var GamePassword               = "GamePassword";
var JoinGameAgain              = false; // wenn der Bot nach chicken oder disconnect ins selbe Spiel nochmal gehen soll, auf true stellen

var UseCDKeyChangeTrick        = false; // Wenn der LeechBot mehrere CD Keys nutzen soll, dann auf true stellen.

var JoinRandomChannel          = false;
var JoinChannelInChat          = "OP MyBaal";
var FirstJoinMessage           = ""; // Soll der Leechbot etwas sagen, wenn er in den Chat kommt, dann hier eintragen
var ChatMessageAfterGame       = ""; // Soll der Leechbot etwas sagen, wenn er aus dem Spiel kommt, dann hier eintragen

//###################################################################
//##############################Delays###############################
//###################################################################

var GameMinLength              = 180000;

// realm delays (minutes)
var UnableToConnectRetry       = 2;
var RealmDownRetry             = 60;
var DisconnectedRetry          = 2;
var CdKeyInUseRetry            = 2;

// interface delays (milliseconds)
var ConnectingToBnetTimeout    = 20000;
var CharacterScreenTimeout     = 10000;
var PleaseWaitTimeout          = 10000;
var CreateGameThreshold        = 10000;
var CreateGameThresholdRandom  = 1000;
var CreateGameTimeout          = 15000;
var WaitInLineTimeout          = 15000;
var CharacterSelectDelay       = 1000;
var LoginDelay                 = 1000;
var ClickDelay                 = 500;
var TextDelay                  = 500;
var ClickDelayRandom           = 500;
var TextDelayRandom            = 500;
var GameDoesNotExistDelayMin   = 600000;
var GameDoesNotExistDelayMax   = 900000;
var GameDoesNotExistTimeout    = 30000;
var WaitBeforeEnterChatMin     = 1000;
var WaitBeforeEnterChatMax     = 2000;
var WaitInChatBeforeActionsMin = 2000;
var WaitInChatBeforeActionsMax = 3000;

//###################################################################
//###################################################################
//###############DO NOT CHANGE ANYTHING BELOW THIS###################
//###################################################################
//###################################################################

//D2NT Manager Command

const D2NT_MGR_LOADING = 1;
const D2NT_MGR_READY = 2;
const D2NT_MGR_LOGIN = 3;
const D2NT_MGR_CREATE_GAME = 4;
const D2NT_MGR_INGAME = 5;
const D2NT_MGR_RESTART = 6;
const D2NT_MGR_CHICKEN = 7;
const D2NT_MGR_PRINT_STATUS = 8;
const D2NT_MGR_PRINT_LOG = 9;

var LastGameMade     = GetTickCount();
var LastGameStatus     = 0;
var NextGameMake     = 0;
var InGameAt       = 0;
var ChatActionsDone   = false;
var LastGameFailed     = false;
var SayChatMsgAfterGame = true;

Include("libs/controlInfo.ntl");

var ControlData = new controlInfo();

var SameGame = "";
var OldGame = "";
var Game = "";
var Debug = false;
var JoinChatAfterGame    = true;


function NTMain()
{
	Delay(1000);

	var _ingame = false;

	ControlData.ClickDelay = ClickDelay;
	ControlData.TextDelay = TextDelay;
	ControlData.ClickDelayRandom = ClickDelayRandom;
	ControlData.TextDelayRandom = TextDelayRandom;

	while(1)
	{
		if(me.ingame)
		{
			OldGame = me.gamename;

			if(!InGameAt)
				InGameAt = GetTickCount();

			if(!_ingame)
			{
				RunGC(); // run garbage collector between each game

				if(Load("NTBot/NTBotGame.ntj"))
				{
					_ingame = true;

					if(me.playtype > 0)
						sendEventToOOG(D2NT_MGR_INGAME, "In Game[IP:" + me.gameserverip.split(".")[3] + "]", 0);
					else
						sendEventToOOG(D2NT_MGR_INGAME, "In Game", 0);

					LastGameStatus = 2; // in game successful
				}
			}

			Delay(1000);
		}
		else
		{
			if(_ingame)
			{
				_ingame = false;
				SayChatMsgAfterGame = true;

				sendEventToOOG(D2NT_MGR_READY, "", 0);
			}

			locationAction(ControlData.getLocation());

			Delay(500);
		}
	}
}

function locationAction(location)
{
	var _randomChannel;
	
	switch(location.id)
	{
	case 3: // Lobby Chat
		sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);

		if(!ChatActionsDone)
		{  
			ChatActionsDone = true;

			Delay(Random(WaitInChatBeforeActionsMin, WaitInChatBeforeActionsMax));

			if(JoinRandomChannel || JoinChannelInChat != "")
			{
				SetStatusText("ÿc8Joining channel...");
				Say("/join " + (JoinRandomChannel ? getRandomString(Random(3,10)) : JoinChannelInChat));
				Delay(2000);
			}

			if(FirstJoinMessage)
			{
				Say(FirstJoinMessage);
				Delay(1000);
			}
		}

		if (SayChatMsgAfterGame == true)
		{
			if(ChatMessageAfterGame && OldGame != "")
				Say(ChatMessageAfterGame);
				
			SetStatusText("ÿc8Checking friendlist...");
			Say("/f l");
			SayChatMsgAfterGame = false;
			Delay(1500);
		}

		Game = "";

		if(chat = ControlData.get(ControlData.controls.lobby.chat.textBox.channelText))
		{
			var found_leader = false;
			lines = chat.GetText();
			for (var line_id = lines.length - 1; line_id > -1; line_id--)
			{
				if (found_leader) // useless... :/
					break;

				if (lines[line_id].substring(0,1) == " ")
					continue;

				// retrieving the whole message
				var msg = lines[line_id].replace(/^\s+|\s+$/, "");
				var msglines = 1;
				while (lines[line_id+msglines] != undefined && lines[line_id+msglines].substring(0,2) == "  ")
				{
					msg += " " + lines[line_id+msglines].replace(/^\s+|\s+$/, "");
					msglines++;
				}
				
				// checking if the msg is a friendly whisper
				if (msg.toLowerCase().lastIndexOf(LeaderName.toLowerCase() + " (*" + LeaderAccountName.toLowerCase() + ")") > -1)
				{
					var regGameNameWhispered=/^.*(game|partie|spiel|partita|partida).*(nomm[^\s]*|called|chiamata)\s*([\w\s-]*\w)\s*\.\s*$/gi;
					if (msg.match(regGameNameWhispered))
						Game = msg.replace(regGameNameWhispered, "$3");

					if (Game != "")
					{
						found_leader = true;
						break;
					}
				}

				// checking if the msg is from the friend list
				if (msg.toLowerCase().lastIndexOf(": " + LeaderAccountName.toLowerCase() + ",") > -1)
				{
					found_leader = true;
					var regOffline=/^.*(offline|desconectado).*$/gi;
					var regInChat=/^.*(channel|canale?)\s*([\w\s-]*\w)\.?\s*$/gi;
					var regGameName=/^.*(game|partie|spiel|partita|partida)\s*([\w\s-]*\w)\s*\(priv[^\)]*\)\.\s*$/gi;

					if (msg.match(regOffline))
						SetStatusText("ÿc8Leader is currently offline.");
					else if (msg.match(regInChat))
						SetStatusText("ÿc8Waiting for leader to create a game.");
					else if (msg.match(regGameName))
						Game = msg.replace(regGameName, "$2");

					break;
				}
			}

			if (found_leader == false)
			{
				DebugInOOG("I couldn\'t find the leader in my friend list!");
				SetStatusText("ÿc8Leader not found.");
			}
			
			if (Game != "")
			{
				DebugInOOG('Leader is in the game "' + Game + '"');
				//ControlData.click(ControlData.controls.lobby.button.join);
				//Delay(100);
				
				if(!JoinGameAgain)
				{
					if (Game != SameGame)
					{
						SetStatusText("ÿc8Joining Game: " + Game);
						
						if (UseCDKeyChangeTrick)
						{
							sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
							Delay(1000);
						}

						ControlData.click(ControlData.controls.lobby.button.join);
						Delay (200);
					}
					else
						SetStatusText("ÿc8Waiting for next game...");
				}
				else
				{
					SetStatusText("ÿc8Joining Game: " + Game);
					
					if (UseCDKeyChangeTrick)
					{
						sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
						Delay(1000);
					}

					ControlData.click(ControlData.controls.lobby.button.join);
					Delay (200);
				}

			}
		}
		else
		{
			DebugInOOG("I can\'t read the chat!");
		}

		if(Game != "")
			SameGame = Game;

		break;

	case 1:    // Lobby
		if(location.id == 1 && JoinChatAfterGame)
		{
			Delay(Random(WaitBeforeEnterChatMin, WaitBeforeEnterChatMax));
			ControlData.click(ControlData.controls.lobby.button.enterChat);
			break;
		}
		break;

	case 2: // Waiting In Line
		if(GetTickCount()-LastGameMade > WaitInLineTimeout)
			ControlData.click(ControlData.controls.lobby.inLine.button.cancel);
		break;

	case 4: // Create Game
		if(!ControlData.get(ControlData.controls.lobby.create.editBox.gameName))
		{
			ControlData.click(ControlData.controls.lobby.button.join);
			Delay (500);
			ControlData.click(ControlData.controls.lobby.button.create);
			Delay (500);
			break;
		}

		sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);

		locationTimeout(5000, location);

		LastGameMade = GetTickCount();
		LastGameStatus = 1; // pending creation
		break;

  case 5: // Join Game
    if (Game)
    {
		ControlData.setText( ControlData.controls.lobby.join.editBox.gameName, Game);
		Delay (100);
		ControlData.setText( ControlData.controls.lobby.join.editBox.password, GamePassword);
		Delay (100);
		ControlData.click(ControlData.controls.lobby.join.button.joinGame);
		RunGC(); // run garbage collector between each game
		locationTimeout(5000, location);
		LastGameStatus = 1; // pending join
	}
	else
	{
		DebugInOOG("No game to join : cancelling");
		me.Cancel(1);
		Delay(1000);
	}
	break;

	case 6: // Ladder
		break;

	case 7: // Channel List
		break;

	case 8: // Main Menu
		if(ControlData.getCurrentRealmIndex() == me.gatewayid)
		{
			outputGameLength();
			ControlData.click(ControlData.gameTypes[me.playtype]);
		}
		else
			ControlData.click(ControlData.controls.mainMenu.button.gateway);
		break;

	case 9: // Login
		sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
		Delay(LoginDelay);

		ControlData.setText(ControlData.controls.login.editBox.accountName, me.account);

		sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);

		locationTimeout(5000, location);
		break;

	case 10: // Login Error (this is a fatal error, so stop)
		sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
		Delay(3500);
		break;

	case 11: // Unable To Connect
		timeoutDelay(UnableToConnectRetry*60*1000, location)
		ControlData.click(ControlData.controls.login.unableToConnect.button.ok);
		break;

	case 12: // Character Select
		var _time, _control;

		sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);

		for(_time = 0 ; _time < CharacterScreenTimeout ; _time += 500)
		{
			_control = ControlData.get(ControlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
			if(_control && _control.GetText() != undefined)
				break;

			Delay(500);
		}

		if(_time < CharacterScreenTimeout)
		{
			Delay(CharacterSelectDelay);

			ControlData.click(ControlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
			ControlData.click(ControlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);

			// reset last game made, so it doesnt make a game immediately
			InGameAt = 0;
			setNextGameMake();
		}
		else
		{
			ControlData.click(ControlData.controls.characterSelect.button.exit);
			timeoutDelay(RealmDownRetry*60*1000, location);
		}
		break;

	case 13: // Realm Down - Character Select screen
		ControlData.click(ControlData.controls.characterSelect.button.exit);
		timeoutDelay(RealmDownRetry*60*1000, location);
		break;

	case 14: // Character Select - Disconnected
		timeoutDelay(DisconnectedRetry*60*1000, location);
		ControlData.click(ControlData.controls.characterSelect.disconnected.button.ok);
		break;

	case 15: // New Character
		break;    

	case 16: // Character Select - Please Wait popup
		if(!locationTimeout(PleaseWaitTimeout, location))
			ControlData.click(ControlData.controls.characterSelect.pleaseWait.button.cancel);
		break;

	case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
		ControlData.click(ControlData.controls.lobby.lostConnection.button.ok);
		break;

	case 18: // D2 Splash
		ControlData.click(ControlData.controls.d2Splash.textBox.copyright);
		break;

	case 19: // Login - Cdkey In Use
		timeoutDelay(CdKeyInUseRetry*60*1000, location);
		ControlData.click(ControlData.controls.login.cdkeyInUse.button.ok);
		break;

	case 20: // Single Player - Select Difficulty
		ControlData.click(ControlData.singlePlayerDifficulties[me.diff]);
		break;

	case 21: // Main Menu - Connecting
		if(!locationTimeout(ConnectingToBnetTimeout, location))
			ControlData.click(ControlData.controls.mainMenu.connecting.button.cancel);
		break;

	case 22: // Login - Invalid Cdkey (classic or xpac)
		sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
		Delay(3500);
		break;    

	case 23: // Character Select - Connecting
		if(!locationTimeout(CharacterScreenTimeout, location))
			ControlData.click(ControlData.controls.characterSelect.button.exit);
		break;

	case 24: // Server Down - not much to do but wait..
		break;

	case 25: // Lobby - Please Wait
		if(!locationTimeout(PleaseWaitTimeout, location))
			ControlData.click(ControlData.controls.lobby.pleaseWait.button.cancel);
		break;

	case 26: // Lobby - Game Name Exists
		sendEventToOOG(D2NT_MGR_PRINT_LOG, "yE00000Game already exists", 0);

		InGameAt = 0;
		LastGameStatus = 0;
		setNextGameMake();

		locationTimeout(15000, location);
		break;

	case 27: // Gateway Select
		ControlData.clickRealmEntry(me.gatewayid);
		ControlData.click(ControlData.controls.gateway.button.ok);
		break;

	case 28: // Lobby - Game Does Not Exist
		InGameAt = Random(GameDoesNotExistDelayMin, GameDoesNotExistDelayMax);
		LastGameStatus = 0;
		setNextGameMake();

		locationTimeout(GameDoesNotExistTimeout, location);
		break;
	default:
		DebugInOOG("Unhandled location : "+location.id);
		break;
	}
	//DebugInOOG("Location : "+location.id);
}

function sendEventToOOG(locationId, statusString, pendingTime)
{
	return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
}

function setNextGameMake()
{
	LastGameMade = GetTickCount();
	NextGameMake = LastGameMade + CreateGameThreshold + Random(0-CreateGameThresholdRandom, CreateGameThresholdRandom) + InGameAt;
	InGameAt = 0;
	ChatActionsDone = false;
}

function outputGameLength()
{
	if(InGameAt)
	{
		duration = GetTickCount() - InGameAt;

		InGameAt = (duration < GameMinLength ? GameMinLength - duration : 0);
	}
}

function locationTimeout(time, location)
{
	endtime = GetTickCount() + time;

	while(ControlData.getLocation().id == location.id && endtime > GetTickCount())
	{
		sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
		Delay(500);
	}

	return (ControlData.getLocation().id != location.id);
}

function timeoutDelay(time, location)
{
	endtime = GetTickCount() + time;

	while(endtime > GetTickCount())
	{
		sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
		Delay(1000);
	}
}

function getRandomString(_length)
{
	_retString = "";
	_charSet = "0123456789abcdefghijklmnopqrstuvwxyz";

	while(_length--)
	{
		_retString += _charSet.charAt(Random(0, _charSet.length-1));
		Delay(1);
	}

	return _retString;
}
function DebugInOOG(logString)
{
	if (Debug)
		return SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + logString);
	else
		return false;
}
07/16/2011 20:49 HacK.#2058
Ich bekomme nen fehler
[Only registered and activated users can see links. Click Here To Register...]
Zeile 735: control = this.get( controlData.controls.mainMenu.button.gateway );
07/16/2011 21:31 lanara#2059
Quote:
Originally Posted by HacK. View Post
Ich bekomme nen fehler
[Only registered and activated users can see links. Click Here To Register...]
Zeile 735: control = this.get( controlData.controls.mainMenu.button.gateway );
Wie auch immer das bei dir dahin gekommen ist. Oo Normal müsste da stehen:

Code:
		control = this.get( this.controls.mainMenu.button.gateway );
07/17/2011 02:14 HacK.#2060
Ty ich weiß auch nicht wieso es bei mir anders ist ^^ naja nun klappt es danke..
07/17/2011 17:19 wowbot.at#2061
Quote:
Originally Posted by lanara View Post
Wie auch immer das bei dir dahin gekommen ist. Oo Normal müsste da stehen:

Code:
		control = this.get( this.controls.mainMenu.button.gateway );
war bei mir genau so ... komisch
07/17/2011 20:50 HacK.#2062
Der Bot funkt perfekt doch wenn da steht das der Leader in xXx Spiel beigetreten ist, geht mein bot zu schnell rein, er soll paar Sekunden länger warten weil der Leader das Spiel nicht so schnell öffnet lässt er manchmal paar runden aus also wo kann man die Sekunden einstellen das er in das game Joinen soll nach dem der Leader ins Spiel ein geklickt hat?
Und wie kann ich noch einstellen das er nicht ins Baal Kammer gehen soll (ich sterbe da oft und verliere exp)
07/17/2011 21:44 lanara#2063
Code:
  case 5: // Join Game
    if (Game)
    {
		ControlData.setText( ControlData.controls.lobby.join.editBox.gameName, Game);
		Delay ([COLOR="Red"]100[/COLOR]);
		ControlData.setText( ControlData.controls.lobby.join.editBox.password, GamePassword);
		Delay (100);
		ControlData.click(ControlData.controls.lobby.join.button.joinGame);
		RunGC(); // run garbage collector between each game
		locationTimeout(5000, location);
		LastGameStatus = 1; // pending join
	}
Das markierte Delay erhöhen.

Und zum zweiten Problem, in der NTBaalLeech das markierte entfernen:
Code:
	while(NTC_InMyParty(NTConfig_Leader) [COLOR="Red"]&& NTC_FindUnit(NTC_UNIT_MONSTER, 543)[/COLOR])
07/18/2011 12:51 Muddy Waters#2064
Quote:
Originally Posted by HacK. View Post
ok vielen dank
Ich verweise mal still und heimlich auf diesen [Only registered and activated users can see links. Click Here To Register...].
Wenn dein Beitrag nur sinngemäß "Danke!" enthält, spar ihn dir und nutze stattdessen den dafür vorgesehenen Button. ;)

LG
Muddy
07/19/2011 08:57 Cobra80#2065
grüss euch

hab da auch mal ne Frage und sorry schon mal falls es in den Weiten dieses Threads schon mal beantwortet wurde
ein sehr lustiges Add von dem Bot iss ja das man im Manager sieht wieviel XP man gesammelt hat und Gold usw
Worauf ich immer am meisten achte ist wieviel runs es ca. noch brauch bis zum nächsten LVL bzw wieviel % ich beim LvL Progress hab ... nun jetzt sind meine beiden Paladine lvl98 und im Manager steht nur noch Blödsinn ... angeblich iss mein lvl Progress -737% und ich brauch noch 45000 runs bis lvl 99 ... kann ich irgendwie nich ganz glauben :D

Vielleicht hatten ja schon andere ähnliches und es gibt schon ne bekannte Lösung ... Vielen dank schon mal im Vorraus
07/19/2011 09:09 lanara#2066
Dass es ab Level 98 rumspinnt ist leider ein bekannter Bug. Ich hatte mir das irgendwann schonmal angeschaut und wenn ich mich recht erinnere lag das an einem fehlerhaften Rückgabewert der XP ab lvl98.
07/19/2011 11:49 Cobra80#2067
wieviel runs sind es denn ungefähr bei 3-6 Spielern Dia und Baal ? schwer zu sagen oder ? von 97 auf 98 waren es zwischen 1500 und 1700 ... also rechne ich jetzt ma mit 3000-3500 ?!?
07/19/2011 12:19 lanara#2068
Keine Ahnung, schon bissel was her, dass ich einen Char auf 99 gelevelt hab. :o Vielleicht fragst du mal [Only registered and activated users can see links. Click Here To Register...], denke da wirst du eher eine Antwort bekommen.
07/19/2011 18:49 modwx#2069
ich bekomm als co leecher nachdem baal tot ist die msg NTBaalLeechFight.ntj : NTC_FindUnit() failed (the worldstone chamber)
weis jemand was da falsch läuft/eingestellt ist bzw geändert werden muss?
07/19/2011 19:05 Cobra80#2070
iss bei mir auch ... der leecher bzw cofighter findet baal nich weil er eben schon tod iss ... ich ignorier es einfach ... hat auch absolut keine auswirkungen