古树旋律 发表于 2023-5-17 15:18:35

技能拓展(冷却、使用代码、限制次数等)(不依靠YEP、MOG)



现在很多游戏都使用了YEP、VS等战斗系统,虽然功能强大,但”捆绑“也导致了各种冲突不断。这个插件有技能CD、限制次数、血量消耗等,以及可以通过在备注栏设置代码来提高多样性。具体使用方法贴在下面参考。

/*:
* @target MZ
* @plugindesc Extends Skills providing more options.
* @author Fomar0153
*
* @param Cooldown Text Colour
* @type integer
* @desc Enter a number that refers to the colour on the windoskin that you would like.
* @default 15
*
* @param Cooldown Abbreviation
* @type string
* @desc This will be displayed when a skill is on cooldown.
* @default CD
*
* @help Fomar0153_SkillExtension.js
* This plugin implements a series of notetags allowing you to customise skills.
*
* Notetags:
* <usable-rep: condition>
* This replaces the usable requirements with your condition, MP requirements etc
* will not need to be met in order for the skill to be usable.
* <usable-add: condition>
* This adds your condition to the usable requirements, MP requirements etc
* will still need to be met in order for the skill to be usable.
* <payment: code>
* This code will be executed when MP, TP would be deducted etc.
*
* <hpcost: n>
* Allows you to assign a HP cost to the skill.
*
* <preskill: code>
* This code runs just before the skill is used.
*
* <damage: code>
* This code runs during the damage calculation, value is a variable that holds
* the damage value.
*
* <postskill: code>
* This code runs just after the skill is used.
*
* <cooldown: n>
* This makes the skill have a cooldown between uses.
*
* <limited: n>
* The skill is only usable n times between the recover all event being called.
* <limitedbattle>
* Will make the skill only have limited uses per battle as opposed to the
* recover all event.
*
*/

值得注意的是,如果你的游戏中使用了其他可以消耗血量的技能插件,而且均是在备注栏书写hpcost的形式(包括Hp Cost、hp_cost之类的写法),在使用技能时会造成双倍的扣血。因为执行了两遍扣除操作。解决方法是 将此插件中所有的”hpcost“替换成其他的字符(比如”血量消耗“),如果想通过此插件来实现扣血效果,则在修改后,于备注栏填写<血量消耗: n>

古树旋律 发表于 2023-5-17 15:28:34

这段代码有趣的地方在于,它解除【冷却】【限制次数】的方式是通过清空数组来实现,并将这个功能复写在”完全恢复“中。


Game_BattlerBase.prototype.recoverAll = function() {
    Fomar.SkillExtension.Game_BattlerBase_recoverAll.call(this);
    this._cooldowns = {};
    this._limitedSkills = {};
};

如果想自由地恢复限制,我们可以自行追加一个函数,比如:
Game_BattlerBase.prototype.recoverSkillLimit = function() {
    this._cooldowns = {};
    this._limitedSkills = {};
};

function recover_skill_limit(){
        for(var i= $gameParty.size()-1;i>=0;i--){
                var actor_ID = $gameParty._actors;
                $gameActors.actor(actor_ID).recoverSkillLimit();
        }
}
想要恢复单个角色,只需要执行:$gameActors.actor(角色ID).recoverSkillLimit();
想要全部恢复,只需要执行:recover_skill_limit()

有了这个基础,就可以制作出诸如”瞬间清除CD、限制“之类的有趣操作。

pakcal 发表于 2023-6-17 23:43:54

感谢分享~

口袋精灵·红 发表于 2023-6-25 09:24:41

感谢分享 楼主辛苦了
页: [1]
查看完整版本: 技能拓展(冷却、使用代码、限制次数等)(不依靠YEP、MOG)