Code: Select all
public float getPercentFromCurrentLevel(long exp, int level)
{
long expPerLevel = getExpForLevel(level);
long expPerLevel2 = getExpForLevel(level + 1);
return (float) (exp - expPerLevel) / (expPerLevel2 - expPerLevel);
}
Code: Select all
public float getPercentFromCurrentLevel(long exp, int level)
{
long expPerLevel = getExpForLevel(level);
long expPerLevel2 = getExpForLevel(level + 1);
return (float) (exp - expPerLevel) / (expPerLevel2 - expPerLevel);
}
Code: Select all
activeChar.removeExpAndSp(activeChar.getExp() - ExperienceData.getInstance().getExpForLevel(20), 0);
Code: Select all
if(iCharLevel != 85)
{
long l_ExpForLvl = ExperienceData.getInstance().getExpForLevel(iCharLevel);
long l_ExpForLvlInc = ExperienceData.getInstance().getExpForLevel(iCharLevel+1);
long lTempExp;
lTempExp = l_ExpForLvl;
while(lTempExp < l_ExpForLvlInc)
{
float fGetNewPercent = ExperienceData.getInstance().getPercentFromCurrentLevel(lTempExp, iCharLevel);
String strNewPercent = String.format("%.2f", fGetNewPercent);
if(strPercent.equals(strNewPercent) )
{
activeChar.addExpAndSp(lTempExp - l_ExpForLvl, 0); //set percantage
activeChar.sendMessage(strPercent);
break;
}
lTempExp += 1; // inc works only for int in Java, so I used this method
}
}
Code: Select all
//lVar1=char lvl (long value, presented as exp)
//lVar2=char lvl+1 (long value, presented as exp)
//fVar3=percent from old lvl, or manual (float value, presented as %.4f in canculations)
if((lVar1<=85)&&(lVar1>1)) long lPercResult=(((((lVar1-lVar2)/100)*(long)(fVar3*10000)))/100);//maybe require diff %.5f
Code: Select all
//Example: now u can use it for your characters' new lvl as additional operation
activeChar.addExpAndSp(lPercResult, 0);
//or make it as fast canculator for lvl down operation with % saving
activeChar.addExpAndSp((activeChar.getExp()-ExperienceData.getInstance().getExpForLevel(lvl))+lPercResult); //lvl up + %