Cutting off experience?

So I want to limit the amount of experience the player can gain in any given area. For example, my first quest is a basic collection quest where the player also runs into several battles (enough to get from 0xp to almost level 4, so about 400xp) but I don't want the player to be able to grind up past about level 4. Is there a way to, after a certain amount of experience is gained, to cut off experience gain from battles? Or to drop the value to 1xp per enemy? Thanks!
Module BattleManager has a method gain_exp (def self.gain_exp).

Put code into that method that checks the area and/or region ID (drop the leading zeros)

and returns the max you've set if the exp would put the players over that.
That sounds way more complicated than what I'm capable of. But thanks!
Neverwinter Nights 1 used a similar deminshing returns system. Their might be a simple scripting option you can setup or request that has a blanket effect for your entire game.

This is my basic example.

(CL - ML) X (ML X 25 X M😎 = BR, (XPG - BR X BM) = FR

So if a character defeated a monster of the same level they would get 100xp. However if that character became level 2. They would only get 75xp.

To the flip side if a level 1 character defeated a level 2 monster they would get 150xp.

If the character was 5 levels or higher then the monster they would get NO xp. Note: This formula does not have the if statement to XP loss or excessive gain.

The number 25 highlighted in red above was the value I chose to allow this to cover a basic 4 level range. More then 4 levels higher no xp is gained. However if a player or party defeats a higher level monster the xp could be excessive.

For example if the character was level 1 and defeated a level 10 monster they would gain 2350xp. You could set the cap at a max of 500xp for example to help curb farming of easy high level monsters.

I did this using excel and about 10 minutes of my time. You would still need someone to script this out in Ruby.

Legend:

CL: Character Level

ML: Monster Level

BR: Base Results

XPG: Experienced Points Gained

BM: Base Modifier

FR: Final Results

Original thread: https://forums.rpgmakerweb.com/threads/cutting-off-experience.25119/