[Iso Help] Magic8Ball Script

07/07/2011 10:55 eXoo~#1
Kennen ja bestimmt einige, man stellt eine Frage und der 8Ball gibt dir die Antwort :) Wollte mir nen kleinen Spaß erlauben mit meinen Leechern, daher habe ich versucht das Ganze in meinen NT-Bot zu implementieren.
Der Script hat auch bis D2NT 3.1 gut funktioniert, aber seitdem ich ETAL benutze will er nichtmehr :S
Kann jemand da vll einen Fehler entdecken?
Das Ganze läuft eigentlich so wie NTHostile / Antihost etc.
Ist im NTBot Ordner und auch in der NTBotgame vertreten.
Kleiner Auszug daraus:
Code:
Load("NTBot/tools/NTToolsThread.ntj");
		Load("NTBot/NTHostile.ntj");
		Load("NTBot/NTm8b.ntj");
Und hier die NTm8b.ntj Datei selber :)

Code:
var _answer;
RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);
Ball_Trigger = "ask8ball";

function NTMain()
{
   Include("libs/common/NTCommon.ntl");
   NTC_IncludeLibs();
   NTC_IncludeConfig("NTBot/char_configs");
   NT_LoadConfig();
   NTA_Initialize();
   
   Print("ÿc1Magic 8 Ball");
}

function NT_GameMsgEvents(msg, type)
{
		if((type == 0 && msg.indexOf(Ball_Trigger) != -1))
      {
         Say("looks into his Magic 8 Ball: " + MW_GetEightBallAnswer());

      }
}

function MW_GetEightBallAnswer()
{
    var _answer;
    
    switch(Random(0, 48))
    {
        case 0:
            _answer = "As I see It, Yes";
            break;
        case 1:
            _answer = "It is decidedly so";
            break;
        case 2:
            _answer = "It is certain";
            break;
        case 3:
            _answer = "Most likely";
            break;
        case 4:
            _answer = "Outlook good";
            break;
        case 5:
            _answer = "Signs point to Yes";
            break;
        case 6:
            _answer = "Without a doubt";
            break;
        case 7:
            _answer = "YES";
            break;
        case 8:
            _answer = "Yes, definitely";
            break;
        case 9:
            _answer = "You may rely on it";
            break;
	case 10:
            _answer = "Better not tell you now";
            break;
	case 11:
            _answer = "Cannot predict now";
            break;
	case 12:
            _answer = "Concentrate and ask again";
            break;
	case 13:
            _answer = "Don't count on it";
            break;
	case 14:
            _answer = "My reply is No";
            break;
	case 15:
            _answer = "My sources say No";
            break;
	case 16:
            _answer = "Outlook not so good";
            break;
	case 17:
            _answer = "Reply Hazy, Try again";
            break;
	case 18:
            _answer = "Stop trolling";
            break;
	case 19:
            _answer = "You missed that day in school, huh?";
            break;
	case 21:
            _answer = "Ask Claz.(/w *118) TY TY";
            break;
	case 22:
            _answer = "Chav -,-";
            break;
	case 23:
            _answer = "How you dare to ask that?";
            break;
	case 24:
            _answer = "GTFO Randpiss";
            break;
	case 25:
            _answer = "Tosser... ,luv.";
            break;
	case 26:
            _answer = "What about some RL instead?";
            break;
	case 27:
            _answer = "That was serious?";
            break;
	case 28:
            _answer = "Absolutely YES.. and Joe is a jew.";
            break;
	case 29:
            _answer = "NO NO NO NO... joe is no jew. i was kidding, he is a jew.";
            break;
	case 30:
            _answer = "Very doubtful";
            break;
	case 31:
            _answer = "Not only no, but HELL No!";
            break;
	case 32:
            _answer = "Not only yes, but HELL Yes!";
            break;
	case 33:
            _answer = "You will regret it!";
            break;
	case 34:
            _answer = "Signs point to No";
            break;
	case 35:
            _answer = "Outlook is disturbing";
            break;
	case 36:
            _answer = "Please shut up, go take your dumb questions somewhere else.";
            break;
	case 37:
            _answer = "Not only yes, but HELL YES";
            break;
	case 38:
            _answer = "Not only no, but HELL NO";
            break;
	case 39:
            _answer = "I'll kill you.";
            break;
	case 40:
            _answer = "Okay.";
            break;
	case 41:
            _answer = "Sure.";
            break;
	case 42:
            _answer = "Probably.";
            break;
	case 43:
            _answer = "You're a girl, you ask too many fucking questions.";
            break;
	case 44:
            _answer = "Uh-huh.";
            break;
	case 45:
            _answer = "Yup.";
            break;
	case 46:
            _answer = "Could you repeat the question?";
            break;
	case 47:
            _answer = "Nazi -,-";
            break;
        default:
            _answer = "Ask again later";
    }
    
    NTC_Delay(1);
    
    return _answer;
}
Früher gab der Bot also eine Antwort sobald jemand ingame (.)ask8ball "Frage" geschrieben hat, mit Etal nichtmehr
HELP?!^^
07/07/2011 11:47 TheCrazy11#2
Quote:
Originally Posted by eXoo~ View Post
Kennen ja bestimmt einige, man stellt eine Frage und der 8Ball gibt dir die Antwort :) Wollte mir nen kleinen Spaß erlauben mit meinen Leechern, daher habe ich versucht das Ganze in meinen NT-Bot zu implementieren.
Der Script hat auch bis D2NT 3.1 gut funktioniert, aber seitdem ich ETAL benutze will er nichtmehr :S
Kann jemand da vll einen Fehler entdecken?
Das Ganze läuft eigentlich so wie NTHostile / Antihost etc.
Ist im NTBot Ordner und auch in der NTBotgame vertreten.
Kleiner Auszug daraus:
Code:
Load("NTBot/tools/NTToolsThread.ntj");
		Load("NTBot/NTHostile.ntj");
		Load("NTBot/NTm8b.ntj");
