[CODE] Gladiator Event

#1
i cant remeber how this event works

Server Side

Code: Select all

Server

Game.h
	Code:
	
#define DEF_MAXARENAPLAYERS   200

char cArenaMap[11];
void RequestArenaStatus(int iClientH);
void RequestArenaStatus(int iSubjectH, bool bUpdate);



Client.h
	Code:
	   int m_iArenaKills;
   int m_iArenaDeaths;
   int m_iGladiatorCount;


Game.cpp - bInit()
	Code:
	
ZeroMemory(cArenaMap, sizeof(cArenaMap));
strcpy(cArenaMap, "fightzone2");


Client.cpp
	Code:
	
m_iArenaKills = 0;
m_iArenaDeaths = 0;
m_iGladiatorCount = 0;


NetMessages.h
	Code:
	
#define DEF_NOTIFY_ARENASTATUS      0x0D27
#define DEF_COMMONTYPE_REQARENASTATUS   0x0A70


Game.cpp - ClientCommonHandler()
	Code:
	
case DEF_COMMONTYPE_REQARENASTATUS:
   RequestArenaStatus(iClientH);
   break;


Game.cpp - RequestArenaStatus(int iClientH)
	Code:
	
// notify player who just joined
void CGame::RequestArenaStatus(int iClientH)
{
   int i;
   if (m_pClientList[iClientH] == NULL) return;

   for (i = 0; i < DEF_MAXARENAPLAYERS; i++) {
      if((m_pClientList[i] != NULL) && (strcmp(m_pMapList[m_pClientList[i]->m_cMapIndex]->m_cName, cArenaMap) == 0))
      {
         SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ARENASTATUS, m_pClientList[i]->m_iArenaKills, m_pClientList[i]->m_iArenaDeaths, 1, m_pClientList[i]->m_cCharName);
      }
   }   
}

// update all players with score change
void CGame::RequestArenaStatus(int iSubjectH, bool bUpdate)
{
   int i;
   if (m_pClientList[iSubjectH] == NULL) return;
   if (bUpdate)
   {
      for (i = 0; i < DEF_MAXARENAPLAYERS; i++) {
         if((m_pClientList[i] != NULL) && (strcmp(m_pMapList[m_pClientList[i]->m_cMapIndex]->m_cName, cArenaMap) == 0))
         {
            SendNotifyMsg(NULL, i, DEF_NOTIFY_ARENASTATUS, m_pClientList[iSubjectH]->m_iArenaKills, m_pClientList[iSubjectH]->m_iArenaDeaths, 1, m_pClientList[iSubjectH]->m_cCharName);
         }
      }
   }
   else
   {
      for (i = 0; i < DEF_MAXARENAPLAYERS; i++)
     {
         if((m_pClientList[i] != NULL) && (strcmp(m_pMapList[m_pClientList[iClientH]->m_cMapIndex]->m_cName, cArenaMap) == 0))
         {
            SendNotifyMsg(NULL, i, DEF_NOTIFY_ARENASTATUS, 0, 0, 0, m_pClientList[iSubjectH]->m_cCharName);
         }
      }
   }
}


Game.cpp - SendNotifyMsg
	Code:
	case DEF_NOTIFY_ARENASTATUS:
   ip  = (int *)cp;
   *ip = sV1;
   cp += 4;

   ip  = (int *)cp;
   *ip = sV2;
   cp += 4;

   ip  = (int *)cp;
   *ip = sV3;
   cp += 4;

   memcpy(cp,pString,21);
   cp += 21;

   iRet = m_pClientList[iToH]->m_pXSock->iSendMsg(cData,39);
   break;


Game.cpp - ClientKilledHandler()
	Code:
	
