RMMZ Battle ends way too fast when using an alias.

Status
Not open for further replies.

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
219
Reaction score
327
First Language
----
Primarily Uses
N/A
Here is the original method:


JavaScript:
BattleManager.checkBattleEnd = function() {
    if (this._phase) {
        if (this.checkAbort()) {
            return true;
        } else if ($gameParty.isAllDead()) {
            this.processDefeat();
            return true;
        } else if ($gameTroop.isAllDead()) {
            this.processVictory();
            return true;
        }
    }
    return false;
};
When this runs and the result is of everyone being dead, you'll see a message that the party was defeated, yadda yadda, and then the screen fades and the game is closed(in the case of battle testing).

However when it's aliased, the process is sped up and you don't even see the defeat message before the game is closed. It doesn't matter if nothing else is added in the function body and just allow the game to run the original code:
JavaScript:
(function(alias) {
    BattleManager.checkBattleEnd = function() {
        alias.apply(this);
        
    };
})(BattleManager.checkBattleEnd);

I want to know how to have it end the battle at its original pace(if that makes sense) and yes I need to change the behavior of that method, preferably not having to rewrite the method.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,485
Reaction score
3,514
First Language
EN
Primarily Uses
RMMZ
That method should return a value, so remember to include a return statement:
JavaScript:
(function(alias) {
    BattleManager.checkBattleEnd = function() {
        return alias.apply(this);
    };
})(BattleManager.checkBattleEnd);
 

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
219
Reaction score
327
First Language
----
Primarily Uses
N/A
I'm dumb.... thanks again.
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,485
Reaction score
3,514
First Language
EN
Primarily Uses
RMMZ
It's an easy mistake to make, no worries! :kaohi:

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.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Since cats love to walk across keyboards...what would an entire RPG where all the text was written by a cat walking across the keyboard look like? Prepare for the adventures of the hero aaaaaaaaasddfghyuyhju878uiop;'[p0ol,m
Had an idea for a new way to calculate damage and work it in a battle system but I had to restrain myself because it would be such a pain in the ass to balance and I just want something DONE not something COMPLEX
shes so skrunkly
62653655_cacf8KHvo9yU5dr.png
Godot's coding language somehow makes my head spin more than Unity's. (No, I'm not switching to Godot, I've just been seeing a few games in that engine.)
And now a new loading screen because the other one was too "old" :kaoswt:
1679419775847.png

Forum statistics

Threads
129,732
Messages
1,204,716
Members
170,817
Latest member
tamal1
Top