Enemy Levels

coreEnemyLevels

This script allows you to assign levels to enemies. The level of an enemy is determined when you encounter the enemy.

The level is specified as a formula, which means you can define two types of levels:

  1. Static level. This means the enemy’s level never changes throughout the game. For example, a slime might always be level 1 no matter what.
  2. Dynamic level. This means the enemy’s level relies on data that may change throughout the game. For example, you can bind an enemy’s level to a game variable so that its level changes whenever you change the variable.

This plugin adds levels to enemies, which is a property that you access through damage formulas or other script calls. You can customize enemy parameters for each level using the enemy classes plugin, allowing you to assign classes to enemies and managing them the same way you would manage your actors.

In addition to setting enemy levels, this script provides a number of other enemy level related functionality, such as changing levels during battle and setting max/min enemy levels.

Download

Script: download here

Installation

Place this script below Materials and above Main

Usage

Setting Enemy Levels

To set an enemy’s level, note-tag it with

<enemy level: FORMULA>

You can use the extended note-tag if you need to write your formula on
multiple lines

<enemy level>
FORMULA
</enemy level>

The formula can be any valid ruby formula that evaluates to a number.
The following formula variables are available:

e - the enemy itself (Game_Enemy object)
p - game party
t - game troop
s - game switches
v - game variables

By default, if no level is specified, then the enemy is assumed to be level 1.

Accessing the level

If you ever need to reference the enemy’s level in your scripts or script calls, assuming you have a Game_Enemy object enemy, you can access it using

enemy.level

Setting Level Limits

You can set maximum and minimum levels for enemies using note-tags.

<max enemy level: FORMULA>
<min enemy level: FORMULA>

By default, the min level is 1 and max level is 99.

Adjusting Levels

If you want to adjust levels during battle, you can use script calls. All script calls require an “enemy index”, which is the index of the enemy in the current troop. You can get that index by looking at some battle event commands and looking at the number beside each enemy.

This call sets the level of the specified enemy.

set_enemy_level(index, level)

This call changes the level of the specified enemy. A positive number will increase its level, while a negative number will decrease its level. The change cannot go past the limits.

change_enemy_level(index, level)

Level Display

In the configuration, you can choose to display the enemy’s level in their name. If you choose to enable this feature, you can customize the display format. If you don’t want this feature you can turn it off by setting the Display_Level option to false.

Examples

A few simple examples to get you started.

Level based on game variable 5

v[5]

If enemy is the “leader” of the troop, then level 10, otherwise level 1

e.index == 0 ? 10 : 1

Random level between 1 and 10 (note that rand returns a number between 0 and n)

rand(10) + 1

Based on highest actor level

 
p.members.max {|actor| actor.level}.level

You may also like...