if (strcmp(m_pMapList[m_pClientList[iClientH]->m_cMapIndex]->m_cName, cArenaMap) == 0)
{
   m_pClientList[iClientH]->m_iArenaDeaths++;
   m_pClientList[iClientH]->m_iArenaKills = 0; // reset dead guy's kill count
   RequestArenaStatus(iClientH, true);
   m_pClientList[iAttackerH]->m_iArenaKills++;

     if(m_pClientList[iAttackerH]->m_iArenaKills % 25 == 0)
     {
          m_pClientList[i]->m_iGladiatorCount += 1;
        CheckTitleLevelUp(i, "Gladiator", m_pClientList[i]->m_iGladiatorCount);
     }

   RequestArenaStatus(iAttackerH, true);
}


Game.cpp - RequestTeleportHandler()
	Code:
	
//top of function
if(strcmp(m_pClientList[iClientH]->m_cMapName, cArenaMap) == 0) RequestArenaStatus(iClientH, false); // remove player

// bottom of function
if(strcmp(m_pClientList[iClientH]->m_cMapName, cArenaMap) == 0)
{
   RequestArenaStatus(iClientH);
   RequestArenaStatus(iClientH, true);
}


Game.cpp - DeleteClient()
	Code:
	
if(strcmp(m_pClientList[iClientH]->m_cMapName, cArenaMap) == 0)
{
   RequestArenaStatus(iClientH, false);
}


Game.cpp - iGetNextTitle()
	Code:
	
else if (memcmp(cSubject, "Gladiator", 9) == 0)
{
   if(iNumber > 0 && iNumber <= 3)       return 3;
   if(iNumber > 3 && iNumber <=  5)       return 5;
   if(iNumber > 5 && iNumber <=   10)       return 10;
   if(iNumber > 10 && iNumber <=  20)       return 20;
   if(iNumber > 20 && iNumber <=  50)       return 50;
   if(iNumber > 50 && iNumber <=  100)       return 100;
   if(iNumber > 100 && iNumber <= 175)       return 175;
   if(iNumber > 175 && iNumber <= 250)       return 250;
   if(iNumber > 250 && iNumber <= 500)       return 500;
   if(iNumber > 500)             return 500;
}


Game.cpp - CheckTitleLevelUp()
	Code:
	
if (memcmp(pSubject, "Gladiator"  , 9) == 0)  {if(m_pClientList[iClientH]->m_iGladiatorCount == iAmount){SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_TITLELEVELUP, m_pClientList[iClientH]->m_iGladiatorCount, 0, NULL, "Gladiator"); bHasLeveled = TRUE;}}



Game.cpp - RequestTitlesHandler()
	Code:
	
if(m_pClientList[iClientH]->m_iGladiatorCount > 0)
   SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ADDTITLE, m_pClientList[iClientH]->m_iGladiatorCount, 0, NULL, "Gladiator");



Game.cpp - ReadTitleLogsFile()
	Code:
	

case 53:
   if ((strlen(token) != 0) && (strlen(token) <= 10000) && (strlen(token) >= 1))
   {
      m_pClientList[iClientH]->m_iGladiatorCount = atoi(token);
   }
   cReadMode = 0;
   break;


if (memcmp(token, "Gladiator"  , 9) == 0)   cReadMode = 53;


Game.cpp - SaveTitleLogsFile()
	Code:
	
strcat(cFn2, "Gladiator = ");
wsprintf(cBuffer, "%d", m_pClientList[iClientH]->m_iGladiatorCount);
strcat (cFn2, cBuffer);
strcat (cFn2,"\n");




Game.cpp - RequestRestartHandler()
	Code:
	
if (strcmp(cTmpMap, cArenaMap) == 0)
{
   strcpy(m_pClientList[iClientH]->m_cMapName, cArenaMap);
}

Client Side

Code: Select all

Client


GlobalDef.h

#define DEF_ARENAMAP "fightzone2"

Game.h
	Code:
	
#define DEF_MAXARENAPLAYERS      200

struct {
   int iKills;
   int iDeaths;
   char cCharName[12];
} m_stArenaPlayers[DEF_MAXARENAPLAYERS];


Game.cpp - CGame
	Code:
	
