ATT_Turan

Forewarner of the Black Wind
Regular
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:
  • 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.
Please let me know if you find any bugs while using these snippets, and if you have any reproducible bugs you'd like addressed, or ideas for features to add.

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;
};

This is legitimately a little plugin I wrote, attached at the bottom of this post. This will emulate the Phantasy Star movement system - if you press against a wall, and there's a valid space "stepping" around it, you'll automatically move that way.
Animation.gif
It's compatible with both MV and MZ.

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:
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:
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:
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);
    }
};
Then, in the Yanfly plugin, go to line 419 and add the line:
Code:
    this._oldPassives=this._passiveStatesRaw;
Go to line 444 and add the lines:
Code:
      if (!this.isCopy && this._oldPassives && !this._oldPassives.contains(raw[i]))
          this.addStateEffects(raw[i]);
Go to line 449 and add the lines:
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;
Go to line 605 and add the line:
Code:
    this._oldPassives=this._passiveStatesRaw;
Finally, go to line 611 and add the line:
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.
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);
};
Then, in Class Change Core, go to line 676 and change it to read:
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:
} 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:
Code:
    if (!this.meetCounterConditionsEval(skill, subject, target)) return false;
Then go to line 1112 and change it to read:
Code:
    if (skill.counterConditionEval=='') return true;
Lastly, go to line 1122 and change it to read:
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:
Code:
    var evalResult;
Then, go to the new line 1467 and change it to read:
Code:
      evalResult = eval(code);
Then go to line 1470 and add the line
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:
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.
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.

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:
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: 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

  • TUR_WallSlide.js
    2.3 KB · Views: 36
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
Added a fix for Custom Show Eval in Yanfly Skill Core.
 

TobyYasha

Spaghetti & Coding go hand in hand.
Regular
Joined
Sep 11, 2019
Messages
194
Reaction score
304
First Language
English
Primarily Uses
RMMZ
Thanks for the fixes, i'm already using the yanfly selection up/down fix.
I do remember having some problems with the yanfly's counter conditions and the skill show eval so when i might need them i'll surely get them from here.
 

lianderson

Regular
Regular
Joined
Dec 27, 2012
Messages
863
Reaction score
1,298
First Language
English
Primarily Uses
N/A
Oooooooooooo, these are fancy. Good job human!
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
Added a fix for row-based selection restrictions in Selection Control.
 

Blackfield

Regular
Regular
Joined
Sep 15, 2017
Messages
126
Reaction score
70
First Language
german, english
Primarily Uses
RMMV
Amazing thanks! Please add terms of use if you like. For now I presume it is free for commercial and non commercial use? Credits?
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
Most of this isn't my whole work, I'm just fixing/augmenting existing plugins, so you'd adhere to the terms of those plugins. For the few little snippets that are mine, they're free to use in any project without credit.
 

JPlaysan

日本語学習者
Regular
Joined
Jul 4, 2019
Messages
122
Reaction score
91
First Language
English
Primarily Uses
RMMZ
@ATT_Turan

Could you have a look at yanfly's equip skill slots plugin if you have it when you can? There seems to be a bug (I think) with skills appearing since one would have to leave the skill menu then return to it for the skill(s) in question to appear for it to be equipped in a skill slot. I'll have to revisit this issue I find to be having to possibly screenshot or take a short video of it.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
@JPlaysan I'm happy to take a look, but that description is pretty confusing. Please take some screenshots and make a list of instructions in complete sentences of what you're doing and what you think is wrong.

Then I'll see if I can reproduce it as a bug.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
Added a plugin for the Phantasy Star-style wall slide.
 

Blackfield

Regular
Regular
Joined
Sep 15, 2017
Messages
126
Reaction score
70
First Language
german, english
Primarily Uses
RMMV
Is there any chance you can have a look at a problem I am experiencing with the YEP Dragonbones integration?

For some reason characters don't flash anymore using the flash-animation from the database... I don't know enough about the Engine but from my perspective that could be an easy fix?
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
@Blackfield I'll take a look at your thread later, but I don't promise much - I don't have any experience with Dragonbones.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
Added a fix for Yanfly's Utility Common Events.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
Added a fix for Yanfly's Quest Journal.
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,247
Reaction score
1,578
First Language
English
Primarily Uses
RMVXA
Added a fix for Yanfly's Quest Journal.

Change line 2914 to read:
Did you mean a different line?
In the plugin I see 2914 as blank, just after the close bracket for Game_System.prototype.getTypeQuests = function(category, type)
That's from v1.02
v1.01 has line 2914 the close bracket for Game_System.prototype.getQuestDescriptionIndex = function(questId)
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,742
Reaction score
11,348
First Language
English
Primarily Uses
RMMV
Did you mean a different line?
In the plugin I see 2914 as blank, just after the close bracket for Game_System.prototype.getTypeQuests = function(category, type)
Huh! That's weird. For some reason, the copy of the file in my game project has more lines someplace than the copy from the complete library zip file, but they're both version 1.02.

I'll correct it - that should be line 2910.
 

Latest Threads

Latest Profile Posts

Christmas decorations! !! :kaojoy:
20231209_114754.jpg
Sophie is already helping dismantle the tree...a month early, of course. Such a helpful kitten!
making horse character for game :D at the end it will have 8 directions puling wagon

2p8jdax
I'm back after a short hiatus (0-0), after playing another eden i think i've understood the fundamentals of world building a lil' bit more so ima use that for crimson evan, (btw working on a trailer teehee)
image.png

I think this is good progress.

Forum statistics

Threads
136,876
Messages
1,270,936
Members
180,641
Latest member
1232421
Top