ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
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;
};

A handy little function for making dynamic skill effects. Good in action sequences, targeting restrictions, or A.I. conditions. (e.g. use this group-wide poison attack only if fewer than 3 party members are already affected)
Code:
// Pass $gameTroop or $gameParty and the ID. Returns how many in that group have that state
function StatesInGroup(group, stateId)
{
    return group.aliveMembers().filter(member => member.isStateAffected(stateId)).length;
};
An example of use for a Yanfly Battle A.I. Core condition that blows up the party with an AoE spell if more than half of them are soaked in oil would be:
Code:
Eval StatesInGroup($gameParty, 15)>2: Explosion

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

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());

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

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

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 1466 and change it to read:
Code:
      var 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).

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.

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"

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.
 

Attachments

  • TUR_WallSlide.js
    2.1 KB · Views: 15
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
First Language
English
Primarily Uses
RMMV
Added a fix for Custom Show Eval in Yanfly Skill Core.
 

Johnny_Ray

Also known as Toby Yasha
Veteran
Joined
Sep 11, 2019
Messages
171
Reaction score
251
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

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

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
First Language
English
Primarily Uses
RMMV
Added a fix for row-based selection restrictions in Selection Control.
 

Blackfield

Veteran
Veteran
Joined
Sep 15, 2017
Messages
41
Reaction score
15
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
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
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

知識は力なり
Veteran
Joined
Jul 4, 2019
Messages
96
Reaction score
65
First Language
English
Primarily Uses
RMMV
@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
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
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
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
First Language
English
Primarily Uses
RMMV
Added a plugin for the Phantasy Star-style wall slide.
 

Blackfield

Veteran
Veteran
Joined
Sep 15, 2017
Messages
41
Reaction score
15
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
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
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
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
First Language
English
Primarily Uses
RMMV
Added a fix for Yanfly's Utility Common Events.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
First Language
English
Primarily Uses
RMMV
Added a fix for Yanfly's Quest Journal.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,384
Reaction score
1,213
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
Veteran
Joined
Jul 2, 2014
Messages
5,553
Reaction score
3,619
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 Posts

Latest Profile Posts

Tried something. Little sneak peak of Unity AD.
M42S7Us.gif

It's the little things. Lengthened the time the bar fades in and out to be a bit more comfortable.
3 days until release!

Forum statistics

Threads
125,734
Messages
1,173,106
Members
164,878
Latest member
INKYLIKE
Top