Current Plug-in Problem

Discussion in 'Javascript/Plugin Support' started by Zizka, Sep 23, 2019.

  1. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    Hello guys,
    So I paid a programmer to code a few scripts for me. Unfortunately, after telling me that he'd reply in a week, he hasn't replied since (this was two weeks ago). I've since tried to get in touch with him numerous times with no success.

    The code mentions in the "setup" part that I need to use the <outline> tag on an event in order to use my script. I have no idea as to how I use that tag and therefore cannot use the script in this current form and the programmer doesn't reply to my queries so I figured I would ask people here so that they can point out how I can use this script.

    Thank you!

    Code:
    /*
    #=============================================================================
    # Outline Events
    # OutlineEvents.js
    # By Lecode
    # Version 1.0
    #-----------------------------------------------------------------------------
    # TERMS OF USE
    #-----------------------------------------------------------------------------
    # - Credits to Lecode
    # - Only usable by Etiennezizka
    #-----------------------------------------------------------------------------
    # Version History
    #-----------------------------------------------------------------------------
    # - 1.0 : Initial release
    #=============================================================================
    */
    var Lecode = Lecode || {};
    Lecode.C_OutlineEvents = {};
    /*:
     * @plugindesc Outline events when the player is close
     * @author Lecode
     * @version 1.0
     *
     * @param Thickness
     * @desc Default thickness of the outline
     * @default 1
     *
     * @param Color
     * @desc Default color of the outline
     * @default 0xFFFFFF
     *
     * @param Distance From Player
     * @desc Default minimal distance to trigger the outline
     * @default 2
     *
     * @param Need Facing ?
     * @desc Should the player face events to trigger the outline ?
     * @default true
     *
     *
     * @help
     * #-----------------------------------------------------------------------------
     * # Introduction
     * #-----------------------------------------------------------------------------
     * This plugin highlights events when the player is near them.
     * The color and thickness of the highlighting can be modified.
     * The other parameters define the required minimal distance from the player
     * to trigger the plugin, and if the player need to face them or not.
     *
     * Note: Color is in hexadecimal notation.
     *
     * #-----------------------------------------------------------------------------
     * # Set Up
     * #-----------------------------------------------------------------------------
     * To activate the plugin on an event, simply put the <Outline> tag on it.
     * You can however give specified parameters for your events, with this tag instead:
     * <Outline: Thickness, Color, Distance, NeedFacing?>
     *
     * Example: <Outline: 4, 0x5882FA, 4, false>
     */
    //#=============================================================================
    
     
    #1
  2. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zizka Hmm, is that the entire plugin file that you have pasted here, or were you just pasting the header of the plugin file? Because there is no actual, functional code being used here. If there is more to the plugin file, and you simply did not want to paste the entire plugin -- which is understandable, seeing as how it is a paid plugin -- then I can guess that by 'tag' the programmer means a comment or note tag. Probably the latter. Within the event, insert a new Comment event command (first page under 'Flow Control' in the 'Event Commands' window). Then follow the example laid out in the 'Set Up' section of the plugin. The end result should look something like this :

    comment-event.png
    Or if you want the event to use the default options laid out in the plugin settings :

    comment-event-b.png

    Without seeing the actual code, this is all just a guess on my part.
     
    #2
  3. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    Oh I can put the whole code:
    Code:
    /*
    #=============================================================================
    # Outline Events
    # OutlineEvents.js
    # By Lecode
    # Version 1.0
    #-----------------------------------------------------------------------------
    # TERMS OF USE
    #-----------------------------------------------------------------------------
    # - Credits to Lecode
    # - Only usable by Etiennezizka
    #-----------------------------------------------------------------------------
    # Version History
    #-----------------------------------------------------------------------------
    # - 1.0 : Initial release
    #=============================================================================
    */
    var Lecode = Lecode || {};
    Lecode.C_OutlineEvents = {};
    /*:
     * @plugindesc Outline events when the player is close
     * @author Lecode
     * @version 1.0
     *
     * @param Thickness
     * @desc Default thickness of the outline
     * @default 1
     *
     * @param Color
     * @desc Default color of the outline
     * @default 0xFFFFFF
     *
     * @param Distance From Player
     * @desc Default minimal distance to trigger the outline
     * @default 2
     *
     * @param Need Facing ?
     * @desc Should the player face events to trigger the outline ?
     * @default true
     *
     *
     * @help
     * #-----------------------------------------------------------------------------
     * # Introduction
     * #-----------------------------------------------------------------------------
     * This plugin highlights events when the player is near them.
     * The color and thickness of the highlighting can be modified.
     * The other parameters define the required minimal distance from the player
     * to trigger the plugin, and if the player need to face them or not.
     *
     * Note: Color is in hexadecimal notation.
     *
     * #-----------------------------------------------------------------------------
     * # Set Up
     * #-----------------------------------------------------------------------------
     * To activate the plugin on an event, simply put the <Outline> tag on it.
     * You can however give specified parameters for your events, with this tag instead:
     * <Outline: Thickness, Color, Distance, NeedFacing?>
     *
     * Example: <Outline: 4, 0x5882FA, 4, false>
     */
    //#=============================================================================
    
    
    /*-------------------------------------------------------------------------
    * Get Parameters
    -------------------------------------------------------------------------*/
    var parameters = PluginManager.parameters('DragonWarrior');
    
    Lecode.C_OutlineEvents.thickness = Number(parameters["Thickness"] || 1);
    Lecode.C_OutlineEvents.color = Number(parameters["Color"] || 0xFFFFFF);
    Lecode.C_OutlineEvents.distanceFromPlayer = Number(parameters["Distance From Player"] || 2);
    Lecode.C_OutlineEvents.needFacing = String(parameters["Need Facing ?"] || 'true') === 'true';
    
    
    /*-------------------------------------------------------------------------
    * Lecode.C_OutlineEvents
    -------------------------------------------------------------------------*/
    Lecode.C_OutlineEvents.applyFilter = function (event, thickness, color) {
        var scene = SceneManager._scene;
        var spriteset = scene._spriteset;
        if (!spriteset) return;
        var sprites = spriteset._characterSprites;
        for (var i = 0; i < sprites.length; i++) {
            var sprite = sprites[i];
            if (sprite._character._eventId === event._eventId) {
                var filter = new OutlineFilter(thickness, color);
                sprite.filters = [filter];
            }
        }
    };
    
    Lecode.C_OutlineEvents.removeFilter = function (event) {
        var scene = SceneManager._scene;
        var spriteset = scene._spriteset;
        if (!spriteset) return;
        var sprites = spriteset._characterSprites;
        for (var i = 0; i < sprites.length; i++) {
            var sprite = sprites[i];
            if (sprite._character._eventId === event._eventId) {
                sprite.filters = [];
            }
        }
    };
    
    
    /*-------------------------------------------------------------------------
    * Game_Player
    -------------------------------------------------------------------------*/
    Lecode.C_OutlineEvents.oldGamePlayer_locate = Game_Player.prototype.locate;
    Game_Player.prototype.locate = function (x, y) {
        Lecode.C_OutlineEvents.oldGamePlayer_locate.call(this, x, y);
        this.checkOutlineEvent();
    };
    
    Lecode.C_OutlineEvents.oldGamePlayer_increaseSteps = Game_Player.prototype.increaseSteps;
    Game_Player.prototype.increaseSteps = function () {
        Lecode.C_OutlineEvents.oldGamePlayer_increaseSteps.call(this);
        this.checkOutlineEvent();
    };
    
    Lecode.C_OutlineEvents.oldGamePlayer_setDirection = Game_Player.prototype.setDirection;
    Game_Player.prototype.setDirection = function (dir) {
        Lecode.C_OutlineEvents.oldGamePlayer_setDirection.call(this, dir);
        this.checkOutlineEvent();
    };
    
    Game_Player.prototype.checkOutlineEvent = function () {
    
        var isLookingAt = function (event) {
            if (event.x > this.x && this._direction === 6) return true;
            if (event.x < this.x && this._direction === 4) return true;
            if (event.y > this.y && this._direction === 2) return true;
            if (event.y < this.y && this._direction === 8) return true;
            return false;
        }.bind(this);
    
        for (var i = 0; i < $gameMap.events().length; i++) {
            var event = $gameMap.events()[i];
            if (event === $gamePlayer) return;
            var distance = $gameMap.distance(this.x, this.y, event.x, event.y);
            var activate = false;
    
            var minDistance = Lecode.C_OutlineEvents.distanceFromPlayer;
            var needFacing = Lecode.C_OutlineEvents.needFacing;
            var thickness = Lecode.C_OutlineEvents.thickness;
            var color = Lecode.C_OutlineEvents.color;
            
            if (event.event().note.match(/<Outline>/i)) {
                activate = true;
            } else if (event.event().note.match(/<Outline\s?:\s?(.+)\,(.+)\,(.+)\,(.+)>/i)) {
                thickness = Number(RegExp.$1);
                color = Number(RegExp.$2);
                minDistance = Number(RegExp.$3);
                needFacing = RegExp.$4.trim() === "true";
                activate = true;
            } else {
                continue;
            }
    
            if (activate && distance <= minDistance) {
                if (needFacing && !isLookingAt(event)) {
                    Lecode.C_OutlineEvents.removeFilter(event);
                    continue;
                }
                Lecode.C_OutlineEvents.applyFilter(event, thickness, color);
            } else {
                Lecode.C_OutlineEvents.removeFilter(event);
            }
        }
    };
    
    
    
    /**
     * OutlineFilter, originally by mishaa
     * http://www.html5gamedevs.com/topic/10640-outline-a-sprite-change-certain-colors/?p=69966
     * http://codepen.io/mishaa/pen/emGNRB
     *
     * @class
     * @param thickness {number} The tickness of the outline. Make it 2 times more for resolution 2
     * @param color {number} The color of the glow.
     *
     * @example
     *  someSprite.shader = new OutlineFilter(9, 0xFF0000);
     */
    function OutlineFilter(thickness, color) {
        thickness = thickness || 1;
    
        var vertext =
            "attribute vec2 aVertexPosition;" +
            "attribute vec2 aTextureCoord;" +
            "" +
            "uniform mat3 projectionMatrix;" +
            "varying vec2 vTextureCoord;" +
            "" +
            "void main(void){" +
            "    gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);" +
            "    vTextureCoord = aTextureCoord;" +
            "}";
    
        var fragment =
            "varying vec2 vTextureCoord;" +
            "uniform sampler2D uSampler;" +
            "" +
            "uniform float thickness;" +
            "uniform vec4 outlineColor;" +
            "uniform vec4 filterArea;" +
            "uniform vec4 filterClamp;" +
            "vec2 px = vec2(1.0 / filterArea.x, 1.0 / filterArea.y);" +
            "" +
            "void main(void) {" +
            "    const float PI = 3.14159265358979323846264;" +
            "    vec4 ownColor = texture2D(uSampler, vTextureCoord);" +
            "    vec4 curColor;" +
            "    float maxAlpha = 0.;" +
            "    vec2 displaced;" +
            "    for (float angle = 0.; angle < PI * 2.; angle += %THICKNESS% ) {" +
            "        displaced.x = vTextureCoord.x + thickness * px.x * cos(angle);" +
            "        displaced.y = vTextureCoord.y + thickness * px.y * sin(angle);" +
            "        curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw));" +
            "        maxAlpha = max(maxAlpha, curColor.a);" +
            "    }" +
            "    float resultAlpha = max(maxAlpha, ownColor.a);" +
            "    if (resultAlpha >= 0.3) {;" +
            "       resultAlpha = 1.;" +
            "    }" +
            "    gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha);" +
            "}";
    
        PIXI.Filter.call(this,
            vertext,
            fragment.replace(/%THICKNESS%/gi, (1.0 / thickness).toFixed(7))
        );
    
        this.uniforms.thickness = thickness;
        this.uniforms.outlineColor = new Float32Array([0, 0, 0, 1]);
        if (color) {
            this.color = color;
        }
    }
    
    OutlineFilter.prototype = Object.create(PIXI.Filter.prototype);
    OutlineFilter.prototype.constructor = OutlineFilter;
    //module.exports = OutlineFilter;
    
    Object.defineProperties(OutlineFilter.prototype, {
        color: {
            get: function () {
                return PIXI.utils.rgb2hex(this.uniforms.outlineColor);
            },
            set: function (value) {
                PIXI.utils.hex2rgb(value, this.uniforms.outlineColor);
            }
        }
    });
     
    #3
  4. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zizka Aah, ok, the '<Outline>' tag will need to go in the 'Note' area of the event and not in a comment. The 'Note' area is to the right of the name of the event. Just toss the tag into that text field and it will work.
     
    #4
    Zizka likes this.
  5. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you but I'm getting an error message:

    upload_2019-9-30_20-10-37.png

    upload_2019-9-30_20-9-45.png
     
    #5
  6. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zizka Hmm, I will need a bit more information on the error message. Once the error occurs in the game, press F12 then copy and paste the text from the debug console.
     
    #6
  7. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    Hmm... nothing happens when I press F12.

    Could it be something related to YEP_MessageCore?
    upload_2019-10-1_17-36-26.png
     

    Attached Files:

    #7
  8. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zizka Huh ... try pressing F12 when the game loads up. A separate window with a console should appear. Then go into the game and trigger the error.
     
    #8
  9. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    I keep pressing F12 from the moment the game loads up and no console show up, no separate window at all.
     
    #9
  10. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zizka Strangeness ... how about F8?

    EDIT: If that does not work, try disabling one plugin at a time, see which one is causing the issue.
     
    #10
  11. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    Yup, it seems to be F8:
    upload_2019-10-1_17-44-30.png
     
    #11
  12. Maliki79

    Maliki79 Veteran Veteran

    Messages:
    639
    Likes Received:
    244
    Location:
    New Jersey
    First Language:
    English
    Primarily Uses:
    N/A
    Try renaming the plugin to DragonWarrior
     
    #12
    Ossra likes this.
  13. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Maliki79 Good catch! However, the defaults will kick in if the parameters variable is empty. So that should not be causing the error. Though that is another thing to fix in the code.

    EDIT: The code should not be blowing up ... the plugin as pasted above works fine for me. Hmm ...

    EDIT II: Ok, I think I found the problem. One moment ...






    EDIT III: @Zizka Open the debug console, click near the light blue '>' angle bracket and type or paste in : PIXI.VERSION

    This plugin will not function correctly for lower versions of PIXI. If the version of PIXI you are using in your project is below '4' -- and it almost certainly is -- you will need to backup and update your project files in order to use the Outline plugin.
     
    Last edited: Oct 2, 2019
    #13
    Zizka likes this.
  14. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    Renaming the plug-in didn't do anything.
    upload_2019-10-1_20-37-0.png
    So how can I update my PIXI version to a higher version?
     
    #14
  15. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zizka Did you start your project several years ago? That could explain the version issue. Another possibility is that you do not use the Steam version, and your RPG Maker MV has not been updated. Or if you do use the Steam version, it has not automatically updated for some reason. To check which version of RPG Maker MV that you are using, go to the 'Help' menu and select the 'About' option in the editor. The most current version of RPG Maker MV is 1.6.2

    If you are using the stand-alone version (non-Steam) and your version is below 1.6.2, then I believe that you will have to perform a manual update. So let me know what version RPG Maker MV is at, and we will go from there.
     
    #15
  16. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    1.6.1 but when I check my PIXI version is was still outdated at 2.2.9.
    I've updated the PIXI version by using one on github. I copy/pasted the code I got from github under notepad and saved the file as .js and replaced the outdated PIXI.js
    upload_2019-10-1_21-32-48.png
    I'm getting a different problem however:
    "WebAudio.initialize is not a function."

    I'm guessing it might be because 5.1.5. is too recent and unstable?
     

    Attached Files:

    #16
  17. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,626
    Likes Received:
    1,053
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Updating RPG Maker (the program) doesn't automatically go into all your projects and change every file, for obvious reasons.

    The best thing would be for you to create a new project and copy files like PIXI and the core scripts from the new project into your existing project. If you get stuck, visit the official thread on these forums that have step-by-step instructions on how to update your project.
     
    #17
    Zizka likes this.
  18. Zizka

    Zizka Veteran Veteran

    Messages:
    127
    Likes Received:
    24
    First Language:
    English
    Primarily Uses:
    RMMV
    Well they're not obvious to me, I'll say that much :D!
    It's working fine as a new project, thank you!
     
    #18
    Aloe Guvner likes this.
  19. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    913
    Likes Received:
    654
    First Language:
    English
    Primarily Uses:
    RMMV
    @Zizka Nice! The Outline plugin is functioning normally now?
     
    #19
  20. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,626
    Likes Received:
    1,053
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Oh sorry what I mean by that is:

    The RPG Maker program simply doesn't know where your projects are. They could be on your 'Desktop', in 'My Documents', in 'Grandmas Secret Folder', etc. etc. It has no way of knowing where you keep your particular project, so it doesn't automatically update your projects, you have to do that part.
     
    #20
    Zizka likes this.

Share This Page