Ok.....so this was working fine up until i raised my LEVEL_INCREMENT
@ an increment of 32 it works wonderfully, but when i bring it up to a 37 it goes haywire.
I'm trying to have a level system that you can specify the points (i call frags) of the first 5 levels. then after that it gets calculated. I'm not sure what is broken but can someone take a look at it? It seems my basic math is kind of rusty.....
Here is the code that i have. Defined lvl 0-5, LEVEL_INCREMENT, and then the offset. Should be self explanatory.
PHP Code:
// Upper boundry for level (inclusive)
// Feel free to edit these values if you don't like the level structure
#define LVL0 5 // Regular knife RandomFloat(15, 75
#define LVL1 25 // Brass knucks RandomFloat(100, 150
#define LVL2 57 // Run faster
#define LVL3 100 // Jump Higher gravity(0.55) ->set by LOW_GRAVITY define
#define LVL4 125 // Stronger hit w/ BK
#define LVL5 180 // Extra powers
#define MAXLEVEL 350 // Maximum level a player can reach (comment to disable)
#define LEVEL_INCREMENT 37 // Frags per level (after the defined levels 0-5)
// Offset to determine how off Level 5 is from norm LEVEL_INCREMENT
// ********DO NOT EDIT BELOW THIS LINE!*********
const LevelOffset = LVL5 - (LEVEL_INCREMENT * 5)
stock getLevel(id) // RETURNS: -1 if off or error
{
// returns the level of the player, based on their frags
if(get_pcvar_num(frags_pcvar) == 0 || !is_user_connected(id))
return -1
static frags, Float:f_calc
frags = gi_playerFrags[id]
if(frags <= LVL0)
return 0
else if(frags <= LVL1)
return 1
else if(frags <= LVL2)
return 2
else if(frags <= LVL3)
return 3
else if(frags <= LVL4)
return 4
else if(frags <= LVL5)
return 5
else
{ //LevelOffset = LVL5 - (LEVEL_INCREMENT*5)
f_calc = floatdiv((frags + LevelOffset), LEVEL_INCREMENT)
#if defined MAXLEVEL
return clamp(floatround(f_calc, floatround_ceil), 0, MAXLEVEL)
#else
return floatround(calc, floatround_ceil)
#endif
}
return -1
}
I'm thinking its within the LevelOffset calculations....but i really don't know.
I know that floatround_ceil is the wrong way to go for most calculations, but it seemed to be going low even when i calculate @ LEVEL_INCREMENT 36 (what a lvl 5 would normally be)
Its just blowing my life...
Thanks in advance.
__________________