33 Responses

  1. Dims says:

    i like your script, but how to make a different stat for different level too?

  2. MDJ says:

    Hey Hime – i have a problem with a scriptcall set_enemy_level(index,level)
    i’m using abs patch so index will be taged as event id so set_enemy_level(@event_id,level) will work with the current event
    there is a not function to the note box says p.members.max {|actor| actor.level}.level – it works correctly but it won’t with a script call
    set_enemy_level(@event_id,p.members.max {|actor| actor.level}.level)
    Please Help me ^^

  3. watermark says:

    I like this plug-in much better than Yanfly’s enemy levels as it’s much easier to set the enemy stats based on actor curves instead of formulas.
    However is there an exp and gold growth addition to this (like Gold and Exp formula you had in VX Ace)? Right now I can’t seem to change enemy exp and gold drops, and that is very important.

  4. NovaK says:

    Hey, I sent a message through the contact form but haven’t received a response. No rush but was Just wondering on the commercial usage of this script?

  5. Applecrumble says:

    Hi!
    I’m trying to make a conditional branch in a troop event page that uses enemy level as
    a condition. For example, I want something like this:
    “if enemy.level > 10”
    but I’m not sure how to make it work.

  6. Anonymous says:

    Can skills reduce an enemy’s level and ensure they flee if the lowest actor level is 15 levels higher than them?

  7. Anonymous says:

    Will skills be able to reduce an enemy’s level in this script, because in one of my games, normal enemies flee battle when (party lowest level – enemy level) > 15.

    • Hime says:

      Yes, you can change enemy levels using script calls either in the skill’s formula or an effect on the skill. See the section on “Adjusting Levels”.

  8. Dugald says:

    Is there a way to have an enemy's experience and gold values vary based on their level? I imagine there would be some sort of formula you could set up for it.

  9. Kenji says:

    Can this be used in a damage formula?
    for example in the skills damage box:

    enemy’s level *10 = damage

  10. Marcos Luna says:

    Sorry to bother you Tsuki,it is possible to make a enemy level based in a current actor?
    Thanks you for this great script and greetings from Argentina.

  11. MikeB says:

    OK, I did update the script. I guess I had an older one.
    But I seem to still be getting the same error. I tried playing around with it a bit, but couldn’t anything to change.
    I just want to make sure…. this line does go inside the ‘script box’ that you can choose on the event editor screen, correct? I don’t need this directly inside the enemy or troop boxes?

  12. MikeB says:

    OK, kind of a nooby question here.
    I have both your enemy level and class installed. If I manually set the level inside the enemy’s note tag, I can get it to work. I tested it using a level 1 character and setting the enemy to 1 first then to 90 so I could the extreme differences.
    The problem now, is that I’m sure where/how to place the call to set the enemy’s level on the field.
    Let’s say I have a troop set up to have 2 of these enemies. Maybe for one encounter I want them to be level 2, but then later using the same troop I want them to be level 8.
    I’m not sure exactly what the proper format set up is to adjust that. I assume it goes as a script in the event box? Or is that wrong too?
    Thanks for any help.

    • Hime says:

      There was a typo in the script that I have fixed (set_level vs set_enemy_level), but basically you would make a script call in your event box like

      set_enemy_level(2, 15)
      

      This will set the second enemy’s level to 15, whichever the “second” enemy is. You would probably call this on turn 0 if you want to “initialize” their level at the beginning of the battle. Of course, you can make this script call anytime.

      • MikeB says:

        Hmm, ok tried it again.
        I’m getting the error that basically says, undefined method for ‘set_enemy_level’ in line 1411 of the Game Interpreter script.
        So I’m trying to figure out if I’m still not using it right.
        Right now in the event box I have the script for enemy level first, followed by the battle processing to call the specific troop.
        Is that right?

  13. RogueDeus says:

    Hime, I just wanted to mention that I think this latest string of tool based scripting is great, but the average user may fail to see how they all work together.

    For example: Core Levels, Enemy Class, Level Difference Exp, and Parameter Tables could be paired with Enemy Exp Formulas and Enemy Gold Formulas, and can thus completely replace catch all scripts like Yanfly’s Enemy Levels, which is very limited in comparison.

    • Hime says:

      Yes, I’ve been thinking of writing a tutorial at some point to show how you can customize enemies in your project. Of course, others are also free to write tutorials for any scripts I develop if they want to share some “dev tips and tricks” with others.

      Admittedly, I am not putting nearly enough effort into marketing the scripts.

  14. 9802 says:

    Would it be possible to get an example of how the multi-line tag is supposed to work?
    From my trial and error it only functions if there aren’t any line breaks in the formula.
    Also, correct me if I’m wrong, but doesn’t “p.members.max {|actor| actor.level}.level” get the last actor and use their level as opposed to the actor with the highest level?

    Thanks for all of your work.

    • Hime says:

      It was a bug. I forgot to tell the extended regex to read multiple lines. Should be fixed now.

      `p.members.max { … }` returns the member whose actor is the highest.

  15. desti says:

    i don’t get it

Leave a Reply

Your email address will not be published. Required fields are marked *