[SOLVED] YED Sideview Battler + Yanfly Row Formation [Visual Error]

Discussion in 'Javascript/Plugin Support' started by AdamSakuru, Mar 14, 2018.

  1. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    I won't be linking both plugins because the issue is actually with a part of Yanfly's Row Formation not accounting for battler sprites that don't follow the default format.

    Yanfly's Row Formation:
    http://yanfly.moe/2016/01/02/yep-54-row-formation/

    Look at the attached image, the first actor has a sprite sheet made to work with YED's Sideview Battler plugin, but is displaying incorrectly in the Row scene. I looked at the code inside of Yanfly's plugin and found this section here:
    Code:
    //=============================================================================
    // Window_Base
    //=============================================================================
    
    Window_Base.prototype.drawSvActor = function(actor, x, y) {
        var filename = actor.battlerName();
        var bitmap = ImageManager.loadSvActor(filename);
        var pw = bitmap.width / 9;
        var ph = bitmap.height / 6;
        var sx = 0;
        var sy = 0;
        this.contents.blt(bitmap, sx, sy, pw, ph, x - pw / 2, y - ph);
    };
    The issue is that the first Actor's sheet doesn't follow the "width / 9, height / 6" format. I had an idea for a workaround which would be easier to implement than having to account for any kind of size. Would anyone know how to modify it so that instead of displaying the Actor's battler sprite in the Row change scene it would display their face instead?
     

    Attached Files:

    #1
  2. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    Le'Bump
     
    #2
  3. Archeia

    Archeia Level 99 Demi-fiend Staff Member Developer

    Messages:
    14,536
    Likes Received:
    14,194
    Location:
    Game Dev Salt Mines
    First Language:
    Filipino
    Primarily Uses:
    VNM
    Code:
    var filename = actor.battlerName();
    var bitmap = ImageManager.loadSvActor(filename);
    You need to change it so it checks the filename of the faceset and load the ImageManager for faceset instead :kaohi:
     
    #3
  4. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    Something like this?
    Code:
    Window_BattleStatus.prototype.drawFace = function(fn, fi, x, y, width, height) {
        width = width || Window_Base._faceWidth;
        height = height || Window_Base._faceHeight;
        var bitmap = ImageManager.loadFace(fn);
        var pw = Window_Base._faceWidth;
        var ph = Window_Base._faceHeight;
        var sw = Math.min(width, pw);
        var sh = Math.min(height, ph);
        var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
        var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
        var sx = fi % 4 * pw + (pw - sw) / 2;
        var sy = Math.floor(fi / 4) * ph + (ph - sh) / 2;
        this._faceContents.bitmap.blt(bitmap, sx, sy, sw, sh, dx, dy);
    };
    Taken from the Battle Status Window addon for Yanfly's Battle System.

    Edit: I don't really code so I don't know exactly how to edit it.
     
    #4
  5. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,509
    Likes Received:
    955
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Should be good to go with this, let me know if there are any issues.

    2018-03-25 20_23_07-Test Project.png


    Code:
    //=============================================================================
    // Yanfly Engine Plugins - Row Formation
    // Patch to add an option to show the actor face in the row setup window.
    // YEP_RowFormation_Patch_ActorFace.js
    //=============================================================================
    
    
    //=============================================================================
    /*:
    * @plugindesc Patch to YEP_RowFormation to give an option to show the actor
    * face in the Row Formation setup window.
    * @author Aloe Guvner, Yanfly Engine Plugins
    *
    * @param showFace
    * @text Show Actor's Face?
    * @type boolean
    * @default false
    * @desc Show the actor's face in the row setup window?
    *
    * @param cropFace
    * @text Crop Face?
    * @type boolean
    * @desc Crop the Face Image to the size of the rectangle?
    * @default false
    */
    //=============================================================================
    
    (function() {
       var params = PluginManager.parameters("YEP_RowFormation_Patch_ActorFace");
       var showFace = params["showFace"] === "true";
       var cropFace = params["cropFace"] === "true";
    
       var alias_Window_RowFormation_getImage = Window_RowFormation.prototype.getImage;
       Window_RowFormation.prototype.getImage = function(actor) {
          if (showFace) {
             return ImageManager.loadFace(actor.faceName());
          } else {
             return alias_Window_RowFormation_getImage.call(this, actor);
          }
       };
    
       var alias_Window_RowFormation_drawActorRowPosition = Window_RowFormation.prototype.drawActorRowPosition;
    
       Window_RowFormation.prototype.drawActorRowPosition = function(actor, index) {
          if (showFace) {
             var img = this.getImage(actor);
             var rect = this.rowRect(index, actor.row());
             var wx = Math.floor(rect.x);
             var wy = Math.floor(rect.y);
             if (cropFace) {
                this.drawActorFace(actor, wx, wy, rect.width, rect.height);
             } else {
                this.drawActorFace(actor, wx, wy);
             }
          } else {
             alias_Window_RowFormation_drawActorRowPosition.call(this, actor, index);
          }
       };
    
    })();
    
     

    Attached Files:

    #5
    AdamSakuru likes this.
  6. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    Everything's good! I'll let you know if any issues arise. Thanks man!
     
    #6
  7. dustyb13@gmx.com

    dustyb13@gmx.com Villager Member

    Messages:
    26
    Likes Received:
    8
    First Language:
    English
    Is there any way to get this to work with SRD Character Creator?
    When used together the characters show up bald and nude.
    This patch plug in for faces works great just wondering if it
    can be modified to show SV-Battlers with equipment like
    it does the faces?
     
    Last edited: Sep 15, 2018
    #7

Share This Page