RMMV How to set an actor or party member to a specific level

OpenTangent

Villager
Member
Joined
Mar 15, 2020
Messages
13
Reaction score
3
First Language
English
Primarily Uses
RMMV
I'm using DreamX's [Capture Enemies] plugin and I would like to make it that if the player has already captured a specific creature and then captures that type of creature again I'd like to give the player the impression that the previous creature is replaced by the newly captured one. For my needs all that's really important is to change the creature's actor level. I have the new creature's level and I have the corresponding actor object.
JavaScript:
DreamX.CaptureEnemy.levelUpDuplicateActors = function (actorId, target) {
        for (var i = 0; i < $gameParty.allMembers().length; i++) {
            var actor = $gameParty.allMembers()[i];
            if (actor.actorId() === actorId || actor.baseActorId() === actorId) {
                //var newExp = actor.currentExp() + actor.nextRequiredExp();
                //actor.changeExp(newExp, paramDefaultLevelUpMsg);
                actor._level = target.level; // OpenTangent attempt 1
                actor.change_level(target.level, false); // OpenTangent attempt 2
            }
        }
    };
DreamX's code simply increments the level of the existing captured creature by 1 regardless of the target creatures stats so I've commented out that code. I made two attempts at explicitly setting the actor's level. Attempt 1 seems to work but then the game almost immediately sets the level back to what is was before. Attempt 2 throws an exception saying "change_level is not a function". Would I need to calculate experience and use actor.changeExp()? If so how would I do that? Any help is greatly appreciated.
 

OpenTangent

Villager
Member
Joined
Mar 15, 2020
Messages
13
Reaction score
3
First Language
English
Primarily Uses
RMMV
I can't thank you enough @SeaPhoenix that worked perfectly. And thanks for the link to the Script Call List, that's going to make my life a lot easier.

Here's the final levelUpDuplicateActors function code. If the level of the enemy is higher than the existing capture's level then it changes it to that level, otherwise it just increases by 1.
JavaScript:
DreamX.CaptureEnemy.levelUpDuplicateActors = function (actorId, target) {
        console.log(target);
        for (var i = 0; i < $gameParty.allMembers().length; i++) {
            var actor = $gameParty.allMembers()[i];
            if (actor.actorId() === actorId || actor.baseActorId() === actorId) {
                if (actor._level < target.level) {
                    actor.changeLevel(target.level, false);
                } else {
                    var newExp = actor.currentExp() + actor.nextRequiredExp();
                    actor.changeExp(newExp, paramDefaultLevelUpMsg);
                }
            }
        }
    };
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Dama wrote on akoniti's profile.
Hi
Thanks for your review.
I was checking the trailer for details and as the woman shut the door at the exact moment the song I was hearing said "you slim the door" and I couldn't resist to add it there. :D And I used this idea one more time on another scene.
Just doing some tileset tinkering again...
rux
Someone please help me make my game.
I need someone to volunteer, I am on my knees man.
I made my own pizza. First critique, more chicken next time.

Forum statistics

Threads
104,690
Messages
1,008,146
Members
136,182
Latest member
kingmart420
Top