Und hier die NTm8b.ntj Datei selber :)

Code:
var _answer;
RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);
Ball_Trigger = "ask8ball";

function NTMain()
{
   Include("libs/common/NTCommon.ntl");
   NTC_IncludeLibs();
   NTC_IncludeConfig("NTBot/char_configs");
   NT_LoadConfig();
   NTA_Initialize();
   
   Print("ÿc1Magic 8 Ball");
}

function NT_GameMsgEvents(msg, type)
{
		if((type == 0 && msg.indexOf(Ball_Trigger) != -1))
      {
         Say("looks into his Magic 8 Ball: " + MW_GetEightBallAnswer());

      }
}

function MW_GetEightBallAnswer()
{
    var _answer;
    
    switch(Random(0, 48))
    {
        case 0:
            _answer = "As I see It, Yes";
            break;
        case 1:
            _answer = "It is decidedly so";
            break;
        case 2:
            _answer = "It is certain";
            break;
        case 3:
            _answer = "Most likely";
            break;
        case 4:
            _answer = "Outlook good";
            break;
        case 5:
            _answer = "Signs point to Yes";
            break;
        case 6:
            _answer = "Without a doubt";
            break;
        case 7:
            _answer = "YES";
            break;
        case 8:
            _answer = "Yes, definitely";
            break;
        case 9:
            _answer = "You may rely on it";
            break;
	case 10:
            _answer = "Better not tell you now";
            break;
	case 11:
            _answer = "Cannot predict now";
            break;
	case 12:
            _answer = "Concentrate and ask again";
            break;
	case 13:
            _answer = "Don't count on it";
            break;
	case 14:
            _answer = "My reply is No";
            break;
	case 15:
            _answer = "My sources say No";
            break;
	case 16:
            _answer = "Outlook not so good";
            break;
	case 17:
            _answer = "Reply Hazy, Try again";
            break;
	case 18:
            _answer = "Stop trolling";
            break;
	case 19:
            _answer = "You missed that day in school, huh?";
            break;
	case 21:
            _answer = "Ask Claz.(/w *118) TY TY";
            break;
	case 22:
            _answer = "Chav -,-";
            break;
	case 23:
            _answer = "How you dare to ask that?";
            break;
	case 24:
            _answer = "GTFO Randpiss";
            break;
	case 25:
            _answer = "Tosser... ,luv.";
            break;
	case 26:
            _answer = "What about some RL instead?";
            break;
	case 27:
            _answer = "That was serious?";
            break;
	case 28:
            _answer = "Absolutely YES.. and Joe is a jew.";
            break;
	case 29:
            _answer = "NO NO NO NO... joe is no jew. i was kidding, he is a jew.";
            break;
	case 30:
            _answer = "Very doubtful";
            break;
	case 31:
            _answer = "Not only no, but HELL No!";
            break;
	case 32:
            _answer = "Not only yes, but HELL Yes!";
            break;
	case 33:
            _answer = "You will regret it!";
            break;
	case 34:
            _answer = "Signs point to No";
            break;
	case 35:
            _answer = "Outlook is disturbing";
            break;
	case 36:
            _answer = "Please shut up, go take your dumb questions somewhere else.";
            break;
	case 37:
            _answer = "Not only yes, but HELL YES";
            break;
	case 38:
            _answer = "Not only no, but HELL NO";
            break;
	case 39:
            _answer = "I'll kill you.";
            break;
	case 40:
            _answer = "Okay.";
            break;
	case 41:
            _answer = "Sure.";
            break;
	case 42:
            _answer = "Probably.";
            break;
	case 43:
            _answer = "You're a girl, you ask too many fucking questions.";
            break;
	case 44:
            _answer = "Uh-huh.";
            break;
	case 45:
            _answer = "Yup.";
            break;
	case 46:
            _answer = "Could you repeat the question?";
            break;
	case 47:
            _answer = "Nazi -,-";
            break;
        default:
            _answer = "Ask again later";
    }
    
    NTC_Delay(1);
    
    return _answer;
}
Früher gab der Bot also eine Antwort sobald jemand ingame (.)ask8ball "Frage" geschrieben hat, mit Etal nichtmehr
HELP?!^^
Folgendes muss glaube ich in der NTMain() stehen:
Code:
RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);
Somit sieht deinen NTMain() so aus:
Code:
function NTMain()
{
   Include("libs/common/NTCommon.ntl");
   NTC_IncludeLibs();
   NTC_IncludeConfig("NTBot/char_configs");
   NT_LoadConfig();
   NTA_Initialize();
   
   Print("ÿc1Magic 8 Ball");

   [COLOR="Red"]RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);[/COLOR]
}
Auch glaube ich, dass danach eine Endlosschleife kommen muss?
Wie genau willst du es implementieren?
07/07/2011 12:21 eXoo~#3
Quote:
Originally Posted by TheCrazy11 View Post
Folgendes muss glaube ich in der NTMain() stehen:
Code:
RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);
Somit sieht deinen NTMain() so aus:
Code:
function NTMain()
{
   Include("libs/common/NTCommon.ntl");
   NTC_IncludeLibs();
   NTC_IncludeConfig("NTBot/char_configs");
   NT_LoadConfig();
   NTA_Initialize();
   
   Print("ÿc1Magic 8 Ball");

   [COLOR="Red"]RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);[/COLOR]
}
Auch glaube ich, dass danach eine Endlosschleife kommen muss?
Wie genau willst du es implementieren?
Habs auch schon so probiert :s
Wie gesagt, es ging ja vorher in Sternenlooper's NT

