PDA

View Full Version : CalcRecommendedLevelBonus


slowglass
02-08-2007, 01:40 AM
This function is used to calculate the stats of an item when the recomended level is greater then the character level.


int Client::CalcRecommendedLevelBonus(int8 level, uint8 reclevel, int basestat)
{
if( (reclevel > 0) && (level < reclevel) )
{
float statmod = (level / reclevel) * basestat;

if( statmod < 0 )
{
statmod *= -1;
statmod += 0.5;
return (((int)statmod) * -1);
}
else
{
statmod += 0.5;
return (int)statmod;
}
}

return 0;
}


In the above code

float statmod = (level / reclevel) * basestat; will always return 0.


The fix should be (please bear with me as I cannot compile or test the server yet. I need to set up the entire enviroment) ...


float statmod = (((float)level) / reclevel) * basestat;



There is a secondary issue (I beleive) that the server computes the stats on an item by item basis, while the client creates amalgamated items of the item and all its augs and then calculates the stats.


Chris

KLS
02-09-2007, 07:14 PM
You're indeed right, that should result in that always being 0. Had noticed rec. levels not working quite right a while back but never looked at it. Might even be able to do it without the casts.

slowglass
02-09-2007, 07:47 PM
Think you are right casts are not needed.
There is a second change that is needed which popergates the recomended level.
I have written the code, just need to test it compiles before I post it