Skill Message Plugin

Discussion in 'JS Plugin Requests' started by Kitdan7, Mar 18, 2019.

  1. Kitdan7

    Kitdan7 Villager Member

    Messages:
    16
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    I want a move to say "(character) tried to eat (target)!" (character is a snake) so, I need a plugin that makes %2 display the target's name. I know it's possible because I found an old post that gave a code for exactly that, (link) but I think it was either too old to be compatible with updates or I did something wrong trying to convert the code to plugin form. I'd try to fix the problem myself, but I understand nothing about how plugins work, so I'd probably end up corrupting my whole computer somehow. I am using YEP_BattleEngineCore, btw.
     
    #1
  2. Kitdan7

    Kitdan7 Villager Member

    Messages:
    16
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    Um... Bump?
     
    #2
  3. Magnus0808

    Magnus0808 Software Developer Veteran

    Messages:
    104
    Likes Received:
    100
    First Language:
    Danish
    Primarily Uses:
    RMMV
    I wrote this almost a year ago that does exactly this.
    If I remember correctly if there are too many targets then it goes out of screen tho.

    Code:
    //=============================================================================
    // MRP_BattleLogSkillTarget.js
    //=============================================================================
    /*:
     * @plugindesc Skills can now display target names using %2
     * @author Magnus0808
     */
     
    (function() {
       
        Window_BattleLog.prototype.displayAction = function(subject, item) {
            var numMethods = this._methods.length;
            var targets = BattleManager._targets;
           
            if (DataManager.isSkill(item)) {
                var targets_string = "";
                // Checks if there is a target
                if (targets && targets.length > 0) {
                    targets_string += targets[0].name();
                    // Checks if there is more than a single target
                    if (targets.length > 1) {
                        for (var i = 1; i < targets.length-1; i++) {
                            targets_string += ", " + targets[i].name();
                        }
                        targets_string += " and " + targets[targets.length-1].name();
                    }
                }
                if (item.message1) {
                    this.push('addText', subject.name() + item.message1.format(item.name, targets_string));
                }
                if (item.message2) {
                    this.push('addText', item.message2.format(item.name, targets_string));
                }
            } else {
                this.push('addText', TextManager.useItem.format(subject.name(), item.name));
            }
            if (this._methods.length === numMethods) {
                this.push('wait');
            }
        };
    })();
    
     

    Attached Files:

    Last edited: Mar 26, 2019
    #3
  4. Kitdan7

    Kitdan7 Villager Member

    Messages:
    16
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    Tried it, but it doesn't show the target's name, it just doesn't put anything there. Here's a screenshot of my active plugins, if that helps.
    Your plugin is highlighted.
    Plugins.png
     
    #4
  5. Magnus0808

    Magnus0808 Software Developer Veteran

    Messages:
    104
    Likes Received:
    100
    First Language:
    Danish
    Primarily Uses:
    RMMV
    I should have checked if it worked with YEP_BattleEngineCore first. I changed it a bit and it should work now. It should be placed above YEP_BattleEngineCore.

    I have edited my original reply :)
     
    #5
  6. Kitdan7

    Kitdan7 Villager Member

    Messages:
    16
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    RMMV
    It works now. Thanks!
     
    #6
    Magnus0808 likes this.

Share This Page