ISO Muddy
07/07/2011 13:34 Muddy Waters#4
Crazy hat schon ganz recht, ich würde dort auch eine Endlosschleife einfügen. Ich bin zwar nicht sicher, ob die Handler Threads mit dem Enden des eigentlichens Threads auch auslaufen, aber schaden kann es potentiell nicht.

Wie genau sieht denn das Fehlerverhalten aus?
Die Ausgabe am Anfang wird angezeigt, aber auf das entsprechende Kommando kommt nicht wie gewünscht die Ausgabe einer zufälligen Nachricht?

Wenn ja, könnte es einfach daran liegen, dass du deine Trigger Variable nicht deklariert hast, damit ist sie in der Handler Funktion nicht definiert und diese wirft aller Wahrscheinlichkeit eine Exception, von welcher du aber aufgrund der Tatsache, dass die Handler Funktion im Hintergrund Thread läuft, nichts mitbekommst.

Ich würde das einfach mal alles etwas aufräumen, dann sollte es eigentlich klappen. Die Funktion zur Auswahl des passenden strings kann man übrigens deutlich kürzer fassen, wenn du die strings einfach in ein Array packst. Abgesehen davon wird das ganze dadurch sehr viel dynamischer und du kannst es leichter ändern.

Wenn man das alles so umsetzt, sieht es danach so aus:
Code:
var Ball_Trigger = "ask8ball";
var Ball_Answers = new Array();
Ball_Answers.push("As I see It, Yes");
Ball_Answers.push("It is decidedly so");
Ball_Answers.push("It is certain");
Ball_Answers.push("Most likely");
Ball_Answers.push("Outlook good");
Ball_Answers.push("Signs point to Yes");
Ball_Answers.push("Without a doubt");
Ball_Answers.push("YES");
Ball_Answers.push("Yes, definitely");
Ball_Answers.push("You may rely on it");
Ball_Answers.push("Better not tell you now");
Ball_Answers.push("Cannot predict now");
Ball_Answers.push("Concentrate and ask again");
Ball_Answers.push("Don't count on it");
Ball_Answers.push("My reply is No");
Ball_Answers.push("My sources say No");
Ball_Answers.push("Outlook not so good");
Ball_Answers.push("Reply Hazy, Try again");
Ball_Answers.push("Stop trolling");
Ball_Answers.push("You missed that day in school, huh?");
Ball_Answers.push("Ask Claz.(/w *118) TY TY");
Ball_Answers.push("Chav -,-");
Ball_Answers.push("How you dare to ask that?");
Ball_Answers.push("GTFO Randpiss");
Ball_Answers.push("Tosser... ,luv.");
Ball_Answers.push("What about some RL instead?");
Ball_Answers.push("That was serious?");
Ball_Answers.push("Absolutely YES.. and Joe is a jew.");
Ball_Answers.push("NO NO NO NO... joe is no jew. i was kidding, he is a jew.");
Ball_Answers.push("Very doubtful");
Ball_Answers.push("Not only no, but HELL No!");
Ball_Answers.push("Not only yes, but HELL Yes!");
Ball_Answers.push("You will regret it!");
Ball_Answers.push("Signs point to No");
Ball_Answers.push("Outlook is disturbing");
Ball_Answers.push("Please shut up, go take your dumb questions somewhere else.");
Ball_Answers.push("Not only yes, but HELL YES");
Ball_Answers.push("Not only no, but HELL NO");
Ball_Answers.push("I'll kill you.");
Ball_Answers.push("Okay.");
Ball_Answers.push("Sure.");
Ball_Answers.push("Probably.");
Ball_Answers.push("You're a girl, you ask too many fucking questions.");
Ball_Answers.push("Uh-huh.");
Ball_Answers.push("Yup.");
Ball_Answers.push("Could you repeat the question?");
Ball_Answers.push("Nazi -,-");
Ball_Answers.push("Ask again later");

