[SRC] void CheckLevelUp

Codes already submitted by people of the forums.
Post Reply
Dax
<3 bd long time
Posts: 785
Joined: Mon Apr 18, 2005 3:19 pm

Post by Dax »

Issues this function fixes:
- It now handles majestic points inside the loop. Your additional experience is carried over so you can get multiple majestic levels.
- Level up gold is handled from inside the loop also. If you are level 1 and you get 3 levels you'll receive 1 single message saying "You received 300 Gold!" insted of any missing gold or getting multiple messages.(Which is better then how nemesis fixed it.)
- The loop has been improved by removing any counting and merging normal levels with majestic levels. All level up situations under massive exp will not produce bugs. Example: You can level from level 18~MAX without bugs, 1 gold message for 600 gold, and 17 majestic points.

This isnt exactly a cut and paste job thanks to the fact i changed it from bool to void. You will need to change every call made to this function. If you can manage to add it then i suggest you use it. It's a very clean code and it's exactly how it should of been. A hint to addint it would be that you don't need the old level up gold methods. These ones dont bug and will work 100% for multiple levels. That is why it was a bool before.

Code: Select all

/* 
 Dax - Level Up
	Max Level
  +1 Majestic Points
  Reset EXP to Max Level (Returns any additional EXP)
  Can handle multiple levels
	Level Up
  +1 Level
  +3 Level Up Points
  Reset Next Level EXP
  Level 5 and Under receive +100 Bonus Gold
  Level 20 and Under receive +300 Bonus Gold
  Can handle multiple levels
*/
void CGame::CheckLevelUp(int iClientH)
{
	class CItem * pItem;

	if (m_pClientList[iClientH] == NULL) return;
	if (m_pClientList[iClientH]->m_iExp < m_pClientList[iClientH]->m_iNextLevelExp) return;
	
	while (m_pClientList[iClientH]->m_iExp >= m_pClientList[iClientH]->m_iNextLevelExp) // Check Level Up Loop
	{
  if (m_pClientList[iClientH]->m_iLevel >= DEF_PLAYERMAXLEVEL) // Max Level
  {
  	m_pClientList[iClientH]->m_iExp -= (m_pClientList[iClientH]->m_iNextLevelExp - m_iLevelExpTable[m_iPlayerMaxLevel]);
  	if (m_pClientList[iClientH]->m_iGizonItemUpgradeLeft < DEF_MAXGIZONPOINT )
    m_pClientList[iClientH]->m_iGizonItemUpgradeLeft++;
  	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_EXP, NULL, NULL, NULL, NULL);
  	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_GIZONITEMUPGRADELEFT, m_pClientList[iClientH]->m_iGizonItemUpgradeLeft, 1, NULL, NULL);
  }
  else // Level Up
  {
  	if (m_pClientList[iClientH]->m_iLevel <= 20) 
  	{ 
    if (pItem == NULL)
    { 
    	pItem = new class CItem;
    	if (_bInitItemAttr(pItem, "Gold") == FALSE) 
    	{
      delete pItem;
      return;
    	}
    }
    if (m_pClientList[iClientH]->m_iLevel <= 5) pItem->m_dwCount += 100;
    else pItem->m_dwCount += 300;
  	}
  	m_pClientList[iClientH]->m_iLevel++;
  	m_pClientList[iClientH]->m_iLU_Pool += 3;
  	m_pClientList[iClientH]->m_iNextLevelExp = m_iLevelExpTable[m_pClientList[iClientH]->m_iLevel + 1];
  	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_LEVELUP, NULL, NULL, NULL, NULL);
  	CalcTotalItemEffect(iClientH, -1, FALSE);
  	if ((m_pClientList[iClientH]->m_iLevel >= DEF_CIVILIANLIMIT) && (m_pClientList[iClientH]->m_bIsHunter == TRUE ) ) 
    SetNoHunterMode(iClientH,TRUE);
  }
	}
	if(pItem != NULL)
  bAddItem(iClientH, pItem, NULL);
	return;
}
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
romax
Member
Posts: 149
Joined: Sat Nov 01, 2003 10:42 am

Post by romax »

goood job bro :)
<img src='http://img357.imageshack.us/img357/505/eyecopy7ng.gif' border='0' alt='user posted image' />
Kiruku
Loyal fan
Posts: 268
Joined: Wed Feb 22, 2006 12:00 pm
Contact:

Post by Kiruku »

lolx thanks :P good tha tu made it like this no noob polish server (siara) can add it i think :D
<img src='http://lichtdrache.lima-city.de/helbrea ... aramba.gif' border='0' alt='user posted image' />
SlammeR
Loyal fan
Posts: 219
Joined: Fri Nov 04, 2005 1:52 am
Location: Brazil

Post by SlammeR »

Thanks dax
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>
marleythe9
Loyal fan
Posts: 391
Joined: Sat Mar 26, 2005 12:41 am

Post by marleythe9 »

lol damn i just did that with mine to.

the MJ part of the exp.
<img src='http://freewebs.com/trickro/70s.png' border='0' alt='user posted image' /><img src='http://freewebs.com/trickro/70s2.jpg' border='0' alt='user posted image' />
Charles
Loyal fan
Posts: 418
Joined: Wed Nov 26, 2003 8:20 pm

Post by Charles »

watch someone post saying they get certain errors as i see that the civilian mode on dax's is different.. lol
<i>"Always write good code. Feel bad to write bad code."</i>
Dax
&lt;3 bd long time
Posts: 785
Joined: Mon Apr 18, 2005 3:19 pm

Post by Dax »

marleythe9 wrote: lol damn i just did that with mine to.

the MJ part of the exp.
Use the entire function. It shits on the old way. And no matter how you use it (MASSIVE exp etc) you wont find a "Level Up" bug of any type.
Charles wrote: watch someone post saying they get certain errors as i see that the civilian mode on dax's is different.. lol
You will get a few errors if you just cut and paste it. A little understanding of some basic features is all you need. Kiruku added it perfectly.
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
Charles
Loyal fan
Posts: 418
Joined: Wed Nov 26, 2003 8:20 pm

Post by Charles »

Dax wrote:
marleythe9 wrote: lol damn i just did that with mine to.

the MJ part of the exp.
Use the entire function. It shits on the old way. And no matter how you use it (MASSIVE exp etc) you wont find a "Level Up" bug of any type.
Charles wrote: watch someone post saying they get certain errors as i see that the civilian mode on dax's is different.. lol
You will get a few errors if you just cut and paste it. A little understanding of some basic features is all you need. Kiruku added it perfectly.
oh yeah i know i added it perfect just was saying that someone might post like usual on outpost :rolleyes:
<i>"Always write good code. Feel bad to write bad code."</i>
Acidx
Member
Posts: 198
Joined: Tue Mar 23, 2004 4:27 am

Post by Acidx »

doesnt work for me danny i get this error

Code: Select all

Error: Missing Storage class 'youran00bformatplix'.
lol :lol:
<b>-<span style='color:green'>ACiD-x </span><span style='color:red'> Owning PCs Since 1987</span><br><img src='http://img204.imageshack.us/img204/2245/hackertf5.gif' border='0' alt='user posted image' /><br><img src='http://img509.imageshack.us/img509/6697 ... 4sc4ed.png' border='0' alt='user posted image' /><br><span style='color:orange'>i am Pwn NetGAYLORDS !</span></b><br><span style='color:blue'><br>I Pwn HBUSA =)</span>
EvilHit
Loyal fan
Posts: 356
Joined: Sun Jan 16, 2005 3:20 am

Post by EvilHit »

lol acid
willem
noob
Posts: 11
Joined: Sun Jun 20, 2004 3:09 pm

Post by willem »

Txs for the code i had to mess the rest of game.ccp a bit up, but i got it to work! :P ty ty ty :)
Orkl
Loyal fan
Posts: 376
Joined: Sat Sep 17, 2005 2:31 pm

Post by Orkl »

How did you mess it up exactly? It's not too hard to implement...
<!--QuoteBegin-crazymnig88+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (crazymnig88)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->by notepad??? it didn't show any code, just show words wif no mean<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd--><br><!--QuoteBegin-charlie+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (charlie)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->he'll probably save it as 600pagebook.bmp<br><br>400gb file plzkthnx<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd-->
Kiruku
Loyal fan
Posts: 268
Joined: Wed Feb 22, 2006 12:00 pm
Contact:

Post by Kiruku »

he messed with Game.cpp u ned to change this bIsLevelUp = bChecklevelUp....... and change the bs of Bool away..... after that it works correctly
<img src='http://lichtdrache.lima-city.de/helbrea ... aramba.gif' border='0' alt='user posted image' />
Post Reply