Author Topic: need help with d2nt fallowbot.ntj  (Read 1641 times)

ismackyou

  • Guest
need help with d2nt fallowbot.ntj
« on: August 29, 2010, 01:32:02 AM »
hello im using d2nt and im new to scripting and ive figured out how to make my bot rejoin the game if it chickens and lets say the game doesnt exist due to a delay in creating the game the bot will try again but when the game becomes full it starts from 3 games b4 the first one so lets say the bot is on run #99 and its full it'll try to join #97 then 98 then 99 again and then just keep doing 99 even tho a ng started can u help?

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #1 on: August 29, 2010, 01:50:53 AM »
ok i fixed theattemping to join old games thing but now it just keeps trying to join same game over and over again and a ng started-.-

Offline Justin

  • I run this bitch!
  • Administrator
  • PureKaoz HeRo
  • *****
  • Posts: 780
  • Reputation 3
  • Fck Bnet
    • View Profile
    • PureKaoz.com
Re: need help with d2nt fallowbot.ntj
« Reply #2 on: August 29, 2010, 06:48:16 AM »
I'm not sure; my bot rejoins the same game it chickened out of with the /f l version of find leader... sounds like you have a different version to me?

Owner of Cutting Edge Promotions http://CEPromotion.net

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #3 on: August 29, 2010, 08:45:39 AM »
i edited my version

cooptheking

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #4 on: August 29, 2010, 02:30:58 PM »
i edited my version
If you have made edits to your script, please post the entire script (using the codebox) so we can see what may be wrong

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #5 on: August 29, 2010, 07:53:08 PM »
Code: [Select]
var gameMinLength      = 90000;   // time in milliseconds, minimum game length, 180 seconds default (1 game/3 minutes)

var unableToConnectRetry   = 5;      // time in minutes to retry connecting on connection fail (real value is +/- 1 min)
var realmDownRetry      = 260;      // time in minutes to retry connecting on a realm down (default is 120 minutes)
var disconnectedRetry      = 5;      // time in minutes to retry on a disconnection (usually ip ban related)
var cdkeyInUseRetry      = 5;      // time in minutes to retry on a cdkey in use error message (set to 0 to stop)
var connectingToBnetTimeout   = 20000;   // time in milliseconds to wait for a login to time out and click cancel and retry
var characterScreenTimeout   = 5000;   // time in milliseconds to wait for character screen to appear
var pleaseWaitTimeout      = 2000;   // time in milliseconds to wait for a please wait popup
var createGameThreshold      = 5000;      // time in milliseconds to wait between making games
var createGameThresholdRandom   = 1000;      // time in milliseconds to randomly add +/- to the game create time
var createGameTimeout      = 15000;   // time in milliseconds to register a failed to create game
var waitInLineTimeout      = 60000;   // time in milliseconds to wait in lines for a create game (60 second default)
var characterSelectDelay   = 1000;      // time in milliseconds to wait before selecting a character on the char screen
var loginDelay         = 1000;      // time in milliseconds to wait before submitting login information
var clickDelay         = 500;      // wait X milliseconds before next action after a click event
var textDelay         = 500;      // wait X milliseconds before next action after inserting text into a textbox
var clickDelayRandom      = 500;      // random amount of time to add to a click
var textDelayRandom      = 500;      // random amount of time to add to a text set
var gameDoesNotExistDelayMin   = 500;   // how long to wait when a Game Does Not Exist occurs - minimum - default 10 minutes
var gameDoesNotExistDelayMax   = 500;   // how long to wait when a Game Does Not Exist occurs - maximum - default 15 minutes
var gameDoesNotExistTimeout   = 1000;   // how long to wait for the dialog to disappear (default 30 seconds, don't change this)
var joinChatAfterGame      = true;   // join chat after leaving a game
var joinRandomChannel      = false;      // if this is true, will join a random channel, otherwise it will use the channel below..
var joinChannelInChat      = "lolcats";      // leave blank to not join a private channel
var waitBeforeEnterChatMin   = 1000;      // min how long to wait before entering chat
var waitBeforeEnterChatMax   = 2000;      // max how long to wait before entering chat
var waitInChatBeforeActionsMin   = 2000;      // min how long to wait before joining channel
var waitInChatBeforeActionsMax   = 3000;      // max how long to wait before joining channel
var JoinFromChat = true;
var leaderAccountName = "ismackyou";
var gamepassword = '';
var samegame = '';
var oldgame = '';
var check = 1;

// DONT EDIT 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;

Include("libs/controlInfo.ntl");
//Include("joinBotSettings.ntl");

var controlData = new controlInfo();

var game = '';

function NTMain()
{
   Delay(1000);

   var _ingame = false;

   controlData.clickDelay = clickDelay;
   controlData.textDelay = textDelay;
   controlData.clickDelayRandom = clickDelayRandom;
   controlData.textDelayRandom = textDelayRandom;

   while(1)
   {
      if(me.ingame)
      {
         if(!inGameAt)
            inGameAt = GetTickCount();

         if(!_ingame)
         {
            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;

            sendEventToOOG(D2NT_MGR_READY, "", 0);
         }

         locationAction(controlData.getLocation());

         Delay(500);
      }
   }
}

function locationAction(location)
{
   switch(location.id)
   {
 
   case 3: // Lobby Chat
      if(!chatActionsDone)
      {
         chatActionsDone = true;
         Delay(Random(waitInChatBeforeActionsMin, waitInChatBeforeActionsMax));
 
         if(joinRandomChannel || joinChannelInChat != "")
         {
            Say("/join " + (joinRandomChannel ? getRandomString(Random(3,10)) : joinChannelInChat));
            Delay(1000);
         }
      }
 
      if(JoinFromChat){

    if(check == 1)
{
    sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
    outputGameLength();
            lastGameStatus = 0;
            setNextGameMake();
            sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
    check = check + 1;
}
         game = '';
         if (joinChannelInChat)
Delay (1000);
//Say('Locating the leader : '+leaderAccountName);
 
         Say('/f l');
         Delay(1000);
         if(chat = controlData.get(controlData.controls.lobby.chat.textBox.channelText))
         {
            var errors = '';
            var found_leader = false;
            lines = chat.GetText();
            for (var friend = 0; friend < lines.length; friend++)
            {
               if (lines[friend].lastIndexOf(': '+leaderAccountName+',') > -1)
               {
                  game = '';
                  found_leader = true;
                  var regOfflineEnglish=/^\d\s?:\s?(\w*)\s?,\s?offline\s*$/gi;
                  var regGameNameEnglish=/^\s*(the\s)?(game\s)?([\w\s-]*\w)\s\(private\)\.\s*$/gi;
                  var regGameNameFrench=/^\s*(la\s)?(partie\s)?([\w\s-]*\w)\s\(priv[^\)]*\)\.\s*$/gi;

                  if (lines[friend].match(regOfflineEnglish))
                  {
                     errors += (errors == '' ? '' : ' ') + 'leader is offline';
                  }
                  if (lines[friend + 1].match(regGameNameEnglish) && lines[friend+1].substr(1, 1) != ':')
                  {
                     game = lines[friend + 1].replace(regGameNameEnglish, "$3");
                  }
                  if (!game && lines[friend + 1].match(regGameNameFrench) && lines[friend+1].substr(1, 1) != ':')
                  {
                     game = lines[friend + 1].replace(regGameNameFrench, "$3");
                  }

                  if (game != '')
                  {
                     controlData.click(controlData.controls.lobby.button.join);
Delay(200);
                 controlData.setText( controlData.controls.lobby.join.editBox.gameName, game);
            Delay (200);
controlData.setText( controlData.controls.lobby.join.editBox.password, gamepassword);
Delay (200);
         controlData.click(controlData.controls.lobby.join.button.joinGame);
check = 1;
                  }
                  else
                  {
                     if(!errors)
                     {
                        errors = 'leader is not in game.';
                     }
                  }
               }
            }
            if (!found_leader && joinChannelInChat)
            {
               if (errors)
                  Say('Errors : ' + errors);
               else
                  Say('');
               Delay(1500);
            }
         }
         else
         {
            if (joinChannelInChat)
               Say(''); 
         }
         
      }


errors = '';

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;
      }

      if(GetTickCount() >= nextGameMake)
      {
         lastGameFailed = false;

         switch(lastGameStatus)
         {
         case 0:
            controlData.click(controlData.controls.lobby.button.create);
            nextGameMake = GetTickCount() + createGameTimeout; // set our timeout
            sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
            break;
         case 1: // game failed, rollover to reset timer
            inGameAt = GetTickCount(); // reset inGameAt, to wait how long we should have waited..
            lastGameFailed = true;
         case 2:
            outputGameLength();
            lastGameStatus = 0;
            setNextGameMake();
            sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
            break;
         }
      }
      else
         timeoutDelay(nextGameMake-GetTickCount(), location);
      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);
        }
      sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);

      RunGC(); // run garbage collector between each game

      locationTimeout(5000, location);

      lastGameMade = GetTickCount();
      lastGameStatus = 1; // pending creation
      break;

   case 5: // Join Game
        if(!controlData.get(controlData.controls.lobby.join.editBox.gameName))
        {
            controlData.click(controlData.controls.lobby.button.create);
            Delay (1000);
            controlData.click(controlData.controls.lobby.button.join);
            Delay (1000);
        }
        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);
        }