function NTMain()
{
	Include("libs/common/NTCommon.ntl");
	NTC_IncludeLibs();
	NTC_IncludeConfig("NTBot/char_configs");
	NT_LoadConfig();
	NTA_Initialize();

	Print("ÿc1Magic 8 Ball");
	RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);

	while(true)
		NTC_Delay(500);
}

function NT_GameMsgEvents(msg, type)
{
	if(type == 0 && msg.indexOf(Ball_Trigger) != -1)
		Say("looks into his Magic 8 Ball: " + MW_GetEightBallAnswer());
}

function MW_GetEightBallAnswer()
{
	NTC_Delay(1);
	return Ball_Answers[Random(0, Ball_Answers.length -1)];
}
Schau mal, ob das besser klappt. ;)

LG
Muddy
07/07/2011 16:31 eXoo~#5
Quote:
Originally Posted by Muddy_Waters View Post
Crazy hat schon ganz recht, ich würde dort auch eine Endlosschleife einfügen. Ich bin zwar nicht sicher, ob die Handler Threads mit dem Enden des eigentlichens Threads auch auslaufen, aber schaden kann es potentiell nicht.

Wie genau sieht denn das Fehlerverhalten aus?
Die Ausgabe am Anfang wird angezeigt, aber auf das entsprechende Kommando kommt nicht wie gewünscht die Ausgabe einer zufälligen Nachricht?

Wenn ja, könnte es einfach daran liegen, dass du deine Trigger Variable nicht deklariert hast, damit ist sie in der Handler Funktion nicht definiert und diese wirft aller Wahrscheinlichkeit eine Exception, von welcher du aber aufgrund der Tatsache, dass die Handler Funktion im Hintergrund Thread läuft, nichts mitbekommst.

Ich würde das einfach mal alles etwas aufräumen, dann sollte es eigentlich klappen. Die Funktion zur Auswahl des passenden strings kann man übrigens deutlich kürzer fassen, wenn du die strings einfach in ein Array packst. Abgesehen davon wird das ganze dadurch sehr viel dynamischer und du kannst es leichter ändern.

