Basically, the Fisher-Yates algorithm ensures that every shuffle outcome is equally likely.
By comparison, you can think of Robro's suggestion as flipping a coin on each pair of values to decide which ones to swap. That makes it increasingly less likely for a value to be moved far from its starting position, which will be more evident with longer lists. It'll also require at least as many swaps as Fisher-Yates...possibly a LOT more depending on how the browser handles unstable sort criteria.
So using Fisher-Yates is probably the simplest option in the long run, unless you want the bias.
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
I've been googling for hours and can't find a solution to this. How can I fill this specific window with white background?
JavaScript:var rect = new Rectangle(0, 0, 200, 200); var dummyWindow = new Window_CreateWindow(rect); SceneManager._scene.addChild(dummyWindow); -
you could try usingHow can I fill this specific window with white background?Code:otherwise i think youd have to make a new windowskin with a white background and then set the window's windowskin property to a bitmap using that new skin
dummyWindow.setTone(255,255,255) -
@SolemnGravity - by default game windows update their tone each frame to match
$gameSystem.windowTone(). That is defined on the System 1 tab in the Database, or per-playthrough via the Change Window Color command.
I assume you're using a plugin to define this new window? In that case, you can define an override for itsupdateTonemethod, e.g.
JavaScript:Or, like Robro suggests, you could assign it a different window skin.Window_CreateWindow.prototype.updateTone = function() { this.setTone(255, 255, 255); }; -
this.setTone(255, 255, 255);This solves my problem. Thanks guys -
Okay, so this is sort of a quasi-necro post but I thought I'd share this since I've been having sleeping nights over this ever since. It's actually stuff in Skills and States Core that does the overwriting. Since HP is also treated as a cost in this plugin, the redraw() of the HP gauge is overwritten with the Visustella version even when you don't have any skills that use HP as a cost.Yup, they overwritten it. And can't seem to find the plugin parameters for this.
So... go into Skill Cost Types, double click the top one (should say HP), scroll down to JS: Draw Gauge and double click, scroll all the way down and then follow Master @ATT_Turan 's instructions:
...simply change the last line to havecurrentValue + '%'
and voila!
-
I did not forget about this, and decided to refactor it somehow like this, always requiring VS and built on logic that states do not stack, but only refresh (without Theo state stacking yet):<JS On Add State>
const drainAmount = Math.randomInt(8) + 1;
target._drainedAttack ??= 0;
target._drainedAttack += drainAmount;
target.addParam(2, -drainAmount);
if (target.atk <= 0) {
target.die();
}
</JS On Add State>
<JS On Erase State>
if (target._drainedAttack) {
target.addParam(2, target._drainedAttack);
delete target._drainedAttack;
}
</JS On Erase State>[/CODE]
JavaScript:<JS On Add State> const paramId = 2; // pick your parameter const percentage = Math.randomInt(15) + 5; // 5-20% drain target._stateDrains ??= {}; target._stateDrains[state.id] ??= []; // this is supposed to be a drain based on base + equipment stat, excluding buffs const baseParam = target.paramBase(paramId) + (target.paramPlus(paramId) || 0); const drainAmount = Math.max(1, Math.round(baseParam * (percentage / 100))); target._stateDrains[state.id].push(drainAmount); target.addParam(paramId, -drainAmount); // once it hits 0, it kills BUT it is also meant to trigger the removal of the effect to prevent permanent state alterations if (target.param(paramId) <= 0) target.die(); </JS On Add State> <JS On Erase State> if (target._stateDrains?.[state.id]?.length > 0) { // this is meant to restore all drained attribute const totalRestore = target._stateDrains[state.id].reduce((sum, value) => sum + value, 0); target.addParam(2, totalRestore); // delete the state itself delete target._stateDrains[state.id]; if (Object.keys(target._stateDrains).length === 0) { delete target._stateDrains; } } </JS On Erase State>
It seems to work properly or semi-properly, but, I wonder if there is a simpler way and if I got the syntax right. I also changed it a bit so that I could re-use it for other parameters, not sure if that was a clever idea or not. -
Quick question: Would it be "easy" to change the way animated autotiles work? Like, using 4 animated frames instead of 3?
-
@TheNewSon - you'd want a plugin. I've made ones for MV & MZ, both called Cae_TileAnimExt (in the "General" spoiler), that allow adjusting tile animation rate and frame order. There's also a lightweight one for MV that only adjusts the rate. There are probably alternatives~
-
Using Yanfly's action sequence, how do I make this sequence only happen when the skill hits?
(Or make it not happen on miss/evade either one works.)
Supposedly you can use if statements but I haven't found a way to make it work after some searching :S
(For reasons I need to have this happen here and cannot do it in the "effects" section.)
(This effect does work right now, but it always triggers regardless of hit or miss)
<follow Action>
remove state 27: target
remove state 28: target
add state 21: target
</follow Action> -
trySupposedly you can use if statements but I haven't found a way to make it work after some searchingCode:
if target.result().isHit() -
Thanks, for some reason I couldn't randomly come across any instance of somebody typing that out lol, I was trying with just Hit instead of isHit xD.tryCode:
if target.result().isHit() -
Hey all, I was wondering if there is a way to make Yanfly's ShopMenuCore have currently equipped items considered "In Possession" for the sake of the shop menu. This confused me during a playtest and it would probably confuse players as well thinking they did not have a piece of equipment even if a character already had it equipped.
-
I think this question deserves its own thread, e.g. in Plugin Support. :kaohi:Hey all, I was wondering if there is a way to make Yanfly's ShopMenuCore have currently equipped items considered "In Possession" for the sake of the shop menu.
-
Guys, I've been trying to use $gameScreen.picture(id).tone() but it's not returning anything... I can grab anything from the picture, like coordinates and opacity, but not the picture's tone. Any ideas why?
Never mind, looks like I'm using it at the wrong moment. -
What does it mean to have 'TypeError Cannot read property 'hitType' of null'?
I was just testing my deployed game on the Steam Deck and on one of my playthroughs, I was suddenly hit by this error after an actor defeats an enemy during battle. I don't know what this error means as I can't open the console on the Steam Deck. I also can't replicate the error on my PC to check where the error is.
Someone help. -
You can always install MZ on the Steam Deck, which will make developing for it easier is a bunch of ways.
Or just enable access to DevTools on deployment (I don't know how to do that on MZ, but I is rather simple on MV).
All that error tells us is that something is trying to access a "hitType" property of a null object. Maybe something trying to use an item/ability that doesn't exist?
Listing which battle-related plugins you're using might also help, but without the rest of the error it will be rather difficult to diagnose anything. -
Thanks. I'll try to install MZ on the deck and hope I can replicate the error.You can always install MZ on the Steam Deck, which will make developing for it easier is a bunch of ways.
Or just enable access to DevTools on deployment (I don't know how to do that on MZ, but I is rather simple on MV).
All that error tells us is that something is trying to access a "hitType" property of a null object. Maybe something trying to use an item/ability that doesn't exist?
Listing which battle-related plugins you're using might also help, but without the rest of the error it will be rather difficult to diagnose anything. -
I'm using MV, and I need to check whether one variable is equal to another variable plus or minus one. In other words, I need to check (as an if statement) if variable1 = variable2+1 some times, and variable1 = variable2-1 other times. As far as I know there isn't a way to do this through basic event commands, so I'll need to use JS. The only way I can think to do this is making 3 versions of variable2, the basic one and two that are one more and one less than it, but with all the different situations that need their own version of variable2, that would result in way way more variables than I'd like to work with. Is there a script or something I could use?
-
It's very possible, but to answer we should know what are those situation that change the check. Are they switch operated?