| 赞 | 55 |
| VIP | |
| 好人卡 | |
| 积分 | 74 |
| 经验 | |
| 最后登录 | 2025-5-13 |
| 在线时间 | 948 小时 |
- 梦石
- 0
- 星屑
- 7427
- 在线时间
- 948 小时
- 注册时间
- 2017-9-27
- 回帖
- 566
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 梦想家大魔王 于 2017-10-29 21:36 编辑
代码里有一点小BUG,实测不影响使用,但既然发现了还是改一下好了。- //=============================================================================
- // SuTao_EquipToLearn.js
- //=============================================================================
- /*:
- * @plugindesc 装备特定武器、装备,在战斗中汲取一定经验后学会新技能。
- * @author sutao80216
- *
- * @param 汲取固定经验
- * @type select
- * @option 固定(默认值)
- * @value true
- * @option 不固定
- * @value false
- * @desc 无论战斗规模,每场战斗汲取的经验值固定。
- * true - 固定(默认);false - 不固定。
- * @default true
- *
- * @param 固定经验值
- * @type number
- * @min 0
- * @desc 每场战斗固定汲取的经验值。
- * 默认值:10
- * @default 10
- *
- * @param 经验值比例
- * @desc 汲取固定经验关闭时,汲取经验值与战斗经验的比例。它可
- * 以是浮点数或表达式,如this.level/10或0.1,this为装备者。
- * @default Math.ceil(this.mdf / 15) * 0.2
- *
- * @param 完成周目数变量ID
- * @type number
- * @min 0
- * @desc 保存已完成周目数的变量ID。
- * 默认值:1
- * @default 1
- *
- * @param 每周目增加可研习武功数量
- * @type number
- * @min 0
- * @desc 每完成一个周目,增加的可研习武功数量。
- * 默认值:1
- * @default 1
- *
- * @help
- * Version 1.0
- *
- * 建议配合YEP_ItemCore, YEP_EquipCore以及YEP_X_EquipRequirements来使用本插件。
- * 如果使用了上述插件,请将本插件置于它们之下。
- *
- * ================Notetag================
- * 适用于Weapon, Armor等可以装备到身上的物品。
- * <EquipToLearn: max_exp, skill_id, force_learn>
- * max_exp: 习得技能所需要之经验值总量,不可省略。
- * skill_id: 可以习得的技能之ID,不可省略。
- * force_learn: 是否可以重新学习曾经学会但被遗忘的技能,可省略。
- * 0 - 否(默认);1 - 是。
- * 【注意】如果输入了多条上述指令,仅有最顶部的一条生效。
- */
- var Imported = Imported || {};
- Imported.SuTao_EquipToLearn = true;
- var SuTao = SuTao || {};
- SuTao.ETL = SuTao.ETL || {};
- SuTao.ETL.version = 1.0;
- (function ($) {
- 'use strick';
- $.Paramaters = PluginManager.parameters('SuTao_EquipToLearn');
- $.Param = $.Param || {};
- $.Param.gainSolidExp = eval(String($.Paramaters['汲取固定经验'] || 'true'));
- $.Param.solidExp = Number($.Paramaters['固定经验值']) || 10;
- $.Param.expPercent = String($.Paramaters['经验值比例']);
- $.Param.circleCountId = Number($.Paramaters['完成周目数变量ID']) || 0;
- $.Param.maxCountPerCircle = Number($.Paramaters['每周目增加可研习武功数量']) || 0;
- //=============================================================================
- // DataManager
- //=============================================================================
- $.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function () {
- if (!$.DataManager_isDatabaseLoaded.call(this)) return false;
- if (!SuTao._loaded_EquipToLearn) {
- this.processEquipToLearnNotetags($dataWeapons);
- this.processEquipToLearnNotetags($dataArmors);
- SuTao._loaded_EquipToLearn = true;
- }
- return true;
- };
- DataManager.processEquipToLearnNotetags = function (group) {
- var regexp1 = /[ ]*<[ ]*EquipToLearn:[ ]*(\d+),[ ]*(\d+)[,]?[ ]*(\d+)?[ ]*>[ ]*/i;
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- var notedata = obj.note.split(/[\r\n]+/);
- // 初始化修炼信息
- obj.EquipToLearn = {
- 'max_exp': 0,
- 'skill_id': 0,
- 'force_learn': false
- };
- for (var i = 0; i < notedata.length; i++) {
- var line = notedata[i];
- if (line.match(regexp1)) {
- obj.EquipToLearn.max_exp = parseInt(RegExp.$1);
- obj.EquipToLearn.skill_id = parseInt(RegExp.$2);
- obj.EquipToLearn.force_learn = parseInt(RegExp.$3) > 0;
- // 一件装备只能修炼一个技能
- break;
- }
- }
- }
- };
- //=============================================================================
- // Game_Actor
- //=============================================================================
- $.Game_Actor_gainExp = Game_Actor.prototype.gainExp;
- Game_Actor.prototype.gainExp = function (exp) {
- // 先调用原始方法
- $.Game_Actor_gainExp.call(this, exp);
- var equip = {};
- this._expPercent = eval($.Param.expPercent) || 0.1;
- var _exp = $.Param.gainSolidExp ? $.Param.solidExp : exp * this._expPercent;
- var _ret = {};
- for (var i = 0; i < this._equips.length; i++) {
- // 如果装备栏是空的则下一个
- if (!this._equips[i].object()) continue;
- equip = this._equips[i].object();
- // 如果不是可修炼型装备则下一个
- if (equip.EquipToLearn.max_exp <= 0 || equip.EquipToLearn.skill_id <= 0) continue;
- // 更新修炼经验,如果经验积满则学习新技能
- _ret = this.updateEquipToLearns(equip, _exp);
- // 如果可以学习新技能,并且相关技能以前没有学习过或者可以重复学习,则可以学会新技能。
- // 有些秘籍被设置成不能重复修炼,是为了兼容
- // MrTS_SimpleSkillLeveling与SRD_SkillExtender这两个插件。
- if (_ret.canLearn && (!this._equipToLearns[_ret.id].learned || equip.EquipToLearn.force_learn)) {
- if (!this.isLearnedSkill(equip.EquipToLearn.skill_id)) {
- if (!!this._learnedCount) {
- // this._learnedCount++;
- } else {
- this._learnedCount = 0;
- }
- // 检查通过秘籍习得的技能数量是否达到当前周目的上限
- if ($.Param.circleCountId > 0 && $.Param.maxCountPerCircle > 0) {
- var _circle = $gameVariables.value($.Param.circleCountId);
- var _maxCount = 10 + $.Param.maxCountPerCircle * _circle;
- if (this._learnedCount < _maxCount) {
- this.learnSkill(equip.EquipToLearn.skill_id);
- this._learnedCount++;
- }
- } else if (this._learnedCount < 10) {
- this.learnSkill(equip.EquipToLearn.skill_id);
- this._learnedCount++;
- }
- }
- this._equipToLearns[_ret.id].learned = true;
- }
- }
- };
- // 参数item是具体类型的物品,如道具、武器、防具等,而非抽象的Game_Item
- // 参数exp是要更新(增长)的经验值
- Game_Actor.prototype.updateEquipToLearns = function (item, exp) {
- // 如果数组未声明则初始化之
- this._equipToLearns = this._equipToLearns || [];
- if (!!Imported.YEP_ItemCore) {
- // 兼容YEP_ItemCore引入的独立物品
- // 统统转换为基础物品
- item = DataManager.getBaseItem(item);
- }
- var _matchId = -1;
- var _canLearn = false;
- // 如果数组不空则会遍历之
- this._equipToLearns.every(function (obj, id) {
- // 如果已有相关记录
- if (obj.item.etypeId === item.etypeId && obj.item.id === item.id) {
- // 保存对应的序号
- _matchId = id;
- // 处理经验值
- obj.exp += exp;
- // 如果经验值已经积满
- if (obj.exp >= item.EquipToLearn.max_exp) {
- // 可以学习新技能了
- _canLearn = true;
- // 避免经验值溢出
- obj.exp = obj.item.EquipToLearn.max_exp;
- }
- // 中断遍历
- return false;
- }
- // 没有相关记录则继续遍历直至完成
- return true;
- }, this);
- // 序号没有变化,表示没找到相关记录
- if (_matchId < 0) {
- // 生成记录数据对象
- var obj = {};
- obj.item = item;
- obj.exp = Math.min(exp, item.EquipToLearn.max_exp);
- _canLearn = obj.exp >= item.EquipToLearn.max_exp;
- obj.learned = false;
- // 添加对象到数组
- _matchId = this._equipToLearns.push(obj) - 1;
- }
- // 返回装备相关记录在数组中的id,以及是否可学新技能
- return {
- 'id': _matchId,
- 'canLearn': _canLearn
- };
- };
- //=============================================================================
- // Window_EquipSlot
- //=============================================================================
- $.Window_EquipSlot_drawItem = Window_EquipSlot.prototype.drawItem;
- Window_EquipSlot.prototype.drawItem = function (index) {
- $.Window_EquipSlot_drawItem.call(this, index);
- if (this._actor) {
- var rect = this.itemRectForText(index);
- var _exp = 0;
- var _maxExp = 0;
- var _newText1 = ' %1\%';
- var _newText2 = ' %1\%';
- var _nameText = '';
- var _percent = 0;
- if (!!this._actor._equipToLearns) {
- var obj = {};
- var _itemEquip = {};
- for (var i = 0, len = this._actor._equipToLearns.length; i < len; i++) {
- if (!this._actor._equipToLearns[i]) continue;
- obj = this._actor._equipToLearns[i];
- _itemEquip = this._actor.equips()[index];
- if (!!Imported.YEP_ItemCore) {
- // 兼容YEP_ItemCore引入的独立物品
- // 统统转换为基础物品
- _itemEquip = DataManager.getBaseItem(_itemEquip);
- }
- if (_itemEquip && obj.item.etypeId === _itemEquip.etypeId && obj.item.id === _itemEquip.id) {
- _exp = obj.exp;
- _maxExp = obj.item.EquipToLearn.max_exp;
- _percent = _exp * 100 / _maxExp;
- if (_percent < 10) {
- _nameText = _newText1.format(_percent.toFixed(2));
- } else if (_percent < 100) {
- _nameText = _newText2.format(_percent.toFixed(2));
- } else {
- _nameText = '研习完毕';
- }
- break;
- }
- }
- }
- this.changePaintOpacity(this.isEnabled(index));
- if (_percent >= 100) {
- this.changeTextColor(this.textColor(13));
- } else {
- this.changeTextColor(this.textColor(24));
- }
- if (!!Imported.YEP_ItemCore) {
- // 启用了YEP_ItemCore.js,使用插件附带的装备显示界面
- // 此处第二个参数的修正量适用于1024x640大小的游戏窗口
- this.drawText(_nameText, rect.x + 372, rect.y, 96, this.lineHeight(), 'right');
- } else {
- // 没有启用YEP_ItemCore.js,使用默认的装备显示界面
- // 此处第二个参数的修正量适用于默认的816x624大小的游戏窗口
- this.drawText(_nameText, rect.x + 360, rect.y, 96, this.lineHeight(), 'right');
- }
- this.changePaintOpacity(true);
- this.changeTextColor(this.systemColor());
- }
- };
- })(SuTao.ETL);
复制代码
SuTao_EquipToLearn.7z
(3.49 KB, 下载次数: 340)
|
评分
-
查看全部评分
|