Wenn man das alles so umsetzt, sieht es danach so aus:
Code:
var Ball_Trigger = "ask8ball";
var Ball_Answers = new Array();
Ball_Answers.push("As I see It, Yes");
Ball_Answers.push("It is decidedly so");
Ball_Answers.push("It is certain");
Ball_Answers.push("Most likely");
Ball_Answers.push("Outlook good");
Ball_Answers.push("Signs point to Yes");
Ball_Answers.push("Without a doubt");
Ball_Answers.push("YES");
Ball_Answers.push("Yes, definitely");
Ball_Answers.push("You may rely on it");
Ball_Answers.push("Better not tell you now");
Ball_Answers.push("Cannot predict now");
Ball_Answers.push("Concentrate and ask again");
Ball_Answers.push("Don't count on it");
Ball_Answers.push("My reply is No");
Ball_Answers.push("My sources say No");
Ball_Answers.push("Outlook not so good");
Ball_Answers.push("Reply Hazy, Try again");
Ball_Answers.push("Stop trolling");
Ball_Answers.push("You missed that day in school, huh?");
Ball_Answers.push("Ask Claz.(/w *118) TY TY");
Ball_Answers.push("Chav -,-");
Ball_Answers.push("How you dare to ask that?");
Ball_Answers.push("GTFO Randpiss");
Ball_Answers.push("Tosser... ,luv.");
Ball_Answers.push("What about some RL instead?");
Ball_Answers.push("That was serious?");
Ball_Answers.push("Absolutely YES.. and Joe is a jew.");
Ball_Answers.push("NO NO NO NO... joe is no jew. i was kidding, he is a jew.");
Ball_Answers.push("Very doubtful");
Ball_Answers.push("Not only no, but HELL No!");
Ball_Answers.push("Not only yes, but HELL Yes!");
Ball_Answers.push("You will regret it!");
Ball_Answers.push("Signs point to No");
Ball_Answers.push("Outlook is disturbing");
Ball_Answers.push("Please shut up, go take your dumb questions somewhere else.");
Ball_Answers.push("Not only yes, but HELL YES");
Ball_Answers.push("Not only no, but HELL NO");
Ball_Answers.push("I'll kill you.");
Ball_Answers.push("Okay.");
Ball_Answers.push("Sure.");
Ball_Answers.push("Probably.");
Ball_Answers.push("You're a girl, you ask too many fucking questions.");
Ball_Answers.push("Uh-huh.");
Ball_Answers.push("Yup.");
Ball_Answers.push("Could you repeat the question?");
Ball_Answers.push("Nazi -,-");
Ball_Answers.push("Ask again later");

function NTMain()
{
	Include("libs/common/NTCommon.ntl");
	NTC_IncludeLibs();
	NTC_IncludeConfig("NTBot/char_configs");
	NT_LoadConfig();
	NTA_Initialize();

	Print("ÿc1Magic 8 Ball");
	RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);

	while(true)
		NTC_Delay(500);
}

function NT_GameMsgEvents(msg, type)
{
	if(type == 0 && msg.indexOf(Ball_Trigger) != -1)
		Say("looks into his Magic 8 Ball: " + MW_GetEightBallAnswer());
}

function MW_GetEightBallAnswer()
{
	NTC_Delay(1);
	return Ball_Answers[Random(0, Ball_Answers.length -1)];
}
Schau mal, ob das besser klappt. ;)

LG
Muddy
Wollte da jetzt noch ne Charbeschränkung reinbauen durch Charname
Code:
function NT_GameMsgEvents(msg, type)
{
	if(type == 0 && msg.indexOf(Ball_Trigger) != -1)
	{
	if(me.charname.toLowerCase() == "Charname")
	{
		Say("looks into his Magic 8 Ball: " + MW_GetEightBallAnswer());
		}
	}
}
Scheint aber nicht zu funktionieren :S

/EDIT
Solved :3
In der Char Config
Code:
//------------------------------------------------------------------------------
	// Magic8Ball Config
	//------------------------------------------------------------------------------
	Magic8Ball = true; bzw false
In NTBotgame
Code:
if(Magic8Ball)
			Load("NTBot/NTm8b.ntj");
Danke nochmal Muddy :)