//============================================================
// SkillPayCostGold.js
//============================================================
var POG_SPCost = POG_SPCost || {};
POG_SPCost.FUNC = POG_SPCost.FUNC || {};
/*:
* @author Pogt
* @plugindesc 简单的技能消耗金钱插件
* @target MZ
* @help
* ============================================================================
* 介绍
* ============================================================================
* 该插件可用于指定一个技能消耗特定的金钱,如果金钱不足,将无法使用该技能
* 在技能的备注栏中加入:<GOLD:1>
* 代表使用该技能需要消耗1个单位的金钱
* 显示消耗金钱的数字将会以黄色呈现
*
* ============================================================================
* 修改内容
* ============================================================================
* 类Game_BattlerBase:
* 新增方法:
* skillGoldCost
* 重定义:
* canPaySkillCost
* paySkillCost
* 类ColorManager:
* 新增方法:
* GoldCostColor
* 窗口Window_SkillList:
* 重定义:
* drawSkillCost
*/
// 提取注释的内容
function matchcomment(comment){
// 定义正则表达式来匹配 <GOLD:数字>
const regex = /<GOLD:(\d+)>/;
// 使用正则表达式匹配并提取数字
var match = comment.match(regex);
if (match && match[1]) {
var GoldValue = match[1];
return GoldValue;
}
return 0;
}
// 获取金钱的消耗量
Game_BattlerBase.prototype.skillGoldCost = function(skill) {
var id = skill.id;
var cost = matchcomment($dataSkills[id].note);
return cost;
};
// 重定义:能否支付使用技能的消耗
POG_SPCost.FUNC.GBB_canPaySkillCost = Game_BattlerBase.prototype.canPaySkillCost;
Game_BattlerBase.prototype.canPaySkillCost = function(skill) {
if(!POG_SPCost.FUNC.GBB_canPaySkillCost.call(this,skill)){
return false;
}
if($gameParty._gold < this.skillGoldCost(skill)){
return false;
}
return true;
}
POG_SPCost.FUNC.GBB_paySkillCost = Game_BattlerBase.prototype.paySkillCost;
Game_BattlerBase.prototype.paySkillCost = function(skill) {
POG_SPCost.FUNC.GBB_paySkillCost.call(this,skill);
$gameParty.loseGold(this.skillGoldCost(skill));
};
// 消耗金钱用的颜色
ColorManager.GoldCostColor = function() {
return this.textColor(6);
};
// 重定义:绘画技能消耗量
POG_SPCost.FUNC.WSL_drawSkillCost = Window_SkillList.prototype.drawSkillCost;
Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
POG_SPCost.FUNC.WSL_drawSkillCost.call(this,skill, x, y, width);
if(this._actor.skillGoldCost(skill) > 0){
this.changeTextColor(ColorManager.GoldCostColor());
this.drawText(this._actor.skillGoldCost(skill), x - 35, y, width, 'right');
}
};