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: 1, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top