Original Source
- Original title: Dan's Daring Debugs & Discoveries
- Original author: RCXGaming
- Original date: April 4, 2023
- Source thread: https://forums.rpgmakerweb.com/threads/dans-daring-debugs-discoveries.156398/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > JS Plugin Releases (RMMV)
Summary
(Clearly not inspired by this thread by @ATT_Turan what are you talking about ) Think of this thread as the accumulation and distribution of the knowledge I've gained messing around and adapting my projects into RPG Maker MV. A lot of this is information that was curated to me while asking for help (the inverse of Turan's thread) and from me scrabbling through the depths of javascript hell, so I figured... why not make a thread for it to help other people. No man is an island, after all, and...
Archived First Post

)Think of this thread as the accumulation and distribution of the knowledge I've gained messing around and adapting my projects into RPG Maker MV.
A lot of this is information that was curated to me while asking for help (the inverse of Turan's thread) and from me scrabbling through the depths of javascript hell, so I figured... why not make a thread for it to help other people. No man is an island, after all, and honestly it just makes me feel good to be useful in some small way.
I also see this as being a huge help for centralizing this information so things aren't just hidden in some obscure "help me!" threads of mine that nobody is ever going to look up.
Warning, though: I don't really do requests to fix scripts outright, since I'm quite a busy guy and I'm not terribly competent at making new javascript features - just lucky most of the time.
I also can't upload full scripts for Yanfly or anybody else behind a paywall due to their terms of service, so I can only put up the snippets I myself have modified and instructions on how to put them in to your version of the script.
I recommend these general tips:
- Always make a backup of the original script in case something goes wrong
- CTRL + F is your best friend, as it saves time when finding sections of the script you're editing.
This is also the prime place I will shout out relevant people who have helped me with certain issues, since those tweaks will be posted here too even if I didn't have a hand in editing the code personally.
An... interesting bug with TSR_Popup is that if you inflict elemental damage (weak/resist/immune) to a character who is currently suffering from a damage over time status, the elemental damage pop-up will stay attached to the damage numbers and will only get fixed by taking regular damage again.
This strange little visual bug can be very confusing for your players as it makes them think your poison states are somehow dealing elemental damage.
Here are two fixes, depending on if you are using Yanfly_X_ExtDoT or not.
If you do have Yanfly_X_ExtDoT installed, attach this code to the processDamageOverTimeStateEffect section, underneath if (value !== 0) {:
this.result()._haveElementEffect = false
If you don't have Yanfly_X_ExtDoT installed:
if (!Imported.YEP_X_ExtDoT) {
//this.checkElementalPopup(preValue, value); <<< THIS PART HERE
}
Comment out this code in TSR_Popups to achieve the same result.
This is a pretty severe fundamental bug that prevents Victor Engine's extremely useful Action Dodge/States function from working.
How do you fix it? Well...
VictorEngine.getAllElements(subject, item).reduce...etc
CTRL + F to find this line, then change the "item" to:
VictorEngine.getAllElements(subject, this).reduce...etc
Problem solved! If you see any of Victor's scripts shoot up this error with getAllElements, just change "item" to "this".
Victor's Event Conditions has a catastrophic oversight in its coding that makes it useless.
To be precise, it only checks if the custom condition of its comment calls are true while ignoring database applied ones (and even blank conditions, so events with no checks don't appear either) - to quote Turan, the logic is completely wrong.
This renders map and troop events unusable unless you put in identifying code (eg. result = true or something like that - it ignores database applied conditions) for EVERY SINGLE EVENT ON EVERY MAP. This is a huge shock coming off of VX Ace, where it only adds extra conditions to events.
However, there is one easy step to completely fix it! Just save the following code as a JS file and put it below Event Conditions on your plugin set-up:
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;
};
This wonderful little scriptlet by Turan will solve the issue with Event Conditions and make it function the same as in VX Ace.
(Don't expect much here.)
A string-based state pop-up addon for TSR_Popups.
Refer to his explanation here on how to implement it into your game, it's pretty in-depth.
The default horizontal bar for Yanfly's Turn Order Display is pretty cumbersome. It's more forgivable for sideview battles, but as someone who uses a front-facing battle system it was getting in my way quite a bit.
So I made a mod to make it both vertical and auto-aligned it so it never shows more than 8 icons on the screen at once, as a way to prevent it from overlapping certain windows (I use Moghunter's Battle HUD, for reference.)
I should mention that this was designed to be used with Yanfly's Battle Core omitting battle log messages, as the turn order totem will overlap messages if you have traditional battle log messages turned on or not centered.
This also contains a bonus quick-and-dirty method of hiding certain icons for "object" enemies.
WARNING: This fix only works for DTB (default) battle systems. If you use any other type of battle system, it will not work. Not interested in fixing it, sorry.
IF YOU CANNOT FIND THE EXACT LINES IN PARTICULAR, PLEASE CTRL+F THE PARTS I HAVE DIRECTLY BROUGHT UP.
Change these specific lines of code -
Line 654
this._turnOrderDisplay[i].updateDestinationX(); // Replace the X with a Y.
Line 780
this.updateDestinationX(); // Replace the X with Y.
Line 782
this.x = this._destinationX; // Replace the X with Y.
Line 812
this.y = this._destinationY; // Replace this Y with X.
Line 991 through 997
// Change all the X's to Y, INCLUDING THE HEADER
Window_TurnOrderIcon.prototype.updateDestinationX = function() {
if (!this.battler()) return;
if (this.battler().isDead()) return;
this._destinationX = 0;
this.calculateDestinationXAlign(); // Except for this one!!
this.calculateDestinationXIndex();
Line 1036 through 1044
// Replace every X with a Y
Window_TurnOrderIcon.prototype.calculateDestinationXIndex = function() {
var size = this.aliveMembersSize() - this.turnOrderDisplayIndex();
var distance = this.width * size;
if (this._direction === 'left') {
this._destinationX -= distance;
} else if (this._direction === 'right') {
this._destinationX += distance;
}
};
Line 1128 through 1141, replace this:
Window_TurnOrderIcon.prototype.destinationY = function() {
var value = Yanfly.Param.TODPositionY;
if (this._helpWindow && this._helpWindow.visible) {
var cap = this._helpWindow.height;
this._selectHeight = this._selectHeight ||
Math.round(this.contents.height / 4);
value = Math.max(value, cap + this._selectHeight);
}
if (!this.battler()) return value;
if (this.battler().isSelected()) {
value -= this._selectHeight;
}
return value;
};
with this instead:
Window_TurnOrderIcon.prototype.destinationX = function() {
var value = 20;
if (this._helpWindow && this._helpWindow.visible) {
var cap = this._helpWindow.height;
this._selectHeight = this._selectHeight ||
Math.round(this.contents.height / 4);
value = Math.max(value, cap + this._selectHeight + 1200);
}
if (!this.battler()) return value;
if (this.battler().isSelected()) {
value += this._selectHeight + 5;
}
return value;
};
(Value 20 is the X position of the turn order totem. You can truthfully make it whatever number you want, as it shifts the location to another spot on the screen.)
--
Line 1143 through 1161, replace this:
Window_TurnOrderIcon.prototype.updatePosition = function() {
if (BattleManager._escaped) return;
if (this._destinationX !== this.x) {
var desX = this._destinationX;
var moveAmount = Math.max(1, Math.abs(desX - this.x) / 4);
if (this.x > desX) this.x = Math.max(this.x - moveAmount, desX);
if (this.x < desX) this.x = Math.min(this.x + moveAmount, desX);
var cap1 = this.destinationY() - this.contents.height / 2;
var cap2 = this.destinationY() + this.contents.height / 2;
var moveAmount = Math.max(1, Math.abs(cap2 - this.y) / 4);
if (this.x > desX) this.y = Math.max(this.y - moveAmount, cap1);
if (this.x < desX) this.y = Math.min(this.y + moveAmount, cap2);
} else if (this.destinationY() !== this.y) {
var desY = this.destinationY();
var moveAmount = Math.max(1, Math.abs(desY - this.y) / 4);
if (this.y > desY) this.y = Math.max(this.y - moveAmount, desY);
if (this.y < desY) this.y = Math.min(this.y + moveAmount, desY);
}
};
with this instead:
Window_TurnOrderIcon.prototype.updatePosition = function() {
if (BattleManager._escaped) return;
if (this._destinationY !== this.y) {
var desY = this._destinationY;
var moveAmount = Math.max(1, Math.abs(desY - this.y) / 4);
if (this.y > desY) this.y = Math.max(this.y - moveAmount, desY);
if (this.y < desY) this.y = Math.min(this.y + moveAmount + 70, desY);
var cap1 = this.destinationX() + this.contents.height / 2;
var cap2 = this.destinationX() - this.contents.height / 2;
var moveAmount = Math.max(1, Math.abs(cap2 - this.y) / 4);
if (this.y > desY) this.x = Math.max(this.x - moveAmount, cap1);
if (this.y < desY) this.x = Math.min(this.x + moveAmount, cap2);
} else if (this.destinationX() !== this.x) {
var desX = this.destinationX();
var moveAmount = Math.max(1, Math.abs(desX - this.x) / 4);
if (this.x < desX) this.x = Math.max(this.x + moveAmount, desX);
if (this.x > desX) this.x = Math.min(this.x - moveAmount, desX);
}
};
(Likewise, if you're editing the X position to be something other than 20, you should change the last bit to be something like:
var moveAmount = Math.max(1, Math.abs(desX - this.x) / 4);
if (this.x > desX) this.x = Math.max(this.x - moveAmount, desX);
if (this.x < desX) this.x = Math.min(this.x + moveAmount, desX);
As it'll look pretty goofy swinging through the screen when you bring up skill/item menus.
In Window_TurnOrderIcon.prototype.aliveMembersSize, change:
var length = members.length;
to:
var length = 6;
Or whatever number you want, really. What changing the number does is limit the amount of icons on screen by scrolling the extras up offscreen. They'll scroll down then their turn has come and scroll offscreen when they're finished.
Go into Game_Temp.prototype.battleTurnOrderAddActionActors and add this condition beneath if (battler.isHidden()) :
if (battler.isStateAffected(163)) continue;
And then do the same thing under AddPerformedActors 's if (battler.isHidden()):
if (battler.isStateAffected(163)) continue;
Replace 163 with your dummy state ID of choice.
Let's say you don't want a certain actor/enemy to show up on the Turn Order for any reason (they're a background object prop or are meant to be a non-physical extension of the player). This check will remove them from the Order lineup, provided you tag said enemy with the state before the fight starts / via a Passive States plugin.
(Small mini-demos that I use to show off mechanics.)
This shows off a few common event functions that I use in my games, such as:
- Quick Swap
- Move Specific Actor to Leader Position
- Auto-facing towards specific actor in your follower caterpillar
- Input Check (ex. [Z] becomes [Enter] if you changed your keyboard, etc.)
- Rare Candy
- Escape Rope
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
(Credit goes to @Poryg for this one) This is a pretty severe fundamental bug that prevents Victor Engine's extremely useful Action Dodge/States function from working. How do you fix it? Well... JavaScript:
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...