Magic reflection fix plugin

● ARCHIVED · READ-ONLY
Started by Danitinkis 13 posts View original ↗
  1. The magic reflection is not good at all. In FF3 (for example), when you use a reflect on a battler and that battler uses a magic skill to himself (like cure), it reflects to an enemy and cannon't be reflected again. However, in RPG Maker MV, the magic skill is reflected to the battler, not the enemy. Here are 2 videos:

    FF3 Reflect:
    [embedded media]
    RPG MAKER MV Reflect (Reflect is "Reflejo"):
    [embedded media]
    I want to change the magic reflection of Rpg maker mv to make it like FF3. But i don't know javascript, so i created this thread. If you, the magic javascript plugin creators have any doubt about this effect, tell me.
  2. This should do it:
    Code:
    _BattleManager_invokeMagicReflection = BattleManager.invokeMagicReflection;
    BattleManager.invokeMagicReflection = function(subject, target) {
        if (!subject.opponentsUnit().members().contains(target)) {
            subject = subject.opponentsUnit().randomTarget();
        }
        _BattleManager_invokeMagicReflection.call(this, subject, target);
    };
    Just save it as a .js file and add it as a new plugin.

    Note that magic reflection by default only occurs when the skill's Hit Type is set to Magical Attack, not for skills like Heal, which are usually Certain Hits. If you want to be able to reflect other skills as well, also add this snippet:
    Code:
    Game_Action.prototype.itemMrf = function(target) {
        if (this.isMagical() || $dataSkills[this._item._itemId].meta.EnableMRF) {
            return target.mrf;
        } else {
            return 0;
        }
    };
    Then you can use the notetag <EnableMRF> in any skill's notebox to reflect it as well.
  3. LadyBaskerville said:
    This should do it:
    Code:
    _BattleManager_invokeMagicReflection = BattleManager.invokeMagicReflection;
    BattleManager.invokeMagicReflection = function(subject, target) {
        if (!subject.opponentsUnit().members().contains(target)) {
            subject = subject.opponentsUnit().randomTarget();
        }
        _BattleManager_invokeMagicReflection.call(this, subject, target);
    };
    Just save it as a .js file and add it as a new plugin.

    Note that magic reflection by default only occurs when the skill's Hit Type is set to Magical Attack, not for skills like Heal, which are usually Certain Hits. If you want to be able to reflect other skills as well, also add this snippet:
    Code:
    Game_Action.prototype.itemMrf = function(target) {
        if (this.isMagical() || $dataSkills[this._item._itemId].meta.EnableMRF) {
            return target.mrf;
        } else {
            return 0;
        }
    };
    Then you can use the notetag <EnableMRF> in any skill's notebox to reflect it as well.
    Thank you! But here is a noob question. How can I download the code?
  4. Just select the text inside the code box with your mouse cursor and copy it from there (CTRL-C or right click -> Copy). Then paste it into a simple text editor like Notepad and save with the extension .js :)
  5. @LadyBaskerville I have a problem. When the reflect occurs, the action animation shows at the battler that has the reflect state. Fix it please :rswt
  6. Currently I don't see a way to remove that animation (as it is played before the engine even checks if the magic is going to be reflected), but Yanfly's Battle Engine Core would display the animation on the enemy as well, along with a reflection animation on the actor reflecting the magic. If you don't want the rest of the plugin's features, I can split the reflection parts into an extra plugin for you (Credit would still go to Yanfly).
  7. This is what happens, @LadyBaskerville (i didn't have time to film a video, i had to go):

    I didn't understand what you said, but if that solves the problem do it. But, when the battle engine core gets an updtate, what I will do?
  8. Ah, my bad - I didn't realize how exactly Yanfly specified the actor to which the animation was reflected. Instead of the first code snippet I posted, use this:
    Code:
    _BattleManager_invokeMagicReflection = BattleManager.invokeMagicReflection;
    BattleManager.invokeMagicReflection = function(subject, target) {
        var tempSubj = this._subject;
        if (!subject.opponentsUnit().members().contains(target)) {
            subject = subject.opponentsUnit().randomTarget();
            this._subject = subject;
        }
        _BattleManager_invokeMagicReflection.call(this, subject, target);
        this._subject = tempSubj;
    };
    Since you're already using Yanfly's Battle Engine, disregard what I said about splitting the reflection parts into an extra plugin.
  9. OK! now works perfectly! How can I credit you?
    PD: You should add that plugin to your colection! I look barely some of your plugins and they look great!
  10. You can credit me as LadyBaskerville if you want, but you don't need to. I'm glad it's working now!
  11. Hi, I have another problem. Using reflect with YEP-X-SelectionControl, when I cast magic to all allies, magic is reflected against enemies, but if one enemy remains and was killed from first magic, the second magic does not strike and displays the following error: Cannot read property 'StartAnimation' of null. Can someone fix it? error2.png