Enemies Experience Per Level Generator

This generator creates a file with the "experience rewards" by enemies per "variation" and "level".

Running the generator

This generator has no page in the administration panel, it is a command line tool. It runs from a terminal in your project folder and writes a JSON file that the Objects Importer (available in the administration panel) uses to set the experience reward of each enemy.

  1. Run the Players Experience Per Level generator first: its output is the required player levels input of this generator.
  2. Create the input file, for example generate-data/monsters-experience-per-level.json, with the variations and decrementProportionPerLevel described below.
  3. From the project root run the command with the input file and the players experience file:
    npx reldens-generate monsters-experience-per-level ./generate-data/monsters-experience-per-level.json ./generated/players-experience-per-level-[date-time].json
  4. The output is saved as generated/monsters-experience-per-level-[date-time].json inside the current folder (change it with the optional jsonFileName and generateFolderPath input properties).
  5. Reference the output file as experiencePerLevelFile in the objects import data and set level and experienceKey (a variation key) on each enemy. The Objects Importer page explains where the file must be placed.

Configuration reference

Required Parameters

  • levelsExperienceByKey - All player level experience data in the same format provided by the Players Experience Per Level generator. The command reads it from the second file argument, which is required and replaces any value set in the input file. When you use the generator class in your own script it is passed inline.
  • variations - Each variation key with a numeric value. Larger values mean more experience rewarded.
  • decrementProportionPerLevel - Values used to decrease the proportion of experience given per level, making high-level enemies give proportionally less experience to increase required kill counts at higher levels.

Optional: jsonFileName (default monsters-experience-per-level-[date-time].json) and generateFolderPath (default generated, relative to the folder where the command runs).

Input File Format

{
    "levelsExperienceByKey": {
        "1": { "req": 10, "total": 10, "growthFactor": 2 },
        "2": { "diff": 10, "req": 20, "total": 30, "growthFactor": 2.005 },
        "3": { "diff": 20, "req": 40, "total": 70, "growthFactor": 2.01 }
    },
    "variations": {
        "monsterA": 8,
        "monsterB": 9,
        "bossExtra": 15
    },
    "decrementProportionPerLevel": {
        "5": 0.8,
        "10": 0.42,
        "15": 0.4,
        "20": 0.26,
        "25": 0.15,
        "30": 0.1,
        "35": 0.08,
        "40": 0.0025
    }
}

With the command line the levelsExperienceByKey block can be left out of the input file, since it is loaded from the second argument.

Output File Format

The output is a JSON object with level numbers as keys. Each level contains per-variation experience data:

{
    "1": {
        "req": 10, "total": 10, "growthFactor": 2,
        "monsterA": { "decrementProportion": 0, "randomVariation": 8, "exp": 1, "kills": 10 },
        "monsterB": { "decrementProportion": 0, "randomVariation": 9, "exp": 1, "kills": 10 },
        "bossExtra": { "decrementProportion": 0, "randomVariation": 15, "exp": 2, "kills": 5 }
    }
}

Output fields per variation per level:

  • exp - Experience points rewarded when defeating this enemy type
  • kills - Number of kills required to level up from this level using this enemy type
  • decrementProportion - The proportion decrement applied at this level
  • randomVariation - The variation factor used for this level

The Objects Importer reads [level][experienceKey].exp from this file to create the experience reward of each imported enemy.

Code integration (advanced)

The command runs the MonstersExperiencePerLevel class of the @reldens/game-data-generator package (bin/generate.js), after setting levelsExperienceByKey from the second file.

Important: if you are using the MonstersExperiencePerLevel class in your own script, note the level keys must be passed as strings.

Related Documentation

Go Up