for (i = 0; i < DEF_MAXARENAPLAYERS; i++)
{
   m_stArenaPlayers[i].iKills = 0;
   m_stArenaPlayers[i].iDeaths = 0;
   ZeroMemory(m_stArenaPlayers[i].cCharName, sizeof(m_stArenaPlayers[i].cCharName));
}


Game.cpp - NotifyMsgHandler()
	Code:
	
case DEF_NOTIFY_ARENASTATUS:
   cp = (char *)(pData   + DEF_INDEX2_MSGTYPE + 2);
   ip  = (int *)cp;
   sV1 = *ip;
   cp += 4;

   ip  = (int *)cp;
   sV2 = *ip;
   cp += 4;

   ip  = (int *)cp;
   sV3 = *ip;
   cp += 4;

   ZeroMemory(cTemp, sizeof(cTemp) );
   memcpy(cTemp, cp, 21);
   cp += 21;

   if(sV3 > 0)
   {
      bool bFound = false;

      for (i = 0; i < DEF_MAXARENAPLAYERS; i++)
      {
         if(bFound) break;
         if(strcmp(m_stArenaPlayers[i].cCharName, cTemp) == 0)
         {
            m_stArenaPlayers[i].iKills = sV1;
            m_stArenaPlayers[i].iDeaths = sV2;
            bFound = true;
         }
      }
      if(bFound == false)
      {
         for (i = 0; i < DEF_MAXARENAPLAYERS; i++)
         {
            if(strlen(m_stArenaPlayers[i].cCharName) == 0)
            {
               m_stArenaPlayers[i].iKills = sV1;
               m_stArenaPlayers[i].iDeaths = sV2;
               ZeroMemory(m_stArenaPlayers[i].cCharName, sizeof(m_stArenaPlayers[i].cCharName) );
               strcpy(m_stArenaPlayers[i].cCharName, cTemp);
               break;
            }
         }
      }
   }
   else // player DC/Logout/Recall, remove from list
   {
      for (i = 0; i < DEF_MAXARENAPLAYERS; i++)
      {
         if(strcmp(m_stArenaPlayers[i].cCharName, cTemp) == 0)
         {
            m_stArenaPlayers[i].iKills = 0;
            m_stArenaPlayers[i].iDeaths = 0;
            ZeroMemory(m_stArenaPlayers[i].cCharName, sizeof(m_stArenaPlayers[i].cCharName));
         }
      }
   }


NetMessages.h
	Code:
	#define DEF_NOTIFY_ARENASTATUS      0x0D27
#define DEF_COMMONTYPE_REQARENASTATUS   0x0A70


Game.cpp - UpdateScreen_OnGame
	Code:
	
if(strcmp(m_cMapName, DEF_ARENAMAP) == 0)
{
   char cEntry[64];
   int iEntry = 0;

   wsprintf(cEntry, "Name      Kills      Deaths");
   PutString( 10, 100, cEntry, RGB(255,255,255) );

   for (i = 0; i < DEF_MAXARENAPLAYERS; i++)
   {
      if(iEntry >= 5) break;  // only show top 5
      if(strlen(m_stArenaPlayers[i].cCharName) != 0)
      {
         iEntry++;
         wsprintf(cEntry, "%s      %i     %i", m_stArenaPlayers[i].cCharName, m_stArenaPlayers[i].iKills, m_stArenaPlayers[i].iDeaths);
         PutString( 10, 100 + (iEntry*15), cEntry, RGB(255,255,255) );
      }
   }
}


Game.cpp - GetTitleName()
	Code:
	
