//============================================================================== // dsGainLpResult02.js // Copyright (c) 2015 - 2019 DOURAKU // Released under the MIT License. // http://opensource.org/licenses/mit-license.php //============================================================================== /*: * @plugindesc LP獲得リザルト画面02プラグイン ver1.0.0 * @author 道楽 * * @param Left Side Width * @desc 左側の表示領域の横幅 * @default 260 * * @param New Skill Text * @desc スキルを習得したときに表示されるテキスト * @default 新たなスキルを習得した! * * @param Learned Skill Text * @desc スキル習得ウィンドウの題字 * @default スキル習得 * * @param Show Skill Detail * @desc 習得したスキルの詳細を表示するか? * (true なら表示する / false なら表示しない) * @default true * * @help * YEP_VictoryAftermath.js導入時に表示される、 * 戦闘結果画面に獲得LP量を表示するプラグインです。 * 戦闘で獲得した経験値やLPを表示した後、 * 装備から習得したスキルを個別のウィンドウで一覧表示します。 * * ※注意事項 * 本プラグインの導入には以下のプラグインの導入が必要です。 * また、必ず本プラグインより上の列に配置してください。 * ・YEP_VictoryAftermath.js * ・dsEquipmentSkillLearning.js */ var Imported = Imported || {}; Imported.dsGainLpResult02 = true; (function (exports) { 'use strict'; exports.Param = (function() { var ret = {}; var parameters = PluginManager.parameters('dsGainLpResult02'); ret.LeftSideWidth = Number(parameters['Left Side Width']); ret.NewSkillText = String(parameters['New Skill Text']); ret.LearnedSkillText = String(parameters['Learned Skill Text']); ret.ShowSkillDetail = Boolean(parameters['Show Skill Detail'] === 'true' || false); return ret; })(); //-------------------------------------------------------------------------- /** Window_VictoryExp */ Window_VictoryExp.prototype.gaugeRect = function(index) { var rect = this.itemRect(index); var fw = Window_Base._faceWidth; rect.x += fw + this.standardPadding() * 2; rect.width -= fw + this.standardPadding() * 2; return rect; }; var _Window_VictoryExp_drawActorGauge = Window_VictoryExp.prototype.drawActorGauge; Window_VictoryExp.prototype.drawActorGauge = function(actor, index) { _Window_VictoryExp_drawActorGauge.call(this, actor, index); var rect = this.gaugeRect(index); this.drawLpGained(actor, rect); }; Window_VictoryExp.prototype.drawExpGauge = function(actor, rect) { var wx = rect.x + exports.Param.LeftSideWidth + 2; var wy = rect.y + this.lineHeight(); var ww = rect.width - exports.Param.LeftSideWidth; var rate = this.actorExpRate(actor); if ( rate >= 1.0 ) { var color1 = this.textColor(Yanfly.Param.ColorLv1); var color2 = this.textColor(Yanfly.Param.ColorLv2); } else { var color1 = this.textColor(Yanfly.Param.ColorExp1); var color2 = this.textColor(Yanfly.Param.ColorExp2); } this.drawGauge(wx, wy, ww, rate, color1, color2); }; Window_VictoryExp.prototype.drawExpValues = function(actor, rect) { var wx = rect.x + exports.Param.LeftSideWidth + 2; var wy = rect.y + this.lineHeight(); var ww = rect.width - exports.Param.LeftSideWidth - 4; var actorLv = actor._preVictoryLv; var bonusExp = 1.0 * actor._expGained * this._tick / Yanfly.Param.VAGaugeTicks; var nowExp = actor._preVictoryExp - actor.expForLevel(actorLv) + bonusExp; var nextExp = actor.expForLevel(actorLv + 1) - actor.expForLevel(actorLv); if ( actorLv === actor.maxLevel() ) { var text = Yanfly.Param.VAMaxLv; } else if ( nowExp >= nextExp ) { var text = Yanfly.Param.VALevelUp; } else { var text = Yanfly.Util.toGroup(parseInt(nextExp - nowExp)); } this.changeTextColor(this.normalColor()); this.drawText(text, wx, wy, ww, 'right'); }; Window_VictoryExp.prototype.drawExpGained = function(actor, rect) { var wx = rect.x + 2; var wy = rect.y + this.lineHeight() * 1; var ww = exports.Param.LeftSideWidth - 4; if ( wy < rect.y + rect.height ) { this.changeTextColor(this.systemColor()); this.drawText(Yanfly.Param.VAGainedExp, wx, wy, ww, 'left'); var bonusExp = 1.0 * actor._expGained * this._tick / Yanfly.Param.VAGaugeTicks; var expParse = Yanfly.Util.toGroup(parseInt(bonusExp)); var expText = Yanfly.Param.VAGainedExpfmt.format(expParse); this.changeTextColor(this.normalColor()); this.drawText(expText, wx, wy, ww, 'right'); } }; Window_VictoryExp.prototype.drawLpGained = function(actor, rect) { var value = actor.battleLp(); var text = dsEquipmentSkillLearning.Param.LpAftermathFormat.format(value, dsEquipmentSkillLearning.Param.Lp); var textWidth = this.textWidthEx(text); var wx = rect.x; var wy = rect.y + this.lineHeight() * 2; var ww = exports.Param.LeftSideWidth - 4; this.changeTextColor(this.systemColor()); this.drawText(dsEquipmentSkillLearning.Param.LpAftermathEarned, wx + 2, wy, ww - 4, 'left'); this.resetTextColor(); this.drawTextEx(text, wx + ww - textWidth, wy); }; Window_VictoryExp.prototype.drawGainedSkills = function(actor, rect) { if ( actor._victorySkills.length <= 0 && actor.victoryLpSkills().length <= 0 ) { return; } if ( !this.meetDrawGainedSkillsCondition(actor) ) { return; } var wx = rect.x + exports.Param.LeftSideWidth + 2; var wy = rect.y + this.lineHeight() * 2; var ww = rect.width - exports.Param.LeftSideWidth - 4; this.drawText(exports.Param.NewSkillText, wx, wy, ww, 'center'); }; Window_VictoryExp.prototype.meetDrawGainedSkillsCondition = function(actor) { if ( !this._showGainedSkills ) { return; } var actorLv = actor._preVictoryLv; var bonusExp = 1.0 * actor._expGained * this._tick / Yanfly.Param.VAGaugeTicks; var nowExp = actor._preVictoryExp - actor.expForLevel(actorLv) + bonusExp; var nextExp = actor.expForLevel(actorLv + 1) - actor.expForLevel(actorLv); if ( actorLv === actor.maxLevel() ) { return false; } else if ( nowExp >= nextExp ) { return true; } if ( this._tick >= Yanfly.Param.VAGaugeTicks / 2 ) { if ( actor.victoryLpSkills().length > 0 ) { return true; } } return false; }; //-------------------------------------------------------------------------- /** Window_VictorySkill */ exports.Window_VictorySkill = (function() { function Window_VictorySkill() { this.initialize.apply(this, arguments); } Window_VictorySkill.prototype = Object.create(Window_VictoryExp.prototype); Window_VictorySkill.prototype.constructor = Window_VictorySkill; Window_VictorySkill.prototype.initialize = function() { Window_VictoryExp.prototype.initialize.call(this); this._actor = null; }; Window_VictorySkill.prototype.maxItems = function() { return 1; }; Window_VictorySkill.prototype.setActor = function(actor) { if ( this._actor !== actor ) { if ( this._actor ) { AudioManager.playSe(this._tickSound); } this._actor = actor; this._tick = 0; this.refresh(); } }; Window_VictorySkill.prototype.drawItem = function(index) { if ( index > 0 ) { return; } if ( this._actor ) { var rect = this.itemRect(index); this.drawActorFace(this._actor, rect.x + 1, rect.y + 1, Window_Base._faceWidth, Window_Base._faceHeight); rect = this.gaugeRect(index); this.changeTextColor(this.normalColor()); this.drawActorName(this._actor, rect.x + 2, rect.y); this.drawGainedSkills(this._actor, rect); } }; Window_VictorySkill.prototype.drawGainedSkills = function(actor, rect) { var skills = actor._victorySkills.concat(actor.victoryLpSkills()); if ( skills.length <= 0 ) { return; } skills.forEach(function(skillId, idx) { var skill = $dataSkills[skillId]; if ( skill ) { var text = '\\i[' + skill.iconIndex + ']' + skill.name; text = TextManager.obtainSkill.format(text); var ww = this.textWidthEx(text); var wx = rect.x; var wy = rect.y + this.lineHeight() + this.lineHeight() * idx; this.drawTextEx(text, wx, wy); } }, this); }; Window_VictorySkill.prototype.actorExpRate = function(actor) { return 1.0; }; return Window_VictorySkill; })(); //-------------------------------------------------------------------------- /** Scene_Battle */ var _Scene_Battle_addCustomVictorySteps = Scene_Battle.prototype.addCustomVictorySteps; Scene_Battle.prototype.addCustomVictorySteps = function(array) { array = _Scene_Battle_addCustomVictorySteps.call(this, array); var stepIdx = array.indexOf("LP"); if ( stepIdx >= 0 ) { array.splice(stepIdx, 1); } this._skillSteps = []; if ( exports.Param.ShowSkillDetail ) { $gameParty.battleMembers().forEach(function(actor, idx) { if ( this.isGainedVictorySkill(actor) ) { var stepName = 'SKILL' + ('0'+idx); if ( !array.contains(stepName) ) { array.push(stepName); this._skillSteps.push(stepName); } } }, this); } return array; }; var _Scene_Battle_updateVictorySteps = Scene_Battle.prototype.updateVictorySteps; Scene_Battle.prototype.updateVictorySteps = function() { _Scene_Battle_updateVictorySteps.call(this); if ( this._victoryStep && this._skillSteps ) { var stepIdx = this._skillSteps.indexOf(this._victoryStep); if ( stepIdx >= 0 ) { this.updateVictorySkill(); } } }; Scene_Battle.prototype.updateVictorySkill = function() { if ( !this._victorySkillWindow ) { this.createVictorySkill(); } else if ( this._victorySkillWindow.isReady() ) { if ( this.victoryTriggerContinue() ) { this.finishVictorySkill(); } } }; Scene_Battle.prototype.createVictorySkill = function() { this._victoryTitleWindow.refresh(exports.Param.LearnedSkillText); if ( !this._victorySkillWindow ) { this._victorySkillWindow = new exports.Window_VictorySkill(); this.addWindow(this._victorySkillWindow); } var actorIdx = Number(this._victoryStep.substr(5)); this._victorySkillWindow.setActor($gameParty.battleMembers()[actorIdx]); this._victorySkillWindow.open(); }; Scene_Battle.prototype.finishVictorySkill = function() { SoundManager.playOk(); if ( this._victoryStep ) { var stepIdx = this._skillSteps.indexOf(this._victoryStep); if ( stepIdx >= 0 ) { this._skillSteps.splice(stepIdx, 1); } } this.processNextVictoryStep(); if ( this._victoryStep && this._skillSteps ) { var stepIdx = this._skillSteps.indexOf(this._victoryStep); if ( stepIdx >= 0 ) { var actorIdx = Number(this._victoryStep.substr(5)); this._victorySkillWindow.openness = 0; this._victorySkillWindow.setActor($gameParty.battleMembers()[actorIdx]); this._victorySkillWindow.open(); } else { this._victorySkillWindow.close(); } } else { this._victorySkillWindow.close(); } }; Scene_Battle.prototype.isGainedVictorySkill = function(actor) { if ( actor.victoryLpSkills().length > 0 ) { return true; } return false; }; }((this.dsGainLpResult02 = this.dsGainLpResult02 || {})));