User avatar
By 9Tales
#215849 I think it would be nice to add the ability to make custom experience groups with datapacks. As far as I can tell, EXP groups are hardcoded. Adding this would make people who want to make datapacks that add the Gen 1 glitch Pokemon able to implement their experience groups as well, and if they wanted to give MissingNo its real experience group they could do that too. Though I don't think many people would use it, it don't hurt to have the option of adding new experience groups.

Now, this means that they would need a way to represent them in JSON files. I have an idea. All experience groups that have ever existed in the main Pokemon games, both intentionally or unintentionally (glitch experience groups of Generation 1 glitch Pokemon), could be represented as piecewise functions where all the pieces are polynomials of degree 4. Many of them don't even require all the terms. I figured that we could allow players to specify any number of quartic polynomials as well as minimum levels and maximum levels where each formula is used. Even if a player wanted to implement a formula that isn't a polynomial, they could implement it by using a piecewise function of 100 functions (all constants) that each are used for only one level equaling the amount of experience the Pokemon should have at that level.

The easiest way to implement the coefficients would be to have the user specify the coefficients as doubles where any coefficients that aren't given are assumed to be 0, but if there are precision issues with the existing experience groups from doing so then rational numbers could be used instead and the player specifies the numerator (default 0) and denominator (default 1) of each coefficient. We also could optionally allow specifying numerators and denominators as an alternative option, which is what I did in the sample JSONs at the bottom. If minimum or maximum levels aren't given, they are assumed to be 1 and the level cap respectively.

Here are some examples of my proposed JSON file format for this, where I represent all of the experience groups in Pixelmon as well as MissingNo's experience group (total EXP = 33(level)^2 + 155(level) - 80) in Pokemon Red and Blue:

Fast experience group | Show
Code: Select all{
    "name": "FAST",
    "equation": [
        {
            "n3_coefficient": 0.8
        }
    ]
}

Medium Fast experience group | Show
Code: Select all{
    "name": "MEDIUM_FAST",
    "equation": [
        {
            "n3_coefficient": 1
        }
    ]
}

Medium Slow experience group | Show
Code: Select all{
    "name": "MEDIUM_SLOW",
    "equation": [
        {
            "n3_coefficient": 1.2,
            "n2_coefficient": -15,
            "n1_coefficient": 100,
            "constant": -140
        }
    ]
}

Slow experience group | Show
Code: Select all{
    "name": "SLOW",
    "equation": [
        {
            "n3_coefficient": 1.25
        }
    ]
}

Erratic experience group | Show
Code: Select all{
    "name": "ERRATIC",
    "equation": [
        {
            "max_level": 49,
            "n4_coefficient": -0.02,
            "n3_coefficient": 2
        },
        {
            "min_level": 50,
            "max_level": 67,
            "n4_coefficient": -0.01,
            "n3_coefficient": 1.5
        },
        {
            "min_level": 68,
            "max_level": 97,
            "n4_coefficient": [
                "numerator": -1,
                "denominator": 150
            ],
            "n3_coefficient": 1.274
        },
        {
            "min_level": 98,
            "n4_coefficient": -0.01,
            "n3_coefficient": 1.6
        }
    ]
}

Fluctuating experience group | Show
Code: Select all{
    "name": "FLUCTUATING",
    "equation": [
        {
            "max_level": 14,
            "n4_coefficient": [
                "numerator": 1,
                "denominator": 150
            ],
            "n3_coefficient": [
                "numerator": 1,
                "denominator": 150
            ],
            "constant": 0.48
        },
        {
            "min_level": 15,
            "max_level": 35,
            "n4_coefficient": 0.02,
            "n3_coefficient": 0.28
        },
        {
            "min_level": 36,
            "n4_coefficient": 0.01,
            "n3_coefficient": 0.64
        }
    ]
}

MissingNo's experience group | Show
Code: Select all{
    "name": "MISSINGNO",
    "equation": [
        {
            "n2_coefficient": 33,
            "n1_coefficient": 155,
            "constant": -80
        }
    ]
}

Edit: Just realized Fluctuating and Erratic include floor functions, which means the JSONs I put above might not quite work out for them. Perhaps the existing experience groups could remain hardcoded, while the game would also check for datapack ones. As experience groups are implemented using Java function objects, could also see if the functions could be input as strings in the JSONs and converted to functions. Could also have another field apart from name and equation that are specifically constant exp amounts assigned to particular levels that override the outputs of the equations for those levels.

JOIN THE TEAM