Level-based experience gain with YEP

Discussion in 'Javascript/Plugin Support' started by Alphaistimz, Jun 12, 2019.

  1. Alphaistimz

    Alphaistimz AlphaDio Production Veteran

    Messages:
    69
    Likes Received:
    4
    Location:
    Indonesia
    First Language:
    Indonesian
    Primarily Uses:
    RMMV
    Hi guys, currently I'm making a game with level-based exp gain. I use YEP enemy level & enemy base parameters.
    So, I'm looking for an effect where my actors will get exp based on enemy's vs each actor's levels.
    Original thread here: https://forums.rpgmakerweb.com/inde...ained-based-on-the-difference-in-level.96158/
    From that thread, I modify it into:

    Code:
    <Custom Base exp Formula>
    Var Base = 80
    if (level-6 >= $gameActors.actor(1).level)
        {exp = Base * 5;}
      else if (level-5 === $gameActors.actor(1).level)
          {exp = Base * 4.3;}
        else if (level-4 === $gameActors.actor(1).level)
            {exp = Base * 3.7;}
          else if (level-3 === $gameActors.actor(1).level)
              {exp = Base * 3.2;}
            else if (level-2 === $gameActors.actor(1).level)
                {exp = Base * 2.8;}
              else if (level-1 === $gameActors.actor(1).level)
                  {exp = Base * 2.4;}
                else if (level === $gameActors.actor(1).level)
                    {exp = Base * 2;}
                  else if (level+1 === $gameActors.actor(1).level)
                      {exp = Base * 1.8;}
                    else if (level+2 === $gameActors.actor(1).level)
                        {exp = Base * 1.6;}
                      else if (level+3 === $gameActors.actor(1).level)
                          {exp = Base * 1.4;}
                        else if (level+4 === $gameActors.actor(1).level)
                            {exp = Base * 1.2;}
                          else {exp = Base;}
    </Custom Base exp Formula>
    
    What I'm looking for (Example):
    Actor A is level 1 and actor B is level 3
    Enemy AA is level 1 and enemy BB is level 2
    EXP is divided among living actors
    in the end of battle, Actor A gets 80 / 2 * 2 = 80 from enemy AA and 80 / 2 * 2.4 = 96 from enemy BB
    Actor B gets 80 / 2 * 1.6 = 64 from enemy AA and 80 / 2 * 1.8 = 72 from enemy BB
    and yes the EXP are count separately for each actors...

    *I've tested it and only the var 'base' works... I feel that something like "this.whatever" line should be used somewhere... I'm not so good with JS tho...
    Thanks in advance!
     
    #1
  2. ShadowDragon

    ShadowDragon Veteran Veteran

    Messages:
    375
    Likes Received:
    112
    Location:
    Netherlands
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    you miss either a change level "$gameActors.actor(y).changeLevel(x, false);"
    or you miss something as return as the last "else" which can be also return exp base or something similair.

    Else i have no clue though.
     
    #2
  3. caethyril

    caethyril ^_^ Veteran

    Messages:
    921
    Likes Received:
    577
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Plugin link for reference: http://yanfly.moe/2017/05/31/yep-139-enemy-base-parameters-rpg-maker-mv/

    JavaScript is case-sensitive: Var is not a valid keyword, use var instead. :kaothx:

    Edit: possible alternative in case you're interested~
    Code:
    <Custom Base exp Formula>
    var lvlDiff = (6 + $gameActors.actor(1).level - level).clamp(0, 11);
    var mult = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][lvlDiff];
    value = 80 * mult;
    </Custom Base exp Formula>
    If this looks confusing then I'd recommend sticking with what you've got. :kaoswt:

    [Edit: corrected difference calculation to match array order.]
     
    Last edited: Jun 13, 2019
    #3
    Magnus0808 likes this.
  4. Magnus0808

    Magnus0808 Software Developer Veteran

    Messages:
    104
    Likes Received:
    100
    First Language:
    Danish
    Primarily Uses:
    RMMV
    Furthermore, the way exp after a battle actually works: It sums up the exp gained from each enemy which it then gives to each member in the party. (The "Knockout" state changes the exp rate to 0 on default which is why knocked out members normally does not get exp).
    This means that actors do not get exp individually which makes it impossible for actors to get individual exp from enemies with the current system. Which means that both Actor A and Actor B will get the same base exp no matter what you write in <Custom Base exp Formula>.
    You would have to change the current system in order to make it possbile for actors to get an individual custom base exp. (This would require a new plugin)

    What you do now is change the base exp according to what the level of actor 1 is. Then every party member gains that amount of exp. It should be noted that $gameActors.actor(1) is the game object for the Actor with id 1 which is "Harold" on a default setting. So currently you set the exp according to an actor that might not even be in the battle.

    YEP Enemy Levels have some functions you can use instead:
    Code:
    $gameParty.lowestLevelAllMembers()
    – This will return the lowest level of all party members.
    
    $gameParty.lowestLevelBattleMembers()
    – This will return the lowest level of all battle members.
    
    $gameParty.averageLevelAllMembers()
    – This will return the average level of all party members.
    
    $gameParty.averageLevelBattleMembers()
    – This will return the average level of all battle members.
    
    $gameParty.highestLevelAllMembers()
    – This will return the highest level of all party members.
    
    $gameParty.highestLevelBattleMembers()
    – This will return the highest level of all battle members.
    Personally, I would recommend $gameParty.highestLevelBattleMembers() instead of $gameActors.actor(1). So the exp would be set according to the highest leveled battle member.
     
    #4
    caethyril likes this.
  5. ShadowDragon

    ShadowDragon Veteran Veteran

    Messages:
    375
    Likes Received:
    112
    Location:
    Netherlands
    First Language:
    Dutch
    Primarily Uses:
    RMMV
    i missed the captical V in var, which i should have known, but the exp you use is something i dont understand, but it
    work like the same as the else if's. Way to go @caethyril =)
     
    #5
  6. Alphaistimz

    Alphaistimz AlphaDio Production Veteran

    Messages:
    69
    Likes Received:
    4
    Location:
    Indonesia
    First Language:
    Indonesian
    Primarily Uses:
    RMMV
    I think I may drop this all together guys, since it's currently impossible to do. Thanks for helping me out.
     
    #6
  7. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Alphaistimz You could set an incrementing loop i = 1 to (# of party members present...I forget the script code for this, but it's out there) and feed the proper level for $gameActors.actor(i).level for each actor into an array. You can then set a pair of nested incrementing loops: outside i = 1 to # of party members, inside j = 1 to (# of enemies in troop...again...script code is out there) and feed the proper differences of level between actor(i) and enemy(j) into a two dimensional array variable, say Difference(i, j). Now that you have the proper differences, you can set up another pair of nested incrementing loops the same way (using i and j again). Here you read in each Difference (i, j), then find the proper multiplier for said difference, and feed it into another two-dimensional array variable, say Multiplier(i, j). Now, yet another set of nested incrementing loops set the same way can then be used to compute:
    Exp(i, j) = Base * Multiplier(i, j) / (# of enemies in troop)
    Finally, one last set of nested increment loops set the same way can be used to give each Exp(i, j) amount to $gameActors.actor(i)
    Don't give up. :smile:
     
    #7
  8. Alphaistimz

    Alphaistimz AlphaDio Production Veteran

    Messages:
    69
    Likes Received:
    4
    Location:
    Indonesia
    First Language:
    Indonesian
    Primarily Uses:
    RMMV
    No worries, guys... I drop it since I've found an easier solution for this. I use the math equation: level * ((50 + level * 50) / 2) so that the actor needs 50 more exp to level up next time and the enemies' exp are enemy level * 40, so with full 8 actors in my party, each of them get 5 exp / enemy level, regardless of their own level. I think it's pretty good workaround.
    And thanks you everybody for trying to help me (thanks for encouraging me @mathmaster74 since your username remind me of a math equation to sum array back in school) :kaoluv:
     
    #8
    mathmaster74 likes this.
  9. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Alphaistimz I understand if you've gone another route, but I could not give up on this. :smile: It still does not work, but I think I am close to . . . something. I got it down to only 1 nested loop, and was therefore able to eliminate any need for two-dimensional array references. :biggrin: @caethyril I hope you do not mind if I tried to make good use of your code example by still applying the clamp and case handler. I have tested it out on Battle Event pages with condition Enemy HP (X) <= 0% where X is the EnemyID. The way I have it set up, it is not a <Custom Base exp Formula>, but rather a script that, when working properly, runs a whole party experience award routine as each enemy dies. It does not return any errors, but does not actually award any experience either. I believe that is because in the last line of the loop I am trying to make a global variable update a value it references...which it cannot do. If someone can help me out with the proper way to add ExPts to each party member's Exp by way of their party member ID reference, we can use that as the last line of this loop's code instead, and then this thing should be golden.

    This is what I used for Enemy #1. Base didn't need to be a variable here, so I just used 80. Technically, since this would be placed by Battle Event page to reference a single enemy, you will always know its level, so the Difference formula can be simplified, too.

    ◆Script:for (var i = 1; i <= $gameParty.members().length; i++) {
    : : var Difference = ($gameParty.members(i).level - $gameTroop.members(1).level + 6).clamp(0, 11);
    : : var Multiplier = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][Difference];
    : : var ExPts = 80 * Multiplier / $gameParty.members().length;
    : : $gameParty.members(i).exp += ExPts;
    : :};

    EDIT: Okay. I'm even closer now. The last line is correct (up to order of actors in party), but has a problem with returning 'NaN' for all awarded exp. I know NaN stands for Not a Number from reading other posts, and get that var ExPts is, therefore, not a number value. I think the global variable feeding ExPts is probably the wrong type, which is feeding the error. I tried setting a variable equal to $gameParty.members().length in hopes that might circumvent the issue, but...nah. No does work. Here's what I have now:

    ◆Script:for (var i = 1; i <= $gameParty.members().length; i++) {
    : : var Difference = ($gameParty.members(i).level - $gameTroop.members(1).level + 6).clamp(0, 11);
    : : var Multiplier = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][Difference];
    : : var ExPts = 80 * Multiplier / $gameParty.members().length;
    : : $gameActors.actor(i).gainExp(ExPts);
    : :};

    I know I'm super close. Who's got the know-how to put this thing to rest? Please weigh in. Note: Also, if you've got the way to translate $gameActors.actor(1) to $gameParty.member(i) where i is the position of actor 1 in the party and can work that for all party members, that would put the nail all the way into this puzzle's grave.
     
    Last edited: Jun 13, 2019
    #9
    caethyril likes this.
  10. Alphaistimz

    Alphaistimz AlphaDio Production Veteran

    Messages:
    69
    Likes Received:
    4
    Location:
    Indonesia
    First Language:
    Indonesian
    Primarily Uses:
    RMMV
    Well, yeah, even though I've got my backup plan, I'm still curious about this. Logically, making the event after each enemy's death should make it work. So... you'll make a plugin out of it? Making it a YEP extension will be handy for a lot of people and probably you should post it in the corresponding thread:kaopride:
     
    #10
  11. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Alphaistimz I'm good...but I'm not that good. Never done a plugin yet. This is all working a short script code in the editor. If someone else with the chops to make this a full-fledged plugin comes along and wants to do it, though, they're welcome to. Once we get the last pieces and it makes sense to, that is... :smile:

    EDIT: Okay. To clear up the Party/Actor thing, here's what I have now:

    ◆Script:for (var i = 1; i <= $gameParty.members().length; i++) {
    : : var Difference = ($gameActors.actor(i).level - $gameTroop.members()[1].level + 6).clamp(0, 11);
    : : var Multiplier = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][Difference];
    : : var ExPts = 80 * Multiplier / parseInt($gameParty.members().length);
    : : $gameActors.actor(i).gainExp(ExPts);
    : :};

    The only problem is...still getting NaN for everybody's Exp after the battle.

    EDIT: Actually...this assumes all actors are in the party...but gets their Exp right even if shuffled around in the formation. Another interesting thought would be setting the loop for all actors. That way even your reserve actors get exp out of battle...once this works.

    EDIT 2: Tried this. Also getting NaN...

    ◆Script:for (var i = 1; i <= $gameParty.members().length; i++) {
    : : var Difference = ($gameActors.actor(i).level - $gameTroop.members()[1].level + 6).clamp(0, 11);
    : : var Multiplier = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][Difference];
    : : var ExPts = Math.floor(80 * Multiplier / $gameParty.members().length);
    : : $gameActors.actor(i).gainExp(ExPts);
    : :};

    I was hopeful that if clamp guarantees Difference comes out a number, and if the values in the case handler are all numerical entries to guarantee that Multiplier comes out a number, maybe some sort of Math "encapsulation" would force ExPts to come out a number and give the desired result. Still no luck, but the answer has got to be right here...

    EDIT 3: I decided to start simplifying the right-hand side of the equations to see if I could pinpoint the culprit and as soon as I set Difference = 3 the NaN error went away and characters were receiving exp! I went back to try to figure out why it was giving NaN before and best I could figure was, the value of the variable was using 2 globals to compute it...so since, as I mentioned earlier, you can replace
    $gameTroop.members()[x].level with the known enemy level value, I plugged that in...and it worked! (to a point...) The actors do receive more at lower levels and less as the levels move up...but not the right amounts. Here's a "working" formula:

    ◆Script:for (var i = 1; i <= $gameParty.members().length; i++) {
    : : var Difference = ($gameActors.actor(i).level + 5).clamp(0, 11);
    : : var Multiplier = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][Difference];
    : : var ExPts = Math.floor(80 * Multiplier / $gameParty.members().length);
    : : $gameActors.actor(i).gainExp(ExPts);
    : :};

    This is for a level 1 enemy, so actor level - 1 + 6 = actor level + 5.
    The only problem now is, the last enemy vanquished gives no experience because the battle ends when they reach 0% HP, so the Battle Event page for that last enemy never runs and the experience awarded ends up short by 1 enemy. There must be a workaround for this, but offhand, I can't think of it.
     
    Last edited: Jun 13, 2019
    #11
  12. Magnus0808

    Magnus0808 Software Developer Veteran

    Messages:
    104
    Likes Received:
    100
    First Language:
    Danish
    Primarily Uses:
    RMMV
    Honestly, I do not like this solutions. Instead of changing the system to work with it you go around it. The mistake you have is probably using $gameTroop.members()[1]. This is the second enemy in the troop, not the first. So it would return an error if there is only a single enemy.
    That said you should probably also change $gameParty.members() to $gameParty.battleMembers() and Math.floor(80 * Multiplier / $gameParty.members().length); to Math.floor(80 * Multiplier / $gameParty.aliveMembers().length);

    That with a few other changes gives you this:
    Code:
    for (var i = 0; i < $gameParty.battleMembers().length; i++) {
    var Difference = ($gameParty.battleMembers()[i].level - $gameTroop.members()[0].level + 6).clamp(0, 11);
    var Multiplier = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][Difference];
    var ExPts = Math.floor(80 * Multiplier / $gameParty.aliveMembers().length);
    $gameParty.battleMembers()[i].gainExp(ExPts);
    };
    But as I said I am not a fan of this solution as it does NOT work with other stuff that relies on the system such as YEP Victory Aftermath
     
    Last edited: Jun 13, 2019
    #12
    caethyril likes this.
  13. caethyril

    caethyril ^_^ Veteran

    Messages:
    921
    Likes Received:
    577
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    As @Magnus0808 says! Also, note you're iterating through party indices, but referencing the database actors (not necessarily correspondent). And you'll need to ensure enemies have a level property (e.g. Yanfly's Enemy Levels plugin) otherwise level will be undefined and turn out as not-a-number. Couple of other points, but best to illustrate with an example:
    Code:
    for (var n = 0; n < $gameParty.aliveMembers().length; n++) {
      var actor = $gameParty.aliveMembers()[n];
      var enemy = $gameTroop.members()[0];  // troop leader
      var diffL = (6 + actor.level - enemy.level).clamp(0, 11);
      var multL = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][diffL];
      var exPts = Math.round(80 * multL / $gameParty.aliveMembers().length);
      actor.gainExp(exPts);
    };
    Or, equivalently:
    Code:
    $gameParty.aliveMembers().forEach(function(actor) {
      var enemy = $gameTroop.members()[0];  // troop leader
      var diffL = (6 + actor.level - enemy.level).clamp(0, 11);
      var multL = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][diffL];
      var exPts = Math.round(80 * multL / $gameParty.aliveMembers().length);
      actor.gainExp(exPts);
    });
    [Edit: corrected difference calculation to match the array order.]

    Like Magnus says, though, it would be better to integrate it properly with the existing system. :kaoswt:
    Actually, clamp just keeps the result between the stated bounds~
    Code:
    Number.prototype.clamp = function(min, max) {
        return Math.min(Math.max(this, min), max);
    };
     
    Last edited: Jun 13, 2019
    #13
  14. Alphaistimz

    Alphaistimz AlphaDio Production Veteran

    Messages:
    69
    Likes Received:
    4
    Location:
    Indonesia
    First Language:
    Indonesian
    Primarily Uses:
    RMMV
    Well, my game relies on evented battle, so the party is fully healed at the end of every battle and it isn't a dungeon crawler with the escape command always disabled. Yes, I do use YEP Victory Aftermath. I think I may give it a shot though... where should I put it?
     
    #14
  15. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    184
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Alphaistimz It won't award Exp for the last enemy defeated in battle. No exp if there's only one enemy. You place the script on pages you create in your battle events under the troops tab. Each enemy in the troop gets a page. On that page, you set the condition to Enemy #X HP < 0% and the script will run if the page runs. Within the script, you have to substitute the enemy level for the enemy you are creating the page for. You have to decide what that level will be. Otherwise, as long as your actors are your party members, something like what I had last, fused with the new suggestions:

    ◆Script:for (var i = 1; i <= $gameParty.aliveMembers().length; i++) {
    : : var Difference = ($gameActors.actor(i).level + #).clamp(0, 11);
    : : var Multiplier = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][Difference];
    : : var ExPts = 80 * Multiplier / $gameParty.aliveMembers().length;
    : : $gameActors.actor(i).gainExp(ExPts);
    : :};

    should work. Note: # should be the result of (6 - the level of the enemy for this battle event page). The exp isn't done as an aftermath, but the good news is, it's actually done in battle as enemies die, so you get level up notifications as the battle is going at the end of each turn. I don't know how this works if actors die, which is why I'm prone to agree with the aliveMembers() suggestion. That and @caethyril knows their stuff. :wink:
    I have only tested where the actors and party are one and the same. Mixing up their order in formation should be fine as long as the total # in party = total # in actors, but new actors may pose problems if you don't modify for that as it is possible to have more actors than party members and this code doesn't account for that. If everything @Magnus0808 and caethyril said, along with what I'm telling you here, is okay with you, then I'd say set up one battle and test it. If that works well for you, then test a few more. The good news is, if there was only 1 enemy, while this system doesn't award exp for the lone enemy, you know that...and you know what the lone enemy should be worth, so you could run a similar routine right after the battle processing plugging in for that lone enemy's level. Again, that's not ideal for the Victory Aftermath, but it's something. :rolleyes: I wish you the best. :smile:
     
    #15
  16. caethyril

    caethyril ^_^ Veteran

    Messages:
    921
    Likes Received:
    577
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Just realised mathmaster & Magnus are right, I had it the wrong way around: it should be actor.level - enemy.level. :kaoback: Will edit my previous post with the correction. :kaoswt:

    Anyway, how about doing this via the Experience Rate parameter instead? Yanfly's Special Param Formula plugin lets you set a formula for EXR, could try something like this:
    Code:
    (base + plus) * rate * ($gameParty.inBattle() ? [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][(6 + user.level - $gameTroop.members()[0].level).clamp(0, 11)] : 1) + flat
    In battle, this should multiply each actor's EXR by the multiplier corresponding to the difference in level between them and the troop leader. Pretty sure that'll work nicely with the existing system, Aftermath, etc. :kaothx:

    (If you want something to calculate the level-difference thing separately for each enemy then that'll need a custom plugin, and I couldn't find one with a quick search.)
     
    #16
    mathmaster74 likes this.
  17. Magnus0808

    Magnus0808 Software Developer Veteran

    Messages:
    104
    Likes Received:
    100
    First Language:
    Danish
    Primarily Uses:
    RMMV
    Okay I made this... I am not too happy about it. I feel it is a bit chunky, however it should work. It is a plugin that changes the system to calculate the exp individually for each actor by passing the actor to the enemy's exp calculation. I also added so you can use either "actor" or "a" to indicate an actor in the custom exp formula so you can write something like:

    Code:
    <Custom Parameter exp Formula>
        value = 10 * a.level;
    </Custom Parameter exp Formula>
    
    It should be placed after YEP_EnemyLevels and if you have YEP_PartySystem then after that one as well (in order to make the exp distribution work).

    If you encounter any problems feel free to message me :)

    Code:
    //=============================================================================
    // YEP EnemyLevels Individual Exp Extension
    // MRP_YEP_EnemyLevels_IndividualExpExtenstion.js
    // By Magnus0808 || Magnus Rubin Peterson
    //=============================================================================
    
    /*:
     * @plugindesc YEP_EnemyLevels_IndividualExpExtenstion
     * @author Magnus0808
     *
     * @help This plugin changes the way exp is calculated for actors. Now it will
     * be calculated individually for each actor by passing the actor to the enemy's
     * exp calculation.
     *
     * Requires YEP_EnemyLevels in order to set a custom exp formular.
     *      Use either 'actor' or 'a' to reference the actor gaining exp in the
     *      exp formular.
     *      e.g. <Custom Parameter exp Formula>
                    value = 10 * a.level;
                 </Custom Parameter exp Formula>
     *
     * This plugin should be placed immediately after YEP_EnemyLevels. If you also
     * use YEP_PartySystem then this should also be placed immediately after that
     * one if possible.
     *
     * @param Default Actor Id
     * @desc If the exp function is called on an enemy in a way that didn't specify
     * the actorId then this is used.
     * @default 1
     *
     */
    
     var Imported = Imported || {};
     Imported.MRP_YEP_EnemyLevels_IndividualExpExtenstion = true;
     
     var MRP = MRP || {};
     MRP.YEP_EnemyLevels_IndividualExpExtenstion = MRP.YEP_EnemyLevels_IndividualExpExtenstion || {};
     
    (function() {
        
        MRP.YEP_EnemyLevels_IndividualExpExtenstion.Parameters = PluginManager.parameters('MRP_YEP_EnemyLevels_IndividualExpExtenstion');;
        MRP.YEP_EnemyLevels_IndividualExpExtenstion.defaultActorId = eval(String(MRP.YEP_EnemyLevels_IndividualExpExtenstion.Parameters['Default Actor Id']));
        
        MRP.YEP_EnemyLevels_IndividualExpExtenstion.BattleManager_makeRewards = BattleManager.makeRewards;
        BattleManager.makeRewards = function() {
            MRP.YEP_EnemyLevels_IndividualExpExtenstion.BattleManager_makeRewards.call(this);
            this._rewards.exp = $gameParty.allMembers().map(function(a) {
                return $gameTroop.expForActor(a._actorId);
            });
        };
        
        Game_Troop.prototype.expForActor = function(actorId) {
            return this.deadMembers().reduce(function(r, enemy) {
                return r + enemy.exp(actorId);
            }, 0);
        }
        
        MRP.YEP_EnemyLevels_IndividualExpExtenstion.Game_Enemy_exp = Game_Enemy.prototype.exp;
        if(Imported.YEP_EnemyLevels) {
            Game_Enemy.prototype.exp = function(actorId) {
                var paramId = 8;
                this.enemy().baseParamFormula[paramId] = this.enemy().baseParamFormula[paramId].split(" ").map(function(item) {
                    return item.replace(/^((\(*)(actor|a|\$gameActors.actor\(\d)(\)|\b))/g, "$2$gameActors.actor(" + (actorId ? actorId : MRP.YEP_EnemyLevels_IndividualExpExtenstion.defaultActorId) + ")");
                }).join(" ");
                var exp = MRP.YEP_EnemyLevels_IndividualExpExtenstion.Game_Enemy_exp.call(this);
                this._cacheBaseParam[paramId] = null;
                return exp;
            }
        } else {
            Game_Enemy.prototype.exp = function(actorId) {
                MRP.YEP_EnemyLevels_IndividualExpExtenstion.Game_Enemy_exp.call(this);
            }
        }
        
        Game_Troop.prototype.expTotal = function() {
            return this.deadMembers().reduce(function(r, enemy) {
                return r + enemy.exp(null);
            }, 0);
        };
        
        BattleManager.displayExp = function() {
            var exp = this._rewards.exp.reduce(function(r, xp) {
                return r + xp;
            });
            if (exp > 0) {
                var text = TextManager.obtainExp.format(exp, TextManager.exp);
                $gameMessage.add('\\.' + text);
            }
        };
        
        MRP.YEP_EnemyLevels_IndividualExpExtenstion.BattleManager_gainExp = BattleManager.gainExp;
        BattleManager.gainExp = function() {
            if(Imported.YEP_PartySystem && Yanfly.Param.ParamExpDis) {
                var alive = $gameParty.aliveMembers().length;
                this._rewards.exp = this._rewards.exp.map(function(e){
                    e = Math.ceil(e / alive);
                    return e;
                });
            }
            var exp = this._rewards.exp;
            for(var i = 0; i < $gameParty.allMembers().length; i++) {
                var actor = $gameParty.allMembers()[i];
                var aExp = exp[i];
                actor.gainExp(aExp);
            }
        };
        
    })();
     

    Attached Files:

    Last edited: Jun 14, 2019
    #17
    mathmaster74 and caethyril like this.
  18. Alphaistimz

    Alphaistimz AlphaDio Production Veteran

    Messages:
    69
    Likes Received:
    4
    Location:
    Indonesia
    First Language:
    Indonesian
    Primarily Uses:
    RMMV
    Wow, I'm amazed on how quick you make a plugin, but I'm a bit off on how to input the conditions I have in the note tags, and is it enemy note tags?
     
    #18
  19. Magnus0808

    Magnus0808 Software Developer Veteran

    Messages:
    104
    Likes Received:
    100
    First Language:
    Danish
    Primarily Uses:
    RMMV
    It is a an extension to YEP EnemyLevels so just use it like at the beginning of this thread:
    Code:
    <Custom Parameter exp Formula>
    var lvlDiff = (a.level - level + 6).clamp(0, 11);
    var mult = [5, 4.3, 3.7, 3.2, 2.8, 2.4, 2, 1.8, 1.6, 1.4, 1.2, 1][lvlDiff];
    value = 80 * mult;
    </Custom Parameter exp Formula>
    Just place that in the enemy note tags :)
     
    #19
  20. Alphaistimz

    Alphaistimz AlphaDio Production Veteran

    Messages:
    69
    Likes Received:
    4
    Location:
    Indonesia
    First Language:
    Indonesian
    Primarily Uses:
    RMMV
    So... it has error... if I have Victory Aftermath ON, I get Pic 1, but if it is OFF, I get Pic 2.
     

    Attached Files:

    #20

Share This Page