Skip to content

Instantly share code, notes, and snippets.

@fluid-decanter
Created January 26, 2022 00:33
Show Gist options
  • Save fluid-decanter/f4acdceb7abf2568001ac73d9d0e9869 to your computer and use it in GitHub Desktop.
Save fluid-decanter/f4acdceb7abf2568001ac73d9d0e9869 to your computer and use it in GitHub Desktop.
Addon to a Yanfly RMMV plugin. Shows mastery status instead of class level in actor's class list.
// YEP_SkillLearnSystem_MasteryCheck.js
/*:
@plugindesc v0.3 Shows mastery status instead of class level in actor's class list.
@author Decanter
@help
Shows count of skills obtained vs skills obtainable on class change list.
Colors count for non-mastered classes differently.
Place in plugin list directly after YEP_SkillLearnSystem.
Overrides one function in YEP_ClassChangeCore.
@param mastered text
@desc Text to show instead of skill count when mastered. Leave blank to still show skill count.
@default
@param mastered color
@desc Color for mastered classes. Hex code formatted #ffffff
@default #84aaff
@param unmastered color
@desc Color for unmastered classes. Hex code formatted #ffffff
@default #66cc40
@param stalled color
@desc Color for classes that can't be mastered yet. Hex code formatted #ffffff
@default #ffffff
*/
(function() {
var params = PluginManager.parameters("YEP_SkillLearnSystem_MasteryCheck");
var masteredText = String(params["mastered text"]);
var masteredColor = String(params["mastered color"]);
var unmasteredColor = String(params["unmastered color"]);
var stalledColor = String(params["stalled color"]);
// override
Window_ClassList.prototype.drawClassLevel = function(item, x, y, width) {
var aryActorSkills = this._actor._skills;
var aryClassSkills = item.learnSkills;
var numClassSkills = aryClassSkills.length;
var arySkillsUnlearned = aryClassSkills.filter(function(el){ return (aryActorSkills.indexOf(el) == -1) }, this);
var numSkillsUnlearned = arySkillsUnlearned.length;
var arySkillsStalled = arySkillsUnlearned.filter(function(el){ return !this.meetsRequirements($dataSkills[el]) }, this);
var numSkillsStalled = arySkillsStalled.length;
var numClassSkillsLearned = numClassSkills - numSkillsUnlearned;
var skillCountText;
if (numSkillsUnlearned == 0 && masteredText.length > 0) {
skillCountText = masteredText;
} else {
skillCountText = numClassSkillsLearned + "/" + numClassSkills;
}
this.resetFontSettings();
if (numSkillsUnlearned == 0) {
this.changeTextColor(masteredColor);
} else if (numSkillsUnlearned == numSkillsStalled) {
this.changeTextColor(stalledColor);
} else {
this.changeTextColor(unmasteredColor);
}
this.contents.fontSize = Yanfly.Param.CCCLvFontSize;
this.drawText(skillCountText, x, y, width, 'right');
};
// copying guts of Window_SkillLearn.meetsRequirements
// because Yanfly apparently didn't anticipate anyone checking this outside that window
Window_ClassList.prototype.meetsRequirements = function(skill) {
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;
} else {
if (skill.learnRequireLevel > this._actor.level) return false;
}
for (var i = 0; i < skill.learnRequireSkill.length; ++i) {
var skillId = skill.learnRequireSkill[i];
if (!$dataSkills[skillId]) continue;
if (!this._actor.isLearnedSkill(skillId)) return false;
}
for (var i = 0; i < skill.learnRequireSwitch.length; ++i) {
var switchId = skill.learnRequireSwitch[i];
if (!$gameSwitches.value(switchId)) return false;
}
return true;
};
// copying guts of Window_SkillLearn.getEvalLine
// because Yanfly apparently didn't anticipate anyone checking this outside that window
Window_ClassList.prototype.getEvalLine = function(evalLine) {
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;
eval(evalLine);
return value;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment