Hi,
How do I clear/erase a drawn rectangle?:
Window_Label.prototype.drawDarkRect = function(dx, dy, dw, dh) {
var color = this.textColor(1);
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};
this.createContents();
this.drawDarkRect(0, 0, 600, this.lineHeight());
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
Hi,
How do I clear/erase a drawn rectangle?:
Window_Label.prototype.drawDarkRect = function(dx, dy, dw, dh) {
var color = this.textColor(1);
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};
this.createContents();
this.drawDarkRect(0, 0, 600, this.lineHeight());
myWindow.contents.clearRect(x, y, width, height) -
Is there a way to check if a skill's targeting type is 1 enemy and not anything else?
I want to make a "chance to taunt" state that can redirect skills to the battler that gave it usinguser.currentAction().setTarget(origin.index())but remove the ability to redirect skills that hit random targets or all of them because that wouldn't make sense.
EDIT: solved.
JavaScript:<Custom Action Start Effect> action = user.currentAction(); //if the scope isn't "1 enemy", action._targetIndex = -1 //otherwise, it's the index of the target, 0 or higher if(action._targetIndex >= 0) { if(Math.random() <= 0.5) { //roll for redirection action.setTarget(origin.index()); //we change the target to origin } } </Custom Action Start Effect> -
Is there a way to check if a skill's targeting type is 1 enemy and not anything else?
I want to make a "chance to taunt" state that can redirect skills to the battler that gave it usinguser.currentAction().setTarget(origin.index())but remove the ability to redirect skills that hit random targets or all of them because that wouldn't make sense.
I don't know what plugins you are using, but generally you can check the scope of a skill like this:
JavaScript:$dataSkills[x].scope // scope = 1 is for targeting 1 enemy -
It was all using the Buffs and States Core. I found my own solution in the meantime, so I edited it into my message. It took a lot ofI don't know what plugins you are using, but generally you can check the scope of a skill like this:
JavaScript:$dataSkills[x].scope // scope = 1 is for targeting 1 enemyconsole.log()commands, but despite how hard the console makes everything slow down, I found a way.
Thank you for your time, though. -
With YEP_BattleEngineCore how do I center the battle text?

