扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 148|回复: 0

[转载发布] 属性点分配插件无法使用

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    2025-2-4 02:05
  • 签到天数: 110 天

    连续签到: 2 天

    [LV.6]常住居民II

    2327

    主题

    395

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10465
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13215

    灌水之王

    发表于 2024-2-24 02:27:12 | 显示全部楼层 |阅读模式
    如题,找到个很好用的升级分配属性插件但总报错,新人表示灰常无奈。。哪位大大给指点一下。{:2_281:}
    附代码:

    JAVASCRIPT 代码
    [code]//=============================================================================
    // StatDistribution.js
    //=============================================================================

    /*:
    @author Icaro10100 / FrozenPhoenix
    @plugindesc Get stat points on level up, those points can be spent to increase stat value
    @help

    *********************************************************************************

    Actors will gain stat points whenever they level up or when you want to give
    them via script call: $gameActors.actor(id).gainStats(amount)

    Those points can be used to increase the actor's stats via a custom scene.
    To call the scene use the call: SceneManager.sceneDistribution(actor)

    Example: SceneManager.sceneDistribution($gameParty.members()[0])
    Learn the basic script calls

    To call the scene for the entire party use SceneManager.partyDistribution()
    Press Q/W to swap the party members. You can use SceneManager.partyDistribution(id)
    to have the scene start with the actor in position "id" in the party, example:
    SceneManager.partyDistribution(2) will start the scene with the third actor in the
    party.

    Holding shift while increasing the attributes will increase them faster.

    Press "x" to toggle between decrease/increase option

    Put the following tags to determine how much the param/stat will increase per
    stat point spent:










    For extra parameters:












    The tags should be put in the class notebox OR in the actor notebox

    To have custom parameter limits for each actor/class put those tags in the notebox:












    Feel free to use for free/comercial games, just give credit.
    Enjoy

    ChangeLog:

    --1.2
    -Fixed bug of max hp value displaying 999 on screen even when the actual value was higher
    -Added option to add custom limits for parameters, those can be different for each actor
    -Added option to limit how much points you can spend on the same parameter each level
    -Added party option, press Q/W to swap between party members
    -Can now put tags in the actor's note box as well

    --1.1
    -Added names for some stuff
    -Added option to decrease stat
    -Added support for extra parameters (crit/evasion etc)

    *********************************************************************************

    @param PointsName
    @desc The name given to stat points
    @default Points

    @param ActorName
    @desc The word before the actor's name
    @default Name

    @param ClassName
    @desc The word before the actor's class
    @default Class

    @param ExpName
    @desc The word before the actor's experience
    @default EXP

    @param IncreaseName
    @desc The word that means increase duhhh (if doing game on another language)
    @default Increase

    @param DecreaseName
    @desc Same thing as before
    @default Decrease

    @param StatNameColor
    @desc The color the stat's name appears, select a number from the windowskin
    @default 1

    @param StatValueColor
    @desc The color the stat's value appears, select a number from the windowskin
    @default 0

    @param ShiftIncrease
    @desc When holding shift, the amount increased will be multiplicated by this parameter
    @default 5

    @param LevelUpPoints
    @desc Points gained on level up, can be any number or formula that returns a number
    @default 10

    @param UsedStats
    @desc The basic stats that will be available to increase, put the id separated by a comma Example: 0,3,4,5
    @default 0,1,2,3,4,5,6,7

    @param UsedXStats
    @desc Same as before, but for extra parameters (crit/evasion etc)
    @default

    @param ExtraParamNames
    @desc Names for the extra stats (crit/evasion etc), just modify the strings in the default.
    @default ["Hit rate", "Evasion", "Crit chance", "Crit Evasion", "Magic Evasion", "Magic Reflect", "Counter", "HP Regen", "MP Regen", "TP Regen"]

    @param DefaultLimits
    @desc Highest possible value for the parameter
    Just change the values, in order: hp/mp/atk/def/mat/mdf/agi/luk
    @default [99999, 9999, 999, 999, 999, 999, 999, 999]

    @param DefaultxParamLimits
    @desc Highest possible value for special parameters
    Just change the values, in order: hit/eva/crit/criteva etc.
    @default [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

    @param MaxPointsPerLevel
    @desc How much points you can spend per level on a single parameter
    use any formula that returns a number, leave 0 for no limits
    @default 0




    */



    (function(){

    //Parameters   
    var parameters = PluginManager.parameters('StatDistribution');
    var pointsName = String(parameters["PointsName"]);
    var actorName = String(parameters["ActorName"]);
    var className = String(parameters["ClassName"]);
    var expName = String(parameters["ExpName"]);
    var increaseName = String(parameters["IncreaseName"]);
    var decreaseName = String(parameters["DecreaseName"]);
    var statNameColor = Number(parameters["StatNameColor"]);
    var statValueColor = Number(parameters["StatValueColor"]);
    var shiftIncrease = Number(parameters["ShiftIncrease"]);
    var levelUpPoints = String(parameters["LevelUpPoints"]);
    var usedStats = String(parameters["UsedStats"]);
    var usedXStats = String(parameters["UsedXStats"]);
    var xParamNames = String(parameters["ExtraParamNames"]);
    var defaultLimits = String(parameters['DefaultLimits']);
    var defaultxLimits = String(parameters['DefaultxParamLimits']);
    var maxPointsPerLevel = String(parameters['MaxPointsPerLevel']);

    getLimit = function(id){
        limits = eval(defaultLimits);
        return limits[id];
    }

    getTag = function(id){
        switch(id){
            case0:
                return"hplimit";
            case1:
                return"mplimit";
            case2:
                return"atklimit";
            case3:
                return"deflimit";
            case4:
                return"matlimit";
            case5:
                return"mdflimit";
            case6:
                return"agilimit";
            case7:
                return"luklimit";                 
        }
    }


    //This function will return an array with the ids of the used stats
    getUsedStats = function(){
        var re = /\d+/g;
        return usedStats.match(re) || [];  
    }

    //This function will return an array with the ids of the used extra stats
    getUsedXStats = function(){
        var re = /\d+/g;
        return usedXStats.match(re) || [];
    }

    //This function will return the name of the extra param with given index
    getXParamName = function(id){
        var names = eval(xParamNames);
        return names[id];
    }

    //Game batlerbase

    Game_BattlerBase.prototype.xparam = function(xparamId){
        var value = this.traitsSum(Game_BattlerBase.TRAIT_XPARAM, xparamId) + this._gainedxparams[xparamId];
        return value;
    };

    _GameBattlerBaseInitialize = Game_BattlerBase.prototype.initialize;
    Game_BattlerBase.prototype.initialize = function(){
        _GameBattlerBaseInitialize.call(this);
        this._gainedxparams = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    };


    Game_BattlerBase.prototype.paramMax = function(paramId){
        if(paramId == 0){
            return999999;  // MHP
        }elseif(paramId == 1){
            return9999;    // MMP
        }else{
            return999;
        }
    };


    //---Game Actor

    _GameActorInitialize = Game_Actor.prototype.initialize;
    Game_Actor.prototype.initialize = function(actorId){
        _GameActorInitialize.call(this, actorId);
        this._statPoints = 0;
        this.resetUsedPoints();
    };

    Game_Actor.prototype.resetUsedPoints = function(){
        this._usedPoints = [0, 0, 0, 0, 0, 0, 0, 0];
        this._usedxPoints = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    }

    Game_Actor.prototype.increasePointLimit = function(){
        for(i=0; i this.paramMax(paramid)){
            result =false;
        }
        return result;
    }

    Game_Actor.prototype.canIncreasex = function(paramid, points, alreadyUsed){
        var result = true;
        if(((this._usedxPoints[paramid] + points) > this.maxPerLevel()) && (this.maxPerLevel() != 0)){
            result = false;
        }
        if((this.xparam(paramid) + alreadyUsed + points*this.xstatPerPoint(paramid)) > this.xparamMax(paramid)){
            result =false;
        }
        return result;
    }

    Game_Actor.prototype.paramMax = function(paramId){
        var limit;
        var meta = "this.actor().meta." + getTag(paramId);
        meta = eval(meta);
        meta = meta ? meta : "$dataClasses[this.actor().id].meta." + getTag(paramId);
        meta = eval(meta);
        if(meta){
            limit = Number(meta);
        }else{
            limit = getLimit(paramId);
        }
        return limit;
    };

    Game_Actor.prototype.xparamMax = function(paramId){
        var limit = eval(defaultxLimits);
        return limit[paramId];
    };

    Game_Actor.prototype.maxPerLevel = function(){
        returneval(this.actor().meta.maxPerLevel) || Number(maxPointsPerLevel);
    }

    //Stat increase per stat point
    Game_Actor.prototype.statPerPoint = function(id){
        var str;
        switch(id){
            case0:
                str = "ihp";
                break;
            case1:
                str = "imp";
                break;
            case2:
                str = "iatk";
                break;
            case3:
                str = "idef";
                break;
            case4:
                str = "imat";
                break;
            case5:
                str = "imdf";
                break;
            case6:
                str = "iagi";
                break;
            case7:
                str = "iluk";
                break;         
        }
        var met = "$dataClasses[this._classId].meta." + str;
        met = eval(met);
        met = met ? met : "this.actor().meta." + str;
        met = eval(met);
        return met ? eval(met) : 1;
    }

    //Xstat increase per stat point
    Game_Actor.prototype.xstatPerPoint = function(id){
        var str;
        switch(id){
            case0:
                str = "ihit";
                break;
            case1:
                str = "ieva";
                break;
            case2:
                str = "icri";
                break;
            case3:
                str = "icev";
                break;
            case4:
                str = "imev";
                break;
            case5:
                str = "imrf";
                break;
            case6:
                str = "icnt";
                break;
            case7:
                str = "ihrg";
                break;
            case8:
                str = "imrg";
                break;
            case9:
                str = "itrg";
        }
        var met = "$dataClasses[this._classId].meta." + str;
        met = eval(met);
        met = met ? met : "this.actor().meta." + str;
        met = eval(met);
        returneval(met) ? eval(met) : 1;
    }

    //-New function gainStats to call on level ups etc
    Game_Actor.prototype.gainStats = function(amount){
        this._statPoints += amount;
    }

    //-Gain stats on level up
    _GameActorLevelUp = Game_Actor.prototype.levelUp;
    Game_Actor.prototype.levelUp = function(){
        _GameActorLevelUp.call(this);
        this.gainStats(eval(levelUpPoints));
        this.increasePointLimit();
    };

    //-Actor current stats
    Game_Actor.prototype.statPoints = function(){
        returnthis._statPoints;
    }  

    //-----New windows

    //****************************************************
    //
    //---Window Points, to display stat points.
    //
    //****************************************************


    function Window_Points(){
        this.initialize.apply(this, arguments);
    }

    Window_Points.prototype = Object.create(Window_Base.prototype);
    Window_Points.prototype.constructor = Window_Points;

    Window_Points.prototype.initialize = function(x, y, actor){
        var width = this.windowWidth();
        var height = this.windowHeight();
        this._actor = actor;
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };

    Window_Points.prototype.windowWidth = function(){
        return300;
    };

    Window_Points.prototype.actor = function(){
        returnthis._actor;
    }

    Window_Points.prototype.windowHeight = function(){
        returnthis.fittingHeight(1);
    };

    Window_Points.prototype.refresh = function(newActor){
        if(!newActor){
            newActor = this.actor();
        }
        this._actor = newActor;
        var x = this.textPadding();
        var width = this.contents.width - this.textPadding() * 2;
        this.contents.clear();
        this.drawThings();
    };

    Window_Points.prototype.drawThings = function(){
        var x = 1;
        var y = 1;
        var mWidth = Math.round(this.windowWidth()/2.5);
        var value = this._actor.statPoints();
        this.changeTextColor(this.textColor(statNameColor));
        this.drawText(pointsName, x, y, mWidth);
        this.changeTextColor(this.textColor(statValueColor));
        this.drawText(value, x + mWidth + 10, y, mWidth);  
    }

    Window_Points.prototype.open = function(){
        this.refresh();
        Window_Base.prototype.open.call(this);
    };


    //****************************************************
    //
    //---Window Selecting, to increase stats or leave scene
    //
    //****************************************************


    Window_Selecting.prototype = Object.create(Window_Command.prototype);
    Window_Selecting.prototype.constructor = Window_Selecting;

    function Window_Selecting(){
        this.initialize.apply(this, arguments);
    }

    Window_Selecting.prototype.initialize = function(x, y, mode){
        this._mode = mode;
        Window_Command.prototype.initialize.call(this, x, y);
    }

    Window_Selecting.prototype.windowWidth = function(){
        return350;
    };

    Window_Selecting.prototype.numVisibleRows = function(){
        return9;
    };

    Window_Selecting.prototype.processOk = function(){
        if(this.isCurrentItemEnabled()){
            this.updateInputData();
            this.deactivate();
            this.callOkHandler();
        }
    };

    Window_Selecting.prototype.activate = function(index){
        Window_Base.prototype.activate.call(this);
        index2 = index ? index : this._index;
        this.select(index2);
    };

    Window_Selecting.prototype.makeCommandList = function(){
        varname;
        var used = getUsedStats();
        var usedx = getUsedXStats();
        var k;
        var mode = this._mode;
        for(i=0;i
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-10 19:16 , Processed in 0.138057 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表