| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 15 |
| 经验 | |
| 最后登录 | 2026-10-1 |
| 在线时间 | 135 小时 |
- 梦石
- 0
- 星屑
- 1494
- 在线时间
- 135 小时
- 注册时间
- 2020-6-1
- 回帖
- 8
|
发表于 2025-2-12 14:16:27
|
显示全部楼层
这个功能很简单,基本上复制粘贴修改一下游戏框架的代码就能实现 现写了一个很简单的示例(没啥优化)
[pre lang="JavaScript" line="0" file="SkillPayCostGold.js"]//============================================================
// 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');
}
};
[/pre] |
|