I hate how it looks on the left but I looked everywhere and I couldn't find an option to switch its position or maybe I'm just a dummy! -
Battle Engine Core (YEP) - Yanfly.moe Wiki Write <CENTER> (case-sensitive, so make sure it's in all caps) anywhere in the message.With YEP_BattleEngineCore how do I center the battle text?
I hate how it looks on the left but I looked everywhere and I couldn't find an option to switch its position or maybe I'm just a dummy! -
@CHKNRAVE That was it thank you very much! I am indeed a dummy. :LZSproud:
-
Hi! I'm looking to inflict an "exhaustion" status on actors when their MP reaches 0. I'm using Yanfly's Skill and States Core, and I'm assuming it could be done with a passive condition switch. I just don't know what would work in the condition box. Any ideas would be appreciated :D (RPG MAKER MZ)
-
Sure, put this state as a passive on whoever can get exhausted this way. In the state's notes, write this:
JavaScript:<Custom Passive Condition> if(user.mp <= 0) { condition = true; } else { condition = false; } </Custom Passive Condition>
EDIT: The code may slightly differ because you're on MZ. Sorry, I didn't catch that in your message. -
Sure, put this state as a passive on whoever can get exhausted this way. In the state's notes, write this:
JavaScript:<Custom Passive Condition> if(user.mp <= 0) { condition = true; } else { condition = false; } </Custom Passive Condition>
EDIT: The code may slightly differ because you're on MZ. Sorry, I didn't catch that in your message.
I’ll give it a try after work and see. Thank you in any case :)
EDIT: Success! Just had to change the brackets
<JS Passive Condition>
if(user.mp <= 0) {
condition = true;
} else {
condition = false;
}
</JS Passive Condition>
Thank you :D -
Hey, two quick questions:
1. Is there a bit of code that can be used to change an events z axis? What I'm trying to achieve is have an event show up above a picture
2. Is there an easy bit of code I can use to "shuffle" a set of 9 variables? (As in, all of the values of these variables are randomly redistributed to one of those 9 variables) -
Hey, two quick questions:
1. Is there a bit of code that can be used to change an events z axis? What I'm trying to achieve is have an event show up above a picture
2. Is there an easy bit of code I can use to "shuffle" a set of 9 variables? (As in, all of the values of these variables are randomly redistributed to one of those 9 variables)
The events and the images that are attached to events are 2 seperate things. What you can do is, take the image of the event and move that to a certain z layer:
SceneManager._scene._spriteset._characterSprites[spriteIndex].z = zLayer;
About shuffling arrays:
I had to look it up, since apparently there is a so called Durstenfeld shuffle method out there. I modified it a little to be able to accept beginning and end indexes within the array to be shuffled.
JavaScript:randomizeVariables = function (startVariable, endVariable) { shuffleArray($gameVariables._data, startVariable, endVariable); } /* Randomize array in-place using modified Durstenfeld shuffle algorithm (modified to accept beginning and end within the array) */ function shuffleArray(array, startIndex, endIndex) { for (let i = endIndex; i >= startIndex; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } }
Ok so once you have that you can simply do:
randomizeVariables(15, 20) // this randomizes variables 15 to 20
That was an interesting task lol
//Edit:
Just realized you may have not even meant the game Variables of MV but just any random variables lol. -
//Edit:
Just realized you may have not even meant the game Variables of MV but just any random variables lol.
Thank you for your help! I have a couple of questions about the two, though.
A bit silly, but could you give me an example of the first one in use? I'm having a hard time figuring out where it should be ran from/it's syntax. To better illustrate what I'm trying to do with it, I'm hoping to run the code from one event, that will make a dozen or so other events on the same map change their Z position to be over pictures.
As for the second, I was indeed talking about MV variables. Something kinda interesting that I'm not sure was intentional or not, it seems that when the variables shuffle, values can show up repeatedly, or not at all. For example, if I'm shuffling variables with values of 1, 2, and 3, the outcome could end up being something like 1 3 3, with 2 being left out. -
Thank you for your help! I have a couple of questions about the two, though.
A bit silly, but could you give me an example of the first one in use? I'm having a hard time figuring out where it should be ran from/it's syntax. To better illustrate what I'm trying to do with it, I'm hoping to run the code from one event, that will make a dozen or so other events on the same map change their Z position to be over pictures.
As for the second, I was indeed talking about MV variables. Something kinda interesting that I'm not sure was intentional or not, it seems that when the variables shuffle, values can show up repeatedly, or not at all. For example, if I'm shuffling variables with values of 1, 2, and 3, the outcome could end up being something like 1 3 3, with 2 being left out.
No problem. Next time please clarify as to how javascript proficient you are so people know whether or not they should respond with extensive instructions or not.
You can always test code in the developer console by pressing F8 when the game is running.
Then click on the "console" tab and enter code.
If you want to run code from an event you simply insert a script (found under the category "advanced") within the event. In that script you insert the code.
Ok, so ignore the last code line I provided, I found a better one that actually works lol:
$gameMap._events[eventId]._priorityType = 2;
So if you for example want to change the z layer of an event with the id 012 you simply use:
$gameMap._events[12]._priorityType = 2;
._priorityType has to be set to 2 to be over the pictures. If that doesn't work, try 3 instead.
For the second issue:
Note that the shuffling only works if the variables are in a consecutive order. You can't shuffle variables 4, 60 and 100. It has to be 1,2,3 or 50,51,52.
If that doesn't solve the problem, please send me a screenshot of how you use it. -
Hello, makers.
Is there a way to make the Map Select Equip plugin work in battle?
I want to give the player the ability to change their current weapon in battle, but from one specific weapon type to the same specific weapon type.
I had the eventing ready, the goal was to give this action a cost so it was all handled by skill calling a common event, but then I reach the plugin commandMapSelectEquip 20 weaponand it's as if the command gets entirely ignored. As if I just pressed Escape, according to how I handle that situation.
Workaround found using events and many hidden items. -
How i can force the Miss Popups?
-
When using the Select Item command script
$gameMessage.setItemChoice(varID, n);, how do I make the game wait for the selection to be made?
I've put the code in a Custom Apply Effect (I'm addicted to these), and theconsole.log()command I put right after (to monitor the new value of the variable) displays 0 (the default value I set up) in the console immediately.
Here's the portion of code where it goes wrong. I'm supposed to process the value of variable number 20 right after that.
JavaScript:$gameVariables.setValue(20, 0); //the default value $gameMessage.add("selection"); //it displays along with the item choice window $gameMessage.setItemChoice(20, 3); //the user has to select a hidden item A $gameParty._interpreter.setWaitMode('message'); //I looked things up and this was supposed to work console.log($gameVariables.value(20)); //that's how it displays a 0 while the item choice window is still open
Note: it's only going to be executed in battle, nowhere else. -
Is there any way I can make the texts and icons on the top bigger and the ones at the bottom smaller?
Image
I know you can change the font in the setting, but that's for all the texts in the game and I'm not sure if I want to make it any lower. Just wanna change the text size in the menu. -
When using the Select Item command script
$gameMessage.setItemChoice(varID, n);, how do I make the game wait for the selection to be made?
I've put the code in a Custom Apply Effect (I'm addicted to these), and theconsole.log()command I put right after (to monitor the new value of the variable) displays 0 (the default value I set up) in the console immediately.
Here's the portion of code where it goes wrong. I'm supposed to process the value of variable number 20 right after that.
JavaScript:$gameVariables.setValue(20, 0); //the default value $gameMessage.add("selection"); //it displays along with the item choice window $gameMessage.setItemChoice(20, 3); //the user has to select a hidden item A $gameParty._interpreter.setWaitMode('message'); //I looked things up and this was supposed to work console.log($gameVariables.value(20)); //that's how it displays a 0 while the item choice window is still open
Note: it's only going to be executed in battle, nowhere else.
If you want the battle scene to wait on you, this could be super difficult if you are not familiar with it.
The battle flow is partially dependent on whether or not a certain window is open or not. As soon as one window closes, the battle process continues until the next window is open. It's very counter-intuitive, I had my fair share of frustration with the battle system.
That being said, I did a quick check to see if there is a simple "pause switch" for the battle scene.
This will probably freeze everything on screen, including your game message, but I think it's worth a shot.
Try setting the battle scene to inactive by using:
SceneManager._scene._active = false;
Then, once the item is chosen set it back to true.
Another possible way could be to go to the Scene_Battle.prototype.update Method and insert a condition for it
to pause the updating whenever you want. I don't know how familliar you are with the core code, let me know and I could help.
Is there any way I can make the texts and icons on the top bigger and the ones at the bottom smaller?
Image
I know you can change the font in the setting, but that's for all the texts in the game and I'm not sure if I want to make it any lower. Just wanna change the text size in the menu.
You can't change that without coding. If you want some guidance on how to do that let me know.