check = 1;
    lastGameStatus = 1; // pending creation
      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
      RunGC(); // run garbage collector between each game

      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, "Game already exists", 0);

      //inGameAt = 0;
      //lastGameStatus = 0;
      //setNextGameMake();
this.controls.lobby.button.quit
      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

Delay(5000); // 40 seconds longer then leader's min game time, edit yourself
Delay(1000);
controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1)
check = 1;
oldgame = game;

      break;


   case 29: // Lobby - Game Is full
Delay(500); // 40 seconds longer then leader's min game time, edit yourself
controlData.click(controlData.controls.lobby.button.quit)
Delay(1000);
controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1)
check = 1;
oldgame = game;

      break;
   }
}

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;
}

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #6 on: August 29, 2010, 08:17:54 PM »
ps the full game case in 29: i just added in cause i thought it mite help (i want the bot when it gets a full game error msg)wait 10 seconds then exit go to char selection then select char and go bax to channel and spaming /f l

cooptheking

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #7 on: August 29, 2010, 08:46:06 PM »
Okay.., maybe i just didnt see it when i scanned it..I dont see ANY variable to controls if game is full do X/Y/Z ...??(ofc case 29)
so what all did you add, maybe i just didnt see it?

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #8 on: August 29, 2010, 09:14:05 PM »
i added the thing were it says game != " " and removed the rest which alows me to rejoin game if i chicken out lag out or if the game doesnt exist it'll try again
this is wat is suppose to be: if (game != '' && game != samegame && game != oldgame)
mine is just: if (Game !="") and that lets me rejoin/try again if doesnt exist

cooptheking

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #9 on: August 29, 2010, 09:36:34 PM »
huh, thats weird....
Also weird you get such an odd "side-effect" that if tries the last 3 games..
then just keeps trying the last one over and over..
specially since it joins via the /f l list command..

Maybe try..
something like this
Code: [Select]
        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);
        }
   check = 1;
       lastGameStatus = 1; // pending creation
      break;

  if(MyConfig_Rejoin=true;)
{
type(/f l);
}
Then write a new function named MyConfig_Rejoin   that says (basically) if i get 'failed to join 3 times' type /f l and start from the beginning...
get what i mean (yeah my codes above is just a simple demonstration of the idea..

:)
lmk if you attempt this (sorry i just dont have the time to write up a function like that atm)

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #10 on: August 29, 2010, 09:46:48 PM »
how do i do
Quote
Then write a new function named MyConfig_Rejoin
sorry i just started scripting like this week

Offline TheFreak

  • Just like an admin ;)
  • PK Pro
  • ****
  • Posts: 373
  • Reputation 1
  • I rap and write javascript mutha fucka!
    • View Profile
Re: need help with d2nt fallowbot.ntj
« Reply #11 on: August 29, 2010, 11:26:03 PM »
Yu dont need if(MyConfig_Rejoin=true) Just if(MyConfig_Rejoin).

But what yu would wanna do is something like:

Code: [Select]
if(Rejoin)
{
   MyConfig_Rejoin();
}

Then create tha function:

Code: [Select]
function MyConfig_Rejoin()
{
Check for ftj x amount, and if checked, x amount,

while(location.id = 1)
{
   Say("/f l");

   Read Chat and join if red!
}
}

Then create a gobal var, (Put inside NTCofnig.ntl) called "var Rejoin;" then go to yur char config, and add "Rejoin = true;" Can also be false
« Last Edit: August 29, 2010, 11:27:43 PM by TheFreak »


My New function:

function AlbertEinstein()
{
If (A = success in life)
A = x + y + z;
x = Work;
y = Play;
z = Keeping your mouth shut;
}

"Right after the Sam-Frodo suckfest, right before the credits roll, Sam fuckin' flat-out brick's in Frodo's mouth"

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #12 on: August 30, 2010, 12:33:40 AM »
im raelly confused -.- i keep getting a syntex error and d2nt restarts

ismackyou

  • Guest
Re: need help with d2nt fallowbot.ntj
« Reply #13 on: August 30, 2010, 12:42:25 AM »
says something about missing a ) after condition i cant really read it its very fast

Offline TheFreak

  • Just like an admin ;)
  • PK Pro
  • ****
  • Posts: 373
  • Reputation 1
  • I rap and write javascript mutha fucka!
    • View Profile
Re: need help with d2nt fallowbot.ntj
« Reply #14 on: August 30, 2010, 01:03:19 AM »
Post yur code, and also. It would be:

Code: [Select]
Say("\/f l");


My New function:

function AlbertEinstein()
{
If (A = success in life)
A = x + y + z;
x = Work;
y = Play;
z = Keeping your mouth shut;
}

"Right after the Sam-Frodo suckfest, right before the credits roll, Sam fuckin' flat-out brick's in Frodo's mouth"