[src] Statschange

Codes already submitted by people of the forums.
Post Reply
SlammeR
Loyal fan
Posts: 219
Joined: Fri Nov 04, 2005 1:52 am
Location: Brazil

Post by SlammeR »

note: the code is allready present on 2.24b... the DEFINITIONS on game.h was wrong never mind here we go...

StateChangeHandler:

Code: Select all

void CGame::StateChangeHandler(int iClientH, char * pData, DWORD dwMsgSize)
{
 char * cp, cStateChange1, cStateChange2, cStateChange3;
 char cStr, cVit, cDex, cInt, cMag, cChar;
 int iOldStr, iOldVit, iOldDex, iOldInt, iOldMag, iOldChar;
	
	if (m_pClientList[iClientH] == NULL) return;
	if (m_pClientList[iClientH]->m_bIsInitComplete == FALSE) return;
	if (m_pClientList[iClientH]->m_iGizonItemUpgradeLeft <= 0) return;

	cStr = cVit = cDex = cInt = cMag = cChar = 0;

	cp = (char *)(pData + DEF_INDEX2_MSGTYPE + 2);

	cStateChange1 = *cp;
	cp++;

	cStateChange2 = *cp;
	cp++;

	cStateChange3 = *cp;
	cp++;

	iOldStr	= m_pClientList[iClientH]->m_iStr;
	iOldVit	= m_pClientList[iClientH]->m_iVit;
	iOldDex = m_pClientList[iClientH]->m_iDex;
	iOldInt = m_pClientList[iClientH]->m_iInt;
	iOldMag = m_pClientList[iClientH]->m_iMag;
	iOldChar = m_pClientList[iClientH]->m_iCharisma;
	
	if (!bChangeState(cStateChange1,&cStr,&cVit,&cDex,&cInt,&cMag,&cChar)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}
	if (!bChangeState(cStateChange2,&cStr,&cVit,&cDex,&cInt,&cMag,&cChar)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}
	if (!bChangeState(cStateChange3,&cStr,&cVit,&cDex,&cInt,&cMag,&cChar)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}

	if (m_pClientList[iClientH]->m_iGuildRank == 0) {
  if (m_pClientList[iClientH]->m_iCharisma - cChar < 20) {
  	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  	return;
  }
	}

	if (iOldStr + iOldVit + iOldDex + iOldInt + iOldMag + iOldChar != (179*3 + 70)) {
  return;
	}

	if ((cStr < 0 || cVit < 0 || cDex < 0 || cInt < 0 || cMag < 0 || cChar < 0) || 
  	(cStr + cVit + cDex + cInt + cMag + cChar != 3)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}
	
	if ((m_pClientList[iClientH]->m_iStr - cStr > DEF_CHARPOINTLIMIT) 
  	|| (m_pClientList[iClientH]->m_iStr - cStr < 10)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}
	
	if ((m_pClientList[iClientH]->m_iDex - cDex > DEF_CHARPOINTLIMIT) 
   || (m_pClientList[iClientH]->m_iDex - cDex < 10)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}

	if ((m_pClientList[iClientH]->m_iInt - cInt > DEF_CHARPOINTLIMIT) 
   || (m_pClientList[iClientH]->m_iInt - cInt < 10)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}

	if ((m_pClientList[iClientH]->m_iVit - cVit > DEF_CHARPOINTLIMIT) 
   || (m_pClientList[iClientH]->m_iVit - cVit < 10)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}

	if ((m_pClientList[iClientH]->m_iMag - cMag > DEF_CHARPOINTLIMIT) 
   || (m_pClientList[iClientH]->m_iMag - cMag < 10)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}

	if ((m_pClientList[iClientH]->m_iCharisma - cChar > DEF_CHARPOINTLIMIT)
   || (m_pClientList[iClientH]->m_iCharisma - cChar < 10)) {
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_FAILED, NULL, NULL, NULL, NULL);
  return;
	}

	if (m_pClientList[iClientH]->m_iLU_Pool < 3) m_pClientList[iClientH]->m_iLU_Pool = 3;

	m_pClientList[iClientH]->m_iGizonItemUpgradeLeft--;
	
	m_pClientList[iClientH]->m_iStr -= cStr;
	m_pClientList[iClientH]->m_iVit -= cVit;
	m_pClientList[iClientH]->m_iDex -= cDex;
	m_pClientList[iClientH]->m_iInt -= cInt;
	m_pClientList[iClientH]->m_iMag  -= cMag;
	m_pClientList[iClientH]->m_iCharisma -= cChar;

	if (cInt > 0) {
  bCheckMagicInt(iClientH);
	}

        //Re-Calculate HP,MP,SP
	if (m_pClientList[iClientH]->m_iHP > iGetMaxHP(iClientH)) m_pClientList[iClientH]->m_iHP = iGetMaxHP(iClientH);
	if (m_pClientList[iClientH]->m_iMP > iGetMaxMP(iClientH)) m_pClientList[iClientH]->m_iMP = iGetMaxMP(iClientH);
	if (m_pClientList[iClientH]->m_iSP > iGetMaxSP(iClientH)) m_pClientList[iClientH]->m_iSP = iGetMaxSP(iClientH);

	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_STATECHANGE_SUCCESS, NULL, NULL, NULL, NULL);
}
bChangeState:

Code: Select all

BOOL CGame::bChangeState(char cStateChange, char *cStr, char *cVit, char *cDex, char *cInt, char *cMag, char *cChar)
{
	if (cStateChange == DEF_STR) {
  *cStr += 1;
	}
	else if (cStateChange == DEF_VIT) {
  *cVit += 1;
	}
	else if (cStateChange == DEF_DEX) {
  *cDex += 1;
	}
	else if (cStateChange == DEF_INT) {
  *cInt += 1;
	}
	else if (cStateChange == DEF_MAG) {
  *cMag += 1;
	}
	else if (cStateChange == DEF_CHR) {
  *cChar += 1;
	}
	else {
  return 0;
	}
	
	return cStateChange;
}
Game.h Definitions...

Code: Select all

#define DEF_STR 0x01 //Correct
#define DEF_DEX 0x02 //Correct
#define DEF_INT	0x03 //Correct
#define DEF_VIT 0x04 //Correct
#define DEF_MAG	0x05 //Correct
#define DEF_CHR 0x06 //Correct
***EDITED***

Added The ReCalculate HP,SP,MP To Prevent Connection Lost. and fixed the GAME.h Definitions... now its 100% TESTED! 100% Working!
OWNED!<br><img src='http://img50.imageshack.us/img50/1386/p ... 3vsqn2.gif' border='0' alt='user posted image' /><br><br><img src="http://hbtop50.com/button.php?u=hbuonline" alt="Helbreath Top 50 - Keepin' it real." border="0" /><br><a href='http://www.hbuonline.net' target='_blank'>Helbreath United</a>
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

That's exactly what you can find in any 3.0 or 2.24b HG sources...


I used 2.24b not edited to code that part client side and it worked fine!!
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
SlammeR
Loyal fan
Posts: 219
Joined: Fri Nov 04, 2005 1:52 am
Location: Brazil

Post by SlammeR »

i dont know if people noticed this but some things on the old post was wrong nvm i updated it check this fixes:

Game.cpp
StateChangeHandler Add this:

Code: Select all

        //Re-Calculate HP,MP,SP
	if (m_pClientList[iClientH]->m_iHP > iGetMaxHP(iClientH)) m_pClientList[iClientH]->m_iHP = iGetMaxHP(iClientH);
	if (m_pClientList[iClientH]->m_iMP > iGetMaxMP(iClientH)) m_pClientList[iClientH]->m_iMP = iGetMaxMP(iClientH);
	if (m_pClientList[iClientH]->m_iSP > iGetMaxSP(iClientH)) m_pClientList[iClientH]->m_iSP = iGetMaxSP(iClientH);
To Char dont get connection lost when you change stats...

Game.h

Code: Select all

#define DEF_STR 0x01 //Correct
#define DEF_DEX 0x02 //Correct
#define DEF_INT	0x03 //Correct
#define DEF_VIT 0x04 //Correct
#define DEF_MAG	0x05 //Correct
#define DEF_CHR 0x06 //Correct
and the fix for Ex: you change STR ok got -3 pts on str and +3 to put in what you want then you put on VIT but MAG got +3

nvm this is 100% working majestic stats change =)
OWNED!<br><img src='http://img50.imageshack.us/img50/1386/p ... 3vsqn2.gif' border='0' alt='user posted image' /><br><br><img src="http://hbtop50.com/button.php?u=hbuonline" alt="Helbreath Top 50 - Keepin' it real." border="0" /><br><a href='http://www.hbuonline.net' target='_blank'>Helbreath United</a>
Post Reply