[Moved] Automated Class Call

View previous topic View next topic Go down

[Moved] Automated Class Call

Post  teller55 on Wed Sep 26, 2012 12:53 pm

Since Amoeba's forum can no longer be linked to, I'm moving this post to my forum.

BloodsReaver wrote:ACC v1.4 should now be fully bug free. Very Happy

game_base.h
after first "public:"
Code:
string classCallString, CC[12], CCstatic[12];
   bool CCStarted;

game_base.cpp
top of CBaseGame constructor
set "CCStarted = false;" to be deactivated by default
Code:
CCStarted = true;
CCstatic[0] = "1";
CCstatic[1] = "2";
CCstatic[2] = "3";
CCstatic[3] = "4";
CCstatic[4] = "5";
CCstatic[5] = "6";
CCstatic[6] = "7";
CCstatic[7] = "8";
CCstatic[8] = "9";

end of EventPlayerDeleted
Code:
if (CCStarted && m_GameLoaded)
{
    float iTime = (float)((GetTime() - m_GameLoadedTime)/60);
    string sTime = UTIL_ToString( iTime,0 ) + "m";
    int myDrop = GetSIDFromPID( player->GetPID( ) );
    SendAllChat("Warning: Your "+CC[myDrop]+" just dropped!");
    CC[myDrop] = CC[myDrop] + " dropped: " + sTime;
    classCallString = CC[0]+"/"+CC[1]+"/"+CC[2]+"/"+CC[3]+"/"+CC[4]+"/"+CC[5]+"/"+CC[6]+"/"+CC[7]+"/"+CC[8];
}
else if (CCStarted && !m_GameLoaded)
{
    for( unsigned int i = 0; i < 9; i++ )
    {
        if( m_Slots[i].GetSlotStatus() != 2 )
        {
            CC[i] = "-";
          }
          else if (CC[i].length() <= 1)
          {
            CC[i] = CCstatic[i];
          }
      }
      classCallString = CC[0]+"/"+CC[1]+"/"+CC[2]+"/"+CC[3]+"/"+CC[4]+"/"+CC[5]+"/"+CC[6]+"/"+CC[7]+"/"+CC[8];
      SendAllChat(classCallString);
}

in EventPlayerChatToHost
after comment "calculate timestamp"
Code:
if (CCStarted && !m_GameLoaded)
{
   string myMsg = chatPlayer->GetMessage( );
   int firstChar = (int)(myMsg[0]);
   int secondChar = (int)(myMsg[1]);
   bool firstDigit = false;
   bool secondDigit = false;
   if (firstChar > 48 && firstChar < 58)
      firstDigit = true;
   if (secondChar > 47 && secondChar < 58)
      secondDigit = true;
   if ( firstDigit && !secondDigit )
   {
      for( unsigned int i = 0; i < 9; i++ )
      {
         if( m_Slots[i].GetSlotStatus() != 2 )
         {
            CC[i] = "-";
         }
         else if (CC[i].length() <= 1)
         {
            CC[i] = CCstatic[i];
         }
      }
      unsigned char myColour = m_Slots[GetSIDFromPID ( player->GetPID( ) )].GetColour( );
      int currentChar = int(myMsg[0]);
      while (currentChar < 65 && !myMsg.empty())
      {
         myMsg = myMsg.erase(0,1);
         currentChar = int(myMsg[0]);
      }
      int requestedSlot = firstChar - 49;
      if ( requestedSlot == myColour )
      {
         if (myMsg.size() > 1)
         {
            if (myMsg.size() > 9)
            {
               myMsg.resize(9);
            }
            CC[myColour] = myMsg;
         }
         else
         {
            CC[myColour] = CCstatic[myColour];
         }
         classCallString = CC[0]+"/"+CC[1]+"/"+CC[2]+"/"+CC[3]+"/"+CC[4]+"/"+CC[5]+"/"+CC[6]+"/"+CC[7]+"/"+CC[8];
         SendAllChat(classCallString);
      }
   }
}

in EventPlayerChangeTeam
Code:
void CBaseGame :: EventPlayerChangeTeam( CGamePlayer *player, unsigned char team )
{
   // player is requesting a team change

   if( m_SaveGame )
      return;

   if( m_Map->GetMapGameType( ) == GAMETYPE_CUSTOM )
   {
      unsigned char oldSID = GetSIDFromPID( player->GetPID( ) );
      unsigned char newSID = GetEmptySlot( team, player->GetPID( ) );
      SwapSlots( oldSID, newSID );
      //int lastColor = oldSID;
      //int cColor = newSID;
      if( oldSID < m_Slots.size( ) && newSID < m_Slots.size( ) && oldSID != newSID )
      {
         string temp = CC[oldSID];
         CC[oldSID] = CC[newSID];
         CC[newSID] = temp;
      }
      classCallString = CC[0]+"/"+CC[1]+"/"+CC[2]+"/"+CC[3]+"/"+CC[4]+"/"+CC[5]+"/"+CC[6]+"/"+CC[7]+"/"+CC[8];
   }

end of EventPlayerJoined
Code:
if (CCStarted && !m_GameLoaded)
{
      for( unsigned int i = 0; i < 9; i++ )
      {
          if( m_Slots[i].GetSlotStatus() != 2 )
          {
                CC[i] = "-";
          }
          else if (CC[i].length() <= 1)
          {
                CC[i] = CCstatic[i];
          }
      }
      classCallString = CC[0]+"/"+CC[1]+"/"+CC[2]+"/"+CC[3]+"/"+CC[4]+"/"+CC[5]+"/"+CC[6]+"/"+CC[7]+"/"+CC[8];
      SendAllChat(classCallString);
}

in game.cpp
at end of "!SWAP (swap slots)"
Code:
else
{
   SwapSlots( (unsigned char)( SID1 - 1 ), (unsigned char)( SID2 - 1 ) );
   if( SID1 < m_Slots.size( ) && SID2 < m_Slots.size( ) && SID1 != SID2 )
   {
      string temp = CC[(int)(SID1 - 1)];
      CC[(int)(SID1 - 1)] = CC[(int)(SID2 - 1)];
      CC[(int)(SID2 - 1)] = temp;
   }
        classCallString = CC[0]+"/"+CC[1]+"/"+CC[2]+"/"+CC[3]+"/"+CC[4]+"/"+CC[5]+"/"+CC[6]+"/"+CC[7]+"/"+CC[8];
}

after comment "ADMIN COMMANDS"
Code:
//
// !startCC
//
if ((command =="startCC" || command == "startcc") && !CCStarted && !m_GameLoaded)
{
      CCStarted = true;
      SendAllChat("Automated Class Caller Activated");
}

//
// !stopCC
//
if ((command =="stopCC" || command == "stopcc") && CCStarted && !m_GameLoaded)
{
      CCStarted = false;
      SendAllChat("Automated Class Caller Deactivated");
}

after comment "NON ADMIN COMMANDS"
Code:
//
// !CC
//

if ( CCStarted && (command == "cc" || command == "CC") && m_GameLoaded )
      SendAllChat(classCallString);
else if ( CCStarted && (command == "cc" || command == "CC") && !m_GameLoaded )
{
      for( unsigned int i = 0; i < 9; i++ )
      {
        if( m_Slots[i].GetSlotStatus() != 2 )
            CC[i] = "-";
        else if (CC[i].length() <= 1)
            CC[i] = CCstatic[i];
      }
      classCallString = CC[0]+"/"+CC[1]+"/"+CC[2]+"/"+CC[3]+"/"+CC[4]+"/"+CC[5]+"/"+CC[6]+"/"+CC[7]+"/"+CC[8];
      SendAllChat(classCallString);
}

Field Medic If using ghost++ also add these lines:
in game_base.h after "protected:"
Code:
uint32_t m_GameLoadedTime;  // GetTime when the game was loaded

in game_base.cpp
at the top of "CBaseGame"
Code:
m_GameLoadedTime = 0;

in EventGameLoaded after "CONSOLE_Print"
Code:
m_GameLoadedTime = GetTime( );


Last edited by teller55 on Sat Jun 08, 2013 10:48 am; edited 1 time in total

_________________
Umbrella Clone Watchman Covert Sniper Psychologist
avatar
teller55
Administrator
Administrator

Favorite Class : Alice
Posts : 158
Join date : 2011-08-12

View user profile http://night.org/swat2/playerdb/?p=view&user=teller55

Back to top Go down

Re: [Moved] Automated Class Call

Post  Amoeba on Wed Oct 03, 2012 11:26 pm

in order to extract links from my forum you just have to right click on either the post title or topic title and copy link address.
http://www.getdanny.com/energyisforwimps/forum/viewtopic.php?f=71&t=89

credits for the above project:
Original executable for GhostONE and GHost++ were developed by the team over at codelain.com.

original
SWAT player Alabrie came up with the idea. He created a very basic working version with no support.

v1.0-1.3
Using Alabrie's code as a base, Amoeba improved the code and added quite a bit of functionality to the original concept and added support for GHost++ Version 17.1 Custom Build 3.6.

v1.4
Bloodsreaver then took Amoeba's code and added safeguards in order to guarantee that the bot will never crash no matter what version of Ghost you use it with.

only known bug:
If an admin joins the game and pushes players down the class call will not update for any player.

i believe the above code is version 1.4
avatar
Amoeba
Recruit
Recruit

Posts : 2
Join date : 2012-09-19

View user profile http://night.org/swat2/playerdb/index.php?p=view&user=Amoeba

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum