Results 1 to 4 of 4

Thread: Calculating level

  1. #1
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts

    Calculating level

    Hey,

    I'm trying calculate a level based on total kills/xp using the Quadratic equation.

    Example:
    Level 1 = 50 (+50)
    Level 2 = 150 (+100)
    Level 3 = 300 (+150)
    Level 4 = 500 (+200)

    I have found the equations to do this (http://stackoverflow.com/questions/6...l-based-on-exp) but i'm not sure how to translate that into the cod2 engine.

    Can anyone give me an example that would work?

  2. #2
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    This should work:
    PHP Code:
    level.rank[0] = 0;
    max_rank 20;

    for(
    1<= max_ranki++)
    {
        
    level.rank[i] = level.rank[i-1] + 50*i

    level.rank[RANK_VALUE] = shows you how many XP need for this rank.
    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  3. The Following 3 Users Say Thank You to RobsoN For This Useful Post:

    filthy_freak_ (9th March 2014),Ni3ls (9th March 2014),smect@ (9th March 2014)

  4. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Code:
    	lvl = 0;
    	xp_gain = 0
    	xp_increase = 50;
    	xp_level = 0;
    	while(xp_prev_level < self.xp)
    	{
    		xp_gain += xp_increase;
    		xp_level += xp_gain;
    		lvl++;
    	}
    easy
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    filthy_freak_ (9th March 2014),Ni3ls (9th March 2014)

  6. #4
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by RobsoN View Post
    This should work:
    PHP Code:
    level.rank[0] = 0;
    max_rank 20;

    for(
    1<= max_ranki++)
    {
        
    level.rank[i] = level.rank[i-1] + 50*i

    level.rank[RANK_VALUE] = shows you how many XP need for this rank.
    Working perfectly, thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •