All pastes #2049505 Raw Edit

Anonymous

public text v1 · immutable
#2049505 ·published 2011-04-22 22:47 UTC
rendered paste body
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){

         game = '';
         Delay(1000);
         if(chat = controlData.get(controlData.controls.lobby.chat.textBox.channelText))
         {
            var errors = '';
            var found_leader = false;
         var linewithname = '';
            lines = chat.GetText();
         if (lines.length > 1)
            for (var friend = 0; friend < lines.length; friend++)
            {
         if (undefined!==lines[friend + 1])
            linewithname = lines[friend + 1];
         if (undefined!==lines[friend + 1])
            linewithname = lines[friend + 2];
           
         if (undefined!==linewithname && linewithname.length > 0)
            if ((lines[friend + 1].lastIndexOf('game called') > -1 || linewithname.lastIndexOf('called') > -1)&& lines[friend].lastIndexOf(leaderAccountName) > -1)
               {
                  game = '';
                  found_leader = true;
                  var regOfflineEnglish=/^\d\s?:\s?(\w*)\s?,\s?offline\s*$/gi;
             
                  if (lines[friend].match(regOfflineEnglish))
                  {
                     errors += (errors == '' ? '' : ' ') + 'leader is offline';
                     Delay(5000);
                  }
               linewithname = linewithname.replace(/^\s+/,"");
               if (linewithname.lastIndexOf('called') > -1)
                  game = linewithname.substring(linewithname.lastIndexOf('called')+7,linewithname.lastIndexOf('.'));
               else
               {
                  game = linewithname.substring(0,linewithname.lastIndexOf('.'));
               }
               linewithname = '';
             
                  if (game != '' && game != samegame && game != oldgame)
                  {
               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('I couldn\'t find the leader in my friend list.');
               Delay(1500);
            }
         }
         else
         {
            //if (joinChannelInChat)
            //   Say('I can\'t read the chat!');
            Delay(1500);
         }
         
      }
   errors = '';
   if(game != '')
      samegame = game;
      break;

     
   case 1:   // Lobby
         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;
      }



     
   case 1:   // Lobby
         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;
      }





 
      
   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;