New Actor Level = Party Average Level

● ARCHIVED · READ-ONLY
Started by Yawgmoth 5 posts View original ↗
  1. Hi all,

    I would like to know how to event a new actor's level to be equal to the average level of the party. Reserve members not included. I'm assuming I need to use variables which I have just started diving into so I don't have much experience with them. I'm sure this can be done lots of different ways but I would prefer to learn the proper way to event this so next time I would hopefully not have to ask for help. I would rather not copy and paste someone's script.

    Thanks in advance for any and all help.
  2. You can calculate the average party level, store the value in a variable, and then set the level of the new actor to the value of that variable. For example, if I use variable #5:

    Code:
    var totalLevel = 0;
    for (var i = 0 ; i < $gameParty.members().length; i++) {
       var ac = $gameParty.members()[i];
       totalLevel += ac.level;
    }
    var averageLevel = Math.round(totalLevel / $gameParty.members().length);
    $gameVariables.setValue(5, averageLevel);

    1) Insert that code as a script BEFORE adding the new actor to the party.
    2) Add the new actor to the party.
    3) Set the new actor's level to the value of variable 5. If you want to change the variable ID, change the number 5 to the desired variable ID in the last line of the code.

    Note that I did not test the code and I hope that it's bug free lol.
  3. @Yawgmoth 's Bargain was to get an answer on eventing this.

    "I would like to know how to event a new actor's level..."


    So here I go:


    How to fetch the level data to a variable?
    Solution:
    Game Progression > Control Variables > Game Data > Actior > HeroNameHERE > Level

    So you can set a variable with A specific actor's level.
    Thus you can use a variable for each actor to fetch the data.

    The problem is, who of the actors is in your party and who is not.
    Solution:

    Create a variable named LVLSUM
    Set it to 0
    Create a Condiotional Branch
    Second Tab gives you the option to choose if a specific actor is in the party.
    IF he is, then add to LVLSUM the fetched data for that hero.

    Create also a variable for the Sum of actors.
    Set it to 0
    For each actor in the respective conditional branch, if he /she is in the party, add +1


    So SUM of LVL/ SUM of actors = the average level.
    and you set the new level.

    Just remember to always initialize to 0 all the involved variables.

    You're welcome.
  4. Thank you both so much! Now I have an example of two ways to go about doing this. I did get this to work too so thank you both for your time. and Happy RPG Making to you both!
  5. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.