PDA

View Full Version : [wip] detailed exp gain


zeiksz2
01-11-2008, 11:29 PM
getting xp was a fabled thing those days i was playing. ya never knew how much you get, never knew how much to be done.. so here you go with some detailed xp.

description:
after "you gain experience/group xp" line you get line for xp and if needed aa xp. you get info that what kind of xp it is (normal or aa) then the amount then how much you are to do to gain a level and then how much of this exp gain you need to do the level.

example:
you gain experience!
normal: 10 (to go: 20 (2 from this)) - means you got 10 xp and you are to get 2 times 10 xp more to do the level.



//we get xp or group xp, so we set up message
if(this->IsGrouped())
this->Message_StringID(15,GAIN_GROUPXP);
else
this->Message_StringID(15,GAIN_XP);


********* start



//and we continue with some details..
char szoveg [256];
if (set_exp>m_pp.exp)
{
char ding [128];
int togo = GetEXPForLevel(GetLevel()+1)-set_exp;
//gain of normal xp
if (togo<0)
{
snprintf(ding,128,"%s","DING!");
} else {
if (togo/(set_exp-m_pp.exp)<10000)
{
snprintf(ding,128,"to go: %i (%i from this)",togo,togo/(set_exp-m_pp.exp));
} else {
snprintf(ding,128,"to go: %i (way to go)",togo);
}
}
//no ding on max level - replace 65 with the function
if (GetLevel()!=65)
{
snprintf(szoveg,256,"Normal: %i(%s)",set_exp-m_pp.exp,(char*)ding);
Message(15,(char*)szoveg);
}
}
if (set_aaxp>m_pp.expAA)
{
char ding2 [128];
int togo2 = max_AAXP-set_aaxp;
//gain of aa xp
if (togo2<0)
{
snprintf(ding2,128,"%s","DING!");
} else {
if (togo2/(set_aaxp-m_pp.expAA)<10000)
{
snprintf(ding2,128,"to go: %i (%i from this)",togo2,togo2/(set_aaxp-m_pp.expAA));
} else {
snprintf(ding2,128,"to go: %i (way to go)",togo2);
}
}
snprintf(szoveg,256,"AA: %i(%s)",set_aaxp-m_pp.expAA,(char*)ding2);
Message(15,(char*)szoveg);
}
}
}


******** end


else if((set_exp + set_aaxp) < (m_pp.exp+m_pp.expAA)){ //only loss message if you lose exp, no message if you gained/lost nothing.
Message(15, "You have lost experience.");
}



my questions - in what i like to get help:
- how to get the level cap? (what function?) i placed a simple 65 into code
- just my second code in c, so ... dumb newbie question: how to round UP numbers? if you see the code you will see that the (from this) values are rounded down - so you may get message 10xp "(to go: 1 (0 from this))"

KLS
01-12-2008, 08:37 AM
You can get the level cap:

make sure #include "../common/rulesys.h" is part of the file, very likely if it's exp code.

Then you can call: RuleI(Character, MaxLevel)

zeiksz2
01-12-2008, 11:05 AM
thank you for your help - worked very well :)

zeiksz2
01-12-2008, 12:06 PM
had no better idea for rounding up allways.. but this may work


int ad=0; if (togo/(set_exp-m_pp.exp)!=(int)(togo/(set_exp-m_pp.exp))) ad=1;
snprintf(ding,128,"to go: %i (%i from this)",togo,ad+(togo/(set_exp-m_pp.exp)));



and for aa exp


int ad2=0; if (togo2/(set_aaxp-m_pp.expAA)!=(int)(togo2/(set_aaxp-m_pp.expAA))) ad2=1;
snprintf(ding2,128,"to go: %i (%i from this)",togo2,ad2+togo2/(set_aaxp-m_pp.expAA));

zeiksz2
01-13-2008, 05:15 AM
previous code did not work and was not even a good shot.. here is a better one.. tested, working:


int ad=0; if (togo % (set_exp-m_pp.exp)!= 0) ad=1;



goes for both, so do same with ad2 too..

Sabyre
03-19-2008, 02:36 PM
Hungry Dev Newb Question: Which file would this code be inserted?

Angelox
03-19-2008, 11:04 PM
getting xp was a fabled thing those days i was playing. ya never knew how much you get, never knew how much to be done..

Probably a dumb question, but I wonder if you meant EqLive or EqEMu? Cause I remember playing on live all night, then sending tells to my friends on how happy I was to get a "sliver" of yellow on my exp bar. Blue bar didn't exist, they later made that so you think you were getting better exp).

zeiksz2
06-02-2008, 08:19 PM
eqlive - but btw i did not saw any of servers telling how much xp you get, etc.. so i can mean eqemu too - i think

zeiksz2
06-02-2008, 08:21 PM
Hungry Dev Newb Question: Which file would this code be inserted?

EQEmu-0.7.0-1070\SOURCE\zone\exp.cpp(134)

BatCountry
06-03-2008, 06:37 PM
had no better idea for rounding up allways.. but this may work

The ceil() function will round up always. It's in math.h

zeiksz2
06-05-2008, 04:34 PM
The ceil() function will round up always. It's in math.h

thank you very much