You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ycrpg/js/plugins/YEP_SkillLearnSystem.js

2461 lines
81 KiB
JavaScript

3 years ago
//=============================================================================
// Yanfly Engine Plugins - Skill Learn System
// YEP_SkillLearnSystem.js
//=============================================================================
var Imported = Imported || {};
Imported.YEP_SkillLearnSystem = true;
var Yanfly = Yanfly || {};
Yanfly.SLS = Yanfly.SLS || {};
Yanfly.SLS.version = 1.13;
//=============================================================================
/*:
3 years ago
* @plugindesc v1.13 技能学习系统
* @author Yanfly Engine Plugins
*
* @param ---魔改---
* @default
*
*
* @param IsHideLearnSkill
* @text 是否隐藏过学习技能
* @parent ---魔改---
* @type boolean
* @on YES
* @off NO
* @desc 控制学习过技能是否在学习系统界面中显示
* YES - true NO - false
* @default true
*
*
*
*
*
* @param ShowGoldWindowFormat
* @text 显示金币窗口的文本
* @desc 文本样式,其中%1会被替换为角色的JP值,%2会被替换为当前的金币数值,支持转义字符
* @default %1\c[1]JP\i[188] \c[0]%2\c[1]\i[313]
*
*
* @param ForgetNote
* @text 显示遗忘显示文本
* @type note
* @desc 这是显示遗忘的文本内容,支持多行显示
* @default "会遗忘所有的学习技能\n并返回全部的JP点!"
*
* @param ForgetCommandText
* @text 遗忘命令文本
* @type text
* @desc 此处可以设置命令的文本信息
* @default 一键遗忘
*
* @param ForgetYesText
* @text 遗忘确认文本
* @type text
* @desc 设置遗忘确认的文本内容
* @default 确认
*
* @param ForgetNoText
* @text 遗忘取消文本
* @type text
* @desc 设置遗忘取消的文本内容
* @default 取消
*
*
* @param ForgeItemID
* @text 遗忘道具ID
* @type item
* @desc 此处需要指定遗忘道具的ID,如果ID值为0,那么不启用这个功能,每次进行遗忘将会消耗一个遗忘道具
* @default 0
*
*
*
*
*
*
*
*
3 years ago
* @param ---命令---
* @default
*
* @param Learn Command
* @text 学习命令
* @desc How the command for learning skills appear in the skill
* command window.
* @default 学习技能
*
* @param Show Command
* @text 显示命令
* @desc Show the Learn command in the main menu by default?
* NO - false YES - true
* @default true
*
* @param Enable Command
* @text 启用命令
* @desc Enable the Learn command in the main menu by default?
* NO - false YES - true
* @default true
*
* @param Integrate
* @text 整合
* @desc Integrate Learn Skills into the Skill scene?
* NO - false YES - true
* @default false
*
* @param ---确认学习---
* @default
*
* @param Confirm Window
* @text 确认窗口
* @desc For non-integrated menu, show a learn confirmation?
* NO - false YES - true
* @default true
*
* @param Confirm Text
* @text 确认文本
* @desc If using the confirm window, this is the text used.
* %1 - Actor %2 - Skill Name
* @default %1 学习 %2
*
* @param Confirm Yes
* @text 确认是
* @desc Text used to display yes.
* @default 学习
*
* @param Confirm No
* @text 确认否
* @desc Text used to display no.
* @default 不学习
*
* @param ---技能学习---
* @default
*
* @param Learned Text
* @text 学习的文本
* @desc Text showing the skill has been learned.
* @default 学习
*
* @param Learned Size
* @text 学习的大小
* @desc Font size for the text showing the skill has been learned.
* Default: 28
* @default 20
*
* @param Learn Cost
* @text 学习费用
* @desc Text used to list what are the learn costs for the skill.
* @default 学习技能费用
*
* @param Cost Size
* @text 费用大小
* @desc Font size used for the cost of learning a skill.
* Default: 28
* @default 20
*
* @param Show Gold Window
* @text 显示金币窗口
* @desc Shows the gold window when learning a new skill.
* NO - false YES - true
* @default true
*
* @param ---默认---
* @default
*
* @param Default Gold Cost
* @text 默认金币费用
* @desc Default gold cost of learning new skills.
* @default 1000
*
* @param Default JP Cost
* @text 默认JP费用
* @desc Default JP cost of learning new skills.
* Requires YEP_JobPoints.js
* @default 100
*
* @help
*
* 魔改作者: 流逝的岁月
* 魔改版本: v1.02
*
*
*
*
*
* 魔改内容: v1.02 隐藏全部的已学习技能
* 魔改内容: v1.01 增加一键遗忘的功能
* 魔改内容: v1.00 将对界面进行调整
*
*
*
3 years ago
* ============================================================================
* Introduction
* ============================================================================
*
* 此插件可以让游戏中的角色在技能菜单中学习技能学习技能的代价可以
* 是金钱物品或所谓的职业点数Job Point它能够提供除了
* 升级以外的获得技能的可选方式
*
* Fox的JP职业点数等级这个插件向Yanfly的JP系统中添加了
* 等级概念就像最终幻想战略版中那样根据你当前职业的职业等级
* Job Level你可以在SkillLearnSystem中获取相应的技能也可以在
* ClassChangeCore中更换相应的业而职业等级只是通过增加JP来提高的
*
3 years ago
* 此插件可以通过YEP_JobPoints.js使用
* 在插件管理页面中我们建议把这个插件放在YEP_JobPoints.js的下面
*
* ============================================================================
* Notetags
* ============================================================================
*
* 通过下述注释来使用技能学习系统
*
* 职业的注释:
* <Learn Skill: x>
* <Learn Skill: x, x, x>
* <Learn Skill: x to y>
* 让此职业能够在菜单中学习技能x如果是第三种情形x to y
* 它允许职业学习从x到y的所有技能其中x和y是技能的ID
*
* 技能注释:
* <Learn Cost: x Gold>
* 设置学习此技能所要花费的金钱为x
*
* <Learn Cost: x JP>
* 设置学习此技能所要花费的JP为x
* 这一条需要YEP_JobPoints.js插件才能运行
*
3 years ago
* <Learn Cost> or <Learn Cost>
* Item x: y item name: y
* Weapon x: y item name: y
* Armor x: y </Learn Cost>
* </Learn Cost>
* 设置学习此技能所要花费的物品武器和防具其中x是物品的ID
* y是所需物品的数量如果你打算用物品的名称作为变量那么把
* item name换为物品在数据库中的名称但如果有多个物品的名称
* 相同那么将会使用ID最大的东西按照物品武器防具
* 的顺序作为费用
* *注意如果你在使用YEP_ItemCore.js插件及独立物品
* Independent Items那么学习费用将不包括那些独立物品
*
* <Learn Require Level: x>
* 角色等级到达x之后此技能才会出现在可学习技能的列表上
*
* <Learn Require Skill: x>
* <Learn Require Skill: x, x, x>
* <Learn Require Skill: x to y>
* 角色必须已经掌握其他技能x此技能才会出现在列表上如果是
* 第三种情形x to y角色必须已经掌握从x到y的所有技能
* 其中x和/或y是技能的ID
*
* <Learn Require Switch: x>
* <Learn Require Switch: x, x, x>
* <Learn Require Switch: x to y>
* 开关x必须已被打开此技能才会出现如果是第三种情形x to y
* 从x到y的所有开关必须已被打开技能才会出现其中x和/或y是开关的ID
*
* ============================================================================
* 疯狂模式自定义要求和花费
* ============================================================================
*
* 如果你只有很少的JavaScript使用经验并且希望更好地定做技能学习的
* 方法那么你可以用下列注释
*
* 技能的注释
*
* <Learn Show Eval>
* value = true;
* value = false;
* </Learn Show Eval>
* 如果想用一串代码来隐藏或显示此技能你可以使用这些注释
* 返回value的值为true那么即使其它要求不被满足技能也会出现
* 在列表上而若返回value的值为false那么即使其它
* 要求被满足技能也不会出现
*
3 years ago
* <Learn Require Eval>
* value = true;
* value = false;
* </Learn Require Eval>
* 给希望通过代码设置自己特定的技能学习要求的人使用只有返回
* value的值为true技能才会显示为可学的请避免使用可以停止
* 后续代码工作的命令code.
*
* <Learn Cost Eval>
* code
* code
* </Learn Cost Eval>
* 如果你熟悉JavaScript你可以在通过学习技能菜单
* 学习技能之后自定义一些功能
*
3 years ago
* <Learn Custom Text>
* text
* text
* </Learn Custom Text>
* 在主要花费的下面显示自定义文字可以在这里使用文本代码
*
* ============================================================================
* Lunatic Mode - Custom JP Costs
* ============================================================================
*
* For those who have basic JavaScript knowledge and would like to make the JP
* costs for skills dynamic, you can use the following notetags:
*
* Skill Notetags:
*
* <Custom Learn JP Cost>
* cost = user.level * 100;
* </Custom Learn JP Cost>
* The 'cost' variable is the value that will be returned as a result of this
* Lunatic Mode notetag. The value returned here from this code will be added
* on top of the <Learn Cost: x JP> value.
*
* ============================================================================
* Plugin Commands 插件命令
* ============================================================================
*
* 可以从事件编辑器Event Editor中使用下列插件命令来确定
* 你是否想让学习技能命令出现在技能界面以使之可行
*
* Plugin Command:
* ShowLearnSkill 显示学习技能命令
* HideLearnSkill 隐藏学习技能命令
* EnableLearnSkill 使学习技能命令可行
* DisableLearnSkill 使学习技能命令不可行
* OpenLearnSkill actor x 为角色x打开学习技能菜单
* OpenLearnSkill party x 为队伍成员x打开学习技能菜单
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.13:
* - Lunatic Mode fail safes added.
*
* Version 1.12:
* - Updated for RPG Maker MV version 1.3.2.
*
* Version 1.11:
* - Removed dependency on YEP_JobPoints.js if using Integrated skill learn.
*
* Version 1.10:
* - Added <Custom Learn JP Cost> Lunatic Mode notetag. Look in the plugin's
* helpfile for more details!
*
* Version 1.09:
* - Compatibility update with Class Change Core's <Use Nickname> notetag.
*
* Version 1.08:
* - Updated for RPG Maker MV version 1.1.0.
*
* Version 1.07:
* - Updated the <Learn Require Level: x> notetag. If you are using the Class
* Change Core, the requirement will now depend on the level of the class.
*
* Version 1.06b:
* - Added 'Confirm Window', 'Confirm Text', 'Confirm Yes', 'Confirm No' to the
* plugin's parameters. This confirm window only appears for non-integrated
* menus as the integrated menus have a class confirmation window already.
* - Confirm Text now supports text codes.
* - Fixed a visual bug when learning skills.
*
* Version 1.05:
* - Fixed a bug with the 'OpenLearnSkill party x' plugin command not opening
* the correct party member.
*
* Version 1.04:
* - Fixed a bug that would duplicate non-independent items.
* - Fixed a bug with class portraits not updating properly.
*
* Version 1.03a:
* - Fixed a bug where JP values weren't updated upon learning.
* - Fixed a bug where the help description didn't update if a skill vanished.
*
* Version 1.02:
* - Reversed the display for item requirements so it is now Held/Needed.
* - Preparations for compatibility for Class Change Core.
*
* Version 1.01:
* - Added an actor refresh to learn and forget skills.
*
* Version 1.00:
* - Finished Plugin!
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
Yanfly.Parameters = PluginManager.parameters("YEP_SkillLearnSystem");
3 years ago
Yanfly.Param = Yanfly.Param || {};
var Zzy = Zzy || {};
Zzy.CYSLS = Zzy.CYSLS || {};
Zzy.CYSLS.Command_F = 'zzycyslsf';//遗忘
Zzy.CYSLS.ShowGoldWindowFormat = Yanfly.Parameters['ShowGoldWindowFormat'] ? String(Yanfly.Parameters['ShowGoldWindowFormat']) : '%1\\c[1]JP\\i[188] \\c[0]%2\\c[1]金\\i[313]';
Zzy.CYSLS.ForgetNote = Yanfly.Parameters['ForgetNote'] ? JSON.parse(Yanfly.Parameters['ForgetNote']) : '';
Zzy.CYSLS.ForgetCommandText = String(Yanfly.Parameters['ForgetCommandText'] || '一键遗忘');
Zzy.CYSLS.ForgetYesText = String(Yanfly.Parameters['ForgetYesText'] || '确认');
Zzy.CYSLS.ForgetNoText = String(Yanfly.Parameters['ForgetNoText'] || '取消');
Zzy.CYSLS.ForgeItemID = parseInt(Yanfly.Parameters['ForgeItemID'] || 0);
Zzy.CYSLS.IsHideLearnSkill = eval(Yanfly.Parameters['IsHideLearnSkill'] || true);
Yanfly.Param.SLSCommand = String(Yanfly.Parameters["Learn Command"]);
Yanfly.Param.SLSShowLearn = String(Yanfly.Parameters["Show Command"]);
3 years ago
Yanfly.Param.SLSShowLearn = eval(Yanfly.Param.SLSShowLearn);
Yanfly.Param.SLSEnableLearn = String(Yanfly.Parameters["Enable Command"]);
3 years ago
Yanfly.Param.SLSEnableLearn = eval(Yanfly.Param.SLSEnableLearn);
Yanfly.Param.SLSIntegrate = String(Yanfly.Parameters["Integrate"]);
3 years ago
Yanfly.Param.SLSIntegrate = eval(Yanfly.Param.SLSIntegrate);
Yanfly.Param.SLSConfirmWin = eval(String(Yanfly.Parameters["Confirm Window"]));
Yanfly.Param.SLSConfirmText = String(Yanfly.Parameters["Confirm Text"]);
Yanfly.Param.SLSConfirmYes = String(Yanfly.Parameters["Confirm Yes"]);
Yanfly.Param.SLSConfirmNo = String(Yanfly.Parameters["Confirm No"]);
Yanfly.Param.SLSLearnText = String(Yanfly.Parameters["Learned Text"]);
Yanfly.Param.SLSLearnSize = Number(Yanfly.Parameters["Learned Size"]);
Yanfly.Param.SLSLearnCost = String(Yanfly.Parameters["Learn Cost"]);
Yanfly.Param.SLSCostSize = Number(Yanfly.Parameters["Cost Size"]);
Yanfly.Param.SLSItemCostFmt = String(Yanfly.Parameters["Item Cost"]);
Yanfly.Param.SLSGoldWindow = String(Yanfly.Parameters["Show Gold Window"]);
3 years ago
Yanfly.Param.SLSGoldWindow = eval(Yanfly.Param.SLSGoldWindow);
Yanfly.Param.SLSDefaultGold = Number(Yanfly.Parameters["Default Gold Cost"]);
Yanfly.Param.SLSDefaultJp = Number(Yanfly.Parameters["Default JP Cost"]);
3 years ago
//=============================================================================
// DataManager
//=============================================================================
Yanfly.SLS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function () {
if (!Yanfly.SLS.DataManager_isDatabaseLoaded.call(this)) return false;
if (!Yanfly._loaded_YEP_SkillLearnSystem) {
this.processSLSNotetagsI($dataItems);
this.processSLSNotetagsW($dataWeapons);
this.processSLSNotetagsA($dataArmors);
this.processSLSNotetags1($dataClasses);
this.processSLSNotetags2($dataSkills);
Yanfly._loaded_YEP_SkillLearnSystem = true;
3 years ago
}
return true;
};
DataManager.processSLSNotetagsI = function (group) {
if (Yanfly.ItemIdRef) return;
Yanfly.ItemIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group[n];
if (obj.name.length <= 0) continue;
Yanfly.ItemIdRef[obj.name.toUpperCase()] = n;
}
};
DataManager.processSLSNotetagsW = function (group) {
if (Yanfly.WeaponIdRef) return;
Yanfly.WeaponIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group[n];
if (obj.name.length <= 0) continue;
Yanfly.WeaponIdRef[obj.name.toUpperCase()] = n;
}
};
DataManager.processSLSNotetagsA = function (group) {
if (Yanfly.ArmorIdRef) return;
Yanfly.ArmorIdRef = {};
for (var n = 1; n < group.length; n++) {
var obj = group[n];
if (obj.name.length <= 0) continue;
Yanfly.ArmorIdRef[obj.name.toUpperCase()] = n;
}
};
DataManager.processSLSNotetags1 = function (group) {
var note1 = /<(?:LEARN SKILL|learn skills):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
var note2 = /<(?:LEARN SKILL|learn skills):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
obj.learnSkills = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata[i];
if (line.match(note1)) {
var array = JSON.parse("[" + RegExp.$1.match(/\d+/g) + "]");
obj.learnSkills = obj.learnSkills.concat(array);
} else if (line.match(note2)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1), parseInt(RegExp.$2));
obj.learnSkills = obj.learnSkills.concat(range);
}
}
}
};
DataManager.processSLSNotetags2 = function (group) {
var note1 = /<(?:LEARN COST)>/i;
var note2 = /<\/(?:LEARN COST)>/i;
var note3 = /<(?:LEARN COST):[ ](\d+)[ ](?:GOLD)>/i;
var note4 = /<(?:LEARN COST):[ ](\d+)[ ](?:JP)>/i;
var note5 = /<(?:LEARN REQUIRE LEVEL):[ ](\d+)>/i;
var note6 = /<(?:LEARN REQUIRE SKILL):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
var note7 = /<(?:LEARN REQUIRE SKILL):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
var note8 = /<(?:LEARN REQUIRE SWITCH):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
var note9 = /<(?:LEARN REQUIRE SWITCH):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
var note10 = /<(?:LEARN REQUIRE EVAL)>/i;
var note11 = /<\/(?:LEARN REQUIRE EVAL)>/i;
var note12 = /<(?:LEARN COST EVAL)>/i;
var note13 = /<\/(?:LEARN COST EVAL)>/i;
var note14 = /<(?:LEARN CUSTOM TEXT)>/i;
var note15 = /<\/(?:LEARN CUSTOM TEXT)>/i;
var note16 = /<(?:LEARN SHOW EVAL)>/i;
var note17 = /<\/(?:LEARN SHOW EVAL)>/i;
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
obj.learnCost = [];
obj.learnCostGold = Yanfly.Param.SLSDefaultGold;
obj.learnCostJp = Yanfly.Param.SLSDefaultJp;
obj.learnRequireLevel = 0;
obj.learnRequireSkill = [];
obj.learnRequireSwitch = [];
obj.learnRequireEval = "";
obj.learnCostEval = "";
obj.learnShowEval = "";
obj.learnCustomText = "";
var mode = "none";
obj.customLearnJpCostEval = "";
for (var i = 0; i < notedata.length; i++) {
var line = notedata[i];
if (line.match(note1)) {
mode = "learn";
} else if (line.match(note2)) {
mode = "none";
} else if (mode === "learn") {
this.addLearnSkillCost(obj, line);
} else if (line.match(note3)) {
obj.learnCostGold = parseInt(RegExp.$1);
} else if (line.match(note4)) {
obj.learnCostJp = parseInt(RegExp.$1);
} else if (line.match(note5)) {
obj.learnRequireLevel = parseInt(RegExp.$1);
} else if (line.match(note6)) {
var array = JSON.parse("[" + RegExp.$1.match(/\d+/g) + "]");
obj.learnRequireSkill = obj.learnRequireSkill.concat(array);
} else if (line.match(note7)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1), parseInt(RegExp.$2));
obj.learnRequireSkill = obj.learnRequireSkill.concat(range);
} else if (line.match(note8)) {
var array = JSON.parse("[" + RegExp.$1.match(/\d+/g) + "]");
obj.learnRequireSwitch = obj.learnRequireSwitch.concat(array);
} else if (line.match(note9)) {
var range = Yanfly.Util.getRange(parseInt(RegExp.$1), parseInt(RegExp.$2));
obj.learnRequireSwitch = obj.learnRequireSwitch.concat(range);
} else if (line.match(note10)) {
mode = "learnRequireEval";
} else if (line.match(note11)) {
mode = "none";
} else if (line.match(note12)) {
mode = "learnCostEval";
} else if (line.match(note13)) {
mode = "none";
} else if (line.match(note14)) {
mode = "learnCustomText";
} else if (line.match(note15)) {
mode = "none";
} else if (line.match(note16)) {
mode = "learnShowEval";
} else if (line.match(note17)) {
mode = "none";
} else if (mode === "learnRequireEval") {
obj.learnRequireEval = obj.learnRequireEval + line + "\n";
} else if (mode === "learnCostEval") {
obj.learnCostEval = obj.learnCostEval + line + "\n";
} else if (mode === "learnCustomText") {
obj.learnCustomText = obj.learnCustomText + line + "\n";
} else if (mode === "learnShowEval") {
obj.learnShowEval = obj.learnShowEval + line + "\n";
} else if (line.match(/<(?:CUSTOM LEARN JP COST)>/i)) {
mode = "customLearnJpCost";
} else if (line.match(/<\/(?:CUSTOM LEARN JP COST)>/i)) {
mode = "none";
} else if (mode === "customLearnJpCost") {
obj.customLearnJpCostEval = obj.customLearnJpCostEval + line + "\n";
}
}
3 years ago
}
};
DataManager.addLearnSkillCost = function (obj, line) {
3 years ago
if (!obj) return;
if (!line) return;
if (line.match(/ITEM[ ](\d+):[ ](\d+)/i)) {
var item = $dataItems[parseInt(RegExp.$1)];
3 years ago
if (!item) return;
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) return;
obj.learnCost.push(line);
} else if (line.match(/WEAPON[ ](\d+):[ ](\d+)/i)) {
var item = $dataWeapons[parseInt(RegExp.$1)];
3 years ago
if (!item) return;
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) return;
obj.learnCost.push(line);
} else if (line.match(/ARMOR[ ](\d+):[ ](\d+)/i)) {
var item = $dataArmors[parseInt(RegExp.$1)];
3 years ago
if (!item) return;
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) return;
obj.learnCost.push(line);
} else if (line.match(/GOLD:[ ](\d+)/i)) {
obj.learnCostGold = parseInt(RegExp.$1);
} else if (line.match(/JP:[ ](\d+)/i)) {
obj.learnCostJp = parseInt(RegExp.$1);
} else if (line.match(/(.*):[ ](\d+)/i)) {
var name = String(RegExp.$1).toUpperCase();
var amount = parseInt(RegExp.$2);
if (Yanfly.ItemIdRef[name]) {
var id = Yanfly.ItemIdRef[name];
var item = $dataItems[id];
if (!item) return;
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) return;
obj.learnCost.push("ITEM " + id + ": " + amount);
} else if (Yanfly.WeaponIdRef[name]) {
var id = Yanfly.WeaponIdRef[name];
var item = $dataWeapons[id];
if (!item) return;
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) return;
obj.learnCost.push("WEAPON " + id + ": " + amount);
} else if (Yanfly.ArmorIdRef[name]) {
var id = Yanfly.ArmorIdRef[name];
var item = $dataArmors[id];
if (!item) return;
if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) return;
obj.learnCost.push("ARMOR " + id + ": " + amount);
}
3 years ago
}
};
//=============================================================================
// Game_System
//=============================================================================
Yanfly.SLS.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () {
3 years ago
Yanfly.SLS.Game_System_initialize.call(this);
this.initSkillLearnSystem();
};
Game_System.prototype.initSkillLearnSystem = function () {
3 years ago
this._showLearnSkill = Yanfly.Param.SLSShowLearn;
this._enableLearnSkill = Yanfly.Param.SLSEnableLearn;
};
Game_System.prototype.isShowLearnSkill = function () {
3 years ago
if (this._showLearnSkill === undefined) this.initSkillLearnSystem();
return this._showLearnSkill;
};
Game_System.prototype.isEnableLearnSkill = function () {
3 years ago
if (this._enableLearnSkill === undefined) this.initSkillLearnSystem();
return this._enableLearnSkill;
};
//=============================================================================
// Game_Actor
//=============================================================================
Game_Actor.prototype.availableClasses = function () {
3 years ago
if (!Imported.YEP_ClassChangeCore) return 1;
return this.unlockedClasses().length;
};
Game_Actor.prototype.sufficientJpLearnSkill = function (skill, classId) {
if (!skill) return false;
if (!Imported.YEP_JobPoints) return true;
var jpCost = skill.learnCostJp;
jpCost += this.customLearnSkillJpCost(skill);
if (this.currentClass().learnSkills.contains(skill.id)) {
if (this.jp(classId) >= jpCost) return true;
3 years ago
}
if (Imported.YEP_ClassChangeCore && Yanfly.Param.SLSIntegrate) {
for (var i = 0; i < this.unlockedClasses().length; ++i) {
classId = this.unlockedClasses()[i];
if (!$dataClasses[classId]) continue;
if (!$dataClasses[classId].learnSkills.contains(skill.id)) continue;
if (this.jp(classId) >= jpCost) return true;
}
} else if (Imported.YEP_ClassChangeCore && $dataClasses[classId]) {
if ($dataClasses[classId].learnSkills.contains(skill.id)) {
if (this.jp(classId) >= jpCost) return true;
}
3 years ago
}
return false;
3 years ago
};
Game_Actor.prototype.isLearnedSkillRaw = function (skillId) {
return this._skills.contains(skillId);
3 years ago
};
Game_Actor.prototype.canLearnSkill = function (skill, classId) {
3 years ago
if (!skill) return false;
if (skill.learnCostGold > $gameParty.gold()) return false;
if (!this.sufficientJpLearnSkill(skill, classId)) return false;
if (!$gameParty.sufficientItemLearnSkill(skill)) return false;
return true;
};
Yanfly.SLS.Game_Actor_releaseUnequippableItems = Game_Actor.prototype.releaseUnequippableItems;
Game_Actor.prototype.releaseUnequippableItems = function (forcing) {
3 years ago
if (Yanfly.SLS.PreventReleaseItem) return;
Yanfly.SLS.Game_Actor_releaseUnequippableItems.call(this, forcing);
};
Game_Actor.prototype.customLearnSkillJpCost = function (skill) {
3 years ago
if (!skill) return 0;
if (skill.customLearnJpCostEval === "") return 0;
3 years ago
var cost = 0;
var item = skill;
var a = this;
var b = this;
var user = this;
var target = this;
var s = $gameSwitches._data;
var v = $gameVariables._data;
var code = skill.customLearnJpCostEval;
try {
eval(code);
3 years ago
} catch (e) {
Yanfly.Util.displayError(e, code, "CUSTOM SKILL LEARN JP COST ERROR");
3 years ago
}
return cost;
};
//=============================================================================
// Game_Party
//=============================================================================
Game_Party.prototype.sufficientItemLearnSkill = function (skill) {
3 years ago
if (!skill) return false;
for (var i = 0; i < skill.learnCost.length; ++i) {
var line = skill.learnCost[i];
var obj = null;
var value = 0;
if (line.match(/ITEM[ ](\d+):[ ](\d+)/i)) {
obj = $dataItems[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
} else if (line.match(/WEAPON[ ](\d+):[ ](\d+)/i)) {
obj = $dataWeapons[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
} else if (line.match(/ARMOR[ ](\d+):[ ](\d+)/i)) {
obj = $dataArmors[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
}
if (!obj) continue;
if (value > $gameParty.numItems(obj)) return false;
3 years ago
}
return true;
};
Game_Party.prototype.processLearnSkillCost = function (skill) {
3 years ago
if (!skill) return false;
for (var i = 0; i < skill.learnCost.length; ++i) {
var line = skill.learnCost[i];
var obj = null;
var value = 0;
if (line.match(/ITEM[ ](\d+):[ ](\d+)/i)) {
obj = $dataItems[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
} else if (line.match(/WEAPON[ ](\d+):[ ](\d+)/i)) {
obj = $dataWeapons[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
} else if (line.match(/ARMOR[ ](\d+):[ ](\d+)/i)) {
obj = $dataArmors[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
}
if (!obj) continue;
$gameParty.loseItem(obj, value, false);
3 years ago
}
return true;
};
Yanfly.SLS.Game_Party_setupBattleTest = Game_Party.prototype.setupBattleTest;
Game_Party.prototype.setupBattleTest = function () {
3 years ago
Yanfly.SLS.Game_Party_setupBattleTest.call(this);
this.setupLearnSkillBattleTest();
};
Game_Party.prototype.setupLearnSkillBattleTest = function () {
3 years ago
for (var i = 0; i < this.members().length; ++i) {
var actor = this.members()[i];
if (!actor) continue;
var classData = actor.currentClass();
for (var j = 0; j < classData.learnSkills.length; ++j) {
var skillId = classData.learnSkills[j];
if (!$dataSkills[skillId]) continue;
if ($dataSkills[skillId].name === "") continue;
actor.learnSkill(skillId);
}
actor.refresh();
3 years ago
}
};
//=============================================================================
// Game_Interpreter
//=============================================================================
Yanfly.SLS.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
Yanfly.SLS.Game_Interpreter_pluginCommand.call(this, command, args);
if (command === "ShowLearnSkill") $gameSystem._showLearnSkill = true;
if (command === "HideLearnSkill") $gameSystem._showLearnSkill = false;
if (command === "EnableLearnSkill") $gameSystem._enableLearnSkill = true;
if (command === "DisableLearnSkill") $gameSystem._enableLearnSkill = false;
if (command === "OpenLearnSkill") this.openLearnSkill(args);
3 years ago
};
Game_Interpreter.prototype.openLearnSkill = function (args) {
3 years ago
if ($gameParty.inBattle()) return;
if (!args) return;
if (!args[0]) return;
if (args[0].toLowerCase() === "actor") {
var actorId = parseInt(args[1]);
var actor = $gameActors.actor(actorId);
} else if (args[0].toLowerCase() === "party") {
var index = parseInt(args[1]) - 1;
index = index.clamp(0, $gameParty.members().length - 1);
var actor = $gameParty.members()[index];
3 years ago
} else {
return;
3 years ago
}
ImageManager.loadFace(actor.faceName());
this.loadPartyFaces();
$gameParty.setMenuActor(actor);
SceneManager.push(Scene_LearnSkill);
};
Game_Interpreter.prototype.loadPartyFaces = function () {
3 years ago
for (var i = 0; i < $gameParty.members().length; ++i) {
var actor = $gameParty.members()[i];
if (actor) ImageManager.loadFace(actor.faceName());
3 years ago
}
};
//=============================================================================
// Window_SkillType
//=============================================================================
Yanfly.SLS.Window_SkillType_makeCommandList = Window_SkillType.prototype.makeCommandList;
Window_SkillType.prototype.makeCommandList = function () {
3 years ago
Yanfly.SLS.Window_SkillType_makeCommandList.call(this);
if (this.findExt("learnSkills") === -1) this.addLearnSkillsCommand();
3 years ago
};
Window_SkillType.prototype.addLearnSkillsCommand = function () {
3 years ago
if (!$gameSystem.isShowLearnSkill()) return;
var name = Yanfly.Param.SLSCommand;
var enabled = $gameSystem.isEnableLearnSkill();
this.addCommand(name, "skill", enabled, "learnSkills");
3 years ago
};
Window_SkillType.prototype.setClassListWindow = function (classWindow) {
3 years ago
this._classListWindow = classWindow;
};
Window_SkillType.prototype.setSkillLearnWindow = function (learnWindow) {
3 years ago
this._skillLearnWindow = learnWindow;
};
Window_SkillType.prototype.setGoldWindow = function (goldWindow) {
3 years ago
this._goldWindow = goldWindow;
};
Window_SkillType.prototype.setSkillLearnDataWindow = function (learnDataWindow) {
3 years ago
this._skillLearnDataWindow = learnDataWindow;
this.update();
};
Yanfly.SLS.Window_SkillType_update = Window_SkillType.prototype.update;
Window_SkillType.prototype.update = function () {
if (this.currentExt() === "learnSkills" && this._actor) {
Window_Command.prototype.update.call(this);
if (this.isSkillLearnIntegrated()) {
this._classListWindow.show();
} else if (this._skillLearnWindow) {
this._skillLearnWindow.show();
}
this._skillWindow.hide();
if (this._goldWindow) this._goldWindow.show();
this._skillLearnDataWindow.show();
3 years ago
} else {
Yanfly.SLS.Window_SkillType_update.call(this);
this._skillWindow.show();
if (this._classListWindow) this._classListWindow.hide();
if (this._skillLearnWindow) this._skillLearnWindow.hide();
if (this._goldWindow) this._goldWindow.hide();
if (this._skillLearnDataWindow) this._skillLearnDataWindow.hide();
3 years ago
}
};
Window_SkillType.prototype.isSkillLearnIntegrated = function () {
3 years ago
if (!this._classListWindow) return false;
if (this._actor.availableClasses() <= 1) return false;
return Yanfly.Param.SLSIntegrate;
};
//=============================================================================
// Window_SkillLearn
//=============================================================================
function Window_SkillLearn() {
this.initialize.apply(this, arguments);
}
Window_SkillLearn.prototype = Object.create(Window_SkillList.prototype);
Window_SkillLearn.prototype.constructor = Window_SkillLearn;
Window_SkillLearn.prototype.maxCols = function () {
3 years ago
return 1;
};
Window_SkillLearn.prototype.setActor = function (actor) {
3 years ago
if (this._actor === actor) return;
this.contents.clear();
this.setClass(null);
this._actor = actor;
this.refresh();
this.resetScroll();
this.setClass(this._actor.currentClass().id);
};
Window_SkillLearn.prototype.setClass = function (classId) {
3 years ago
if (this._classId === classId) return;
this._classId = classId;
this.makeItemList();
this.refresh();
};
Window_SkillLearn.prototype.getClass = function () {
3 years ago
return $dataClasses[this._classId];
};
Window_SkillLearn.prototype.makeItemList = function () {
3 years ago
if (this._actor && this.getClass()) {
this.createSkillLearnData();
3 years ago
} else {
this._data = [];
3 years ago
}
};
Window_SkillLearn.prototype.createSkillLearnData = function () {
3 years ago
this._data = [];
for (var i = 0; i < this.getClass().learnSkills.length; ++i) {
var skillId = this.getClass().learnSkills[i];
var skill = $dataSkills[skillId];
if(Zzy.CYSLS.IsHideLearnSkill)//---魔改--- v1.02 隐藏全部的已学习技能
{
if (skill && this.includes(skill) && !this._actor.isLearnedSkill(skillId)) this._data.push(skill);
}
else
{
if (skill && this.includes(skill)) this._data.push(skill);
}
3 years ago
}
this._data = this._data.sort(function (a, b) {
return a.id - b.id;
});
3 years ago
this._data = this._data.filter(Yanfly.Util.onlyUnique);
;
3 years ago
};
Window_SkillLearn.prototype.includes = function (skill) {
if (skill.name === "") return false;
3 years ago
if (!this.meetsRequirements(skill)) return false;
return true;
};
Window_SkillLearn.prototype.meetsRequirements = function (skill) {
3 years ago
var evalValue = this.getEvalLine(skill.learnShowEval);
if (evalValue !== undefined) return evalValue;
if (Imported.YEP_ClassChangeCore) {
var classLevel = this._actor.classLevel(this._classId);
if (skill.learnRequireLevel > classLevel) return false;
3 years ago
} else {
if (skill.learnRequireLevel > this._actor.level) return false;
3 years ago
}
for (var i = 0; i < skill.learnRequireSkill.length; ++i) {
var skillId = skill.learnRequireSkill[i];
if (!$dataSkills[skillId]) continue;
if (!this._actor.isLearnedSkillRaw(skillId)) return false;
3 years ago
}
for (var i = 0; i < skill.learnRequireSwitch.length; ++i) {
var switchId = skill.learnRequireSwitch[i];
if (!$gameSwitches.value(switchId)) return false;
3 years ago
}
return true;
};
Window_SkillLearn.prototype.isEnabled = function (item) {
3 years ago
if (!this._actor) return false;
if (!item) return false;
if (this._actor.isLearnedSkillRaw(item.id)) return false;
if ($gamePlayer.isDebugThrough()) return true;
if (!this._actor.canLearnSkill(item, this._classId)) return false;
if (!this.meetsRequirements(item)) return false;
var evalValue = this.getEvalLine(item.learnRequireEval);
if (evalValue !== undefined) return evalValue;
return true;
};
Window_SkillLearn.prototype.getEvalLine = function (evalLine) {
3 years ago
if (evalLine.length <= 0) return undefined;
var value = undefined;
var a = this._actor;
var user = this._actor;
var subject = this._actor;
var s = $gameSwitches._data;
var v = $gameVariables._data;
var code = evalLine;
try {
eval(code);
3 years ago
} catch (e) {
Yanfly.Util.displayError(e, code, "SKILL LEARN EVAL LINE ERROR");
3 years ago
}
return value;
};
Window_SkillLearn.prototype.drawItem = function (index) {
3 years ago
var skill = this._data[index];
if (!skill) return;
var rect = this.itemRect(index);
rect.width -= this.textPadding();
this.changePaintOpacity(this.isEnabled(skill));
this.drawItemName(skill, rect.x, rect.y, rect.width);
this.drawItemLearned(skill, rect.x, rect.y, rect.width);
this.changePaintOpacity(true);
};
Window_SkillLearn.prototype.drawItemLearned = function (skill, wx, wy, ww) {
3 years ago
if (!this._actor.isLearnedSkillRaw(skill.id)) {
this.drawSkillCost(skill, wx, wy, ww);
return;
3 years ago
}
var text = Yanfly.Param.SLSLearnText;
this.contents.fontSize = Yanfly.Param.SLSLearnSize;
this.drawText(text, wx, wy, ww, "right");
3 years ago
this.resetFontSettings();
};
Window_SkillLearn.prototype.setDataWindow = function (learnDataWindow) {
3 years ago
this._skillLearnDataWindow = learnDataWindow;
this.update();
};
Window_SkillLearn.prototype.update = function () {
3 years ago
Window_SkillList.prototype.update.call(this);
if (this._skillLearnDataWindow && this.item()) {
this._skillLearnDataWindow.setSkill(this.item());
if (this._classId) this._skillLearnDataWindow.setClass(this._classId);
3 years ago
}
};
//=============================================================================
// Window_SkillLearnClass
//=============================================================================
if (Imported.YEP_ClassChangeCore) {
function Window_SkillLearnClass() {
this.initialize.apply(this, arguments);
}
3 years ago
Window_SkillLearnClass.prototype = Object.create(Window_ClassList.prototype);
Window_SkillLearnClass.prototype.constructor = Window_SkillLearnClass;
Window_SkillLearnClass.prototype.initialize = function (x, y, width, height) {
Window_ClassList.prototype.initialize.call(this, x, y, width, height);
this._skill = null;
};
Window_SkillLearnClass.prototype.setSkill = function (skill) {
if (this._skill === skill) return;
this._skill = skill;
this.refresh();
this.resetScroll();
};
Window_SkillLearnClass.prototype.makeItemList = function () {
if (this._actor && this._skill) {
this._data = [];
for (var i = 0; i < this._actor.unlockedClasses().length; ++i) {
var classId = this._actor.unlockedClasses()[i];
var item = $dataClasses[classId];
if (!item) continue;
if (item.learnSkills.contains(this._skill.id)) {
this._data.push(classId);
}
}
} else {
this._data = [];
}
this._data.sort(function (a, b) {
return a - b;
});
};
3 years ago
Window_SkillLearnClass.prototype.isEnabled = function (classId) {
if (!this._skill) return false;
3 years ago
var item = $dataClasses[classId];
if (!item) return false;
if (Imported.YEP_JobPoints) {
var jpCost = this._skill.learnCostJp;
jpCost += this._actor.customLearnSkillJpCost(this._skill);
if (jpCost > this._actor.jp(item.id)) return false;
3 years ago
}
return Window_ClassList.prototype.isEnabled.call(this, classId);
};
Window_SkillLearnClass.prototype.drawClassLevel = function (item, wx, wy, ww) {
if (!Imported.YEP_JobPoints) return;
var value = Yanfly.Util.toGroup(this._actor.jp(item.id));
var icon = "\\i[" + Yanfly.Icon.Jp + "]";
var fmt = Yanfly.Param.JpMenuFormat;
var text = fmt.format(value, Yanfly.Param.Jp, icon);
this.resetFontSettings();
this.changeTextColor(this.normalColor());
this.contents.fontSize = Yanfly.Param.CCCLvFontSize;
wx += ww - this.textWidthEx(text);
this.drawTextEx(text, wx, wy);
};
Window_SkillLearnClass.prototype.selectLast = function () {
this._index = this._data.indexOf(this._actor._classId);
if (this._index < 0) this._index = 0;
this.select(this._index);
};
3 years ago
} // Imported.YEP_ClassChangeCore
//=============================================================================
// Window_SkillLearnData
//=============================================================================
function Window_SkillLearnData() {
this.initialize.apply(this, arguments);
}
Window_SkillLearnData.prototype = Object.create(Window_Base.prototype);
Window_SkillLearnData.prototype.constructor = Window_SkillLearnData;
Window_SkillLearnData.prototype.initialize = function (wx, wy, ww, wh) {
3 years ago
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
this._actor = null;
this._classId = null;
this._skill = null;
this.refresh();
};
Window_SkillLearnData.prototype.setActor = function (actor) {
3 years ago
if (this._actor === actor) return;
this.setClass(null);
this.setSkill(null);
this.contents.clear();
this._actor = actor;
this.refresh();
};
Window_SkillLearnData.prototype.setClass = function (classId) {
3 years ago
if (this._classId === classId) return;
this._classId = classId;
this.refresh();
};
Window_SkillLearnData.prototype.setSkill = function (skill) {
3 years ago
if (this._skill === skill) return;
this._skill = skill;
this.refresh();
};
Window_SkillLearnData.prototype.refresh = function () {
3 years ago
this.contents.clear();
this.resetFontSettings();
this.resetTextColor();
this.drawDarkRectangles();
if (!this._skill) return;
this.drawSkillData();
};
Window_SkillLearnData.prototype.drawDarkRectangles = function (dx, dy, dw, dh) {
3 years ago
var wx = 0;
var wy = 0;
var ww = this.contents.width;
var wh = this.lineHeight();
for (;;) {
if (wy + wh > this.contents.height) break;
this.drawDarkRect(wx, wy, ww, wh);
wy += this.lineHeight();
3 years ago
}
};
Window_SkillLearnData.prototype.drawDarkRect = function (dx, dy, dw, dh) {
3 years ago
var color = this.gaugeBackColor();
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};
Window_SkillLearnData.prototype.drawSkillData = function () {
3 years ago
this.drawItemName(this._skill, 0, 0, this.contents.width);
var wy = this.lineHeight();
wy = this.drawRequirements(wy);
wy = this.drawCostText(wy);
wy = this.drawGoldCosts(wy);
wy = this.drawJpCosts(wy);
wy = this.drawOtherCosts(wy);
wy = this.drawCustomText(wy);
return wy;
};
Window_SkillLearnData.prototype.drawRequirements = function (wy) {
3 years ago
return wy;
};
Window_SkillLearnData.prototype.drawCostText = function (wy) {
3 years ago
if (!this.hasLearnCost()) return wy;
var text = Yanfly.Param.SLSLearnCost;
this.changeTextColor(this.systemColor());
this.drawText(text, 0, wy, this.contents.width, "center");
3 years ago
wy += this.lineHeight();
return wy;
};
Window_SkillLearnData.prototype.hasLearnCost = function () {
3 years ago
if (this._skill.learnCostGold > 0) return true;
if (Imported.YEP_JobPoints) {
var cost = this._skill.learnCostJp;
cost += this._actor.customLearnSkillJpCost(this._skill);
return cost > 0;
}
3 years ago
if (this._skill.learnCost.length > 0) return true;
return false;
};
Window_SkillLearnData.prototype.drawGoldCosts = function (wy) {
3 years ago
if (this._skill.learnCostGold <= 0) return wy;
var text = "";
3 years ago
if (Imported.YEP_CoreEngine && Yanfly.Icon.Gold > 0) {
text = "\\i[" + Yanfly.Icon.Gold + "]";
3 years ago
}
text += TextManager.currencyUnit;
var wx = this.drawTextEx(text, 0, wy);
var ww = this.contents.width - wx - 4;
var costText = Yanfly.Util.toGroup(this._skill.learnCostGold);
this.contents.fontSize = Yanfly.Param.SLSCostSize;
if (this._skill.learnCostGold > $gameParty.gold()) {
this.changeTextColor(this.powerDownColor());
3 years ago
} else {
this.changeTextColor(this.powerUpColor());
3 years ago
}
this.drawText(costText, wx, wy, ww, "right");
3 years ago
this.resetFontSettings();
this.resetTextColor();
wy += this.lineHeight();
return wy;
};
Window_SkillLearnData.prototype.drawJpCosts = function (wy) {
3 years ago
if (!Imported.YEP_JobPoints) return wy;
var cost = this._skill.learnCostJp;
cost += this._actor.customLearnSkillJpCost(this._skill);
if (cost <= 0) return wy;
var text = "";
if (Yanfly.Icon.Jp > 0) text = "\\i[" + Yanfly.Icon.Jp + "]";
3 years ago
text += Yanfly.Param.Jp;
var wx = this.drawTextEx(text, 0, wy);
var ww = this.contents.width - wx - 4;
var costText = Yanfly.Util.toGroup(cost);
this.contents.fontSize = Yanfly.Param.SLSCostSize;
if (this._actor.sufficientJpLearnSkill(this._skill, this._classId)) {
this.changeTextColor(this.powerUpColor());
3 years ago
} else {
this.changeTextColor(this.powerDownColor());
3 years ago
}
this.drawText(costText, wx, wy, ww, "right");
3 years ago
this.resetFontSettings();
this.resetTextColor();
wy += this.lineHeight();
return wy;
};
Window_SkillLearnData.prototype.drawOtherCosts = function (wy) {
3 years ago
if (this._skill.learnCost.length <= 0) return wy;
for (var i = 0; i < this._skill.learnCost.length; ++i) {
if (wy + this.lineHeight() > this.contents.height) break;
this.resetFontSettings();
this.resetTextColor();
var ww = this.contents.width;
var line = this._skill.learnCost[i];
var obj = null;
var value = 0;
if (line.match(/ITEM[ ](\d+):[ ](\d+)/i)) {
obj = $dataItems[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
} else if (line.match(/WEAPON[ ](\d+):[ ](\d+)/i)) {
obj = $dataWeapons[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
} else if (line.match(/ARMOR[ ](\d+):[ ](\d+)/i)) {
obj = $dataArmors[parseInt(RegExp.$1)];
value = parseInt(RegExp.$2);
}
if (!obj) continue;
this.drawItemName(obj, 0, wy, ww);
this.contents.fontSize = Yanfly.Param.SLSCostSize;
var text = "/" + Yanfly.Util.toGroup(value);
this.drawText(text, 0, wy, ww - 4, "right");
if ($gameParty.numItems(obj) >= value) {
this.changeTextColor(this.powerUpColor());
} else {
this.changeTextColor(this.powerDownColor());
}
ww -= this.textWidth(text);
var held = Yanfly.Util.toGroup($gameParty.numItems(obj));
this.drawText(held, 0, wy, ww - 4, "right");
this.resetFontSettings();
this.resetTextColor();
wy += this.lineHeight();
3 years ago
}
return wy;
};
Window_SkillLearnData.prototype.drawCustomText = function (wy) {
if (this._skill.learnCustomText === "") return wy;
3 years ago
this.drawTextEx(this._skill.learnCustomText, 4, wy);
return wy;
};
//=============================================================================
// Window_SkillLearnCommand
//=============================================================================
function Window_SkillLearnCommand() {
this.initialize.apply(this, arguments);
}
Window_SkillLearnCommand.prototype = Object.create(Window_Command.prototype);
Window_SkillLearnCommand.prototype.constructor = Window_SkillType;
Window_SkillLearnCommand.prototype.initialize = function (x, y) {
3 years ago
Window_Command.prototype.initialize.call(this, x, y);
this._actor = null;
};
Window_SkillLearnCommand.prototype.windowWidth = function () {
3 years ago
return 240;
};
Window_SkillLearnCommand.prototype.numVisibleRows = function () {
3 years ago
return 4;
};
Window_SkillLearnCommand.prototype.itemTextAlign = function () {
3 years ago
if (Imported.YEP_SkillCore) return Yanfly.Param.SCCTextAlign;
return Window_Command.prototype.itemTextAlign.call(this);
};
Window_SkillLearnCommand.prototype.setActor = function (actor) {
3 years ago
if (this._actor === actor) return;
this.contents.clear();
this._actor = actor;
this.refresh();
};
Window_SkillLearnCommand.prototype.setStatusWindow = function (w) {
3 years ago
this._statusWindow = w;
};
Window_SkillLearnCommand.prototype.setSkillLearnWindow = function (w) {
3 years ago
this._skillLearnWindow = w;
};
Window_SkillLearnCommand.prototype.setSkillLearnDataWindow = function (w) {
3 years ago
this._skillLearnDataWindow = w;
this.update();
};
Window_SkillLearnCommand.prototype.makeCommandList = function ()
{
3 years ago
if (!this._actor) return;
this.addClassCommand(this._actor.currentClass().id);
this._currentClass = this._actor.currentClass().id;
if (!Imported.YEP_ClassChangeCore) return;
for (var i = 0; i < this._actor.unlockedClasses().length; ++i) {
classId = this._actor.unlockedClasses()[i];
if (classId === this._actor.currentClass().id) continue;
if ($dataClasses[classId]) this.addClassCommand(classId);
3 years ago
}
};
Window_SkillLearnCommand.prototype.addClassCommand = function (classId) {
3 years ago
var actorClass = $dataClasses[classId];
if (!actorClass) return;
var name = actorClass.name;
if (actorClass.useNickname) {
name = this._actor.nickname();
3 years ago
}
this.addCommand(name, "class", true, classId);
//---魔改--- v1.00 添加新的选项
this.addCommand(Zzy.CYSLS.ForgetCommandText,Zzy.CYSLS.Command_F,this.IsEnableZzyCommand_F());
3 years ago
};
Window_SkillLearnCommand.prototype.IsEnableZzyCommand_F = function()
{
//此处检测是否拥有遗忘道具,进行开关的显示
if(Zzy.CYSLS.ForgeItemID)
{
return $gameParty.hasItem($dataItems[Zzy.CYSLS.ForgeItemID]);
}
return true;
}
Window_SkillLearnCommand.prototype.update = function () {
3 years ago
Window_Command.prototype.update.call(this);
if (this._helpWindow && this.active) {
var classId = this.currentExt();
this._helpWindow.setItem($dataClasses[classId]);
3 years ago
}
if (this._skillLearnWindow) {
var classId = this.currentExt();
this._skillLearnWindow.setClass(classId);
3 years ago
}
if (this._statusWindow && this._currentClassIndex !== this.index())
{
this._currentClassIndex = this.index();
//---魔改--- v1.00 将不会使用原版数据计算
if(this._currentClassIndex>0 && this._list[this._currentClassIndex].symbol === Zzy.CYSLS.Command_F)
{
//此处不会绘制任何的数据信息
return;
}
var actor = JsonEx.makeDeepCopy(this._actor);
if (!actor) return;
var classId = this.currentExt();
this._currentClass = this.currentExt();
var hpRate = actor.hp / actor.mhp;
var mpRate = actor.mp / Math.max(1, actor.mmp);
Yanfly.SLS.PreventReleaseItem = true;
if (Imported.YEP_ClassChangeCore) {
actor.changeClass(classId, Yanfly.Param.CCCMaintainLv);
} else {
actor.changeClass(classId, false);
}
var max = actor.isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(actor.mhp * hpRate));
actor.setHp(hpAmount);
actor.setMp(parseInt(actor.mmp * mpRate));
this._statusWindow.setActor(actor);
Yanfly.SLS.PreventReleaseItem = false;
3 years ago
}
};
Yanfly.SLS.Window_Command_drawItem = Window_Command.prototype.drawItem;
Window_SkillLearnCommand.prototype.drawItem = function (index) {
3 years ago
if (Imported.YEP_ClassChangeCore) {
this.drawItemEx(index);
3 years ago
} else {
Yanfly.SLS.Window_Command_drawItem.call(this, index);
3 years ago
}
};
Window_SkillLearnCommand.prototype.drawItemEx = function (index) {
3 years ago
var rect = this.itemRectForText(index);
var align = this.itemTextAlign();
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
var classId = this._list[index].ext;
this.drawIcon($dataClasses[classId].iconIndex, rect.x, rect.y);
rect.x += Window_Base._iconWidth + 4;
rect.width -= Window_Base._iconWidth + 4;
this.drawText(this.commandName(index), rect.x, rect.y, rect.width);
};
//=============================================================================
// Window_SkillLearnConfirm
//=============================================================================
function Window_SkillLearnConfirm() {
this.initialize.apply(this, arguments);
}
Window_SkillLearnConfirm.prototype = Object.create(Window_Command.prototype);
Window_SkillLearnConfirm.prototype.constructor = Window_SkillLearnConfirm;
Window_SkillLearnConfirm.prototype.initialize = function () {
3 years ago
Window_Command.prototype.initialize.call(this, 0, 0);
this.openness = 0;
};
Window_SkillLearnConfirm.prototype.makeCommandList = function () {
this.addCommand(Yanfly.Param.SLSConfirmYes, "confirm");
this.addCommand(Yanfly.Param.SLSConfirmNo, "cancel");
3 years ago
};
Window_SkillLearnConfirm.prototype.setData = function (actor, skill) {
3 years ago
var fmt = Yanfly.Param.SLSConfirmText;
this._text = fmt.format(actor.name(), skill.name);
var ww = this.textWidthEx(this._text) + this.standardPadding() * 4;
this.width = ww;
this.refresh();
this.x = (Graphics.boxWidth - this.width) / 2;
this.y = (Graphics.boxHeight - this.height) / 2;
this.drawTextEx(this._text, this.textPadding(), 0);
};
Window_SkillLearnConfirm.prototype.textWidthEx = function (text) {
3 years ago
return this.drawTextEx(text, 0, this.contents.height);
};
Window_SkillLearnConfirm.prototype.itemTextAlign = function () {
return "center";
3 years ago
};
Window_SkillLearnConfirm.prototype.windowHeight = function () {
3 years ago
return this.fittingHeight(3);
};
Window_SkillLearnConfirm.prototype.itemRect = function (index) {
3 years ago
var rect = Window_Selectable.prototype.itemRect.call(this, index);
rect.y += this.lineHeight();
return rect;
};
//=============================================================================
// Scene_Skill
//=============================================================================
Yanfly.SLS.Scene_Skill_create = Scene_Skill.prototype.create;
Scene_Skill.prototype.create = function () {
3 years ago
Yanfly.SLS.Scene_Skill_create.call(this);
this.createClassListWindow();
this.createSkillLearnWindow();
this.createGoldWindow();
this.createSkillLearnClassWindow();
this.createSkillLearnDataWindow();
};
Yanfly.SLS.Scene_Skill_refreshActor = Scene_Skill.prototype.refreshActor;
Scene_Skill.prototype.refreshActor = function () {
Yanfly.SLS.Scene_Skill_refreshActor.call(this);
var actor = this.actor();
if (this._classListWindow) this._classListWindow.setActor(actor);
if (this._skillLearnWindow) this._skillLearnWindow.setActor(actor);
if (this._skillLearnClassWindow) this._skillLearnClassWindow.setActor(actor);
if (this._skillLearnDataWindow) this._skillLearnDataWindow.setActor(actor);
3 years ago
};
Scene_Skill.prototype.createClassListWindow = function () {
3 years ago
if (!Imported.YEP_ClassChangeCore) return;
if (this._classListWindow) return;
var wx = 0;
var wy = this._statusWindow.y + this._statusWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._classListWindow = new Window_ClassList(wx, wy, ww, wh);
this._classListWindow.setHelpWindow(this._helpWindow);
this._classListWindow.setHandler("ok", this.onClassOk.bind(this));
this._classListWindow.setHandler("cancel", this.onClassCancel.bind(this));
3 years ago
this._skillTypeWindow.setClassListWindow(this._classListWindow);
this._classListWindow.hide();
this._classListWindow.setActor(this.actor());
this.addWindow(this._classListWindow);
};
Scene_Skill.prototype.createSkillLearnWindow = function () {
3 years ago
var wx = 0;
var wy = this._statusWindow.y + this._statusWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._skillLearnWindow = new Window_SkillLearn(wx, wy, ww, wh);
this._skillLearnWindow.setHelpWindow(this._helpWindow);
this._skillLearnWindow.setHandler("ok", this.onLearnOk.bind(this));
this._skillLearnWindow.setHandler("cancel", this.onLearnCancel.bind(this));
3 years ago
this._skillTypeWindow.setSkillLearnWindow(this._skillLearnWindow);
this._skillLearnWindow.hide();
this._skillLearnWindow.setActor(this.actor());
this._skillLearnWindow.setClass(this.actor().currentClass().id);
this.addWindow(this._skillLearnWindow);
};
Scene_Skill.prototype.createGoldWindow = function () {
3 years ago
if (!Yanfly.Param.SLSGoldWindow) return;
var wx = Graphics.boxWidth / 2;
//---魔改--- v1.00 金币窗口修改
this._goldWindow = new Window_ZzyCYSLSGold(wx, 0);
3 years ago
this._goldWindow.width = Graphics.boxWidth / 2;
this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;
this._skillTypeWindow.setGoldWindow(this._goldWindow);
this._goldWindow.hide();
this._goldWindow.createContents();
this._goldWindow.refresh();
this.addWindow(this._goldWindow);
};
Scene_Skill.prototype.createSkillLearnClassWindow = function () {
3 years ago
if (!Imported.YEP_ClassChangeCore) return;
if (this._skillLearnClassWindow) return;
var wx = 0;
var wy = this._statusWindow.y + this._statusWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._skillLearnClassWindow = new Window_SkillLearnClass(wx, wy, ww, wh);
this._skillLearnClassWindow.setHelpWindow(this._helpWindow);
this._skillLearnClassWindow.setHandler("ok", this.onSLCOk.bind(this));
this._skillLearnClassWindow.setHandler("cancel", this.onSLCCancel.bind(this));
3 years ago
this._skillLearnClassWindow.hide();
this._skillLearnClassWindow.setActor(this.actor());
this.addWindow(this._skillLearnClassWindow);
};
Scene_Skill.prototype.createSkillLearnDataWindow = function () {
3 years ago
var wx = Graphics.boxWidth / 2;
var wy = this._statusWindow.y + this._statusWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
if (this._goldWindow) wh -= this._goldWindow.height;
this._skillLearnDataWindow = new Window_SkillLearnData(wx, wy, ww, wh);
this._skillTypeWindow.setSkillLearnDataWindow(this._skillLearnDataWindow);
this._skillLearnWindow.setDataWindow(this._skillLearnDataWindow);
this._skillLearnDataWindow.setActor(this.actor());
this._skillLearnDataWindow.hide();
this.addWindow(this._skillLearnDataWindow);
};
Yanfly.SLS.Scene_Skill_commandSkill = Scene_Skill.prototype.commandSkill;
Scene_Skill.prototype.commandSkill = function () {
if (this._skillTypeWindow.currentExt() === "learnSkills") {
this.commandLearnSkill();
3 years ago
} else {
Yanfly.SLS.Scene_Skill_commandSkill.call(this);
3 years ago
}
};
Scene_Skill.prototype.commandLearnSkill = function () {
3 years ago
if (!eval(Yanfly.Param.SLSIntegrate)) {
SceneManager.push(Scene_LearnSkill);
3 years ago
} else if (this._classListWindow && this.actor().availableClasses() > 1) {
this._classListWindow.activate();
this._classListWindow.selectLast();
3 years ago
} else if (this._skillLearnWindow) {
this._skillLearnWindow.activate();
this._skillLearnWindow.selectLast();
3 years ago
}
};
Scene_Skill.prototype.onClassOk = function () {
3 years ago
var item = this._classListWindow.item();
this._skillLearnWindow.setClass(item);
this._classListWindow.hide();
this._skillLearnWindow.show();
this._skillLearnWindow.activate();
this._skillLearnWindow.selectLast();
};
Scene_Skill.prototype.onClassCancel = function () {
3 years ago
this._classListWindow.deselect();
this._skillTypeWindow.activate();
this._helpWindow.setItem(null);
};
Scene_Skill.prototype.onLearnOk = function () {
3 years ago
var skill = this._skillLearnWindow.item();
if (this.actor().availableClasses() === 1) {
var classId = this.actor().currentClass().id;
this.processLearnSkill(skill, classId);
3 years ago
} else if (this._skillLearnClassWindow) {
this._skillLearnWindow.hide();
this._skillLearnClassWindow.show();
this._skillLearnClassWindow.setSkill(skill);
this._skillLearnClassWindow.activate();
this._skillLearnClassWindow.selectLast();
}
};
Scene_Skill.prototype.processLearnSkill = function (skill, classId) {
this._skillLearnWindow.activate();
this.actor().learnSkill(skill.id);
SoundManager.playUseSkill();
$gameParty.loseGold(skill.learnCostGold);
$gameParty.processLearnSkillCost(skill);
if (Imported.YEP_JobPoints) {
var cost = skill.learnCostJp;
cost += this.actor().customLearnSkillJpCost(skill);
this.actor().loseJp(cost, classId);
if(cost)
{
//---魔改--- v1.00 损失技能JP进行存储
this.actor()._ZzyCYSLSCache = this.actor()._ZzyCYSLSCache || [];//技能缓存记录
var info = {skillId:skill.id,jpCost:cost};
this.actor()._ZzyCYSLSCache.push(info);//记录JP消耗值,进行缓存
}
}
this.processLearnCostEval(skill, classId);
this.actor().refresh();
this._skillLearnWindow.refresh();
this._skillLearnWindow.updateHelp();
this._statusWindow.refresh();
if (this._goldWindow) this._goldWindow.refresh();
if (this._classListWindow) this._classListWindow.refresh();
this._skillLearnDataWindow.refresh();
this._skillTypeWindow.refresh();
};
Scene_Skill.prototype.processLearnCostEval = function (skill, classId) {
if (skill.learnCostEval === "") return;
var a = this.actor();
var user = this.actor();
var subject = this.actor();
var s = $gameSwitches._data;
var v = $gameVariables._data;
var code = skill.learnCostEval;
try {
eval(code);
} catch (e) {
Yanfly.Util.displayError(e, code, "SKILL LEARN CUSTOM COST ERROR");
3 years ago
}
};
Scene_Skill.prototype.onLearnCancel = function () {
3 years ago
this._skillLearnWindow.deselect();
this._skillLearnDataWindow.setSkill(null);
if (this._classListWindow && this._actor.availableClasses() > 1) {
this._skillLearnWindow.hide();
this._classListWindow.show();
this._classListWindow.activate();
this._classListWindow.selectLast();
3 years ago
} else {
this._skillTypeWindow.activate();
this._helpWindow.setItem(null);
3 years ago
}
};
Scene_Skill.prototype.onSLCOk = function () {
3 years ago
var skill = this._skillLearnWindow.item();
var classId = this._skillLearnClassWindow.item();
this.processLearnSkill(skill, classId);
this.onSLCCancel();
};
Scene_Skill.prototype.onSLCCancel = function () {
3 years ago
this._skillLearnClassWindow.hide();
this._skillLearnWindow.activate();
this._skillLearnWindow.show();
};
//=============================================================================
// Scene_LearnSkill
//=============================================================================
function Scene_LearnSkill() {
this.initialize.apply(this, arguments);
}
Scene_LearnSkill.prototype = Object.create(Scene_ItemBase.prototype);
Scene_LearnSkill.prototype.constructor = Scene_LearnSkill;
Scene_LearnSkill.prototype.initialize = function () {
3 years ago
Scene_ItemBase.prototype.initialize.call(this);
};
Scene_LearnSkill.prototype.onActorChange = function () {
3 years ago
this.refreshActor();
this.adjustSelection();
};
Scene_LearnSkill.prototype.adjustSelection = function () {
3 years ago
if (Imported.YEP_ClassChangeCore) {
this._commandWindow.activate();
3 years ago
} else {
this.commandClass();
this._commandWindow.deactivate();
3 years ago
}
};
Scene_LearnSkill.prototype.start = function () {
3 years ago
Scene_ItemBase.prototype.start.call(this);
};
Scene_LearnSkill.prototype.create = function () {
3 years ago
Scene_ItemBase.prototype.create.call(this);
this.createHelpWindow();
this.createCommandWindow();
this.createStatusWindow();
this.createSkillLearnWindow();
this.createGoldWindow();
this.createSkillLearnDataWindow();
this.createConfirmWindow();
//---魔改--- v1.01 创造提示遗忘文本窗口 创造确认取消窗口
this.createForgetHelpWindow();
this.createForgetCommandWindow();//此窗口需要获取Help窗口计算的宽度,因此一定要在下面加载
3 years ago
this.refreshActor();
this.adjustSelection();
};
Scene_LearnSkill.prototype.refreshActor = function () {
3 years ago
var actor = this.actor();
this._commandWindow.setActor(actor);
this._statusWindow.setActor(actor);
this._skillLearnWindow.setActor(actor);
this._skillLearnDataWindow.setActor(actor);
};
Scene_LearnSkill.prototype.createCommandWindow = function () {
3 years ago
var wy = this._helpWindow.height;
this._commandWindow = new Window_SkillLearnCommand(0, wy);
this._commandWindow.setHelpWindow(this._helpWindow);
this._commandWindow.setHandler("class", this.commandClass.bind(this));
this._commandWindow.setHandler("cancel", this.popScene.bind(this));
this._commandWindow.setHandler("pagedown", this.nextActor.bind(this));
this._commandWindow.setHandler("pageup", this.previousActor.bind(this));
//---魔改--- v1.01 添加一键遗忘
this._commandWindow.setHandler(Zzy.CYSLS.Command_F, this.ExeForgetSkill.bind(this));
3 years ago
this._commandWindow.setHelpWindow(this._helpWindow);
this.addWindow(this._commandWindow);
};
Scene_LearnSkill.prototype.ExeForgetSkill = function()//执行一键遗忘操作,弹出提示
{
//进行弹开
this._windowForgetCommand.open();
this._windowForgetHelp.open();
this._windowForgetCommand.select(0);//自动选择确认
this._windowForgetCommand.activate();//设置为活跃
}
Scene_LearnSkill.prototype.createForgetHelpWindow = function()
{
this._windowForgetHelp = new Window_ZzyCYSLSForgetHelp();
this.addWindow(this._windowForgetHelp);
}
Scene_LearnSkill.prototype.createForgetCommandWindow = function()
{
this._windowForgetCommand = new Window_ZzyCYSLSForgetCommand();
this._windowForgetCommand.setHandler('zzycyslsf',this.ForgetCommandOk.bind(this));
this._windowForgetCommand.setHandler('cancel',this.ForgetCommandCancel.bind(this));
this.addWindow(this._windowForgetCommand);
}
Scene_LearnSkill.prototype.ForgetCommandOk = function()
{
this.ForgetCommandJumpCommandWindow();
//此处消耗道具
var gjp = Zzy.CYSLS.GetForgetOfActorJP(this.actor().actorId());//获取遗忘剩余JP
var res = Zzy.CYSLS.ExeForgetOfActor(this.actor().actorId());//执行遗忘技能
if(res)
{
//消耗一个遗忘石
if(Zzy.CYSLS.ForgeItemID)
{
$gameParty.loseItem($dataItems[Zzy.CYSLS.ForgeItemID],1);
}
}
//增加原本的JP值
if(gjp>0)this.actor().gainJp(gjp);
SoundManager.playUseSkill();//播放获取音效
//刷新所有的窗口
//this.refreshStatus();
this._windowForgetCommand.refresh();
this._windowForgetHelp.refresh();
this._goldWindow.refresh();
this._commandWindow.refresh();//刷新
}
Scene_LearnSkill.prototype.ForgetCommandCancel = function()
{
this.ForgetCommandJumpCommandWindow();
SoundManager.playCancel();//取消音效
}
Scene_LearnSkill.prototype.ForgetCommandJumpCommandWindow = function()//进行跳转
{
this._windowForgetCommand.close();//取消
this._windowForgetHelp.close();
//this._windowForgetCommand.deselect();//取消活跃
this._commandWindow.activate();//设置活跃
}
Scene_LearnSkill.prototype.createStatusWindow = function () {
3 years ago
var wx = this._commandWindow.width;
var wy = this._helpWindow.height;
var ww = Graphics.boxWidth - wx;
var wh = this._commandWindow.height;
this._statusWindow = new Window_SkillStatus(wx, wy, ww, wh);
this._commandWindow.setStatusWindow(this._statusWindow);
this.addWindow(this._statusWindow);
};
Scene_LearnSkill.prototype.createSkillLearnWindow = function () {
var wx = 0;
var wy = this._statusWindow.y + this._statusWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
this._skillLearnWindow = new Window_SkillLearn(wx, wy, ww, wh);
this._skillLearnWindow.setHelpWindow(this._helpWindow);
this._skillLearnWindow.setHandler("ok", this.onLearnOk.bind(this));
this._skillLearnWindow.setHandler("cancel", this.onLearnCancel.bind(this));
if (!Imported.YEP_ClassChangeCore) {
var win = this._skillLearnWindow;
win.setHandler("pagedown", this.onLearnPageDn.bind(this));
win.setHandler("pageup", this.onLearnPageUp.bind(this));
}
this._commandWindow.setSkillLearnWindow(this._skillLearnWindow);
this._skillLearnWindow.setActor(this.actor());
this._skillLearnWindow.setClass(this.actor().currentClass().id);
this.addWindow(this._skillLearnWindow);
};
Scene_LearnSkill.prototype.createGoldWindow = function () {
3 years ago
if (!eval(Yanfly.Param.SLSGoldWindow)) return;
var wx = Graphics.boxWidth / 2;
//---魔改--- v1.00 金币窗口修改
this._goldWindow = new Window_ZzyCYSLSGold(wx, 0);
3 years ago
this._goldWindow.width = Graphics.boxWidth / 2;
this._goldWindow.y = Graphics.boxHeight - this._goldWindow.height;
this._goldWindow.createContents();
this._goldWindow.refresh();
this.addWindow(this._goldWindow);
};
Scene_LearnSkill.prototype.createSkillLearnDataWindow = function () {
3 years ago
var wx = Graphics.boxWidth / 2;
var wy = this._statusWindow.y + this._statusWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy;
if (this._goldWindow) wh -= this._goldWindow.height;
this._skillLearnDataWindow = new Window_SkillLearnData(wx, wy, ww, wh);
this._commandWindow.setSkillLearnDataWindow(this._skillLearnDataWindow);
this._skillLearnWindow.setDataWindow(this._skillLearnDataWindow);
this._skillLearnDataWindow.setActor(this.actor());
this.addWindow(this._skillLearnDataWindow);
};
Scene_LearnSkill.prototype.createConfirmWindow = function () {
3 years ago
this._confirmWindow = new Window_SkillLearnConfirm();
var win = this._confirmWindow;
win.setHandler("confirm", this.onConfirmOk.bind(this));
win.setHandler("cancel", this.onConfirmCancel.bind(this));
3 years ago
this.addWindow(this._confirmWindow);
};
Scene_LearnSkill.prototype.commandClass = function () {
3 years ago
var item = this._commandWindow.currentExt();
this._skillLearnWindow.setClass(item);
this._skillLearnWindow.show();
this._skillLearnWindow.activate();
this._skillLearnWindow.selectLast();
};
Scene_LearnSkill.prototype.onLearnOk = function () {
3 years ago
var skill = this._skillLearnWindow.item();
var classId = this._commandWindow.currentExt();
this.confirmLearnSkill(skill, classId);
};
Scene_LearnSkill.prototype.refreshStatus = function () {
3 years ago
var actor = JsonEx.makeDeepCopy(this.actor());
if (!actor) return;
var classId = this._commandWindow.currentExt();
this._commandWindow._currentClass = this._commandWindow.currentExt();
var hpRate = actor.hp / actor.mhp;
var mpRate = actor.mp / Math.max(1, actor.mmp);
Yanfly.SLS.PreventReleaseItem = true;
if (Imported.YEP_ClassChangeCore) {
actor.changeClass(classId, Yanfly.Param.CCCMaintainLv);
3 years ago
} else {
actor.changeClass(classId, false);
3 years ago
}
var max = actor.isDead() ? 0 : 1;
var hpAmount = Math.max(max, parseInt(actor.mhp * hpRate));
actor.setHp(hpAmount);
actor.setMp(parseInt(actor.mmp * mpRate));
this._statusWindow.setActor(actor);
Yanfly.SLS.PreventReleaseItem = false;
};
Scene_LearnSkill.prototype.processLearnSkill = function (skill, classId) {
this._skillLearnWindow.activate();
this.actor().learnSkill(skill.id);
SoundManager.playUseSkill();
$gameParty.loseGold(skill.learnCostGold);
$gameParty.processLearnSkillCost(skill);
if (Imported.YEP_JobPoints) {
var cost = skill.learnCostJp;
cost += this.actor().customLearnSkillJpCost(skill);
this.actor().loseJp(cost, classId);
if(cost)
{
//---魔改--- v1.00 损失技能JP进行存储
this.actor()._ZzyCYSLSCache = this.actor()._ZzyCYSLSCache || [];//技能缓存记录
var info = {skillId:skill.id,jpCost:cost};
this.actor()._ZzyCYSLSCache.push(info);//记录JP消耗值,进行缓存
}
}
this.processLearnCostEval(skill, classId);
this.actor().refresh();
this._skillLearnWindow.refresh();
this._skillLearnWindow.updateHelp();
this.refreshStatus();
if (this._goldWindow) this._goldWindow.refresh();
if (this._classListWindow) this._classListWindow.refresh();
this._skillLearnDataWindow.refresh();
this._commandWindow.refresh();
};
Scene_LearnSkill.prototype.confirmLearnSkill = function (skill, classId) {
3 years ago
if (Yanfly.Param.SLSConfirmWin) {
this.startConfirmWindow(skill);
3 years ago
} else {
this.processLearnSkill(skill, classId);
3 years ago
}
};
Scene_LearnSkill.prototype.processLearnCostEval = function (skill, classId) {
if (skill.learnCostEval === "") return;
3 years ago
var a = this.actor();
var user = this.actor();
var subject = this.actor();
var s = $gameSwitches._data;
var v = $gameVariables._data;
var code = skill.learnCostEval;
try {
eval(code);
3 years ago
} catch (e) {
Yanfly.Util.displayError(e, code, "SKILL LEARN COST ERROR");
3 years ago
}
};
Scene_LearnSkill.prototype.onLearnCancel = function ()
{
//---魔改--- v1.00 识别一键遗忘的效果
var fIndex = this._commandWindow.findSymbol(Zzy.CYSLS.Command_F);
//检测是否选择添加有效
if (Imported.YEP_ClassChangeCore || (fIndex && this._commandWindow._list[fIndex].enabled))
{
this._skillLearnWindow.deselect();
this._skillLearnDataWindow.setSkill(null);
this._commandWindow.activate();
this._helpWindow.setItem(null);
}
else
{
this.popScene();
3 years ago
}
};
Scene_LearnSkill.prototype.onLearnPageDn = function () {
3 years ago
this.nextActor();
};
Scene_LearnSkill.prototype.onLearnPageUp = function () {
3 years ago
this.previousActor();
};
Scene_LearnSkill.prototype.startConfirmWindow = function (skill) {
3 years ago
this._confirmWindow.setData(this._actor, skill);
this._confirmWindow.open();
this._confirmWindow.activate();
this._confirmWindow.select(0);
};
Scene_LearnSkill.prototype.onConfirmOk = function () {
3 years ago
var skill = this._skillLearnWindow.item();
var classId = this._commandWindow.currentExt();
this.processLearnSkill(skill, classId);
this._confirmWindow.close();
};
Scene_LearnSkill.prototype.onConfirmCancel = function () {
3 years ago
this._confirmWindow.deactivate();
this._confirmWindow.close();
this._skillLearnWindow.activate();
};
//=============================================================================
// Window_ZzyCYSLSForgetHelp
//=============================================================================
function Window_ZzyCYSLSForgetHelp() {
this.initialize.apply(this, arguments);
}
Window_ZzyCYSLSForgetHelp.prototype = Object.create(Window_Base.prototype);
Window_ZzyCYSLSForgetHelp.prototype.constructor = Window_ZzyCYSLSForgetHelp;
Window_ZzyCYSLSForgetHelp.prototype.initialize = function()
{
Window_Base.prototype.initialize.call(this, 0, 0,Graphics.boxWidth,Graphics.boxHeight);
this.openness = 0;//隐藏
this.refresh();
};
Window_ZzyCYSLSForgetHelp.prototype.refresh = function()//进行一次刷新
{
var textArr = Zzy.CYSLS.ForgetNote.split('\n');
var width = 0;
this.contents.clear();//清理
for(var i=0;i<textArr.length;i++)
{
var text = textArr[i];
var t = this.textWidthEx(text);
width = Math.max(width,t);
}
var len = textArr.length;
var height = this.fittingHeight(len);
var pad = this.standardPadding();
this.move(0,0,width+pad*2,height);//修改宽高
var lh = this.lineHeight();
for(var i=0;i<textArr.length;i++)
{
var text = textArr[i];
this.drawTextEx(text,0,lh*i);
}
//设置位置居中处理
var cx = Graphics.boxWidth / 2 - this.width / 2;
var cy = Graphics.boxHeight / 2 - this.height;
//设置位置
this.x = cx;
this.y = cy;
}
//=============================================================================
// Window_ZzyCYSLSForgetCommand
//=============================================================================
function Window_ZzyCYSLSForgetCommand() {
this.initialize.apply(this, arguments);
}
Window_ZzyCYSLSForgetCommand.prototype = Object.create(Window_Command.prototype);
Window_ZzyCYSLSForgetCommand.prototype.constructor = Window_ZzyCYSLSForgetCommand;
Window_ZzyCYSLSForgetCommand.prototype.initialize = function()
{
Window_Command.prototype.initialize.call(this, 200,200);
this.openness = 0;
this.deactivate();//取消活跃
this.deselect();//取消选择
this.SetAutoPosition();//自动设置位置处理
};
Window_ZzyCYSLSForgetCommand.prototype.makeCommandList = function()
{
this.addCommand(Zzy.CYSLS.ForgetYesText, 'zzycyslsf', true);
this.addCommand(Zzy.CYSLS.ForgetNoText, 'cancel', true);
}
Window_ZzyCYSLSForgetCommand.prototype.playOkSound = function() //不会进行声音播放
{
SoundManager.playOk();
};
Window_ZzyCYSLSForgetCommand.prototype.SetAutoPosition = function()
{
var win = SceneManager._scene._windowForgetHelp;
this.x = Graphics.boxWidth / 2 - this.width / 2;
this.y = Graphics.boxHeight / 2;
}
Window_ZzyCYSLSForgetCommand.prototype.windowWidth = function()
{
return SceneManager._scene._windowForgetHelp.width;//返回帮助窗口的宽度值
};
Window_ZzyCYSLSForgetCommand.prototype.itemTextAlign = function() {
return 'center';
};
//---魔改--- v1.00 新的窗口类型
//=============================================================================
// Window_ZzyCYSLSGold
//=============================================================================
function Window_ZzyCYSLSGold() {
this.initialize.apply(this, arguments);
}
Window_ZzyCYSLSGold.prototype = Object.create(Window_Gold.prototype);
Window_ZzyCYSLSGold.prototype.constructor = Window_ZzyCYSLSGold;
Window_ZzyCYSLSGold.prototype.initialize = function(x, y)
{
Window_Gold.prototype.initialize.call(this, x, y);
};
Window_ZzyCYSLSGold.prototype.refresh = function()
{
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
//绘制文本信息
var actor = SceneManager._scene.actor();
var jp = actor.jp();
var gold = $gameParty.gold();
var tf = Zzy.CYSLS.ShowGoldWindowFormat;//获取文本格式
var text = tf.format(jp,gold);
var wex = this.textWidthEx(text);
var ofx = 0;
if(wex > width)ofx = 0;
else
{ofx = (width-wex)/2;}
//绘制JP--位于中心
this.drawTextEx(text,x+ofx,0);
}
Window_ZzyCYSLSGold.prototype.textWidthEx = function(text) //计算宽高
{
return this.drawTextEx(text, 0, this.contents.height);
};
//---魔改--- v1.00 关闭Scene_Skill界面下的Window_SkillStatus界面的JP绘制
Window_SkillStatus.prototype.drawActorJp = function(actor, id, wx, wy, ww, align)
{
if(SceneManager._scene instanceof Scene_Skill)return undefined;//不进行绘制
// var jp = actor.jp(id);
// var icon = '\\i[' + Yanfly.Icon.Jp + ']';
// var fmt = Yanfly.Param.JpMenuFormat;
// var text = fmt.format(Yanfly.Util.toGroup(jp), Yanfly.Param.Jp, icon);
// if (align === 'left') {
// wx = 0;
// } else if (align === 'center') {
// wx += (ww - this.textWidthEx(text)) / 2;
// } else {
// wx += ww - this.textWidthEx(text);
// }
// this.drawTextEx(text, wx, wy);
};
3 years ago
//=============================================================================
// Utilities
//=============================================================================
Yanfly.Util = Yanfly.Util || {};
if (!Yanfly.Util.toGroup) {
Yanfly.Util.toGroup = function (inVal) {
3 years ago
return inVal;
};
}
3 years ago
Yanfly.Util.getRange = function (n, m) {
3 years ago
var result = [];
for (var i = n; i <= m; ++i) result.push(i);
return result;
};
Yanfly.Util.onlyUnique = function (value, index, self) {
3 years ago
return self.indexOf(value) === index;
};
Yanfly.Util.displayError = function (e, code, message) {
console.log(message);
console.log(code || "NON-EXISTENT");
console.error(e);
if (Utils.isNwjs() && Utils.isOptionValid("test")) {
if (!require("nw.gui").Window.get().isDevToolsOpen()) {
require("nw.gui").Window.get().showDevTools();
}
3 years ago
}
};
//---魔改--- v1.00 恢复函数
Zzy.CYSLS.ExeForgetOfActor = function(actorId)//遗忘一个角色全部的技能,并返回点数
{
//将角色的技能进行遗忘
var actor = $gameActors.actor(actorId);
var fg = false;
if(actor)
{
var cache = actor._ZzyCYSLSCache;
if(cache)
{
for(var i=0;i<cache.length;i++)
{
var info = cache[i];
var skillId = info.skillId;
if(skillId && actor.isLearnedSkill(skillId))
{
actor.forgetSkill(skillId);//对这个技能进行遗忘
fg = true;
}
}
}
actor._ZzyCYSLSCache = [];//清理所有的缓存
}
return fg;
}
Zzy.CYSLS.GetForgetOfActorJP = function(actorId)//通过一个角色返回其遗忘点
{
var actor = $gameActors.actor(actorId);
if(actor)
{
var tjp = 0;
var cache = actor._ZzyCYSLSCache;
if(cache)
{
for(var i=0;i<cache.length;i++)
{
var info = cache[i];
tjp += info.jpCost;
}
}
return tjp;
}
return 0;
}
3 years ago
//=============================================================================
// End of File
//=============================================================================