Understanding Battle Animations and Interrupting Them After Execution

ktri9

Warper
Member
Joined
Mar 1, 2019
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
I want to check to see if a specific skill is used in battle and after the first part of the attack animation plays (for a magic spell when the magic circle forms under the actor), transfer the game to a custom scene in which I plan to have a mini game of some sort and when that mini game is completed, return to the map and execute a cut scene. I have been looking through the code for a few hours and I am a unsure what function to overwrite to catch the game right after the actor does the first part of the animation but before the next part executes. I have been looking through BattleManager specifically at these functions:
Code:
BattleManager.startAction = function() {
    var subject = this._subject;
    var action = subject.currentAction();
    var targets = action.makeTargets();
    this._phase = 'action';
    this._action = action;
    this._targets = targets;
    subject.useItem(action.item());
    this._action.applyGlobal();
    this.refreshStatus();
    this._logWindow.startAction(subject, action, targets);
};

BattleManager.updateAction = function() {
    var target = this._targets.shift();
    if (target) {
        this.invokeAction(this._subject, target);
    } else {
        this.endAction();
    }
};

BattleManager.endAction = function() {
    this._logWindow.endAction(this._subject);
    this._phase = 'turn';
};

BattleManager.invokeAction = function(subject, target) {
    this._logWindow.push('pushBaseLine');
    if (Math.random() < this._action.itemCnt(target)) {
        this.invokeCounterAttack(subject, target);
    } else if (Math.random() < this._action.itemMrf(target)) {
        this.invokeMagicReflection(subject, target);
    } else {
        this.invokeNormalAction(subject, target);
    }
    subject.setLastTarget(target);
    this._logWindow.push('popBaseLine');
    this.refreshStatus();
};

BattleManager.invokeNormalAction = function(subject, target) {
    var realTarget = this.applySubstitute(target);
    this._action.apply(realTarget);
    this._logWindow.displayActionResults(subject, realTarget);
};
and it just looks like a lot of math calculations for determining if an attack is countered or not. I was hoping the invokeAction functions would call the animation functions in Spriteset_Battle but I dont see anything in the battle manager pertaining to animation (Though I'm not seeing a lot of update functions in the Spriteset_Battle class either). So my question is where is the code that executes the first part of the magic animation so after that completes, I can redirect the game to my custom scene before any more actors or enemies do anything else?
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Unfortunately (and much to the annoyance of a lot of devs), a lot of battle logic happens on the Window_BattleLog. Instead of only using the BattleLog as a combat log, it also controls many animations. Take a look at Window_BattleLog.prototype.startAction:

Code:
Window_BattleLog.prototype.startAction = function(subject, action, targets) {
    var item = action.item();
    this.push('performActionStart', subject, action);
    this.push('waitForMovement');
    this.push('performAction', subject, action);
    this.push('showAnimation', subject, targets.clone(), item.animationId);
    this.displayAction(subject, item);
};
Additionally, they've also decided to have a function named "push" that is not the normal JavaScript "push" function, so that can be a little confusing, too. Window_BattleLog has a stack of functions it stores in its _methods property. It adds to that stack via its push method, then, unless it's waiting (checked via the updateWait method), it calls the next function.

You'll see in the BattleManager.startAction function that the last bit of logic calls _logWindow.startAction, which is the BattleLog's startAction method. performActionStart and performAction are methods that animate the battler Sprite, while showAnimation is probably what you're looking for. Specifically, I'd probably start investigating in this block:

Code:
Window_BattleLog.prototype.showAnimation = function(subject, targets, animationId) {
    if (animationId < 0) {
        this.showAttackAnimation(subject, targets);
    } else {
        this.showNormalAnimation(targets, animationId);
    }
};

Window_BattleLog.prototype.showAttackAnimation = function(subject, targets) {
    if (subject.isActor()) {
        this.showActorAttackAnimation(subject, targets);
    } else {
        this.showEnemyAttackAnimation(subject, targets);
    }
};

Window_BattleLog.prototype.showActorAttackAnimation = function(subject, targets) {
    this.showNormalAnimation(targets, subject.attackAnimationId1(), false);
    this.showNormalAnimation(targets, subject.attackAnimationId2(), true);
};

Window_BattleLog.prototype.showEnemyAttackAnimation = function(subject, targets) {
    SoundManager.playEnemyAttack();
};

Window_BattleLog.prototype.showNormalAnimation = function(targets, animationId, mirror) {
    var animation = $dataAnimations[animationId];
    if (animation) {
        var delay = this.animationBaseDelay();
        var nextDelay = this.animationNextDelay();
        targets.forEach(function(target) {
            target.startAnimation(animationId, mirror, delay);
            delay += nextDelay;
        });
    }
};
If you're using Yanfly Plugins, it's going to be completely different, though. You get the sense that he hated the approach of putting non-log logic on the log window because in his BattleEngineCore Plugin, he completely removes all logic from those methods:

Code:
Window_BattleLog.prototype.startAction = function(subject, action, targets) {
};

Window_BattleLog.prototype.endAction = function(subject) {
};
So if you are using Yanfly's BattleEngineCore, you'll have to go digging through his logic to figure out how he's rebuilt where animations happen.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
If thats a specific skill, I suggest just doing

- Make the skill only have the magic animation
- Make it run a common event that transfer you to the mini-game map or whatever it is

No need to tap into the code
 

ktri9

Warper
Member
Joined
Mar 1, 2019
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
The thing is when I say mini game I mean a custom coded non rpgmaker map scene. So basically think something like space invaders. As far as I know, it is impossible or at the very least, extremely difficult to modify the map scene so that it functions as a separate type of game. I want to add custom movement and objects falling from the sky onto the object that the player gains control of which in this case wont be an actor anymore but another sprite. I would be open to using a common event if its possible but I dont think common events allow you to transfer to custom created scenes. If I'm wrong please correct me. I'm very new to this software. And thank you Zevia, I'll be sure to take a look at that code block and at the moment, I'm not using any YEP plugins. I want to see what I can do myself before I tap into his and other people's stuff.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You could still make the common event transfer you to your custom scene though via script calls, it doesnt necessarily mean it has to be a map. I just said map on my other post because I thought it was on a map
 

ktri9

Warper
Member
Joined
Mar 1, 2019
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
oh yeah that does sound a lot easier but I may still attempt this just to see if I can do it.
 

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top