- Joined
- Jul 2, 2014
- Messages
- 12,742
- Reaction score
- 11,348
- First Language
- English
- Primarily Uses
- RMMV
This thread is a compilation of tweaks and snippets I've written as I work through my game or respond to requests on these forums.
A couple of small things are by me to fulfill requests, but most of this is for the Yanfly Engine Plugins, both fixes and modifications.
Due to Yanfly's terms of use, I can't post the full fixes in plugin format, so they will require some user installation. You'll want a text editor, such as Notepad++, that will show you line numbers (the common shortcut to go to a specific line is Ctrl+G).
I use three common instructions here:
Standalone plugins:
Custom Hit Formula for MZ
Chanting Animations for MZ/MV
Activate Equipment
Release Enemies
Action Sequence Targets Extension
Subclass Mods Extension
Party Approval
Profanity Filter for MZ/MV
Eval Tags MZ
A couple of small things are by me to fulfill requests, but most of this is for the Yanfly Engine Plugins, both fixes and modifications.
Due to Yanfly's terms of use, I can't post the full fixes in plugin format, so they will require some user installation. You'll want a text editor, such as Notepad++, that will show you line numbers (the common shortcut to go to a specific line is Ctrl+G).
I use three common instructions here:
- Save a plugin indicates the following code can be copied into an empty text file, saved as a .js file in your plugins folder, and then added in your plugin manager.
- Add a line means you go to the specified line number, place your cursor at the end of that line, then press Enter and paste the code as a new line.
- Change a line to read means you go to the specified line number, highlight it, and replace the entirety of that line with the code I provided.
This small plugin was written by request - it will allow two events to move through each other if they both have the <passable> notetag. They will still interact normally with players, impassable tiles and other events, unless you turn Through ON as normal.
Code:
// Allow two events to move through each other if they both have the <passable> notetag
Game_Event.prototype.isCollidedWithEvents = function(x, y) {
var events = $gameMap.eventsXyNt(x, y);
return $dataMap.events[this._eventId].meta["passable"] && events.length>0 ? !events.some(event => $dataMap.events[event._eventId].meta["passable"]) : events.length>0;
};
The way this plugin handles the various forms of payment for skills is what I consider a bug: it ignores dual MP/TP costs, it subtracts costs (e.g. spell slots) once for every target hit by a skill, and it appears to double-charge MP on top of that per-target payment.
This modification corrects all of those behaviors to pay the cost once when the skill is performed and to treat TP costs as expected.
Go to line 1980. Select from 1980 through 1988 and delete it.
Then go up to line 1883. Replace that whole function from 1883 through 1891 with:
This modification corrects all of those behaviors to pay the cost once when the skill is performed and to treat TP costs as expected.
Go to line 1980. Select from 1980 through 1988 and delete it.
Then go up to line 1883. Replace that whole function from 1883 through 1891 with:
Code:
Game_Actor.prototype.paySkillCost = function(skill) {
var classMagic = FROG.Magic.getClassMagic(this, skill.stypeId);
if (classMagic)
{
switch (classMagic.resource) {
case "Spell Slots":
FROG.Magic.gainSlotUsed(this, skill, 1);
// Only remove the spell for Prepared casters, not Hybrid ones
if (classMagic.casterType == "Prepared") {
FROG.Magic.gainSpellPrepared(this, skill, -1);
}
break;
case "Magic Points":
this._mp -= this.skillMpCost(skill);
break;
case "Powers":
FROG.Magic.gainPowerUsed(this, skill, 1);
break;
}
FROG.Magic.useSpellComponents(this, skill);
FROG.Magic.gainSpellXp(this, skill);
}
this._tp -= this.skillTpCost(skill);
}
There's what I consider an oversight in this plugin - if the user has set their Window Color to be anything other than the default transparent, that color will bleed over the entire screen when using a picture choice. To correct, save a plugin with the following code:
Code:
Window_PictureChoiceList.prototype.updateTone = function()
{
this.setTone(0, 0, 0);
};
This plugin appears to be broken out of the box. To make it work correctly, change line 439 to read:
Code:
var elmtnValue = item.damage.elementId<0 ? subject.attackElements() : [item.damage.elementId];
elmtnValue = elmtnValue.reduce(function(r, elementId) {
This plugin has a game-breaking bug out of the box. It will cause the game to crash whenever a skill is selected that does not require target selection. To correct it, swap lines 1376 and 1377. They should read:
Code:
this.setActionIcon();
VictorEngine.BattleStatusWindow.onSelectAction.call(this);
This plugin appears to be broken out of the box. To make it work correctly, save the following as a plugin beneath the Event Conditions in your plugin manager.
Code:
Game_Event.prototype.meetsConditions = function(page) {
var c = page.conditions;
if (c.switch1Valid) {
if (!$gameSwitches.value(c.switch1Id)) {
return false;
}
}
if (c.switch2Valid) {
if (!$gameSwitches.value(c.switch2Id)) {
return false;
}
}
if (c.variableValid) {
if ($gameVariables.value(c.variableId) < c.variableValue) {
return false;
}
}
if (c.selfSwitchValid) {
var key = [this._mapId, this._eventId, c.selfSwitchCh];
if ($gameSelfSwitches.value(key) !== true) {
return false;
}
}
if (c.itemValid) {
var item = $dataItems[c.itemId];
if (!$gameParty.hasItem(item)) {
return false;
}
}
if (c.actorValid) {
var actor = $gameActors.actor(c.actorId);
if (!$gameParty.members().contains(actor)) {
return false;
}
}
var condition = VictorEngine.EventConditions.getCustomCondition(page);
if (condition)
return eval(condition[1]);
return true;
};
The default behavior of the barrier is to only absorb damage inflicted by a skill. This plugin will make it absorb all damage, such as negative regeneration (poison) effects.
Code:
// Make Yanfly barrier block indirect damage
Game_Battler.prototype.gainHp = function(value) {
var blocked=false;
if (value<0 && !BattleManager._subject && this.barrierPoints()>0)
{
var damage=-value;
damage = this.loseBarrier(damage, 1, 0);
if (!damage)
blocked=true;
else
value=-damage;
}
if (!blocked)
{
this._result.hpDamage = -value;
this._result.hpAffected = true;
this.setHp(this.hp + value);
}
};
Action Sequence Pack 3 adds commands for camera control, but has a bug that causes screen shake commands to not work. To fix this, go to line 830 and add the line:
Code:
this.x += Math.round($gameScreen.shake());
There's a fairly niche bug in the Animated Sideview Enemies plugin. If you have an enemy with the Sideview Collapse notetag who dies and later gets revived, they retain the glow effect from the collapse animation.
To fix this, save a plugin with the following code beneath the Sideview Enemies:
To fix this, save a plugin with the following code beneath the Sideview Enemies:
Code:
Sprite_Enemy.prototype.revertToNormal = function() {
this._shake = 0;
this.blendMode = 0;
this.opacity = 255;
this.setBlendColor([0, 0, 0, 0]);
if (this._svBattlerEnabled)
{
this._mainSprite.setBlendColor([0, 0, 0, 0]);
this._mainSprite.blendMode=0;
}
};
Something that comes up pretty frequently is the interaction between some of the commands in Yanfly's Buffs & States and Auto Passive States - specifically, that (as unintuitive as it seems) passive states do not execute Custom Apply or Custom Remove Effects. Adding this functionality requires a few steps. First, save the following as a plugin:
Then, in the Yanfly plugin, go to line 419 and add the line:
Go to line 444 and add the lines:
Go to line 449 and add the lines:
Go to line 605 and add the line:
Finally, go to line 611 and add the line:
Code:
Game_BattlerBase.prototype.setCopy = function(value) {
console.log("Set copy" + value);
this.isCopy=value;
};
Window_EquipItem.prototype.updateHelp = function() {
Window_ItemList.prototype.updateHelp.call(this);
if (this._actor && this._statusWindow) {
var actor = JsonEx.makeDeepCopy(this._actor);
actor.setCopy(true);
actor.forceChangeEquip(this._slotId, this.item());
this._statusWindow.setTempActor(actor);
}
};
Code:
this._oldPassives=this._passiveStatesRaw;
Code:
if (!this.isCopy && this._oldPassives && !this._oldPassives.contains(raw[i]))
this.addStateEffects(raw[i]);
Code:
if (!this.isCopy && this._oldPassives)
{
for (i=0; i<this._oldPassives.length; i++)
{
if (!raw.contains(this._oldPassives[i]))
this.removeStateEffects(this._oldPassives[i]);
}
}
this._oldPassives=undefined;
Code:
this._oldPassives=this._passiveStatesRaw;
Code:
this._oldPassives=this._passiveStatesRaw;
In the latest version of Auto Passive States, the included switch conditions (and any custom conditions that reference switches) do not function correctly. To fix this, add this plugin:
Code:
// Fix for switch conditions
Game_Map.prototype.refresh = function() {
this.events().forEach(function(event) {
event.refresh();
});
this._commonEvents.forEach(function(event) {
event.refresh();
});
this.refreshTileEvents();
$gamePlayer.refresh();
this._needsRefresh = false;
};
When the Show HP Text plugin parameter is on, attacks will cause a duplicate hit reaction to be displayed. Save a plugin with the following code, placed above the Battle Engine Core.
Code:
Window_BattleLog.prototype.displayHpDamage = function(target) {
if (target.result().hpAffected) {
this.push('addText', this.makeHpDamageText(target));
}
};
By default, Custom Remove Effects do not trigger when the states are removed by death. If you would like them to, save a plugin with the following code and put it above all Yanfly plugins in your plugin manager.
Code:
Game_BattlerBase.prototype.clearStates = function()
{
if (this._states)
{
for (let i=0; i<this._states.length; i++)
{
if (Imported.YEP_X_StateCategories && this.isCustomClearStates() && (($gameTemp._deathStateClear && $dataStates[this._states[i]].category.contains('BYPASS DEATH REMOVAL')) || ($gameTemp._recoverAllClear && $dataStates[this._states[i]].category.contains('BYPASS RECOVER ALL REMOVAL'))))
continue;
this.removeState(this._states[i]);
}
}
this._states = [];
this._stateTurns = {};
};
There's a bug in the Class Change Core wherein your level in any class is calculated according to the exp chart of your current class. Save a plugin with the following code and place it immediately above the Class Change Core.
Then, in Class Change Core, go to line 676 and change it to read:
Code:
Game_Actor.prototype.expForLevel = function(level, classId) {
var c = classId ? $dataClasses[classId] : this.currentClass();
var basis = c.expParams[0];
var extra = c.expParams[1];
var acc_a = c.expParams[2];
var acc_b = c.expParams[3];
return Math.round(basis*(Math.pow(level-1, 0.9+acc_a/250))*level*
(level+1)/(6+Math.pow(level,2)/50/acc_b)+(level-1)*extra);
};
Code:
if (this.expForLevel(level + 1, classId) > this._exp[classId]) break;
There's a bug in Yanfly's Counter Control that causes Attacker and Defender conditions to not be evaluated. To fix this, replace the following lines.
Line 1227:
Line 1229
Line 1232
Line 1234
Thanks to @caethyril for this fix.
Line 1227:
} else if (line.match(/ATTACKER[ ]([^\s]*)[ ](.*)/i)) {
Line 1229
var value2 = String(RegExp.$2);
Line 1232
} else if (line.match(/DEFENDER[ ]([^\s]*)[ ](.*)/i)) {
Line 1234
var value2 = String(RegExp.$2);
Thanks to @caethyril for this fix.
There's a bug in Yanfly's Counter Control that causes Custom Counter Condition tags to not be evaluated. There are several edits necessary to fix this: go to line 1105 and change it to read:
Then go to line 1112 and change it to read:
Lastly, go to line 1122 and change it to read:
Code:
if (!this.meetCounterConditionsEval(skill, subject, target)) return false;
Code:
if (skill.counterConditionEval=='') return true;
Code:
var code = skill.counterConditionEval;
The Counter Control as written does not support multi-element attacks created by the Element Core. Making this change will cause the Element: x counter condition to trigger if that element is included in a multiple element hit. Change line 1286 to read:
Code:
return this._subject.attackElements().contains(elementId) || this._action.getItemElements().contains(elementId);
The multiplication multi-element rule does not work correctly if the target has a rate of 0% for one of the elements. Add a line after 740:
Code:
elements.sort(function(a, b) {return target.elementRate(b)-target.elementRate(a)});
There's a bug in Enhanced TP Modes that prevents the Learn Unlock notetag from working. Change line 3723 to read:
Code:
var tpMode = skill.learnUnlockedTpModes[i];
There's a bug in Hide/Show Shop Items that causes items to be hidden by default, not evaluated by the plugin parameter. Change line 130 to read:
Code:
// if (!item.note) return false;
There's a weirdly blatant bug in Instant Cast wherein winning a battle using an instant cast skill results in the next battle starting with no party/actor command window to continue playing with. Save a plugin with the following code:
Code:
var TUR_endBattle = BattleManager.endBattle;
BattleManager.endBattle = function(result)
{
this._instantCasting=false;
TUR_endBattle.call(this, result);
};
An edge scenario in this plugin causes a crash if the player is given a Select Item screen and has no items to choose. Save the following plugin from @caethyril:
Code:
/*:
* @target MV
* @plugindesc Patches YEP Message Backlog - prevent error on selecting null item.
* @author Caethyril
* @url https://forums.rpgmakerweb.com/threads/159752/
* @help Load this plugin after YEP_X_MessageBacklog.
*
* Free to use and/or modify for any project, no credit required.
*/
;void (function(alias) {
Window_EventItem.prototype.backlogAddSelectedChoice = function() {
if (this.item()) // only if item is truthy
alias.apply(this, arguments);
};
})(Window_EventItem.prototype.backlogAddSelectedChoice);
There's a bug in Yanfly's Quest Journal wherein you select the Quest List Window setting "Show Types" to be false, and no quests are listed. This will cause all quests to list correctly under that setting. Change line 2910 to read:
Code:
if (type=='' || questData.type === type) result.push(questId);
There's a bug in Yanfly's Selection Control that makes Param Conditions not function. To fix this, go to line 1465. Add a line that says:
Then, go to the new line 1467 and change it to read:
Then go to line 1470 and add the line
Code:
var evalResult;
Code:
evalResult = eval(code);
Code:
return evalResult;
For some reason, Yanfly's Selection Control intentionally ignores row-based selection restrictions on skills with a scope of allies. To make these function correctly, delete (in order) lines 1406, 1411 and 1416 (before deleting anything, that's lines 1406, 1412 and 1418).
This plugin modifies the order that battlers are cycled through to be by screen position - so no matter what order you added the enemies to the troop, left/right will move left and right across the screen. That works perfectly for enemies, but can be screwy with actors depending on your formation of them and whether that order changes when an actor steps forward to take their turn.
It will be more intuitive to make sure the actors are always scrolled through in party order (and this works particularly well with "Use Up/Down," below).
Place your cursor at the beginning of line 1555 and type /* to begin a comment. Place your cursor at the end of line 1560 and type */ to end the comment. This makes the code non-functional without deleting it.
Then add a new line and paste in:
It will be more intuitive to make sure the actors are always scrolled through in party order (and this works particularly well with "Use Up/Down," below).
Place your cursor at the beginning of line 1555 and type /* to begin a comment. Place your cursor at the end of line 1560 and type */ to end the comment. This makes the code non-functional without deleting it.
Then add a new line and paste in:
Code:
this._enemies.sort(function(a, b) {
if (a.isActor() && b.isActor())
return a.index() - b.index();
else if (a.isActor() != b.isActor())
return a.isActor() ? 1 : -1;
else if (a.spritePosX() === b.spritePosX()) {
return a.spritePosY() - b.spritePosY();
}
else
return a.spritePosX() - b.spritePosX();
});
In the default battle engine, when you're using an effect that targets party members, you use up/down to select the target. This makes sense both because your party members are arranged vertically, and because you can see their names listed vertically on the bottom.
However, when using a skill that has been modified with selection control (you can only target party members afflicted with blind for your cure-blind spell), up and down no longer work, and you're forced to use left and right. The below plugin will restore the ability to use up and down again.
However, when using a skill that has been modified with selection control (you can only target party members afflicted with blind for your cure-blind spell), up and down no longer work, and you're forced to use left and right. The below plugin will restore the ability to use up and down again.
Code:
// Make up and down work with Yanfly Selection Control
Window_Selectable.prototype.processCursorMove = function() {
if (this.isCursorMovable()) {
var lastIndex = this.index();
if (Input.isRepeated('down')) {
if (SceneManager._scene._enemyWindow && SceneManager._scene._enemyWindow.active)
this.cursorRight(Input.isTriggered('right'));
else
this.cursorDown(Input.isTriggered('down'));
}
if (Input.isRepeated('up')) {
if (SceneManager._scene._enemyWindow && SceneManager._scene._enemyWindow.active)
this.cursorLeft(Input.isTriggered('left'));
else
this.cursorUp(Input.isTriggered('up'));
}
if (Input.isRepeated('right')) {
this.cursorRight(Input.isTriggered('right'));
}
if (Input.isRepeated('left')) {
this.cursorLeft(Input.isTriggered('left'));
}
if (!this.isHandled('pagedown') && Input.isTriggered('pagedown')) {
this.cursorPagedown();
}
if (!this.isHandled('pageup') && Input.isTriggered('pageup')) {
this.cursorPageup();
}
if (this.index() !== lastIndex) {
SoundManager.playCursor();
}
}
};
There's a bug in Yanfly's Skill Core that makes Custom Show conditions not function. To fix this, go to line 765 and change it to read:
Code:
visible=eval(code);
There's a bug in Yanfly's Skill Core where using a Learn Show Eval to show a skill in an actor's list of learnable skills also makes it automatically learnable (thus defeating the purpose of requirements and the Learn Require Eval). To fix this, select lines 935 and 936 and cut them. Go to line 927, add a line, and paste those two lines in.
Now, using a Learn Show Eval will make a skill show up in the actor's list, but it will be greyed out and disabled until they actually meet the requirements.
Now, using a Learn Show Eval will make a skill show up in the actor's list, but it will be greyed out and disabled until they actually meet the requirements.
There's a very niche bug when using the Skill Learn System with the Class Change System. If you're looking at the available skills for an actor to learn and you use page up/down to change to an actor who doesn't know as many classes, the game will crash.
To fix this, go to line 1703, add a line, and paste in:
To fix this, go to line 1703, add a line, and paste in:
Code:
if (Imported.YEP_ClassChangeCore)
this._commandWindow._index=0;
Using the <Target: Everybody> notetag causes the effect to only target one party member when used from the menu. The below plugin will make it correctly target all party members.
Code:
Game_Action.prototype.isForAll = function() {
return this.checkItemScope([2, 8, 10, "EVERYBODY"]);
};
There is a bug in this plugin that prevents the Escape event from ever being called. On line 36 of the plugin, change the words "Escape Battle Event" to read "Battle Escape Event"
There are bugs in this plugin that don't correctly read the Weapon Animation notetag and incorrectly displays it as a dual wielding attack when using only one weapon.
On lines 421, 426, and 430, change it to read:
Then, on line 446, change it to read
On lines 421, 426, and 430, change it to read:
return this._cacheWeaponAni;
Then, on line 446, change it to read
Code:
if (this.weapons().length>1 && this.getUniqueWeaponAni()) return this.getUniqueWeaponAni();
Standalone plugins:
Custom Hit Formula for MZ
Chanting Animations for MZ/MV
Activate Equipment
Release Enemies
Action Sequence Targets Extension
Subclass Mods Extension
Party Approval
Profanity Filter for MZ/MV
Eval Tags MZ
Attachments
Last edited: