Stat Polygon

Discussion in 'JS Plugin Releases (RMMV)' started by mjshi, Jun 23, 2017.

  1. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    891
    Likes Received:
    707
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A

    Stat Polygon v1.0
    by mjshi- OK for use in all projects with credit

    Get it here!

    A fancy radar chart for your stats!
    Commissioned by the wonderful Lonewulf123 of these very forums.
    Features
    - Customize which and how many stats to show!
    - Supports icon labels!
    - Change the colors as you like-- just be sure to use hex color codes!
    - Compatible with Yanfly Status Menu Core-- read help for more info

    Screenshots
    [​IMG]
    [​IMG]
    [​IMG]

    Version History
    1.0 plugin released

    Credit
    mjshi
     
    #1
    Lady, atoms, Levolpehh and 21 others like this.
  2. Lonewulf123

    Lonewulf123 Veteran Veteran

    Messages:
    279
    Likes Received:
    80
    Location:
    United States
    First Language:
    Enlish
    Thank you for taking on my request! It's awesome and works perfectly for me!
     
    #2
  3. kovak

    kovak Silverguard Veteran

    Messages:
    1,244
    Likes Received:
    1,547
    Location:
    I'm from the Hu3
    First Language:
    PT - EN
    Primarily Uses:
    RMMV
    Just in case you can't download remember to login in your dropbox account.
     
    #3
  4. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    891
    Likes Received:
    707
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
  5. kovak

    kovak Silverguard Veteran

    Messages:
    1,244
    Likes Received:
    1,547
    Location:
    I'm from the Hu3
    First Language:
    PT - EN
    Primarily Uses:
    RMMV
    I had to edit my post cuz for some reason i could download it only after log in my acc
     
    #5
  6. IAmJakeSauvage

    IAmJakeSauvage Veteran Veteran

    Messages:
    417
    Likes Received:
    666
    Location:
    Hamilton, ON
    First Language:
    English
    Primarily Uses:
    RMMV
    This is wicked cool!
     
    #6
    Lonewulf123 likes this.
  7. Lionheart_84

    Lionheart_84 Veteran Veteran

    Messages:
    462
    Likes Received:
    42
    First Language:
    Italian
    Beautiful idea !!! You can do that figure in the middle ... blinking ???
     
    #7
  8. Johnboy

    Johnboy Veteran Veteran

    Messages:
    314
    Likes Received:
    103
    Location:
    Canadia
    First Language:
    English
    @mjshi Is there any way I can replace the bars in Yanfly's Status Menu core? I would like to remove the bars and have just this polygon to represent my statistics to my players. Or maybe even call this in a separate window or with a separate menu command?
     
    #8
    Lonewulf123 likes this.
  9. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    891
    Likes Received:
    707
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Johnboy In StatPolygon.js, find these lines:

    Code:
    if (Imported.YEP_StatusMenuCore) {
    Window_StatusInfo.prototype.drawParameters = function() {
        var dx = indent;
        var dy = this.lineHeight() / 2;
        var dw = this.contents.width - indent;
        var dh = this.lineHeight();
        var dw2;
        var text;
        this.changeTextColor(this.systemColor());
        this.drawText(Yanfly.Param.StatusGraphText, dx, dy, dw, 'center');
        dy = this.lineHeight();
        dx = indent;
        dw -= this.standardPadding() * 2;
        for (var i = 2; i < 8; ++i) {
            dy += this.lineHeight();
            var rate = this.drawParamGauge(dx, dy, dw, i);
            this.changeTextColor(this.systemColor());
            this.drawText(TextManager.param(i), dx + 4, dy, dw - 4);
            text = Yanfly.Util.toGroup(this._actor.param(i))
            this.changeTextColor(this.normalColor());
            dw2 = dw * rate;
            this.drawText(text, dx, dy, dw2 - 4, 'right');
        }
    and delete everything from this.changeTextColor(this.systemColor()); to this.drawText(text, dx, dy, dw2 - 4, 'right')... all the way to the closing brace } (lines 248 to 262).
     
    #9
    Johnboy and Lonewulf123 like this.
  10. Johnboy

    Johnboy Veteran Veteran

    Messages:
    314
    Likes Received:
    103
    Location:
    Canadia
    First Language:
    English
    @mjshi Awesome. Thanks a bunch.
     
    #10
  11. MORINGA

    MORINGA Villager Member

    Messages:
    29
    Likes Received:
    11
    First Language:
    English
    Primarily Uses:
    RMMV
    Hum...can anyone help me with this one? I can't seem to make it work at all...
    (Edit: turned off Yanfly's StatusMenuCore, it works! Thanks a lot! =)
    I won't be using StatusMenuCore, anyway, so this might be perfect for my project. Again, thanks a lot!)
     
    Last edited: Aug 28, 2017
    #11
    Lonewulf123 likes this.
  12. Lonewulf123

    Lonewulf123 Veteran Veteran

    Messages:
    279
    Likes Received:
    80
    Location:
    United States
    First Language:
    Enlish
    You've come to the right place, but you'll need to be more specific with the issue you have. What other scripts are you using? Did you try in a fresh project?
     
    #12
  13. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    891
    Likes Received:
    707
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @MORINGA This plugin is compatible with Status Menu Core. Make sure to read the help file! If it isn't showing up your Center X and Center Y values probably need to be adjusted.
     
    #13
    Lonewulf123 likes this.
  14. Harken_W

    Harken_W Veteran Veteran

    Messages:
    80
    Likes Received:
    22
    First Language:
    English
    Primarily Uses:
    N/A
    Incoming ridiculous question.

    Visually I much prefer this way of showing information compared to just having a list of stats and numbers.

    The list of stats and numbers window appears in other places such as the equip screen and status screen.

    Is there any way in which this Stat Polygon can just replace that entirely?
    So when other plugins/scenes want to show that list of stats, the Stat Polygon would be there instead of the list.

    TL;DR No more list, only Polygon.
     
    #14
  15. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    891
    Likes Received:
    707
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Harken_W

    Do you mean to have two different stat polygons in the equip/status screen that show the changes?
    Really, the part of the plugin drawing the entire thing is just the stuff in

    Window_Status.prototype.drawParameters = function(x, y) {
    and under

    //Begin edits
    //draw polygon

    The actual function that draws the polygon is just

    this.contents.SPolyDrawStatPolygon(this._actor);

    so if you copy/pasted that to other windows you could have stat polygons there also. However, if you wanted to make two stat polygons side by side you'd have to move the x and y coordinates around a bit and to show the changes rather than this._actor use this._tempActor for the second stat polygon.

    But otherwise, there's no built in function for that.
     
    #15
    Harken_W likes this.
  16. Harken_W

    Harken_W Veteran Veteran

    Messages:
    80
    Likes Received:
    22
    First Language:
    English
    Primarily Uses:
    N/A
    Not two stat polygons side by side, just this same stat polygon appearing in different places,
    so I believe it was the 'this.contents.SPolyDrawStatPolygon(this._actor);' part that I was after!

    Thanks for the quick reply and awesome plugin :D
     
    #16
  17. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    891
    Likes Received:
    707
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Harken_W No problem! Also, if you want to make that polygon anywhere else but also have the icons/text etc just copy/paste the relevant portions later on labelled "//draw icon" and "//draw text", respectively.

    You might run into issues later on with positioning since the entire thing uses a global x and y variable. You can remedy that by finding this part:

    Code:
    Bitmap.prototype.SPolyDrawStatPolygon = function(actor) {
        var cx = centerX, cy = centerY;
    
    ...(etc code stuff)...
    
    };
    and changing that var cx = centerX thing to this:
    Code:
    Bitmap.prototype.SPolyDrawStatPolygon = function(actor, x, y) {
        if (x !== undefined) {
            var cx = x, cy = y;
        } else {
            var cx = centerX, cy = centerY;
        }
    
    ...(etc code stuff)...
    
    };
    This way when you call this.contents.SPolyDrawStatPolygon(this._actor); you can also specify a center x and y coordinate.

    Example:
    this.contents.SPolyDrawStatPolygon(this._actor, 100, 200);
    to center it at x=100 and y=200.
     
    #17
  18. Zack Phoenix

    Zack Phoenix Artist Veteran

    Messages:
    185
    Likes Received:
    22
    First Language:
    German
    Primarily Uses:
    RMMV
    This is so simple yet so awesome and helps to show players information in a way that lets them immediately distinguish strengths and weaknesses. This would be awesome for element resistances etc. too!
    Thanks and great job!

    Edit:
    I do seem to have a problem. Showing the stats on level 1 seems just fine, but as soon as I test it with their initial level being something like 20, all the graphs are completely maxed out.
    Do I do something wrong or does the graph not "grow" with the stats? It should probably always be a relative value.
     
    Last edited: Oct 2, 2017
    #18
  19. Lonewulf123

    Lonewulf123 Veteran Veteran

    Messages:
    279
    Likes Received:
    80
    Location:
    United States
    First Language:
    Enlish
    You have to adjust the “max stats” value in the plugin parameters I believe. You can’t change the maximum value dynamically with each level.
     
    #19
  20. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    891
    Likes Received:
    707
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    @Zack Phoenix It's just as Lonewulf123 said. The default "max stat" values are set intentionally low, so that differences in stats are immediately obvious the second you enable the plugin. However, for it to be useful realistically, you're going to have to decide what approximate upper maximum the stats in your game are going to have.

    If you know a little bit about coding and want to change how that's decided though, the relevant portion is this:
    Code:
    Bitmap.prototype.SPolyDrawStatPolygon = function(actor) {
        var cx = centerX, cy = centerY;
    
        //draw graph background
        for (var i = 0; i < numSegments; i++) this.SPolyDrawRegularPolygon(cx, cy, radius - (i * radius/numSegments), sides, secondaryColor, lineWeight);
      
        //draw lines
        for (var i = 0; i < sides; i++) this.SPolyDrawLine(cx, cy, cx + radius * Math.cos(Math.PI/2 + i * 2 * Math.PI / sides), cy - radius * Math.sin(Math.PI/2 + i * 2 * Math.PI / sides), secondaryColor, lineWeight);
    
        //draw stat polygon
        var points = [];
        for (var i = 0; i < stats.length; i++) {
            points.push(cx + Math.min(actor.param(stats[i]) / maxStats[i], 1) * radius * Math.cos(Math.PI/2 + i * 2 * Math.PI / sides));
            points.push(cy - Math.min(actor.param(stats[i]) / maxStats[i], 1) * radius * Math.sin(Math.PI/2 + i * 2 * Math.PI / sides));
        }
        this.SPolyDrawPolygon(points, primaryColor, lineWeight2);
    };
    Change what the bolded text is. This value should go from 0 to 1 (so 0 to 100% of the polygon). Currently it's based on the percentage created from the actor's current stats divided by the approximate maximum stat.
    Math.min(actor.param(stats) / maxStats, 1)
     
    #20
    Lonewulf123 likes this.

Share This Page