else if (memcmp(cSubject, "Gladiator", 9) == 0)
{
   if(iNumber >  0 && iNumber < 3)         strcpy(cTxt, "Novice Gladiator");
   if(iNumber >= 3 && iNumber < 5)         strcpy(cTxt, "Fierce Gladiator");
   if(iNumber >= 5 && iNumber < 10)      strcpy(cTxt, "Mighty Gladiator");
   if(iNumber >= 10 && iNumber < 20)      strcpy(cTxt, "Deadly Gladiator");
   if(iNumber >= 20 && iNumber < 50)      strcpy(cTxt, "Conquering Gladiator");
   if(iNumber >= 50 && iNumber < 100)      strcpy(cTxt, "Vanquishing Gladiator");
   if(iNumber >= 100 && iNumber < 175)      strcpy(cTxt, "King's Gladiator");
   if(iNumber >= 175 && iNumber < 250)      strcpy(cTxt, "Emperor's Gladiator");
   if(iNumber >= 250 && iNumber < 500)      strcpy(cTxt, "Legendary Gladiator");
   if(iNumber >= 500)                   strcpy(cTxt, "Legendary Gladiator ");
}



Game.cpp iGetNextTitle()
	Code:
	
else if (memcmp(cSubject, "Gladiator", 9) == 0)
{
   if(iNumber > 0 && iNumber <= 2)          return 3;
   if(iNumber > 2 && iNumber <=  5)       return 5;
   if(iNumber > 5 && iNumber <=   10)       return 10;
   if(iNumber > 10 && iNumber <=  20)       return 20;
   if(iNumber > 20 && iNumber <=  50)       return 50;
   if(iNumber > 50 && iNumber <=  100)       return 100;
   if(iNumber > 100 && iNumber <= 175)       return 175;
   if(iNumber > 175 && iNumber <= 250)       return 250;
   if(iNumber > 250 && iNumber <= 500)       return 500;
   if(iNumber > 500)                    return 500;
}



Game.cpp - NotifyMsg_TitleLevelUp()
	Code:
	
else if (memcmp(cSubject, "Gladiator", 9) == 0)
{
   wsprintf(cMsg, "You have earned a new title by earning 25 consecutive kills %i times in the arena!", iCurrentNo);
}



Game.cpp - InitDataResponseHandler()
	Code:
	
// clear list if relog or log new char
for (i = 0; i < DEF_MAXARENAPLAYERS; i++)
{
   m_stArenaPlayers[i].iKills = 0;
   m_stArenaPlayers[i].iDeaths = 0;
   ZeroMemory(m_stArenaPlayers[i].cCharName, sizeof(m_stArenaPlayers[i].cCharName));
}



Game.cpp - DrawObjectName
	Code:
	
if(((m_bLMSEnabled) & (memcmp(m_cLMSMap, m_cMapName, 10) == 0) & bIsGM == FALSE) || (strcpy(m_cMapName, DEF_ARENAMAP) == 0))
{
   strcpy(cTxt, "Enemy");
   PutString2(sX, sY+14 +iAddY, cTxt, 255, 0, 0);
}
else
{
   PutString2(sX, sY+14 +iAddY, cTxt, sR, sG, sB);
   iAddY += 14;
}

Makes everyone show as enemy
Note: Some Last Man Standing code in there also!



Game.cpp - CommandProcessor
	Code:
	
if((m_bLMSEnabled == FALSE) & (memcmp(m_cLMSMap, m_cMapName, 10)) || (strcpy(m_cMapName, DEF_ARENAMAP)))
{
   if ( _iGetFOE(iObjectStatus) >= 0 ) break;
   if ( (sObjectType>=1) && (sObjectType<=6) && (m_bForceAttack==FALSE) ) break;
}

Makes it so same town dont need auto attack
Note: Some Last Man Standing code in there also!

Game.cpp - DrawObjects
	Code:
	
if( _iGetFOE(iFocuiStatus) < 0 )
{
   m_stMCursor.sCursorFrame = 3;
}
else if(((m_bLMSEnabled) & (memcmp(m_cLMSMap, m_cMapName, 10) == 0)) || (strcpy(m_cMapName, DEF_ARENAMAP) == 0)){
   m_stMCursor.sCursorFrame = 3;
}

Show an attack cursor even if its same town 

Who is online

Users browsing this forum: No registered users and 1 guest

cron