Adding support for EXP items
Posted: Fri May 30, 2008 3:45 pm
here is the code you need to be able to support EXP rate items in your server.
This will be included in the SVN at some point once we are settled into our new project properly and once Drakia and i get the darn skills working properly.
In the mean time, if you want to add this support to osirose or osprose servers (osrose is slightly different + Lmame has already coded it for rev 81) then here it is.
It is pretty basic code but it is spread all over the server so follow carefully.
Some parts are optional but they will be included in a second post.
in chartypes.h, find
after, add
This adds a personal xprate multiplier value to your player->stats structure.
in Character.h, find
after, add
in charstats.cpp, find
after, add
in WorldMonster.h, find
after, add
in monsterstats.cpp, find
after, add
Why does a monster need xprate?
it doesn't but the monster and character classes are intricately interwoven and the server will not compile properly unless you add it.
still in monsterstats.cpp, find
after, add
in player.h, find
after, add
in Playerdata.cpp, find
after, add
in playerstats.cpp
add this function anywhere you like.
You might as well put it after the one that returns defence just to keep it neat.
still in playerstats.cpp, find
after, add
in worldprocesses.cpp, find
The entire line may be slightly different. i don't have an unmodified version to check against. Either way it should be easy enough to find it.
replace line with
in the same function, find
Again this may be slightly different but easy to find.
replace line with
same function, about 3 lines after teh last change, find
replace line with
and finally a little addition to datatypes.h so that the function in playerstats knows what value to look far.
find
after, add
That should be all you need to be able to read back the XP rate of items such as hero medals and so on.
This will be included in the SVN at some point once we are settled into our new project properly and once Drakia and i get the darn skills working properly.
In the mean time, if you want to add this support to osirose or osprose servers (osrose is slightly different + Lmame has already coded it for rev 81) then here it is.
It is pretty basic code but it is spread all over the server so follow carefully.
Some parts are optional but they will be included in a second post.
in chartypes.h, find
- unsigned int MaxSummonGauge;
- unsigned int MPReduction;
- unsigned int ExtraDamage;
after, add
- unsigned int xprate;
This adds a personal xprate multiplier value to your player->stats structure.
in Character.h, find
- virtual unsigned int GetDefense( );
after, add
- virtual unsigned int GetXPRate( );
in charstats.cpp, find
- // virtual [return defense]
- unsigned int CCharacter::GetDefense( )
- {
- return 0;
- }
after, add
- // virtual [return xprate]
- unsigned int CCharacter::GetXPRate( )
- {
- return 0;
- }
in WorldMonster.h, find
- unsigned int GetDefense( );
after, add
- unsigned int GetXPRate( );
in monsterstats.cpp, find
- unsigned int CMonster::GetCritical( )
- {
- return 60; //60 = 20% of 300 our critical probability
- }
after, add
- unsigned int CMonster::GetXPRate( )
- {
- return 0;
- }
Why does a monster need xprate?
it doesn't but the monster and character classes are intricately interwoven and the server will not compile properly unless you add it.
still in monsterstats.cpp, find
- Stats->Defense = GetDefense( );
after, add
- Stats->xprate = GetXPRate( );
in player.h, find
- unsigned int GetDefense( );
after, add
- unsigned int GetXPRate( );
in Playerdata.cpp, find
- Clan->clanid = atoi(row[26]);
- Clan->clanrank = atoi(row[27]);
- Position->saved = atoi(row[28]);
after, add
- Stats->xprate = GetXPRate();
in playerstats.cpp
add this function anywhere you like.
You might as well put it after the one that returns defence just to keep it neat.
- // Return XPRate
- unsigned int CPlayer::GetXPRate( )
- {
- UINT XPRate = 0;
- for(UINT i=1;i<12;i++)
- {
- if( items[i].count != 0 )
- {
- if(items[i].itemtype>9)
- {
- Log(MSG_WARNING, "Char %s have equip invalid item: %i,%i", CharInfo->charname, items[i].itemtype, items[i].itemnum );
- continue;
- }
- if( GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat1[0] == XP_RATE)
- {
- XPRate += GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat1[1];
- //Log( MSG_INFO, "XP rate item detected basic stat = %i item number %i", GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat1[1],items[i].itemnum);
- }
- if( GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat2[0] == XP_RATE)
- {
- XPRate += GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat2[1];
- //Log( MSG_INFO, "XP rate item detected basic stat = %i item number %i", GServer->EquipList[items[i].itemtype].Index[items[i].itemnum]->stat1[2],items[i].itemnum);
- }
- if(items[i].stats>0 && items[i].stats<500)
- {
- if(GServer->StatsList[items[i].stats].stat[0] == XP_RATE)
- {
- XPRate += GServer->StatsList[items[i].stats].value[0];
- //Log( MSG_INFO, "XP rate item detected. extra stat = %i item number %i", GServer->StatsList[items[i].stats].value[0],items[i].itemnum);
- }
- if(GServer->StatsList[items[i].stats].stat[1] == XP_RATE)
- {
- XPRate += GServer->StatsList[items[i].stats].value[1];
- //Log( MSG_INFO, "XP rate item detected. extra stat = %i item number %i", GServer->StatsList[items[i].stats].value[1],items[i].itemnum);
- }
- }
- }
- }
- //Log( MSG_INFO, "XP rate rate calculated as = %i", XPRate);
- if(XPRate < 1)
- XPRate=1;
- return XPRate;
- }
still in playerstats.cpp, find
- Stats->Defense = GetDefense( );
after, add
- Stats->xprate = GetXPRate( );
in worldprocesses.cpp, find
- thisclient->CharInfo->Exp += GetColorExp( thisclient->Stats->Level, thismon->thisnpc->level, exp )
The entire line may be slightly different. i don't have an unmodified version to check against. Either way it should be easy enough to find it.
replace line with
- thisclient->CharInfo->Exp += GetColorExp( thisclient->Stats->Level, thismon->thisnpc->level, exp ) * thisclient->Stats->xprate;
in the same function, find
- partyclient->CharInfo->Exp += GetColorExp( partyclient->Stats->Level, thismon->Stats->Level, (UINT)round(thisparty->exp / thisparty->num) )
Again this may be slightly different but easy to find.
replace line with
- partyclient->CharInfo->Exp += GetColorExp( partyclient->Stats->Level, thismon->Stats->Level, (UINT)round(thisparty->exp / thisparty->num) ) * partyclient->Stats->xprate;
same function, about 3 lines after teh last change, find
- partyclient->CharInfo->Exp += GetColorExp( partyclient->Stats->Level, thismon->Stats->Level, (UINT)round(partyclient->Stats->Level * thisparty->exp / thisparty->maxlevel) )
replace line with
- partyclient->CharInfo->Exp += GetColorExp( partyclient->Stats->Level, thismon->Stats->Level, (UINT)round(partyclient->Stats->Level * thisparty->exp / thisparty->maxlevel) ) * partyclient->Stats->xprate;
and finally a little addition to datatypes.h so that the function in playerstats knows what value to look far.
find
- #define CRITICAL 26
after, add
- #define XP_RATE 30
That should be all you need to be able to read back the XP rate of items such as hero medals and so on.