じ☆ve冰风 发表于 2026-7-29 18:50:01

Speed Eval v1.2

Introduction
Allows the use of formulas to adjust the invocation speed of skills and items, and adjusting base speed formula.

How to use
Save it as APHO_SpeedEval.js and put it in your plugin folder.
If you are using YEP_BattleEngineCore.js, this needs to be placed below it.

Use the following notetags in your skills/items:
                JavaScript:       
<speed>
//Code goes here; perform operations on 'speed'.
</speed>

The code will be run after all the default speed calculations.
You can use 'a' to reference the user.


Examples
                JavaScript:       
<speed>
speed += a.atk;
</speed>

This will increase the invocation speed by the user's Attack.

                JavaScript:       
<speed>
speed = 0;
</speed>

This will set the invocation speed to 0, ignoring Agility or the invocation speed set in the editor.

The base speed can also be adjusted from the plugin parameter 'Base speed'.
By default, RMMV has some random variance added to base speed.
This plugin's default settings will remove the random variance.

Script
Spoiler: CODE                JavaScript:       
//==========================================
// APHO_SpeedEval.js
//==========================================
/*:
* @title Speed Eval
* @author Apho
* @plugindesc v1.1 Allows the use of formulas to adjust the invocation speed of skills and items, and adjusting base speed formula.
*
* @param Base speed
* @desc Formula to determine base speed.
* @default agi
* @help
*
* This plugin allows the developer to use evals to adjust the invocation speed
* of skills and items.
* To do so, use the following notetags in your skills/items:
*
* <speed>
* //Code goes here; perform operations on 'speed'.
* </speed>
*
* The code will be run after all the default speed calculations.
* You can use 'a' to reference the user.
*
* EXAMPLES:
* <speed>
* speed += a.atk;
* </speed>
* This will increase the invocation speed by the user's Attack.
*
* <speed>
* speed = 0;
* </speed>
* This will set the invocation speed to 0, ignoring Agility or the invocation
* speed set in the editor.
*
* The base speed can also be adjusted from the plugin parameter 'Base speed'.
* By default, RMMV has some random variance added to base speed.
* This plugin's default settings will remove the random variance.
*
* TERMS OF USE
* - Free for commercial and non-commercial use, as long as I get a free copy
*   of the game.
* - Edits allowed for personal use.
* - Do not repost or claim as your own, even if edited.
*
* VERSION HISTORY
* v1.1 - 2022/9/10 - Optimized code to improve compatibility with other plugins.
* v1.0 - 2022/9/9 - Initial release.
*/
var Apho = Apho || {};
Apho.SpeedEvalParams = PluginManager.parameters('APHO_SpeedEval');
Apho.SpeedEvalParams.BaseSpeed = Apho.SpeedEvalParams['Base speed'];

const AphoDataBaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function()
{
    AphoDataBaseLoaded.call(this);
    if (!AphoDataBaseLoaded.call(this)) return false;
    if (!Apho.SpeedEvalLoaded)
    {
      Apho.CheckSpeedEval($dataSkills);
      Apho.CheckSpeedEval($dataItems);
      Apho.SpeedEvalLoaded = true;
    }
    return true;
};

Apho.CheckSpeedEval = function(group)
{
    const SpeedEvalOpen = '<speed>';
    const SpeedEvalClose = '</speed>';
    for (var n = 1; n < group.length; n++)
    {
      var obj = group;
      var NoteData = obj.note.split(/[\r\n]+/);
      var ReadSpeedEval = false;
      obj.SpeedEval = '';
      for (var i = 0; i < NoteData.length; i++)
      {
            var line = NoteData;
            if (line.match(SpeedEvalOpen))
            {
                ReadSpeedEval = true;
            } else if (line.match(SpeedEvalClose))
            {
                ReadSpeedEval = false;
            }
            else if (ReadSpeedEval == true)
            {
                obj.SpeedEval = obj.SpeedEval + line + '\n';
            }
      }
    }
};

Game_Action.prototype.speed = function()
{
    var agi = this.subject().agi;
    var speed = eval(Apho.SpeedEvalParams.BaseSpeed);
    if (this.item())
    {
      speed += this.item().speed;
    }
    if (this.isAttack())
    {
      speed += this.subject().attackSpeed();
    }
    if(this.item().SpeedEval)
    {
      var a = this.subject();
      eval(this.item().SpeedEval);
    }
    return speed;
};


FAQ

Terms of use

[*]Free for commercial and non-commercial use, as long as I get a free copy of the game.
[*]Edits allowed for personal use.
[*]Do not repost or claim as your own, even if edited.
[*]Do not use for training AI models. This includes, but is not limited to, inputting the plugin contents or part thereof into AI models that train on user input.
Version history

[*]v1.2 - 2023/6/1 - Fixed a bug that caused incompatibility issues with other turn order display plugins.
[*]v1.1 - 2022/9/10 - Optimized code to improve compatibility with other plugins.
[*]v1.0 - 2022/9/9 - Initial release.



本贴来自国际rpgmaker官方论坛作者:AphoticAmaranth处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/speed-eval-v1-2.151183/
页: [1]
查看完整版本: Speed Eval v1.2