[CODE] ChangeCity con cartel para elegir Si/No

#1
Primero en los sources del Cliente, Game.cpp

En la función

Code: Select all

BOOL CGame::bSendCommand(DWORD dwMsgID, WORD wCommand, char cDir, int iV1, int iV2, int iV3, char * pString, int iV4)
Agregar abajo de

Code: Select all

switch (dwMsgID) {
Esto

Code: Select all

	case DEF_REQUEST_CHANGECITY_YES:
	case DEF_REQUEST_CHANGECITY_NO: // Centuu : Change City
		dwp = (DWORD *)(cMsg + DEF_INDEX4_MSGID);
		*dwp = dwMsgID;
		wp  = (WORD *)(cMsg + DEF_INDEX2_MSGTYPE);
		*wp = NULL;
		iRet = m_pGSock->iSendMsg(cMsg, 6, cKey);
		break;
En la función

Code: Select all

BOOL CGame::_bCheckDlgBoxClick(short msX, short msY)
Agregar abajo de

Code: Select all

switch (cDlgID) {
Esto

Code: Select all

			case 52: // Centuu : Change City
				DlgBoxClick_ChangeCity(msX, msY);
				break;
En la función

Code: Select all

void CGame::DrawDialogBoxs(short msX, short msY, short msZ, char cLB)
Agregar abajo de

Code: Select all

switch (m_cDialogBoxOrder[i]) {
Esto

Code: Select all

		case 52: // Centuu : Change City
			DrawDialogBox_ChangeCity(msX, msY);
			break;
En la función

Code: Select all

void CGame::EnableDialogBox(int iBoxID, int cType, int sV1, int sV2, char * pString)
Agregar abajo de

Code: Select all

switch (iBoxID) {
Esto

Code: Select all

	case 52: // Centuu : Change City
		if (m_bIsDialogEnabled[52] == FALSE) 
		{	m_stDialogBoxInfo[52].sX = 185;
			m_stDialogBoxInfo[52].sY = 100;
			m_stDialogBoxInfo[52].cMode	= 0;
			m_stDialogBoxInfo[52].sView = 0;
			m_bSkillUsingStatus = FALSE;
		}
		break;
En la función

Code: Select all

void CGame::NotifyMsgHandler(char * pData)
Agregar abajo de

Code: Select all

switch (wEventType) {
Esto

Code: Select all

	case DEF_NOTIFY_CHANGECITY: // Centuu : Change City
		EnableDialogBox(52, 0, NULL, NULL);
		break;
En la función

Code: Select all

void CGame::InitDataResponseHandler(char * pData)
Agregar

Code: Select all

DisableDialogBox(52); // Centuu : Change City
En la función

Code: Select all

CGame::CGame()
Agregar

Code: Select all

	// Centuu : Change City
	m_stDialogBoxInfo[52].sX = 185;
	m_stDialogBoxInfo[52].sY = 100;
	m_stDialogBoxInfo[52].sSizeX = 270;
	m_stDialogBoxInfo[52].sSizeY = 105;
Y agregar 2 nuevas funciones

Code: Select all

/*****************************************************************************************************************
***** void CGame::DrawDialogBox_ChangeCity(short msX, short msY)											 *****
*****--------------------------------------------------------------------------------------------------------*****
***** Créditos		:: By Centuu.-																			 *****
***** Descripción	:: Pregunta si quieres cambiar de ciudad.												 *****
*****************************************************************************************************************/
void CGame::DrawDialogBox_ChangeCity(short msX, short msY)
{short sX, sY;
	//00476D02  |. 68 A4474C00    PUSH 004C47A4                    ;  ASCII "          Do you really"
	//00476D41  |. 68 8C474C00    PUSH 004C478C                    ;  ASCII "wanna change city?"
	sX = m_stDialogBoxInfo[52].sX;
	sY = m_stDialogBoxInfo[52].sY;
	DrawNewDialogBox(DEF_SPRID_INTERFACE_ND_GAME1, sX, sY, 2);
	PutString(sX + 50, sY + 20, "          Do you really", RGB(4,0,50));
	PutString(sX + 80, sY + 35, "wanna change city?", RGB(4,0,50));
	if ((msX >= sX + 30) && (msX <= sX + 30 + DEF_BTNSZX) && (msY >= sY + 55) && (msY <= sY + 55 + DEF_BTNSZY)) 
	{	DrawNewDialogBox(DEF_SPRID_INTERFACE_ND_BUTTON, sX + 30, sY + 55 ,19);
	}else
	{	DrawNewDialogBox(DEF_SPRID_INTERFACE_ND_BUTTON, sX + 30, sY + 55 , 18);
	}
	if ((msX >= sX + 170 ) && (msX <= sX + 170 + DEF_BTNSZX ) && (msY >= sY + 55 ) && (msY <= sY + 55 + DEF_BTNSZY)) 
	{	DrawNewDialogBox(DEF_SPRID_INTERFACE_ND_BUTTON, sX + 170 , sY + 55 , 3);
	}else
	{	DrawNewDialogBox(DEF_SPRID_INTERFACE_ND_BUTTON, sX + 170, sY + 55 , 2);
	}
}
/*****************************************************************************************************************
***** void CGame::DlgBoxClick_ChangeCity(short msX, short msY)												 *****
*****--------------------------------------------------------------------------------------------------------*****
***** Créditos		:: By Centuu.-																			 *****
***** Descripción	:: Da las opciones YES o NO para elejir.												 *****
*****************************************************************************************************************/
void CGame::DlgBoxClick_ChangeCity(short msX, short msY)
{short sX, sY;
	sX = m_stDialogBoxInfo[52].sX;
	sY = m_stDialogBoxInfo[52].sY;
	if ((msX >= sX + 30) && (msX <= sX + 30 + DEF_BTNSZX) && (msY >= sY + 55) && (msY <= sY + 55 + DEF_BTNSZY)) 
	{   bSendCommand(DEF_REQUEST_CHANGECITY_YES, 0, 0, 0, 0 ,0, NULL, 0);
		DisableDialogBox(52);
	}else if ((msX >= sX + 170 ) && (msX <= sX + 170 + DEF_BTNSZX ) && (msY >= sY + 55 ) && (msY <= sY + 55 + DEF_BTNSZY)) 
	{	bSendCommand(DEF_REQUEST_CHANGECITY_NO, 0, 0, 0, 0 ,0, NULL, 0);
		DisableDialogBox(52);
	}
}
Declarar en Game.h

Code: Select all

void DlgBoxClick_ChangeCity(short msX, short msY);
void DrawDialogBox_ChangeCity(short msX, short msY);
Segundo en los sources del HG, Game.cpp

Agregar 2 nuevas funciones

Code: Select all

/*****************************************************************************************************************
***** void CGame::PlayerRequest_ChangeCity(int iClientH)													 *****
*****--------------------------------------------------------------------------------------------------------*****
***** Créditos		:: By Centuu.-																			 *****
***** Descripción	:: Chequea si tenes los requerimientos para el cambio.									 *****
*****************************************************************************************************************/
void CGame::PlayerRequest_ChangeCity(int iClientH)
{
	if (m_pClientList[iClientH] == NULL) return;
	// Centuu : No tiene los majestic's necesarios.
	if (m_pClientList[iClientH]->m_iGizonItemUpgradeLeft < 200) {   
		ShowClientMsg(iClientH, " You don't have 200 Majestic points."); 
		return;
	}
	// Centuu : Manda un mensaje al cliente y activa una ventana preguntando si desea el cambio de ciudad.
	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_CHANGECITY, NULL, NULL, NULL, NULL);
}
/*****************************************************************************************************************
***** void CGame::PlayerOrder_ChangeCity(int iClientH, BOOL bChange)										 *****
*****--------------------------------------------------------------------------------------------------------*****
***** Créditos		:: By Centuu.-																			 *****
***** Descripción	:: Realiza cambio de ciudad, preguntando si lo deseas.									 *****
*****************************************************************************************************************/
void CGame::PlayerOrder_ChangeCity(int iClientH, BOOL bChange) 
{
	if (m_pClientList[iClientH] == NULL) return;  
	if (bChange == TRUE) { // Centuu : Desea realizar el cambio.
		// Centuu : Cambia de ciudad.
		if (memcmp(m_pClientList[iClientH]->m_cLocation, "aresden", 7) == 0) { 
			// Ares -> Elv
			strcpy(m_pClientList[iClientH]->m_cLocation, "elvine"); 
			// Centuu : Dice que se cambió de ciudad.
			ShowClientMsg(iClientH, " Now you're a citizen of Elvine.");
		}
		else if (memcmp(m_pClientList[iClientH]->m_cLocation, "elvine", 6) == 0) { 
			// Elv -> Ares
			strcpy(m_pClientList[iClientH]->m_cLocation, "aresden");  
			// Centuu : Dice que se cambió de ciudad.
			ShowClientMsg(iClientH, " Now you're a citizen of Aresden.");
		}
		// Centuu : Quita los majestic's.
		m_pClientList[iClientH]->m_iGizonItemUpgradeLeft -= 200;
		SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_GIZONITEMUPGRADELEFT, NULL, NULL, NULL, NULL);
		// Centuu : Avisa al cliente que se cambió de modo de juego para que no haya errores.
		SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_CHANGEPLAYMODE, NULL, NULL, NULL, m_pClientList[iClientH]->m_cLocation);
		SendEventToNearClient_TypeA(iClientH, DEF_OWNERTYPE_PLAYER, MSGID_EVENT_MOTION, m_pClientList[iClientH]->m_iLevel, NULL, NULL, NULL);
		// Centuu ; Dice que se cambió con éxito.
		ShowClientMsg(iClientH, " Change city successfully.");
	}
	else if (bChange == FALSE) return; // Centuu : Cambio cancelado.
}
En la función

Code: Select all

void CGame::ChatMsgHandler(int iClientH, char * pData, DWORD dwMsgSize)
Agregar abajo de

Code: Select all

		if (memcmp(cp, "/to", 3) == 0) {
			ToggleWhisperPlayer(iClientH, cp, dwMsgSize - 21);
			return;
		}
Esto

Code: Select all

		if (memcmp(cp, "/changecity", 11) == 0) { 
			PlayerRequest_ChangeCity(iClientH);  
            return; 
		}
En la función

Code: Select all

void CGame::MsgProcess()
Agregar arriba de

Code: Select all

			default:
				wsprintf(m_msgBuff,"Unknown message received! (0x%.8X) Delete Client",*dwpMsgID);
				PutLogList(m_msgBuff);
				DeleteClient(iClientH, TRUE, TRUE); // v1.4
				break;
Esto

Code: Select all

			// Centuu: "Do you really wanna change city?"
			case DEF_REQUEST_CHANGECITY_YES:
				PlayerOrder_ChangeCity(iClientH, TRUE);
				break;
			case DEF_REQUEST_CHANGECITY_NO:
				PlayerOrder_ChangeCity(iClientH, FALSE);
				break;
En la función

Code: Select all

void CGame::SendNotifyMsg(int iFromH, int iToH, WORD wMsgType, DWORD sV1, DWORD sV2, DWORD sV3, char * pString, DWORD sV4, DWORD sV5, DWORD sV6, DWORD sV7, DWORD sV8, DWORD sV9, char * pString2)
Agregar abajo de

Code: Select all

switch (wMsgType) {
Esto

Code: Select all

	case DEF_NOTIFY_CHANGECITY: // Centuu: Pregunta si quieres cambiar de city.
		iRet = m_pClientList[iToH]->m_pXSock->iSendMsg(cData, 16);
		break;
Y declarar en Game.h

Code: Select all

void PlayerOrder_ChangeCity(int iClientH, BOOL bChange);
void PlayerRequest_ChangeCity(int iClientH);



Agregar en NetMessages.h (del Cliente y el HG)

Code: Select all

// Centuu : Agregado cartel YES-NO para ChangeCity
#define DEF_NOTIFY_CHANGECITY 0x0CA1
#define DEF_REQUEST_CHANGECITY_YES 0x0FC9422E
#define DEF_REQUEST_CHANGECITY_NO  0x0FC9423E


Image

Image

Image
Centuu.-

Sol Lucet Omnibus.-

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron